From 0ffef299a0bed2ccbacafca63414274a102f1a04 Mon Sep 17 00:00:00 2001 From: ahodgkinson Date: Mon, 8 May 2006 22:35:48 +0000 Subject: [PATCH] XFLAIM modifications to use FTK. git-svn-id: https://svn.code.sf.net/p/flaim/code/trunk@383 0109f412-320b-0410-ab79-c3e0c5ffbbe6 --- xflaim/src/btreeinfo.cpp | 61 +- xflaim/src/checksum.cpp | 94 + xflaim/src/f64bitfh.cpp | 915 ----- xflaim/src/f64bitfh.h | 204 -- xflaim/src/f_btpool.h | 2 +- xflaim/src/f_btree.cpp | 13 +- xflaim/src/f_btree.h | 2 +- xflaim/src/f_nici.h | 4 +- xflaim/src/fbtrset.cpp | 11 +- xflaim/src/fbtrset.h | 2 +- xflaim/src/fbuff.cpp | 557 --- xflaim/src/fbuff.h | 276 -- xflaim/src/fcache.h | 838 +---- xflaim/src/fcollate.cpp | 7237 +------------------------------------- xflaim/src/fcollate.h | 563 +-- xflaim/src/fcomfact.cpp | 128 - xflaim/src/fcomfact.h | 53 - xflaim/src/fdbcnfig.cpp | 88 +- xflaim/src/fdbcopy.cpp | 112 +- xflaim/src/fdbremov.cpp | 54 +- xflaim/src/fdbrenam.cpp | 40 +- xflaim/src/fdict.cpp | 188 +- xflaim/src/fdict.h | 17 +- xflaim/src/fdir.h | 157 - xflaim/src/fdllmain.cpp | 76 +- xflaim/src/fdom.cpp | 686 ++-- xflaim/src/fdynbtre.cpp | 12 +- xflaim/src/fdynbuf.h | 2 +- xflaim/src/fdynsset.cpp | 2 +- xflaim/src/fdynsset.h | 4 +- xflaim/src/ffilehdl.cpp | 602 ---- xflaim/src/ffilehdl.h | 260 -- xflaim/src/ffilehdr.cpp | 6 +- xflaim/src/ffilesys.cpp | 927 ----- xflaim/src/ffilesys.h | 173 - xflaim/src/filesys.h | 98 +- xflaim/src/flaimsys.h | 1932 +++++----- xflaim/src/flalloc.cpp | 1798 ---------- xflaim/src/flbackup.cpp | 131 +- xflaim/src/flblddb.cpp | 83 +- xflaim/src/flblksum.cpp | 120 - xflaim/src/flchkdb.cpp | 21 +- xflaim/src/flchkix.cpp | 4 +- xflaim/src/flchktr.cpp | 4 +- xflaim/src/flclose.cpp | 19 +- xflaim/src/flconvrt.cpp | 12 +- xflaim/src/flcreate.cpp | 22 +- xflaim/src/fldbglog.cpp | 2 +- xflaim/src/flerror.cpp | 501 ++- xflaim/src/flerrstr.cpp | 176 - xflaim/src/flfixed.cpp | 2502 ------------- xflaim/src/flfixed.h | 585 --- xflaim/src/flgethdr.cpp | 2 +- xflaim/src/flindex.cpp | 27 +- xflaim/src/flkeyret.cpp | 10 +- xflaim/src/flog.cpp | 392 +-- xflaim/src/flopen.cpp | 224 +- xflaim/src/flprintf.cpp | 769 ---- xflaim/src/flreduce.cpp | 24 +- xflaim/src/flsweep.cpp | 4 +- xflaim/src/fltrbeg.cpp | 14 +- xflaim/src/fltrcmit.cpp | 2 +- xflaim/src/flutil.cpp | 4937 -------------------------- xflaim/src/flverify.cpp | 40 +- xflaim/src/fntable.cpp | 61 +- xflaim/src/fposix.cpp | 1654 --------- xflaim/src/fposix.h | 270 -- xflaim/src/fqeval.cpp | 968 +---- xflaim/src/fqsort.cpp | 48 +- xflaim/src/fquery.cpp | 229 +- xflaim/src/frecread.cpp | 5718 ------------------------------ xflaim/src/frecread.h | 1184 ------- xflaim/src/frestore.cpp | 70 +- xflaim/src/frset.cpp | 1960 ----------- xflaim/src/frset.h | 567 --- xflaim/src/frsetblk.cpp | 1403 -------- xflaim/src/fscursor.cpp | 33 +- xflaim/src/fscursor.h | 4 +- xflaim/src/fslfile.cpp | 10 +- xflaim/src/fslfileu.cpp | 41 +- xflaim/src/fsrvlock.cpp | 18 +- xflaim/src/fsrvlock.h | 8 +- xflaim/src/fstream.cpp | 3345 ------------------ xflaim/src/fstructs.h | 207 +- xflaim/src/fsuperfl.cpp | 414 +-- xflaim/src/fsuperfl.h | 203 +- xflaim/src/fsysdata.cpp | 2244 +++--------- xflaim/src/ftk.h | 3014 ---------------- xflaim/src/ftkdir.cpp | 911 ----- xflaim/src/ftkmem.h | 207 -- xflaim/src/ftkmisc.cpp | 398 --- xflaim/src/ftkpath.cpp | 775 ---- xflaim/src/ftkrand.cpp | 206 -- xflaim/src/ftksem.cpp | 366 -- xflaim/src/ftkthrd.cpp | 1006 ------ xflaim/src/ftkthrd.h | 350 -- xflaim/src/ftktime.cpp | 335 -- xflaim/src/funicode.cpp | 1713 +-------- xflaim/src/fvector.cpp | 123 +- xflaim/src/fwin.cpp | 1674 --------- xflaim/src/fwin.h | 302 -- xflaim/src/fxml.cpp | 770 +--- xflaim/src/fxml.h | 90 +- xflaim/src/fxpath.cpp | 35 +- xflaim/src/fxpath.h | 2 +- xflaim/src/inifile.cpp | 1082 ------ xflaim/src/inifile.h | 141 - xflaim/src/kybldkey.cpp | 220 +- xflaim/src/kybuild.cpp | 139 +- xflaim/src/kycollat.cpp | 2038 +---------- xflaim/src/kyeword.cpp | 12 +- xflaim/src/kyqsort.cpp | 82 +- xflaim/src/kyunlock.cpp | 12 +- xflaim/src/ncache.cpp | 496 +-- xflaim/src/nodeinfo.cpp | 4 +- xflaim/src/recover.cpp | 44 +- xflaim/src/regexp.cpp | 4164 ---------------------- xflaim/src/rfl.cpp | 502 +-- xflaim/src/rfl.h | 8 +- xflaim/src/scache.cpp | 541 +-- xflaim/src/translog.cpp | 18 +- xflaim/src/xflaim.h | 2787 +++++---------- 122 files changed, 5397 insertions(+), 68650 deletions(-) delete mode 100644 xflaim/src/f64bitfh.cpp delete mode 100644 xflaim/src/f64bitfh.h delete mode 100644 xflaim/src/fbuff.cpp delete mode 100644 xflaim/src/fbuff.h delete mode 100644 xflaim/src/fcomfact.cpp delete mode 100644 xflaim/src/fcomfact.h delete mode 100644 xflaim/src/fdir.h delete mode 100644 xflaim/src/ffilehdl.cpp delete mode 100644 xflaim/src/ffilehdl.h delete mode 100644 xflaim/src/ffilesys.cpp delete mode 100644 xflaim/src/ffilesys.h delete mode 100644 xflaim/src/flalloc.cpp delete mode 100644 xflaim/src/flblksum.cpp delete mode 100644 xflaim/src/flerrstr.cpp delete mode 100644 xflaim/src/flfixed.cpp delete mode 100644 xflaim/src/flfixed.h delete mode 100644 xflaim/src/flprintf.cpp delete mode 100644 xflaim/src/flutil.cpp delete mode 100644 xflaim/src/fposix.cpp delete mode 100644 xflaim/src/fposix.h delete mode 100644 xflaim/src/frecread.cpp delete mode 100644 xflaim/src/frecread.h delete mode 100644 xflaim/src/frset.cpp delete mode 100644 xflaim/src/frset.h delete mode 100644 xflaim/src/frsetblk.cpp delete mode 100644 xflaim/src/fstream.cpp delete mode 100644 xflaim/src/ftk.h delete mode 100644 xflaim/src/ftkdir.cpp delete mode 100644 xflaim/src/ftkmem.h delete mode 100644 xflaim/src/ftkmisc.cpp delete mode 100644 xflaim/src/ftkpath.cpp delete mode 100644 xflaim/src/ftkrand.cpp delete mode 100644 xflaim/src/ftksem.cpp delete mode 100644 xflaim/src/ftkthrd.cpp delete mode 100644 xflaim/src/ftkthrd.h delete mode 100644 xflaim/src/ftktime.cpp delete mode 100644 xflaim/src/fwin.cpp delete mode 100644 xflaim/src/fwin.h delete mode 100644 xflaim/src/inifile.cpp delete mode 100644 xflaim/src/inifile.h delete mode 100644 xflaim/src/regexp.cpp diff --git a/xflaim/src/btreeinfo.cpp b/xflaim/src/btreeinfo.cpp index 60f3d5c..dbb92c9 100644 --- a/xflaim/src/btreeinfo.cpp +++ b/xflaim/src/btreeinfo.cpp @@ -200,8 +200,9 @@ RCODE F_BTreeInfo::collectBlockInfo( // Subtract from uiIODataLen - should go to exactly // zero by the time we leave this loop. - uiOADataLen -= (m_uiBlockSize - sizeofDOBlkHdr( pCachedBlock->m_pBlkHdr) - - pCachedBlock->m_pBlkHdr->ui16BlkBytesAvail); + uiOADataLen -= (m_uiBlockSize - + sizeofDOBlkHdr( pCachedBlock->m_pBlkHdr) - + pCachedBlock->m_pBlkHdr->ui16BlkBytesAvail); uiBlkAddr = (FLMUINT)pCachedBlock->m_pBlkHdr->ui32NextBlkInChain; @@ -343,7 +344,8 @@ RCODE F_BTreeInfo::collectBTreeInfo( // Allocate a name buffer. uiNameBufSize = f_strlen( pszName) + 1; - if (RC_BAD( rc = m_pool.poolAlloc( uiNameBufSize, (void **)(&pBTreeInfo->pszLfName)))) + if (RC_BAD( rc = m_pPool->poolAlloc( uiNameBufSize, + (void **)(&pBTreeInfo->pszLfName)))) { goto Exit; } @@ -355,7 +357,8 @@ RCODE F_BTreeInfo::collectBTreeInfo( // Allocate a name buffer. uiNameBufSize++; - if (RC_BAD( rc = m_pool.poolAlloc( uiNameBufSize, (void **)(&pBTreeInfo->pszLfName)))) + if (RC_BAD( rc = m_pPool->poolAlloc( uiNameBufSize, + (void **)(&pBTreeInfo->pszLfName)))) { goto Exit; } @@ -364,8 +367,8 @@ RCODE F_BTreeInfo::collectBTreeInfo( if (RC_BAD( rc = pDb->m_pDict->m_pNameTable->getFromTagTypeAndNum( pDb, pIxd ? ELM_INDEX_TAG : ELM_COLLECTION_TAG, - pLFile->uiLfNum, NULL, pBTreeInfo->pszLfName, &uiNameBufSize, - NULL, NULL, NULL, NULL, TRUE))) + pLFile->uiLfNum, NULL, pBTreeInfo->pszLfName, + &uiNameBufSize, NULL, NULL, NULL, NULL, TRUE))) { goto Exit; } @@ -536,7 +539,7 @@ Desc: Collect b-tree information for an index. If uiIndexNum is zero, If we already have information on the index, we will clear the information and get it again. ****************************************************************************/ -RCODE XFLMAPI F_BTreeInfo::collectIndexInfo( +RCODE FLMAPI F_BTreeInfo::collectIndexInfo( IF_Db * ifpDb, FLMUINT uiIndexNum, IF_BTreeInfoStatus * pInfoStatus) @@ -635,8 +638,8 @@ RCODE XFLMAPI F_BTreeInfo::collectIndexInfo( if (m_uiNumIndexes == m_uiIndexArraySize) { - if (RC_BAD( rc = f_realloc( sizeof( BTREE_INFO) * (m_uiIndexArraySize + 5), - &m_pIndexArray))) + if (RC_BAD( rc = f_realloc( + sizeof( BTREE_INFO) * (m_uiIndexArraySize + 5), &m_pIndexArray))) { goto Exit; } @@ -672,7 +675,7 @@ Desc: Collect b-tree information for a collection. If uiCollectionNum is If we already have information on the collection, we will clear the information and get it again. ****************************************************************************/ -RCODE XFLMAPI F_BTreeInfo::collectCollectionInfo( +RCODE FLMAPI F_BTreeInfo::collectCollectionInfo( IF_Db * ifpDb, FLMUINT uiCollectionNum, IF_BTreeInfoStatus * pInfoStatus) @@ -709,13 +712,15 @@ RCODE XFLMAPI F_BTreeInfo::collectCollectionInfo( m_uiNumCollections = 0; for (;;) { - if ((pCollection = pDb->m_pDict->getNextCollection( uiCollectionNum, TRUE)) == NULL) + if ((pCollection = pDb->m_pDict->getNextCollection( + uiCollectionNum, TRUE)) == NULL) { break; } uiCollectionNum = pCollection->lfInfo.uiLfNum; - if (RC_BAD( rc = collectCollectionInfo( ifpDb, uiCollectionNum, pInfoStatus))) + if (RC_BAD( rc = collectCollectionInfo( + ifpDb, uiCollectionNum, pInfoStatus))) { goto Exit; } @@ -727,7 +732,8 @@ RCODE XFLMAPI F_BTreeInfo::collectCollectionInfo( uiLoop = 0; pCollectionInfo = m_pCollectionArray; - while (uiLoop < m_uiNumCollections && pCollectionInfo->uiLfNum != uiCollectionNum) + while (uiLoop < m_uiNumCollections && + pCollectionInfo->uiLfNum != uiCollectionNum) { uiLoop++; pCollectionInfo++; @@ -739,7 +745,8 @@ RCODE XFLMAPI F_BTreeInfo::collectCollectionInfo( // See if the index is defined in the database - if (RC_BAD( rc = pDb->m_pDict->getCollection( uiCollectionNum, &pCollection, TRUE))) + if (RC_BAD( rc = pDb->m_pDict->getCollection( + uiCollectionNum, &pCollection, TRUE))) { if (rc == NE_XFLM_BAD_COLLECTION) { @@ -771,8 +778,9 @@ RCODE XFLMAPI F_BTreeInfo::collectCollectionInfo( if (m_uiNumCollections == m_uiCollectionArraySize) { - if (RC_BAD( rc = f_realloc( sizeof( BTREE_INFO) * (m_uiCollectionArraySize + 5), - &m_pCollectionArray))) + if (RC_BAD( rc = f_realloc( + sizeof( BTREE_INFO) * (m_uiCollectionArraySize + 5), + &m_pCollectionArray))) { goto Exit; } @@ -805,19 +813,32 @@ Exit: /**************************************************************************** Desc: Create an empty b-tree info. object and return it's interface... ****************************************************************************/ -RCODE XFLMAPI F_DbSystem::createIFBTreeInfo( +RCODE FLMAPI F_DbSystem::createIFBTreeInfo( IF_BTreeInfo ** ppBTreeInfo) { - RCODE rc = NE_XFLM_OK; + RCODE rc = NE_XFLM_OK; + F_BTreeInfo * pBTreeInfo; - if ((*ppBTreeInfo = f_new F_BTreeInfo) == NULL) + if ((pBTreeInfo = f_new F_BTreeInfo) == NULL) { rc = RC_SET( NE_XFLM_MEM); goto Exit; } + if( RC_BAD( rc = pBTreeInfo->setup())) + { + goto Exit; + } + + *ppBTreeInfo = pBTreeInfo; + pBTreeInfo = NULL; + Exit: + if( pBTreeInfo) + { + pBTreeInfo->Release(); + } + return( rc); } - diff --git a/xflaim/src/checksum.cpp b/xflaim/src/checksum.cpp index 5dd364f..557ccb6 100644 --- a/xflaim/src/checksum.cpp +++ b/xflaim/src/checksum.cpp @@ -602,3 +602,97 @@ FLMBYTE RflCalcChecksum( return( (FLMBYTE)uiChecksum); } + +/******************************************************************** +Desc: Calculate the checksum for a block. NOTE: This is ALWAYS done + on the raw image that will be written to disk. This means + that if the block needs to be converted before writing it out, + it should be done before calculating the checksum. +*********************************************************************/ +FLMUINT32 calcBlkCRC( + F_BLK_HDR * pBlkHdr, + FLMUINT uiBlkEnd) +{ + FLMUINT32 ui32SaveCRC; + FLMUINT uiAdds; + FLMUINT uiXORs; + FLMBYTE * pucBlkPtr; + + // Calculate CRC on everything except for the ui32BlkCRC value. + // To do this, we temporarily change it to zero. The saved + // value will be restored after calculating the CRC. + + ui32SaveCRC = pBlkHdr->ui32BlkCRC; + pBlkHdr->ui32BlkCRC = 0; + uiAdds = 0; + uiXORs = 0; + pucBlkPtr = (FLMBYTE *)pBlkHdr; + +#if defined( FLM_NLM) || (defined( FLM_WIN) && !defined( FLM_64BIT)) + + FastBlockCheckSum( pucBlkPtr, &uiAdds, &uiXORs, + (unsigned long)uiBlkEnd); + +#else + + FLMBYTE * pucCur = pucBlkPtr; + FLMBYTE * pucEnd = pucCur + uiBlkEnd; + + while( pucCur < pucEnd) + { + uiAdds += *pucCur; + uiXORs ^= *pucCur++; + } + + uiAdds &= 0xFF; +#endif + + // Restore the CRC that was in the block. + + pBlkHdr->ui32BlkCRC = ui32SaveCRC; + return( (FLMUINT32)((uiAdds << 16) + uiXORs)); +} + +/******************************************************************** +Desc: Calculate the CRC for the database header. +*********************************************************************/ +FLMUINT32 calcDbHdrCRC( + XFLM_DB_HDR * pDbHdr) +{ + FLMUINT32 ui32SaveCRC; + FLMUINT uiAdds; + FLMUINT uiXORs; + FLMBYTE * pucHdr; + + // Checksum everything except for the ui32HdrCRC value. + + ui32SaveCRC = pDbHdr->ui32HdrCRC; + pDbHdr->ui32HdrCRC = 0; + + uiAdds = 0; + uiXORs = 0; + pucHdr = (FLMBYTE *)pDbHdr; + +#if defined( FLM_NLM) || (defined( FLM_WIN) && !defined( FLM_64BIT)) + + FastBlockCheckSum( pucHdr, &uiAdds, &uiXORs, + (unsigned long)sizeof( XFLM_DB_HDR)); + +#else + FLMBYTE * pucCur = pucHdr; + FLMBYTE * pucEnd = pucHdr + sizeof( XFLM_DB_HDR); + + while( pucCur < pucEnd) + { + uiAdds += *pucCur; + uiXORs ^= *pucCur++; + } + + uiAdds &= 0xFF; +#endif + + // Restore the checksum that was in the header + + pDbHdr->ui32HdrCRC = ui32SaveCRC; + return( (FLMUINT32)((uiAdds << 16) + uiXORs)); +} diff --git a/xflaim/src/f64bitfh.cpp b/xflaim/src/f64bitfh.cpp deleted file mode 100644 index 59c1a06..0000000 --- a/xflaim/src/f64bitfh.cpp +++ /dev/null @@ -1,915 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: This file contains the F_64BitFile class -// -// Tabs: 3 -// -// Copyright (c) 2001,2003-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: f64bitfh.cpp 3111 2006-01-19 13:10:50 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -/**************************************************************************** -Desc: -****************************************************************************/ -F_64BitFileHandle::F_64BitFileHandle( - FLMUINT uiMaxFileSize) -{ - m_bOpen = FALSE; - m_szPath[ 0] = 0; - m_ui64EOF = 0; - m_pLockFileHdl = NULL; - f_memset( m_pFileHdlList, 0, sizeof( FH_INFO) * F_64BIT_FHDL_LIST_SIZE); - m_uiMaxFileSize = uiMaxFileSize; - if( !m_uiMaxFileSize) - { - m_uiMaxFileSize = F_64BIT_FHDL_DEFAULT_MAX_FILE_SIZE; - } -} - -/**************************************************************************** -Desc: -****************************************************************************/ -F_64BitFileHandle::~F_64BitFileHandle() -{ - if( m_bOpen) - { - Close(); - } - - flmAssert( !m_pLockFileHdl); -} - -/**************************************************************************** -Desc: Closes all data files associated with the object -****************************************************************************/ -void F_64BitFileHandle::Close( - FLMBOOL bDelete) -{ - FLMUINT uiLoop; - IF_DirHdl * pDir = NULL; - char szTmpPath[ F_PATH_MAX_SIZE]; - RCODE rc = NE_XFLM_OK; - - if( !m_bOpen) - { - return; - } - - for( uiLoop = 0; uiLoop < F_64BIT_FHDL_LIST_SIZE; uiLoop++) - { - if( m_pFileHdlList[ uiLoop].pFileHdl) - { - if( m_pFileHdlList[ uiLoop].bDirty) - { - (void)m_pFileHdlList[ uiLoop].pFileHdl->Flush(); - } - m_pFileHdlList[ uiLoop].pFileHdl->Close(); - m_pFileHdlList[ uiLoop].pFileHdl->Release(); - f_memset( &m_pFileHdlList[ uiLoop], 0, sizeof( FH_INFO)); - } - } - - m_ui64EOF = 0; - m_bOpen = FALSE; - - if( bDelete) - { - if( RC_OK( gv_pFileSystem->OpenDir( - m_szPath, "*.64", &pDir))) - { - /* - Remove all data files - */ - - for( rc = pDir->Next(); !RC_BAD( rc) ; rc = pDir->Next() ) - { - pDir->CurrentItemPath( szTmpPath); - flmAssert( f_strstr( szTmpPath, ".64") != 0); - (void)gv_pFileSystem->Delete( szTmpPath); - } - - pDir->Release(); - pDir = NULL; - } - - /* - Release and delete the lock file - */ - - (void)ReleaseLockFile( m_szPath, TRUE); - - /* - Remove the directory - */ - - (void)gv_pFileSystem->RemoveDir( m_szPath); - } - else - { - (void)ReleaseLockFile( m_szPath, FALSE); - } -} - -/**************************************************************************** -Desc: Removes a 64-bit file -****************************************************************************/ -RCODE F_64BitFileHandle::Delete( - const char * pszPath) -{ - IF_DirHdl * pDir = NULL; - char szTmpPath[ F_PATH_MAX_SIZE]; - RCODE rc = NE_XFLM_OK; - - // Can't use this handle to delete something if we already - // have a file open. - - if( m_bOpen) - { - - // Can't jump to exit, because it calls ReleaseLockFile - - return( RC_SET_AND_ASSERT( NE_XFLM_FAILURE)); - } - - if( RC_BAD( rc = gv_pFileSystem->Exists( pszPath))) - { - goto Exit; - } - - if( !gv_pFileSystem->IsDir( pszPath)) - { - /* - If the path specifies a single file rather than a - 64-bit directory, just go ahead and delete the file. - */ - - rc = gv_pFileSystem->Delete( pszPath); - goto Exit; - } - - if( RC_BAD( rc = CreateLockFile( pszPath))) - { - goto Exit; - } - - if( RC_OK( gv_pFileSystem->OpenDir( pszPath, "*.64", &pDir))) - { - /* - Remove all data files - */ - - for( rc = pDir->Next(); !RC_BAD( rc) ; rc = pDir->Next()) - { - pDir->CurrentItemPath( szTmpPath); - flmAssert( f_strstr( szTmpPath, ".64") != 0); - (void)gv_pFileSystem->Delete( szTmpPath); - } - - pDir->Release(); - pDir = NULL; - rc = NE_XFLM_OK; - } - - /* - Release and delete the lock file - */ - - (void)ReleaseLockFile( pszPath, TRUE); - - /* - Remove the directory - */ - - (void)gv_pFileSystem->RemoveDir( pszPath); - -Exit: - - (void)ReleaseLockFile( pszPath, FALSE); - - return( rc); -} - -/**************************************************************************** -Desc: Creates a new 64-bit "file" -****************************************************************************/ -RCODE F_64BitFileHandle::Create( - const char * pszPath) -{ - FLMBOOL bCreatedDir = FALSE; - RCODE rc = NE_XFLM_OK; - - if( m_bOpen) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_FAILURE); - goto Exit; - } - - if( RC_BAD( rc = gv_pFileSystem->CreateDir( pszPath))) - { - goto Exit; - } - - f_strcpy( m_szPath, pszPath); - bCreatedDir = TRUE; - - /* - Create the lock file - */ - - if( RC_BAD( rc = CreateLockFile( m_szPath))) - { - goto Exit; - } - - /* - Initialize the EOF to 0 and set the state to open - */ - - m_ui64EOF = 0; - m_bOpen = TRUE; - -Exit: - - /* - Release the lock file - */ - - if( RC_BAD( rc)) - { - (void)ReleaseLockFile( m_szPath, TRUE); - if( bCreatedDir) - { - (void)gv_pFileSystem->RemoveDir( m_szPath); - } - } - - return( rc); -} - -/**************************************************************************** -Desc: Creates a new 64-bit file with a unique, generated name -****************************************************************************/ -RCODE F_64BitFileHandle::CreateUnique( - const char * pszPath, // Directory where the file is to be created - const char * pszFileExtension) // Extension to be used on the new file. -{ - FLMUINT uiCount; - FLMBOOL bModext = TRUE; - FLMBOOL bCreatedDir = FALSE; - FLMUINT uiBaseTime = 0; - FLMBYTE ucHighByte = 0; - char szDirName[ F_FILENAME_SIZE]; - char szTmpPath[ F_PATH_MAX_SIZE]; - char szBasePath[ F_PATH_MAX_SIZE]; - RCODE rc = NE_XFLM_OK; - - if( m_bOpen) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_FAILURE); - goto Exit; - } - - if( !pszPath || pszPath[ 0] == '\0') - { -#if defined( FLM_UNIX) - f_strcpy( szBasePath, "./"); -#elif defined( FLM_NLM) - f_strcpy( szBasePath, "SYS:_NETWARE"); -#else - szBasePath[ 0] = '\0'; -#endif - } - else - { - f_strcpy( szBasePath, pszPath); - } - - if ((pszFileExtension) && (f_strlen( pszFileExtension) >= 3)) - { - bModext = FALSE; - } - - uiCount = 0; - szDirName[ 0] = '\0'; - do - { - gv_pFileSystem->pathCreateUniqueName( &uiBaseTime, szDirName, pszFileExtension, - &ucHighByte, bModext); - - f_strcpy( szTmpPath, szBasePath); - gv_pFileSystem->pathAppend( szTmpPath, szDirName); - rc = gv_pFileSystem->CreateDir( szTmpPath); - } while ((rc != NE_XFLM_OK) && (uiCount++ < 20)); - - if( RC_BAD( rc)) - { - goto Exit; - } - - f_strcpy( m_szPath, szTmpPath); - bCreatedDir = TRUE; - - /* - Create the lock file - */ - - if( RC_BAD( rc = CreateLockFile( m_szPath))) - { - goto Exit; - } - - /* - Initialize the EOF to 0 and set the state to open - */ - - m_ui64EOF = 0; - m_bOpen = TRUE; - -Exit: - - /* - Release the lock file - */ - - if( RC_BAD( rc)) - { - ReleaseLockFile( m_szPath, TRUE); - - if( bCreatedDir) - { - (void)gv_pFileSystem->RemoveDir( m_szPath); - } - } - - return( rc); -} - -/**************************************************************************** -Desc: Opens an existing 64-bit file -****************************************************************************/ -RCODE F_64BitFileHandle::Open( - const char * pszPath) -{ - IF_DirHdl * pDir = NULL; - FLMUINT uiTmp; - FLMUINT uiHighFileNum = 0; - FLMUINT64 ui64HighOffset = 0; - RCODE rc = NE_XFLM_OK; - - if( m_bOpen) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_FAILURE); - goto Exit; - } - - if( RC_BAD( gv_pFileSystem->Exists( pszPath)) || - !gv_pFileSystem->IsDir( pszPath)) - { - rc = RC_SET( NE_XFLM_IO_PATH_NOT_FOUND); - goto Exit; - } - - f_strcpy( m_szPath, pszPath); - - /* - Create the lock file - */ - - if( RC_BAD( rc = CreateLockFile( m_szPath))) - { - goto Exit; - } - - /* - Need to determine the current EOF - */ - - if( RC_BAD( rc = gv_pFileSystem->OpenDir( - m_szPath, (char *)"*.64", &pDir))) - { - goto Exit; - } - - /* - Find all data files to determine the EOF - */ - - for( rc = pDir->Next(); !RC_BAD( rc) ; rc = pDir->Next() ) - { - if( RC_OK( GetFileNum( pDir->CurrentItemName(), &uiTmp))) - { - if( uiTmp >= uiHighFileNum) - { - uiHighFileNum = uiTmp; - ui64HighOffset = pDir->CurrentItemSize(); - } - } - } - rc = NE_XFLM_OK; - - m_ui64EOF = (((FLMUINT64)uiHighFileNum) * m_uiMaxFileSize) + ui64HighOffset; - m_bOpen = TRUE; - -Exit: - - if( pDir) - { - pDir->Release(); - } - - /* - Release the lock file - */ - - if( RC_BAD( rc)) - { - ReleaseLockFile( m_szPath, FALSE); - } - - return( rc); -} - -/**************************************************************************** -Desc: Flushes cached data to the data file(s) -****************************************************************************/ -RCODE F_64BitFileHandle::Flush( void) -{ - FLMUINT uiLoop; - RCODE rc = NE_XFLM_OK; - - if( !m_bOpen) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_FAILURE); - goto Exit; - } - - for( uiLoop = 0; uiLoop < F_64BIT_FHDL_LIST_SIZE; uiLoop++) - { - if( m_pFileHdlList[ uiLoop].bDirty) - { - if( RC_BAD( rc = m_pFileHdlList[ uiLoop].pFileHdl->Flush())) - { - goto Exit; - } - m_pFileHdlList[ uiLoop].bDirty = FALSE; - } - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Reads data from the file -****************************************************************************/ -RCODE F_64BitFileHandle::Read( - FLMUINT64 ui64Offset, // Offset to begin reading - FLMUINT uiLength, // Number of bytes to read - void * pvBuffer, // Buffer - FLMUINT * puiBytesRead) // [out] Number of bytes read -{ - FLMUINT uiFileNum = GetFileNum( ui64Offset); - FLMUINT uiFileOffset = GetFileOffset( ui64Offset); - FLMUINT uiTmp; - FLMUINT uiTotalBytesRead = 0; - FLMUINT uiBytesToRead; - FLMUINT uiMaxReadLen; - IF_FileHdl * pFileHdl; - RCODE rc = NE_XFLM_OK; - - /* - Handle the case of a 0-byte read - */ - - if( !uiLength) - { - if( ui64Offset >= m_ui64EOF) - { - rc = RC_SET( NE_XFLM_IO_END_OF_FILE); - } - goto Exit; - } - - /* - Read the data file(s), moving to new files as needed. - */ - - for( ;;) - { - if( ui64Offset >= m_ui64EOF) - { - rc = RC_SET( NE_XFLM_IO_END_OF_FILE); - goto Exit; - } - - uiMaxReadLen = m_uiMaxFileSize - uiFileOffset; - flmAssert( uiMaxReadLen != 0); - uiTmp = (uiLength >= uiMaxReadLen ? uiMaxReadLen : uiLength); - uiBytesToRead = (((FLMUINT64)uiTmp > (FLMUINT64)(m_ui64EOF - ui64Offset)) - ? (FLMUINT)(m_ui64EOF - ui64Offset) - : uiTmp); - - if( RC_BAD( rc = GetFileHdl( uiFileNum, FALSE, &pFileHdl))) - { - if( rc == NE_XFLM_IO_PATH_NOT_FOUND) - { - /* - Handle the case of a sparse file by filling the unread - portion of the buffer with zeros. - */ - - f_memset( pvBuffer, 0, uiBytesToRead); - uiTmp = uiBytesToRead; - rc = NE_XFLM_OK; - } - else - { - goto Exit; - } - } - else - { - if( RC_BAD( rc = pFileHdl->Read( uiFileOffset, uiBytesToRead, - pvBuffer, &uiTmp))) - { - if( rc == NE_XFLM_IO_END_OF_FILE) - { - /* - Handle the case of a sparse file by filling the unread - portion of the buffer with zeros. - */ - - f_memset( &(((FLMBYTE *)(pvBuffer))[ uiTmp]), - 0, (FLMUINT)(uiBytesToRead - uiTmp)); - uiTmp = uiBytesToRead; - rc = NE_XFLM_OK; - } - else - { - goto Exit; - } - } - } - - uiTotalBytesRead += uiTmp; - uiLength -= uiTmp; - if( !uiLength) - { - break; - } - - /* - Set up for next read - */ - - pvBuffer = ((FLMBYTE *)pvBuffer) + uiTmp; - ui64Offset += uiTmp; - uiFileNum = GetFileNum( ui64Offset); - uiFileOffset = GetFileOffset( ui64Offset); - } - -Exit: - - *puiBytesRead = uiTotalBytesRead; - return( rc); -} - -/**************************************************************************** -Desc: Writes data to the file -****************************************************************************/ -RCODE F_64BitFileHandle::Write( - FLMUINT64 ui64Offset, // Offset - FLMUINT uiLength, // Number of bytes to write. - void * pvBuffer, // Buffer that contains bytes to be written - FLMUINT * puiBytesWritten) // Number of bytes written. -{ - FLMUINT uiFileNum = GetFileNum( ui64Offset); - FLMUINT uiFileOffset = GetFileOffset( ui64Offset); - FLMUINT uiTmp; - FLMUINT uiTotalBytesWritten = 0; - FLMUINT uiBytesToWrite; - FLMUINT uiMaxWriteLen; - IF_FileHdl * pFileHdl; - RCODE rc = NE_XFLM_OK; - - /* - Don't allow zero-length writes - */ - - flmAssert( uiLength); - - /* - Write to the data file(s), moving to new files as needed. - */ - - for( ;;) - { - if( RC_BAD( rc = GetFileHdl( uiFileNum, TRUE, &pFileHdl))) - { - goto Exit; - } - - uiMaxWriteLen = m_uiMaxFileSize - uiFileOffset; - flmAssert( uiMaxWriteLen != 0); - uiBytesToWrite = uiLength >= uiMaxWriteLen ? uiMaxWriteLen : uiLength; - - uiTmp = 0; - rc = pFileHdl->Write( uiFileOffset, uiBytesToWrite, pvBuffer, &uiTmp); - - uiTotalBytesWritten += uiTmp; - uiLength -= uiTmp; - ui64Offset += uiTmp; - - if( RC_BAD( rc)) - { - goto Exit; - } - - if( !uiLength) - { - break; - } - - /* - Set up for next write - */ - - pvBuffer = ((FLMBYTE *)pvBuffer) + uiTmp; - uiFileNum = GetFileNum( ui64Offset); - uiFileOffset = GetFileOffset( ui64Offset); - } - -Exit: - - if( ui64Offset > m_ui64EOF) - { - m_ui64EOF = ui64Offset; - } - - *puiBytesWritten = uiTotalBytesWritten; - return( rc); -} - -/**************************************************************************** -Desc: Returns the requested file handle -****************************************************************************/ -RCODE F_64BitFileHandle::GetFileHdl( - FLMUINT uiFileNum, - FLMBOOL bGetForWrite, - IF_FileHdl ** ppFileHdl) -{ - FLMUINT uiSlot; - IF_FileHdl * pTmpHdl; - char szPath[ F_PATH_MAX_SIZE]; - RCODE rc = NE_XFLM_OK; - - flmAssert( m_bOpen); - - *ppFileHdl = NULL; - - uiSlot = uiFileNum % F_64BIT_FHDL_LIST_SIZE; - pTmpHdl = m_pFileHdlList[ uiSlot].pFileHdl; - - if( pTmpHdl && m_pFileHdlList[ uiSlot].uiFileNum != uiFileNum) - { - if( RC_BAD( rc = pTmpHdl->Flush())) - { - goto Exit; - } - - pTmpHdl->Close(); - pTmpHdl->Release(); - pTmpHdl = NULL; - - f_memset( &m_pFileHdlList[ uiSlot], 0, sizeof( FH_INFO)); - } - - if( !pTmpHdl) - { - DataFilePath( uiFileNum, szPath); - if( RC_BAD( rc = gv_pFileSystem->Open( szPath, XFLM_IO_RDWR, &pTmpHdl))) - { - if( rc == NE_XFLM_IO_PATH_NOT_FOUND && bGetForWrite) - { - if( RC_BAD( rc = gv_pFileSystem->Create( szPath, - XFLM_IO_RDWR, &pTmpHdl))) - { - goto Exit; - } - } - else - { - goto Exit; - } - } - - m_pFileHdlList[ uiSlot].pFileHdl = pTmpHdl; - m_pFileHdlList[ uiSlot].uiFileNum = uiFileNum; - flmAssert( !m_pFileHdlList[ uiSlot].bDirty); - } - - *ppFileHdl = m_pFileHdlList[ uiSlot].pFileHdl; - if( bGetForWrite) - { - m_pFileHdlList[ uiSlot].bDirty = TRUE; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Given a data file name, returns the file's number -****************************************************************************/ -RCODE F_64BitFileHandle::GetFileNum( - const char * pszFileName, - FLMUINT * puiFileNum) -{ - FLMUINT uiCnt = 0; - FLMUINT uiDigit; - FLMUINT uiFileNum = 0; - RCODE rc = NE_XFLM_OK; - - if( f_strlen( pszFileName) != 11) // XXXXXXXX.64 - { - rc = RC_SET( NE_XFLM_IO_INVALID_FILENAME); - goto Exit; - } - - if( f_strcmp( &pszFileName[ 8], ".64") != 0) - { - rc = RC_SET( NE_XFLM_IO_INVALID_FILENAME); - goto Exit; - } - - while( uiCnt < 8) - { - uiDigit = pszFileName[ uiCnt]; - if( uiDigit >= NATIVE_LOWER_A && uiDigit <= NATIVE_LOWER_F) - { - uiDigit = (FLMUINT)(uiDigit - NATIVE_LOWER_A) + 10; - } - else if( uiDigit >= NATIVE_UPPER_A && uiDigit <= NATIVE_UPPER_F) - { - uiDigit = (FLMUINT)(uiDigit - NATIVE_UPPER_A) + 10; - } - else if( uiDigit >= NATIVE_ZERO && uiDigit <= NATIVE_NINE) - { - uiDigit -= NATIVE_ZERO; - } - else - { - /* - Invalid character found in the file name - */ - - rc = RC_SET( NE_XFLM_IO_INVALID_FILENAME); - goto Exit; - } - - uiFileNum <<= 4; - uiFileNum += uiDigit; - uiCnt++; - } - - *puiFileNum = uiFileNum; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: This routine obtains exclusive access to a 64-bit file by creating - a .lck file. The object holds the .lck file open as long as the - 64-bit file is open. -****************************************************************************/ -RCODE F_64BitFileHandle::CreateLockFile( - const char * pszBasePath) -{ - RCODE rc = NE_XFLM_OK; - char szLockPath [F_PATH_MAX_SIZE]; - F_FileHdl * pLockFileHdl = NULL; - - f_strcpy( szLockPath, pszBasePath); - gv_pFileSystem->pathAppend( szLockPath, "64.LCK"); - - /* - Attempt to create the lock file. If it fails, the lock file - may have been left because of a crash. Hence, we first try - to delete the file. If that succeeds, we then attempt to - create the file again. If it, or the 2nd create fail, we simply - return an access denied error. - */ - - if ((pLockFileHdl = f_new F_FileHdl) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - -#ifndef FLM_UNIX - pLockFileHdl->setupFileHdl( 0, TRUE); -#else - - // On Unix, we do not want to delete the file because it - // will succeed even if someone else has the file open. - - pLockFileHdl->setupFileHdl( 0, FALSE); -#endif - - if( RC_BAD( pLockFileHdl->Create( szLockPath, - XFLM_IO_RDWR | XFLM_IO_EXCL | XFLM_IO_SH_DENYRW))) - { -#ifndef FLM_UNIX - if (RC_BAD( gv_pFileSystem->Delete( szLockPath))) - { - rc = RC_SET( NE_XFLM_IO_ACCESS_DENIED); - goto Exit; - } - else if (RC_BAD( pLockFileHdl->Create( szLockPath, - XFLM_IO_RDWR | XFLM_IO_EXCL | - XFLM_IO_SH_DENYRW))) - { - rc = RC_SET( NE_XFLM_IO_ACCESS_DENIED); - goto Exit; - } -#else - - if( RC_BAD( pLockFileHdl->Open( szLockPath, - XFLM_IO_RDWR | XFLM_IO_SH_DENYRW))) - { - rc = RC_SET( NE_XFLM_IO_ACCESS_DENIED); - goto Exit; - } -#endif - } - -#ifdef FLM_UNIX - if( RC_BAD( pLockFileHdl->Lock())) - { - rc = RC_SET( NE_XFLM_IO_ACCESS_DENIED); - goto Exit; - } -#endif - - m_pLockFileHdl = pLockFileHdl; - pLockFileHdl = NULL; - -Exit: - - if (pLockFileHdl) - { - (void)pLockFileHdl->Close(); - pLockFileHdl->Release(); - pLockFileHdl = NULL; - } - return( rc); -} - -/**************************************************************************** -Desc: This is a private method that will truncate the spill file back to - the specified size. -****************************************************************************/ -RCODE F_64BitFileHandle::Truncate( - FLMUINT64 ui64NewSize - ) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiFileNum = GetFileNum( ui64NewSize); - IF_FileHdl * pFileHdl; - - if( RC_BAD( rc = GetFileHdl( uiFileNum, TRUE, &pFileHdl))) - { - goto Exit; - } - - if (RC_BAD( rc = pFileHdl->Truncate( GetFileOffset( ui64NewSize)))) - { - goto Exit; - } - -Exit: - - return rc; - -} diff --git a/xflaim/src/f64bitfh.h b/xflaim/src/f64bitfh.h deleted file mode 100644 index 26483db..0000000 --- a/xflaim/src/f64bitfh.h +++ /dev/null @@ -1,204 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: FLAIM's 64-bit file abstraction class -// -// Tabs: 3 -// -// Copyright (c) 2001-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: f64bitfh.h 3108 2006-01-19 13:05:19 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#ifndef F64BITFH_H -#define F64BITFH_H - -#define F_64BIT_FHDL_LIST_SIZE 8 -#define F_64BIT_FHDL_DEFAULT_MAX_FILE_SIZE ((FLMUINT)0xFFFFFFFF) - -typedef struct -{ - IF_FileHdl * pFileHdl; - FLMUINT uiFileNum; - FLMBOOL bDirty; -} FH_INFO; - -/*=========================================================================== -Desc: This object is used to simulate a 64-bit file system. -===========================================================================*/ -class F_64BitFileHandle : public XF_RefCount, public XF_Base -{ -public: - - F_64BitFileHandle( // Constructor - FLMUINT uiMaxFileSize = F_64BIT_FHDL_DEFAULT_MAX_FILE_SIZE); - - ~F_64BitFileHandle(); // Destructor - - void Close( // Close a file - The destructor will call this - FLMBOOL bDelete = FALSE); - - - RCODE Create( - const char * pszPath); // File to be created (creates a directory for - // the data files) - - RCODE CreateUnique( // Create a new file (with a unique file name -- - // creates a directory for the data files). - const char * pszPath, // Directory where the file is to be created - const char * pszFileExtension); // Extension to be used on the new file. - - RCODE Delete( // Delete a file - const char * pszPath); - - RCODE Open( // Initiates access to an existing file. - const char * pszPath); // File to be opened (specifies the data - // file directory). - - RCODE Flush( void); // Flushes a file's buffers to disk - - RCODE Read( // Reads a buffer of data from a file - FLMUINT64 ui64Offset, // Offset to begin reading - FLMUINT uiLength, // Number of bytes to read - void * pvBuffer, // Buffer - FLMUINT * puiBytesRead); // [out] Number of bytes read - - RCODE Write( // Writes a buffer of data to a file. - FLMUINT64 ui64Offset, // Offset - FLMUINT uiLength, // Number of bytes to write. - void * pvBuffer, // Buffer that contains bytes to be written - FLMUINT * puiBytesWritten); // Number of bytes written. - - RCODE GetPath( // Returns the full path to the data file - // directory - char * pszFilePath); - - FINLINE RCODE Size( - FLMUINT64 * pui64FileSize) - { - *pui64FileSize = m_ui64EOF; - return( NE_XFLM_OK); - } - - RCODE Truncate( - FLMUINT64 ui64NewSize); - -private: - - /* - Methods - */ - - RCODE GetFileHdl( // Get / Open / Create data file - FLMUINT uiFileNum, - FLMBOOL bGetForWrite, - IF_FileHdl ** ppFileHdl); - - RCODE CreateLockFile( // Creates a lock file for exclusive - // access to the 64-bit file. This is - // necessary since this object maintains - // an in-memory EOF offset. - const char * pszBasePath); - - FINLINE void ReleaseLockFile( - const char * pszBasePath, - FLMBOOL bDelete) - { -#ifndef FLM_UNIX - F_UNREFERENCED_PARM( bDelete); - F_UNREFERENCED_PARM( pszBasePath); -#endif - - if( m_pLockFileHdl) - { - - // Release the lock file - - (void)m_pLockFileHdl->Close(); - m_pLockFileHdl->Release(); - m_pLockFileHdl = NULL; - -#ifdef FLM_UNIX - if( bDelete) - { - char szTmpPath[ F_PATH_MAX_SIZE]; - - // Delete the lock file - - f_strcpy( szTmpPath, pszBasePath); - gv_pFileSystem->pathAppend( szTmpPath, "64.LCK"); - gv_pFileSystem->Delete( szTmpPath); - } -#endif - } - } - - /*=========================================================================== - Private: FormatFileNum - Desc: Formats the file number into a string using characters 0 - 9 and - a - z - ===========================================================================*/ - FINLINE void FormatFileNum( - FLMUINT uiFileNum, - char * pszStr) - { - f_sprintf( pszStr, "%08X.64", (unsigned)uiFileNum); - } - - RCODE GetFileNum( - const char * pszFileName, - FLMUINT * puiFileNum); - - /*=========================================================================== - Private: DataFilePath - Desc: Returns the specified data file's path - ===========================================================================*/ - FINLINE void DataFilePath( - FLMUINT uiFileNum, - char * pszPath) - { - char szFileName[ 13]; - - f_strcpy( pszPath, m_szPath); - FormatFileNum( uiFileNum, szFileName); - gv_pFileSystem->pathAppend( pszPath, szFileName); - } - - FINLINE FLMUINT GetFileNum( - FLMUINT64 ui64Offset) - { - return( (FLMUINT)(ui64Offset / m_uiMaxFileSize)); - } - - FINLINE FLMUINT GetFileOffset( - FLMUINT64 ui64Offset) - { - return( (FLMUINT)(ui64Offset % m_uiMaxFileSize)); - } - - /* - Data - */ - - FH_INFO m_pFileHdlList[ F_64BIT_FHDL_LIST_SIZE]; - char m_szPath[ F_PATH_MAX_SIZE]; // Data file directory path - FLMBOOL m_bOpen; - FLMUINT64 m_ui64EOF; - FLMUINT m_uiMaxFileSize; - IF_FileHdl * m_pLockFileHdl; -}; - -#endif // #ifndef F64BITFH_H diff --git a/xflaim/src/f_btpool.h b/xflaim/src/f_btpool.h index 3c9fe73..063cf43 100644 --- a/xflaim/src/f_btpool.h +++ b/xflaim/src/f_btpool.h @@ -28,7 +28,7 @@ #include "f_btree.h" -class F_BtPool : public XF_RefCount, public XF_Base +class F_BtPool : public F_Object { public: F_BtPool( void) diff --git a/xflaim/src/f_btree.cpp b/xflaim/src/f_btree.cpp index 7bb8010..3705178 100644 --- a/xflaim/src/f_btree.cpp +++ b/xflaim/src/f_btree.cpp @@ -545,9 +545,6 @@ RCODE btFreeBlockChain( { uiStatusCounter = 0; if( RC_BAD( rc = ifpDeleteStatus->reportDelete( - pLFile->uiLfNum, pLFile->eLfType == XFLM_LF_INDEX - ? TRUE - : FALSE, uiTreeBlocksFreed + uiDataBlocksFreed, pDatabase->getBlockSize()))) { @@ -917,7 +914,7 @@ RCODE F_Btree::btReplaceEntry( RCODE rc = NE_XFLM_OK; FLMBYTE * pucEntry; F_BLK_HDR * pBlkHdr; - const FLMBYTE * pucLocalData; + const FLMBYTE * pucLocalData = NULL; FLMUINT uiOADataLength = 0; FLMBYTE pucDOAddr[ 4]; @@ -2781,11 +2778,9 @@ RCODE F_Btree::createNewLevel( void) pRootStack->pBlkHdr->ui16NumKeys++; - pRootStack->pBlkHdr->stdBlkHdr.ui16BlkBytesAvail -= - (FLMUINT16)(uiEntrySize + 2); + pRootStack->pBlkHdr->stdBlkHdr.ui16BlkBytesAvail -= (FLMUINT16)uiEntrySize + 2; - pRootStack->pBlkHdr->ui16HeapSize -= - (FLMUINT16)(uiEntrySize + 2); + pRootStack->pBlkHdr->ui16HeapSize -= (FLMUINT16)uiEntrySize + 2; m_uiStackLevels++; m_uiRootLevel++; @@ -4613,7 +4608,7 @@ FLMUINT F_Btree::getEntryKeyLength( const FLMBYTE ** ppucKeyRV) { FLMUINT uiKeyLength; - FLMBYTE * pucTmp; + FLMBYTE * pucTmp = NULL; // The way we get the key length depends on the type of block we have. diff --git a/xflaim/src/f_btree.h b/xflaim/src/f_btree.h index a65dfd9..33bb279 100644 --- a/xflaim/src/f_btree.h +++ b/xflaim/src/f_btree.h @@ -259,7 +259,7 @@ typedef struct class F_BtPool; -class F_Btree : public XF_RefCount, public XF_Base +class F_Btree : public F_Object { public: diff --git a/xflaim/src/f_nici.h b/xflaim/src/f_nici.h index 0a38e31..27aa1d0 100644 --- a/xflaim/src/f_nici.h +++ b/xflaim/src/f_nici.h @@ -65,7 +65,7 @@ /*----------------------------------------------------------------------- * CCS Interface. *-----------------------------------------------------------------------*/ -class IF_CCS +class IF_CCS : public F_Object { public: @@ -97,7 +97,7 @@ public: -class F_CCS : public IF_CCS, public XF_Base, public XF_RefCount +class F_CCS : public IF_CCS { public: diff --git a/xflaim/src/fbtrset.cpp b/xflaim/src/fbtrset.cpp index 8d98900..f4da94d 100644 --- a/xflaim/src/fbtrset.cpp +++ b/xflaim/src/fbtrset.cpp @@ -70,7 +70,7 @@ RCODE F_BtResultSet::getBTree( RCODE rc = NE_XFLM_OK; FLMUINT uiCollHash; BT_COLLECTION_XREF * pCollPtr = NULL; - F_RandomGenerator * pRandGen = NULL; + IF_RandomGenerator * pRandGen = NULL; F_Database * pDatabase; FLMUINT uiCollection; @@ -106,14 +106,13 @@ RCODE F_BtResultSet::getBTree( pDatabase = m_pResultSetDb->m_pDatabase; // Will need a random number generator. - - if (( pRandGen = f_new F_RandomGenerator) == NULL) + + if( RC_BAD( rc = FlmAllocRandomGenerator( &pRandGen))) { - rc = RC_SET( NE_XFLM_MEM); goto Exit; } - pRandGen->randomSetSeed( (FLMINT32)pSrcIxd->uiIndexNum); + pRandGen->setSeed( (FLMINT32)pSrcIxd->uiIndexNum); // Allocate a new collection key context and create a new // collection for it. @@ -133,7 +132,7 @@ TryAgain: // Randomly select a collection number to use. - uiCollection = pRandGen->randomChoice( 100, XFLM_MAX_COLLECTION_NUM); + uiCollection = pRandGen->getINT32( 100, XFLM_MAX_COLLECTION_NUM); // Check to see if it already exists. if (RC_BAD( rc = pDatabase->lFileCreate( m_pResultSetDb, diff --git a/xflaim/src/fbtrset.h b/xflaim/src/fbtrset.h index 7f4e867..83e7853 100644 --- a/xflaim/src/fbtrset.h +++ b/xflaim/src/fbtrset.h @@ -47,7 +47,7 @@ typedef struct BtCollXref Desc: Result set class that uses an independant database. The name is randomly generated. =============================================================================*/ -class F_BtResultSet : public XF_RefCount, public XF_Base +class F_BtResultSet : public F_Object { public: diff --git a/xflaim/src/fbuff.cpp b/xflaim/src/fbuff.cpp deleted file mode 100644 index b095317..0000000 --- a/xflaim/src/fbuff.cpp +++ /dev/null @@ -1,557 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: This file contains the F_IOBuffer and F_IOBufferMgr classes. -// -// Tabs: 3 -// -// Copyright (c) 2001-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: fbuff.cpp 3111 2006-01-19 13:10:50 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -/**************************************************************************** -Desc: -****************************************************************************/ -F_IOBufferMgr::F_IOBufferMgr() -{ - m_pFirstPending = NULL; - m_pFirstAvail = NULL; - m_pFirstUsed = NULL; - m_uiMaxBuffers = 0; - m_uiMaxBufferBytesToUse = 0; - m_uiBufferBytesInUse = 0; - m_uiBuffersInUse = 0; - m_completionRc = NE_XFLM_OK; - m_bKeepBuffers = FALSE; -} - -/**************************************************************************** -Desc: -****************************************************************************/ -F_IOBufferMgr::~F_IOBufferMgr() -{ - flmAssert( !m_pFirstPending && !m_pFirstUsed); - while (m_pFirstPending) - { - m_pFirstPending->Release(); - } - - while (m_pFirstAvail) - { - m_pFirstAvail->Release(); - } - - while (m_pFirstUsed) - { - m_pFirstUsed->Release(); - } -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE F_IOBufferMgr::waitForAllPendingIO( void) -{ - RCODE rc = NE_XFLM_OK; - F_IOBuffer * pBuf; - - while( (pBuf = m_pFirstPending) != NULL) - { - (void)pBuf->waitToComplete(); - } - - rc = m_completionRc; - m_completionRc = NE_XFLM_OK; - - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void F_IOBufferMgr::linkToList( - F_IOBuffer ** ppListHead, - F_IOBuffer * pIOBuffer) -{ - flmAssert( pIOBuffer->m_eList == F_IOBuffer::MGR_LIST_NONE); - pIOBuffer->m_pPrev = NULL; - if ((pIOBuffer->m_pNext = *ppListHead) != NULL) - { - (*ppListHead)->m_pPrev = pIOBuffer; - } - *ppListHead = pIOBuffer; - if (ppListHead == &m_pFirstPending || - ppListHead == &m_pFirstUsed) - { - pIOBuffer->m_eList = (ppListHead == &m_pFirstPending - ? F_IOBuffer::MGR_LIST_PENDING - : F_IOBuffer::MGR_LIST_USED); - pIOBuffer->m_bDeleteOnNotify = (m_bKeepBuffers - ? FALSE - : TRUE); - m_uiBuffersInUse++; - m_uiBufferBytesInUse += pIOBuffer->m_uiBufferSize; - } - else - { - pIOBuffer->m_eList = F_IOBuffer::MGR_LIST_AVAIL; - } -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void F_IOBufferMgr::unlinkFromList( - F_IOBuffer * pIOBuffer) -{ - if (pIOBuffer->m_pNext) - { - pIOBuffer->m_pNext->m_pPrev = pIOBuffer->m_pPrev; - } - if (pIOBuffer->m_pPrev) - { - pIOBuffer->m_pPrev->m_pNext = pIOBuffer->m_pNext; - } - else if (pIOBuffer->m_eList == F_IOBuffer::MGR_LIST_AVAIL) - { - m_pFirstAvail = pIOBuffer->m_pNext; - } - else if (pIOBuffer->m_eList == F_IOBuffer::MGR_LIST_PENDING) - { - m_pFirstPending = pIOBuffer->m_pNext; - } - else if (pIOBuffer->m_eList == F_IOBuffer::MGR_LIST_USED) - { - m_pFirstUsed = pIOBuffer->m_pNext; - } - else - { - flmAssert( 0); - } - if (pIOBuffer->m_eList == F_IOBuffer::MGR_LIST_PENDING || - pIOBuffer->m_eList == F_IOBuffer::MGR_LIST_USED) - { - m_uiBuffersInUse--; - flmAssert( m_uiBufferBytesInUse >= pIOBuffer->m_uiBufferSize); - m_uiBufferBytesInUse -= pIOBuffer->m_uiBufferSize; - } - pIOBuffer->m_eList = F_IOBuffer::MGR_LIST_NONE; -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE F_IOBufferMgr::getBuffer( - F_IOBuffer ** ppIOBuffer, - FLMUINT uiBufferSize, - FLMUINT uiBlockSize) -{ - RCODE rc = NE_XFLM_OK; - F_IOBuffer * pIOBuffer = NULL; - F_IOBuffer * pBuf; - - if( RC_BAD( m_completionRc)) - { - rc = m_completionRc; - goto Exit; - } - - if ((m_uiBufferBytesInUse + uiBufferSize > m_uiMaxBufferBytesToUse && - m_pFirstPending) || - m_uiBuffersInUse == m_uiMaxBuffers) - { - pBuf = m_pFirstPending; - for (;;) - { - if( pBuf->isIOComplete()) - { - if( RC_BAD( rc = pBuf->waitToComplete())) - { - goto Exit; - } - pBuf = m_pFirstPending; - if (m_uiBufferBytesInUse + uiBufferSize > m_uiMaxBufferBytesToUse && - m_pFirstPending) - { - continue; - } - else - { - flmAssert( m_uiBuffersInUse < m_uiMaxBuffers); - break; - } - } - - if ((pBuf = pBuf->m_pNext) == NULL) - { - f_yieldCPU(); - pBuf = m_pFirstPending; - } - } - } - - // If we are set up to keep buffers, caller better always ask - // for the same size. - - if (m_pFirstAvail) - { - pIOBuffer = m_pFirstAvail; - unlinkFromList( pIOBuffer); - flmAssert( pIOBuffer->getBufferSize() == uiBufferSize); - } - else - { - if ((pIOBuffer = f_new F_IOBuffer) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - pIOBuffer->m_pIOBufferMgr = this; - if (RC_BAD( rc = pIOBuffer->setupBuffer( uiBufferSize, - uiBlockSize))) - { - goto Exit; - } - } - - // An F_IOBuffer object, once created must ALWAYS be linked - // into the buffer manager's used list. - - linkToList( &m_pFirstUsed, pIOBuffer); -#ifdef FLM_NLM - flmAssert( kSemaphoreExamineCount( (SEMAPHORE)(pIOBuffer->m_hSem)) == 0); -#endif - -Exit: - - if (RC_BAD( rc) && pIOBuffer) - { - pIOBuffer->Release(); - pIOBuffer = NULL; - } - *ppIOBuffer = pIOBuffer; - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -F_IOBuffer::F_IOBuffer() -{ - m_pIOBufferMgr = NULL; - m_pucBuffer = NULL; -#ifdef FLM_DEBUG - f_memset( m_UserData, 0, sizeof( m_UserData)); -#endif - m_uiBufferSize = 0; - m_uiBlockSize = 0; - m_eList = MGR_LIST_NONE; - m_bDeleteOnNotify = TRUE; - m_pNext = NULL; - m_pPrev = NULL; - m_fnCompletion = NULL; - m_completionRc = NE_XFLM_OK; -#if defined( FLM_WIN) - m_FileHandle = INVALID_HANDLE_VALUE; - m_Overlapped.hEvent = 0; -#elif defined( FLM_LINUX) || defined( FLM_SOLARIS) - m_aio.aio_fildes = -1; -#elif defined( FLM_NLM) - m_hSem = F_SEM_NULL; -#endif - m_pDbStats = NULL; -} - -/**************************************************************************** -Desc: -****************************************************************************/ -F_IOBuffer::~F_IOBuffer() -{ - // Unlink from list object is in, if any. - - if (m_eList != MGR_LIST_NONE) - { - flmAssert( m_pIOBufferMgr); - m_pIOBufferMgr->unlinkFromList( this); - } - -#if defined( FLM_WIN) - if( m_Overlapped.hEvent) - { - CloseHandle( m_Overlapped.hEvent); - } -#endif - -#ifdef FLM_NLM - if (m_hSem != F_SEM_NULL) - { - f_semDestroy( &m_hSem); - } -#endif - - if (m_pucBuffer) - { -#ifdef FLM_WIN - (void)VirtualFree( m_pucBuffer, 0, MEM_RELEASE); - m_pucBuffer = NULL; -#elif defined( FLM_LINUX) || defined( FLM_SOLARIS) - free( m_pucBuffer); - m_pucBuffer = NULL; -#else - f_free( &m_pucBuffer); -#endif - } -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void F_IOBuffer::makePending( void) -{ - flmAssert( m_eList == MGR_LIST_USED); - - // Unlink from used list - - m_pIOBufferMgr->unlinkFromList( this); - - // Link into pending list. - - m_pIOBufferMgr->linkToList( &m_pIOBufferMgr->m_pFirstPending, this); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE F_IOBuffer::setupBuffer( - FLMUINT uiBufferSize, - FLMUINT uiBlockSize) -{ - RCODE rc = NE_XFLM_OK; - -#if defined( FLM_WIN) - if( (m_Overlapped.hEvent = CreateEvent( NULL, TRUE, - FALSE, NULL)) == NULL) - { - rc = MapWinErrorToFlaim( GetLastError(), - NE_XFLM_SETTING_UP_FOR_WRITE); - goto Exit; - } -#endif - -#ifdef FLM_NLM - if (RC_BAD( rc = f_semCreate( &m_hSem))) - { - goto Exit; - } -#endif - - // Allocate a buffer - -#ifdef FLM_WIN - if ((m_pucBuffer = (FLMBYTE *)VirtualAlloc( NULL, - (DWORD)uiBufferSize, - MEM_COMMIT, PAGE_READWRITE)) == NULL) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_MEM); - goto Exit; - } -#elif defined( FLM_LINUX) - if( posix_memalign( (void **)&m_pucBuffer, - sysconf( _SC_PAGESIZE), uiBufferSize) != 0) - { - rc = MapErrnoToFlaimErr( errno, NE_XFLM_MEM); - goto Exit; - } -#elif defined( FLM_SOLARIS) - if( (m_pucBuffer = (FLMBYTE *)memalign( sysconf( _SC_PAGESIZE), - uiBufferSize)) == NULL) - { - rc = MapErrnoToFlaimErr( errno, NE_XFLM_MEM); - goto Exit; - } -#else - if (RC_BAD( rc = f_alloc( uiBufferSize, &m_pucBuffer))) - { - goto Exit; - } -#endif - - m_uiBufferSize = uiBufferSize; - m_uiBlockSize = uiBlockSize; - -Exit: - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void F_IOBuffer::notifyComplete( - RCODE rc) -{ - flmAssert( m_eList == MGR_LIST_PENDING || - m_eList == MGR_LIST_USED); - - m_completionRc = rc; - endTimer(); - if( m_fnCompletion) - { - m_fnCompletion( this); - - // Fix so completion callback won't be called twice. - - m_fnCompletion = NULL; - } - - if (RC_BAD( rc) && RC_OK( m_pIOBufferMgr->m_completionRc)) - { - m_pIOBufferMgr->m_completionRc = rc; - } - - if (m_bDeleteOnNotify) - { - Release(); - } - else - { - m_pIOBufferMgr->unlinkFromList( this); - m_pIOBufferMgr->linkToList( &m_pIOBufferMgr->m_pFirstAvail, this); - } -} - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMBOOL F_IOBuffer::isIOComplete( void) -{ - FLMBOOL bComplete = FALSE; -#ifdef FLM_NLM - FLMUINT uiSemCount; -#endif - - if( m_eList != MGR_LIST_PENDING) - { - bComplete = TRUE; - goto Exit; - } - -#ifdef FLM_WIN - if (m_FileHandle == INVALID_HANDLE_VALUE || - HasOverlappedIoCompleted( &m_Overlapped)) - { - bComplete = TRUE; - } -#endif - -#if defined( FLM_LINUX) || defined( FLM_SOLARIS) - if( m_aio.aio_fildes == -1 || aio_error( &m_aio) != EINPROGRESS) - { - bComplete = TRUE; - } -#endif - -#ifdef FLM_NLM - if( (uiSemCount = (FLMUINT)kSemaphoreExamineCount( (SEMAPHORE)m_hSem)) != 0) - { - flmAssert( uiSemCount == 1); - bComplete = TRUE; - } -#endif - -Exit: - return( bComplete); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE F_IOBuffer::waitToComplete( void) -{ - RCODE rc = NE_XFLM_OK; - - // IMPORTANT NOTE! The call to notifyComplete will destroy this - // object, so nothing in the object can be accessed after notifyComplete - // is called. - -#ifdef FLM_WIN - if (m_FileHandle != INVALID_HANDLE_VALUE) - { - DWORD udBytesWritten; - - if (!GetOverlappedResult( m_FileHandle, &m_Overlapped, - &udBytesWritten, TRUE)) - { - rc = MapWinErrorToFlaim( GetLastError(), - NE_XFLM_WRITING_FILE); - } - - notifyComplete( rc); - } -#endif - -#if defined( FLM_LINUX) || defined( FLM_SOLARIS) - if( m_aio.aio_fildes != -1) - { - const struct aiocb * pAio = &m_aio; - - if( aio_suspend( &pAio, 1, NULL) == -1) - { - rc = MapErrnoToFlaimErr( errno, NE_XFLM_MEM); - } - - notifyComplete( rc); - } -#endif - -#ifdef FLM_NLM - if( kSemaphoreWait( (SEMAPHORE)m_hSem) != 0) - { - flmAssert( 0); - } - flmAssert( kSemaphoreExamineCount( (SEMAPHORE)m_hSem) == 0); - rc = m_completionRc; - notifyComplete( m_completionRc); -#endif - - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void F_IOBuffer::endTimer( void) -{ - if (m_pDbStats) - { - flmAddElapTime( &m_StartTime, &m_ui64ElapMilli); - } -} - -/**************************************************************************** -Desc: -****************************************************************************/ -#ifdef FLM_NLM -void F_IOBuffer::signalComplete( - RCODE rc) -{ - m_completionRc = rc; - flmAssert( kSemaphoreExamineCount( (SEMAPHORE)m_hSem) == 0); - kSemaphoreSignal( (SEMAPHORE)m_hSem); -} -#endif diff --git a/xflaim/src/fbuff.h b/xflaim/src/fbuff.h deleted file mode 100644 index de5b64e..0000000 --- a/xflaim/src/fbuff.h +++ /dev/null @@ -1,276 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: This file contains the F_IOBuffer and F_IOBufferMgr classes. -// -// Tabs: 3 -// -// Copyright (c) 2001-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: fbuff.h 3123 2006-01-24 17:19:50 -0700 (Tue, 24 Jan 2006) ahodgkinson $ -//------------------------------------------------------------------------------ - -#ifndef FBUFF_H -#define FBUFF_H - -class F_IOBuffer; -class F_IOBufferMgr; - -typedef void (* WRITE_COMPLETION_CB)( - F_IOBuffer * pWriteBuffer); - -/*=========================================================================== -Class: F_IOBufferMgr -===========================================================================*/ -class F_IOBufferMgr : public XF_RefCount, public XF_Base -{ -public: - - // Constructor - - F_IOBufferMgr(); - - // Destructor - - virtual ~F_IOBufferMgr(); - - RCODE waitForAllPendingIO( void); - - FINLINE void setMaxBuffers( - FLMUINT uiMaxBuffers) - { - m_uiMaxBuffers = uiMaxBuffers; - } - - FINLINE void setMaxBytes( - FLMUINT uiMaxBytes) - { - m_uiMaxBufferBytesToUse = uiMaxBytes; - } - - FINLINE void enableKeepBuffer( void) - { - m_bKeepBuffers = TRUE; - } - - RCODE getBuffer( - F_IOBuffer ** ppIOBuffer, - FLMUINT uiBufferSize, - FLMUINT uiBlockSize); - - FINLINE FLMBOOL havePendingIO( void) - { - return( m_pFirstPending ? TRUE : FALSE); - } - - FINLINE FLMBOOL haveUsed( void) - { - return( m_pFirstUsed ? TRUE : FALSE); - } - -private: - - // Private methods and variables - - F_IOBuffer * m_pFirstPending; - F_IOBuffer * m_pFirstAvail; - F_IOBuffer * m_pFirstUsed; - FLMUINT m_uiMaxBuffers; - FLMUINT m_uiMaxBufferBytesToUse; - FLMUINT m_uiBufferBytesInUse; - FLMUINT m_uiBuffersInUse; - RCODE m_completionRc; - FLMBOOL m_bKeepBuffers; - - void linkToList( - F_IOBuffer ** ppListHead, - F_IOBuffer * pIOBuffer); - - void unlinkFromList( - F_IOBuffer * pIOBuffer); - -friend class F_IOBuffer; - -}; - -/*=========================================================================== -Class: F_IOBuffer -===========================================================================*/ -class F_IOBuffer : public XF_RefCount, public XF_Base -{ -#define MAX_BUFFER_BLOCKS 16 -public: - - typedef enum - { - MGR_LIST_NONE, - MGR_LIST_AVAIL, - MGR_LIST_PENDING, - MGR_LIST_USED - } eBufferMgrList; - - // Constructor - - F_IOBuffer(); - - // Destructor - - ~F_IOBuffer(); - - RCODE setupBuffer( - FLMUINT uiBufferSize, - FLMUINT uiBlockSize); - - FINLINE FLMBYTE * getBuffer( void) - { - return( m_pucBuffer); - } - - FINLINE FLMUINT getBufferSize( void) - { - return( m_uiBufferSize); - } - - FINLINE FLMUINT getBlockSize( void) - { - return( m_uiBlockSize); - } - - void notifyComplete( - RCODE rc); - - FINLINE void setCompletionCallback( - WRITE_COMPLETION_CB fnCompletion) - { - m_fnCompletion = fnCompletion; - } - - FINLINE void startTimer( - XFLM_DB_STATS * pDbStats) - { - if ((m_pDbStats = pDbStats) != NULL) - { - m_ui64ElapMilli = 0; - f_timeGetTimeStamp( &m_StartTime); - } - } - - void endTimer( void); - - FINLINE FLMUINT64 getElapTime( void) - { - return( m_ui64ElapMilli); - } - - FINLINE XFLM_DB_STATS * getDbStats( void) - { - return( m_pDbStats); - } - - FINLINE void setCompletionCallbackData( - FLMUINT uiBlockNumber, - void * pvData) - { - flmAssert( uiBlockNumber < MAX_BUFFER_BLOCKS); - m_UserData [uiBlockNumber] = pvData; - } - - FINLINE void * getCompletionCallbackData( - FLMUINT uiBlockNumber) - { - flmAssert( uiBlockNumber < MAX_BUFFER_BLOCKS); - return( m_UserData [uiBlockNumber]); - } - - FINLINE RCODE getCompletionCode( void) - { - return( m_completionRc); - } - - FINLINE eBufferMgrList getList( void) - { - return( m_eList); - } - - void makePending( void); - -#ifdef FLM_WIN - FINLINE OVERLAPPED * getOverlapped( void) - { - return( &m_Overlapped); - } - - FINLINE void setFileHandle( - HANDLE FileHandle) - { - m_FileHandle = FileHandle; - } -#endif - -#if defined( FLM_LINUX) || defined( FLM_SOLARIS) || defined( FLM_OSX) - FINLINE struct aiocb * getAIOStruct( void) - { - return( &m_aio); - } -#endif - -#ifdef FLM_NLM - void signalComplete( - RCODE rc); -#endif - -private: - - // Only called by the buffer manager - - RCODE setupIOBuffer( - F_IOBufferMgr * pIOBufferMgr); - - FLMBOOL isIOComplete( void); - - RCODE waitToComplete( void); - - // Private methods and variables - - F_IOBufferMgr * m_pIOBufferMgr; - FLMBYTE * m_pucBuffer; - void * m_UserData [MAX_BUFFER_BLOCKS]; - FLMUINT m_uiBufferSize; - FLMUINT m_uiBlockSize; - eBufferMgrList m_eList; - FLMBOOL m_bDeleteOnNotify; -#ifdef FLM_WIN - HANDLE m_FileHandle; - OVERLAPPED m_Overlapped; -#endif -#if defined( FLM_LINUX) || defined( FLM_SOLARIS) || defined( FLM_OSX) - struct aiocb m_aio; -#endif -#ifdef FLM_NLM - F_SEM m_hSem; -#endif - F_IOBuffer * m_pNext; - F_IOBuffer * m_pPrev; - WRITE_COMPLETION_CB m_fnCompletion; - XFLM_DB_STATS * m_pDbStats; - RCODE m_completionRc; - F_TMSTAMP m_StartTime; - FLMUINT64 m_ui64ElapMilli; - - friend class F_IOBufferMgr; -}; - -#endif // #ifndef FBUFF_H diff --git a/xflaim/src/fcache.h b/xflaim/src/fcache.h index d9d39fa..7b5581b 100644 --- a/xflaim/src/fcache.h +++ b/xflaim/src/fcache.h @@ -26,14 +26,11 @@ #ifndef FCACHE_H #define FCACHE_H -#include "flfixed.h" - class F_Rfl; class F_DOMNode; class F_Db; class F_DbSystem; class F_Database; -class F_MultiAlloc; class F_LocalNodeCache; class F_CachedNode; class F_CachedBlock; @@ -117,7 +114,7 @@ FINLINE FLMBOOL checkHashFailTime( /***************************************************************************** Desc: Cached item ******************************************************************************/ -class F_CachedItem +class F_CachedItem : public F_Object { public: @@ -131,12 +128,6 @@ public: { } -#ifdef FLM_CACHE_PROTECT - virtual void protectCachedItem( void) = 0; - - virtual void unprotectCachedItem( void) = 0; -#endif - private: F_CachedItem * m_pPrevInGlobal; @@ -188,19 +179,9 @@ public: FINLINE void linkGlobalAsMRU( F_CachedItem * pItem) { -#ifdef FLM_CACHE_PROTECT - pItem->unprotectCachedItem(); -#endif - if ((pItem->m_pNextInGlobal = m_pMRUItem) != NULL) { -#ifdef FLM_CACHE_PROTECT - pItem->m_pNextInGlobal->unprotectCachedItem(); -#endif pItem->m_pNextInGlobal->m_pPrevInGlobal = pItem; -#ifdef FLM_CACHE_PROTECT - pItem->m_pNextInGlobal->protectCachedItem(); -#endif } else { @@ -209,9 +190,6 @@ public: } pItem->m_pPrevInGlobal = NULL; -#ifdef FLM_CACHE_PROTECT - pItem->protectCachedItem(); -#endif m_pMRUItem = pItem; flmAssert( pItem != pItem->m_pPrevInGlobal); flmAssert( pItem != pItem->m_pNextInGlobal); @@ -233,19 +211,9 @@ public: flmAssert( m_pLastMRUItem); -#ifdef FLM_CACHE_PROTECT - pItem->unprotectCachedItem(); -#endif - if( m_pLastMRUItem->m_pNextInGlobal) { -#ifdef FLM_CACHE_PROTECT - m_pLastMRUItem->m_pNextInGlobal->unprotectCachedItem(); -#endif m_pLastMRUItem->m_pNextInGlobal->m_pPrevInGlobal = pItem; -#ifdef FLM_CACHE_PROTECT - m_pLastMRUItem->m_pNextInGlobal->protectCachedItem(); -#endif pItem->m_pNextInGlobal = m_pLastMRUItem->m_pNextInGlobal; } else @@ -254,21 +222,10 @@ public: m_pLRUItem = pItem; } -#ifdef FLM_CACHE_PROTECT - m_pLastMRUItem->unprotectCachedItem(); -#endif m_pLastMRUItem->m_pNextInGlobal = pItem; -#ifdef FLM_CACHE_PROTECT - m_pLastMRUItem->protectCachedItem(); -#endif - pItem->m_pPrevInGlobal = m_pLastMRUItem; m_pLastMRUItem = pItem; -#ifdef FLM_CACHE_PROTECT - pItem->protectCachedItem(); -#endif - flmAssert( pItem != pItem->m_pPrevInGlobal); flmAssert( pItem != pItem->m_pNextInGlobal); } @@ -280,19 +237,9 @@ public: FINLINE void linkGlobalAsLRU( F_CachedItem * pItem) { -#ifdef FLM_CACHE_PROTECT - pItem->unprotectCachedItem(); -#endif - if ((pItem->m_pPrevInGlobal = m_pLRUItem) != NULL) { -#ifdef FLM_CACHE_PROTECT - pItem->m_pPrevInGlobal->unprotectCachedItem(); -#endif pItem->m_pPrevInGlobal->m_pNextInGlobal = pItem; -#ifdef FLM_CACHE_PROTECT - pItem->m_pPrevInGlobal->protectCachedItem(); -#endif } else { @@ -304,9 +251,6 @@ public: } pItem->m_pNextInGlobal = NULL; -#ifdef FLM_CACHE_PROTECT - pItem->protectCachedItem(); -#endif m_pLRUItem = pItem; flmAssert( pItem != pItem->m_pPrevInGlobal); @@ -336,13 +280,7 @@ public: { flmAssert( pItem != m_pLRUItem); -#ifdef FLM_CACHE_PROTECT - pItem->m_pNextInGlobal->unprotectCachedItem(); -#endif pItem->m_pNextInGlobal->m_pPrevInGlobal = pItem->m_pPrevInGlobal; -#ifdef FLM_CACHE_PROTECT - pItem->m_pNextInGlobal->protectCachedItem(); -#endif } else { @@ -353,27 +291,15 @@ public: { flmAssert( pItem != m_pMRUItem); -#ifdef FLM_CACHE_PROTECT - pItem->m_pPrevInGlobal->unprotectCachedItem(); -#endif pItem->m_pPrevInGlobal->m_pNextInGlobal = pItem->m_pNextInGlobal; -#ifdef FLM_CACHE_PROTECT - pItem->m_pPrevInGlobal->protectCachedItem(); -#endif } else { m_pMRUItem = pItem->m_pNextInGlobal; } -#ifdef FLM_CACHE_PROTECT - pItem->unprotectCachedItem(); -#endif pItem->m_pNextInGlobal = NULL; pItem->m_pPrevInGlobal = NULL; -#ifdef FLM_CACHE_PROTECT - pItem->protectCachedItem(); -#endif } // Moves a cached item one step closer to the MRU slot in the global list. @@ -394,57 +320,27 @@ public: if (pPrevItem->m_pPrevInGlobal) { -#ifdef FLM_CACHE_PROTECT - pPrevItem->m_pPrevInGlobal->unprotectCachedItem(); -#endif pPrevItem->m_pPrevInGlobal->m_pNextInGlobal = pItem; -#ifdef FLM_CACHE_PROTECT - pPrevItem->m_pPrevInGlobal->protectCachedItem(); -#endif } else { m_pMRUItem = pItem; } -#ifdef FLM_CACHE_PROTECT - pItem->unprotectCachedItem(); -#endif pItem->m_pPrevInGlobal = pPrevItem->m_pPrevInGlobal; -#ifdef FLM_CACHE_PROTECT - pItem->protectCachedItem(); -#endif -#ifdef FLM_CACHE_PROTECT - pPrevItem->unprotectCachedItem(); -#endif pPrevItem->m_pPrevInGlobal = pItem; pPrevItem->m_pNextInGlobal = pItem->m_pNextInGlobal; -#ifdef FLM_CACHE_PROTECT - pPrevItem->protectCachedItem(); -#endif if (pItem->m_pNextInGlobal) { -#ifdef FLM_CACHE_PROTECT - pItem->m_pNextInGlobal->unprotectCachedItem(); -#endif pItem->m_pNextInGlobal->m_pPrevInGlobal = pPrevItem; -#ifdef FLM_CACHE_PROTECT - pItem->m_pNextInGlobal->protectCachedItem(); -#endif } else { m_pLRUItem = pPrevItem; } -#ifdef FLM_CACHE_PROTECT - pItem->unprotectCachedItem(); -#endif pItem->m_pNextInGlobal = pPrevItem; -#ifdef FLM_CACHE_PROTECT - pItem->protectCachedItem(); -#endif } } @@ -470,7 +366,7 @@ friend class F_BlockRelocator; /*************************************************************************** Desc: Global cache manager for XFLAIM. ***************************************************************************/ -class F_GlobalCacheMgr : public XF_RefCount, public XF_Base +class F_GlobalCacheMgr : public F_Object { public: F_GlobalCacheMgr(); @@ -556,7 +452,7 @@ public: private: - F_SlabManager * m_pSlabManager; + IF_SlabManager * m_pSlabManager; FLMUINT m_uiMaxBytes; FLMUINT m_uiMaxSlabs; FLMBOOL m_bCachePreallocated; @@ -604,18 +500,18 @@ public: { } - void relocate( + void FLMAPI relocate( void * pvOldAlloc, void * pvNewAlloc); - FLMBOOL canRelocate( + FLMBOOL FLMAPI canRelocate( void * pvOldAlloc); }; /**************************************************************************** Desc: This class manages block cache. ****************************************************************************/ -class F_BlockCacheMgr : public XF_RefCount, public XF_Base +class F_BlockCacheMgr : public F_Object { public: F_BlockCacheMgr(); @@ -661,7 +557,7 @@ public: f_mutexLock( gv_XFlmSysData.hBlockCacheMutex); } - m_blockAllocator.defragmentMemory(); + m_pBlockAllocator->defragmentMemory(); if( !bMutexLocked) { @@ -670,10 +566,10 @@ public: } FINLINE void getUsageStats( - XFLM_SLAB_USAGE * pUsage) + FLM_SLAB_USAGE * pUsage) { gv_XFlmSysData.pGlobalCacheMgr->m_pSlabManager->lockMutex(); - f_memcpy( pUsage, &m_Usage, sizeof( XFLM_SLAB_USAGE)); + f_memcpy( pUsage, &m_Usage, sizeof( FLM_SLAB_USAGE)); gv_XFlmSysData.pGlobalCacheMgr->m_pSlabManager->unlockMutex(); } @@ -741,7 +637,7 @@ private: // retry again. FLMUINT m_uiHashMask; // Bits that are significant // for the number of hash buckets. - F_MultiAlloc m_blockAllocator; + IF_MultiAlloc * m_pBlockAllocator; // Fixed size allocators for cache blocks F_BlockRelocator m_blockRelocator; // Relocator for cache blocks @@ -847,23 +743,9 @@ public: ~F_CachedBlock(); -#ifdef FLM_CACHE_PROTECT - FINLINE void protectCachedItem( void) - { - gv_XFlmSysData.pBlockCacheMgr->m_blockAllocator.protectBuffer( this); - } -#endif - -#ifdef FLM_CACHE_PROTECT - FINLINE void unprotectCachedItem( void) - { - gv_XFlmSysData.pBlockCacheMgr->m_blockAllocator.unprotectBuffer( this); - } -#endif - FINLINE FLMUINT memSize( void) { - return( gv_XFlmSysData.pBlockCacheMgr->m_blockAllocator.getTrueSize( + return( gv_XFlmSysData.pBlockCacheMgr->m_pBlockAllocator->getTrueSize( (FLMBYTE *)this)); } @@ -929,13 +811,7 @@ public: gv_XFlmSysData.pBlockCacheMgr->m_Usage.uiOldVerCount--; } -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_ui64HighTransID = ui64NewTransID; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Determines if a cache block is needed by a read transaction. @@ -954,27 +830,14 @@ public: if ((m_pNextInReplaceList = gv_XFlmSysData.pBlockCacheMgr->m_pMRUReplace) != NULL) { -#ifdef FLM_CACHE_PROTECT - m_pNextInReplaceList->unprotectCachedItem(); -#endif m_pNextInReplaceList->m_pPrevInReplaceList = this; -#ifdef FLM_CACHE_PROTECT - m_pNextInReplaceList->protectCachedItem(); -#endif } else { gv_XFlmSysData.pBlockCacheMgr->m_pLRUReplace = this; } -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_pPrevInReplaceList = NULL; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif - gv_XFlmSysData.pBlockCacheMgr->m_pMRUReplace = this; gv_XFlmSysData.pBlockCacheMgr->m_uiReplaceableCount++; gv_XFlmSysData.pBlockCacheMgr->m_uiReplaceableBytes += memSize(); @@ -988,26 +851,14 @@ public: if ((m_pPrevInReplaceList = gv_XFlmSysData.pBlockCacheMgr->m_pLRUReplace) != NULL) { -#ifdef FLM_CACHE_PROTECT - m_pPrevInReplaceList->unprotectCachedItem(); -#endif m_pPrevInReplaceList->m_pNextInReplaceList = this; -#ifdef FLM_CACHE_PROTECT - m_pPrevInReplaceList->protectCachedItem(); -#endif } else { gv_XFlmSysData.pBlockCacheMgr->m_pMRUReplace = this; } -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_pNextInReplaceList = NULL; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif gv_XFlmSysData.pBlockCacheMgr->m_pLRUReplace = this; gv_XFlmSysData.pBlockCacheMgr->m_uiReplaceableCount++; gv_XFlmSysData.pBlockCacheMgr->m_uiReplaceableBytes += memSize(); @@ -1023,19 +874,9 @@ public: if( (pPrevSCache = m_pPrevInReplaceList) != NULL) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif - if( pPrevSCache->m_pPrevInReplaceList) { -#ifdef FLM_CACHE_PROTECT - pPrevSCache->m_pPrevInReplaceList->unprotectCachedItem(); -#endif pPrevSCache->m_pPrevInReplaceList->m_pNextInReplaceList = this; -#ifdef FLM_CACHE_PROTECT - pPrevSCache->m_pPrevInReplaceList->protectCachedItem(); -#endif } else { @@ -1044,24 +885,12 @@ public: m_pPrevInReplaceList = pPrevSCache->m_pPrevInReplaceList; -#ifdef FLM_CACHE_PROTECT - pPrevSCache->unprotectCachedItem(); -#endif pPrevSCache->m_pPrevInReplaceList = this; pPrevSCache->m_pNextInReplaceList = m_pNextInReplaceList; -#ifdef FLM_CACHE_PROTECT - pPrevSCache->protectCachedItem(); -#endif if( m_pNextInReplaceList) { -#ifdef FLM_CACHE_PROTECT - m_pNextInReplaceList->unprotectCachedItem(); -#endif m_pNextInReplaceList->m_pPrevInReplaceList = pPrevSCache; -#ifdef FLM_CACHE_PROTECT - m_pNextInReplaceList->protectCachedItem(); -#endif } else { @@ -1069,9 +898,6 @@ public: } m_pNextInReplaceList = pPrevSCache; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } } @@ -1082,9 +908,6 @@ public: { if( m_ui16Flags) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif if( (m_ui16Flags &= ~ui16FlagsToClear) == 0) { if( !m_pPrevInGlobal || @@ -1098,9 +921,6 @@ public: linkToReplaceListAsLRU(); } } -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } } @@ -1112,18 +932,12 @@ public: { flmAssert( ui16FlagsToSet); -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif if( !m_ui16Flags) { unlinkFromReplaceList(); } m_ui16Flags |= ui16FlagsToSet; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Set the dirty flag on a cache block. @@ -1194,9 +1008,6 @@ public: FLMUINT) // uiThreadId) #endif { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif #ifdef FLM_DEBUG if (m_pUseList || @@ -1252,10 +1063,6 @@ public: gv_XFlmSysData.pBlockCacheMgr->m_uiBlocksUsed--; } } - -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Tests if a block can be freed from cache. @@ -1377,39 +1184,9 @@ public: void operator delete( void * ptr); -#if !defined( __WATCOMC__) && !defined( FLM_SOLARIS) - void operator delete( - void * ptr, - FLMSIZET uiSize, - const char * pszFileName, - int iLine); -#endif - void operator delete[]( void * ptr); -#if !defined( __WATCOMC__) && !defined( FLM_SOLARIS) - void operator delete( - void * ptr, - FLMUINT uiBlockSize, - FLMBOOL bAllocMutexLocked); -#endif - - -#if !defined( __WATCOMC__) && !defined( FLM_SOLARIS) - void operator delete( - void * ptr, - const char * file, - int line); -#endif - -#if !defined( __WATCOMC__) && !defined( FLM_SOLARIS) - void operator delete[]( - void * ptr, - const char * pszFileName, - int iLineNum); -#endif - private: void unlinkFromReplaceList( void); @@ -1522,29 +1299,15 @@ private: FINLINE void linkToHashBucket( F_CachedBlock ** ppSCacheBucket) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif - #ifdef SCACHE_LINK_CHECKING checkHashLinks( ppSCacheBucket); #endif m_pPrevInHashBucket = NULL; if ((m_pNextInHashBucket = *ppSCacheBucket) != NULL) { -#ifdef FLM_CACHE_PROTECT - m_pNextInHashBucket->unprotectCachedItem(); -#endif m_pNextInHashBucket->m_pPrevInHashBucket = this; -#ifdef FLM_CACHE_PROTECT - m_pNextInHashBucket->protectCachedItem(); -#endif } *ppSCacheBucket = this; - -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Unlink a cache block from its hash bucket. This routine assumes @@ -1552,10 +1315,6 @@ private: FINLINE void unlinkFromHashBucket( F_CachedBlock ** ppSCacheBucket) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif - #ifdef SCACHE_LINK_CHECKING checkHashUnlinks( ppSCacheBucket); #endif @@ -1566,24 +1325,12 @@ private: if (m_pNextInHashBucket) { -#ifdef FLM_CACHE_PROTECT - m_pNextInHashBucket->unprotectCachedItem(); -#endif m_pNextInHashBucket->m_pPrevInHashBucket = m_pPrevInHashBucket; -#ifdef FLM_CACHE_PROTECT - m_pNextInHashBucket->protectCachedItem(); -#endif } if (m_pPrevInHashBucket) { -#ifdef FLM_CACHE_PROTECT - m_pPrevInHashBucket->unprotectCachedItem(); -#endif m_pPrevInHashBucket->m_pNextInHashBucket = m_pNextInHashBucket; -#ifdef FLM_CACHE_PROTECT - m_pPrevInHashBucket->protectCachedItem(); -#endif } else { @@ -1592,10 +1339,6 @@ private: m_pNextInHashBucket = NULL; m_pPrevInHashBucket = NULL; - -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } void unlinkCache( @@ -1695,11 +1438,11 @@ public: { } - void relocate( + void FLMAPI relocate( void * pvOldAlloc, void * pvNewAlloc); - FLMBOOL canRelocate( + FLMBOOL FLMAPI canRelocate( void * pvOldAlloc); }; @@ -1718,11 +1461,11 @@ public: { } - void relocate( + void FLMAPI relocate( void * pvOldAlloc, void * pvNewAlloc); - FLMBOOL canRelocate( + FLMBOOL FLMAPI canRelocate( void * pvOldAlloc); }; @@ -1741,11 +1484,11 @@ public: { } - void relocate( + void FLMAPI relocate( void * pvOldAlloc, void * pvNewAlloc); - FLMBOOL canRelocate( + FLMBOOL FLMAPI canRelocate( void * pvOldAlloc); }; @@ -1764,11 +1507,11 @@ public: { } - void relocate( + void FLMAPI relocate( void * pvOldAlloc, void * pvNewAlloc); - FLMBOOL canRelocate( + FLMBOOL FLMAPI canRelocate( void * pvOldAlloc); }; @@ -1787,11 +1530,11 @@ public: { } - void relocate( + void FLMAPI relocate( void * pvOldAlloc, void * pvNewAlloc); - FLMBOOL canRelocate( + FLMBOOL FLMAPI canRelocate( void * pvOldAlloc); }; @@ -1810,11 +1553,11 @@ public: { } - void relocate( + void FLMAPI relocate( void * pvOldAlloc, void * pvNewAlloc); - FLMBOOL canRelocate( + FLMBOOL FLMAPI canRelocate( void * pvOldAlloc); }; @@ -1824,7 +1567,7 @@ Desc: This structure defines the header information that is used to control the FLAIM record cache. This structure will be embedded in the FLMSYSDATA structure. ****************************************************************************/ -class F_NodeCacheMgr : public XF_RefCount, public XF_Base +class F_NodeCacheMgr : public F_Object { public: F_NodeCacheMgr(); @@ -1894,9 +1637,9 @@ public: f_mutexLock( gv_XFlmSysData.hNodeCacheMutex); } - m_nodeAllocator.defragmentMemory(); - m_bufAllocator.defragmentMemory(); - m_attrItemAllocator.defragmentMemory(); + m_pNodeAllocator->defragmentMemory(); + m_pBufAllocator->defragmentMemory(); + m_pAttrItemAllocator->defragmentMemory(); if( !bMutexLocked) { @@ -1905,10 +1648,10 @@ public: } FINLINE void getUsageStats( - XFLM_SLAB_USAGE * pUsage) + FLM_SLAB_USAGE * pUsage) { gv_XFlmSysData.pGlobalCacheMgr->m_pSlabManager->lockMutex(); - f_memcpy( pUsage, &m_Usage, sizeof( XFLM_SLAB_USAGE)); + f_memcpy( pUsage, &m_Usage, sizeof( FLM_SLAB_USAGE)); gv_XFlmSysData.pGlobalCacheMgr->m_pSlabManager->unlockMutex(); } @@ -1984,11 +1727,11 @@ private: FLMUINT m_uiIoWaits; // Number of times multiple threads // were reading the same node from // disk at the same time. - F_FixedAlloc m_nodeAllocator; // Fixed size allocator for F_CachedNode + IF_FixedAlloc * m_pNodeAllocator; // Fixed size allocator for F_CachedNode // objects - F_BufferAlloc m_bufAllocator; // Buffer allocator for buffers in + IF_BufferAlloc * m_pBufAllocator; // Buffer allocator for buffers in // F_CachedNode objects - F_FixedAlloc m_attrItemAllocator; + IF_FixedAlloc * m_pAttrItemAllocator; // Allocator for attribute list items F_NodeRelocator m_nodeRelocator; F_NodeDataRelocator m_nodeDataRelocator; @@ -2219,11 +1962,11 @@ public: FINLINE FLMUINT memSize( void) { - FLMUINT uiSize = gv_XFlmSysData.pNodeCacheMgr->m_attrItemAllocator.getCellSize(); + FLMUINT uiSize = gv_XFlmSysData.pNodeCacheMgr->m_pAttrItemAllocator->getCellSize(); if( m_uiPayloadLen > sizeof( FLMBYTE *)) { - uiSize += gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.getTrueSize( + uiSize += gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->getTrueSize( m_uiPayloadLen + sizeof( F_AttrItem *), m_pucPayload - sizeof( F_AttrItem *)); } @@ -2307,20 +2050,6 @@ public: void operator delete[]( void * ptr); -#if defined( FLM_DEBUG) && !defined( __WATCOMC__) && !defined( FLM_SOLARIS) - void operator delete( - void * ptr, - const char * file, - int line); -#endif - -#if defined( FLM_DEBUG) && !defined( __WATCOMC__) && !defined( FLM_SOLARIS) - void operator delete[]( - void * ptr, - const char * pszFileName, - int iLineNum); -#endif - private: F_CachedNode * m_pCachedNode; @@ -2444,18 +2173,6 @@ public: ~F_CachedNode(); -#ifdef FLM_CACHE_PROTECT - FINLINE void protectCachedItem( void) - { - gv_XFlmSysData.pNodeCacheMgr->m_nodeAllocator.protectCell( this); - } - - FINLINE void unprotectCachedItem( void) - { - gv_XFlmSysData.pNodeCacheMgr->m_nodeAllocator.unprotectCell( this); - } -#endif - // This method assumes that the node cache mutex has been locked. FINLINE FLMBOOL canBeFreed( void) @@ -2536,40 +2253,22 @@ public: FINLINE void setNodeAndDataPtr( FLMBYTE * pucActualAlloc) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif *((F_CachedNode **)(pucActualAlloc)) = this; m_pucData = pucActualAlloc + allocOverhead(); -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE void setNodeListPtr( FLMBYTE * pucActualAlloc) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif *((F_CachedNode **)(pucActualAlloc)) = this; m_pNodeList = (NODE_ITEM *)(pucActualAlloc + allocOverhead()); -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE void setAttrListPtr( FLMBYTE * pucActualAlloc) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif *((F_CachedNode **)(pucActualAlloc)) = this; m_ppAttrList = (F_AttrItem **)(pucActualAlloc + allocOverhead()); -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE FLMBYTE * getDataPtr( void) @@ -2595,25 +2294,13 @@ public: FINLINE void setFlags( FLMUINT uiFlags) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_uiFlags |= uiFlags; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE void unsetFlags( FLMUINT uiFlags) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_uiFlags &= ~uiFlags; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE FLMUINT64 getNodeId( void) @@ -2639,13 +2326,7 @@ public: FINLINE void setNodeType( eDomNodeType eNodeType) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_nodeInfo.eNodeType = eNodeType; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE FLMUINT getDataType( void) @@ -2656,13 +2337,7 @@ public: FINLINE void setDataType( FLMUINT uiDataType) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_nodeInfo.uiDataType = uiDataType; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE FLMUINT getNameId( void) @@ -2673,13 +2348,7 @@ public: FINLINE void setNameId( FLMUINT uiNameId) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_nodeInfo.uiNameId = uiNameId; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE FLMUINT getPrefixId( void) @@ -2690,13 +2359,7 @@ public: FINLINE void setPrefixId( FLMUINT uiPrefixId) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_nodeInfo.uiPrefixId = uiPrefixId; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE FLMUINT64 getDocumentId( void) @@ -2714,13 +2377,7 @@ public: FINLINE void setDocumentId( FLMUINT64 ui64DocumentId) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_nodeInfo.ui64DocumentId = ui64DocumentId; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE FLMUINT64 getParentId( void) @@ -2731,13 +2388,7 @@ public: FINLINE void setParentId( FLMUINT64 ui64ParentId) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_nodeInfo.ui64ParentId = ui64ParentId; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE FLMUINT64 getNextSibId( void) @@ -2748,13 +2399,7 @@ public: FINLINE void setNextSibId( FLMUINT64 ui64NextSibId) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_nodeInfo.ui64NextSibId = ui64NextSibId; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE FLMUINT64 getPrevSibId( void) @@ -2765,27 +2410,15 @@ public: FINLINE void setPrevSibId( FLMUINT64 ui64PrevSibId) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_nodeInfo.ui64PrevSibId = ui64PrevSibId; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE void setSibIds( FLMUINT64 ui64PrevSibId, FLMUINT64 ui64NextSibId) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_nodeInfo.ui64NextSibId = ui64NextSibId; m_nodeInfo.ui64PrevSibId = ui64PrevSibId; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE FLMUINT64 getFirstChildId( void) @@ -2796,13 +2429,7 @@ public: FINLINE void setFirstChildId( FLMUINT64 ui64FirstChildId) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_nodeInfo.ui64FirstChildId = ui64FirstChildId; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE FLMUINT64 getLastChildId( void) @@ -2813,27 +2440,15 @@ public: FINLINE void setLastChildId( FLMUINT64 ui64LastChildId) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_nodeInfo.ui64LastChildId = ui64LastChildId; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE void setChildIds( FLMUINT64 ui64FirstChildId, FLMUINT64 ui64LastChildId) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_nodeInfo.ui64FirstChildId = ui64FirstChildId; m_nodeInfo.ui64LastChildId = ui64LastChildId; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE FLMUINT getDataChildCount( void) @@ -2844,16 +2459,8 @@ public: FINLINE void setDataChildCount( FLMUINT uiDataChildCount) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif - flmAssert( m_nodeInfo.ui64FirstChildId); m_nodeInfo.uiDataChildCount = uiDataChildCount; - -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE FLMUINT64 getAnnotationId( void) @@ -2864,13 +2471,7 @@ public: FINLINE void setAnnotationId( FLMUINT64 ui64AnnotationId) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_nodeInfo.ui64AnnotationId = ui64AnnotationId; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE FLMBOOL hasAttributes( void) @@ -2929,13 +2530,7 @@ public: FINLINE void setDataLength( FLMUINT uiDataLength) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_nodeInfo.uiDataLength = uiDataLength; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE FLMUINT getEncDefId( void) @@ -2946,13 +2541,7 @@ public: FINLINE void setEncDefId( FLMUINT uiEncDefId) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_nodeInfo.uiEncDefId = uiEncDefId; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE FLMBOOL getQuickNumber64( @@ -3003,41 +2592,23 @@ public: FINLINE void setUINT64( FLMUINT64 ui64Value) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_numberVal.ui64Val = ui64Value; m_uiFlags &= ~FDOM_SIGNED_QUICK_VAL; m_uiFlags |= FDOM_UNSIGNED_QUICK_VAL; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE void setINT64( FLMINT64 i64Value) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_numberVal.i64Val = i64Value; m_uiFlags &= ~FDOM_UNSIGNED_QUICK_VAL; m_uiFlags |= FDOM_SIGNED_QUICK_VAL; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE void setMetaValue( FLMUINT64 ui64Value) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_nodeInfo.ui64MetaValue = ui64Value; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE FLMUINT64 getMetaValue( void) @@ -3053,13 +2624,7 @@ public: FINLINE void setOffsetIndex( FLMUINT uiOffsetIndex) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_uiOffsetIndex = uiOffsetIndex; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE FLMUINT32 getBlkAddr( void) @@ -3070,13 +2635,7 @@ public: FINLINE void setBlkAddr( FLMUINT32 ui32BlkAddr) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_ui32BlkAddr = ui32BlkAddr; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE FLMBOOL isRightVersion( @@ -3140,69 +2699,31 @@ public: void operator delete[]( void * ptr); -#if defined( FLM_DEBUG) && !defined( __WATCOMC__) && !defined( FLM_SOLARIS) - void operator delete( - void * ptr, - const char * file, - int line); -#endif - -#if defined( FLM_DEBUG) && !defined( __WATCOMC__) && !defined( FLM_SOLARIS) - void operator delete[]( - void * ptr, - const char * pszFileName, - int iLineNum); -#endif - // Assumes that the node cache mutex has already been locked. FINLINE void incrNodeUseCount( void) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_uiCacheFlags = (m_uiCacheFlags & (~(NCA_COUNTER_BITS))) | (((m_uiCacheFlags & NCA_COUNTER_BITS) + 1)); -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Assumes that the node cache mutex has already been locked. FINLINE void decrNodeUseCount( void) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_uiCacheFlags = (m_uiCacheFlags & (~(NCA_COUNTER_BITS))) | (((m_uiCacheFlags & NCA_COUNTER_BITS) - 1)); -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Assumes that the node cache mutex has already been locked. FINLINE void incrStreamUseCount( void) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_uiStreamUseCount++; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Assumes that the node cache mutex has already been locked. FINLINE void decrStreamUseCount( void) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif flmAssert( m_uiStreamUseCount); m_uiStreamUseCount--; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE FLMUINT getStreamUseCount( void) @@ -3464,49 +2985,25 @@ private: // Assumes that the node cache mutex has already been locked. FINLINE void setReadingIn( void) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_uiCacheFlags |= NCA_READING_IN; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Assumes that the node cache mutex has already been locked. FINLINE void unsetReadingIn( void) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_uiCacheFlags &= (~(NCA_READING_IN)); -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Assumes that the node cache mutex has already been locked. FINLINE void setUncommitted( void) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_uiCacheFlags |= NCA_UNCOMMITTED; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Assumes that the node cache mutex has already been locked. FINLINE void unsetUncommitted( void) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_uiCacheFlags &= (~(NCA_UNCOMMITTED)); -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Assumes that the node cache mutex has already been locked. @@ -3518,49 +3015,25 @@ private: // Assumes that the node cache mutex has already been locked. FINLINE void setLatestVer( void) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_uiCacheFlags |= NCA_LATEST_VER; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Assumes that the node cache mutex has already been locked. FINLINE void unsetLatestVer( void) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_uiCacheFlags &= (~(NCA_LATEST_VER)); -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Assumes that the node cache mutex has already been locked. FINLINE void setPurged( void) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_uiCacheFlags |= NCA_PURGED; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Assumes that the node cache mutex has already been locked. FINLINE void unsetPurged( void) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_uiCacheFlags &= (~(NCA_PURGED)); -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Assumes that the node cache mutex has already been locked. @@ -3572,25 +3045,13 @@ private: // Assumes that the node cache mutex has already been locked. FINLINE void setLinkedToDatabase( void) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_uiCacheFlags |= NCA_LINKED_TO_DATABASE; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Assumes that the node cache mutex has already been locked. FINLINE void unsetLinkedToDatabase( void) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_uiCacheFlags &= (~(NCA_LINKED_TO_DATABASE)); -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Assumes that the node cache mutex has already been locked. @@ -3605,24 +3066,12 @@ private: { if (m_pNextInGlobal) { -#ifdef FLM_CACHE_PROTECT - m_pNextInGlobal->unprotectCachedItem(); -#endif m_pNextInGlobal->m_pPrevInGlobal = m_pPrevInGlobal; -#ifdef FLM_CACHE_PROTECT - m_pNextInGlobal->protectCachedItem(); -#endif } if (m_pPrevInGlobal) { -#ifdef FLM_CACHE_PROTECT - m_pPrevInGlobal->unprotectCachedItem(); -#endif m_pPrevInGlobal->m_pNextInGlobal = m_pNextInGlobal; -#ifdef FLM_CACHE_PROTECT - m_pPrevInGlobal->protectCachedItem(); -#endif } else { @@ -3630,14 +3079,8 @@ private: (F_CachedNode *)m_pNextInGlobal; } -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_pPrevInGlobal = NULL; m_pNextInGlobal = NULL; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Link a node to an F_Database list at the head of the list. @@ -3645,22 +3088,12 @@ private: FINLINE void linkToDatabaseAtHead( F_Database * pDatabase) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif - if (!pDatabase->m_pLastDirtyNode || nodeIsDirty()) { m_pPrevInDatabase = NULL; if ((m_pNextInDatabase = pDatabase->m_pFirstNode) != NULL) { -#ifdef FLM_CACHE_PROTECT - pDatabase->m_pFirstNode->unprotectCachedItem(); -#endif pDatabase->m_pFirstNode->m_pPrevInDatabase = this; -#ifdef FLM_CACHE_PROTECT - pDatabase->m_pFirstNode->protectCachedItem(); -#endif } else { @@ -3682,22 +3115,10 @@ private: m_pPrevInDatabase = pDatabase->m_pLastDirtyNode; m_pNextInDatabase = m_pPrevInDatabase->m_pNextInDatabase; -#ifdef FLM_CACHE_PROTECT - m_pPrevInDatabase->unprotectCachedItem(); -#endif m_pPrevInDatabase->m_pNextInDatabase = this; -#ifdef FLM_CACHE_PROTECT - m_pPrevInDatabase->protectCachedItem(); -#endif if (m_pNextInDatabase) { -#ifdef FLM_CACHE_PROTECT - m_pNextInDatabase->unprotectCachedItem(); -#endif m_pNextInDatabase->m_pPrevInDatabase = this; -#ifdef FLM_CACHE_PROTECT - m_pNextInDatabase->protectCachedItem(); -#endif } else { @@ -3707,9 +3128,6 @@ private: m_pDatabase = pDatabase; setLinkedToDatabase(); -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Link a node to an F_Database list at the end of the list. @@ -3717,9 +3135,6 @@ private: FINLINE void linkToDatabaseAtEnd( F_Database * pDatabase) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif // Node cannot be a dirty node. @@ -3727,13 +3142,7 @@ private: m_pNextInDatabase = NULL; if( (m_pPrevInDatabase = pDatabase->m_pLastNode) != NULL) { -#ifdef FLM_CACHE_PROTECT - pDatabase->m_pLastNode->unprotectCachedItem(); -#endif pDatabase->m_pLastNode->m_pNextInDatabase = this; -#ifdef FLM_CACHE_PROTECT - pDatabase->m_pLastNode->protectCachedItem(); -#endif } else { @@ -3743,10 +3152,6 @@ private: pDatabase->m_pLastNode = this; m_pDatabase = pDatabase; setLinkedToDatabase(); - -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Unlink a node from its F_Database list. @@ -3755,9 +3160,6 @@ private: { if( nodeLinkedToDatabase()) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif // If this is the last dirty node, change the database's // last dirty pointer to point to the previous node, if any. @@ -3772,13 +3174,7 @@ private: if( m_pNextInDatabase) { -#ifdef FLM_CACHE_PROTECT - m_pNextInDatabase->unprotectCachedItem(); -#endif m_pNextInDatabase->m_pPrevInDatabase = m_pPrevInDatabase; -#ifdef FLM_CACHE_PROTECT - m_pNextInDatabase->protectCachedItem(); -#endif } else { @@ -3787,13 +3183,7 @@ private: if( m_pPrevInDatabase) { -#ifdef FLM_CACHE_PROTECT - m_pPrevInDatabase->unprotectCachedItem(); -#endif m_pPrevInDatabase->m_pNextInDatabase = m_pNextInDatabase; -#ifdef FLM_CACHE_PROTECT - m_pPrevInDatabase->protectCachedItem(); -#endif } else { @@ -3804,10 +3194,6 @@ private: m_pNextInDatabase = NULL; m_pDatabase = NULL; unsetLinkedToDatabase(); - -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } } @@ -3818,28 +3204,15 @@ private: F_CachedNode ** ppHashBucket = gv_XFlmSysData.pNodeCacheMgr->nodeHash( m_nodeInfo.ui64NodeId); -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif - flmAssert( m_pNewerVersion == NULL); m_pPrevInBucket = NULL; if ((m_pNextInBucket = *ppHashBucket) != NULL) { -#ifdef FLM_CACHE_PROTECT - m_pNextInBucket->unprotectCachedItem(); -#endif m_pNextInBucket->m_pPrevInBucket = this; -#ifdef FLM_CACHE_PROTECT - m_pNextInBucket->protectCachedItem(); -#endif } -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif *ppHashBucket = this; } @@ -3847,32 +3220,16 @@ private: // Assumes that the node cache mutex has already been locked. FINLINE void unlinkFromHashBucket( void) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif - flmAssert( m_pNewerVersion == NULL); if (m_pNextInBucket) { -#ifdef FLM_CACHE_PROTECT - m_pNextInBucket->unprotectCachedItem(); -#endif m_pNextInBucket->m_pPrevInBucket = m_pPrevInBucket; -#ifdef FLM_CACHE_PROTECT - m_pNextInBucket->protectCachedItem(); -#endif } if (m_pPrevInBucket) { -#ifdef FLM_CACHE_PROTECT - m_pPrevInBucket->unprotectCachedItem(); -#endif m_pPrevInBucket->m_pNextInBucket = m_pNextInBucket; -#ifdef FLM_CACHE_PROTECT - m_pPrevInBucket->protectCachedItem(); -#endif } else { @@ -3885,10 +3242,6 @@ private: m_pPrevInBucket = NULL; m_pNextInBucket = NULL; - -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Unlink a node from its version list. @@ -3897,73 +3250,33 @@ private: F_CachedNode * pNewerVer, F_CachedNode * pOlderVer) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif - if( (m_pNewerVersion = pNewerVer) != NULL) { -#ifdef FLM_CACHE_PROTECT - pNewerVer->unprotectCachedItem(); -#endif pNewerVer->m_pOlderVersion = this; -#ifdef FLM_CACHE_PROTECT - pNewerVer->protectCachedItem(); -#endif } if ((m_pOlderVersion = pOlderVer) != NULL) { -#ifdef FLM_CACHE_PROTECT - pOlderVer->unprotectCachedItem(); -#endif pOlderVer->m_pNewerVersion = this; -#ifdef FLM_CACHE_PROTECT - pOlderVer->protectCachedItem(); -#endif } - -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Unlink a node from its version list. This routine // Assumes that the node cache mutex has already been locked. FINLINE void unlinkFromVerList( void) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif - if (m_pNewerVersion) { -#ifdef FLM_CACHE_PROTECT - m_pNewerVersion->unprotectCachedItem(); -#endif m_pNewerVersion->m_pOlderVersion = m_pOlderVersion; -#ifdef FLM_CACHE_PROTECT - m_pNewerVersion->protectCachedItem(); -#endif } if (m_pOlderVersion) { -#ifdef FLM_CACHE_PROTECT - m_pOlderVersion->unprotectCachedItem(); -#endif m_pOlderVersion->m_pNewerVersion = m_pNewerVersion; -#ifdef FLM_CACHE_PROTECT - m_pOlderVersion->protectCachedItem(); -#endif } m_pNewerVersion = NULL; m_pOlderVersion = NULL; - -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Link a node into the heap list @@ -3973,28 +3286,14 @@ private: flmAssert( !m_pPrevInHeapList); flmAssert( (m_uiFlags & FDOM_HEAP_ALLOC) == 0); -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif - if( (m_pNextInHeapList = gv_XFlmSysData.pNodeCacheMgr->m_pHeapList) != NULL) { -#ifdef FLM_CACHE_PROTECT - gv_XFlmSysData.pNodeCacheMgr->m_pHeapList->unprotectCachedItem(); -#endif gv_XFlmSysData.pNodeCacheMgr->m_pHeapList->m_pPrevInHeapList = this; -#ifdef FLM_CACHE_PROTECT - gv_XFlmSysData.pNodeCacheMgr->m_pHeapList->protectCachedItem(); -#endif } gv_XFlmSysData.pNodeCacheMgr->m_pHeapList = this; m_uiFlags |= FDOM_HEAP_ALLOC; - -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Unlink a node from the heap list @@ -4003,30 +3302,14 @@ private: { flmAssert( m_uiFlags & FDOM_HEAP_ALLOC); -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif - if (m_pNextInHeapList) { -#ifdef FLM_CACHE_PROTECT - m_pNextInHeapList->unprotectCachedItem(); -#endif m_pNextInHeapList->m_pPrevInHeapList = m_pPrevInHeapList; -#ifdef FLM_CACHE_PROTECT - m_pNextInHeapList->protectCachedItem(); -#endif } if (m_pPrevInHeapList) { -#ifdef FLM_CACHE_PROTECT - m_pPrevInHeapList->unprotectCachedItem(); -#endif m_pPrevInHeapList->m_pNextInHeapList = m_pNextInHeapList; -#ifdef FLM_CACHE_PROTECT - m_pPrevInHeapList->protectCachedItem(); -#endif } else { @@ -4036,10 +3319,6 @@ private: m_pPrevInHeapList = NULL; m_pNextInHeapList = NULL; m_uiFlags &= ~FDOM_HEAP_ALLOC; - -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Assumes that the node cache mutex has already been locked. @@ -4047,56 +3326,26 @@ private: { flmAssert( !m_pPrevInOldList); -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif - if( (m_pNextInOldList = gv_XFlmSysData.pNodeCacheMgr->m_pOldList) != NULL) { -#ifdef FLM_CACHE_PROTECT - gv_XFlmSysData.pNodeCacheMgr->m_pOldList->unprotectCachedItem(); -#endif gv_XFlmSysData.pNodeCacheMgr->m_pOldList->m_pPrevInOldList = this; -#ifdef FLM_CACHE_PROTECT - gv_XFlmSysData.pNodeCacheMgr->m_pOldList->protectCachedItem(); -#endif } gv_XFlmSysData.pNodeCacheMgr->m_pOldList = this; - -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } // Assumes that the node cache mutex has already been locked. FINLINE void unlinkFromOldList( void) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif - if (m_pNextInOldList) { -#ifdef FLM_CACHE_PROTECT - m_pNextInOldList->unprotectCachedItem(); -#endif m_pNextInOldList->m_pPrevInOldList = m_pPrevInOldList; -#ifdef FLM_CACHE_PROTECT - m_pNextInOldList->protectCachedItem(); -#endif } if (m_pPrevInOldList) { -#ifdef FLM_CACHE_PROTECT - m_pPrevInOldList->unprotectCachedItem(); -#endif m_pPrevInOldList->m_pNextInOldList = m_pNextInOldList; -#ifdef FLM_CACHE_PROTECT - m_pPrevInOldList->protectCachedItem(); -#endif } else { @@ -4105,32 +3354,28 @@ private: m_pPrevInOldList = NULL; m_pNextInOldList = NULL; - -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } FINLINE FLMUINT memSize( void) { - FLMUINT uiSize = gv_XFlmSysData.pNodeCacheMgr->m_nodeAllocator.getCellSize(); + FLMUINT uiSize = gv_XFlmSysData.pNodeCacheMgr->m_pNodeAllocator->getCellSize(); if (m_pucData) { - uiSize += gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.getTrueSize( + uiSize += gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->getTrueSize( m_uiDataBufSize, getActualPointer( m_pucData)); } if( m_pNodeList) { - uiSize += gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.getTrueSize( + uiSize += gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->getTrueSize( calcNodeListBufSize( m_nodeInfo.uiChildElmCount), getActualPointer( m_pNodeList)); } if( m_ppAttrList) { - uiSize += gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.getTrueSize( + uiSize += gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->getTrueSize( calcAttrListBufSize( m_uiAttrCount), getActualPointer( m_ppAttrList)); } @@ -4146,10 +3391,6 @@ private: { FLMUINT uiSize; -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif - if (m_ui64HighTransId == FLM_MAX_UINT64 && ui64NewTransID != FLM_MAX_UINT64) { @@ -4170,9 +3411,6 @@ private: } m_ui64HighTransId = ui64NewTransID; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } void freePurged( void); diff --git a/xflaim/src/fcollate.cpp b/xflaim/src/fcollate.cpp index a1ad6fa..7a9512e 100644 --- a/xflaim/src/fcollate.cpp +++ b/xflaim/src/fcollate.cpp @@ -25,4267 +25,6 @@ #include "flaimsys.h" -#define shiftN(data,size,distance) \ - f_memmove((FLMBYTE *)(data) + (FLMINT)(distance), \ - (FLMBYTE *)(data), (size_t)(size)) - -typedef struct -{ - FLMBYTE base; - FLMBYTE diacrit; -} BASE_DIACRIT_TABLE; - -typedef struct -{ - FLMUINT16 char_count; // # of characters in table - FLMUINT16 start_char; // start char. - BASE_DIACRIT_TABLE * table; - -} BASE_DIACRIT; - -typedef struct -{ - FLMBYTE key; // character key to search on - FLMBYTE * charPtr; // character pointer for matched key -} TBL_B_TO_BP; - -typedef struct -{ - FLMBYTE ByteValue; - FLMUINT16 WordValue; -} BYTE_WORD_TBL; - -// Static functions - -FSTATIC RCODE flmColStr2WPStr( - const FLMBYTE * pucColStr, - FLMUINT uiColStrLen, - FLMBYTE * pucWPStr, - FLMUINT * puiWPStrLen, - FLMUINT uiLang, - FLMUINT * puiUnconvChars, - FLMBOOL * pbDataTruncated, - FLMBOOL * pbFirstSubstring); - -FSTATIC RCODE flmWPCmbSubColBuf( - FLMBYTE * pucWPStr, - FLMUINT * uiWPStrLen, - FLMUINT uiMaxWPBytes, - const FLMBYTE * pucSubColBuf, - FLMBOOL bHebrewArabic, - FLMUINT * puiSubColBitPos); - -FSTATIC FLMUINT flmWPToMixed( - FLMBYTE * pucWPStr, - FLMUINT uiWPStrLen, - const FLMBYTE * pucLowUpBitStr, - FLMUINT uiLang); - -FSTATIC FLMUINT16 flmWPZenToHankaku( - FLMUINT16 ui16WpChar, - FLMUINT16 * pui16DakutenOrHandakuten); - -FSTATIC FLMUINT16 flmWPHanToZenkaku( - FLMUINT16 ui16WpChar, - FLMUINT16 ui16NextWpChar, - FLMUINT16 * pui16Zenkaku); - -FSTATIC FLMBOOL flmWPCmbcar( - FLMUINT16 * pui16WpChar, - FLMUINT16 ui16BaseChar, - FLMINT16 ui16DiacriticChar); - -FSTATIC RCODE flmAsiaColStr2WPStr( - const FLMBYTE * pucColStr, - FLMUINT uiColStrLen, - FLMBYTE * pucWPStr, - FLMUINT * puiWPStrLen, - FLMUINT * puiUnconvChars, - FLMBOOL * pbDataTruncated, - FLMBOOL * pbFirstSubstring); - -FSTATIC RCODE flmAsiaParseSubCol( - FLMBYTE * pucWPStr, - FLMUINT * puiWPStrLen, - FLMUINT uiMaxWPBytes, - const FLMBYTE * pucSubColBuf, - FLMUINT * puiSubColBitPos); - -FSTATIC RCODE flmAsiaParseCase( - FLMBYTE * pucWPStr, - FLMUINT * puiWPStrLen, - FLMUINT uiMaxWPBytes, - const FLMBYTE * pucCaseBits, - FLMUINT * puiColBytesProcessed); - -#define MAX_COL_OPCODE COLL_TRUNCATED // Max. opcode for any collation markers -#define WP_MAX_CAR60_SIZE NCHSETS -#define SET_CASE_BIT 0x01 -#define SET_KATAKANA_BIT 0x01 -#define SET_WIDTH_BIT 0x02 -#define COLS_ASIAN_MARKS 0x140 -#define COLS_ASIAN_MARK_VAL 0x40 // Without 0x100 - -#define ASCTBLLEN 95 -#define MNTBLLEN 219 -#define SYMTBLLEN 9 -#define GRKTBLLEN 219 -#define CYRLTBLLEN 200 -#define HEBTBL1LEN 27 -#define HEBTBL2LEN 35 -#define AR1TBLLEN 158 -#define AR2TBLLEN 179 - -#define Upper_JP_A 0x2520 -#define Upper_JP_Z 0x2539 -#define Upper_KR_A 0x5420 -#define Upper_KR_Z 0x5439 -#define Upper_CS_A 0x82FC -#define Upper_CS_Z 0x8316 -#define Upper_CT_A 0xA625 -#define Upper_CT_Z 0xA63E - -#define Lower_JP_a 0x2540 -#define Lower_JP_z 0x2559 -#define Lower_KR_a 0x5440 -#define Lower_KR_z 0x5459 -#define Lower_CS_a 0x82DC -#define Lower_CS_z 0x82F5 -#define Lower_CT_a 0xA60B -#define Lower_CT_z 0xA624 - -// # of characters in each character set. -// CHANGING ANY OF THESE DEFINES WILL CAUSE BUGS! - -#define ASC_N 95 -#define ML1_N 242 -#define ML2_N 145 -#define BOX_N 88 -#define TYP_N 103 -#define ICN_N 255 -#define MTH_N 238 -#define MTX_N 229 -#define GRK_N 219 -#define HEB_N 123 -#define CYR_N 250 -#define KAN_N 63 -#define USR_N 255 -#define ARB_N 196 -#define ARS_N 220 - -// TOTAL: 1447 WP + 255 User Characters - -#define C_N ASC_N + ML1_N + ML2_N + BOX_N +\ - MTH_N + MTX_N + TYP_N + ICN_N +\ - GRK_N + HEB_N + CYR_N + KAN_N +\ - USR_N + ARB_N + ARS_N - -// State table constants for double character sorting - -#define STATE1 1 -#define STATE2 2 -#define STATE3 3 -#define STATE4 4 -#define STATE5 5 -#define STATE6 6 -#define STATE7 7 -#define STATE8 8 -#define STATE9 9 -#define STATE10 10 -#define STATE11 11 -#define AFTERC 12 -#define AFTERH 13 -#define AFTERL 14 -#define INSTAE 15 -#define INSTOE 16 -#define INSTSG 17 -#define INSTIJ 18 -#define WITHAA 19 - -#define START_COL 12 -#define START_ALL (START_COL + 1) // all US and european -#define START_DK (START_COL + 2) // Danish -#define START_IS (START_COL + 3) // Icelandic -#define START_NO (START_COL + 4) // Norwegian -#define START_SU (START_COL + 5) // Finnish -#define START_SV (START_COL + 5) // Swedish -#define START_YK (START_COL + 6) // Ukrain -#define START_TK (START_COL + 7) // Turkish -#define START_CZ (START_COL + 8) // Czech -#define START_SL (START_COL + 8) // Slovak - -#define FIXUP_AREA_SIZE 24 // Number of characters to fix up - -// Collation tables - -/**************************************************************************** -Desc: Table of # of characters in each character set -****************************************************************************/ -FLMBYTE fwp_c60_max[] = -{ - ASC_N, // ascii - ML1_N, // multinational 1 - ML2_N, // multinational 2 - BOX_N, // line draw - TYP_N, // typographic - ICN_N, // icons - MTH_N, // math - MTX_N, // math extension - GRK_N, // Greek - HEB_N, // Hebrew - CYR_N, // Cyrillic - Russian - KAN_N, // Kana - USR_N, // user - ARB_N, // Arabic - ARS_N, // Arabic Script -}; - -/**************************************************************************** -Desc: Base character location table - Bit mapped table. (1) - corresponding base char is in same - set as combined - (0) - corresponding base char is in ascii set - -Notes: In the following table, the bits are numbered from left - to right relative to each individual byte. - EX. 00000000b ;0-7 - bit# 01234567 -****************************************************************************/ -FLMBYTE fwp_ml1_cb60[] = -{ - 0x00, // 0-7 - 0x00, // 8-15 - 0x00, // 16-23 - 0x00, // 24-31 - 0x00, // 32-39 - 0x00, // 40-47 - 0x55, // 48-55 - 0x00, // 56-63 - 0x00, // 64-71 - 0x00, // 72-79 - 0x00, // 80-87 - 0x00, // 88-95 - 0x00, // 96-103 - 0x00, // 104-111 - 0x00, // 112-119 - 0x00, // 120-127 - 0x14, // 128-135 - 0x44, // 136-143 - 0x00, // 144-151 - 0x00, // 152-159 - 0x00, // 160-167 - 0x00, // 168-175 - 0x00, // 176-183 - 0x00, // 184-191 - 0x00, // 192-199 - 0x00, // 200-207 - 0x00, // 208-215 - 0x00, // 216-223 - 0x00, // 224-231 - 0x04, // 232-239 - 0x00, // 240-241 -}; - -/**************************************************************************** -Desc: Format of index: - 2 words before = count. - word before = start character. - db code for base char. - db code for diacritic -Notes: Diacritical char is always in same set as composed char - base is in same set if other table indicates, else in ASCII -****************************************************************************/ -BASE_DIACRIT_TABLE fwp_ml1c_table[] = -{ - {'A',acute}, - {'a',acute}, - {'A',circum}, - {'a',circum}, - {'A',umlaut}, - {'a',umlaut}, - {'A',grave}, - {'a',grave}, - {'A',ring}, - {'a',ring}, - {0xff,0xff}, // no AE diagraph - {0xff,0xff}, // no ae diagraph - {'C',cedilla}, - {'c',cedilla}, - {'E',acute}, - {'e',acute}, - {'E',circum}, - {'e',circum}, - {'E',umlaut}, - {'e',umlaut}, - {'E',grave}, - {'e',grave}, - {'I',acute}, - {dotlesi,acute}, - {'I',circum}, - {dotlesi,circum}, - {'I',umlaut}, - {dotlesi,umlaut}, - {'I',grave}, - {dotlesi,grave}, - {'N',tilde}, - {'n',tilde}, - {'O',acute}, - {'o',acute}, - {'O',circum}, - {'o',circum}, - {'O',umlaut}, - {'o',umlaut}, - {'O',grave}, - {'o',grave}, - {'U',acute}, - {'u',acute}, - {'U',circum}, - {'u',circum}, - {'U',umlaut}, - {'u',umlaut}, - {'U',grave}, - {'u',grave}, - {'Y',umlaut}, - {'y',umlaut}, - {'A',tilde}, - {'a',tilde}, - {'D',crossb}, - {'d',crossb}, - {'O',slash}, - {'o',slash}, - {'O',tilde}, - {'o',tilde}, - {'Y',acute}, - {'y',acute}, - {0xff,0xff}, // no eth - {0xff,0xff}, // no eth - {0xff,0xff}, // no Thorn - {0xff,0xff}, // no Thorn - {'A',breve}, - {'a',breve}, - {'A',macron}, - {'a',macron}, - {'A',ogonek}, - {'a',ogonek}, - {'C',acute}, - {'c',acute}, - {'C',caron}, - {'c',caron}, - {'C',circum}, - {'c',circum}, - {'C',dota}, - {'c',dota}, - {'D',caron}, - {'d',caron}, - {'E',caron}, - {'e',caron}, - {'E',dota}, - {'e',dota}, - {'E',macron}, - {'e',macron}, - {'E',ogonek}, - {'e',ogonek}, - {'G',acute}, - {'g',acute}, - {'G',breve}, - {'g',breve}, - {'G',caron}, - {'g',caron}, - {'G',cedilla}, - {'g',aposab}, - {'G',circum}, - {'g',circum}, - {'G',dota}, - {'g',dota}, - {'H',circum}, - {'h',circum}, - {'H',crossb}, - {'h',crossb}, - {'I',dota}, - {dotlesi,dota}, - {'I',macron}, - {dotlesi,macron}, - {'I',ogonek}, - {'i',ogonek}, - {'I',tilde}, - {dotlesi,tilde}, - {0xff,0xff}, // no IJ digraph - {0xff,0xff}, // no ij digraph - {'J',circum}, - {dotlesj,circum}, - {'K',cedilla}, - {'k',cedilla}, - {'L',acute}, - {'l',acute}, - {'L',caron}, - {'l',caron}, - {'L',cedilla}, - {'l',cedilla}, - {'L',centerd}, - {'l',centerd}, - {'L',stroke}, - {'l',stroke}, - {'N',acute}, - {'n',acute}, - {'N',aposba}, - {'n',aposba}, - {'N',caron}, - {'n',caron}, - {'N',cedilla}, - {'n',cedilla}, - {'O',dacute}, - {'o',dacute}, - {'O',macron}, - {'o',macron}, - {0xff,0xff}, // OE digraph - {0xff,0xff}, // oe digraph - {'R',acute}, - {'r',acute}, - {'R',caron}, - {'r',caron}, - {'R',cedilla}, - {'r',cedilla}, - {'S',acute}, - {'s',acute}, - {'S',caron}, - {'s',caron}, - {'S',cedilla}, - {'s',cedilla}, - {'S',circum}, - {'s',circum}, - {'T',caron}, - {'t',caron}, - {'T',cedilla}, - {'t',cedilla}, - {'T',crossb}, - {'t',crossb}, - {'U',breve}, - {'u',breve}, - {'U',dacute}, - {'u',dacute}, - {'U',macron}, - {'u',macron}, - {'U',ogonek}, - {'u',ogonek}, - {'U',ring}, - {'u',ring}, - {'U',tilde}, - {'u',tilde}, - {'W',circum}, - {'w',circum}, - {'Y',circum}, - {'y',circum}, - {'Z',acute}, - {'z',acute}, - {'Z',caron}, - {'z',caron}, - {'Z',dota}, - {'z',dota}, - {0xff,0xff}, // no Eng - {0xff,0xff}, // no eng - {'D',macron}, - {'d',macron}, - {'L',macron}, - {'l',macron}, - {'N',macron}, - {'n',macron}, - {'R',grave}, - {'r',grave}, - {'S',macron}, - {'s',macron}, - {'T',macron}, - {'t',macron}, - {'Y',breve}, - {'y',breve}, - {'Y',grave}, - {'y',grave}, - {'D',aposbes}, - {'d',aposbes}, - {'O',aposbes}, - {'o',aposbes}, - {'U',aposbes}, - {'u',aposbes}, - {'E',breve}, - {'e',breve}, - {'I',breve}, - {dotlesi,breve}, - {0xff,0xff}, // no dotless I - {0xff,0xff}, // no dotless i - {'O',breve}, - {'o',breve} -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -BASE_DIACRIT fwp_ml1c = -{ - 216, // # of characters in table - 26, // start char - fwp_ml1c_table, -}; - -/**************************************************************************** -Desc: Format of index: - 2 words before = count. - word before = start character. - db code for base char. - db code for diacritic -Notes: Diacritical char is always in same set as composed char - base is in same set -****************************************************************************/ -static BASE_DIACRIT_TABLE fwp_grk_c_table[] = -{ - { 0, ghprime }, // ALPHA High Prime - { 1, gacute }, // alpha acute - { 10, ghprime }, // EPSILON High Prime - { 11, gacute }, // epsilon Acute - { 14, ghprime }, // ETA High Prime - { 15, gacute }, // eta Acute - { 18, ghprime }, // IOTA High Prime - { 19, gacute }, // iota Acute - { 0xFF, 0xFF }, // IOTA Diaeresis - { 19, gdia }, // iota Diaeresis - { 30, ghprime }, // OMICRON High Prime - { 31, gacute }, // omicron Acute - { 42, ghprime }, // UPSILON High Prime - { 43, gacute }, // upsilon Acute - { 0xFF, 0xFF }, // UPSILON Diaeresis - { 43,gdia }, // upsilon Diaeresis - { 50,ghprime }, // OMEGA High Prime - { 51,gacute }, // omega Acute - { 0xFF, 0xFF }, // epsilon (Variant) - { 0xFF, 0xFF }, // theta (Variant) - { 0xFF, 0xFF }, // kappa (Variant) - { 0xFF, 0xFF }, // pi (Variant) - { 0xFF, 0xFF }, // rho (Variant) - { 0xFF, 0xFF }, // sigma (Variant) - { 0xFF, 0xFF }, // UPSILON (Variant) - { 0xFF, 0xFF }, // phi (Variant) - { 0xFF, 0xFF }, // omega (Variant) - { 0xFF, 0xFF }, // Greek Question Mark - { 0xFF, 0xFF }, // Greek Semicolon - { 0xFF, 0xFF }, // High Prime - { 0xFF, 0xFF }, // Low Prime - { 0xFF, 0xFF }, // Acute (Greek) - { 0xFF, 0xFF }, // Diaeresis (Greek) - { gacute,gdia }, // Acute Diaeresis - { ggrave, gdia }, // Grave Diaeresis - { 0xFF, 0xFF }, // Grave (Greek) - { 0xFF, 0xFF }, // Circumflex (Greek) - { 0xFF, 0xFF }, // Smooth Breathing - { 0xFF, 0xFF }, // Rough Breathing - { 0xFF, 0xFF }, // Iota Subscript - { gsmooth, gacute }, // Smooth Breathing Acute - { grough, gacute }, // Rough Breathing Acute - { gsmooth, ggrave }, // Smooth Breathing Grave - { grough, ggrave }, // Rough Breathing Grave - { gsmooth, gcircm }, // Smooth Breathing Circumflex - { grough, gcircm }, // Rough Breathing Circumflex - { gacute, giota }, // Acute w/Iota Subscript - { ggrave, giota }, // Grave w/Iota Subscript - { gcircm, giota }, // Circumflex w/Iota Subscript - { gsmooth, giota }, // Smooth Breathing w/Iota Subscript - { grough, giota }, // Rough Breathing w/Iota Subscript - { gsmact, giota }, // Smooth Breathing Acute w/Iota Subscript - { grgact, giota }, // Rough Breathing Acute w/Iota Subscript - { gsmgrv, giota }, // Smooth Breathing Grave w/Iota Subscript - { grggrv, giota }, // Rough Breathing Grave w/Iota Subscript - { gsmcir, giota }, // Smooth Breathing Circumflex w/Iota Sub - { grgcir, giota }, // Rough Breathing Circumflex w/Iota Sub - { 1, ggrave }, // alpha Grave - { 1, gcircm }, // alpha Circumflex - { 1, giota }, // alpha w/Iota - { 1, gactio }, // alpha Acute w/Iota - { 1, ggrvio }, // alpha Grave w/Iota - { 1, gcirio }, // alpha Circumflex w/Iota - { 1, gsmooth }, // alpha Smooth - { 1, gsmact }, // alpha Smooth Acute - { 1, gsmgrv }, // alpha Smooth Grave - { 1, gsmcir }, // alpha Smooth Circumflex - { 1, gsmio }, // alpha Smooth w/Iota - { 1, gsmaio }, // alpha Smooth Acute w/Iota - { 1, gsmgvio }, // alpha Smooth Grave w/Iota - { 1, gsmcio }, // alpha Smooth Circumflex w/Iota - { 1, grough }, // alpha Rough - { 1, grgact }, // alpha Rough Acute - { 1, grggrv }, // alpha Rough Grave - { 1, grgcir }, // alpha Rough Circumflex - { 1, grgio }, // alpha Rough w/Iota - { 1, grgaio }, // alpha Rough Acute w/Iota - { 1, grggvio }, // alpha Rough Grave w/Iota - { 1, grgcio }, // alpha Rough Circumflex w/Iota - { 11, ggrave }, // epsilon Grave - { 11, gsmooth }, // epsilon Smooth - { 11, gsmact }, // epsilon Smooth Acute - { 11, gsmgrv }, // epsilon Smooth Grave - { 11, grough }, // epsilon Rough - { 11, grgact }, // epsilon Rough Acute - { 11, grggrv }, // epsilon Rough Grave - { 15, ggrave }, // eta Grave - { 15, gcircm }, // eta Circumflex - { 15, giota }, // eta w/Iota - { 15, gactio }, // eta Acute w/Iota - { 15, ggrvio }, // eta Grave w/Iota - { 15, gcirio }, // eta Circumflex w/Iota - { 15, gsmooth }, // eta Smooth - { 15, gsmact }, // eta Smooth Acute - { 15, gsmgrv }, // eta Smooth Grave - { 15, gsmcir }, // eta Smooth Circumflex - { 15, gsmio }, // eta Smooth w/Iota - { 15, gsmaio }, // eta Smooth Acute w/Iota - { 15, gsmgvio }, // eta Smooth Grave w/Iota - { 15, gsmcio }, // eta Smooth Circumflex w/Iota - { 15, grough }, // eta Rough - { 15, grgact }, // eta Rough Acute - { 15, grggrv }, // eta Rough Grave - { 15, grgcir }, // eta Rough Circumflex - { 15, grgio }, // eta Rough w/Iota - { 15, grgaio }, // eta Rough Acute w/Iota - { 15, grggvio }, // eta Rough Grave w/Iota - { 15, grgcio }, // eta Rough Circumflex w/Iota - { 19, ggrave }, // iota Grave - { 19, gcircm }, // iota Circumflex - { 19, gactdia }, // iota Acute Diaeresis - { 19, ggrvdia }, // iota Grave Diaeresis - { 19, gsmooth }, // iota Smooth - { 19, gsmact }, // iota Smooth Acute - { 19, gsmgrv }, // iota Smooth Grave - { 19, gsmcir }, // iota Smooth Circumflex - { 19, grough }, // iota Rough - { 19, grgact }, // iota Rough Acute - { 19, grggrv }, // iota Rough Grave - { 19, grgcir }, // iota Rough Circumflex - { 31, ggrave }, // omicron Grave - { 31, gsmooth }, // omicron Smooth - { 31, gsmact }, // omicron Smooth Acute - { 31, gsmgrv }, // omicron Smooth Grave - { 31, grough }, // omicron Rough - { 31, grgact }, // omicron Rough Acute - { 31, grggrv }, // omicron Rough Grave - { 0xFF, 0xFF }, // rho rough - { 0xFF, 0xFF }, // rho smooth - { 43, ggrave }, // upsilon Grave - { 43, gcircm }, // upsilon Circumflex - { 43, gactdia }, // upsilon Acute Diaeresis - { 43, ggrvdia }, // upsilon Grave Diaeresis - { 43, gsmooth }, // upsilon Smooth - { 43, gsmact }, // upsilon Smooth Acute - { 43, gsmgrv }, // upsilon Smooth Grave - { 43, gsmcir }, // upsilon Smooth Circumflex - { 43, grough }, // upsilon Rough - { 43, grgact }, // upsilon Rough Acute - { 43, grggrv }, // upsilon Rough Grave - { 43, grgcir }, // upsilon Rough Circumflex - { 51, ggrave }, // omega Grave - { 51, gcircm }, // omega Circumflex - { 51, giota }, // omega w/Iota - { 51, gactio }, // omega Acute w/Iota - { 51, ggrvio }, // omega Grave w/Iota - { 51, gcirio }, // omega Circumflex w/Iota - { 51, gsmooth }, // omega Smooth - { 51, gsmact }, // omega Smooth Acute - { 51, gsmgrv }, // omega Smooth Grave - { 51, gsmcir }, // omega Smooth Circumflex - { 51, gsmio }, // omega Smooth w/Iota - { 51, gsmaio }, // omega Smooth Acute w/Iota - { 51, gsmgvio }, // omega Smooth Grave w/Iota - { 51, gsmcio }, // omega Smooth Circumflex w/Iota - { 51, grough }, // omega Rough - { 51, grgact }, // omega Rough Acute - { 51, grggrv }, // omega Rough Grave - { 51, grgcir }, // omega Rough Circumflex - { 51, grgio }, // omega Rough w/Iota - { 51, grgaio }, // omega Rough Acute w/Iota - { 51, grggvio }, // omega Rough Grave w/Iota - { 51, grgcio} // omega Rough Circumflex w/Iota -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -static BASE_DIACRIT fwp_grk_c = -{ - 163, // # of characters in table. - 52, // start char. - fwp_grk_c_table -}; - -/**************************************************************************** -Desc: Format of index: - 2 words before = count. - word before = start character. - db code for base char. - db code for diacritic -Notes: Diacritical char is always in same set as composed char - base is in same set -****************************************************************************/ -static BASE_DIACRIT_TABLE fwp_rus_c_table[] = -{ - { 14, 204 }, // ZHE with right descender - { 15, 204 }, // zhe with right descender - { 0xFF, 0xFF}, // DZE - { 0xFF, 0xFF}, // dze - { 0xFF, 0xFF}, // Z - { 0xFF, 0xFF}, // z - { 18, 206 }, // II with macron - { 19, 206}, // ii with macron - { 0xFF, 0xFF}, // I - { 0xFF, 0xFF}, // i - { 0xFF, 0xFF}, // YI - { 0xFF, 0xFF}, // yi - { 0xFF, 0xFF}, // I ligature - { 0xFF, 0xFF}, // i ligature - { 0xFF, 0xFF}, // JE - { 0xFF, 0xFF}, // je - { 0xFF, 0xFF}, // KJE - { 0xFF, 0xFF}, // kje - { 22, 204}, // KA with right descender - { 23, 204}, // ka with right descender - { 22, 205 }, // KA ogonek - { 23, 205 }, // ka ogonek - { 0xFF, 0xFF}, // KA vertical bar - { 0xFF, 0xFF}, // ka vertical bar - { 0xFF, 0xFF}, // LJE - { 0xFF, 0xFF}, // lje - { 28, 204 }, // EN with right descender - { 29, 204 }, // en with right descender - { 0xFF, 0xFF}, // NJE - { 0xFF, 0xFF}, // nje - { 0xFF, 0xFF}, // ROUND OMEGA - { 0xFF, 0xFF}, // round omega - { 0xFF, 0xFF}, // OMEGA - { 0xFF, 0xFF}, // omega - { 0xFF, 0xFF}, // TSHE - { 0xFF, 0xFF}, // tshe - { 0xFF, 0xFF}, // SHORT U - { 0xFF, 0xFF}, // short u - { 40, 206}, // U with macron - { 41, 206 }, // u with macron - { 0xFF, 0xFF}, // STRAIGHT U - { 0xFF, 0xFF}, // straight u - { 0xFF, 0xFF}, // STRAIGHT U BAR - { 0xFF, 0xFF}, // straight u bar - { 0xFF, 0xFF}, // OU ligature - { 0xFF, 0xFF}, // ou ligature - { 44, 204 }, // KHA with right descender - { 45, 204 }, // kha with right descender - { 44, 205 }, // KHA ogonek - { 45, 205 }, // kha ogonek - { 0xFF, 0xFF}, // H - { 0xFF, 0xFF}, // h - { 0xFF, 0xFF}, // OMEGA titlo - { 0xFF, 0xFF}, // omega titlo - { 0xFF, 0xFF}, // DZHE - { 0xFF, 0xFF}, // dzhe - { 48, 204 }, // CHE with right descender - { 49, 204 }, // che with right descender - { 0xFF, 0xFF}, // CHE vertical bar - { 0xFF, 0xFF}, // che vertical bar - { 0xFF, 0xFF}, // SHCHA (variant) - { 0xFF, 0xFF}, // shcha (variant) - { 0xFF, 0xFF}, // YAT - { 0xFF, 0xFF}, // yat - { 0xFF, 0xFF}, // YUS BOLSHOI - { 0xFF, 0xFF}, // yus bolshoi - { 0xFF, 0xFF}, // BIG MALYI - { 0xFF, 0xFF}, // big malyi - { 0xFF, 0xFF}, // KSI - { 0xFF, 0xFF}, // ksi - { 0xFF, 0xFF}, // PSI - { 0xFF, 0xFF}, // psi - { 0xFF, 0xFF}, // FITA - { 0xFF, 0xFF}, // fita - { 0xFF, 0xFF}, // IZHITSA - { 0xFF, 0xFF}, // izhitsa - { 00, racute}, // Russian A acute - { 01, racute }, // Russian a acute - { 10, racute }, // Russian IE acute - { 11, racute }, // Russian ie acute - { 78, racute }, // Russian E acute - { 79, racute }, // Russian e acute - { 18, racute }, // Russian II acute - { 19, racute }, // Russian ii acute - { 88, racute }, // Russian I acute - { 89, racute }, // Russian i acute - { 90, racute }, // Russian YI acute - { 91, racute }, // Russian yi acute - { 30, racute }, // Russian O acute - { 31, racute }, // Russian o acute - { 40, racute }, // Russian U acute - { 41, racute }, // Russian u acute - { 56, racute }, // Russian YERI acute - { 57, racute }, // Russian yeri acute - { 60, racute }, // Russian REVERSED E acute - { 61, racute }, // Russian reversed e acute - { 62, racute }, // Russian IU acute - { 63, racute }, // Russian iu acute - { 64, racute }, // Russian IA acute - { 65, racute }, // Russian ia acute - { 00, rgrave }, // Russian A grave - { 01, rgrave }, // Russian a grave - { 10, rgrave }, // Russian IE grave - { 11, rgrave }, // Russian ie grave - { 12, rgrave }, // Russian YO grave - { 13, rgrave }, // Russian yo grave - { 18, rgrave }, // Russian I grave - { 19, rgrave }, // Russian i grave - { 30, rgrave }, // Russian O grave - { 31, rgrave }, // Russian o grave - { 40, rgrave }, // Russian U grave - { 41, rgrave }, // Russian u grave - { 56, rgrave }, // Russian YERI grave - { 57, rgrave }, // Russian yeri grave - { 60, rgrave }, // Russian REVERSED E grave - { 61, rgrave }, // Russian reversed e grave - { 62, rgrave }, // Russian IU grave - { 63, rgrave }, // Russian iu grave - { 64, rgrave }, // Russian IA grave - { 65, rgrave} // Russian ia grave -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -static BASE_DIACRIT fwp_rus_c = -{ - 120, // # of characters in table. - 156, // start char. - fwp_rus_c_table, -}; - -/**************************************************************************** -Desc: Table of pointers to character component tables. -****************************************************************************/ -BASE_DIACRIT * fwp_car60_c[ NCHSETS] = -{ - (BASE_DIACRIT*)0, // no composed characters for ascii. - &fwp_ml1c, - (BASE_DIACRIT*)0, // no composed characters for multinational 2 - (BASE_DIACRIT*)0, // no composed characters for line draw. - (BASE_DIACRIT*)0, // no composed characters for typographic. - (BASE_DIACRIT*)0, // no composed characters for icons. - (BASE_DIACRIT*)0, // no composed characters for math. - (BASE_DIACRIT*)0, // no composed characters for math extension. - &fwp_grk_c, // Greek - (BASE_DIACRIT*)0, // Hebrew - &fwp_rus_c, // Cyrillic - Russian - (BASE_DIACRIT*)0, // Hiragana or Katakana (Japanese) - (BASE_DIACRIT*)0, // no composed characters for user. - (BASE_DIACRIT*)0, // no composed characters for Arabic. - (BASE_DIACRIT*)0, // no composed characters for Arabic Script . -}; - -/**************************************************************************** -Desc: Map special chars in CharSet (x24) to collation values -****************************************************************************/ -BYTE_WORD_TBL fwp_Ch24ColTbl[] = // Position in the table+1 is subColValue -{ - {1, COLLS+2}, // comma - {2, COLLS+1}, // maru - {5, COLS_ASIAN_MARKS+2}, // chuuten - {10, COLS_ASIAN_MARKS}, // dakuten - {11, COLS_ASIAN_MARKS+1}, // handakuten - {43, COLS2+2}, // angled brackets - {44, COLS2+3}, // - {49, COLS2+2}, // pointy brackets - {50, COLS2+3}, - {51, COLS2+2}, // double pointy brackets - {52, COLS2+3}, - {53, COLS1}, // Japanese quotes - {54, COLS1}, - {55, COLS1}, // hollow Japanese quotes - {56, COLS1}, - {57, COLS2+2}, // filled rounded brackets - {58, COLS2+3} -}; - -/**************************************************************************** -Desc: Kana subcollation values - BIT 0: set if large char - BIT 1: set if voiced - BIT 2: set if half voiced -Notes: - To save space should be nibbles - IMPORTANT: - The '1' entries that do not have - a matching '0' entry have been - changed to zero to save space in - the subcollation area. - The original table is listed below. -****************************************************************************/ -FLMBYTE KanaSubColTbl[] = -{ - 0,1,0,1,0,1,0,1,0,1, // a A i I u U e E o O - 1,3,0,3,0,3,1,3,0,3, // KA GA KI GI KU GU KE GE KO GO - 0,3,0,3,0,3,0,3,0,3, // SA ZA SHI JI SU ZU SE ZE SO ZO - 0,3,0,3,0,1,3,0,3,0,3, // TA DA CHI JI tsu TSU ZU TE DE TO DO - 0,0,0,0,0, // NA NI NU NE NO - 0,3,5,0,3,5,0,3,5, // HA BA PA HI BI PI FU BU PU - 0,3,5,0,3,5, // HE BE PE HO BO PO - 0,0,0,0,0, // MA MI MU ME MO - 0,1,0,1,0,1, // ya YA yu YU yo YO - 0,0,0,0,0, // RA RI RU RE RO - 0,1,0,0,0, // wa WA WI WE WO - 0,3,0,0 // N VU ka ke -}; - -/**************************************************************************** -Desc: Map katakana (CharSet x26) to collation values - kana collating values are two byte values - where the high byte is 0x01. -****************************************************************************/ -FLMBYTE KanaColTbl[] = -{ - 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, // a A i I u U e E o O - 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, // KA GA KI GI KU GU KE GE KO GO - 10,10,11,11,12,12,13,13,14,14, // SA ZA SHI JI SU ZU SE ZE SO ZO - 15,15,16,16,17,17,17,18,18,19,19, // TA DA CHI JI tsu TSU ZU TE DE TO DO - 20,21,22,23,24, // NA NI NU NE NO - 25,25,25,26,26,26,27,27,27, // HA BA PA HI BI PI FU BU PU - 28,28,28,29,29,29, // HE BE PE HO BO PO - 30,31,32,33,34, // MA MI MU ME MO - 35,35,36,36,37,37, // ya YA yu YU yo YO - 38,39,40,41,42, // RA RI RU RE RO - 43,43,44,45,46, // wa WA WI WE WO - 47, 2, 5, 8 // N VU ka ke -}; - -/**************************************************************************** -Desc: Map KataKana collated value to vowel value for - use for the previous char. -****************************************************************************/ -FLMBYTE KanaColToVowel[] = -{ - 0,1,2,3,4, // a i u e o - 0,1,2,3,4, // ka ki ku ke ko - 0,1,2,3,4, // sa shi su se so - 0,1,2,3,4, // ta chi tsu te to - 0,1,2,3,4, // na ni nu ne no - 0,1,2,3,4, // ha hi hu he ho - 0,1,2,3,4, // ma mi mu me mo - 0,2,4, // ya yu yo - 0,1,2,3,4, // ra ri ru re ro - 0,1,3,4, // wa wi we wo -}; - -/**************************************************************************** -Desc: Convert Zenkaku (double wide) to Hankaku (single wide) - Character set 0x24 maps to single wide chars in other char sets. - This enables collation values to be found on some symbols. - This is also used to convert symbols from hankaku to Zen24. -****************************************************************************/ -BYTE_WORD_TBL Zen24ToHankaku[] = -{ - { 0 ,0x0020 }, // space - { 1 ,0x0b03 }, // japanese comma - { 2 ,0x0b00 }, // circle period - { 3 , 44 }, // comma - { 4 , 46 }, // period - { 5 ,0x0b04 }, // center dot - { 6 , 58 }, // colon - { 7 , 59 }, // semicolon - { 8 , 63 }, // question mark - { 9 , 33 }, // exclamation mark - { 10 ,0x0b3d }, // dakuten - { 11 ,0x0b3e }, // handakuten - { 12 ,0x0106 }, // accent mark - { 13 , 96 }, // accent mark - { 14 ,0x0107 }, // umlat - { 15 , 94 }, // caret - { 16 ,0x0108 }, // macron - { 17 , 95 }, // underscore - { 27 ,0x0b0f }, // extend vowel - { 28 ,0x0422 }, // mdash - { 29 , 45 }, // hyphen - { 30 , 47 }, // slash - { 31 ,0x0607 }, // backslash - { 32 , 126 }, // tilde - { 33 ,0x0611 }, // doubleline - { 34 ,0x0609 }, // line - { 37 ,0x041d }, // left apostrophe - { 38 ,0x041c }, // right apostrophe - { 39 ,0x0420 }, // left quote - { 40 ,0x041f }, // right quote - { 41 , 40 }, // left paren - { 42 , 41 }, // right paren - { 45 , 91 }, // left bracket - { 46 , 93 }, // right bracket - { 47 , 123 }, // left curly bracket - { 48 , 125 }, // right curly bracket - { 53 ,0x0b01 }, // left j quote - { 54 ,0x0b02 }, // right j quote - { 59 , 43 }, // plus - { 60 ,0x0600 }, // minus - { 61 ,0x0601 }, // plus/minus - { 62 ,0x0627 }, // times - { 63 ,0x0608 }, // divide - { 64 , 61 }, // equal - { 65 ,0x0663 }, // unequal - { 66 , 60 }, // less - { 67 , 62 }, // greater - { 68 ,0x0602 }, // less/equal - { 69 ,0x0603 }, // greater/equal - { 70 ,0x0613 }, // infinity - { 71 ,0x0666 }, // traingle dots - { 72 ,0x0504 }, // man - { 73 ,0x0505 }, // woman - { 75 ,0x062d }, // prime - { 76 ,0x062e }, // double prime - { 78 ,0x040c }, // yen - { 79 , 36 }, // $ - { 80 ,0x0413 }, // cent - { 81 ,0x040b }, // pound - { 82 , 37 }, // % - { 83 , 35 }, // # - { 84 , 38 }, // & - { 85 , 42 }, // * - { 86 , 64 }, // @ - { 87 ,0x0406 }, // squiggle - { 89 ,0x06b8 }, // filled star - { 90 ,0x0425 }, // hollow circle - { 91 ,0x042c }, // filled circle - { 93 ,0x065f }, // hollow diamond - { 94 ,0x0660 }, // filled diamond - { 95 ,0x0426 }, // hollow box - { 96 ,0x042e }, // filled box - { 97 ,0x0688 }, // hollow triangle - { 99 ,0x0689 }, // hollow upside down triangle - { 103,0x0615 }, // right arrow - { 104,0x0616 }, // left arrow - { 105,0x0617 }, // up arrow - { 106,0x0622 }, // down arrow - { 119,0x060f }, - { 121,0x0645 }, - { 122,0x0646 }, - { 123,0x0643 }, - { 124,0x0644 }, - { 125,0x0642 }, // union - { 126,0x0610 }, // intersection - { 135,0x0655 }, - { 136,0x0656 }, - { 138,0x0638 }, // right arrow - { 139,0x063c }, // left/right arrow - { 140,0x067a }, - { 141,0x0679 }, - { 153,0x064f }, // angle - { 154,0x0659 }, - { 155,0x065a }, - { 156,0x062c }, - { 157,0x062b }, - { 158,0x060e }, - { 159,0x06b0 }, - { 160,0x064d }, - { 161,0x064e }, - { 162,0x050e }, // square root - { 164,0x0604 }, - { 175,0x0623 }, // angstrom - { 176,0x044b }, // percent - { 177,0x051b }, // sharp - { 178,0x051c }, // flat - { 179,0x0509 }, // musical note - { 180,0x0427 }, // dagger - { 181,0x0428 }, // double dagger - { 182,0x0405 }, // paragraph - { 187,0x068f } // big hollow circle -}; - -/**************************************************************************** -Desc: Maps CS26 to CharSet 11 - Used to uncollate characters for FLAIM - placed here for consistency - 0x80 - add dakuten - 0xC0 - add handakuten - 0xFF - no mapping exists -****************************************************************************/ -FLMBYTE MapCS26ToCharSet11[ 86] = -{ - 0x06, // 0 a - 0x10, // 1 A - 0x07, // 2 i - 0x11, // 3 I - 0x08, // 4 u - 0x12, // 5 U - 0x09, // 6 e - 0x13, // 7 E - 0x0a, // 8 o - 0x14, // 9 O - - 0x15, // 0x0a KA - 0x95, // GA - 21 followed by 0x3D dakuten - - 0x16, // 0x0c KI - 0x96, // GI - 0x17, // 0x0e KU - 0x97, // GU - 0x18, // 0x10 KE - 0x98, // GE - 0x19, // 0x12 KO - 0x99, // GO - - 0x1a, // 0x14 SA - 0x9a, // ZA - 0x1b, // 0x16 SHI - 0x9b, // JI - 0x1c, // 0x18 SU - 0x9c, // ZU - 0x1d, // 0x1a SE - 0x9d, // ZE - 0x1e, // 0x1c SO - 0x9e, // ZO - - 0x1f, // 0x1e TA - 0x9f, // DA - 0x20, // 0x20 CHI - 0xa0, // JI - 0x0e, // 0x22 small tsu - 0x21, // 0x23 TSU - 0xa1, // ZU - 0x22, // 0x25 TE - 0xa2, // DE - 0x23, // 0x27 TO - 0xa3, // DO - - 0x24, // 0x29 NA - 0x25, // 0x2a NI - 0x26, // 0x2b NU - 0x27, // 0x2c NE - 0x28, // 0x2d NO - - 0x29, // 0x2e HA - 0xa9, // 0x2f BA - 0xe9, // 0x30 PA - 0x2a, // 0x31 HI - 0xaa, // 0x32 BI - 0xea, // 0x33 PI - 0x2b, // 0x34 FU - 0xab, // 0x35 BU - 0xeb, // 0x36 PU - 0x2c, // 0x37 HE - 0xac, // 0x38 BE - 0xec, // 0x39 PE - 0x2d, // 0x3a HO - 0xad, // 0x3b BO - 0xed, // 0x3c PO - - 0x2e, // 0x3d MA - 0x2f, // 0x3e MI - 0x30, // 0x3f MU - 0x31, // 0x40 ME - 0x32, // 0x41 MO - - 0x0b, // 0x42 small ya - 0x33, // 0x43 YA - 0x0c, // 0x44 small yu - 0x34, // 0x45 YU - 0x0d, // 0x46 small yo - 0x35, // 0x47 YO - - 0x36, // 0x48 RA - 0x37, // 0x49 RI - 0x38, // 0x4a RU - 0x39, // 0x4b RE - 0x3a, // 0x4c RO - - 0xff, // 0x4d small wa - 0x3b, // 0x4e WA - 0xff, // 0x4f WI - 0xff, // 0x50 WE - 0x05, // 0x51 WO - - 0x3c, // 0x52 N - 0xff, // 0x53 VU - 0xff, // 0x54 ka - 0xff // 0x55 ke -}; - -/**************************************************************************** -Desc: Conversion from single (Hankaku) to double (Zenkaku) wide characters - Used in flmWPHanToZenkaku() - Maps from charset 11 to CS24 (punctuation) (starting from 11,0) -****************************************************************************/ -FLMBYTE From0AToZen[] = // ' changed because of windows -{ - 0, 9, 40, 0x53, // sp ! " # - 0x4f, 0x52, 0x54, 38, // $ % & ' - // Was 187 for ! and 186 for ' - 0x29, 0x2a, 0x55, 0x3b, // ( ) * + - 3, 0x1d, 4, 0x1e // , - . / -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMBYTE From0BToZen[] = -{ - 6, 7, 0x42, 0x40, // : ; < = - 0x43, 8, 0x56 // > ? @ -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMBYTE From0CToZen[] = -{ - 0x2d, 0x1f, 0x2e, 0x0f, 0x11, 0x0d // [ BACKSLASH ] ^ _ ` -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMBYTE From0DToZen[] = -{ - 0x2f, 0x22, 0x30, 0x20 // { | } ~ -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMBYTE From8ToZen[] = -{ - 0x5e, 0x7e, 0x5f, 0x7f, 0x5f, 0xFF, 0x60, 0x80, - 0x61, 0x81, 0x62, 0x82, 0x63, 0x83, 0x64, 0x84, - 0x65, 0x85, 0x66, 0x86, 0x67, 0x87, 0x68, 0x88, - 0x69, 0x89, 0x6a, 0x8a, 0x6b, 0x8b, 0x6c, 0x8c, - 0x6d, 0x8d, 0x6e, 0x8e, 0x6f, 0x8f, 0x6f, 0xFF, - 0x70, 0x90, 0x71, 0x91, 0x72, 0x92, 0x73, 0x93, - 0x74, 0x94, 0x75, 0x95 -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMBYTE From11AToZen[] = // 11 to 24 punctuation except dash -{ - 2, // japanese period - 0x35, // left bracket - 0x36, // right bracket - 0x01, // comma - 0x05 // chuuten -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMBYTE From11BToZen[] = // 11 to 26 (katakana) from 11,5 -{ - 0x51, // wo - 0,2,4,6,8,0x42,0x44,0x46,0x22, // small a i u e o ya yu yo tsu - 0xFF, 1, 3, 5, 7, 9, // dash (x241b) a i u e o - 0x0a, 0x0c, 0x0e, 0x10, 0x12, // ka ki ku ke ko - 0x14, 0x16, 0x18, 0x1a, 0x1c, // sa shi su se so - 0x1e, 0x20, 0x23, 0x25, 0x27, // ta chi tsu te to - 0x29, 0x2a, 0x2b, 0x2c, 0x2d, // na ni nu ne no - 0x2e, 0x31, 0x34, 0x37, 0x3a, // ha hi fu he ho - 0x3d, 0x3e, 0x3f, 0x40, 0x41, // ma mi mu me mo - 0x43, 0x45, 0x47, // ya yu yo - 0x48, 0x49, 0x4a, 0x4b, 0x4c, // ra ri ru re ro - 0x4e, 0x52 // WA N -}; // does not have wa WI WE VU ka ke - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMUINT16 fwp_indexi[] = -{ - 0,11,14,15,17,18,19,21,22,23,24,25,26,35,59 -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMUINT16 fwp_indexj[] = // DOUBLE CHAR AREA - LANGUAGES -{ - XFLM_CA_LANG, // Catalan (0) - XFLM_CF_LANG, // Canadian French - XFLM_CZ_LANG, // Czech - XFLM_SL_LANG, // Slovak - XFLM_DE_LANG, // German - XFLM_SD_LANG, // Swiss German - XFLM_ES_LANG, // Spanish (Spain) - XFLM_FR_LANG, // French - XFLM_NL_LANG, // Netherlands - 0xFFFF, // DK_LANG, Danish - support for 'aa' -> a-ring out - 0xFFFF, // NO_LANG, Norwegian - support for 'aa' -> a-ring out - 0x0063, // c - DOUBLE CHARACTERS - STATE ENTRIES - 0x006c, // l - 0x0197, // l with center dot - 0x0063, // c - 0x0125, // ae digraph - 0x01a7, // oe digraph - 0x0068, // h - 0x0068, // h - 0x006c, // l - 0x0101, // center dot alone - 0x006c, // l - 0x0117, // ? (for German) - 0x018b, // ij digraph - 0x0000, // was 'a' - will no longer map 'aa' to a-ring - 0x0000, // was 'a' - - XFLM_CZ_LANG, // SINGLE CHARS - LANGUAGES - XFLM_DK_LANG, - XFLM_NO_LANG, - XFLM_SL_LANG, - XFLM_TK_LANG, - XFLM_SU_LANG, - XFLM_IS_LANG, - XFLM_SV_LANG, - XFLM_YK_LANG, - // SINGLE CHARS - 0x011e, // A Diaeresis - alternate collating sequences - 0x011f, // a Diaeresis - 0x0122, // A Ring - 2 - 0x0123, // a Ring - 0x0124, // AE Diagraph - 4 - 0x0125, // ae diagraph - 0x013e, // O Diaeresis - 6 - 0x013f, // o Diaeresis - 0x0146, // U Diaeresis - 8 - 0x0147, // u Diaeresis - 0x0150, // O Slash - 10 - 0x0151, // o Slash - - 0x0A3a, // CYRILLIC SOFT SIGN - 12 - 0x0A3b, // CYRILLIC soft sign - 0x01ee, // dotless i - turkish - 14 - 0x01ef, // dotless I - turkish - 0x0162, // C Hacek/caron - 1,98 - 16 - 0x0163, // c Hacek/caron - 1,99 - 0x01aa, // R Hacek/caron - 1,170 - 18 - 0x01ab, // r Hacek/caron - 1,171 - 0x01b0, // S Hacek/caron - 1,176 - 20 - 0x01b1, // s Hacek/caron - 1,177 - 0x01ce, // Z Hacek/caron - 1,206 - 22 - 0x01cf, // z Hacek/caron - 1,207 -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMUINT16 fwp_valuea[] = -{ -// DOUBLE CHAR STATE VALUES - STATE1, // 00 - STATE3, - STATE2, - STATE2, - STATE8, - STATE8, - STATE1, - STATE3, - STATE9, - STATE10, // No longer in use - STATE10, // No longer in use - STATE4, - STATE6, - STATE6, - STATE5, - INSTAE, - INSTOE, - AFTERC, - AFTERH, - AFTERL, - STATE7, - STATE6, - INSTSG, // ss for German - INSTIJ, - STATE11, // aa - no longer in use - WITHAA, // aa - no longer in use - -// SINGLE CHARS - LANGUAGES - START_CZ, // Czech - START_DK, // Danish - START_NO, // Norwegian - START_SL, // Slovak - START_TK, // Turkish - START_SU, // Finnish - START_IS, // Icelandic - START_SV, // Swedish - START_YK, // Ukrainian - -// SINGLE CHARS FIXUP AREAS - COLS9, COLS9, COLS9, COLS9, // US & OTHERS - COLS9+1, COLS9+1, COLS9+21, COLS9+21, - COLS9+30, COLS9+30, COLS9+21, COLS9+21, - COLS10+43, COLS10+43, COLS9+12, COLS9+12, - COLS9+3, COLS9+3, COLS9+25, COLS9+25, - COLS9+27, COLS9+27, COLS9+35, COLS9+35, - - COLS9+45, COLS9+45, COLS9+55, COLS9+55, // DANISH - COLS9+42, COLS9+42, COLS9+53, COLS9+53, - COLS9+30, COLS9+30, COLS9+49, COLS9+49, // Oct98 U Diaer no longer to y Diaer - COLS10+43, COLS10+43, COLS9+12, COLS9+12, - COLS9+3, COLS9+3, COLS9+25, COLS9+25, - COLS9+27, COLS9+27, COLS9+35, COLS9+35, - - COLS9, COLS9, COLS9, COLS9, // Icelandic - COLS9+46, COLS9+46, COLS9+50, COLS9+50, - COLS9+30, COLS9+30, COLS9+54, COLS9+54, - COLS10+43, COLS10+43, COLS9+12, COLS9+12, - COLS9+3, COLS9+3, COLS9+25, COLS9+25, - COLS9+27, COLS9+27, COLS9+35, COLS9+35, - - COLS9, COLS9, COLS9+51, COLS9+51, // Norwegian - COLS9+43, COLS9+43, COLS9+21, COLS9+21, - COLS9+30, COLS9+30, COLS9+47, COLS9+47, - COLS10+43, COLS10+43, COLS9+12, COLS9+12, - COLS9+3, COLS9+3, COLS9+25, COLS9+25, - COLS9+27, COLS9+27, COLS9+35, COLS9+35, - - COLS9+48, COLS9+48, COLS9+44, COLS9+44, // Finnish/Swedish - COLS9+1, COLS9+1, COLS9+52, COLS9+52, - COLS9+30, COLS9+30, COLS9+21, COLS9+21, // Oct98 U Diaer no longer to y Diaer - COLS10+43, COLS10+43, COLS9+12, COLS9+12, - COLS9+3, COLS9+3, COLS9+25, COLS9+25, - COLS9+27, COLS9+27, COLS9+35, COLS9+35, - - COLS9, COLS9, COLS9, COLS9, // Ukrain - COLS9+1, COLS9+1, COLS9+21, COLS9+21, - COLS9+30, COLS9+30, COLS9+21, COLS9+21, - COLS10+48, COLS10+48, COLS9+12, COLS9+12, - COLS9+3, COLS9+3, COLS9+25, COLS9+25, - COLS9+27, COLS9+27, COLS9+35, COLS9+35, - - COLS9, COLS9, COLS9, COLS9, // Turkish - COLS9+1, COLS9+1, COLS9+21, COLS9+21, - COLS9+30, COLS9+30, COLS9+21, COLS9+21, - COLS9+43, COLS9+43, COLS9+11, COLS9+11, // dotless i same as - COLS9+3, COLS9+3, COLS9+25, COLS9+25, // the "CH" in Czech - COLS9+27, COLS9+27, COLS9+35, COLS9+35, // works because char - // fails brkcar() - - COLS9, COLS9, COLS9, COLS9, // Czech / Slovak - COLS9+1, COLS9+1, COLS9+21, COLS9+21, - COLS9+30, COLS9+30, COLS9+21, COLS9+21, - COLS10+43, COLS10+43, COLS9+12, COLS9+12, - COLS9+5, COLS9+5, COLS9+26, COLS9+26, // carons - COLS9+28, COLS9+28, COLS9+36, COLS9+36 -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMBYTE fwp_asc60Tbl[ ASCTBLLEN + 2] = -{ - 0x20, // initial character offset!! - ASCTBLLEN, // len of this table - COLLS, // - COLLS+5, // ! - COLS1, // " - COLS6+1, // # - COLS3, // $ - COLS6, // % - COLS6+2, // & - COLS1+1, // ' - COLS2, // ( - COLS2+1, // ) - COLS4+2, // * - COLS4, // + - COLLS+2, // , - COLS4+1, // - - COLLS+1, // . - COLS4+3, // / - COLS8, // 0 - COLS8+1, // 1 - COLS8+2, // 2 - COLS8+3, // 3 - COLS8+4, // 4 - COLS8+5, // 5 - COLS8+6, // 6 - COLS8+7, // 7 - COLS8+8, // 8 - COLS8+9, // 9 - COLLS+3, // : - COLLS+4, // ; - COLS5, // < - COLS5+2, // = - COLS5+4, // > - COLLS+7, // ? - COLS6+3, // @ - COLS9, // A - COLS9+2, // B - COLS9+3, // C - COLS9+6, // D - COLS9+7, // E - COLS9+8, // F - COLS9+9, // G - COLS9+10, // H - COLS9+12, // I - COLS9+14, // J - COLS9+15, // K - COLS9+16, // L - COLS9+18, // M - COLS9+19, // N - COLS9+21, // O - COLS9+23, // P - COLS9+24, // Q - COLS9+25, // R - COLS9+27, // S - COLS9+29, // T - COLS9+30, // U - COLS9+31, // V - COLS9+32, // W - COLS9+33, // X - COLS9+34, // Y - COLS9+35, // Z - COLS9+40, // [ (note: alphabetic - end of list) - COLS6+4, // Backslash - COLS9+41, // ] (note: alphabetic - end of list) - COLS4+4, // ^ - COLS6+5, // _ - COLS1+2, // ` - COLS9, // a - COLS9+2, // b - COLS9+3, // c - COLS9+6, // d - COLS9+7, // e - COLS9+8, // f - COLS9+9, // g - COLS9+10, // h - COLS9+12, // i - COLS9+14, // j - COLS9+15, // k - COLS9+16, // l - COLS9+18, // m - COLS9+19, // n - COLS9+21, // o - COLS9+23, // p - COLS9+24, // q - COLS9+25, // r - COLS9+27, // s - COLS9+29, // t - COLS9+30, // u - COLS9+31, // v - COLS9+32, // w - COLS9+33, // x - COLS9+34, // y - COLS9+35, // z - COLS2+4, // { - COLS6+6, // | - COLS2+5, // } - COLS6+7 // ~ -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMBYTE fwp_mn60Tbl[ MNTBLLEN + 2] = // multinational table -{ - 23, // initial character offset!! - MNTBLLEN, // len of this table - COLS9+27, // German Double s - COLS9+15, // Icelandic k - COLS9+14, // Dotless j - -// IBM Charset - - COLS9, // A Acute - COLS9, // a Acute - COLS9, // A Circumflex - COLS9, // a Circumflex - COLS9, // A Diaeresis or Umlaut - COLS9, // a Diaeresis or Umlaut - COLS9, // A Grave - COLS9, // a Grave - COLS9, // A Ring - COLS9, // a Ring - COLS9+1, // AE digraph - COLS9+1, // ae digraph - COLS9+3, // C Cedilla - COLS9+3, // c Cedilla - COLS9+7, // E Acute - COLS9+7, // e Acute - COLS9+7, // E Circumflex - COLS9+7, // e Circumflex - COLS9+7, // E Diaeresis or Umlaut - COLS9+7, // e Diaeresis or Umlaut - COLS9+7, // E Grave - COLS9+7, // e Grave - COLS9+12, // I Acute - COLS9+12, // i Acute - COLS9+12, // I Circumflex - COLS9+12, // i Circumflex - COLS9+12, // I Diaeresis or Umlaut - COLS9+12, // i Diaeresis or Umlaut - COLS9+12, // I Grave - COLS9+12, // i Grave - COLS9+20, // N Tilde - COLS9+20, // n Tilde - COLS9+21, // O Acute - COLS9+21, // o Acute - COLS9+21, // O Circumflex - COLS9+21, // o Circumflex - COLS9+21, // O Diaeresis or Umlaut - COLS9+21, // o Diaeresis or Umlaut - COLS9+21, // O Grave - COLS9+21, // o Grave - COLS9+30, // U Acute - COLS9+30, // u Acute - COLS9+30, // U Circumflex - COLS9+30, // u Circumflex - COLS9+30, // U Diaeresis or Umlaut - COLS9+30, // u Diaeresis or Umlaut - COLS9+30, // U Grave - COLS9+30, // u Grave - COLS9+34, // Y Diaeresis or Umlaut - COLS9+34, // y Diaeresis or Umlaut - -// IBM foreign - - COLS9, // A Tilde - COLS9, // a Tilde - COLS9+6, // D Cross Bar - COLS9+6, // d Cross Bar - COLS9+21, // O Slash - COLS9+21, // o Slash - COLS9+21, // O Tilde - COLS9+21, // o Tilde - COLS9+34, // Y Acute - COLS9+34, // y Acute - COLS9+6, // Uppercase Eth - COLS9+6, // Lowercase Eth - COLS9+37, // Uppercase Thorn - COLS9+37, // Lowercase Thorn - -// Teletex chars - - COLS9, // A Breve - COLS9, // a Breve - COLS9, // A Macron - COLS9, // a Macron - COLS9, // A Ogonek - COLS9, // a Ogonek - COLS9+3, // C Acute - COLS9+3, // c Acute - COLS9+3, // C Caron or Hachek - COLS9+3, // c Caron or Hachek - COLS9+3, // C Circumflex - COLS9+3, // c Circumflex - COLS9+3, // C Dot Above - COLS9+3, // c Dot Above - COLS9+6, // D Caron or Hachek (Apostrophe Beside) - COLS9+6, // d Caron or Hachek (Apostrophe Beside) - COLS9+7, // E Caron or Hachek - COLS9+7, // e Caron or Hachek - COLS9+7, // E Dot Above - COLS9+7, // e Dot Above - COLS9+7, // E Macron - COLS9+7, // e Macron - COLS9+7, // E Ogonek - COLS9+7, // e Ogonek - COLS9+9, // G Acute - COLS9+9, // g Acute - COLS9+9, // G Breve - COLS9+9, // g Breve - COLS9+9, // G Caron or Hachek - COLS9+9, // g Caron or Hachek - COLS9+9, // G Cedilla (Apostrophe Under) - COLS9+9, // g Cedilla (Apostrophe Over) - COLS9+9, // G Circumflex - COLS9+9, // g Circumflex - COLS9+9, // G Dot Above - COLS9+9, // g Dot Above - COLS9+10, // H Circumflex - COLS9+10, // h Circumflex - COLS9+10, // H Cross Bar - COLS9+10, // h Cross Bar - COLS9+12, // I Dot Above (Sharp Accent) - COLS9+12, // i Dot Above (Sharp Accent) - COLS9+12, // I Macron - COLS9+12, // i Macron - COLS9+12, // I Ogonek - COLS9+12, // i Ogonek - COLS9+12, // I Tilde - COLS9+12, // i Tilde - COLS9+13, // IJ Digraph - COLS9+13, // ij Digraph - COLS9+14, // J Circumflex - COLS9+14, // j Circumflex - COLS9+15, // K Cedilla (Apostrophe Under) - COLS9+15, // k Cedilla (Apostrophe Under) - COLS9+16, // L Acute - COLS9+16, // l Acute - COLS9+16, // L Caron or Hachek (Apostrophe Beside) - COLS9+16, // l Caron or Hachek (Apostrophe Beside) - COLS9+16, // L Cedilla (Apostrophe Under) - COLS9+16, // l Cedilla (Apostrophe Under) - COLS9+16, // L Center Dot - COLS9+16, // l Center Dot - COLS9+16, // L Stroke - COLS9+16, // l Stroke - COLS9+19, // N Acute - COLS9+19, // n Acute - COLS9+19, // N Apostrophe - COLS9+19, // n Apostrophe - COLS9+19, // N Caron or Hachek - COLS9+19, // n Caron or Hachek - COLS9+19, // N Cedilla (Apostrophe Under) - COLS9+19, // n Cedilla (Apostrophe Under) - COLS9+21, // O Double Acute - COLS9+21, // o Double Acute - COLS9+21, // O Macron - COLS9+21, // o Macron - COLS9+22, // OE digraph - COLS9+22, // oe digraph - COLS9+25, // R Acute - COLS9+25, // r Acute - COLS9+25, // R Caron or Hachek - COLS9+25, // r Caron or Hachek - COLS9+25, // R Cedilla (Apostrophe Under) - COLS9+25, // r Cedilla (Apostrophe Under) - COLS9+27, // S Acute - COLS9+27, // s Acute - COLS9+27, // S Caron or Hachek - COLS9+27, // s Caron or Hachek - COLS9+27, // S Cedilla - COLS9+27, // s Cedilla - COLS9+27, // S Circumflex - COLS9+27, // s Circumflex - COLS9+29, // T Caron or Hachek (Apostrophe Beside) - COLS9+29, // t Caron or Hachek (Apostrophe Beside) - COLS9+29, // T Cedilla (Apostrophe Under) - COLS9+29, // t Cedilla (Apostrophe Under) - COLS9+29, // T Cross Bar - COLS9+29, // t Cross Bar - COLS9+30, // U Breve - COLS9+30, // u Breve - COLS9+30, // U Double Acute - COLS9+30, // u Double Acute - COLS9+30, // U Macron - COLS9+30, // u Macron - COLS9+30, // U Ogonek - COLS9+30, // u Ogonek - COLS9+30, // U Ring - COLS9+30, // u Ring - COLS9+30, // U Tilde - COLS9+30, // u Tilde - COLS9+32, // W Circumflex - COLS9+32, // w Circumflex - COLS9+34, // Y Circumflex - COLS9+34, // y Circumflex - COLS9+35, // Z Acute - COLS9+35, // z Acute - COLS9+35, // Z Caron or Hachek - COLS9+35, // z Caron or Hachek - COLS9+35, // Z Dot Above - COLS9+35, // z Dot Above - COLS9+19, // Uppercase Eng - COLS9+19, // Lowercase Eng - -// Other - - COLS9+6, // D Macron - COLS9+6, // d Macron - COLS9+16, // L Macron - COLS9+16, // l Macron - COLS9+19, // N Macron - COLS9+19, // n Macron - COLS9+25, // R Grave - COLS9+25, // r Grave - COLS9+27, // S Macron - COLS9+27, // s Macron - COLS9+29, // T Macron - COLS9+29, // t Macron - COLS9+34, // Y Breve - COLS9+34, // y Breve - COLS9+34, // Y Grave - COLS9+34, // y Grave - COLS9+6, // D Apostrophe Beside - COLS9+6, // d Apostrophe Beside - COLS9+21, // O Apostrophe Beside - COLS9+21, // o Apostrophe Beside - COLS9+30, // U Apostrophe Beside - COLS9+30, // u Apostrophe Beside - COLS9+7, // E breve - COLS9+7, // e breve - COLS9+12, // I breve - COLS9+12, // i breve - COLS9+12, // dotless I - COLS9+12, // dotless i - COLS9+21, // O breve - COLS9+21 // o breve -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMBYTE fwp_sym60Tbl[ SYMTBLLEN + 2] = -{ - 11, // initial character offset!! - SYMTBLLEN, // len of this table - COLS3+2, // pound - COLS3+3, // yen - COLS3+4, // pacetes - COLS3+5, // floren - COLS0, - COLS0, - COLS0, - COLS0, - COLS3+1, // cent -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMBYTE fwp_grk60Tbl[ GRKTBLLEN + 2] = -{ - 0, // starting offset - GRKTBLLEN, // length - COLS7, // Uppercase Alpha - COLS7, // Lowercase Alpha - COLS7+1, // Uppercase Beta - COLS7+1, // Lowercase Beta - COLS7+1, // Uppercase Beta Medial - COLS7+1, // Lowercase Beta Medial - COLS7+2, // Uppercase Gamma - COLS7+2, // Lowercase Gamma - COLS7+3, // Uppercase Delta - COLS7+3, // Lowercase Delta - COLS7+4, // Uppercase Epsilon - COLS7+4, // Lowercase Epsilon - COLS7+5, // Uppercase Zeta - COLS7+5, // Lowercase Zeta - COLS7+6, // Uppercase Eta - COLS7+6, // Lowercase Eta - COLS7+7, // Uppercase Theta - COLS7+7, // Lowercase Theta - COLS7+8, // Uppercase Iota - COLS7+8, // Lowercase Iota - COLS7+9, // Uppercase Kappa - COLS7+9, // Lowercase Kappa - COLS7+10, // Uppercase Lambda - COLS7+10, // Lowercase Lambda - COLS7+11, // Uppercase Mu - COLS7+11, // Lowercase Mu - COLS7+12, // Uppercase Nu - COLS7+12, // Lowercase Nu - COLS7+13, // Uppercase Xi - COLS7+13, // Lowercase Xi - COLS7+14, // Uppercase Omicron - COLS7+14, // Lowercase Omicron - COLS7+15, // Uppercase Pi - COLS7+15, // Lowercase Pi - COLS7+16, // Uppercase Rho - COLS7+16, // Lowercase Rho - COLS7+17, // Uppercase Sigma - COLS7+17, // Lowercase Sigma - COLS7+17, // Uppercase Sigma Terminal - COLS7+17, // Lowercase Sigma Terminal - COLS7+18, // Uppercase Tau - COLS7+18, // Lowercase Tau - COLS7+19, // Uppercase Upsilon - COLS7+19, // Lowercase Upsilon - COLS7+20, // Uppercase Phi - COLS7+20, // Lowercase Phi - COLS7+21, // Uppercase Chi - COLS7+21, // Lowercase Chi - COLS7+22, // Uppercase Psi - COLS7+22, // Lowercase Psi - COLS7+23, // Uppercase Omega - COLS7+23, // Lowercase Omega - -// Other Modern Greek Characters [8,52] - - COLS7, // Uppercase ALPHA Tonos high prime - COLS7, // Lowercase Alpha Tonos - acute - COLS7+4, // Uppercase EPSILON Tonos - high prime - COLS7+4, // Lowercase Epslion Tonos - acute - COLS7+6, // Uppercase ETA Tonos - high prime - COLS7+6, // Lowercase Eta Tonos - acute - COLS7+8, // Uppercase IOTA Tonos - high prime - COLS7+8, // Lowercase iota Tonos - acute - COLS7+8, // Uppercase IOTA Diaeresis - COLS7+8, // Lowercase iota diaeresis - COLS7+14, // Uppercase OMICRON Tonos - high prime - COLS7+14, // Lowercase Omicron Tonos - acute - COLS7+19, // Uppercase UPSILON Tonos - high prime - COLS7+19, // Lowercase Upsilon Tonos - acute - COLS7+19, // Uppercase UPSILON Diaeresis - COLS7+19, // Lowercase Upsilon diaeresis - COLS7+23, // Uppercase OMEGA Tonos - high prime - COLS7+23, // Lowercase Omega Tonso - acute - -// Variants [8,70] - - COLS7+4, // epsilon (variant) - COLS7+7, // theta (variant) - COLS7+9, // kappa (variant) - COLS7+15, // pi (variant) - COLS7+16, // rho (variant) - COLS7+17, // sigma (variant) - COLS7+19, // upsilon (variant) - COLS7+20, // phi (variant) - COLS7+23, // omega (variant) - -// Greek Diacritic marks [8,79] - - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, - COLS0, // 8,108 end of diacritic marks - -// Ancient Greek [8,109] - - COLS7, // alpha grave - COLS7, // alpha circumflex - COLS7, // alpha w/iota - COLS7, // alpha acute w/iota - COLS7, // alpha grave w/iota - COLS7, // alpha circumflex w/Iota - COLS7, // alpha smooth - COLS7, // alpha smooth acute - COLS7, // alpha smooth grave - COLS7, // alpha smooth circumflex - COLS7, // alpha smooth w/Iota - COLS7, // alpha smooth acute w/Iota - COLS7, // alpha smooth grave w/Iota - COLS7, // alpha smooth circumflex w/Iota -// [8,123] - COLS7, // alpha rough - COLS7, // alpha rough acute - COLS7, // alpha rough grave - COLS7, // alpha rough circumflex - COLS7, // alpha rough w/Iota - COLS7, // alpha rough acute w/Iota - COLS7, // alpha rough grave w/Iota - COLS7, // alpha rough circumflex w/Iota -// [8,131] - COLS7+4, // epsilon grave - COLS7+4, // epsilon smooth - COLS7+4, // epsilon smooth acute - COLS7+4, // epsilon smooth grave - COLS7+4, // epsilon rough - COLS7+4, // epsilon rough acute - COLS7+4, // epsilon rough grave -// [8,138] - COLS7+6, // eta grave - COLS7+6, // eta circumflex - COLS7+6, // eta w/iota - COLS7+6, // eta acute w/iota - COLS7+6, // eta grave w/Iota - COLS7+6, // eta circumflex w/Iota - COLS7+6, // eta smooth - COLS7+6, // eta smooth acute - COLS7+6, // eta smooth grave - COLS7+6, // eta smooth circumflex - COLS7+6, // eta smooth w/Iota - COLS7+6, // eta smooth acute w/Iota - COLS7+6, // eta smooth grave w/Iota - COLS7+6, // eta smooth circumflex w/Iota - COLS7+6, // eta rough - COLS7+6, // eta rough acute - COLS7+6, // eta rough grave - COLS7+6, // eta rough circumflex - COLS7+6, // eta rough w/Iota - COLS7+6, // eta rough acute w/Iota - COLS7+6, // eta rough grave w/Iota - COLS7+6, // eta rough circumflex w/Iota -// [8,160] - COLS7+8, // iota grave - COLS7+8, // iota circumflex - COLS7+8, // iota acute diaeresis - COLS7+8, // iota grave diaeresis - COLS7+8, // iota smooth - COLS7+8, // iota smooth acute - COLS7+8, // iota smooth grave - COLS7+8, // iota smooth circumflex - COLS7+8, // iota rough - COLS7+8, // iota rough acute - COLS7+8, // iota rough grave - COLS7+8, // iota rough circumflex -// [8,172] - COLS7+14, // omicron grave - COLS7+14, // omicron smooth - COLS7+14, // omicron smooth acute - COLS7+14, // omicron smooth grave - COLS7+14, // omicron rough - COLS7+14, // omicron rough acute - COLS7+14, // omicron rough grave -// [8,179] - COLS7+16, // rho smooth - COLS7+16, // rho rough -// [8,181] - COLS7+19, // upsilon grave - COLS7+19, // upsilon circumflex - COLS7+19, // upsilon acute diaeresis - COLS7+19, // upsilon grave diaeresis - COLS7+19, // upsilon smooth - COLS7+19, // upsilon smooth acute - COLS7+19, // upsilon smooth grave - COLS7+19, // upsilon smooth circumflex - COLS7+19, // upsilon rough - COLS7+19, // upsilon rough acute - COLS7+19, // upsilon rough grave - COLS7+19, // upsilon rough circumflex -// [8,193] - COLS7+23, // omega grave - COLS7+23, // omega circumflex - COLS7+23, // omega w/Iota - COLS7+23, // omega acute w/Iota - COLS7+23, // omega grave w/Iota - COLS7+23, // omega circumflex w/Iota - COLS7+23, // omega smooth - COLS7+23, // omega smooth acute - COLS7+23, // omega smooth grave - COLS7+23, // omega smooth circumflex - COLS7+23, // omega smooth w/Iota - COLS7+23, // omega smooth acute w/Iota - COLS7+23, // omega smooth grave w/Iota - COLS7+23, // omega smooth circumflex w/Iota - COLS7+23, // omega rough - COLS7+23, // omega rough acute - COLS7+23, // omega rough grave - COLS7+23, // omega rough circumflex - COLS7+23, // omega rough w/Iota - COLS7+23, // omega rough acute w/Iota - COLS7+23, // omega rough grave w/Iota - COLS7+23, // omega rough circumflex w/Iota -// [8,215] - COLS7+24, // Uppercase Stigma--the number 6 - COLS7+24, // Uppercase Digamma--Obsolete letter used as 6 - COLS7+24, // Uppercase Koppa--Obsolete letter used as 90 - COLS7+24 // Uppercase Sampi--Obsolete letter used as 900 -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMBYTE fwp_cyrl60Tbl[ CYRLTBLLEN + 2] = -{ - 0, // starting offset - CYRLTBLLEN, // len of table - - COLS10, // Russian uppercase A - COLS10, // Russian lowercase A - COLS10+1, // Russian uppercase BE - COLS10+1, // Russian lowercase BE - COLS10+2, // Russian uppercase VE - COLS10+2, // Russian lowercase VE - COLS10+3, // Russian uppercase GHE - COLS10+3, // Russian lowercase GHE - COLS10+5, // Russian uppercase DE - COLS10+5, // Russian lowercase DE - - COLS10+8, // Russian uppercase E - COLS10+8, // Russian lowercase E - COLS10+9, // Russian lowercase YO - COLS10+9, // Russian lowercase YO - COLS10+11, // Russian uppercase ZHE - COLS10+11, // Russian lowercase ZHE - COLS10+12, // Russian uppercase ZE - COLS10+12, // Russian lowercase ZE - COLS10+14, // Russian uppercase I - COLS10+14, // Russian lowercase I - - COLS10+17, // Russian uppercase SHORT I - COLS10+17, // Russian lowercase SHORT I - COLS10+19, // Russian uppercase KA - COLS10+19, // Russian lowercase KA - COLS10+20, // Russian uppercase EL - COLS10+20, // Russian lowercase EL - COLS10+22, // Russian uppercase EM - COLS10+22, // Russian lowercase EM - COLS10+23, // Russian uppercase EN - COLS10+23, // Russian lowercase EN - - COLS10+25, // Russian uppercase O - COLS10+25, // Russian lowercase O - COLS10+26, // Russian uppercase PE - COLS10+26, // Russian lowercase PE - COLS10+27, // Russian uppercase ER - COLS10+27, // Russian lowercase ER - COLS10+28, // Russian uppercase ES - COLS10+28, // Russian lowercase ES - COLS10+29, // Russian uppercase TE - COLS10+29, // Russian lowercase TE - - COLS10+32, // Russian uppercase U - COLS10+32, // Russian lowercase U - COLS10+34, // Russian uppercase EF - COLS10+34, // Russian lowercase EF - COLS10+35, // Russian uppercase HA - COLS10+35, // Russian lowercase HA - COLS10+36, // Russian uppercase TSE - COLS10+36, // Russian lowercase TSE - COLS10+37, // Russian uppercase CHE - COLS10+37, // Russian lowercase CHE - - COLS10+39, // Russian uppercase SHA - COLS10+39, // Russian lowercase SHA - COLS10+40, // Russian uppercase SHCHA - COLS10+40, // Russian lowercase SHCHA - COLS10+41, // Russian lowercase ER (also hard sign) - COLS10+41, // Russian lowercase ER (also hard sign) - COLS10+42, // Russian lowercase ERY - COLS10+42, // Russian lowercase ERY - COLS10+43, // Russian lowercase SOFT SIGN - COLS10+43, // Russian lowercase SOFT SIGN - - COLS10+45, // Russian uppercase REVERSE E - COLS10+45, // Russian lowercase REVERSE E - COLS10+46, // Russian uppercase YU - COLS10+46, // Russian lowercase yu - COLS10+47, // Russian uppercase YA - COLS10+47, // Russian lowercase ya - - COLS0, // Russian uppercase EH - COLS0, // Russian lowercase eh - COLS10+7, // Macedonian uppercase SOFT DJ - COLS10+7, // Macedonian lowercase soft dj - - COLS10+4, // Ukrainian uppercase HARD G - COLS10+4, // Ukrainian lowercase hard g - COLS0, // GE bar - COLS0, // ge bar - COLS10+6, // Serbian uppercase SOFT DJ - COLS10+6, // Serbian lowercase SOFT DJ - COLS0, // IE (variant) - COLS0, // ie (variant) - COLS10+10, // Ukrainian uppercase YE - COLS10+10, // Ukrainian lowercase YE - - COLS0, // ZHE with right descender - COLS0, // zhe with right descender - COLS10+13, // Macedonian uppercase ZELO - COLS10+13, // Macedonian lowercase ZELO - COLS0, // Old Slovanic uppercase Z - COLS0, // Old Slovanic uppercase z - COLS0, // II with macron - COLS0, // ii with mscron - COLS10+15, // Ukrainian uppercase I - COLS10+15, // Ukrainian lowercase I - - COLS10+16, // Ukrainian uppercase I with Two Dots - COLS10+16, // Ukrainian lowercase I with Two Dots - COLS0, // Old Slovanic uppercase I ligature - COLS0, // Old Slovanic lowercase I ligature - COLS10+18, // Serbian--Macedonian uppercase JE - COLS10+18, // Serbian--Macedonian lowercase JE - COLS10+31, // Macedonian uppercase SOFT K - COLS10+31, // Macedonian lowercase SOFT K - COLS0, // KA with right descender - COLS0, // ka with right descender - - COLS0, // KA ogonek - COLS0, // ka ogonek - COLS0, // KA vertical bar - COLS0, // ka vertical bar - COLS10+21, // Serbian--Macedonian uppercase SOFT L - COLS10+21, // Serbian--Macedonian lowercase SOFT L - COLS0, // EN with right descender - COLS0, // en with right descender - COLS10+24, // Serbian--Macedonian uppercase SOFT N - COLS10+24, // Serbian--Macedonian lowercase SOFT N - - COLS0, // ROUND OMEGA - COLS0, // round omega - COLS0, // OMEGA - COLS0, // omega - COLS10+30, // Serbian uppercase SOFT T - COLS10+30, // Serbian lowercase SOFT T - COLS10+33, // Byelorussian uppercase SHORT U - COLS10+33, // Byelorussian lowercase SHORT U - COLS0, // U with macron - COLS0, // u with macron - - COLS0, // STRAIGHT U - COLS0, // straight u - COLS0, // STRAIGHT U bar - COLS0, // straight u bar - COLS0, // OU ligature - COLS0, // ou ligature - COLS0, // KHA with right descender - COLS0, // kha with right descender - COLS0, // KHA ogonek - COLS0, // kha ogonek - - COLS0, // H - COLS0, // h - COLS0, // OMEGA titlo - COLS0, // omega titlo - COLS10+38, // Serbian uppercase HARD DJ - COLS10+38, // Serbian lowercase HARD DJ - COLS0, // CHE with right descender - COLS0, // che with right descender - COLS0, // CHE vertical bar - COLS0, // che vertical bar - - COLS0, // Old Slavonic SHCHA (variant) - COLS0, // old SLAVONIC shcha (variant) - COLS10+44, // Old Russian uppercase YAT - COLS10+44, // Old Russian lowercase YAT - -// END OF UNIQUE COLLATED BYTES -// CHARACTERS BELOW MUST HAVE HAVE THEIR OWN -// SUB-COLLATION VALUE TO COMPARE CORRECTLY. - - COLS0, // Old Bulgarian uppercase YUS - COLS0, // Old Bulgarian lowercase YUS - COLS0, // Old Slovanic uppercase YUS MALYI - COLS0, // Old Slovanic uppercase YUS MALYI - COLS0, // KSI - COLS0, // ksi - - COLS0, // PSI - COLS0, // psi - COLS0, // Old Russian uppercase FITA - COLS0, // Old Russian lowercase FITA - COLS0, // Old Russian uppercase IZHITSA - COLS0, // Old Russian lowercase IZHITSA - COLS0, // Russian uppercase A acute - COLS0, // Russian lowercase A acute - COLS10+8, // Russian uppercase E acute - COLS10+8, // Russian lowercase E acute - -// 160-below all characters are russian to 199 - - COLS0, // E acute - COLS0, // e acute - COLS10+14, // II acute - COLS10+14, // ii acute - COLS0, // I acute - COLS0, // i acute - COLS0, // YI acute - COLS0, // yi acute - COLS10+25, // O acute - COLS10+25, // o acute - - COLS10+32, // U acute - COLS10+32, // u acute - COLS10+42, // YERI acute - COLS10+42, // YERI acute - COLS10+45, // REVERSED E acute - COLS10+45, // reversed e acute - COLS10+46, // YU acute - COLS10+46, // yu acute - COLS10+47, // YA acute - COLS10+47, // ya acute - - COLS10, // A grave - COLS10, // a grave - COLS10+8, // E grave - COLS10+8, // e grave - COLS10+9, // YO grave - COLS10+9, // yo grave - COLS10+14, // I grave - COLS10+14, // i grave - COLS10+25, // O grave - COLS10+25, // o grave - - COLS10+32, // U grave - COLS10+32, // u grave - COLS10+42, // YERI grave - COLS10+42, // yeri grave - COLS10+45, // REVERSED E grave - COLS10+45, // reversed e grave - COLS10+46, // IU (YU) grave - COLS10+46, // iu (yu) grave - COLS10+47, // ia (YA) grave - COLS10+47, // ia (ya) grave ******* [10,199] -}; - -/**************************************************************************** -Desc: The Hebrew characters are collated over the Russian characters - Therefore sorting both Hebrew and Russian is impossible to do. -****************************************************************************/ -FLMBYTE fwp_heb60TblA[ HEBTBL1LEN + 2] = -{ - 0, // starting offset - HEBTBL1LEN, // len of table - COLS10h+0, // Alef - COLS10h+1, // Bet - COLS10h+2, // Gimel - COLS10h+3, // Dalet - COLS10h+4, // He - COLS10h+5, // Vav - COLS10h+6, // Zayin - COLS10h+7, // Het - COLS10h+8, // Tet - COLS10h+9, // Yod - COLS10h+10, // Kaf (final) [9,10] - COLS10h+11, // Kaf - COLS10h+12, // Lamed - COLS10h+13, // Mem (final) - COLS10h+14, // Mem - COLS10h+15, // Nun (final) - COLS10h+16, // Nun - COLS10h+17, // Samekh - COLS10h+18, // Ayin - COLS10h+19, // Pe (final) - COLS10h+20, // Pe [9,20] - COLS10h+21, // Tsadi (final) - COLS10h+22, // Tsadi - COLS10h+23, // Qof - COLS10h+24, // Resh - COLS10h+25, // Shin - COLS10h+26 // Tav [9,26] -}; - -/**************************************************************************** -Desc: This is the ANCIENT HEBREW SCRIPT piece. - The actual value will be stored in the subcollation. - This way we don't play diacritic/subcollation games. -****************************************************************************/ -FLMBYTE fwp_heb60TblB[ HEBTBL2LEN + 2] = -{ - 84, - HEBTBL2LEN, - -// [9,84] - COLS10h+0, // Alef Dagesh [9,84] - COLS10h+1, // Bet Dagesh - COLS10h+1, // Vez - looks like a bet - COLS10h+2, // Gimel Dagesh - COLS10h+3, // Dalet Dagesh - COLS10h+4, // He Dagesh - COLS10h+5, // Vav Dagesh [9,90] - COLS10h+5, // Vav Holem - COLS10h+6, // Zayin Dagesh - COLS10h+7, // Het Dagesh - COLS10h+8, // Tet Dagesh - COLS10h+9, // Yod Dagesh - COLS10h+9, // Yod Hiriq [9,96] - not on my list - - COLS10h+11, // Kaf Dagesh - COLS10h+10, // Kaf Dagesh (final) - COLS10h+10, // Kaf Sheva (final) - COLS10h+10, // Kaf Tsere (final) [9,100] - COLS10h+10, // Kaf Segol (final) - COLS10h+10, // Kaf Patah (final) - COLS10h+10, // Kaf Qamats (final) - COLS10h+10, // Kaf Dagesh Qamats (final) - COLS10h+12, // Lamed Dagesh - COLS10h+14, // Mem Dagesh - COLS10h+16, // Nun Dagesh - COLS10h+15, // Nun Qamats (final) - COLS10h+17, // Samekh Dagesh - COLS10h+20, // Pe Dagesh [9,110] - COLS10h+20, // Fe - just guessing this is like Pe - was +21 - COLS10h+22, // Tsadi Dagesh - COLS10h+23, // Qof Dagesh - COLS10h+25, // Sin (with sin dot) - COLS10h+25, // Sin Dagesh (with sin dot) - COLS10h+25, // Shin - COLS10h+25, // Shin Dagesh - COLS10h+26 // Tav Dagesh [9,118] -}; - -/**************************************************************************** -Desc: The Arabic characters are collated OVER the Russian characters - Therefore sorting both Arabic and Russian in the same database - is not supported. - - Arabic starts with a bunch of accents/diacritic marks that are - Actually placed OVER a preceeding character. These accents are - ignored while sorting the first pass - when collation == COLS0. - - There are 4 possible states for all/most arabic characters: - ?? - occurs as the only character in a word - ?? - appears at the first of the word - ?? - appears at the middle of a word - ?? - appears at the end of the word - - Usually only the simple version of the letter is stored. - Therefore we should not have to worry about sub-collation - of these characters. - - The arabic characters with diacritics differ however. The alef has - sub-collation values to sort correctly. There is not any more room - to add more collation values. Some chars in CS14 are combined when - urdu, pashto and sindhi characters overlap. -****************************************************************************/ -FLMBYTE fwp_ar160Tbl[ AR1TBLLEN + 2] = -{ - 38, // starting offset - AR1TBLLEN, // len of table -// [13,38] - COLLS+2, // , comma - COLLS+3, // : colon -// [13,40] - COLLS+7, // ? question mark - COLS4+2, // * asterick - COLS6, // % percent - COLS9+41, // >> alphabetic - end of list) - COLS9+40, // << alphabetic - end of list) - COLS2, // ( - COLS2+1, // ) -// [13,47] - COLS8+1, // ?? One - COLS8+2, // ?? Two - COLS8+3, // ?? Three -// [13,50] - COLS8+4, // ?? Four - COLS8+5, // ?? Five - COLS8+6, // ?? Six - COLS8+7, // ?? Seven - COLS8+8, // ?? Eight - COLS8+9, // ?? Nine - COLS8+0, // ?? Zero - COLS8+2, // ?? Two (Handwritten) - - COLS10a+1, // ?? alif - COLS10a+1, // ?? alif -// [13,60] - COLS10a+2, // ?? ba - COLS10a+2, // ?? ba - COLS10a+2, // ?? ba - COLS10a+2, // ?? ba - COLS10a+6, // ?? ta - COLS10a+6, // ?? ta - COLS10a+6, // ?? ta - COLS10a+6, // ?? ta - COLS10a+8, // ?? tha - COLS10a+8, // ?? tha -// [13,70] - COLS10a+8, // ?? tha - COLS10a+8, // ?? tha - COLS10a+12, // ?? jiim - COLS10a+12, // ?? jiim - COLS10a+12, // ?? jiim - COLS10a+12, // ?? jiim - COLS10a+16, // ?? Ha - COLS10a+16, // ?? Ha - COLS10a+16, // ?? Ha - COLS10a+16, // ?? Ha -// [13,80] - COLS10a+17, // ?? kha - COLS10a+17, // ?? kha - COLS10a+17, // ?? kha - COLS10a+17, // ?? kha - COLS10a+20, // ?? dal - COLS10a+20, // ?? dal - COLS10a+22, // ?? dhal - COLS10a+22, // ?? dhal - COLS10a+27, // ?? ra - COLS10a+27, // ?? ra -// [13,90] - COLS10a+29, // ?? ziin - COLS10a+29, // ?? ziin - COLS10a+31, // ?? siin - COLS10a+31, // ?? siin - COLS10a+31, // ?? siin - COLS10a+31, // ?? siin - COLS10a+32, // ?? shiin - COLS10a+32, // ?? shiin - COLS10a+32, // ?? shiin - COLS10a+32, // ?? shiin -// [13,100] - COLS10a+34, // ?? Sad - COLS10a+34, // ?? Sad - COLS10a+34, // ?? Sad - COLS10a+34, // ?? Sad - COLS10a+35, // ?? Dad - COLS10a+35, // ?? Dad - COLS10a+35, // ?? Dad - COLS10a+35, // ?? Dad - COLS10a+36, // ?? Ta - COLS10a+36, // ?? Ta -// [13,110] - COLS10a+36, // ?? Ta - COLS10a+36, // ?? Ta - COLS10a+37, // ?? Za - COLS10a+37, // ?? Za - COLS10a+37, // ?? Za - COLS10a+37, // ?? Za - COLS10a+38, // ?? 'ain - COLS10a+38, // ?? 'ain - COLS10a+38, // ?? 'ain - COLS10a+38, // ?? 'ain -// [13,120] - COLS10a+39, // ?? ghain - COLS10a+39, // ?? ghain - COLS10a+39, // ?? ghain - COLS10a+39, // ?? ghain - COLS10a+40, // ?? fa - COLS10a+40, // ?? fa - COLS10a+40, // ?? fa - COLS10a+40, // ?? fa - COLS10a+42, // ?? Qaf - COLS10a+42, // ?? Qaf -// [13,130] - COLS10a+42, // ?? Qaf - COLS10a+42, // ?? Qaf - COLS10a+43, // ?? kaf - COLS10a+43, // ?? kaf - COLS10a+43, // ?? kaf - COLS10a+43, // ?? kaf - COLS10a+46, // ?? lam - COLS10a+46, // ?? lam - COLS10a+46, // ?? lam - COLS10a+46, // ?? lam -// [13,140] - COLS10a+47, // ?? miim - COLS10a+47, // ?? miim - COLS10a+47, // ?? miim - COLS10a+47, // ?? miim - COLS10a+48, // ?? nuun - COLS10a+48, // ?? nuun - COLS10a+48, // ?? nuun - COLS10a+48, // ?? nuun - COLS10a+49, // ?? ha - COLS10a+49, // ?? ha -// [13,150] - COLS10a+49, // ?? ha - COLS10a+49, // ?? ha - // ha is also 51 for non-arabic - COLS10a+6, // ?? ta marbuuTah - COLS10a+6, // ?? ta marbuuTah - COLS10a+50, // ?? waw - COLS10a+50, // ?? waw - COLS10a+53, // ?? ya - COLS10a+53, // ?? ya - COLS10a+53, // ?? ya - COLS10a+53, // ?? ya -// [13,160] - COLS10a+52, // ?? alif maqSuurah - COLS10a+52, // ?? ya maqSuurah? - COLS10a+52, // ?? ya maqSuurah? - COLS10a+52, // ?? alif maqSuurah - - COLS10a+0, // ?? hamzah accent - never appears alone -// [13,165] - -// Store the sub-collation as the actual -// character value from this point on - - COLS10a+1, // ?? alif hamzah - COLS10a+1, // ?? alif hamzah - COLS10a+1, // ?? hamzah-under-alif - COLS10a+1, // ?? hamzah-under-alif - COLS10a+1, // ?? waw hamzah -// [13,170] - COLS10a+1, // ?? waw hamzah - COLS10a+1, // ?? ya hamzah - COLS10a+1, // ?? ya hamzah - COLS10a+1, // ?? ya hamzah - COLS10a+1, // ?? ya hamzah - COLS10a+1, // ?? alif fatHataan - COLS10a+1, // ?? alif fatHataan - COLS10a+1, // ?? alif maddah - COLS10a+1, // ?? alif maddah - COLS10a+1, // ?? alif waSlah -// [13,180] - COLS10a+1, // ?? alif waSlah (final) - -// LIGATURES -// Should NEVER be stored so will not worry -// about breaking up into pieces for collation. -// NOTE: -// Let's store the "Lam" collation value (+42) -// below and in the sub-collation store the -// actual character. This will sort real close. -// The best implementation is to -// break up ligatures into its base pieces. - - COLS10a+46, // ?? lamalif - COLS10a+46, // ?? lamalif - COLS10a+46, // ?? lamalif hamzah - COLS10a+46, // ?? lamalif hamzah - COLS10a+46, // ?? hamzah-under-lamalif - COLS10a+46, // ?? hamzah-under-lamalif - COLS10a+46, // ?? lamalif fatHataan - COLS10a+46, // ?? lamalif fatHataan - COLS10a+46, // ?? lamalif maddah -// [13,190] - COLS10a+46, // ?? lamalif maddah - COLS10a+46, // ?? lamalif waSlah - COLS10a+46, // ?? lamalif waSlah - COLS10a+46, // ?? Allah - khaDalAlif - COLS0_ARABIC, // ?? taTwiil - character extension - throw out - COLS0_ARABIC // ?? taTwiil 1/6 - character extension - throw out -}; - -/**************************************************************************** -Desc: Alef needs a subcollation table. - If colval==COLS10a+1 & char>=165 - index through this table. Otherwise - the alef value is [13,58] and subcol - value should be 7. Alef maddah is default (0) - - Handcheck if colval==COLS10a+6 - Should sort: - [13,152]..[13,153] - taa marbuuTah - nosubcoll - [13,64] ..[13,67] - taa - subcoll of 1 -****************************************************************************/ -FLMBYTE fwp_alefSubColTbl[] = -{ -// [13,165] - 1, // ?? alif hamzah - 1, // ?? alif hamzah - 3, // ?? hamzah-under-alif - 3, // ?? hamzah-under-alif - 2, // ?? waw hamzah -// [13,170] - 2, // ?? waw hamzah - 4, // ?? ya hamzah - 4, // ?? ya hamzah - 4, // ?? ya hamzah - 4, // ?? ya hamzah - 5, // ?? alif fatHataan - 5, // ?? alif fatHataan - 0, // ?? alif maddah - 0, // ?? alif maddah - 6, // ?? alif waSlah -// [13,180] - 6 // ?? alif waSlah (final) -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMBYTE fwp_ar260Tbl[ AR2TBLLEN + 2] = -{ - 41, // starting offset - AR2TBLLEN, // len of table -// [14,41] - COLS8+4, // Farsi and Urdu Four - COLS8+4, // Urdu Four - COLS8+5, // Farsi and Urdu Five - COLS8+6, // Farsi Six - COLS8+6, // Farsi and Urdu Six - COLS8+7, // Urdu Seven - COLS8+8, // Urdu Eight - - COLS10a+3, // Sindhi bb - baa /w 2 dots below (67b) - COLS10a+3, - COLS10a+3, - COLS10a+3, - COLS10a+4, // Sindhi bh - baa /w 4 dots below (680) - COLS10a+4, - COLS10a+4, - COLS10a+4, -// [14,56] - COLS10a+5, // Malay, Kurdish, Pashto, Farsi, Sindhi, and Urdu p - COLS10a+5, // =peh - taa /w 3 dots below (67e) - COLS10a+5, - COLS10a+5, - COLS10a+7, // Urdu T - taa /w small tah - COLS10a+7, - COLS10a+7, - COLS10a+7, - COLS10a+7, // Pashto T - taa /w ring (forced to combine) - COLS10a+7, - COLS10a+7, - COLS10a+7, - COLS10a+9, // Sindhi th - taa /w 4 dots above (67f) - COLS10a+9, -// [14,70] - COLS10a+9, - COLS10a+9, - COLS10a+10, // Sindhi Tr - taa /w 3 dots above (67d) - COLS10a+10, - COLS10a+10, - COLS10a+10, - COLS10a+11, // Sindhi Th - taa /w 2 dots above (67a) - COLS10a+11, - COLS10a+11, - COLS10a+11, - COLS10a+13, // Sindhi jj - haa /w 2 middle dots verticle (684) - COLS10a+13, - COLS10a+13, - COLS10a+13, - COLS10a+14, // Sindhi ny - haa /w 2 middle dots (683) - COLS10a+14, - COLS10a+14, - COLS10a+14, -// [14,88] - COLS10a+15, // Malay, Kurdish, Pashto, Farsi, Sindhi, and Urdu ch - COLS10a+15, // =tcheh (686) - COLS10a+15, - COLS10a+15, - COLS10a+15, // Sindhi chh - haa /w middle 4 dots (687) - COLS10a+15, // forced to combine - COLS10a+15, - COLS10a+15, - COLS10a+18, // Pashto ts - haa /w 3 dots above (685) - COLS10a+18, - COLS10a+18, - COLS10a+18, - COLS10a+19, // Pashto dz - hamzah on haa (681) - COLS10a+19, - COLS10a+19, - COLS10a+19, -// [14,104] - COLS10a+21, // Urdu D - dal /w small tah (688) - COLS10a+21, - COLS10a+21, // Pashto D - dal /w ring (689) forced to combine - COLS10a+21, - COLS10a+23, // Sindhi dh - dal /w 2 dots above (68c) - COLS10a+23, - COLS10a+24, // Sindhi D - dal /w 3 dots above (68e) - COLS10a+24, - COLS10a+25, // Sindhi Dr - dal /w dot below (68a) - COLS10a+25, - COLS10a+26, // Sindhi Dh - dal /w 2 dots below (68d) - COLS10a+26, - COLS10a+28, // Pashto r - ra /w ring (693) - COLS10a+28, -// [14,118] - COLS10a+28, // Urdu R - ra /w small tah (691) forced to combine - COLS10a+28, - COLS10a+28, // Sindhi r - ra /w 4 dots above (699) forced to combine - COLS10a+28, - COLS10a+27, // Kurdish rolled r - ra /w 'v' below (695) - COLS10a+27, - COLS10a+27, - COLS10a+27, -// [14,126] - COLS10a+30, // Kurdish, Pashto, Farsi, Sindhi, and Urdu Z - COLS10a+30, // = jeh - ra /w 3 dots above (698) - COLS10a+30, // Pashto zz - ra /w dot below & dot above (696) - COLS10a+30, // forced to combine - COLS10a+30, // Pashto g - not in unicode! - forced to combine - COLS10a+30, - COLS10a+33, // Pashto x - seen dot below & above (69a) - COLS10a+33, - COLS10a+33, - COLS10a+33, - COLS10a+39, // Malay ng - old maly ain /w 3 dots above (6a0) - COLS10a+39, // forced to combine - COLS10a+39, - COLS10a+39, -// [14,140] - COLS10a+41, // Malay p, Kurdish v - Farsi ? - fa /w 3 dots above - COLS10a+41, // = veh - means foreign words (6a4) - COLS10a+41, - COLS10a+41, - COLS10a+41, // Sindhi ph - fa /w 4 dots above (6a6) forced to combine - COLS10a+41, - COLS10a+41, - COLS10a+41, -// [14,148] - COLS10a+43, // Misc k - open caf (6a9) - COLS10a+43, - COLS10a+43, - COLS10a+43, - COLS10a+43, // misc k - no unicode - forced to combine - COLS10a+43, - COLS10a+43, - COLS10a+43, - COLS10a+43, // Sindhi k - swash caf (various) (6aa) -forced to combine - COLS10a+43, - COLS10a+43, - COLS10a+43, -// [14,160] - COLS10a+44, // Persian/Urdu g - gaf (6af) - COLS10a+44, - COLS10a+44, - COLS10a+44, - COLS10a+44, // Persian/Urdu g - no unicode - COLS10a+44, - COLS10a+44, - COLS10a+44, - COLS10a+44, // malay g - gaf /w ring (6b0) - COLS10a+44, - COLS10a+44, - COLS10a+44, - COLS10a+44, // Sindhi ng - gaf /w 2 dots above (6ba) - COLS10a+44, // forced to combine ng only - COLS10a+44, - COLS10a+44, - COLS10a+45, // Sindhi gg - gaf /w 2 dots vertical below (6b3) - COLS10a+45, - COLS10a+45, - COLS10a+45, -// [14,180] - COLS10a+46, // Kurdish velar l - lam /w small v (6b5) - COLS10a+46, - COLS10a+46, - COLS10a+46, - COLS10a+46, // Kurdish Lamalif with diacritic - no unicode - COLS10a+46, -// [14,186] - COLS10a+48, // Urdu n - dotless noon (6ba) - COLS10a+48, - COLS10a+48, - COLS10a+48, - COLS10a+48, // Pashto N - noon /w ring (6bc) - forced to combine - COLS10a+48, - COLS10a+48, - COLS10a+48, - COLS10a+48, // Sindhi N - dotless noon/w small tah (6bb) - COLS10a+48, // forced to combine - COLS10a+48, - COLS10a+48, - COLS10a+50, // Kurdish o - waw /w small v (6c6) - COLS10a+50, -// [14,200] - COLS10a+50, // Kurdish o - waw /w bar above (6c5) - COLS10a+50, - COLS10a+50, // Kurdish o - waw /w 2 dots above (6ca) - COLS10a+50, -// [14,204] - COLS10a+51, // Urdu h - no unicode - COLS10a+51, - COLS10a+51, - COLS10a+51, - COLS10a+52, // Kurdish ? - ya /w small v (6ce) - COLS10a+52, - COLS10a+52, - COLS10a+52, -// [14,212] - COLS10a+54, // Urdu y - ya barree (6d2) - COLS10a+54, - COLS10a+54, // Malay ny - ya /w 3 dots below (6d1) forced to combine - COLS10a+54, - COLS10a+54, - COLS10a+54, -// [14,218] - COLS10a+51, // Farsi hamzah - hamzah on ha (6c0) forced to combine - COLS10a+51 -}; - -/**************************************************************************** -Desc: If the bit position is set then save the character in the sub-col - area. The bit values are determined by looking at the - FLAIM COLTBL1 to see which characters are combined with other - Arabic characters. -****************************************************************************/ -FLMBYTE fwp_ar2BitTbl[] = -{ - // Start at character 64 - // The only 'clean' areas uncollate to the correct place, they are... - // 48..63 - // 68..91 - // 96..117 - // 126..127 - // 140..143 - // 160..163 - // 176..179 - // 212..213 - - 0xF0, // 64..71 - 0x00, // 72..79 - 0x00, // 80..87 - 0x0F, // 88..95 - 92..95 - 0x00, // 96..103 - 0x00, // 104..111 - 0x03, // 112..119 - 0xFC, // 120..127 - 0xFF, // 128..135 - 0xF0, // 136..143 - 136..139 - 0xFF, // 144..151 - 144..147, 148..159 - 0xFF, // 152..159 - 0x0F, // 160..167 - 164..175 - 0xFF, // 168..175 - 0x0F, // 176..183 - 180..185 - 0xFF, // 184..191 - 186..197 - 0xFF, // 192..199 - 198..203 - 0xFF, // 200..207 - 204..207 - 0xF3, // 208..215 - 208..211 , 214..217 - 0xF0 // 216..219 - 218..219 -}; - -/**************************************************************************** -Desc: This table describes and gives addresses for collating 5.0 - character sets. Each line corresponds with a character set. -***************************************************************************/ -TBL_B_TO_BP fwp_col60Tbl[] = -{ - {CHSASCI, fwp_asc60Tbl}, // ascii - " " - "~" - {CHSMUL1, fwp_mn60Tbl}, // multinational - {CHSSYM1, fwp_sym60Tbl}, // symbols - {CHSGREK, fwp_grk60Tbl}, // greek - {CHSCYR, fwp_cyrl60Tbl}, // Cyrillic - Russian - {0xFF, 0} // table terminator -}; - -/**************************************************************************** -Desc: This table is for sorting the hebrew/arabic languages. - These values overlap the end of ASC/european and cyrillic tables. -****************************************************************************/ -TBL_B_TO_BP fwp_HebArabicCol60Tbl[] = -{ - {CHSASCI, fwp_asc60Tbl}, // ascii - " " - "~" - {CHSMUL1, fwp_mn60Tbl}, // multinational - {CHSSYM1, fwp_sym60Tbl}, // symbols - {CHSGREK, fwp_grk60Tbl}, // greek - {CHSHEB, fwp_heb60TblA}, // Hebrew - {CHSHEB, fwp_heb60TblB}, // Hebrew - {CHSARB1, fwp_ar160Tbl}, // Arabic Set 1 - {CHSARB2, fwp_ar260Tbl}, // Arabic Set 2 - {0xff, 0} // table terminator -}; - -/**************************************************************************** -Desc: The diacritical to collated table translates the first 26 - characters of WP character set #1 into a 5 bit value for "correct" - sorting sequence for that diacritical (DCV) - diacritic collated - value. - - The attempt here is to convert the collated character value - along with the DCV to form the original WP character. - - The diacriticals are in an order to fit the most languages. - Czech, Swedish, and Finnish will have to manual reposition the - ring above (assign it a value greater then the umlaut) - - This table is index by the diacritical value. -****************************************************************************/ -FLMBYTE fwp_dia60Tbl[] = -{ - 2, // grave offset = 0 - 16, // centerd offset = 1 - 7, // tilde offset = 2 - 4, // circum offset = 3 - 12, // crossb offset = 4 - 10, // slash offset = 5 - 1, // acute offset = 6 - 6, // umlaut offset = 7 - // In SU, SV and CZ will = 9 - 17, // macron offset = 8 - 18, // aposab offset = 9 - 19, // aposbes offset = 10 - 20, // aposba offset = 11 - 21, // aposbc offset = 12 - 22, // abosbl offset = 13 - 8, // ring offset = 14 - 13, // dota offset = 15 - 23, // dacute offset = 16 - 11, // cedilla offset = 17 - 14, // ogonek offset = 18 - 5, // caron offset = 19 - 15, // stroke offset = 20 - 24, // bara offset = 21 - 3, // breve offset = 22 - 0, // dbls offset = 23 sorts as 'ss' - 25, // dotlesi offset = 24 - 26 // dotlesj offset = 25 -}; - -/**************************************************************************** -Desc: This table defines the range of characters within the set - which are case convertible. -****************************************************************************/ -static FLMBYTE fwp_caseConvertableRange[] = -{ - 26,241, // Multinational 1 - 0,0, // Multinational 2 - 0,0, // Box Drawing - 0,0, // Symbol 1 - 0,0, // Symbol 2 - 0,0, // Math 1 - 0,0, // Math 2 - 0,69, // Greek 1 - 0,0, // Hebrew - 0,199, // Cyrillic - 0,0, // Japanese Kana - 0,0, // User-defined - 0,0, // Not defined - 0,0, // Not defined - 0,0, // Not defined -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMUINT16 colToWPChr[ COLS11 - COLLS] = -{ - 0x20, // colls - - 0x2e, // colls+1 - . - 0x2c, // colls+2 - , - 0x3a, // colls+3 - : - 0x3b, // colls+4 - ; - 0x21, // colls+5 - ! - 0, // colls+6 - NO VALUE - 0x3f, // colls+7 - ? - 0, // colls+8 - NO VALUE - - 0x22, // cols1 - " - 0x27, // cols1+1 - ' - 0x60, // cols1+2 - ` - 0, // cols1+3 - NO VALUE - 0, // cols1+4 - NO VALUE - - 0x28, // cols2 - ( - 0x29, // cols2+1 - ) - 0x5b, // cols2+2 - japanese angle brackets - 0x5d, // cols2+3 - japanese angle brackets - 0x7b, // cols2+4 - { - 0x7d, // cols2+5 - } - - 0x24, // cols3 - $ - 0x413, // cols3+1 - cent - 0x40b, // cols3+2 - pound - 0x40c, // cols3+3 - yen - 0x40d, // cols3+4 - pacetes - 0x40e, // cols3+5 - floren - - 0x2b, // cols4 - + - 0x2d, // cols4+1 - - - 0x2a, // cols4+2 - * - 0x2f, // cols4+3 - / - 0x5e, // cols4+4 - ^ - 0, // cols4+5 - NO VALUE - 0, // cols4+6 - NO VALUE - 0, // cols4+7 - NO VALUE - - 0x3c, // cols5 - < - 0, // cols5+1 - NO VALUE - 0x3d, // cols5+2 - = - 0, // cols5+3 - NO VALUE - 0x3e, // cols5+4 - > - 0, // cols5+5 - NO VALUE - 0, // cols5+6 - NO VALUE - 0, // cols5+7 - NO VALUE - 0, // cols5+8 - NO VALUE - 0, // cols5+9 - NO VALUE - 0, // cols5+10 - NO VALUE - 0, // cols5+11 - NO VALUE - 0, // cols5+12 - NO VALUE - 0, // cols5+13 - NO VALUE - - 0x25, // cols6 - % - 0x23, // cols6+1 - # - 0x26, // cols6+2 - & - 0x40, // cols6+3 - @ - 0x5c, // cols6+4 - Backslash - 0x5f, // cols6+5 - _ - 0x7c, // cols6+6 - | - 0x7e, // cols6+7 - ~ - 0, // cols6+8 - NO VALUE - 0, // cols6+9 - NO VALUE - 0, // cols6+10 - NO VALUE - 0, // cols6+11 - NO VALUE - 0, // cols6+12 - NO VALUE - - 0x800, // cols7 - Uppercase Alpha - 0x802, // cols7+1 - Uppercase Beta - 0x806, // cols7+2 - Uppercase Gamma - 0x808, // cols7+3 - Uppercase Delta - 0x80a, // cols7+4 - Uppercase Epsilon - 0x80c, // cols7+5 - Uppercase Zeta - 0x80e, // cols7+6 - Uppercase Eta - 0x810, // cols7+7 - Uppercase Theta - 0x812, // cols7+8 - Uppercase Iota - 0x814, // cols7+9 - Uppercase Kappa - 0x816, // cols7+10 - Uppercase Lambda - 0x818, // cols7+11 - Uppercase Mu - 0x81a, // cols7+12 - Uppercase Nu - 0x81c, // cols7+13 - Uppercase Xi - 0x81e, // cols7+14 - Uppercase Omicron - 0x820, // cols7+15 - Uppercase Pi - 0x822, // cols7+16 - Uppercase Rho - 0x824, // cols7+17 - Uppercase Sigma - 0x828, // cols7+18 - Uppercase Tau - 0x82a, // cols7+19 - Uppercase Upsilon - 0x82c, // cols7+20 - Uppercase Phi - 0x82e, // cols7+21 - Uppercase Chi - 0x830, // cols7+22 - Uppercase Psi - 0x832, // cols7+23 - Uppercase Omega - 0, // cols7+24 - NO VALUE - - 0x30, // cols8 - 0 - 0x31, // cols8+1 - 1 - 0x32, // cols8+2 - 2 - 0x33, // cols8+3 - 3 - 0x34, // cols8+4 - 4 - 0x35, // cols8+5 - 5 - 0x36, // cols8+6 - 6 - 0x37, // cols8+7 - 7 - 0x38, // cols8+8 - 8 - 0x39, // cols8+9 - 9 - - 0x41, // cols9 - A - 0x124, // cols9+1 - AE digraph - 0x42, // cols9+2 - B - 0x43, // cols9+3 - C - 0xffff, // cols9+4 - CH in spanish - 0x162, // cols9+5 - Holder for C caron in Czech - 0x44, // cols9+6 - D - 0x45, // cols9+7 - E - 0x46, // cols9+8 - F - 0x47, // cols9+9 - G - 0x48, // cols9+10 - H - 0xffff, // cols9+11 - CH in czech or dotless i in turkish - 0x49, // cols9+12 - I - 0x18a, // cols9+13 - IJ Digraph - 0x4a, // cols9+14 - J - 0x4b, // cols9+15 - K - 0x4c, // cols9+16 - L - 0xffff, // cols9+17 - LL in spanish - 0x4d, // cols9+18 - M - 0x4e, // cols9+19 - N - 0x138, // cols9+20 - N Tilde - 0x4f, // cols9+21 - O - 0x1a6, // cols9+22 - OE digraph - 0x50, // cols9+23 - P - 0x51, // cols9+24 - Q - 0x52, // cols9+25 - R - 0x1aa, // cols9+26 - Holder for R caron in Czech - 0x53, // cols9+27 - S - 0x1b0, // cols9+28 - Holder for S caron in Czech - 0x54, // cols9+29 - T - 0x55, // cols9+30 - U - 0x56, // cols9+31 - V - - 0x57, // cols9+32 - W - 0x58, // cols9+33 - X - 0x59, // cols9+34 - Y - 0x5a, // cols9+35 - Z - 0x1ce, // cols9+36 - Holder for Z caron in Czech - 0x158, // cols9+37 - Uppercase Thorn - 0, // cols9+38 - ??? - 0, // cols9+39 - ??? - 0x5b, // cols9+40 - [ (note: alphabetic - end of list) - 0x5d, // cols9+41 - ] (note: alphabetic - end of list) -// 0xAA - also start of Hebrew - 0x124, // cols9+42 - AE diagraph - DK - 0x124, // cols9+43 - AE diagraph - NO - 0x122, // cols9+44 - A ring - SW - 0x11E, // cols9+45 - A diaeresis - DK - 0x124, // cols9+46 - AE diagraph - IC - 0x150, // cols9+47 - O slash - NO - 0x11e, // cols9+48 - A diaeresis - SW - 0x150, // cols9+49 - O slash - DK - 0x13E, // cols9+50 - O Diaeresis - IC - 0x122, // cols9+51 - A ring - NO - 0x13E, // cols9+52 - O Diaeresis - SW - 0x13E, // cols9+53 - O Diaeresis - DK - 0x150, // cols9+54 - O slash - IC - 0x122, // cols9+55 - A ring - DK - 0x124, // cols9+56 - AE diagraph future - 0x13E, // cols9+57 - O Diaeresis future - 0x150, // cols9+58 - O slash future - 0, // cols9+59 - NOT USED future - - 0xA00, // cols10 - Russian A - 0xA02, // cols10+1 - Russian BE - 0xA04, // cols10+2 - Russian VE - 0xA06, // cols10+3 - Russian GHE - 0xA46, // cols10+4 - Ukrainian HARD G - 0xA08, // cols10+5 - Russian DE - 0xA4a, // cols10+6 - Serbian SOFT DJ - 0xA44, // cols10+7 - Macedonian SOFT DJ - 0xA0a, // cols10+8 - Russian E - 0xA0c, // cols10+9 - Russian YO - 0xA4e, // cols10+10 - Ukrainian YE - 0xA0e, // cols10+11 - Russian ZHE - 0xA10, // cols10+12 - Russian ZE - 0xA52, // cols10+13 - Macedonian ZELO - 0xA12, // cols10+14 - Russian I - 0xA58, // cols10+15 - Ukrainian I - 0xA5a, // cols10+16 - Ukrainian I with Two dots - 0xA14, // cols10+17 - Russian SHORT I - 0xA5e, // cols10+18 - Serbian--Macedonian JE - 0xA16, // cols10+19 - Russian KA - 0xA18, // cols10+20 - Russian EL - 0xA68, // cols10+21 - Serbian--Macedonian SOFT L - 0xA1a, // cols10+22 - Russian EM - 0xA1c, // cols10+23 - Russian EN - 0xA6c, // cols10+24 - Serbian--Macedonian SOFT N - 0xA1e, // cols10+25 - Russian O - 0xA20, // cols10+26 - Russian PE - 0xA22, // cols10+27 - Russian ER - 0xA24, // cols10+28 - Russian ES - 0xA26, // cols10+29 - Russian TE - 0xA72, // cols10+30 - Serbian SOFT T - 0xA60, // cols10+31 - Macedonian SOFT K - 0xA28, // cols10+32 - Russian U - 0xA74, // cols10+33 - Byelorussian SHORT U - 0xA2a, // cols10+34 - Russian EF - 0xA2c, // cols10+35 - Russian HA - 0xA2e, // cols10+36 - Russian TSE - 0xA30, // cols10+37 - Russian CHE - 0xA86, // cols10+38 - Serbian HARD DJ - 0xA32, // cols10+39 - Russian SHA - 0xA34, // cols10+40 - Russian SHCHA - 0xA36, // cols10+41 - Russian ER (also hard - 0xA38, // cols10+42 - Russian ERY - 0xA3a, // cols10+43 - Russian SOFT SIGN - 0xA8e, // cols10+44 - Old Russian YAT - 0xA3c, // cols10+45 - Russian uppercase REVERSE E - 0xA3e, // cols10+46 - Russian YU - 0xA40, // cols10+47 - Russian YA - 0xA3a, // cols10+48 - Russian SOFT SIGN - UKRAIN ONLY - 0 // cols10+49 - future -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMUINT16 HebArabColToWPChr[] = -{ - // Start at COLS10a+0 -// [0] - 0x0D00 +164, // hamzah - 0x0D00 + 58, // [13,177] alef maddah - // Read subcollation to get other alef values - 0x0D00 + 60, // baa - 0x0E00 + 48, // Sindhi bb - 0x0E00 + 52, // Sindhi bh - 0x0E00 + 56, // Misc p = peh - 0x0D00 +152, // taa marbuuTah - // subcollation of 1 is taa [13,64] - 0x0E00 + 60, // Urdu T [14,60] - // Pashto T [14,64] -// [8] - 0x0D00 + 68, // thaa - 0x0E00 + 68, // Sindhi th - 0x0E00 + 72, // Sindhi tr - 0x0E00 + 76, // Sindhi Th - 0x0D00 + 72, // jiim - jeem - 0x0E00 + 80, // Sindhi jj - 0x0E00 + 84, // Sindhi ny - 0x0E00 + 88, // Misc ch - // Sinhi chh [14,92] -// [16] - 0x0D00 + 76, // Haa - 0x0D00 + 80, // khaa - 0x0E00 + 96, // Pashto ts - 0x0E00 +100, // Pashto dz - - 0x0D00 + 84, // dal - 0x0E00 +104, // Urdu D - // Pashto D - 0x0D00 + 86, // thal - 0x0E00 +108, // Sindhi dh - -// [24] - 0x0E00 +110, // Sindhi D - 0x0E00 +112, // Sindhi Dr - 0x0E00 +114, // Sindhi Dh - - 0x0D00 + 88, // ra - // Kurdish rolled r [14,122] - 0x0E00 +116, // Pashto r [14,116] - must pick this! - // Urdu R [14,118] - // Sindhi r [14,120] - - 0x0D00 + 90, // zain - 0x0E00 +126, // Mizc Z=jeh [14,126] - // Pashto zz [14,128] - // Pashto g [14,130] - - 0x0D00 + 92, // seen - -// [32] - 0x0D00 + 96, // sheen - 0x0E00 +132, // Pashto x - 0x0D00 +100, // Sad - 0x0D00 +104, // Dad - 0x0D00 +108, // Tah - 0x0D00 +112, // Za (dhah) - 0x0D00 +116, // 'ain - 0x0D00 +120, // ghain - // malay ng [14,136] -// [40] - 0x0D00 +124, // fa - 0x0E00 +140, // Malay p, kurdish v = veh - // Sindhi ph [14,144] - 0x0D00 +128, // Qaf - 0x0D00 +132, // kaf (caf) - // Misc k [14,148] - // misc k - no unicode [14,152] - // Sindhi k [14,156] - - 0x0E00 +160, // Persian/Urdu gaf - // gaf - no unicode [14,164] - // malay g [14,168] - // Sindhi ng [14,172] - 0x0E00 +176, // Singhi gg - - 0x0D00 +136, // lam - all ligature variants - // Kurdish valar lam [14,180] - // Kurdish lamalef - no unicode [14,184] - - 0x0D00 +140, // meem - -// [48] - 0x0D00 +144, // noon - // Urdu n [14,186] - // Pashto N [14,190] - // Sindhi N [14,194] - 0x0D00 +148, // ha - arabic language only! - 0x0D00 +154, // waw - // Kurdish o [14,198] - // Kurdish o with bar [14,200] - // Kurdish o with 2 dots [14,202] - 0x0D00 +148, // ha - non-arabic language - // Urdu h [14,204] - // Farsi hamzah on ha [14,218] - 0x0D00 +160, // alef maqsurah - // Kurdish e - ya /w small v - - 0x0D00 +156, // ya - 0x0E00 +212 // Urdu ya barree - // Malay ny [14,214] -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMUINT16 ArabSubColToWPChr[] = -{ - 0x0D00 +177, // Alef maddah - default value - here for documentation - 0x0D00 +165, // Alef Hamzah - 0x0D00 +169, // Waw hamzah - 0x0D00 +167, // Hamzah under alef - 0x0D00 +171, // ya hamzah - 0x0D00 +175, // alef fathattan - 0x0D00 +179, // alef waslah - 0x0D00 + 58, // alef - 0x0D00 + 64 // taa - after taa marbuuTah -}; - -/**************************************************************************** -Desc: Turns a collated diacritic value into the original diacritic value -****************************************************************************/ -FLMBYTE ml1_COLtoD[27] = -{ - 23, // dbls sort value = 0 sorts as 'ss' - 6, // acute sort value = 1 - 0, // grave sort value = 2 - 22, // breve sort value = 3 - 3, // circum sort value = 4 - 19, // caron sort value = 5 - 7, // umlaut sort value = 6 - 2, // tilde sort value = 7 - 14, // ring sort value = 8 - 7, // umlaut in SU,SV & CZ after ring = 9 - 5, // slash sort value = 10 - 17, // cedilla sort value = 11 - 4, // crossb sort value = 12 - 15, // dota sort value = 13 - 18, // ogonek sort value = 14 - 20, // stroke sort value = 15 - 1, // centerd sort value = 16 - 8, // macron sort value = 17 - 9, // aposab sort value = 18 - 10, // aposbes sort value = 19 - 11, // aposba sort value = 20 - 12, // aposbc sort value = 21 - 13, // abosbl sort value = 22 - 16, // dacute sort value = 23 - 21, // bara sort value = 24 - 24, // dotlesi sort value = 25 - 25 // dotlesj sort value = 26 -}; - -/**************************************************************************** -Desc: -Notes: Only 48 values + 0x40, 0x41, 0x42 (169..171) -****************************************************************************/ -FLMBYTE ColToKanaTbl[ 48] = -{ - 0, // a=0, A=1 - 2, // i=2, I=3 - 4, // u=4, U=5, VU=83 - 6, // e=6, E=7 - 8, // o=8, O=9 - 84, // KA=10, GA=11, ka=84 - remember voicing table is optimized - // so that zero value is position and - // if voice=1 and no 0 is changed to 0 - 12, // KI=12, GI=13 - 14, // KU=14, GU=15 - 85, // KE=16, GE=17, ke=85 - 18, // KO=18, GO=19 - 20, // SA=20, ZA=21 - 22, // SHI=22, JI=23 - 24, // SU=24, ZU=25 - 26, // SE=26, ZE=27 - 28, // SO=28, ZO=29 - 30, // TA=30, DA=31 - 32, // CHI=32, JI=33 - 34, // tsu=34, TSU=35, ZU=36 - 37, // TE=37, DE=38 - 39, // TO=39, DO=40 - 41, // NA - 42, // NI - 43, // NU - 44, // NE - 45, // NO - 46, // HA, BA, PA - 49, // HI, BI, PI - 52, // FU, BU, PU - 55, // HE, BE, PE - 58, // HO, BO, PO - 61, // MA - 62, // MI - 63, // MU - 64, // ME - 65, // MO - 66, // ya, YA - 68, // yu, YU - 70, // yo, YO - 72, // RA - 73, // RI - 74, // RU - 75, // RE - 76, // RO - 77, // wa, WA - 79, // WI - 80, // WE - 81, // WO - 82 // N -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -static FLMBYTE fwp_langtbl[ LAST_LANG + LAST_LANG] = -{ - 'U', 'S', // English, United States - 'A', 'F', // Afrikaans - 'A', 'R', // Arabic - 'C', 'A', // Catalan - 'H', 'R', // Croatian - 'C', 'Z', // Czech - 'D', 'K', // Danish - 'N', 'L', // Dutch - 'O', 'Z', // English, Australia - 'C', 'E', // English, Canada - 'U', 'K', // English, United Kingdom - 'F', 'A', // Farsi - 'S', 'U', // Finnish - 'C', 'F', // French, Canada - 'F', 'R', // French, France - 'G', 'A', // Galician - 'D', 'E', // German, Germany - 'S', 'D', // German, Switzerland - 'G', 'R', // Greek - 'H', 'E', // Hebrew - 'M', 'A', // Hungarian - 'I', 'S', // Icelandic - 'I', 'T', // Italian - 'N', 'O', // Norwegian - 'P', 'L', // Polish - 'B', 'R', // Portuguese, Brazil - 'P', 'O', // Portuguese, Portugal - 'R', 'U', // Russian - 'S', 'L', // Slovak - 'E', 'S', // Spanish - 'S', 'V', // Swedish - 'Y', 'K', // Ukrainian - 'U', 'R', // Urdu - 'T', 'K', // Turkey - 'J', 'P', // Japanese - 'K', 'R', // Korean - 'C', 'T', // Chinese-Traditional - 'C', 'S', // Chinese-Simplified - 'L', 'A' // Future asian language -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -FINLINE FLMUINT bytesInBits( - FLMUINT uiBits) -{ - return( (uiBits + 7) >> 3); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -FINLINE FLMBOOL testOneBit( - const FLMBYTE * pucBuf, - FLMUINT uiBit) -{ - return( (((pucBuf[ uiBit >> 3]) >> (7 - (uiBit & 7))) & 1) - ? TRUE - : FALSE); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -FINLINE FLMUINT getNBits( - FLMUINT uiNumBits, - const FLMBYTE * pucBuf, - FLMUINT uiBit) -{ - return(((FLMUINT)( - ((FLMUINT)pucBuf[ uiBit >> 3] << 8) | // append high bits (byte 1) to ... - (FLMUINT)pucBuf[ (uiBit >> 3) + 1]) >> // ... overflow bits in 2nd byte - (16 - uiNumBits - (uiBit & 7))) & // reposition to low end of value - ((1 << uiNumBits) - 1)); // mask off high bits -} - -/**************************************************************************** -Desc: -****************************************************************************/ -FINLINE void setBit( - FLMBYTE * pucBuf, - FLMUINT uiBit) -{ - pucBuf[ uiBit >> 3] |= (FLMBYTE)(1 << (7 - (uiBit & 7))); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -FINLINE void setBits( - FLMUINT uiCount, - FLMBYTE * pucBuf, - FLMUINT uiBit, - FLMUINT uiVal) -{ - pucBuf[ uiBit >> 3] |= // 1st byte - (FLMBYTE)((uiVal << (8 - uiCount)) // Align to bit 0 - >> - (uiBit & 7)); // Re-align to actual bit position - - pucBuf[ (uiBit >> 3) + 1] = // 2nd byte - (FLMBYTE)(uiVal - << - (16 - uiCount - (uiBit & 7))); // Align spill-over bits -} - -/**************************************************************************** -Desc: getNextCharState can be thought of as a 2 dimentional array with - i and j as the row and column indicators respectively. If a value - exists at the intersection of i and j, it is returned. Sparse array - techniques are used to minimize memory usage. - -Return: 0 = no valid next state - non-zero = valid next state, offset for action, or collating value -****************************************************************************/ -FINLINE FLMUINT16 getNextCharState( - FLMUINT i, - FLMUINT j) -{ - FLMUINT k, x; - - for( k = fwp_indexi[ x = - (i > START_COL) ? (START_ALL) : i ]; // adjust so don't use full tables - k <= (FLMUINT) (fwp_indexi[ x + 1] - 1); - k++ ) - { - // FIXUP_AREA_SIZE should be 24. - if( j == fwp_indexj[ k]) - { - return( fwp_valuea[ (i > START_COL) - ? (k + (FIXUP_AREA_SIZE * (i - START_ALL))) - : k]); - } - } - - return(0); -} - -/**************************************************************************** -Desc: Returns TRUE if the character is upper case, FALSE if lower case. -****************************************************************************/ -FINLINE FLMBOOL charIsUpper( - FLMUINT16 ui16Char) -{ - return( (FLMBOOL)((ui16Char < 0x7F) - ? (FLMBOOL)((ui16Char >= ASCII_LOWER_A && - ui16Char <= ASCII_LOWER_Z) - ? (FLMBOOL)FALSE - : (FLMBOOL)TRUE) - : flmWPIsUpper( ui16Char))); -} - -/**************************************************************************** -Desc: Convert a text string to a collated string. - If NE_XFLM_CONV_DEST_OVERFLOW is returned the string is truncated as - best as it can be. The caller must decide to return the error up - or deal with the truncation. -VISIT: If the string is EXACTLY the length of the truncation - length then it should, but doesn't, set the truncation flag. - The code didn't match the design intent. Fix next major - version. -****************************************************************************/ -RCODE flmUTF8ToColText( - IF_PosIStream * pIStream, - FLMBYTE * pucCollatedStr, // Returns collated string - FLMUINT * puiCollatedStrLen, // Returns total collated string length - // Input is maximum bytes in buffer - FLMBOOL bCaseInsensitive, // Set if to convert to uppercase - FLMUINT * puiCollationLen, // Returns the collation bytes length - FLMUINT * puiCaseLen, // Returns length of case bytes - FLMUINT uiLanguage, // Language - FLMUINT uiCharLimit, // Max number of characters in this key piece - FLMBOOL bFirstSubstring, // TRUE is this is the first substring key - FLMBOOL bDataTruncated, // TRUE if data is coming in truncated. - FLMBOOL * pbOriginalCharsLost, - FLMBOOL * pbDataTruncated) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT16 ui16Base; // Value of the base character - FLMUINT16 ui16SubColVal; // Sub-collated value (diacritic) - FLMUINT uiLength; // Temporary variable for length - FLMUINT uiTargetColLen = *puiCollatedStrLen - 8; // 4=ovhd,4=worse char - - // Need to increase the buffer sizes to not overflow. - // Characaters without COLL values will take up 3 bytes in - // the ucSubColBuf[] and easily overflow the buffer. - // Hard coded the values so as to minimize changes. - - FLMBYTE ucSubColBuf[ MAX_SUBCOL_BUF + 301]; // Holds sub-collated values(diac) - FLMBYTE ucCaseBits[ MAX_CASE_BYTES + 81]; // Holds case bits - FLMUINT16 ui16WpChr; // Current WP character - FLMUNICODE uChar = 0; // Current unconverted Unicode character - FLMUNICODE uChar2; - FLMUINT16 ui16WpChr2; // 2nd character if any; default 0 for US lang - FLMUINT uiColLen; // Return value of collated length - FLMUINT uiSubColBitPos; // Sub-collation bit position - FLMUINT uiCaseBitPos; // Case bit position - FLMUINT uiFlags; // Clear all bit flags - FLMBOOL bHebrewArabic = FALSE; // Set if language is hebrew, arabic, farsi - FLMBOOL bTwoIntoOne; - FLMUINT uiUppercaseFlag; - - uiColLen = 0; - uiSubColBitPos = 0; - uiCaseBitPos = 0; - uiFlags = 0; - ui16WpChr2 = 0; - - // We don't want any single key piece to "pig out" more - // than 256 bytes of the key - - if( uiTargetColLen > 256 - 8) - { - uiTargetColLen = 256 - 8; - } - - // Code below sets ucSubColBuf[] and ucCaseBits[] values to zero. - - if (uiLanguage != XFLM_US_LANG) - { - if (uiLanguage == XFLM_AR_LANG || // Arabic - uiLanguage == XFLM_FA_LANG || // Farsi - persian - uiLanguage == XFLM_HE_LANG || // Hebrew - uiLanguage == XFLM_UR_LANG) // Urdu - { - bHebrewArabic = TRUE; - } - } - - for (;;) - { - // Set the case bits and sub-collation bits to zero when - // on the first bit of the byte. - - if (!(uiCaseBitPos & 0x07)) - { - ucCaseBits [uiCaseBitPos >> 3] = 0; - } - if (!(uiSubColBitPos & 0x07)) - { - ucSubColBuf [uiSubColBitPos >> 3] = 0; - } - - ui16SubColVal = 0; // Default sub-collation value - - // Get the next character from the string. - - if( RC_BAD( rc = flmReadUTF8CharAsUnicode( pIStream, &uChar))) - { - if (rc == NE_XFLM_EOF_HIT) - { - rc = NE_XFLM_OK; - break; - } - goto Exit; - } - - // flmWPCheckDoubleCollation modifies ui16WpChr if a digraph or a double - // character sequence is found. If a double character is found, pucStr - // is incremented past the next character and ui16WpChr2 is set to 1. - // If a digraph is found, pucStr is not changed, but ui16WpChr - // contains the first character and ui16WpChr2 contains the second - // character of the digraph. - - if (uiLanguage != XFLM_US_LANG) - { - if( RC_BAD( rc = flmWPCheckDoubleCollation( - pIStream, FALSE, TRUE, &uChar, &uChar2, &bTwoIntoOne, uiLanguage))) - { - goto Exit; - } - if (!flmUnicodeToWP( uChar, &ui16WpChr)) - { - ui16WpChr = UNK_UNICODE_CODE; - } - if (uChar2) - { - if (!flmUnicodeToWP( uChar2, &ui16WpChr2)) - { - ui16WpChr2 = UNK_UNICODE_CODE; - } - } - else - { - ui16WpChr2 = 0; - } - } - else - { - - // Convert the character to its WP equivalent - - if( !flmUnicodeToWP( uChar, &ui16WpChr)) - { - ui16WpChr = UNK_UNICODE_CODE; - } - } - - // Save the case bit if not case-insensitive - - if (!bCaseInsensitive) - { - - // charIsUpper returns TRUE if upper case, 0 if lower case. - - if (!charIsUpper( ui16WpChr)) - { - uiFlags |= HAD_LOWER_CASE; - } - else - { - // Set if upper case. - - setBit( ucCaseBits, uiCaseBitPos); - } - uiCaseBitPos++; - } - - // Handle non-collating characters with subcollating values, - // Get the collated value from the WP character-if not collating value - - if ((pucCollatedStr[ uiColLen++] = - (FLMBYTE)(flmWPGetCollation( ui16WpChr, uiLanguage))) >= COLS11) - { - FLMUINT uiTemp; - - // If lower case, convert to upper case. - - if (!charIsUpper( ui16WpChr)) - { - ui16WpChr &= ~1; - } - - // No collating value given for this WP char. - // Save original WP char (2 bytes) in subcollating - // buffer. - - // 1110 is a new code that will store an insert over - // the character OR a non-convertable unicode character. - // Store with the same alignment as "store_extended_char" - // below. - - // 11110 is code for unmappable UNICODE value. - // A value 0xFE will be the collation value. The sub-collation - // value will be 0xFFFF followed by the UNICODE value. - // Be sure to eat an extra case bit. - - // See specific Hebrew and Arabic comments in the - // switch statement below. - - // Set the next byte that follows in the sub collation buffer. - - ucSubColBuf [(uiSubColBitPos + 8) >> 3] = 0; - if (bHebrewArabic && (pucCollatedStr[ uiColLen - 1] == COLS0_ARABIC)) - { - // Store first bit of 1110, fall through & store remaining 3 bits - - setBit( ucSubColBuf, uiSubColBitPos); - uiSubColBitPos++; - - // Don't store collation value - - uiColLen--; - } - else if( uChar) - { - ui16WpChr = uChar; - uChar = 0; - - // Store 11 out of 11110 - - setBit( ucSubColBuf, uiSubColBitPos); - uiSubColBitPos++; - setBit( ucSubColBuf, uiSubColBitPos); - uiSubColBitPos++; - if (!bCaseInsensitive) - { - ucCaseBits [(uiCaseBitPos + 7) >> 3] = 0; - - // Set upper case bit. - - setBit( ucCaseBits, uiCaseBitPos); - uiCaseBitPos++; - } - } -store_extended_char: - - // Set the next byte that follows in the sub collation buffer. - - ucSubColBuf [(uiSubColBitPos + 8) >> 3] = 0; - ucSubColBuf [(uiSubColBitPos + 16) >> 3] = 0; - uiFlags |= HAD_SUB_COLLATION; - - // Set 110 bits in sub-collation - continued from above. - // No need to explicitly set the zero, but must increment - // for it. - - setBit( ucSubColBuf, uiSubColBitPos); - uiSubColBitPos++; - setBit( ucSubColBuf, uiSubColBitPos); - uiSubColBitPos += 2; - - // store_aligned_word: This label is not referenced. - // Go to the next byte boundary to write the character. - - uiSubColBitPos = (uiSubColBitPos + 7) & (~7); - uiTemp = bytesInBits( uiSubColBitPos); - - // Need to big-endian - so it will sort correctly. - - ucSubColBuf [uiTemp] = (FLMBYTE)(ui16WpChr >> 8); - ucSubColBuf [uiTemp + 1] = (FLMBYTE)(ui16WpChr); - uiSubColBitPos += 16; - ucSubColBuf [uiSubColBitPos >> 3] = 0; - } - else - { - // Had a collation value - // Add the lower/uppercase bit if a mixed case output. - // If not lower ASCII set - check diacritic value for sub-collation - - if( !(ui16WpChr & 0xFF00)) - { - // ASCII character set - set a single 0 bit - just need to - // increment to do this. - - uiSubColBitPos++; - } - else - { - FLMBYTE ucChar = (FLMBYTE)ui16WpChr; - FLMBYTE ucCharSet = (FLMBYTE)(ui16WpChr >> 8); - - // Convert char to uppercase because case information - // is stored above. This will help - // ensure that the "ETA" doesn't sort before "eta" - - if( !charIsUpper( ui16WpChr)) - { - ui16WpChr &= ~1; - } - - switch( ucCharSet) - { - case CHSMUL1: // Multinational 1 - { - // If we cannot break down a char into base and - // diacritic we cannot combine the charaacter - // later when converting back the key. In that case, - // write the entire WP char in the sub-collation area. - - if( flmWPBrkcar( ui16WpChr, &ui16Base, &ui16SubColVal)) - { - goto store_extended_char; - } - - // Write the FLAIM diacritic sub-collation value. - // Prefix is 2 bits "10". Remember to leave - // "111" alone for the future. - // NOTE: The "unlaut" character must sort after the "ring" - // character. - - ui16SubColVal = ((ui16SubColVal & 0xFF) == umlaut && - (uiLanguage == XFLM_SU_LANG || - uiLanguage == XFLM_SV_LANG || - uiLanguage == XFLM_CZ_LANG || - uiLanguage == XFLM_SL_LANG)) - ? (FLMUINT16)(fwp_dia60Tbl[ ring] + 1) - : (FLMUINT16)(fwp_dia60Tbl[ ui16SubColVal & 0xFF]); - -store_sub_col: - // Set the next byte that follows in the sub collation buffer. - - ucSubColBuf[ (uiSubColBitPos + 8) >> 3] = 0; - uiFlags |= HAD_SUB_COLLATION; - - // Set the 10 bits - no need to explicitly set the zero, but - // must increment for it. - - setBit( ucSubColBuf, uiSubColBitPos); - uiSubColBitPos += 2; - - // Set sub-collation bits. - - setBits( 5, ucSubColBuf, uiSubColBitPos, ui16SubColVal); - uiSubColBitPos += 5; - break; - } - - case CHSGREK: // Greek - { - if (ucChar >= 52 || // Keep case bit for 52-69 else ignore - ui16WpChr == 0x804 || // [ 8,4] BETA Medial | Terminal - ui16WpChr == 0x826) // [ 8,38] SIGMA terminal - { - goto store_extended_char; - } - - // No subcollation to worry about - set a zero bit by - // incrementing the bit position. - - uiSubColBitPos++; - break; - } - - case CHSCYR: - { - if (ucChar >= 144) - { - goto store_extended_char; - } - - // No subcollation to worry about - set a zero bit by - // incrementing the bit position. - - uiSubColBitPos++; - - // Georgian covers 208-249 - no collation defined yet - - break; - } - - case CHSHEB: // Hebrew - { - // Three sections in Hebrew: - // 0..26 - main characters - // 27..83 - accents that apear over previous character - // 84..118- dagesh (ancient) hebrew with accents - - // Because the ancient is only used for sayings & scriptures - // we will support a collation value and in the sub-collation - // store the actual character because sub-collation is in - // character order. - - if (ucChar >= 84) // Save ancient - value 84 and above - { - goto store_extended_char; - } - - // No subcollation to worry about - set a zero bit by - // incrementing the bit position. - - uiSubColBitPos++; - break; - } - - case CHSARB1: // Arabic 1 - { - // Three sections in Arabic: - // 00..37 - accents that display OVER a previous character - // 38..46 - symbols - // 47..57 - numbers - // 58..163 - characters - // 164 - hamzah accent - // 165..180- common characters with accents - // 181..193- ligatures - common character combinations - // 194..195- extensions - throw away when sorting - - if( ucChar <= 46) - { - goto store_extended_char; // save original character - } - - if( pucCollatedStr[ uiColLen - 1] == COLS10a + 1) // Alef? - { - ui16SubColVal = (ucChar >= 165) - ? (FLMUINT16)(fwp_alefSubColTbl[ ucChar - 165 ]) - : (FLMUINT16)7; // Alef subcol value - goto store_sub_col; - } - - if (ucChar >= 181) // Ligatures - char combination - { - goto store_extended_char; // save original character - } - - if (ucChar == 64) // taa exception - { - ui16SubColVal = 8; - goto store_sub_col; - } - - // No subcollation to worry about - set a zero bit by - // incrementing the bit position. - - uiSubColBitPos++; - break; - } - - case CHSARB2: // Arabic 2 - { - // There are some characters that share the same slot - // Check the bit table if above character 64 - - if (ucChar >= 64 && - fwp_ar2BitTbl[(ucChar-64)>> 3] & (0x80 >> (ucChar&0x07))) - { - goto store_extended_char; // Will save original - } - - // No subcollation to worry about - set a zero bit by - // incrementing the bit position. - - uiSubColBitPos++; - break; - } - - default: - { - // Increment bit position to set a zero bit. - - uiSubColBitPos++; - break; - } - } - } - - // Now let's worry about double character sorting - - if (ui16WpChr2) - { - if (pbOriginalCharsLost) - { - *pbOriginalCharsLost = TRUE; - } - - // Set the next byte that follows in the sub collation buffer. - - ucSubColBuf[ (uiSubColBitPos + 7) >> 3] = 0; - - if (bTwoIntoOne) - { - - // Sorts after character in ui16WpChr after call to - // flmWPCheckDoubleCollation - // Write the char 2 times so lower/upper bits are correct. - // Could write infinite times because of collation rules. - - pucCollatedStr[ uiColLen] = ++pucCollatedStr[ uiColLen - 1]; - uiColLen++; - - // If original was upper case, set one more upper case bit - - if( !bCaseInsensitive) - { - ucCaseBits[ (uiCaseBitPos + 7) >> 3] = 0; - if( !charIsUpper( ui16WpChr2)) - { - uiFlags |= HAD_LOWER_CASE; - } - else - { - setBit( ucCaseBits, uiCaseBitPos); - } - uiCaseBitPos++; - } - - // Take into account the diacritical space - - uiSubColBitPos++; - } - else - { - - // We have a digraph, get second collation value - - pucCollatedStr[ uiColLen++] = - (FLMBYTE)(flmWPGetCollation( ui16WpChr2, uiLanguage)); - - // Normal case, assume no diacritics set - - uiSubColBitPos++; - - // If first was upper, set one more upper bit. - - if( !bCaseInsensitive) - { - ucCaseBits [(uiCaseBitPos + 7) >> 3] = 0; - if (charIsUpper( ui16WpChr)) - { - setBit( ucCaseBits, uiCaseBitPos); - } - uiCaseBitPos++; - - // no need to reset the uiFlags - } - } - } - } - - // Check to see if uiColLen is at some overflow limit. - - if (uiColLen >= uiCharLimit || - uiColLen + bytesInBits( uiSubColBitPos) + - bytesInBits( uiCaseBitPos) >= uiTargetColLen) - { - - // We hit the maximum number of characters. See if we hit the - // end of the string. - - if (RC_BAD( rc = flmReadUTF8CharAsUnicode( pIStream, &uChar))) - { - if (rc == NE_XFLM_EOF_HIT) - { - rc = NE_XFLM_OK; - } - else - { - goto Exit; - } - } - else - { - bDataTruncated = TRUE; - } - break; - } - } - - if (puiCollationLen) - { - *puiCollationLen = uiColLen; - } - - // Add the first substring marker - also serves as making the string non-null. - - if (bFirstSubstring) - { - pucCollatedStr[ uiColLen++] = COLL_FIRST_SUBSTRING; - } - - if (bDataTruncated) - { - pucCollatedStr[ uiColLen++ ] = COLL_TRUNCATED; - } - - // Return NOTHING if no values found - - if (!uiColLen && !uiSubColBitPos) - { - if (puiCaseLen) - { - *puiCaseLen = 0; - } - goto Exit; - } - - // Store extra zero bit in the sub-collation area for Hebrew/Arabic - - if (bHebrewArabic) - { - uiSubColBitPos++; - } - - // Done putting the string into 4 sections - build the COLLATED KEY - // Don't set uiUppercaseFlag earlier than here because SC_LOWER may be zero - - uiUppercaseFlag = (uiLanguage == XFLM_GR_LANG) - ? SC_LOWER - : SC_UPPER; - - // Did we write anything to the subcollation area? - // The default terminating characters is (COLL_MARKER|SC_UPPER) - - if (uiFlags & HAD_SUB_COLLATION) - { - // Writes out a 0x7 - - pucCollatedStr[ uiColLen++] = COLL_MARKER | SC_SUB_COL; - - // Move the sub-collation into the collating string - - uiLength = bytesInBits( uiSubColBitPos); - f_memcpy( &pucCollatedStr[ uiColLen], ucSubColBuf, uiLength); - uiColLen += uiLength; - } - - // Move the upper/lower case stuff - force bits for Greek ONLY - // This is such a small size that a memcpy is not worth it - - if( uiFlags & HAD_LOWER_CASE) - { - FLMUINT uiNumBytes = bytesInBits( uiCaseBitPos); - FLMBYTE * pucCasePtr = ucCaseBits; - - // Output the 0x5 - - pucCollatedStr[ uiColLen++] = (FLMBYTE)(COLL_MARKER | SC_MIXED); - if( puiCaseLen) - { - *puiCaseLen = uiNumBytes + 1; - } - - if( uiUppercaseFlag == SC_LOWER) - { - // Negate case bits for languages (like GREEK) that sort - // upper case before lower case. - - while( uiNumBytes--) - { - pucCollatedStr[ uiColLen++] = ~(*pucCasePtr++); - } - } - else - { - while( uiNumBytes--) - { - pucCollatedStr[ uiColLen++] = *pucCasePtr++; - } - } - } - else - { - // All characters are either upper or lower case, as determined - // by uiUppercaseFlag. - - pucCollatedStr[ uiColLen++] = (FLMBYTE)(COLL_MARKER | uiUppercaseFlag); - if( puiCaseLen) - { - *puiCaseLen = 1; - } - } - -Exit: - - if( pbDataTruncated) - { - *pbDataTruncated = bDataTruncated; - } - - *puiCollatedStrLen = uiColLen; - return( rc); -} - /************************************************************************** Desc: Get the Flaim collating string and convert back to a text string Ret: Length of new wpStr @@ -4313,7 +52,7 @@ RCODE flmColText2StorageText( FLMUINT uiStorageOffset; FLMBYTE ucTmpSen[ 5]; FLMBYTE * pucTmpSen = &ucTmpSen[ 0]; - RCODE rc = NE_XFLM_OK; + RCODE rc = NE_FLM_OK; if( uiColStrLen > LOCAL_CHARS) { @@ -4333,10 +72,10 @@ RCODE flmColText2StorageText( uiMaxWPBytes = uiWPStrLen = sizeof( ucWPStr); } - if( (uiLang >= FIRST_DBCS_LANG) && - (uiLang <= LAST_DBCS_LANG)) + if( (uiLang >= FLM_FIRST_DBCS_LANG) && + (uiLang <= FLM_LAST_DBCS_LANG)) { - if( RC_BAD( rc = flmAsiaColStr2WPStr( pucColStr, uiColStrLen, + if( RC_BAD( rc = f_asiaColStr2WPStr( pucColStr, uiColStrLen, pucWPPtr, &uiWPStrLen, &uiUnconvChars, pbDataTruncated, pbFirstSubstring))) { @@ -4345,7 +84,7 @@ RCODE flmColText2StorageText( } else { - if( RC_BAD( rc = flmColStr2WPStr( pucColStr, uiColStrLen, + if( RC_BAD( rc = f_colStr2WPStr( pucColStr, uiColStrLen, pucWPPtr, &uiWPStrLen, uiLang, &uiUnconvChars, pbDataTruncated, pbFirstSubstring))) { @@ -4361,12 +100,12 @@ RCODE flmColText2StorageText( // Encode the number of characters as a SEN. If pucEncPtr is // NULL, the caller is only interested in the length of the encoded - // string, so a temporary buffer is used to call flmEncodeSEN. + // string, so a temporary buffer is used to call f_encodeSEN. - uiTmp = flmEncodeSEN( uiWPStrLen - uiUnconvChars, &pucTmpSen); + uiTmp = f_encodeSEN( uiWPStrLen - uiUnconvChars, &pucTmpSen); if( (uiStorageOffset + uiTmp) >= uiMaxStorageBytes) { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); + rc = RC_SET( NE_FLM_CONV_DEST_OVERFLOW); goto Exit; } f_memcpy( pucStoragePtr, &ucTmpSen[ 0], uiTmp); @@ -4393,7 +132,7 @@ RCODE flmColText2StorageText( } else { - if( RC_BAD( rc = flmWPToUnicode( + if( RC_BAD( rc = f_wpToUnicode( (((FLMUINT16)ucCharSet) << 8) + ucChar, &uChar))) { goto Exit; @@ -4401,7 +140,7 @@ RCODE flmColText2StorageText( } uiTmp = uiMaxStorageBytes - uiStorageOffset; - if( RC_BAD( rc = flmUni2UTF8( uChar, + if( RC_BAD( rc = f_uni2UTF8( uChar, &pucStorageBuf[ uiStorageOffset], &uiTmp))) { goto Exit; @@ -4411,7 +150,7 @@ RCODE flmColText2StorageText( if( uiStorageOffset >= uiMaxStorageBytes) { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); + rc = RC_SET( NE_FLM_CONV_DEST_OVERFLOW); goto Exit; } @@ -4433,2930 +172,54 @@ Exit: return( rc); } -/***************************************************************************** -Desc: Convert a collated string to a WP word string -*****************************************************************************/ -FSTATIC RCODE flmColStr2WPStr( - const FLMBYTE * pucColStr, // Points to the collated string - FLMUINT uiColStrLen, // Length of the collated string - FLMBYTE * pucWPStr, // Output string to build - WP word string - FLMUINT * puiWPStrLen, - FLMUINT uiLang, - FLMUINT * puiUnconvChars, - FLMBOOL * pbDataTruncated, // Set to TRUE if truncated - FLMBOOL * pbFirstSubstring) // Sets to TRUE if first substring -{ - FLMBYTE * pucWPPtr = pucWPStr; // Points to the word string data area - FLMBYTE * pucWPEnd = &pucWPPtr[ *puiWPStrLen]; - FLMUINT uiMaxWPBytes = *puiWPStrLen; - FLMUINT uiLength = uiColStrLen; // May optimize as a register - FLMUINT uiPos = 0; // Position in pucColStr - FLMUINT uiBitPos; // Computed bit position - FLMUINT uiColChar; // Not portable if a FLMBYTE value - FLMUINT uiWPStrLen; - FLMUINT uiUnconvChars = 0; - FLMBOOL bHebrewArabic = FALSE; - RCODE rc = NE_XFLM_OK; - - // WARNING: - // The code is duplicated for performance reasons. - // The US code below is much more optimized so - // any changes must be done twice. - - if( uiLang == XFLM_US_LANG) - { - while( uiLength && (pucColStr[ uiPos] > MAX_COL_OPCODE)) - { - uiLength--; - - // Move in the WP value given uppercase collated value - - uiColChar = (FLMUINT)pucColStr[ uiPos++]; - if( uiColChar == COLS0) - { - uiColChar = (FLMUINT)0xFFFF; - uiUnconvChars++; - } - else - { - uiColChar = (FLMUINT)colToWPChr[ uiColChar - COLLS]; - } - - // Put the WP char in the word string - - if( pucWPPtr + 2 >= pucWPEnd) - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto Exit; - } - - UW2FBA( (FLMUINT16)uiColChar, pucWPPtr); - pucWPPtr += 2; - } - } - else // Non-US collation - { - if( (uiLang == XFLM_AR_LANG ) || // Arabic - (uiLang == XFLM_FA_LANG ) || // Farsi - Persian - (uiLang == XFLM_HE_LANG ) || // Hebrew - (uiLang == XFLM_UR_LANG)) // Urdu - { - bHebrewArabic = TRUE; - } - - while( uiLength && (pucColStr[ uiPos] > MAX_COL_OPCODE)) - { - uiLength--; - uiColChar = (FLMUINT)pucColStr[ uiPos++]; - - switch( uiColChar) - { - case COLS9+4: // ch in spanish - case COLS9+11: // ch in czech - { - // Put the WP char in the word string - - if( pucWPPtr + 2 >= pucWPEnd) - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto Exit; - } - - UW2FBA( (FLMUINT16) 'C', pucWPPtr); - pucWPPtr += 2; - uiColChar = (FLMUINT)'H'; - uiPos++; // Move past second duplicate char - break; - } - - case COLS9+17: // ll in spanish - { - // Put the WP char in the word string - - if( pucWPPtr + 2 >= pucWPEnd) - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto Exit; - } - - UW2FBA( (FLMUINT16)'L', pucWPPtr); - pucWPPtr += 2; - uiColChar = (FLMUINT)'L'; - uiPos++; // Move past duplicate character - break; - } - - case COLS0: // Non-collating character or OEM character - { - // Actual character is in sub-collation area - - uiColChar = (FLMUINT)0xFFFF; - uiUnconvChars++; - break; - } - - default: - { - // Watch out COLS10h has () around it for subtraction - - if( bHebrewArabic && (uiColChar >= COLS10h)) - { - uiColChar = (uiColChar < COLS10a) // Hebrew only? - ? (FLMUINT) (0x900 + (uiColChar - (COLS10h))) // Hebrew - : (FLMUINT) (HebArabColToWPChr[ uiColChar - (COLS10a)]); // Arabic - } - else - { - uiColChar = (FLMUINT)colToWPChr[ uiColChar - COLLS]; - } - break; - } - } - - // Put the WP char in the word string - - if( pucWPPtr + 2 >= pucWPEnd) - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto Exit; - } - - UW2FBA( (FLMUINT16)uiColChar, pucWPPtr); - pucWPPtr += 2; - } - } - - // Terminate the string - - if( pucWPPtr + 2 >= pucWPEnd) - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto Exit; - } - - UW2FBA( (FLMUINT16)0, pucWPPtr); - uiWPStrLen = uiPos + uiPos; // Multiply by 2 - - // Parse through the sub-collation and case information. - // Here are values for some of the codes: - // [ 0x04] - case information is all uppercase (IS,DK,GR) - // [ 0x05] - case bits follow - // [ 0x06] - case information is all uppercase - // [ 0x07] - beginning of sub-collation information - // [ 0x08] - first substring field that is made - // [ 0x09] - truncation marker for text and binary - // - // Below are some cases to consider... - // - // [ COLLATION][ 0x07 sub-collation][ 0x05 case info] - // [ COLLATION][ 0x07 sub-collation][ 0x05 case info] - // [ COLLATION][ 0x07 sub-collation] - // [ COLLATION][ 0x07 sub-collation] - // [ COLLATION][ 0x05 case info] - // [ COLLATION][ 0x05 case info] - // [ COLLATION] - // [ COLLATION] - // - // In the future still want[ 0x06] to be compressed out for uppercase - // only indexes. - - // Check first substring before truncated - - if( uiLength && pucColStr[ uiPos] == COLL_FIRST_SUBSTRING) - { - if( pbFirstSubstring) - { - *pbFirstSubstring = TRUE; // Don't need to initialize to FALSE. - } - uiLength--; - uiPos++; - } - - // Is the key truncated? - - if( uiLength && pucColStr[ uiPos] == COLL_TRUNCATED) - { - if( pbDataTruncated) - { - *pbDataTruncated = TRUE; // Don't need to initialize to FALSE. - } - uiLength--; - uiPos++; - } - - // Does sub-collation follow? - // Still more to process - first work on the sub-collation (diacritics) - // Hebrew/Arabic may have empty collation area - - if( uiLength && (pucColStr[ uiPos] == (COLL_MARKER | SC_SUB_COL))) - { - FLMUINT uiTempLen; - - // Do another pass on the word string adding the diacritics - - if( RC_BAD( rc = flmWPCmbSubColBuf( pucWPStr, &uiWPStrLen, uiMaxWPBytes, - &pucColStr[ ++uiPos], bHebrewArabic, &uiBitPos))) - { - goto Exit; - } - - // Move pos to next byte value - - uiTempLen = bytesInBits( uiBitPos); - uiPos += uiTempLen; - uiLength -= uiTempLen + 1; // The 1 includes the 0x07 byte - } - - // Does the case info follow? - - if( uiLength && (pucColStr[ uiPos] >= 0x04)) - { - // Take care of the lower and upper case conversion - // If mixed case then convert using case bits - - if( pucColStr[ uiPos++] & SC_MIXED) // Increment pos here! - { - // Don't pre-increment pos on line below! - uiPos += flmWPToMixed( pucWPStr, uiWPStrLen, - &pucColStr[ uiPos], uiLang); - } - // else 0x04 or 0x06 - all characters already in uppercase - } - - // Should end perfectly at the end of the collation buffer. - - if (uiPos != uiColStrLen) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_DATA_ERROR); - goto Exit; - } - - *puiWPStrLen = uiWPStrLen; - *puiUnconvChars = uiUnconvChars; - -Exit: - - return( rc); -} - -/************************************************************************** -Desc: Combine the diacritic 5-bit values to an existing WP string -***************************************************************************/ -FSTATIC RCODE flmWPCmbSubColBuf( - FLMBYTE * pucWPStr, // Existing WP string to modify - FLMUINT * puiWPStrLen, // WP string length in bytes - FLMUINT uiMaxWPBytes, - const FLMBYTE * pucSubColBuf, // Diacritic values in 5 bit sets - FLMBOOL bHebrewArabic, // Set if language is Hebrew or Arabic - FLMUINT * puiSubColBitPos) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiSubColBitPos = 0; - FLMUINT uiNumChars = *puiWPStrLen >> 1; - FLMUINT16 ui16Diac; - FLMUINT16 ui16WPChar; - FLMUINT uiTemp; - - // For each character (two bytes) in the WP string ... - - while( uiNumChars--) - { - // Label used for hebrew/arabic - additional subcollation can follow - // This macro DOESN'T increment bitPos - - if( testOneBit( pucSubColBuf, uiSubColBitPos)) - { - // If "11110" - unmappable unicode char - 0xFFFF is before it - // If "1110" then INDEX extended char is inserted - // If "110" then extended char follows that replaces collation - // If "10" then take next 5 bits which - // contain the diacritic subcollation value. - -after_last_character: - - uiSubColBitPos++; // Eat the first 1 bit - if( !testOneBit( pucSubColBuf, uiSubColBitPos)) - { - uiSubColBitPos++; // Eat the 0 bit - ui16Diac = (FLMUINT16)(getNBits( 5, pucSubColBuf, uiSubColBitPos)); - uiSubColBitPos += 5; - - // If not extended base - - if( (ui16WPChar = FB2UW( pucWPStr)) < 0x100) - { - // Convert to WP diacritic and combine characters - - flmWPCmbcar( &ui16WPChar, ui16WPChar, - (FLMUINT16)ml1_COLtoD[ ui16Diac]); - - // Even if cmbcar fails, wpchar is still set to a valid value - - UW2FBA( ui16WPChar, pucWPStr); - } - else if( (ui16WPChar & 0xFF00) == 0x0D00) // Arabic? - { - ui16WPChar = ArabSubColToWPChr[ ui16Diac]; - UW2FBA( ui16WPChar, pucWPStr); - } - // else diacritic is extra info - // cmbcar should not handle extended chars for this design - } - else // "110" or "1110" or "11110" - { - uiSubColBitPos++; // Eat the 2nd '1' bit - if( testOneBit( pucSubColBuf, uiSubColBitPos)) // Test the 3rd bit - { - if( (*puiWPStrLen) + 2 > uiMaxWPBytes) - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto Exit; - } - - // 1110 - shift wpchars down 1 word and insert value below - uiSubColBitPos++; // Eat the 3rd '1' bit - *puiWPStrLen += 2; // Return 2 more bytes - - if( testOneBit( pucSubColBuf, uiSubColBitPos)) // Test 4th bit - { - // Unconvertable UNICODE character - // The format will be 4 bytes, 0xFF, 0xFF, 2 byte Unicode - - shiftN( pucWPStr, uiNumChars + uiNumChars + 4, 2); - uiSubColBitPos++; // Eat the 4th '1' bit - pucWPStr += 2; // Skip the 0xFFFF for now - } - else - { - // Move down 2 byte NULL and rest of the 2 byte characters - // The extended character does not have a 0xFF col value - - shiftN( pucWPStr, uiNumChars + uiNumChars + 2, 2); - uiNumChars++; // Increment because inserted - - // Fall through reading the actual charater value - } - } - - uiSubColBitPos++; // Skip past the zero bit - uiSubColBitPos = (uiSubColBitPos + 7) & (~7); // roundup to next byte - uiTemp = bytesInBits( uiSubColBitPos); // compute position - pucWPStr[ 1] = pucSubColBuf[ uiTemp]; // Character set - pucWPStr[ 0] = pucSubColBuf[ uiTemp + 1]; // Character - uiSubColBitPos += 16; - } - } - else - { - uiSubColBitPos++; - } - - pucWPStr += 2; // Next WP character - } - - if( bHebrewArabic) - { - if( testOneBit( pucSubColBuf, uiSubColBitPos)) - { - // Hebrew/Arabic can have trailing accents that - // don't have a matching collation value. - // Keep looping in this case. - // Note that subColBitPos isn't incremented above. - - uiNumChars = 0; // Set so we won't loop forever! - goto after_last_character; // process trailing bit - } - uiSubColBitPos++; // Eat the last '0' bit - } - - *puiSubColBitPos = uiSubColBitPos; - -Exit: - - return( rc); -} - -/************************************************************************** -Desc: Convert the WP string to lower case chars given low/up bit string -Out: WP characters that have been modified to their original case -Ret: Number of bytes used in the lower/upper buffer -Notes: Only WP to lower case conversion is done here for each bit NOT set. -***************************************************************************/ -FSTATIC FLMUINT flmWPToMixed( - FLMBYTE * pucWPStr, // Existing WP string to modify - FLMUINT uiWPStrLen, // Length of the WP string in bytes - const FLMBYTE * pucLowUpBitStr, // Lower/upper case bit string - FLMUINT uiLang) -{ - FLMUINT uiNumChars; - FLMUINT uiTempWord; - FLMBYTE ucTempByte = 0; - FLMBYTE ucMaskByte; - FLMBYTE ucXorByte; // Used to reverse GR, bits - - ucXorByte = (uiLang == XFLM_US_LANG) // Do most common compare first - ? (FLMBYTE)0 - : (uiLang == XFLM_GR_LANG) // Greek has uppercase first - ? (FLMBYTE)0xFF - : (FLMBYTE)0 ; - - // For each character (two bytes) in the word string ... - for( uiNumChars = uiWPStrLen >> 1, - ucMaskByte = 0; // Force first time to get a byte - uiNumChars--; - pucWPStr += 2, // Next WP character - word - ucMaskByte >>= 1) // Next bit to mask and check - { - if( ucMaskByte == 0) - { - // Time to get another byte - - ucTempByte = ucXorByte ^ *pucLowUpBitStr++; - ucMaskByte = 0x80; - } - - // If lowercase convert, else is upper - - if( (ucTempByte & ucMaskByte) == 0) - { - // Convert to lower case - COLL -> WP is already in upper case - - uiTempWord = (FLMUINT) FB2UW( pucWPStr); - if( uiTempWord >= ASCII_UPPER_A && uiTempWord <= ASCII_UPPER_Z) - { - uiTempWord |= 0x20; - } - else - { - FLMBYTE ucCharVal = (FLMBYTE)( uiTempWord & 0xFF); - FLMBYTE ucCharSet = (FLMBYTE)( uiTempWord >> 8); - - // Check if charact within region of character set - - if( ((ucCharSet == CHSMUL1) && - ((ucCharVal >= 26) && (ucCharVal <= 241))) || - ((ucCharSet == CHSGREK) && (ucCharVal <= 69)) || - ((ucCharSet == CHSCYR) && (ucCharVal <= 199))) - { - uiTempWord |= 0x01; // Set the bit ... don't increment! - } - } - UW2FBA( (FLMUINT16)uiTempWord, pucWPStr); - } - } - - uiNumChars = uiWPStrLen >> 1; - return( bytesInBits( uiNumChars)); -} - -/**************************************************************************** -Desc: Converts a character to upper case (if possible) +/*************************************************************************** +Desc: ****************************************************************************/ -FLMUINT16 flmWPUpper( - FLMUINT16 ui16WpChar) +RCODE F_DbSystem::compareUTF8Strings( + const FLMBYTE * pucLString, + FLMUINT uiLStrBytes, + FLMBOOL bLeftWild, + const FLMBYTE * pucRString, + FLMUINT uiRStrBytes, + FLMBOOL bRightWild, + FLMUINT uiCompareRules, + FLMUINT uiLanguage, + FLMINT * piResult) { - if( ui16WpChar < 256) - { - if( ui16WpChar >= ASCII_LOWER_A && ui16WpChar <= ASCII_LOWER_Z) - { - // Return ASCII upper case - - return( ui16WpChar & 0xdf); - } - } - else - { - FLMBYTE ucCharSet = ui16WpChar >> 8; - - if( ucCharSet == CHSMUL1) - { - FLMBYTE ucChar = ui16WpChar & 0xFF; - - if( ucChar >= fwp_caseConvertableRange[ (CHSMUL1-1) * 2] && - ucChar <= fwp_caseConvertableRange[ ((CHSMUL1-1) * 2) + 1]) - { - return( ui16WpChar & 0xFFFE); - } - } - else if( ucCharSet == CHSGREK) - { - if( (ui16WpChar & 0xFF) <= - fwp_caseConvertableRange[ ((CHSGREK-1) * 2) + 1]) - { - return( ui16WpChar & 0xFFFE); - } - } - else if( ucCharSet == CHSCYR) - { - if( (ui16WpChar & 0xFF) <= - fwp_caseConvertableRange[ ((CHSCYR-1) * 2) + 1]) - { - return( ui16WpChar & 0xFFFE); - } - } - else if( ui16WpChar >= Lower_JP_a) - { - // Possible double byte character set alphabetic character? - - if( ui16WpChar <= Lower_JP_z) - { - // Japanese? - - ui16WpChar = (ui16WpChar - Lower_JP_a) + Upper_JP_A; - } - else if( ui16WpChar >= Lower_KR_a && ui16WpChar <= Lower_KR_z) - { - // Korean? - - ui16WpChar = (ui16WpChar - Lower_KR_a) + Upper_KR_A; - } - else if( ui16WpChar >= Lower_CS_a && ui16WpChar <= Lower_CS_z) - { - // Chinese Simplified? - - ui16WpChar = (ui16WpChar - Lower_CS_a) + Upper_CS_A; - } - else if( ui16WpChar >= Lower_CT_a && ui16WpChar <= Lower_CT_z) - { - // Chinese Traditional? - - ui16WpChar = (ui16WpChar - Lower_CT_a) + Upper_CT_A; - } - } - } - - // Return original character - original not in lower case. - - return( ui16WpChar); -} - -/**************************************************************************** -Desc: Checks to see if WP character is upper case -****************************************************************************/ -FLMBOOL flmWPIsUpper( - FLMUINT16 ui16WpChar) -{ - FLMBYTE ucChar; - FLMBYTE ucCharSet; - - // Get character - - ucChar = (FLMBYTE)(ui16WpChar & 0xFF); - - // Test if ASCII character set - - if( !(ui16WpChar & 0xFF00)) - { - return( (ucChar >= ASCII_LOWER_A && ucChar <= ASCII_LOWER_Z) - ? FALSE - : TRUE); - } - - // Get the character set - - ucCharSet = (FLMBYTE) (ui16WpChar >> 8); - - // CHSMUL1 == Multinational 1 character set - // CHSGREK == Greek character set - // CHSCYR == Cyrillic character set - - if( (ucCharSet == CHSMUL1 && ucChar >= 26 && ucChar <= 241) || - (ucCharSet == CHSGREK && ucChar <= 69) || - (ucCharSet == CHSCYR && ucChar <= 199)) - { - return( (ucChar & 1) ? FALSE : TRUE); - } - - // Don't care that double ss is lower - - return( TRUE); -} - -/**************************************************************************** -Desc: Converts a character to lower case (if possible) -****************************************************************************/ -FLMUINT16 flmWPLower( - FLMUINT16 ui16WpChar) -{ - if( ui16WpChar < 256) - { - if( ui16WpChar >= ASCII_UPPER_A && ui16WpChar <= ASCII_UPPER_Z) - { - return( ui16WpChar | 0x20); - } - } - else - { - FLMBYTE ucCharSet = ui16WpChar >> 8; - - if( ucCharSet == CHSMUL1) - { - FLMBYTE ucChar = ui16WpChar & 0xFF; - - if( ucChar >= fwp_caseConvertableRange[ (CHSMUL1-1) * 2] && - ucChar <= fwp_caseConvertableRange[ ((CHSMUL1-1) * 2) + 1] ) - { - return( ui16WpChar | 1); - } - } - else if( ucCharSet == CHSGREK) - { - if( (ui16WpChar & 0xFF) <= - fwp_caseConvertableRange[ ((CHSGREK-1) * 2) + 1]) - { - return( ui16WpChar | 1); - } - } - else if( ucCharSet == CHSCYR) - { - if( (ui16WpChar & 0xFF) <= - fwp_caseConvertableRange[ ((CHSCYR-1) * 2) + 1]) - { - return( ui16WpChar | 1); - } - } - else if( ui16WpChar >= Upper_JP_A) - { - // Possible double byte character set alphabetic character? - - if( ui16WpChar <= Upper_JP_Z) - { - // Japanese? - - ui16WpChar = ui16WpChar - Upper_JP_A + Lower_JP_a; - } - else if( ui16WpChar >= Upper_KR_A && ui16WpChar <= Upper_KR_Z) - { - // Korean? - - ui16WpChar = ui16WpChar - Upper_KR_A + Lower_KR_a; - } - else if( ui16WpChar >= Upper_CS_A && ui16WpChar <= Upper_CS_Z) - { - // Chinese Simplified? - - ui16WpChar = ui16WpChar - Upper_CS_A + Lower_CS_a; - } - else if( ui16WpChar >= Upper_CT_A && ui16WpChar <= Upper_CT_Z) - { - // Chinese Traditional? - - ui16WpChar = ui16WpChar - Upper_CT_A + Lower_CT_a; - } - } - } - - // Return original character, original not in upper case - - return( ui16WpChar); -} - -/**************************************************************************** -Desc: Break a WP character into a base and a diacritical char. -Ret: TRUE - if not found - FALSE - if found -****************************************************************************/ -FLMBOOL flmWPBrkcar( - FLMUINT16 ui16WpChar, - FLMUINT16 * pui16BaseChar, - FLMUINT16 * pui16DiacriticChar) -{ - BASE_DIACRIT * pBaseDiacritic; - FLMINT iTableIndex; - - if( (pBaseDiacritic = fwp_car60_c[ HI(ui16WpChar)]) == 0) - { - return( TRUE); - } - - iTableIndex = ((FLMBYTE)ui16WpChar) - pBaseDiacritic->start_char; - if( iTableIndex < 0 || - iTableIndex > pBaseDiacritic->char_count || - pBaseDiacritic->table [iTableIndex].base == (FLMBYTE)0xFF) - { - return( TRUE); - } - - if( (HI( ui16WpChar) != CHSMUL1) || - ((fwp_ml1_cb60[ ((FLMBYTE) ui16WpChar) >> 3] >> - (7 - (ui16WpChar & 0x07))) & 0x01)) - { - - // normal case, same base as same as characters - - *pui16BaseChar = (ui16WpChar & 0xFF00) | - pBaseDiacritic->table [iTableIndex].base; - *pui16DiacriticChar = (ui16WpChar & 0xFF00) | - pBaseDiacritic->table[iTableIndex].diacrit; - } - else - { - - // Multi-national where base is ascii value. - - *pui16BaseChar = pBaseDiacritic->table [iTableIndex].base; - *pui16DiacriticChar = (ui16WpChar & 0xFF00) | - pBaseDiacritic->table[iTableIndex].diacrit; - } - - return( FALSE); -} - -/**************************************************************************** -Desc: Take a base and a diacritic and compose a WP character. - Note on base character: i's and j's must be dotless i's and j's (for - those which use them) or they will not be found. -Ret: TRUE - if not found - FALSE - if found -Notes: ascii characters with diacriticals are in multi-national if anywhere; - all other base chars with diacritics are found in their own sets. -****************************************************************************/ -FSTATIC FLMBOOL flmWPCmbcar( - FLMUINT16 * pui16WpChar, - FLMUINT16 ui16BaseChar, - FLMINT16 ui16DiacriticChar) -{ - FLMUINT uiRemaining; - FLMBYTE ucCharSet; - FLMBYTE ucChar; - BASE_DIACRIT * pBaseDiacritic; - BASE_DIACRIT_TABLE * pTable; - - ucCharSet = HI( ui16BaseChar); - if( ucCharSet > WP_MAX_CAR60_SIZE) - { - return( TRUE); - } - - // Is base ASCII? If so, look in multinational 1 - - if( !ucCharSet) - { - ucCharSet = CHSMUL1; - } - - if( (pBaseDiacritic = fwp_car60_c[ucCharSet]) == 0) - { - return( TRUE); - } - - ucChar = LO( ui16BaseChar); - ui16DiacriticChar = LO( ui16DiacriticChar); - pTable = pBaseDiacritic->table; - for( uiRemaining = pBaseDiacritic->char_count; - uiRemaining; - uiRemaining--, pTable++ ) - { - // Same base? - - if( pTable->base == ucChar && - (pTable->diacrit & 0x7F) == ui16DiacriticChar) - { - // Same diacritic? - - *pui16WpChar = (FLMUINT16) (((FLMUINT16) ucCharSet << 8) + - (pBaseDiacritic->start_char + - (FLMUINT16)(pTable - pBaseDiacritic->table))); - return( FALSE); - } - } - - return( TRUE); -} - -/************************************************************************** -Desc: Find the collating value of a WP character -ret: Collating value (COLS0 is high value - undefined WP char) -***********************************************************************/ -FLMUINT16 flmWPGetCollation( - FLMUINT16 ui16WpChar, - FLMUINT uiLanguage) -{ - FLMUINT16 ui16State; - FLMBYTE ucCharVal; - FLMBYTE ucCharSet; - FLMBOOL bHebrewArabicFlag = FALSE; - TBL_B_TO_BP * pColTbl = fwp_col60Tbl; - - // State ONLY for non-US - - if( uiLanguage != XFLM_US_LANG) - { - if( uiLanguage == XFLM_AR_LANG || // Arabic - uiLanguage == XFLM_FA_LANG || // Farsi - persian - uiLanguage == XFLM_HE_LANG || // Hebrew - uiLanguage == XFLM_UR_LANG) // Urdu - { - pColTbl = fwp_HebArabicCol60Tbl; - bHebrewArabicFlag = TRUE; - } - else - { - // check if uiLanguage candidate for alternate double collating - - ui16State = getNextCharState( START_COL, uiLanguage); - if( 0 != (ui16State = getNextCharState( (ui16State - ? ui16State // look at special case languages - : START_ALL), // look at US and European - (FLMUINT) ui16WpChar))) - { - return( ui16State); - } - } - } - - ucCharVal = (FLMBYTE)ui16WpChar; - ucCharSet = (FLMBYTE)(ui16WpChar >> 8); - - do - { - if( pColTbl->key == ucCharSet) - { - FLMBYTE * pucColVals; // table of collating values - - pucColVals = pColTbl->charPtr; - - // Check if the value is in the range of collated chars - // Above lower range of table? - - if (ucCharVal >= *pucColVals) - { - // Make value zero based to index - - ucCharVal -= *pucColVals++; - - // Below maximum number of table entries? - - if( ucCharVal < *pucColVals++) - { - // Return collated value. - - return( pucColVals[ ucCharVal]); - } - } - } - - // Go to next table entry - - pColTbl++; - } while( pColTbl->key != 0xFF); - - if( bHebrewArabicFlag) - { - if( ucCharSet == CHSHEB || - ucCharSet == CHSARB1 || - ucCharSet == CHSARB2) - { - // Same as COLS0_HEBREW - - return( COLS0_ARABIC); - } - } - - // Defaults for characters that don't have a collation value. - - return( COLS0); -} - -/**************************************************************************** -Desc: Check for double characters that sort as 1 (like ch in Spanish) or - 1 character that should sort as 2 (like ? sorts as ae in French). -Return: 0 = nothing changes - 1 if sorting 2 characters as 1 - *pui16WpChar is the one character. - second character value if 1 character sorts as 2, - *pui16WpChar changes to first character in sequence -****************************************************************************/ -RCODE flmWPCheckDoubleCollation( - IF_PosIStream * pIStream, - FLMBOOL bUnicodeStream, - FLMBOOL bAllowTwoIntoOne, - FLMUNICODE * puzChar, - FLMUNICODE * puzChar2, - FLMBOOL * pbTwoIntoOne, - FLMUINT uiLanguage) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT16 ui16CurState; - FLMUINT16 ui16WpChar; - FLMUNICODE uzLastChar = 0; - FLMUNICODE uChar = *puzChar; - FLMUNICODE uDummy; - FLMBOOL bUpperFlag; - FLMUINT64 ui64SavePosition = pIStream->getCurrPosition(); - - if (!flmUnicodeToWP( *puzChar, &ui16WpChar)) - { - ui16WpChar = UNK_UNICODE_CODE; - } - bUpperFlag = flmWPIsUpper( ui16WpChar); - - if ((ui16CurState = getNextCharState( 0, uiLanguage)) == 0) - { - *pbTwoIntoOne = FALSE; - *puzChar2 = 0; - goto Exit; - } - - for (;;) - { - switch (ui16CurState) - { - case INSTSG: - *puzChar = *puzChar2 = (FLMUNICODE)f_toascii( 's'); - *pbTwoIntoOne = FALSE; - goto Exit; - case INSTAE: - if (bUpperFlag) - { - *puzChar = (FLMUNICODE)f_toascii( 'A'); - *puzChar2 = (FLMUNICODE)f_toascii( 'E'); - } - else - { - *puzChar = (FLMUNICODE)f_toascii( 'a'); - *puzChar2 = (FLMUNICODE)f_toascii( 'e'); - } - *pbTwoIntoOne = FALSE; - goto Exit; - case INSTIJ: - if (bUpperFlag) - { - *puzChar = (FLMUNICODE)f_toascii( 'I'); - *puzChar2 = (FLMUNICODE)f_toascii( 'J'); - } - else - { - *puzChar = (FLMUNICODE)f_toascii( 'i'); - *puzChar2 = (FLMUNICODE)f_toascii( 'j'); - } - *pbTwoIntoOne = FALSE; - goto Exit; - case INSTOE: - if (bUpperFlag) - { - *puzChar = (FLMUNICODE)f_toascii( 'O'); - *puzChar2 = (FLMUNICODE)f_toascii( 'E'); - } - else - { - *puzChar = (FLMUNICODE)f_toascii( 'o'); - *puzChar2 = (FLMUNICODE)f_toascii( 'e'); - } - *pbTwoIntoOne = FALSE; - goto Exit; - case WITHAA: - *puzChar = (FLMUNICODE)(bUpperFlag - ? (FLMUNICODE)0xC5 - : (FLMUNICODE)0xE5); - - if (RC_BAD( rc = pIStream->positionTo( ui64SavePosition))) - { - goto Exit; - } - - if( bUnicodeStream) - { - rc = pIStream->read( &uDummy, sizeof( FLMUNICODE), NULL); - } - else - { - rc = flmReadUTF8CharAsUnicode( pIStream, &uDummy); - } - - if( RC_BAD( rc)) - { - if (rc == NE_XFLM_EOF_HIT) - { - rc = NE_XFLM_OK; - } - else - { - goto Exit; - } - } - - ui64SavePosition = pIStream->getCurrPosition(); - break; - case AFTERC: - *puzChar = (FLMUINT16)(bUpperFlag - ? (FLMUNICODE)f_toascii( 'C') - : (FLMUNICODE)f_toascii( 'c')); -Position_After_2nd: - - if( bAllowTwoIntoOne) - { - *puzChar2 = uzLastChar; - *pbTwoIntoOne = TRUE; - - if (RC_BAD( rc = pIStream->positionTo( ui64SavePosition))) - { - goto Exit; - } - - if( bUnicodeStream) - { - rc = pIStream->read( &uChar, sizeof( FLMUNICODE), NULL); - } - else - { - rc = flmReadUTF8CharAsUnicode( pIStream, &uChar); - } - - if (RC_BAD( rc)) - { - if (rc == NE_XFLM_EOF_HIT) - { - rc = NE_XFLM_OK; - } - else - { - goto Exit; - } - } - - ui64SavePosition = pIStream->getCurrPosition(); - } - goto Exit; - case AFTERH: - *puzChar = (FLMUINT16)(bUpperFlag - ? (FLMUNICODE)f_toascii( 'H') - : (FLMUNICODE)f_toascii( 'h')); - goto Position_After_2nd; - case AFTERL: - *puzChar = (FLMUINT16)(bUpperFlag - ? (FLMUNICODE)f_toascii( 'L') - : (FLMUNICODE)f_toascii( 'l')); - goto Position_After_2nd; - default: - // Handles STATE1 through STATE11 also - break; - } - - if ((ui16CurState = getNextCharState( ui16CurState, - flmWPLower( ui16WpChar))) == 0) - { - break; - } - - uzLastChar = uChar; - - if( bUnicodeStream) - { - rc = pIStream->read( &uChar, sizeof( FLMUNICODE), NULL); - } - else - { - rc = flmReadUTF8CharAsUnicode( pIStream, &uChar); - } - - if (RC_BAD( rc)) - { - if (rc == NE_XFLM_EOF_HIT) - { - rc = NE_XFLM_OK; - } - else - { - goto Exit; - } - } - - if (!flmUnicodeToWP( uChar, &ui16WpChar)) - { - ui16WpChar = UNK_UNICODE_CODE; - } - } - -Exit: - - if (RC_OK( rc)) - { - rc = pIStream->positionTo( ui64SavePosition); - } - - return( rc); -} - -/**************************************************************************** -Desc: Returns the collation value of the input WP character. - If in charset 11 will convert the character to Zenkaku (double wide). -In: ui16WpChar - Char to collate off of - could be in CS0..14 or x24..up - ui16NextWpChar - next WP char for CS11 voicing marks - ui16PrevColValue - previous collating value - for repeat/vowel repeat - pui16ColValue - returns 2 byte collation value - pui16SubColVal - 0, 6 or 16 bit value for the latin sub collation - or the kana size & vowel voicing - 001 - set if large (upper) character - 010 - set if voiced - 100 - set if half voiced - - pucCaseBits - returns 2 bits - Latin/Greek/Cyrillic - 01 - case bit set if character is uppercase - 10 - double wide character in CS 0x25xx, 0x26xx and 0x27xx - Japanese - 00 - double wide hiragana 0x255e..25b0 - 01 - double wide katakana 0x2600..2655 - 10 - double wide symbols that map to charset 11 - 11 - single wide katakana from charset 11 -Ret: 0 - no valid collation value - high values set for pui16ColValue - Sub-collation gets original WP character value - 1 - valid collation value - 2 - valid collation value and used the ui16NextWpChar - -Notes: Code taken from XCH2COL.ASM - routine xch2col_f - also from CMPWS.ASM - routine getcase -Terms: - HANKAKU - single wide characters in charsets 0..14 - ZENKAKU - double wide characters in charsets 0x24..end of kanji - KANJI - collation values are 0x2900 less than WPChar value - -****************************************************************************/ -FLMUINT16 flmWPAsiaGetCollation( - FLMUINT16 ui16WpChar, // WP char to get collation values - FLMUINT16 ui16NextWpChar, // Next WP char - for CS11 voicing marks - FLMUINT16 ui16PrevColValue, // Previous collating value - FLMUINT16 * pui16ColValue, // Returns collation value - FLMUINT16 * pui16SubColVal, // Returns sub-collation value - FLMBYTE * pucCaseBits, // Returns case bits value - FLMBOOL bUppercaseFlag) // Set if to convert to uppercase -{ - FLMUINT16 ui16ColValue; - FLMUINT16 ui16SubColVal; - FLMBYTE ucCaseBits = 0; - FLMBYTE ucCharSet = ui16WpChar >> 8; - FLMBYTE ucCharVal = ui16WpChar & 0xFF; - FLMUINT16 ui16Hankaku; - FLMUINT uiLoop; - FLMUINT16 ui16ReturnValue = 1; - - ui16ColValue = ui16SubColVal = 0; - - // Kanji or above - - if( ucCharSet >= 0x2B) - { - // Puts 2 or above into high byte. - - ui16ColValue = ui16WpChar - 0x2900; - - // No subcollation or case bits need to be set - - goto Exit; - } - - // Single wide character? (HANKAKU) - - if( ucCharSet < 11) - { - // Get the values from a non-asian character - // LATIN, GREEK or CYRILLIC - // The width bit may have been set on a jump to - // label from below. - -Latin_Greek_Cyrillic: - - // YES: Pass XFLM_US_LANG because this is what we want - - // Prevents double character sorting. - - ui16ColValue = flmWPGetCollation( ui16WpChar, XFLM_US_LANG); - - if (bUppercaseFlag || flmWPIsUpper( ui16WpChar)) - { - // Uppercase - set case bit - - ucCaseBits |= SET_CASE_BIT; - } - - // Character for which there is no collation value? - - if( ui16ColValue == COLS0) - { - ui16ReturnValue = 0; - if( !flmWPIsUpper( ui16WpChar)) - { - // Convert to uppercase - - ui16WpChar--; - } - ui16ColValue = 0xFFFF; - ui16SubColVal = ui16WpChar; - } - else if( ucCharSet) // Don't bother with ascii - { - if( !flmWPIsUpper( ui16WpChar)) - { - // Convert to uppercase - - ui16WpChar--; - } - - if( ucCharSet == CHSMUL1) - { - FLMUINT16 ui16Base; - FLMUINT16 ui16Diacritic; - - ui16SubColVal = !flmWPBrkcar( ui16WpChar, &ui16Base, - &ui16Diacritic) - ? fwp_dia60Tbl[ ui16Diacritic & 0xFF] - : ui16WpChar; - } - else if( ucCharSet == CHSGREK) // GREEK - { - if( ui16WpChar >= 0x834 || // [8,52] or above - ui16WpChar == 0x804 || // [8,4] BETA Medial | Terminal - ui16WpChar == 0x826) // [8,38] SIGMA terminal - { - ui16SubColVal = ui16WpChar; - } - } - else if( ucCharSet == CHSCYR) // CYRILLIC - { - if( ui16WpChar >= 0xA90) // [10, 144] or above - { - ui16SubColVal = ui16WpChar; // Dup collation values - } - } - // else don't need a sub collation value - } - goto Exit; - } - - // Single wide Japanese character? - - if( ucCharSet == 11) - { - FLMUINT16 ui16KanaChar; - - // Convert charset 11 to Zenkaku (double wide) CS24 or CS26 hex. - // All characters in charset 11 will convert to CS24 or CS26. - // when combining the collation and the sub-collation values. - - if( flmWPHanToZenkaku( ui16WpChar, - ui16NextWpChar, &ui16KanaChar ) == 2) - { - // Return 2 - - ui16ReturnValue++; - } - - ucCaseBits |= SET_WIDTH_BIT; // Set so will allow to go back - ui16WpChar = ui16KanaChar; // If in CS24 will fall through to ZenKaku - ucCharSet = ui16KanaChar >> 8; - ucCharVal = ui16KanaChar & 0xFF; - } - - if( ui16WpChar < 0x2400) - { - // In some other character set - - goto Latin_Greek_Cyrillic; - } - else if( ui16WpChar >= 0x255e && // Hiragana? - ui16WpChar <= 0x2655) // Katakana? - { - if( ui16WpChar >= 0x2600) - { - ucCaseBits |= SET_KATAKANA_BIT; - } - - // HIRAGANA & KATAKANA - // Kana contains both hiragana and katakana. - // The tables contain the same characters in same order - - if( ucCharSet == 0x25) - { - // Change value to be in character set 26 - - ucCharVal -= 0x5E; - } - - ui16ColValue = 0x0100 + KanaColTbl[ ucCharVal ]; - ui16SubColVal = KanaSubColTbl[ ucCharVal ]; - goto Exit; - } - - // ZenKaku - means any double wide character - // Hankaku - single wide character - - // Inputs: 0x2400..2559 symbols..latin - Zenkaku - // 0x265B..2750 greek..cyrillic - Zenkaku - - // SET_WIDTH_BIT may have been set if original char - // was in 11 and got converted to CS24. [1,2,5,27(extendedVowel),53,54] - // Original chars from CS11 will have some collation value that when - // combined with the sub-collation value will format a character in - // CS24. The width bit will then convert back to CS11. - - if( (ui16Hankaku = flmWPZenToHankaku( ui16WpChar, NULL)) != 0) - { - if( (ui16Hankaku >> 8) != 11) // if CharSet11 was a CS24 symbol - { - ui16WpChar = ui16Hankaku; // May be CS24 symbol/latin/gk/cy - ucCharSet = ui16WpChar >> 8; - ucCharVal = ui16WpChar & 0xFF; - ucCaseBits |= SET_WIDTH_BIT; // Latin symbols double wide - goto Latin_Greek_Cyrillic; - } - } - - // 0x2400..0x24bc Japanese symbols that cannot be converted to Hankaku. - // All 6 original symbol chars from 11 will also be here. - // First try to find a collation value of the symbol. - // The sub-collation value will be the position in the CS24 table + 1. - - for( uiLoop = 0; - uiLoop < (sizeof( fwp_Ch24ColTbl) / sizeof( BYTE_WORD_TBL)); - uiLoop++ ) - { - if( ucCharVal == fwp_Ch24ColTbl[ uiLoop].ByteValue) - { - if( (ui16ColValue = fwp_Ch24ColTbl[ uiLoop].WordValue) < 0x100) - { - // Don't save for chuuten, dakuten, handakuten - - ui16SubColVal = (FLMUINT16)(uiLoop + 1); - } - break; - } - } - - if( !ui16ColValue) - { - // Now see if it's a repeat or repeat-vowel character - - if( (((ucCharVal >= 0x12) && (ucCharVal <= 0x15)) || - (ucCharVal == 0x17) || - (ucCharVal == 0x18)) && - ((ui16PrevColValue >> 8) == 1)) - { - ui16ColValue = ui16PrevColValue; - - // Store original WP character - - ui16SubColVal = ui16WpChar; - } - else if( (ucCharVal == 0x1B) && // repeat vowel? - (ui16PrevColValue >= 0x100) && - (ui16PrevColValue < COLS_ASIAN_MARKS)) // Previous kana char? - { - ui16ColValue = 0x0100 + KanaColToVowel[ ui16PrevColValue & 0xFF ]; - - // Store original WP character - - ui16SubColVal = ui16WpChar; - } - else - { - ui16ReturnValue = 0; - ui16ColValue = 0xFFFF; // No collation value - ui16SubColVal = ui16WpChar; // Never have changed if gets here - } - } - -Exit: - - // Set return values - - *pui16ColValue = ui16ColValue; - *pui16SubColVal = ui16SubColVal; - *pucCaseBits = ucCaseBits; - - return( ui16ReturnValue); -} - -/**************************************************************************** -Desc: Convert a text string to a collated string. -****************************************************************************/ -RCODE flmAsiaUTF8ToColText( - IF_PosIStream * pIStream, - FLMBYTE * pucColStr, // Output collated string - FLMUINT * puiColStrLen, // Collated string length return value - // Input value is MAX num of bytes in buffer - FLMBOOL bCaseInsensitive, // Set if to convert to uppercase - FLMUINT * puiCollationLen, // Returns the collation bytes length - FLMUINT * puiCaseLen, // Returns length of case bytes - FLMUINT uiCharLimit, // Max number of characters in this key piece - FLMBOOL bFirstSubstring, // TRUE is this is the first substring key - FLMBOOL bDataTruncated, // Was input data already truncated. - FLMBOOL * pbDataTruncated) -{ - RCODE rc = NE_XFLM_OK; - FLMBOOL bEndOfStr = FALSE; - FLMUINT uiLength; - FLMUINT uiTargetColLen = *puiColStrLen - 12; // 6=ovhd,6=worst char - FLMBYTE ucSubColBuf[ MAX_SUBCOL_BUF + 1]; // Holds Sub-col values (diac) - FLMBYTE ucLowUpBuf[ MAX_CASE_BYTES + MAX_CASE_BYTES + 2]; // 2 case bits/wpchar - FLMUINT uiColLen; - FLMUINT uiSubColBitPos; - FLMUINT uiLowUpBitPos; - FLMUINT uiFlags; - FLMUNICODE uChar; - FLMUINT16 ui16NextWpChar; - FLMUINT16 ui16ColValue; - - uiColLen = uiSubColBitPos = uiLowUpBitPos = uiFlags = 0; - uChar = ui16ColValue = 0; - - // We don't want any single key piece to "pig out" more - // than 256 bytes of the key - - if( uiTargetColLen > 256 - 12) - { - uiTargetColLen = 256 - 12; - } - - // Make sure ucSubColBuf and ucLowUpBuf are set to 0 - - f_memset( ucSubColBuf, 0, sizeof( ucSubColBuf)); - f_memset( ucLowUpBuf, 0, sizeof( ucLowUpBuf)); - - ui16NextWpChar = 0; - - while( !bEndOfStr || ui16NextWpChar || uChar) - { - FLMUINT16 ui16WpChar; // Current WP character - FLMUINT16 ui16SubColVal; // Sub-collated value (diacritic) - FLMBYTE ucCaseFlags; - FLMUINT16 ui16CurWpChar; - - // Get the next character from the string. - - ui16WpChar = ui16NextWpChar; - for( ui16NextWpChar = 0; - (!ui16WpChar || !ui16NextWpChar) && - !uChar && !bEndOfStr;) - { - if (!bEndOfStr) - { - if( RC_BAD( rc = flmReadUTF8CharAsUnicode( pIStream, &uChar))) - { - if (rc == NE_XFLM_EOF_HIT) - { - rc = NE_XFLM_OK; - bEndOfStr = TRUE; - } - else - { - goto Exit; - } - } - } - else - { - uChar = 0; - } - - if( flmUnicodeToWP( uChar, &ui16CurWpChar)) - { - uChar = 0; - } - - if( !ui16WpChar) - { - ui16WpChar = ui16CurWpChar; - } - else - { - ui16NextWpChar = ui16CurWpChar; - } - } - - // If we didn't get a character, break out of the outer - // processing loop. - - if( !ui16WpChar && !uChar) - { - break; - } - - if( ui16WpChar) - { - if( flmWPAsiaGetCollation( ui16WpChar, ui16NextWpChar, ui16ColValue, - &ui16ColValue, &ui16SubColVal, &ucCaseFlags, bCaseInsensitive) == 2) - { - // Took the ui16NextWpChar value - // Force to skip this value - - ui16NextWpChar = 0; - } - } - else // Use the uChar value for this pass - { - // This handles all of the UNICODE characters that could not - // be converted to WP characters - which will include most - // of the Asian characters. - - ucCaseFlags = 0; - if( uChar < 0x20) - { - ui16ColValue = 0xFFFF; - - // Setting ui16SubColVal to a high code will ensure - // that the code that the uChar value will be stored - // in in the sub-collation area. - - ui16SubColVal = 0xFFFF; - - // NOTE: uChar SHOULD NOT be set to zero here. - // It will be set to zero below. - } - else - { - ui16ColValue = uChar; - ui16SubColVal = 0; - uChar = 0; - } - } - - // Store the values in 2 bytes - - pucColStr[ uiColLen++] = (FLMBYTE)(ui16ColValue >> 8); - pucColStr[ uiColLen++] = (FLMBYTE)(ui16ColValue & 0xFF); - - if( ui16SubColVal) - { - uiFlags |= HAD_SUB_COLLATION; - if( ui16SubColVal <= 31) // 5 bit - store bits 10 - { - setBit( ucSubColBuf, uiSubColBitPos); - uiSubColBitPos += 1 + 1; // Stores a zero - setBits( 5, ucSubColBuf, uiSubColBitPos, ui16SubColVal); - uiSubColBitPos += 5; - } - else // 2 bytes - store bits 110 or 11110 - { - FLMUINT uiTemp; - - setBit( ucSubColBuf, uiSubColBitPos); - uiSubColBitPos++; - setBit( ucSubColBuf, uiSubColBitPos); - uiSubColBitPos++; - - if( !ui16WpChar && uChar) // Store as "11110" - { - ui16SubColVal = uChar; - uChar = 0; - setBit( ucSubColBuf, uiSubColBitPos); - uiSubColBitPos++; - setBit( ucSubColBuf, uiSubColBitPos); - uiSubColBitPos++; - } - uiSubColBitPos++; // Skip past the zero - - // Go to the next byte boundary to write the WP char - uiSubColBitPos = (uiSubColBitPos + 7) & (~7); - uiTemp = bytesInBits( uiSubColBitPos); - - // Need to store HIGH-Low - PC format is Low-high! - ucSubColBuf[ uiTemp ] = (FLMBYTE)(ui16SubColVal >> 8); - ucSubColBuf[ uiTemp + 1] = (FLMBYTE)(ui16SubColVal); - - uiSubColBitPos += 16; - } - } - else - { - uiSubColBitPos++; - } - - // Save case information - always 2 bits worth for Asian - - if( ucCaseFlags & 0x02) - { - setBit( ucLowUpBuf, uiLowUpBitPos); - } - - uiLowUpBitPos++; - - if( ucCaseFlags & 0x01) - { - setBit( ucLowUpBuf, uiLowUpBitPos); - } - uiLowUpBitPos++; - - // Check to see if uiColLen is within 1 byte of max - - if( (uiColLen >= uiCharLimit) || - (uiColLen + bytesInBits( uiSubColBitPos) + - bytesInBits( uiLowUpBitPos) >= uiTargetColLen)) - { - // Still something left? - - if (ui16NextWpChar || uChar) - { - bDataTruncated = TRUE; - } - else if (!bEndOfStr) - { - if (RC_BAD( rc = flmReadUTF8CharAsUnicode( pIStream, &uChar))) - { - if (rc == NE_XFLM_EOF_HIT) - { - bEndOfStr = TRUE; - rc = NE_XFLM_OK; - } - else - { - goto Exit; - } - } - else - { - bDataTruncated = TRUE; - } - } - break; // Hit the max. number of characters - } - } - - if( puiCollationLen) - { - *puiCollationLen = uiColLen; - } - - // Add the first substring marker - also serves - // as making the string non-null. - - if( bFirstSubstring) - { - pucColStr[ uiColLen++] = 0; - pucColStr[ uiColLen++] = COLL_FIRST_SUBSTRING; - } - - if( bDataTruncated) - { - pucColStr[ uiColLen++] = 0; - pucColStr[ uiColLen++] = COLL_TRUNCATED; - } - - // Return NOTHING if no values found - - if( !uiColLen && !uiSubColBitPos) - { - if( puiCaseLen) - { - *puiCaseLen = 0; - } - goto Exit; - } - - // Done putting the String into 3 sections - build the COLLATED KEY - - if( uiFlags & HAD_SUB_COLLATION) - { - pucColStr[ uiColLen++] = 0; - pucColStr[ uiColLen++] = COLL_MARKER | SC_SUB_COL; - - // Move the Sub-collation (diacritics) into the collating string - - uiLength = (FLMUINT)(bytesInBits( uiSubColBitPos)); - f_memcpy( &pucColStr[ uiColLen], ucSubColBuf, uiLength); - uiColLen += uiLength; - } - - // Always represent the marker as 2 bytes and case bits in Asia - - pucColStr[ uiColLen++] = 0; - pucColStr[ uiColLen++] = COLL_MARKER | SC_MIXED; - - uiLength = (FLMUINT)(bytesInBits( uiLowUpBitPos)); - f_memcpy( &pucColStr[ uiColLen ], ucLowUpBuf, uiLength); - - if( puiCaseLen) - { - *puiCaseLen = (FLMUINT)(uiLength + 2); - } - uiColLen += uiLength; - -Exit: - - if( pbDataTruncated) - { - *pbDataTruncated = bDataTruncated; - } - - *puiColStrLen = uiColLen; - return( rc); + return( f_compareUTF8Strings( pucLString, uiLStrBytes, bLeftWild, + pucRString, uiRStrBytes, bRightWild, uiCompareRules, uiLanguage, + piResult)); } /*************************************************************************** -Desc: Get the original string from an asian collation string -Ret: Length of the word string in bytes +Desc: ****************************************************************************/ -FSTATIC RCODE flmAsiaColStr2WPStr( - const FLMBYTE * pucColStr, // Points to the collated string - FLMUINT uiColStrLen, // Length of the collated string - FLMBYTE * pucWPStr, // Output string to build - WP word string - FLMUINT * puiWPStrLen, - FLMUINT * puiUnconvChars, - FLMBOOL * pbDataTruncated, // Set to TRUE if truncated - FLMBOOL * pbFirstSubstring) // Sets to TRUE if first substring +RCODE F_DbSystem::compareUnicodeStrings( + const FLMUNICODE * puzLString, + FLMUINT uiLStrBytes, + FLMBOOL bLeftWild, + const FLMUNICODE * puzRString, + FLMUINT uiRStrBytes, + FLMBOOL bRightWild, + FLMUINT uiCompareRules, + FLMUINT uiLanguage, + FLMINT * piResult) { - FLMBYTE * pucWPStrPtr = pucWPStr; - FLMBYTE * pucWPEnd = &pucWPStr[ *puiWPStrLen]; - FLMUINT uiLength = uiColStrLen; - FLMUINT uiMaxWPBytes = *puiWPStrLen; - FLMUINT uiColStrPos = 0; - FLMBOOL bHadExtended = FALSE; - FLMUINT uiWPStrLen; - FLMUINT16 ui16ColChar; - FLMUINT uiUnconvChars = 0; - FLMUINT uiColBytesProcessed; - RCODE rc = NE_XFLM_OK; - - while( uiLength) - { - FLMBYTE ucChar = pucColStr[ uiColStrPos + 1]; - FLMBYTE ucCharSet = pucColStr[ uiColStrPos]; - - ui16ColChar = (FLMUINT16)((ucCharSet << 8) + ucChar); - if( ui16ColChar <= MAX_COL_OPCODE) - { - break; - } - - uiColStrPos += 2; - uiLength -= 2; - if( ucCharSet == 0) // Normal Latin/Greek/Cyrillic value - { - ui16ColChar = colToWPChr[ ucChar - COLLS]; - } - else if( ucCharSet == 1) // Katakana or Hiragana character - { - if( ucChar > sizeof( ColToKanaTbl)) // Special cases below - { - if( ucChar == COLS_ASIAN_MARK_VAL) // Dakuten - { - ui16ColChar = 0x240a; - } - else if( ucChar == COLS_ASIAN_MARK_VAL + 1) // Handakuten - { - ui16ColChar = 0x240b; - } - else if( ucChar == COLS_ASIAN_MARK_VAL + 2) // Chuuten - { - ui16ColChar = 0x2405; - } - else - { - ui16ColChar = 0xFFFF; // Error - } - } - else - { - ui16ColChar = (FLMUINT16)(0x2600 + ColToKanaTbl[ ucChar]); - } - } - else if( ucCharSet != 0xFF || ucChar != 0xFF) // Asian characters - { - // Insert zeroes that will be treated as a signal for - // uncoverted unicode characters later on. NOTE: Cannot - // use 0xFFFF, because we need to be able to detect this - // case in the sub-collation stuff, and we don't want - // to confuse it with the 0xFFFF that may have been inserted - // in another case. - // THIS IS A REALLY BAD HACK, BUT IT IS THE BEST WE CAN DO - // FOR NOW! - - if( pucWPStrPtr + 2 >= pucWPEnd) - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto Exit; - } - - *pucWPStrPtr++ = 0; - *pucWPStrPtr++ = 0; - uiUnconvChars++; - bHadExtended = TRUE; - } - // else, there is no collation value - found in sub-collation part - - if( pucWPStrPtr + 2 >= pucWPEnd) - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto Exit; - } - - UW2FBA( ui16ColChar, pucWPStrPtr); // Put the uncollation value back - pucWPStrPtr += 2; - } - - if( pucWPStrPtr + 2 >= pucWPEnd) - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto Exit; - } - - UW2FBA( 0, pucWPStrPtr); // Terminate the string - uiWPStrLen = (FLMUINT)(pucWPStrPtr - pucWPStr); - - // Parse through the sub-collation and case information. - // Here are values for some of the codes: - // [ 0x05] - case bits follow - // [ 0x06] - case information is all uppercase - // [ 0x07] - beginning of sub-collation information - // [ 0x08] - first substring field that is made - // [ 0x09] - truncation marker for text and binary - // - // Asian chars the case information should always be there and not - // compressed out. This is because the case information could change - // the actual width of the character from 0x26xx to charset 11. - - // Does truncation marker or sub-collation follow? - - if( uiLength) - { - ui16ColChar = (FLMUINT16)((pucColStr[ uiColStrPos] << 8) + - pucColStr[ uiColStrPos + 1]); - - // First substring is before truncated. - if( ui16ColChar == COLL_FIRST_SUBSTRING) - { - if( pbFirstSubstring) - { - *pbFirstSubstring = TRUE; // Don't need to initialize to FALSE. - } - - uiLength -= 2; - uiColStrPos += 2; - ui16ColChar = (FLMUINT16)((pucColStr[ uiColStrPos] << 8) + - pucColStr[ uiColStrPos + 1]); - } - - if( ui16ColChar == COLL_TRUNCATED) - { - if( pbDataTruncated) - { - *pbDataTruncated = TRUE; // Don't need to initialize to FALSE. - } - uiLength -= 2; - uiColStrPos += 2; - ui16ColChar = (FLMUINT16)((pucColStr[ uiColStrPos] << 8) + - pucColStr[ uiColStrPos+1]); - } - - if( ui16ColChar == (COLL_MARKER | SC_SUB_COL)) - { - FLMUINT uiTempLen; - - // Do another pass on the word string adding diacritics/voicings - - uiColStrPos += 2; - uiLength -= 2; - if( RC_BAD( rc = flmAsiaParseSubCol( pucWPStr, &uiWPStrLen, - uiMaxWPBytes, &pucColStr[ uiColStrPos], &uiTempLen))) - { - goto Exit; - } - - uiColStrPos += uiTempLen; - uiLength -= uiTempLen; - } - else - { - goto check_case; - } - } - - // Does the case info follow? - - if( uiLength) - { - ui16ColChar = (FLMUINT16)((pucColStr[ uiColStrPos] << 8) + - pucColStr[ uiColStrPos + 1]); -check_case: - - if( ui16ColChar == (COLL_MARKER | SC_MIXED)) - { - uiColStrPos += 2; - - if( RC_BAD( rc = flmAsiaParseCase( pucWPStr, &uiWPStrLen, - uiMaxWPBytes, &pucColStr[ uiColStrPos], &uiColBytesProcessed))) - { - goto Exit; - } - - uiColStrPos += uiColBytesProcessed; - - // Set bHadExtended to FALSE, because they will have - // been taken care of in this pass. - - bHadExtended = FALSE; - } - } - - // Change embedded zeroes to 0xFFFFs - - if (bHadExtended) - { - FLMUINT uiCnt; - FLMBYTE * pucTmp; - - for( uiCnt = 0, pucTmp = pucWPStr; - uiCnt < uiWPStrLen; - uiCnt += 2, pucTmp += 2) - { - if( FB2UW( pucTmp) == 0) - { - UW2FBA( 0xFFFF, pucTmp); - } - } - } - - if (uiColStrLen != uiColStrPos) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_DATA_ERROR); - goto Exit; - } - - *puiUnconvChars = uiUnconvChars; - *puiWPStrLen = uiWPStrLen; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Combine the diacritic 5 and 16 bit values to an existing word string. -Ret: FLMUINT - Number of bytes parsed -Notes: For each bit in the sub-collation section: - 0 - no subcollation information - 10 - take next 5 bits - will tell about diacritics or japanese vowel - 110 - align to next byte & take word value as extended character - -****************************************************************************/ -FSTATIC RCODE flmAsiaParseSubCol( - FLMBYTE * pucWPStr, - FLMUINT * puiWPStrLen, - FLMUINT uiMaxWPBytes, - const FLMBYTE * pucSubColBuf, - FLMUINT * puiSubColBitPos) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiSubColBitPos = 0; - FLMUINT uiNumChars = *puiWPStrLen >> 1; - FLMUINT16 ui16Diac; - FLMUINT16 ui16WpChar; - - // For each character (16 bits) in the WP string ... - - while( uiNumChars--) - { - // Have to skip 0, because it is not accounted for - // in the sub-collation bits. It was inserted when we - // encountered unconverted unicode characters (Asian). - // Will be converted to something else later on. - // SEE NOTE ABOVE. - - if( FB2UW( pucWPStr) == 0) - { - pucWPStr += 2; - continue; - } - - // This macro DOESN'T increment uiBitPos - - if( testOneBit( pucSubColBuf, uiSubColBitPos)) - { - // Bits 10 - take next 5 bits - // Bits 110 align and take next word - // Bits 11110 align and take unicode value - - uiSubColBitPos++; - if( !testOneBit( pucSubColBuf, uiSubColBitPos)) - { - uiSubColBitPos++; - ui16Diac = (FLMUINT16)(getNBits( 5, pucSubColBuf, uiSubColBitPos)); - uiSubColBitPos += 5; - - if( (ui16WpChar = FB2UW( pucWPStr)) < 0x100) - { - if( (ui16WpChar >= 'A') && (ui16WpChar <= 'Z')) - { - // Convert to WP diacritic and combine characters - - flmWPCmbcar( &ui16WpChar, ui16WpChar, - (FLMUINT16)ml1_COLtoD[ ui16Diac]); - - // Even if cmbcar fails, WpChar is still set to a valid value - } - else - { - // Symbols from charset 0x24 - - ui16WpChar = (FLMUINT16)(0x2400 + - fwp_Ch24ColTbl[ ui16Diac - 1 ].ByteValue); - } - } - else if( ui16WpChar >= 0x2600) // Katakana - { - // Voicings - will allow to select original char - // 000 - some 001 are changed to 000 to save space - // 001 - set if large char (uppercase) - // 010 - set if voiced - // 100 - set if half voiced - // - // Should NOT match voicing or wouldn't be here! - - FLMBYTE ucChar = (FLMBYTE)(ui16WpChar & 0xFF); - - // Try exceptions first so don't access out of bounds - - if( ucChar == 84) - { - ui16WpChar = (FLMUINT16)(0x2600 + - ((ui16Diac == 1) - ? (FLMUINT16)10 - : (FLMUINT16)11)); - } - else if( ucChar == 85) - { - ui16WpChar = (FLMUINT16)(0x2600 + - ((ui16Diac == 1) - ? (FLMUINT16)16 - : (FLMUINT16)17)); - } - - // Try the next 2 slots, if not then - // value is 83, 84 or 85 - - else if( KanaSubColTbl[ ucChar + 1 ] == ui16Diac) - { - ui16WpChar++; - } - else if( KanaSubColTbl[ ucChar + 2 ] == ui16Diac) - { - ui16WpChar += 2; - } - else if( ucChar == 4) // Last exception - { - ui16WpChar = 0x2600 + 83; - } - - // else, leave alone! - invalid storage - } - - UW2FBA( ui16WpChar, pucWPStr); // Set if changed or not - } - else // "110" - { - FLMUINT uiTemp; - - uiSubColBitPos++; // Skip second '1' - if( testOneBit( pucSubColBuf, uiSubColBitPos)) // 11?10 ? - { - if( (*puiWPStrLen) + 2 > uiMaxWPBytes) - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto Exit; - } - - // Unconvertable UNICODE character - // The format will be 4 bytes, 0xFF, 0xFF, 2 byte Unicode - - shiftN( pucWPStr, - (FLMUINT16)(uiNumChars + uiNumChars + 4), 2); - - pucWPStr += 2; // Skip the 0xFFFF for now - uiSubColBitPos += 2; // Skip next "11" - (*puiWPStrLen) += 2; - } - uiSubColBitPos++; // Skip the zero - - // Round up to next byte - uiSubColBitPos = (uiSubColBitPos + 7) & (~7); - uiTemp = bytesInBits( uiSubColBitPos); - pucWPStr[ 1] = pucSubColBuf[ uiTemp]; // Character set - pucWPStr[ 0] = pucSubColBuf[ uiTemp + 1]; // Character - uiSubColBitPos += 16; - } - } - else - { - uiSubColBitPos++; // Be sure to increment this! - } - - pucWPStr += 2; // Next WP character - } - - *puiSubColBitPos = bytesInBits( uiSubColBitPos); - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: The case bits for asia are: - Latin/Greek/Cyrillic - 01 - case bit set if character is uppercase - 10 - double wide character in CS 0x25xx, 0x26xx and 0x27xx - Japanese - 00 - double wide hiragana 0x255e..25b0 - 01 - double wide katakana 0x2600..2655 - 10 - single wide symbols from charset 11 that map to CS24?? - 11 - single wide katakana from charset 11 -Ret: -Notes: This is tricky to really understand the inputs. - This looks at the bits according to the current character value. -****************************************************************************/ -FSTATIC RCODE flmAsiaParseCase( - FLMBYTE * pucWPStr, - FLMUINT * puiWPStrLen, - FLMUINT uiMaxWPBytes, - const FLMBYTE * pucCaseBits, - FLMUINT * puiColBytesProcessed) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiWPStrLen = *puiWPStrLen; - FLMUINT uiCharCnt; - FLMUINT uiExtraBytes = 0; - FLMUINT16 ui16WpChar; - FLMBYTE ucTempByte = 0; - FLMBYTE ucMaskByte; - - // For each character (two bytes) in the string ... - - for( uiCharCnt = uiWPStrLen >> 1, // Total number of words in word string - ucMaskByte = 0; // Force first time to get a byte - uiCharCnt--;) - { - FLMBYTE ucChar; - FLMBYTE ucCharSet; - - ui16WpChar = FB2UW( pucWPStr); // Get the next character - - // Must skip any 0xFFFFs or zeroes that were inserted. - - if( ui16WpChar == 0xFFFF || ui16WpChar == 0) - { - // Put back 0xFFFF in case it was a zero. - - UW2FBA( 0xFFFF, pucWPStr); - pucWPStr += 2; - uiExtraBytes += 2; - continue; - } - - // Time to get another byte? - - if( ucMaskByte == 0) - { - ucTempByte = *pucCaseBits++; - ucMaskByte = 0x80; - } - - ucCharSet = (FLMBYTE)(ui16WpChar >> 8); - ucChar = (FLMBYTE)(ui16WpChar & 0xFF); - - // SINGLE WIDE - NORMAL CHARACTERS - - if( ui16WpChar < 0x2400) - { - // Convert to double wide? - - if( ucTempByte & ucMaskByte) - { - // Latin/greek/cyrillic - // Convert to uppercase double wide char - - if( ucCharSet == 0) // Latin - uppercase - { - // May convert to 0x250F (Latin) or CS24 - - if( ui16WpChar >= ASCII_UPPER_A && ui16WpChar <= ASCII_UPPER_Z) - { - // Convert to double wide - - ui16WpChar = (FLMUINT16)(ui16WpChar - 0x30 + 0x250F); - } - else - { - flmWPHanToZenkaku( ui16WpChar, 0, &ui16WpChar); - } - } - else if( ucCharSet == 8) // Greek - { - if( ucChar > 38) // Adjust for spaces in Greek - { - ucChar -= 2; - } - - if( ucChar > 4) - { - ucChar -= 2; - } - - ui16WpChar = (FLMUINT16)((ucChar >> 1) + 0x265E); - } - else if( ucCharSet == 10) // Cyrillic - { - ui16WpChar = (FLMUINT16)((ucChar >> 1) + 0x2700); - } - else - { - flmWPHanToZenkaku( ui16WpChar, 0, &ui16WpChar); - } - - ucCharSet = (FLMBYTE)(ui16WpChar >> 8); - ucChar = (FLMBYTE)(ui16WpChar & 0xFF); - } - - ucMaskByte >>= 1; // Next bit - - // Change to lower case? - - if( (ucTempByte & ucMaskByte) == 0) - { - // Convert ui16WpChar to lower case - - switch( ucCharSet) - { - case 0: - // Bit zero only if lower case - - ui16WpChar |= 0x20; - break; - - case 1: - // In upper/lower case region? - - if( ucChar >= 26) - { - ui16WpChar++; - } - break; - - case 8: - // All lowercase after 69 - - if( ucChar <= 69) - { - ui16WpChar++; - } - break; - - case 10: - // No cases after 199 - - if( ucChar <= 199) - { - ui16WpChar++; - } - break; - - case 0x25: - case 0x26: - // Should be double wide latin or Greek - // Add offset to convert to lowercase - - ui16WpChar += 0x20; - break; - - case 0x27: - // Double wide cyrillic only - // Add offset to convert to lowercase - - ui16WpChar += 0x30; - break; - } - } - } - else // JAPANESE CHARACTERS - { - if( ucTempByte & ucMaskByte) // Original chars from CharSet 11 - { - if( ucCharSet == 0x26) // Convert to Zen to Hankaku - { - FLMUINT16 ui16NextChar = 0; - - ui16WpChar = flmWPZenToHankaku( ui16WpChar, &ui16NextChar); - if( ui16NextChar) // Move everyone down - { - if( (*puiWPStrLen) + 2 > uiMaxWPBytes) - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto Exit; - } - - uiCharCnt++; - shiftN( pucWPStr, uiCharCnt + uiCharCnt + 2, 2); - UW2FBA( ui16WpChar, pucWPStr); - pucWPStr += 2; - ui16WpChar = ui16NextChar; // This will be stored below - - // Adjust the length - *puiWPStrLen = *puiWPStrLen + 2; - } - } - else if( ucCharSet == 0x24) - { - ui16WpChar = flmWPZenToHankaku( ui16WpChar, NULL); - } - ucMaskByte >>= 1; // Eat the next bit - } - else - { - ucMaskByte >>= 1; // Next bit - if( (ucTempByte & ucMaskByte) == 0) // Convert to Hiragana? - { - // Kanji will also fall through here - - if( ucCharSet == 0x26) - { - // Convert to Hiragana - ui16WpChar = (FLMUINT16)(0x255E + ucChar); - } - } - } - } - UW2FBA( ui16WpChar, pucWPStr); - pucWPStr += 2; - ucMaskByte >>= 1; - } - - uiCharCnt = uiWPStrLen - uiExtraBytes; // Should be 2 bits for each character. - *puiColBytesProcessed = bytesInBits( uiCharCnt); - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Convert a zenkaku (double wide) char to a hankaku (single wide) char -Ret: Hankaku char or 0 if a conversion doesn't exist -Notes: Taken from CHAR.ASM - zen2han_f routine -****************************************************************************/ -FSTATIC FLMUINT16 flmWPZenToHankaku( - FLMUINT16 ui16WpChar, - FLMUINT16 * pui16DakutenOrHandakuten) -{ - FLMUINT16 ui16Hankaku = 0; - FLMBYTE ucCharSet = ui16WpChar >> 8; - FLMBYTE ucCharVal = ui16WpChar & 0xFF; - FLMUINT uiLoop; - - switch( ucCharSet) - { - // SYMBOLS - - case 0x24: - { - for( uiLoop = 0; - uiLoop < (sizeof( Zen24ToHankaku) / sizeof( BYTE_WORD_TBL)); - uiLoop++) - { - // List is sorted so table entry is more you are done - - if( Zen24ToHankaku [uiLoop].ByteValue >= ucCharVal) - { - if( Zen24ToHankaku [uiLoop].ByteValue == ucCharVal) - { - ui16Hankaku = Zen24ToHankaku [uiLoop].WordValue; - } - break; - } - } - break; - } - - // ROMAN - 0x250F..2559 - // Hiragana - 0x255E..2580 - - case 0x25: - { - if( ucCharVal >= 0x0F && ucCharVal < 0x5E) - { - ui16Hankaku = ucCharVal + 0x21; - } - break; - } - - // Katakana - 0x2600..2655 - // Greek - 0x265B..2695 - - case 0x26: - { - if( ucCharVal <= 0x55) // Katakana range - { - FLMBYTE ucCS11CharVal; - FLMUINT16 ui16NextWpChar = 0; - - if( (ucCS11CharVal = MapCS26ToCharSet11[ ucCharVal ]) != 0xFF) - { - if( ucCS11CharVal & 0x80) - { - if( ucCS11CharVal & 0x40) - { - // Handakuten voicing - - ui16NextWpChar = 0xB3E; - } - else - { - // Dakuten voicing - - ui16NextWpChar = 0xB3D; - } - ucCS11CharVal &= 0x3F; - } - ui16Hankaku = 0x0b00 + ucCS11CharVal; - if( ui16NextWpChar && pui16DakutenOrHandakuten) - { - *pui16DakutenOrHandakuten = ui16NextWpChar; - } - } - } - else if( ucCharVal <= 0x95) // Greek - { - FLMBYTE ucGreekChar = ucCharVal; - - // Make a zero based number. - - ucGreekChar -= 0x5E; - - // Check for lowercase - if( ucGreekChar >= 0x20) - { - // Convert to upper case for now - - ucGreekChar -= 0x20; - } - - if( ucGreekChar >= 2) - { - ucGreekChar++; - } - - if (ucGreekChar >= 19) - { - ucGreekChar++; - } - - // Convert to character set 8 - - ui16Hankaku = (ucGreekChar << 1) + 0x800; - if( ucCharVal >= (0x5E + 0x20)) - { - // Adjust to lower case character - - ui16Hankaku++; - } - } - break; - } - - // Cyrillic - - case 0x27: - { - // Uppercase? - - if( ucCharVal <= 0x20) - { - ui16Hankaku = (ucCharVal << 1) + 0xa00; - } - else if( ucCharVal >= 0x30 && ucCharVal <= 0x50) - { - // Lower case - - ui16Hankaku = ((ucCharVal - 0x30) << 1) + 0xa01; - } - break; - } - } - - return( ui16Hankaku); -} - -/**************************************************************************** -Desc: Convert a WPChar from hankaku (single wide) to zenkaku (double wide). - 1) Used to see if a char in CS11 can map to a double wide character - 2) Used to convert keys into original data. -Ret: 0 = no conversion - 1 = converted character to zenkaku - 2 = ui16NextWpChar dakuten or handakuten voicing got combined -Notes: Taken from char.asm - han2zen() - From8ToZen could be taken out and placed in code. -****************************************************************************/ -FSTATIC FLMUINT16 flmWPHanToZenkaku( - FLMUINT16 ui16WpChar, - FLMUINT16 ui16NextWpChar, - FLMUINT16 * pui16Zenkaku) -{ - FLMUINT16 ui16Zenkaku = 0; - FLMBYTE ucCharSet = ui16WpChar >> 8; - FLMBYTE ucCharVal = ui16WpChar & 0xFF; - FLMUINT uiLoop; - FLMUINT16 ui16CharsUsed = 1; - - switch( ucCharSet) - { - // Character set 0 - symbols - - case 0: - { - // Invalid? - all others are used. - - if( ucCharVal < 0x20) - { - ; - } - else if( ucCharVal <= 0x2F) - { - // Symbols A - ui16Zenkaku = 0x2400 + From0AToZen[ ucCharVal - 0x20 ]; - } - else if( ucCharVal <= 0x39) - { - // 0..9 - ui16Zenkaku = 0x2500 + (ucCharVal - 0x21); - } - else if( ucCharVal <= 0x40) - { - // Symbols B - ui16Zenkaku = 0x2400 + From0BToZen[ ucCharVal - 0x3A ]; - } - else if( ucCharVal <= 0x5A) - { - // A..Z - ui16Zenkaku = 0x2500 + (ucCharVal - 0x21); - } - else if( ucCharVal <= 0x60) - { - // Symbols C - ui16Zenkaku = 0x2400 + From0CToZen[ ucCharVal - 0x5B ]; - } - else if( ucCharVal <= 0x7A) - { - // a..z - ui16Zenkaku = 0x2500 + (ucCharVal - 0x21); - } - else if( ucCharVal <= 0x7E) - { - // Symbols D - ui16Zenkaku = 0x2400 + From0DToZen[ ucCharVal - 0x7B ]; - } - break; - } - - // GREEK - - case 8: - { - if( (ucCharVal >= sizeof( From8ToZen)) || - ((ui16Zenkaku = 0x2600 + From8ToZen[ ucCharVal ]) == 0x26FF)) - { - ui16Zenkaku = 0; - } - break; - } - - // CYRILLIC - - case 10: - { - // Check range - - ui16Zenkaku = 0x2700 + (ucCharVal >> 1); // Uppercase value - - // Convert to lower case? - - if( ucCharVal & 0x01) - { - ui16Zenkaku += 0x30; - } - break; - } - - // JAPANESE - - case 11: - { - if( ucCharVal < 5) - { - ui16Zenkaku = 0x2400 + From11AToZen[ ucCharVal ]; - } - else if( ucCharVal < 0x3D) // katakana? - { - if( (ui16Zenkaku = 0x2600 + - From11BToZen[ ucCharVal - 5 ]) == 0x26FF) - { - // Dash - convert to this - ui16Zenkaku = 0x241b; - } - else - { - if( ui16NextWpChar == 0xB3D) // dakuten? - voicing - { - // First check exception(s) then - // check if voicing exists! - will NOT access out of table - - if( (ui16Zenkaku != 0x2652) && // is not 'N'? - (KanaSubColTbl[ ui16Zenkaku - 0x2600 + 1 ] == 3)) - { - ui16Zenkaku++; - - // Return 2 - - ui16CharsUsed++; - } - } - else if( ui16NextWpChar == 0xB3E) // handakuten? - voicing - { - // Check if voicing exists! - will NOT access out of table - - if( KanaSubColTbl [ui16Zenkaku - 0x2600 + 2 ] == 5) - { - ui16Zenkaku += 2; - - // Return 2 - - ui16CharsUsed++; - } - } - } - } - else if( ucCharVal == 0x3D) // dakuten? - { - // Convert to voicing symbol - - ui16Zenkaku = 0x240A; - } - else if( ucCharVal == 0x3E) // handakuten? - { - // Convert to voicing symbol - - ui16Zenkaku = 0x240B; - } - // else cannot convert - - break; - } - - // Other character sets - // CS 1,4,5,6 - symbols - - default: - { - // Instead of includes more tables from char.asm - look down the - // Zen24Tohankaku[] table for a matching value - not much slower. - - for( uiLoop = 0; - uiLoop < (sizeof(Zen24ToHankaku) / sizeof(BYTE_WORD_TBL)); - uiLoop++) - { - if( Zen24ToHankaku[ uiLoop].WordValue == ui16WpChar) - { - ui16Zenkaku = 0x2400 + Zen24ToHankaku[ uiLoop].ByteValue; - break; - } - } - break; - } - } - - if( !ui16Zenkaku) - { - // Change return value - - ui16CharsUsed = 0; - } - - *pui16Zenkaku = ui16Zenkaku; - return( ui16CharsUsed); -} - -/**************************************************************************** -Desc: Converts a 2-byte language code into its corresponding language ID -****************************************************************************/ -FLMUINT F_DbSystem::languageToNum( - const char * pszLanguage) -{ - FLMBYTE ucFirstChar = (FLMBYTE)(*pszLanguage); - FLMBYTE ucSecondChar = (FLMBYTE)(*(pszLanguage + 1)); - FLMUINT uiTablePos; - - for( uiTablePos = 0; - uiTablePos < (LAST_LANG + LAST_LANG); uiTablePos += 2) - { - if( fwp_langtbl [uiTablePos] == ucFirstChar && - fwp_langtbl [uiTablePos+1] == ucSecondChar) - { - - // Return uiTablePos div 2 - - return( uiTablePos >> 1); - } - } - - // Language not found, return default US language - - return( XFLM_US_LANG); -} - -/**************************************************************************** -Desc: Converts a language ID to its corresponding 2-byte language code -****************************************************************************/ -void F_DbSystem::languageToStr( - FLMINT iLangNum, - char * pszLanguage) -{ - // iLangNum could be negative - - if( iLangNum < 0 || iLangNum >= LAST_LANG) - { - iLangNum = XFLM_US_LANG; - } - - iLangNum += iLangNum; - *pszLanguage++ = (char)fwp_langtbl [iLangNum ]; - *pszLanguage++ = (char)fwp_langtbl [iLangNum+1]; - *pszLanguage = 0; + return( f_compareUnicodeStrings( puzLString, uiLStrBytes, bLeftWild, + puzRString, uiRStrBytes, bRightWild, uiCompareRules, + uiLanguage, piResult)); } /*************************************************************************** -Desc: Return the sub-collation value of a WP character. Unconverted - unicode values always have a sub-collation value of - 11110+UnicodeChar -***************************************************************************/ -FLMUINT16 flmWPGetSubCol( - FLMUINT16 ui16WPValue, // [in] WP Character value. - FLMUINT16 ui16ColValue, // [in] Collation Value (for arabic) - FLMUINT uiLanguage) // [in] WP Language ID. +Desc: +****************************************************************************/ +RCODE FLMAPI F_DbSystem::utf8IsSubStr( + const FLMBYTE * pszString, + const FLMBYTE * pszSubString, + FLMUINT uiCompareRules, + FLMUINT uiLanguage, + FLMBOOL * pbExists) { - FLMUINT16 ui16SubColVal; - FLMBYTE ucCharVal; - FLMBYTE ucCharSet; - FLMUINT16 ui16Base; - - // Easy case first - ascii characters. - - ui16SubColVal = 0; - if (ui16WPValue <= 127) - { - goto Exit; - } - - // From here down default ui16SubColVal is WP value. - - ui16SubColVal = ui16WPValue; - ucCharVal = (FLMBYTE) ui16WPValue; - ucCharSet = (FLMBYTE) (ui16WPValue >> 8); - - // Convert char to uppercase because case information - // is stored above. This will help - // ensure that the "ETA" doesn't sort before "eta" - // could use is lower code here for added performance. - - // This just happens to work with all WP character values. - - if (!flmWPIsUpper( ui16WPValue)) - { - ui16WPValue &= ~1; - } - - switch (ucCharSet) - { - case CHSMUL1: - - // If you cannot break down a char into base and - // diacritic then you cannot combine the charaacter - // later when converting back the key. So, write - // the entire WP char in the sub-collation area. - // We can ONLY SUPPORT MULTINATIONAL 1 for brkcar() - - if (flmWPBrkcar( ui16WPValue, &ui16Base, &ui16SubColVal)) - { - - // WordPerfect character cannot be broken down. - // If we had a collation value other than 0xFF (COLS0), don't - // return a sub-collation value. This will allow things like - // upper and lower AE digraphs to compare properly. - - if (ui16ColValue != COLS0) - { - ui16SubColVal = 0; - } - goto Exit; - } - - // Write the FLAIM diacritic sub-collation value. - // Prefix is 2 bits "10". Remember to leave - // "111" alone for the future. - // Bug 11/16/92 = was only writing a "1" and not "10" - - ui16SubColVal = ( - (ui16SubColVal & 0xFF) == umlaut - && ( (uiLanguage == XFLM_SU_LANG) || - (uiLanguage == XFLM_SV_LANG) || - (uiLanguage == XFLM_CZ_LANG) || - (uiLanguage == XFLM_SL_LANG) - ) - ) - ? (FLMUINT16)(fwp_dia60Tbl[ ring] + 1) // umlaut must be after ring above - : (FLMUINT16)(fwp_dia60Tbl[ ui16SubColVal & 0xFF]); - - break; - - case CHSGREK: - - // Greek - - if( (ucCharVal >= 52) || // Keep case bit for 52-69 else ignore - (ui16WPValue == 0x804) || // [ 8,4] BETA Medial | Terminal - (ui16WPValue == 0x826)) // [ 8,38] SIGMA termainal - { - ui16SubColVal = ui16WPValue; - } - // else no subcollation to worry about - break; - - case CHSCYR: - if (ucCharVal >= 144) - { - ui16SubColVal = ui16WPValue; - } - // else no subcollation to worry about - - // VISIT: Georgian covers 208-249 - no collation defined yet - break; - - case CHSHEB: // Hebrew - - // Three sections in Hebrew: - // 0..26 - main characters - // 27..83 - accents that apear over previous character - // 84..118- dagesh (ancient) hebrew with accents - - // Because the ancient is only used for sayings & scriptures - // we will support a collation value and in the sub-collation - // store the actual character because sub-collation is in - // character order. - - if (ucCharVal >= 84) // Save ancient - value 84 and above - { - ui16SubColVal = ui16WPValue; - } - break; - - case CHSARB1: // Arabic 1 - - // Three sections in Arabic: - // 00..37 - accents that display OVER a previous character - // 38..46 - symbols - // 47..57 - numbers - // 58..163 - characters - // 164 - hamzah accent - // 165..180- common characters with accents - // 181..193- ligatures - common character combinations - // 194..195- extensions - throw away when sorting - - if (ucCharVal <= 46) - { - ui16SubColVal = ui16WPValue; - } - else - { - if (ui16ColValue == COLS10a+1) // Alef? - { - ui16SubColVal = (ucCharVal >= 165) - ? (FLMUINT16)(fwp_alefSubColTbl[ ucCharVal - 165 ]) - : (FLMUINT16)7; // Alef subcol value - } - else - { - if (ucCharVal >= 181) // Ligatures - char combination - { - ui16SubColVal = ui16WPValue; - } - else if (ucCharVal == 64) // taa exception - { - ui16SubColVal = 8; - } - } - } - break; - - case CHSARB2: // Arabic 2 - - // There are some characters that share the same slot - // Check the bit table if above character 64 - - if ((ucCharVal >= 64) && - (fwp_ar2BitTbl[(ucCharVal-64)>> 3] & (0x80 >> (ucCharVal&0x07)))) - { - ui16SubColVal = ui16WPValue; - } - break; - - } - -Exit: - - return( ui16SubColVal); + return( f_utf8IsSubStr( pszString, pszSubString, uiCompareRules, + uiLanguage, pbExists)); } diff --git a/xflaim/src/fcollate.h b/xflaim/src/fcollate.h index 8831190..8df0750 100644 --- a/xflaim/src/fcollate.h +++ b/xflaim/src/fcollate.h @@ -27,159 +27,11 @@ #ifndef FCOLLATE_H #define FCOLLATE_H -// Character set #'s are same as high byte values -// except for algorithmic set. - -#define CHSASCI 0 // ASCII -#define CHSMUL1 1 // Multinational 1 -#define CHSMUL2 2 // Multinational 2 -#define CHSBOXD 3 // Box drawing -#define CHSSYM1 4 // Typographic Symbols -#define CHSSYM2 5 // Iconic Symbols -#define CHSMATH 6 // Math -#define CHMATHX 7 // Math Extension -#define CHSGREK 8 // Greek -#define CHSHEB 9 // Hebrew -#define CHSCYR 10 // Cyrillic -#define CHSKANA 11 // Japanese Kana -#define CHSUSER 12 // User-defined -#define CHSARB1 13 // Arabic -#define CHSARB2 14 // Arabic script - -#define NCHSETS 15 // # of character sets (excluding Asian) -#define ACHSETS 0x0E0 // Maximum character set value - Asian -#define ACHSMIN 0x024 // Minimum character set value - Asian -#define ACHCMAX 0x0FE // Maxmimum character value in Asian sets - -// LAST_LANG - Used for tables than contain items for each language. -// *_DBCS_LANG - Start and end points for double byte languages. - -#define LAST_LANG (XFLM_LA_LANG + 1) // Last language marker -#define FIRST_DBCS_LANG (XFLM_JP_LANG) -#define LAST_DBCS_LANG (XFLM_LA_LANG) - -// Collating Sequence Equates -// NOTE:The collating sequence MUST start at 32 (20h). This allows for the -// handling of nulls and control characters. - -#define COLLS 32 // first collating number (space/end of line) -#define COLS1 (COLLS + 9) // quotes -#define COLS2 (COLS1 + 5) // parens -#define COLS3 (COLS2 + 6) // money -#define COLS4 (COLS3 + 6) // math ops -#define COLS5 (COLS4 + 8) // math others -#define COLS6 (COLS5 + 14) // others: %#&@\_|~ -#define COLS7 (COLS6 + 13) // greek -#define COLS8 (COLS7 + 25) // numbers -#define COLS9 (COLS8 + 10) // alphabet -// Three below will overlap each other -#define COLS10 (COLS9 + 60) // cyrillic -#define COLS10h (COLS9 + 42) // hebrew - writes over european & cyrilic -#define COLS10a (COLS10h + 28) // arabic - inclusive from 198(C6)-252(FC) - -#define COLS11 253 // End of list - arabic goes to the end - -#define COLS0_ARABIC COLS11 // Set if arabic accent marking -#define COLS0_HEBREW COLS11 // Set if hebrew accent marking - -#define COLSOEM 254 // OEM character in upper range - non-collatable - // Phase COLSOEM out - not used! -#define COLS0_UNICODE 254 // Use this for UNICODE -#define COLS0 255 // graphics/misc - chars without a collate value - -// Definitions for diacritics. - -#define grave 0 -#define centerd 1 -#define tilde 2 -#define circum 3 -#define crossb 4 -#define slash 5 -#define acute 6 -#define umlaut 7 -#define macron 8 - -#define aposab 9 -#define aposbes 10 -#define aposba 11 - -#define ring 14 -#define dota 15 -#define dacute 16 -#define cedilla 17 -#define ogonek 18 -#define caron 19 -#define stroke 20 - -#define breve 22 -#define dotlesi 239 -#define dotlesj 25 - -#define gacute 83 // greek acute -#define gdia 84 // greek diaeresis -#define gactdia 85 // acute diaeresis -#define ggrvdia 86 // grave diaeresis -#define ggrave 87 // greek grave -#define gcircm 88 // greek circumflex -#define gsmooth 89 // smooth breathing -#define grough 90 // rough breathing -#define giota 91 // iota subscript -#define gsmact 92 // smooth breathing acute -#define grgact 93 // rough breathing acute -#define gsmgrv 94 // smooth breathing grave -#define grggrv 95 // rough breathing grave -#define gsmcir 96 // smooth breathing circumflex -#define grgcir 97 // rough breathing circumflex -#define gactio 98 // acute iota -#define ggrvio 99 // grave iota -#define gcirio 100 // circumflex iota -#define gsmio 101 // smooth iota -#define grgio 102 // rough iota -#define gsmaio 103 // smooth acute iota -#define grgaio 104 // rough acute iota -#define gsmgvio 105 // smooth grave iota -#define grggvio 106 // rough grave iota -#define gsmcio 107 // smooth circumflex iota -#define grgcio 108 // rough circumflex iota -#define ghprime 81 // high prime -#define glprime 82 // low prime - -#define racute 200 // russian acute -#define rgrave 201 // russian grave -#define rrtdesc 204 // russian right descender -#define rogonek 205 // russian ogonek -#define rmacron 206 // russian macron - -// GWBUG 30,645 - Had 200 and 70 - the 200 for max subcol was not -// enough for the sset and JP characters - computed wrong. -// This crashed the process that was building a key of sset characaters. - -#define MAX_SUBCOL_BUF (500) // (((XFLM_MAX_KEY_SIZE / 4) * 3 + fluff -#define MAX_CASE_BYTES (150) // ((XFLM_MAX_KEY_SIZE -(XFLM_MAX_KEY_SIZE / 8)) / 8) * 2 - -// Flags - -#define HAD_SUB_COLLATION 0x01 // Set if had sub-collating values-diacritics -#define HAD_LOWER_CASE 0x02 // Set if you hit a lowercase character - - -#define COLL_FIRST_SUBSTRING 0x03 // First substring marker - -#define COLL_MARKER 0x04 // Marks place of sub-collation - -#define SC_LOWER 0x00 // Only lowercase characters exist -#define SC_MIXED 0x01 // Lower/uppercase flags follow in next byte -#define SC_UPPER 0x02 // Only upper characters exist -#define SC_SUB_COL 0x03 // Sub-collation follows (diacritics|extCh) - -#define COLL_TRUNCATED 0x0C // This key piece has been truncated from original - -#define UNK_UNICODE_CODE 0xFFFE // Used for collation - #define TRUNCATED_FLAG 0x8000 #define EXCLUSIVE_LT_FLAG 0x4000 #define EXCLUSIVE_GT_FLAG 0x2000 #define SEARCH_KEY_FLAG 0x1000 + #define KEY_COMPONENT_LENGTH_MASK 0x0FFF #define KEY_LOW_VALUE 0x0FFE #define KEY_HIGH_VALUE 0x0FFF @@ -214,9 +66,16 @@ FINLINE FLMUINT getKeyComponentLength( return( (FLMUINT)(FB2UW( pucKeyComponent)) & KEY_COMPONENT_LENGTH_MASK); } -// Prototypes - -RCODE flmUTF8ToColText( // Source: fcollate.cpp +RCODE flmColText2StorageText( + const FLMBYTE * pucColStr, + FLMUINT uiColStrLen, + FLMBYTE * pucStorageBuf, + FLMUINT * puiStorageLen, + FLMUINT uiLang, + FLMBOOL * pbDataTruncated, + FLMBOOL * pbFirstSubstring); + +RCODE flmUTF8ToColText( IF_PosIStream * pIStream, FLMBYTE * pucCollatedStr, FLMUINT * puiCollatedStrLen, @@ -230,404 +89,4 @@ RCODE flmUTF8ToColText( // Source: fcollate.cpp FLMBOOL * pbOriginalCharsLost, FLMBOOL * pbDataTruncated); -RCODE flmColText2StorageText( // Source: fcollate.cpp - const FLMBYTE * pucColStr, - FLMUINT uiColStrLen, - FLMBYTE * pucStorageBuf, - FLMUINT * puiStorageLen, - FLMUINT uiLang, - FLMBOOL * pbDataTruncated, - FLMBOOL * pbFirstSubstring); - -RCODE flmAsiaUTF8ToColText( // Source: fcollate.cpp - IF_PosIStream * pIStream, - FLMBYTE * pucColStr, - FLMUINT * puiColStrLen, - FLMBOOL bCaseInsensitive, - FLMUINT * puiCollationLen, - FLMUINT * puiCaseLen, - FLMUINT uiCharLimit, - FLMBOOL bFirstSubstring, - FLMBOOL bDataTruncated, - FLMBOOL * pbDataTruncated); - -RCODE flmWPCheckDoubleCollation( // Source: fcollate.cpp - IF_PosIStream * pIStream, - FLMBOOL bUnicodeStream, - FLMBOOL bAllowTwoIntoOne, - FLMUNICODE * puzChar, - FLMUNICODE * puzChar2, - FLMBOOL * pbTwoIntoOne, - FLMUINT uiLanguage); - -FLMUINT16 flmWPAsiaGetCollation( // Source: fcollate.cpp - FLMUINT16 ui16WpChar, - FLMUINT16 ui16NextWpChar, - FLMUINT16 ui16PrevColValue, - FLMUINT16 * pui16ColValue, - FLMUINT16 * pui16SubColVal, - FLMBYTE * pucCaseBits, - FLMBOOL bUppercaseFlag); - -FLMUINT16 flmWPGetCollation( // Source: fcollate.cpp - FLMUINT16 ui16WpChar, - FLMUINT uiLanguage); - -FLMUINT16 flmWPUpper( // Source: fcollate.cpp - FLMUINT16 ui16WpChar); - -FLMUINT16 flmWPLower( // Source: fcollate.cpp - FLMUINT16 ui16WpChar); - -FLMBOOL flmWPIsUpper( // Source: fcollate.cpp - FLMUINT16 ui16WpChar); - -FLMBOOL flmWPBrkcar( // Source: fcollate.cpp - FLMUINT16 ui16WpChar, - FLMUINT16 * pui16BaseChar, - FLMUINT16 * pui16DiacriticChar); - -FLMUINT16 flmWPGetSubCol( // Source: fcollate.cpp - FLMUINT16 ui16WPValue, - FLMUINT16 ui16ColValue, - FLMUINT uiLanguage); - -RCODE flmInitCharMappingTables( void); // Source: funicode.cpp - -#ifdef DEF_FLM_UNI_GLOBALS - #define UNIG_EXTERN -#else - #define UNIG_EXTERN extern -#endif - -UNIG_EXTERN FLMUINT16 * gv_pUnicodeToWP60 -#ifdef DEF_FLM_UNI_GLOBALS - = NULL -#endif - ; - -UNIG_EXTERN FLMUINT16 * gv_pWP60ToUnicode -#ifdef DEF_FLM_UNI_GLOBALS - = NULL -#endif - ; - -UNIG_EXTERN FLMUINT gv_uiMinUniChar -#ifdef DEF_FLM_UNI_GLOBALS - = 0 -#endif - ; - -UNIG_EXTERN FLMUINT gv_uiMaxUniChar -#ifdef DEF_FLM_UNI_GLOBALS - = 0 -#endif - ; - -UNIG_EXTERN FLMUINT gv_uiMinWPChar -#ifdef DEF_FLM_UNI_GLOBALS - = 0 -#endif - ; - -UNIG_EXTERN FLMUINT gv_uiMaxWPChar -#ifdef DEF_FLM_UNI_GLOBALS - = 0 -#endif - ; -/**************************************************************************** -Desc: Convert a Unicode character to its WP equivalent -Ret: Returns TRUE if the character could be converted -****************************************************************************/ -FINLINE FLMBOOL flmUnicodeToWP( - FLMUNICODE uUniChar, // Unicode character to convert - FLMUINT16 * pui16WPChar) // Returns 0 or WPChar converted. -{ - if( uUniChar <= 127) - { - // Character is in the ASCII conversion range - - *pui16WPChar = uUniChar; - return( TRUE); - } - - if( uUniChar < gv_uiMinUniChar || uUniChar > gv_uiMaxUniChar) - { - *pui16WPChar = 0; - return( FALSE); - } - - if( (*pui16WPChar = gv_pUnicodeToWP60[ uUniChar - gv_uiMinUniChar]) != 0) - { - return( TRUE); - } - - return( FALSE); -} - -/**************************************************************************** -Desc: Convert a WP character to its Unicode equivalent -****************************************************************************/ -FINLINE RCODE flmWPToUnicode( - FLMUINT16 ui16WPChar, - FLMUNICODE * puUniChar) -{ - if( ui16WPChar <= 127) - { - // Character is in the ASCII conversion range - - *puUniChar = (FLMUNICODE)ui16WPChar; - return( NE_XFLM_OK); - } - - if( ui16WPChar < gv_uiMinWPChar || ui16WPChar > gv_uiMaxWPChar) - { - return( RC_SET_AND_ASSERT( NE_XFLM_CONV_ILLEGAL)); - } - - *puUniChar = gv_pWP60ToUnicode[ ui16WPChar - gv_uiMinWPChar]; - return( NE_XFLM_OK); -} - -/**************************************************************************** -Desc: Reads the next character from the storage buffer -****************************************************************************/ -FINLINE RCODE flmGetCharFromUTF8Buf( - const FLMBYTE ** ppucBuf, - const FLMBYTE * pucEnd, - FLMUNICODE * puChar) -{ - const FLMBYTE * pucBuf = *ppucBuf; - FLMUINT uiMaxLen = pucEnd ? (FLMUINT)(pucEnd - *ppucBuf) : 3; - - if( !uiMaxLen) - { - *puChar = 0; - return( NE_XFLM_OK); - } - - if( pucBuf[ 0] <= 0x7F) - { - if( (*puChar = (FLMUNICODE)pucBuf[ 0]) != 0) - { - (*ppucBuf)++; - } - return( NE_XFLM_OK); - } - - if( uiMaxLen < 2 || (pucBuf[ 1] >> 6) != 0x02) - { - return( RC_SET( NE_XFLM_BAD_UTF8)); - } - - if( (pucBuf[ 0] >> 5) == 0x06) - { - *puChar = - (FLMUNICODE)(((FLMUNICODE)( pucBuf[ 0] - 0xC0) << 6) + - (FLMUNICODE)(pucBuf[ 1] - 0x80)); - (*ppucBuf) += 2; - return( NE_XFLM_OK); - } - - if( uiMaxLen < 3 || - (pucBuf[ 0] >> 4) != 0x0E || - (pucBuf[ 2] >> 6) != 0x02) - { - return( RC_SET( NE_XFLM_BAD_UTF8)); - } - - *puChar = - (FLMUNICODE)(((FLMUNICODE)(pucBuf[ 0] - 0xE0) << 12) + - ((FLMUNICODE)(pucBuf[ 1] - 0x80) << 6) + - (FLMUNICODE)(pucBuf[ 2] - 0x80)); - (*ppucBuf) += 3; - - return( NE_XFLM_OK); -} - -/**************************************************************************** -Desc: Convert a Unicode character to UTF-8 -*****************************************************************************/ -FINLINE RCODE flmUni2UTF8( - FLMUNICODE uChar, - FLMBYTE * pucBuf, - FLMUINT * puiBufSize) -{ - if( uChar <= 0x007F) - { - if( pucBuf) - { - if( *puiBufSize < 1) - { - return( RC_SET( NE_XFLM_CONV_DEST_OVERFLOW)); - } - - *pucBuf = (FLMBYTE)uChar; - } - *puiBufSize = 1; - } - else if( uChar <= 0x07FF) - { - if( pucBuf) - { - if( *puiBufSize < 2) - { - return( RC_SET( NE_XFLM_CONV_DEST_OVERFLOW)); - } - - *pucBuf++ = (FLMBYTE)(0xC0 | (FLMBYTE)(uChar >> 6)); - *pucBuf = (FLMBYTE)(0x80 | (FLMBYTE)(uChar & 0x003F)); - } - *puiBufSize = 2; - } - else - { - if( pucBuf) - { - if( *puiBufSize < 3) - { - return( RC_SET( NE_XFLM_CONV_DEST_OVERFLOW)); - } - - *pucBuf++ = (FLMBYTE)(0xE0 | (FLMBYTE)(uChar >> 12)); - *pucBuf++ = (FLMBYTE)(0x80 | (FLMBYTE)((uChar & 0x0FC0) >> 6)); - *pucBuf = (FLMBYTE)(0x80 | (FLMBYTE)(uChar & 0x003F)); - } - *puiBufSize = 3; - } - - return( NE_XFLM_OK); -} - -/**************************************************************************** -Desc: Reads the next UTF-8 character from a UTF-8 buffer -Notes: This routine assumes that the destination buffer can hold at least - three bytes -****************************************************************************/ -FINLINE RCODE flmGetUTF8CharFromUTF8Buf( - FLMBYTE ** ppucBuf, - FLMBYTE * pucEnd, - FLMBYTE * pucDestBuf, - FLMUINT * puiLen) -{ - FLMBYTE * pucBuf = *ppucBuf; - FLMUINT uiMaxLen = pucEnd ? (FLMUINT)(pucEnd - *ppucBuf) : 3; - - if( !uiMaxLen || !pucBuf[ 0]) - { - *puiLen = 0; - return( NE_XFLM_OK); - } - - if( pucBuf[ 0] <= 0x7F) - { - *pucDestBuf = pucBuf[ 0]; - (*ppucBuf)++; - *puiLen = 1; - return( NE_XFLM_OK); - } - - if( uiMaxLen < 2 || (pucBuf[ 1] >> 6) != 0x02) - { - return( RC_SET( NE_XFLM_BAD_UTF8)); - } - - if( (pucBuf[ 0] >> 5) == 0x06) - { - pucDestBuf[ 0] = pucBuf[ 0]; - pucDestBuf[ 1] = pucBuf[ 1]; - (*ppucBuf) += 2; - *puiLen = 2; - return( NE_XFLM_OK); - } - - if( uiMaxLen < 3 || - (pucBuf[ 0] >> 4) != 0x0E || - (pucBuf[ 2] >> 6) != 0x02) - { - return( RC_SET( NE_XFLM_BAD_UTF8)); - } - - pucDestBuf[ 0] = pucBuf[ 0]; - pucDestBuf[ 1] = pucBuf[ 1]; - pucDestBuf[ 2] = pucBuf[ 2]; - (*ppucBuf) += 3; - *puiLen = 3; - - return( NE_XFLM_OK); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -FINLINE RCODE flmGetUTF8Length( - const FLMBYTE * pucBuf, - FLMUINT uiBufLen, - FLMUINT * puiBytes, - FLMUINT * puiChars) -{ - const FLMBYTE * pucStart = pucBuf; - const FLMBYTE * pucEnd = uiBufLen ? (pucStart + uiBufLen) : NULL; - FLMUINT uiChars = 0; - - if (!pucBuf) - { - goto Exit; - } - - while( (!pucEnd || pucBuf < pucEnd) && *pucBuf) - { - if( *pucBuf <= 0x7F) - { - pucBuf++; - uiChars++; - continue; - } - - if( (pucEnd && pucBuf + 1 >= pucEnd) || - (pucBuf[ 1] >> 6) != 0x02) - { - return( RC_SET( NE_XFLM_BAD_UTF8)); - } - - if( ((*pucBuf) >> 5) == 0x06) - { - pucBuf += 2; - uiChars++; - continue; - } - - if( (pucEnd && pucBuf + 2 >= pucEnd) || - (pucBuf[ 0] >> 4) != 0x0E || - (pucBuf[ 2] >> 6) != 0x02) - { - return( RC_SET( NE_XFLM_BAD_UTF8)); - } - - pucBuf += 3; - uiChars++; - } - -Exit: - - *puiChars = uiChars; - if (pucEnd && pucBuf == pucEnd) - { - *puiBytes = (FLMUINT)(pucBuf - pucStart); - } - else - { - // Hit a null byte - *puiBytes = (FLMUINT)(pucBuf - pucStart) + 1; - } - - return( NE_XFLM_OK); -} - -RCODE flmUnicode2UTF8( // Source: funicode.cpp - FLMUNICODE * puzStr, - FLMUINT uiStrLen, - FLMBYTE * pucBuf, - FLMUINT * puiBufLength); - #endif diff --git a/xflaim/src/fcomfact.cpp b/xflaim/src/fcomfact.cpp deleted file mode 100644 index 9cb3048..0000000 --- a/xflaim/src/fcomfact.cpp +++ /dev/null @@ -1,128 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: This file contains the implementation for the F_DbSystemFactory -// class. -// -// Tabs: 3 -// -// Copyright (c) 2003-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: fcomfact.cpp 3112 2006-01-19 13:12:40 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#define PCOM_INIT_GUID -#include "flaimsys.h" -#include "fcomfact.h" - -/******************************************************************** -Desc: -*********************************************************************/ -RCODE F_DbSystemFactory::QueryInterface( - RXFLMIID riid, - void ** ppvInt) -{ - RCODE rc = NE_XFLM_OK; - - if( (f_memcmp(&riid, &Internal_IID_XFLMIClassFactory, - sizeof( Internal_IID_XFLMIClassFactory)) == 0) || - (f_memcmp(&riid, &Internal_IID_XFLMIUnknown, - sizeof( Internal_IID_XFLMIUnknown)) == 0) ) - { - *ppvInt = this; - AddRef(); - } - else - { - rc = RC_SET( NE_XFLM_UNSUPPORTED_INTERFACE); - } - - return( rc); -} - -/******************************************************************** -Desc: -*********************************************************************/ -FLMINT F_DbSystemFactory::AddRef(void) -{ - LockModule(); - return( 2); -} - -/******************************************************************** -Desc: -*********************************************************************/ -FLMINT F_DbSystemFactory::Release(void) -{ - UnlockModule(); - return( 1); -} - -/******************************************************************** -Desc: -*********************************************************************/ -RCODE F_DbSystemFactory::LockServer( - bool bLock) -{ - if( bLock) - { - LockModule(); - } - else - { - UnlockModule(); - } - - return( NE_XFLM_OK); -} - -/******************************************************************** -Desc: -*********************************************************************/ -RCODE F_DbSystemFactory::CreateInstance( - XFLMIUnknown * pUnkOut, - RXFLMIID riid, - void ** ppvOut) -{ - RCODE rc = NE_XFLM_OK; - F_DbSystem * pDbSystem = NULL; - - if (pUnkOut) - { - rc = RC_SET( NE_XFLM_UNSUPPORTED_INTERFACE); - goto Exit; - } - - if( (pDbSystem = f_new F_DbSystem) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = pDbSystem->QueryInterface( riid, ppvOut))) - { - goto Exit; - } - -Exit: - - if (pDbSystem) - { - pDbSystem->Release(); - } - - return( rc); -} diff --git a/xflaim/src/fcomfact.h b/xflaim/src/fcomfact.h deleted file mode 100644 index e6bef74..0000000 --- a/xflaim/src/fcomfact.h +++ /dev/null @@ -1,53 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: This include file contains the definition for the F_DbSystemFactory -// class, which is used to create an interface to the F_DbSystem object. -// The factory is only used by COM clients. -// -// Tabs: 3 -// -// Copyright (c) 2003-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: fcomfact.h 3108 2006-01-19 13:05:19 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#ifndef FCOMFACT_H -#define FCOMFACT_H - - class F_DbSystemFactory : public XFLMIClassFactory - { - public: - - RCODE XFLMAPI QueryInterface( - RXFLMIID riid, - void ** ppvInt); - - RCODE XFLMAPI CreateInstance( - XFLMIUnknown * pUnkOut, - RXFLMIID riid, - void ** ppvOut); - - RCODE XFLMAPI LockServer( - bool bLock); - - FLMINT XFLMAPI AddRef( void); - - FLMINT XFLMAPI Release( void); - }; - -#endif // FCOMFACT_H - diff --git a/xflaim/src/fdbcnfig.cpp b/xflaim/src/fdbcnfig.cpp index c1792bb..23047a3 100644 --- a/xflaim/src/fdbcnfig.cpp +++ b/xflaim/src/fdbcnfig.cpp @@ -28,7 +28,7 @@ /**************************************************************************** Desc: Set the RFL keep files flag. ****************************************************************************/ -RCODE XFLMAPI F_Db::setRflKeepFilesFlag( +RCODE FLMAPI F_Db::setRflKeepFilesFlag( FLMBOOL bKeepFiles) { RCODE rc = NE_XFLM_OK; @@ -122,7 +122,7 @@ Exit: /**************************************************************************** Desc: Set the RFL directory for a database. ****************************************************************************/ -RCODE XFLMAPI F_Db::setRflDir( +RCODE FLMAPI F_Db::setRflDir( const char * pszNewRflDir) { RCODE rc = NE_XFLM_OK; @@ -159,9 +159,9 @@ RCODE XFLMAPI F_Db::setRflDir( if (pszNewRflDir && *pszNewRflDir) { - if (!gv_pFileSystem->IsDir( pszNewRflDir)) + if (!gv_XFlmSysData.pFileSystem->isDir( pszNewRflDir)) { - rc = RC_SET( NE_XFLM_IO_INVALID_FILENAME); + rc = RC_SET( NE_FLM_IO_INVALID_FILENAME); goto Exit; } } @@ -224,7 +224,7 @@ Exit: /**************************************************************************** Desc: Set the RFL file size limits for a database. ****************************************************************************/ -RCODE XFLMAPI F_Db::setRflFileSizeLimits( +RCODE FLMAPI F_Db::setRflFileSizeLimits( FLMUINT uiMinRflSize, FLMUINT uiMaxRflSize) { @@ -299,7 +299,7 @@ Exit: /**************************************************************************** Desc: Roll to the next RFL file for this database ****************************************************************************/ -RCODE XFLMAPI F_Db::rflRollToNextFile( void) +RCODE FLMAPI F_Db::rflRollToNextFile( void) { RCODE rc = NE_XFLM_OK; @@ -326,7 +326,7 @@ Exit: /**************************************************************************** Desc: Set keep aborted transactions in RFL flag. ****************************************************************************/ -RCODE XFLMAPI F_Db::setKeepAbortedTransInRflFlag( +RCODE FLMAPI F_Db::setKeepAbortedTransInRflFlag( FLMBOOL bKeep ) { @@ -381,7 +381,7 @@ Exit: /**************************************************************************** Desc: Set auto turn off keep RFL flag. ****************************************************************************/ -RCODE XFLMAPI F_Db::setAutoTurnOffKeepRflFlag( +RCODE FLMAPI F_Db::setAutoTurnOffKeepRflFlag( FLMBOOL bAutoTurnOff ) { @@ -458,7 +458,7 @@ void F_Database::getCPInfo( uiElapTime = FLM_ELAPSED_TIME( uiCurrTime, m_pCPInfo->uiStartTime); - FLM_TIMER_UNITS_TO_MILLI( uiElapTime, pCheckpointInfo->uiRunningTime); + pCheckpointInfo->uiRunningTime = FLM_TIMER_UNITS_TO_MILLI( uiElapTime); } else { @@ -471,8 +471,8 @@ void F_Database::getCPInfo( uiCurrTime = FLM_GET_TIMER(); uiElapTime = FLM_ELAPSED_TIME( uiCurrTime, m_pCPInfo->uiForceCheckpointStartTime); - FLM_TIMER_UNITS_TO_MILLI( uiElapTime, - pCheckpointInfo->uiForceCheckpointRunningTime); + pCheckpointInfo->uiForceCheckpointRunningTime = + FLM_TIMER_UNITS_TO_MILLI( uiElapTime); } else { @@ -496,8 +496,8 @@ void F_Database::getCPInfo( uiElapTime = FLM_ELAPSED_TIME( uiCurrTime, m_pCPInfo->uiStartWaitTruncateTime); - FLM_TIMER_UNITS_TO_MILLI( uiElapTime, - pCheckpointInfo->uiWaitTruncateTime); + pCheckpointInfo->uiWaitTruncateTime = + FLM_TIMER_UNITS_TO_MILLI( uiElapTime); } else { @@ -509,7 +509,7 @@ void F_Database::getCPInfo( /**************************************************************************** Desc: Retrieves the Checkpoint info for the database. *****************************************************************************/ -void XFLMAPI F_Db::getCheckpointInfo( +void FLMAPI F_Db::getCheckpointInfo( XFLM_CHECKPOINT_INFO * pCheckpointInfo) { m_pDatabase->lockMutex(); @@ -520,7 +520,7 @@ void XFLMAPI F_Db::getCheckpointInfo( /**************************************************************************** Desc: Returns current RFL file number ****************************************************************************/ -RCODE XFLMAPI F_Db::getRflFileNum( +RCODE FLMAPI F_Db::getRflFileNum( FLMUINT * puiRflFileNum ) { @@ -578,7 +578,7 @@ Exit: /**************************************************************************** Desc: Returns highest not used RFL file number ****************************************************************************/ -RCODE XFLMAPI F_Db::getHighestNotUsedRflFileNum( +RCODE FLMAPI F_Db::getHighestNotUsedRflFileNum( FLMUINT * puiHighestNotUsedRflFileNum ) { @@ -635,7 +635,7 @@ Exit: /**************************************************************************** Desc: Returns RFL file size limits for the database ****************************************************************************/ -RCODE XFLMAPI F_Db::getRflFileSizeLimits( +RCODE FLMAPI F_Db::getRflFileSizeLimits( FLMUINT * puiRflMinFileSize, FLMUINT * puiRflMaxFileSize ) @@ -689,7 +689,7 @@ Exit: /**************************************************************************** Desc: Returns RFL keep flag for the database ****************************************************************************/ -RCODE XFLMAPI F_Db::getRflKeepFlag( +RCODE FLMAPI F_Db::getRflKeepFlag( FLMBOOL * pbKeep ) { @@ -735,7 +735,7 @@ Exit: /**************************************************************************** Desc: Returns last backup transaction ID for the database ****************************************************************************/ -RCODE XFLMAPI F_Db::getLastBackupTransID( +RCODE FLMAPI F_Db::getLastBackupTransID( FLMUINT64 * pui64LastBackupTransID ) { @@ -780,7 +780,7 @@ Exit: /**************************************************************************** Desc: Returns blocks changed since the last backup for the database ****************************************************************************/ -RCODE XFLMAPI F_Db::getBlocksChangedSinceBackup( +RCODE FLMAPI F_Db::getBlocksChangedSinceBackup( FLMUINT * puiBlocksChangedSinceBackup ) { @@ -825,7 +825,7 @@ Exit: /**************************************************************************** Desc: Returns the auto-turn-off-keep-RFL flag for the database ****************************************************************************/ -RCODE XFLMAPI F_Db::getAutoTurnOffKeepRflFlag( +RCODE FLMAPI F_Db::getAutoTurnOffKeepRflFlag( FLMBOOL * pbAutoTurnOff ) { @@ -871,7 +871,7 @@ Exit: /**************************************************************************** Desc: Returns the keep aborted transactions in RFL flag for the database ****************************************************************************/ -RCODE XFLMAPI F_Db::getKeepAbortedTransInRflFlag( +RCODE FLMAPI F_Db::getKeepAbortedTransInRflFlag( FLMBOOL * pbKeep ) { @@ -917,7 +917,7 @@ Exit: /**************************************************************************** Desc: Returns disk space usage for the database ****************************************************************************/ -RCODE XFLMAPI F_Db::getDiskSpaceUsage( +RCODE FLMAPI F_Db::getDiskSpaceUsage( FLMUINT64 * pui64DataSize, FLMUINT64 * pui64RollbackSize, FLMUINT64 * pui64RflSize) @@ -968,11 +968,11 @@ RCODE XFLMAPI F_Db::getDiskSpaceUsage( // Get the actual size of the last file. - if (RC_BAD( rc = m_pSFileHdl->GetFileSize( uiLastFileNumber, + if (RC_BAD( rc = m_pSFileHdl->getFileSize( uiLastFileNumber, &ui64LastFileSize))) { - if (rc == NE_XFLM_IO_PATH_NOT_FOUND || - rc == NE_XFLM_IO_INVALID_FILENAME) + if (rc == NE_FLM_IO_PATH_NOT_FOUND || + rc == NE_FLM_IO_INVALID_FILENAME) { if (uiLastFileNumber > 1) { @@ -1041,11 +1041,11 @@ RCODE XFLMAPI F_Db::getDiskSpaceUsage( // Get the size of the last file number. - if (RC_BAD( rc = m_pSFileHdl->GetFileSize( uiLastFileNumber, + if (RC_BAD( rc = m_pSFileHdl->getFileSize( uiLastFileNumber, &ui64LastFileSize))) { - if (rc == NE_XFLM_IO_PATH_NOT_FOUND || - rc == NE_XFLM_IO_INVALID_FILENAME) + if (rc == NE_FLM_IO_PATH_NOT_FOUND || + rc == NE_FLM_IO_INVALID_FILENAME) { if (uiLastFileNumber) { @@ -1128,21 +1128,21 @@ RCODE XFLMAPI F_Db::getDiskSpaceUsage( // See if the directory exists. If not, we are done. - if (gv_pFileSystem->IsDir( szRflDir)) + if (gv_XFlmSysData.pFileSystem->isDir( szRflDir)) { // Open the directory and scan for RFL files. - if (RC_BAD( rc = gv_pFileSystem->OpenDir( szRflDir, + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->openDir( szRflDir, "*", &pDirHdl))) { goto Exit; } for (;;) { - if (RC_BAD( rc = pDirHdl->Next())) + if (RC_BAD( rc = pDirHdl->next())) { - if (rc == NE_XFLM_IO_NO_MORE_FILES) + if (rc == NE_FLM_IO_NO_MORE_FILES) { rc = NE_XFLM_OK; break; @@ -1152,23 +1152,23 @@ RCODE XFLMAPI F_Db::getDiskSpaceUsage( goto Exit; } } - pDirHdl->CurrentItemPath( szTmpName); + pDirHdl->currentItemPath( szTmpName); // If the item looks like an RFL file name, get // its size. - if (!pDirHdl->CurrentItemIsDir() && + if (!pDirHdl->currentItemIsDir() && rflGetFileNum( szTmpName, &uiLastFileNumber)) { // Open the file and get its size. - if (RC_BAD( rc = gv_pFileSystem->OpenBlockFile( - szTmpName, XFLM_IO_RDWR | XFLM_IO_SH_DENYNONE | XFLM_IO_DIRECT, + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->openBlockFile( + szTmpName, FLM_IO_RDWR | FLM_IO_SH_DENYNONE | FLM_IO_DIRECT, 512, &pFileHdl))) { - if (rc == NE_XFLM_IO_PATH_NOT_FOUND || - rc == NE_XFLM_IO_INVALID_FILENAME) + if (rc == NE_FLM_IO_PATH_NOT_FOUND || + rc == NE_FLM_IO_INVALID_FILENAME) { rc = NE_XFLM_OK; ui64LastFileSize = 0; @@ -1180,7 +1180,7 @@ RCODE XFLMAPI F_Db::getDiskSpaceUsage( } else { - if (RC_BAD( rc = pFileHdl->Size( &ui64LastFileSize))) + if (RC_BAD( rc = pFileHdl->size( &ui64LastFileSize))) { goto Exit; } @@ -1219,7 +1219,7 @@ Exit: /**************************************************************************** Desc: Returns the next incremental backup sequence number for the database ****************************************************************************/ -RCODE XFLMAPI F_Db::getNextIncBackupSequenceNum( +RCODE FLMAPI F_Db::getNextIncBackupSequenceNum( FLMUINT * puiNextIncBackupSequenceNum ) { @@ -1265,7 +1265,7 @@ Exit: Desc: Returns list of lock waiters in an object that allows caller to iterate through the list. ****************************************************************************/ -RCODE XFLMAPI F_Db::getLockWaiters( +RCODE FLMAPI F_Db::getLockWaiters( IF_LockInfoClient * pLockInfo ) { @@ -1285,7 +1285,7 @@ RCODE XFLMAPI F_Db::getLockWaiters( /**************************************************************************** Desc: Returns RFL directory for the database ****************************************************************************/ -void XFLMAPI F_Db::getRflDir( +void FLMAPI F_Db::getRflDir( char * pszRflDir ) { @@ -1297,7 +1297,7 @@ void XFLMAPI F_Db::getRflDir( /**************************************************************************** Desc: Returns database serial number ****************************************************************************/ -void XFLMAPI F_Db::getSerialNumber( +void FLMAPI F_Db::getSerialNumber( char * pucSerialNumber) { m_pDatabase->lockMutex(); diff --git a/xflaim/src/fdbcopy.cpp b/xflaim/src/fdbcopy.cpp index 8a118d3..8203f0c 100644 --- a/xflaim/src/fdbcopy.cpp +++ b/xflaim/src/fdbcopy.cpp @@ -46,7 +46,6 @@ typedef struct FSTATIC RCODE flmCopyFile( - F_FileSystem * pFileSystem, DB_COPY_INFO * pDbCopyInfo, COPIED_NAME ** ppCopiedListRV, FLMBOOL bOkToTruncate, @@ -210,7 +209,7 @@ RCODE F_DbSystem::copyDb( // Set up the super file object for the source database. // Must at least open the control file. - if (RC_BAD( rc = SrcSFileHdl.Setup( NULL, pszSrcDbName, pszSrcDataDir))) + if (RC_BAD( rc = SrcSFileHdl.setup( pszSrcDbName, pszSrcDataDir))) { goto Exit; } @@ -317,8 +316,7 @@ retry: // Set up the super file object for the destination database. - if (RC_BAD( rc = DestSFileHdl.Setup( NULL, pszDestDbName, - pszDestDataDir))) + if (RC_BAD( rc = DestSFileHdl.setup( pszDestDbName, pszDestDataDir))) { goto Exit; } @@ -328,11 +326,11 @@ retry: uiHighFileNumber = 0; for (;;) { - if ((RC_BAD( rc = SrcSFileHdl.GetFileSize( + if ((RC_BAD( rc = SrcSFileHdl.getFileSize( uiHighFileNumber, &ui64FileSize))) || !ui64FileSize ) { - if (rc == NE_XFLM_IO_PATH_NOT_FOUND || - rc == NE_XFLM_IO_INVALID_FILENAME || + if (rc == NE_FLM_IO_PATH_NOT_FOUND || + rc == NE_FLM_IO_INVALID_FILENAME || !ui64FileSize) { // If the control file doesn't exist, we will return @@ -363,11 +361,11 @@ retry: uiHighLogFileNumber = FIRST_LOG_BLOCK_FILE_NUMBER; for (;;) { - if ((RC_BAD( rc = SrcSFileHdl.GetFileSize( + if ((RC_BAD( rc = SrcSFileHdl.getFileSize( uiHighLogFileNumber, &ui64FileSize))) || !ui64FileSize) { - if (rc == NE_XFLM_IO_PATH_NOT_FOUND || - rc == NE_XFLM_IO_INVALID_FILENAME || + if (rc == NE_FLM_IO_PATH_NOT_FOUND || + rc == NE_FLM_IO_INVALID_FILENAME || !ui64FileSize) { if (uiHighLogFileNumber == @@ -401,7 +399,7 @@ retry: goto Exit; } - if (RC_BAD( rc = gv_pFileSystem->OpenDir( + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->openDir( pszActualSrcRflPath, (char *)"*", &pDirHdl))) { goto Exit; @@ -409,9 +407,9 @@ retry: for (;;) { - if (RC_BAD( rc = pDirHdl->Next())) + if (RC_BAD( rc = pDirHdl->next())) { - if (rc == NE_XFLM_IO_NO_MORE_FILES) + if (rc == NE_FLM_IO_NO_MORE_FILES) { rc = NE_XFLM_OK; break; @@ -424,9 +422,9 @@ retry: // If the current file is an RFL file, increment ui64BytesToCopy - if (rflGetFileNum( pDirHdl->CurrentItemName(), &uiFileNumber)) + if (rflGetFileNum( pDirHdl->currentItemName(), &uiFileNumber)) { - DbCopyInfo.ui64BytesToCopy += (FLMUINT64)pDirHdl->CurrentItemSize(); + DbCopyInfo.ui64BytesToCopy += (FLMUINT64)pDirHdl->currentItemSize(); } } @@ -435,8 +433,8 @@ retry: // Close all file handles in the source and destination - SrcSFileHdl.ReleaseFiles( TRUE); - DestSFileHdl.ReleaseFiles( TRUE); + SrcSFileHdl.releaseFiles( TRUE); + DestSFileHdl.releaseFiles( TRUE); // Copy the database files. @@ -445,21 +443,20 @@ retry: // Get the source file path and destination file path. - if( RC_BAD( rc = SrcSFileHdl.GetFilePath( + if( RC_BAD( rc = SrcSFileHdl.getFilePath( uiFileNumber, DbCopyInfo.szSrcFileName))) { goto Exit; } - if( RC_BAD( rc = DestSFileHdl.GetFilePath( + if( RC_BAD( rc = DestSFileHdl.getFilePath( uiFileNumber, DbCopyInfo.szDestFileName))) { goto Exit; } DbCopyInfo.bNewSrcFile = TRUE; - if (RC_BAD( rc = flmCopyFile( gv_pFileSystem, - &DbCopyInfo, &pCopiedList, TRUE, - ifpStatus))) + if (RC_BAD( rc = flmCopyFile( + &DbCopyInfo, &pCopiedList, TRUE, ifpStatus))) { goto Exit; } @@ -473,22 +470,21 @@ retry: // Get the source file path and destination file path. - if (RC_BAD( rc = SrcSFileHdl.GetFilePath( uiFileNumber, + if (RC_BAD( rc = SrcSFileHdl.getFilePath( uiFileNumber, DbCopyInfo.szSrcFileName))) { goto Exit; } - if (RC_BAD( rc = DestSFileHdl.GetFilePath( uiFileNumber, + if (RC_BAD( rc = DestSFileHdl.getFilePath( uiFileNumber, DbCopyInfo.szDestFileName))) { goto Exit; } DbCopyInfo.bNewSrcFile = TRUE; - if (RC_BAD( rc = flmCopyFile( gv_pFileSystem, - &DbCopyInfo, &pCopiedList, TRUE, - ifpStatus))) + if (RC_BAD( rc = flmCopyFile( + &DbCopyInfo, &pCopiedList, TRUE, ifpStatus))) { goto Exit; } @@ -508,18 +504,18 @@ retry: goto Exit; } - if( RC_OK( gv_pFileSystem->Exists( pszActualDestRflPath))) + if( RC_OK( gv_XFlmSysData.pFileSystem->doesFileExist( pszActualDestRflPath))) { - if( gv_pFileSystem->IsDir( pszActualDestRflPath)) + if( gv_XFlmSysData.pFileSystem->isDir( pszActualDestRflPath)) { // Remove the existing directory and all files, etc. - (void)gv_pFileSystem->RemoveDir( + (void)gv_XFlmSysData.pFileSystem->removeDir( pszActualDestRflPath, TRUE); } else { - (void)gv_pFileSystem->Delete( pszActualDestRflPath); + (void)gv_XFlmSysData.pFileSystem->deleteFile( pszActualDestRflPath); } } @@ -530,14 +526,14 @@ retry: // when we try to create the destination files (below), the FLAIM file // file system code will try to create any necessary directories. - (void)gv_pFileSystem->CreateDir( pszActualDestRflPath); + (void)gv_XFlmSysData.pFileSystem->createDir( pszActualDestRflPath); bCreatedDestRflDir = TRUE; // Copy the RFL files. NOTE: We need to copy all of the RFL files // in the source RFL directory so that they will be available // when performing a database restore operation. - if (RC_BAD( rc = gv_pFileSystem->OpenDir( + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->openDir( pszActualSrcRflPath, (char *)"*", &pDirHdl))) { goto Exit; @@ -545,9 +541,9 @@ retry: for (;;) { - if( RC_BAD( rc = pDirHdl->Next())) + if( RC_BAD( rc = pDirHdl->next())) { - if (rc == NE_XFLM_IO_NO_MORE_FILES) + if (rc == NE_FLM_IO_NO_MORE_FILES) { rc = NE_XFLM_OK; break; @@ -560,7 +556,7 @@ retry: // If the current file is an RFL file, copy it to the destination - if( rflGetFileNum( pDirHdl->CurrentItemName(), &uiFileNumber)) + if( rflGetFileNum( pDirHdl->currentItemName(), &uiFileNumber)) { // Get the source file path and the destination file path. @@ -579,9 +575,8 @@ retry: } DbCopyInfo.bNewSrcFile = TRUE; - if (RC_BAD( rc = flmCopyFile( gv_pFileSystem, - &DbCopyInfo, &pCopiedList, TRUE, - ifpStatus))) + if (RC_BAD( rc = flmCopyFile( + &DbCopyInfo, &pCopiedList, TRUE, ifpStatus))) { goto Exit; } @@ -643,7 +638,7 @@ Exit: if (pLockFileHdl) { - (void)pLockFileHdl->Close(); + (void)pLockFileHdl->close(); pLockFileHdl->Release(); pLockFileHdl = NULL; } @@ -670,7 +665,7 @@ Exit: if (RC_BAD( rc)) { - (void)gv_pFileSystem->Delete( pCopiedList->szPath); + (void)gv_XFlmSysData.pFileSystem->deleteFile( pCopiedList->szPath); } f_free( &pCopiedList); @@ -679,7 +674,7 @@ Exit: if (RC_BAD( rc) && bCreatedDestRflDir) { - (void)gv_pFileSystem->RemoveDir( pszActualDestRflPath); + (void)gv_XFlmSysData.pFileSystem->removeDir( pszActualDestRflPath); } if (pszActualSrcRflPath) @@ -699,7 +694,6 @@ Exit: Desc: Copy a file that is one of the files of the database. *****************************************************************************/ FSTATIC RCODE flmCopyFile( - F_FileSystem * pFileSystem, DB_COPY_INFO * pDbCopyInfo, COPIED_NAME ** ppCopiedListRV, FLMBOOL bOkToTruncate, @@ -718,8 +712,9 @@ FSTATIC RCODE flmCopyFile( // Open the source file. - if( RC_BAD( rc = pFileSystem->Open( pDbCopyInfo->szSrcFileName, - XFLM_IO_RDWR | XFLM_IO_SH_DENYNONE | XFLM_IO_DIRECT, + if( RC_BAD( rc = gv_XFlmSysData.pFileSystem->openFile( + pDbCopyInfo->szSrcFileName, + FLM_IO_RDWR | FLM_IO_SH_DENYNONE | FLM_IO_DIRECT, &pSrcFileHdl))) { goto Exit; @@ -729,19 +724,20 @@ FSTATIC RCODE flmCopyFile( // First attempt to open the destination file. If it does // not exist, attempt to create it. - if (RC_BAD( rc = pFileSystem->Open( pDbCopyInfo->szDestFileName, - XFLM_IO_RDWR | XFLM_IO_SH_DENYNONE | XFLM_IO_DIRECT, + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->openFile( pDbCopyInfo->szDestFileName, + FLM_IO_RDWR | FLM_IO_SH_DENYNONE | FLM_IO_DIRECT, &pDestFileHdl))) { - if (rc != NE_XFLM_IO_PATH_NOT_FOUND && - rc != NE_XFLM_IO_INVALID_FILENAME) + if (rc != NE_FLM_IO_PATH_NOT_FOUND && + rc != NE_FLM_IO_INVALID_FILENAME) { goto Exit; } - if( RC_BAD( rc = pFileSystem->Create( pDbCopyInfo->szDestFileName, - XFLM_IO_RDWR | XFLM_IO_EXCL | XFLM_IO_SH_DENYNONE | - XFLM_IO_CREATE_DIR | XFLM_IO_DIRECT, + if( RC_BAD( rc = gv_XFlmSysData.pFileSystem->createFile( + pDbCopyInfo->szDestFileName, + FLM_IO_RDWR | FLM_IO_EXCL | FLM_IO_SH_DENYNONE | + FLM_IO_CREATE_DIR | FLM_IO_DIRECT, &pDestFileHdl))) { goto Exit; @@ -769,10 +765,10 @@ FSTATIC RCODE flmCopyFile( // Read data from source file. - if (RC_BAD( rc = pSrcFileHdl->SectorRead( uiOffset, uiBytesToRead, + if (RC_BAD( rc = pSrcFileHdl->sectorRead( uiOffset, uiBytesToRead, pucBuffer, &uiBytesRead))) { - if (rc == NE_XFLM_IO_END_OF_FILE) + if (rc == NE_FLM_IO_END_OF_FILE) { rc = NE_XFLM_OK; if (!uiBytesRead) @@ -788,7 +784,7 @@ FSTATIC RCODE flmCopyFile( // Write data to destination file. - if (RC_BAD( rc = pDestFileHdl->Write( uiOffset, + if (RC_BAD( rc = pDestFileHdl->write( uiOffset, uiBytesRead, pucBuffer, &uiBytesWritten))) { goto Exit; @@ -834,7 +830,7 @@ FSTATIC RCODE flmCopyFile( if (!bCreatedDestFile && bOkToTruncate) { - if (RC_BAD( rc = pDestFileHdl->Truncate( uiOffset))) + if (RC_BAD( rc = pDestFileHdl->truncate( uiOffset))) { goto Exit; } @@ -872,7 +868,7 @@ Exit: if (pDestFileHdl) { - pDestFileHdl->Flush(); + pDestFileHdl->flush(); pDestFileHdl->Release(); } @@ -881,7 +877,7 @@ Exit: if (RC_BAD( rc)) { - (void)pFileSystem->Delete( pDbCopyInfo->szDestFileName); + (void)gv_XFlmSysData.pFileSystem->deleteFile( pDbCopyInfo->szDestFileName); } return( rc); diff --git a/xflaim/src/fdbremov.cpp b/xflaim/src/fdbremov.cpp index 3fbdaae..fdfd18e 100644 --- a/xflaim/src/fdbremov.cpp +++ b/xflaim/src/fdbremov.cpp @@ -53,7 +53,7 @@ RCODE F_DbSystem::dbRemove( if( !pszDbName || !(*pszDbName)) { - rc = RC_SET( NE_XFLM_IO_INVALID_FILENAME); + rc = RC_SET( NE_FLM_IO_INVALID_FILENAME); goto Exit; } @@ -79,12 +79,14 @@ RCODE F_DbSystem::dbRemove( if (pszDataDir && *pszDataDir) { - if (RC_BAD( rc = gv_pFileSystem->pathReduce( pszDbName, pszDataName, pszBaseName))) + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathReduce( + pszDbName, pszDataName, pszBaseName))) { goto Exit; } f_strcpy( pszDataName, pszDataDir); - if (RC_BAD( rc = gv_pFileSystem->pathAppend( pszDataName, pszBaseName))) + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathAppend( + pszDataName, pszBaseName))) { goto Exit; } @@ -97,9 +99,9 @@ RCODE F_DbSystem::dbRemove( // Start deleting files, beginning with the main DB file. - if (RC_BAD( rc = gv_pFileSystem->Delete( pszDbName))) + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->deleteFile( pszDbName))) { - if (rc == NE_XFLM_IO_PATH_NOT_FOUND || rc == NE_XFLM_IO_INVALID_FILENAME) + if (rc == NE_FLM_IO_PATH_NOT_FOUND || rc == NE_FLM_IO_INVALID_FILENAME) { rc = NE_XFLM_OK; } @@ -132,9 +134,9 @@ RCODE F_DbSystem::dbRemove( // Delete the .lck file, if any f_strcpy( pszExt, ".lck"); - if (RC_BAD( rc = gv_pFileSystem->Delete( pszTmpName))) + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->deleteFile( pszTmpName))) { - if (rc == NE_XFLM_IO_PATH_NOT_FOUND || rc == NE_XFLM_IO_INVALID_FILENAME) + if (rc == NE_FLM_IO_PATH_NOT_FOUND || rc == NE_FLM_IO_INVALID_FILENAME) { rc = NE_XFLM_OK; } @@ -151,9 +153,9 @@ RCODE F_DbSystem::dbRemove( { bldSuperFileExtension( uiFileNumber, pszDataExt); - if (RC_BAD( rc = gv_pFileSystem->Delete( pszDataName))) + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->deleteFile( pszDataName))) { - if (rc == NE_XFLM_IO_PATH_NOT_FOUND || rc == NE_XFLM_IO_INVALID_FILENAME) + if (rc == NE_FLM_IO_PATH_NOT_FOUND || rc == NE_FLM_IO_INVALID_FILENAME) { rc = NE_XFLM_OK; break; @@ -177,9 +179,9 @@ RCODE F_DbSystem::dbRemove( { bldSuperFileExtension( uiFileNumber, pszExt); - if (RC_BAD( rc = gv_pFileSystem->Delete( pszTmpName))) + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->deleteFile( pszTmpName))) { - if (rc == NE_XFLM_IO_PATH_NOT_FOUND || rc == NE_XFLM_IO_INVALID_FILENAME) + if (rc == NE_FLM_IO_PATH_NOT_FOUND || rc == NE_FLM_IO_INVALID_FILENAME) { rc = NE_XFLM_OK; break; @@ -212,18 +214,18 @@ RCODE F_DbSystem::dbRemove( // See if the directory exists. If not, we are done. - if (!gv_pFileSystem->IsDir( pszRflDirName)) + if (!gv_XFlmSysData.pFileSystem->isDir( pszRflDirName)) { goto Exit; // Should return NE_XFLM_OK } // Open the directory and scan for RFL files. - // NOTE: DO NOT just call RemoveDir. There may be other + // NOTE: DO NOT just call removeDir. There may be other // things in the directory that we do not want to delete. // Look specifically for files that match our expected // name format for RFL files. - if (RC_BAD( rc = gv_pFileSystem->OpenDir( pszRflDirName, + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->openDir( pszRflDirName, "*", &pDirHdl))) { goto Exit; @@ -236,9 +238,9 @@ RCODE F_DbSystem::dbRemove( bCanDeleteDir = TRUE; for (;;) { - if (RC_BAD( rc = pDirHdl->Next())) + if (RC_BAD( rc = pDirHdl->next())) { - if (rc == NE_XFLM_IO_NO_MORE_FILES) + if (rc == NE_FLM_IO_NO_MORE_FILES) { rc = NE_XFLM_OK; break; @@ -248,8 +250,8 @@ RCODE F_DbSystem::dbRemove( goto Exit; } } - pDirHdl->CurrentItemPath( pszTmpName); - if (pDirHdl->CurrentItemIsDir()) + pDirHdl->currentItemPath( pszTmpName); + if (pDirHdl->currentItemIsDir()) { bCanDeleteDir = FALSE; } @@ -260,10 +262,10 @@ RCODE F_DbSystem::dbRemove( else { if( RC_BAD( rc = - gv_pFileSystem->Delete( pszTmpName))) + gv_XFlmSysData.pFileSystem->deleteFile( pszTmpName))) { - if (rc == NE_XFLM_IO_PATH_NOT_FOUND || - rc == NE_XFLM_IO_INVALID_FILENAME) + if (rc == NE_FLM_IO_PATH_NOT_FOUND || + rc == NE_FLM_IO_INVALID_FILENAME) { rc = NE_XFLM_OK; } @@ -289,14 +291,10 @@ RCODE F_DbSystem::dbRemove( pDirHdl->Release(); pDirHdl = NULL; } - if ((pDirHdl = f_new F_DirHdl) == NULL) + + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->removeDir( pszRflDirName))) { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - if (RC_BAD( rc = pDirHdl->RemoveDir( pszRflDirName))) - { - if (rc == NE_XFLM_IO_PATH_NOT_FOUND || rc == NE_XFLM_IO_INVALID_FILENAME) + if (rc == NE_FLM_IO_PATH_NOT_FOUND || rc == NE_FLM_IO_INVALID_FILENAME) { rc = NE_XFLM_OK; } diff --git a/xflaim/src/fdbrenam.cpp b/xflaim/src/fdbrenam.cpp index 9d409e7..97e6ee7 100644 --- a/xflaim/src/fdbrenam.cpp +++ b/xflaim/src/fdbrenam.cpp @@ -104,11 +104,13 @@ RCODE F_DbSystem::dbRename( // There must be either no directory specified for the new name, or // it must be identical to the old directory. - if (RC_BAD( rc = gv_pFileSystem->pathReduce( pszDbName, pszOldName, szOldBase))) + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathReduce( + pszDbName, pszOldName, szOldBase))) { goto Exit; } - if (RC_BAD( rc = gv_pFileSystem->pathReduce( pszNewDbName, pszNewName, szNewBase))) + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathReduce( + pszNewDbName, pszNewName, szNewBase))) { goto Exit; } @@ -121,7 +123,8 @@ RCODE F_DbSystem::dbRename( goto Exit; } f_strcpy( pszNewName, pszOldName); - if (RC_BAD( rc = gv_pFileSystem->pathAppend( pszNewName, szNewBase))) + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathAppend( + pszNewName, szNewBase))) { goto Exit; } @@ -133,11 +136,13 @@ RCODE F_DbSystem::dbRename( { f_strcpy( pszOldDataName, pszDataDir); f_strcpy( pszNewDataName, pszDataDir); - if (RC_BAD( rc = gv_pFileSystem->pathAppend( pszOldDataName, szOldBase))) + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathAppend( + pszOldDataName, szOldBase))) { goto Exit; } - if (RC_BAD( rc = gv_pFileSystem->pathAppend( pszNewDataName, szNewBase))) + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathAppend( + pszNewDataName, szNewBase))) { goto Exit; } @@ -313,8 +318,8 @@ Exit: if (RC_BAD( rc)) { - gv_pFileSystem->Rename( pRenameFile->Info.szDstFileName, - pRenameFile->Info.szSrcFileName); + gv_XFlmSysData.pFileSystem->renameFile( + pRenameFile->Info.szDstFileName, pRenameFile->Info.szSrcFileName); } f_free( &pRenameFile); } @@ -343,7 +348,8 @@ FSTATIC RCODE flmRenameFile( if (f_stricmp( pszSrcFileName, pszDstFileName) == 0) { - if (gv_pFileSystem->Exists( pszSrcFileName) == NE_XFLM_OK) + if (gv_XFlmSysData.pFileSystem->doesFileExist( + pszSrcFileName) == NE_XFLM_OK) { *pbFileFound = TRUE; } @@ -360,20 +366,20 @@ FSTATIC RCODE flmRenameFile( if (bOverwriteDestOk) { - if (gv_pFileSystem->IsDir( pszDstFileName)) + if (gv_XFlmSysData.pFileSystem->isDir( pszDstFileName)) { - if (RC_BAD( rc = gv_pFileSystem->RemoveDir( - pszDstFileName, TRUE))) + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->removeDir( + pszDstFileName, TRUE))) { goto Exit; } } else { - if (RC_BAD( rc = gv_pFileSystem->Delete( - pszDstFileName))) + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->deleteFile( + pszDstFileName))) { - if (rc == NE_XFLM_IO_PATH_NOT_FOUND || rc == NE_XFLM_IO_INVALID_FILENAME) + if (rc == NE_FLM_IO_PATH_NOT_FOUND || rc == NE_FLM_IO_INVALID_FILENAME) { rc = NE_XFLM_OK; } @@ -388,10 +394,10 @@ FSTATIC RCODE flmRenameFile( // If names are the same, no need to actually do the // rename. - if (RC_BAD( rc = gv_pFileSystem->Rename( pszSrcFileName, - pszDstFileName))) + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->renameFile( + pszSrcFileName, pszDstFileName))) { - if (rc == NE_XFLM_IO_PATH_NOT_FOUND || rc == NE_XFLM_IO_INVALID_FILENAME) + if (rc == NE_FLM_IO_PATH_NOT_FOUND || rc == NE_FLM_IO_INVALID_FILENAME) { if (bPathNotFoundOk) { diff --git a/xflaim/src/fdict.cpp b/xflaim/src/fdict.cpp index e417155..ce7ef47 100644 --- a/xflaim/src/fdict.cpp +++ b/xflaim/src/fdict.cpp @@ -48,17 +48,17 @@ FSTATIC void fdictRemoveFromIcdChain( ICD * pIcd); FSTATIC RCODE fdictCopyCollection( - F_Pool * pDictPool, + IF_Pool * pDictPool, F_COLLECTION ** ppDestCollection, F_COLLECTION * pSrcCollection); FSTATIC RCODE fdictCopyPrefix( - F_Pool * pDictPool, + IF_Pool * pDictPool, F_PREFIX ** ppDestPrefix, F_PREFIX * pSrcPrefix); FSTATIC RCODE fdictCopyEncDef( - F_Pool * pDictPool, + IF_Pool * pDictPool, F_ENCDEF ** ppDestEncDef, F_ENCDEF * pSrcEncDef); @@ -94,7 +94,7 @@ F_Dict::F_Dict() m_pPrev = NULL; m_pDatabase = NULL; m_uiDictSeq = 0; - m_dictPool.poolInit( 1024); + m_pDictPool = NULL; m_pElementDefTbl = NULL; m_uiLowestElementNum = 0; @@ -157,11 +157,35 @@ F_Dict::F_Dict() } /*************************************************************************** -Desc: Destructor +Desc: ***************************************************************************/ F_Dict::~F_Dict() { resetDict(); + + if( m_pDictPool) + { + m_pDictPool->Release(); + } +} + +/*************************************************************************** +Desc: +***************************************************************************/ +RCODE F_Dict::setup( void) +{ + RCODE rc = NE_XFLM_OK; + + if( RC_BAD( rc = FlmAllocPool( &m_pDictPool))) + { + goto Exit; + } + + m_pDictPool->poolInit( 1024); + +Exit: + + return( rc); } /*************************************************************************** @@ -241,8 +265,11 @@ void F_Dict::resetDict( void) m_pDataCollection = NULL; m_pMaintCollection = NULL; - m_dictPool.poolFree(); - m_dictPool.poolInit( 1024); + if( m_pDictPool) + { + m_pDictPool->poolFree(); + m_pDictPool->poolInit( 1024); + } if (m_pNameTable) { @@ -2265,7 +2292,7 @@ RCODE F_Dict::copyIXD( // Allocate the IXD structure - if (RC_BAD( rc = m_dictPool.poolAlloc( sizeof( IXD), (void **)&pDestIxd))) + if (RC_BAD( rc = m_pDictPool->poolAlloc( sizeof( IXD), (void **)&pDestIxd))) { goto Exit; } @@ -2288,7 +2315,7 @@ RCODE F_Dict::copyIXD( pSrcIcd = pSrcIxd->pIcdTree; while (pSrcIcd) { - if (RC_BAD( rc = m_dictPool.poolAlloc( sizeof( ICD), + if (RC_BAD( rc = m_pDictPool->poolAlloc( sizeof( ICD), (void **)&pDestIcd))) { goto Exit; @@ -2503,11 +2530,11 @@ Exit: Desc: Copies a collection ****************************************************************************/ FSTATIC RCODE fdictCopyCollection( - F_Pool * pDictPool, + IF_Pool * pDictPool, F_COLLECTION ** ppDestCollection, F_COLLECTION * pSrcCollection) { - RCODE rc = NE_XFLM_OK; + RCODE rc = NE_XFLM_OK; if (!pSrcCollection) { @@ -2532,7 +2559,7 @@ Exit: Desc: Copies a prefix ****************************************************************************/ FSTATIC RCODE fdictCopyPrefix( - F_Pool * pDictPool, + IF_Pool * pDictPool, F_PREFIX ** ppDestPrefix, F_PREFIX * pSrcPrefix) { @@ -2575,7 +2602,7 @@ Exit: Desc: Copies an encryption def (F_ENCDEF) ****************************************************************************/ FSTATIC RCODE fdictCopyEncDef( - F_Pool * pDictPool, + IF_Pool * pDictPool, F_ENCDEF ** ppDestEncDef, F_ENCDEF * pSrcEncDef) { @@ -2852,21 +2879,21 @@ RCODE F_Dict::cloneDict( // Copy the pre-defined collections - if (RC_BAD( rc = fdictCopyCollection( &m_dictPool, + if (RC_BAD( rc = fdictCopyCollection( m_pDictPool, &m_pDictCollection, pSrcDict->m_pDictCollection))) { goto Exit; } - if (RC_BAD( rc = fdictCopyCollection( &m_dictPool, + if (RC_BAD( rc = fdictCopyCollection( m_pDictPool, &m_pDataCollection, pSrcDict->m_pDataCollection))) { goto Exit; } - if (RC_BAD( rc = fdictCopyCollection( &m_dictPool, + if (RC_BAD( rc = fdictCopyCollection( m_pDictPool, &m_pMaintCollection, pSrcDict->m_pMaintCollection))) { @@ -2890,7 +2917,7 @@ RCODE F_Dict::cloneDict( for (uiLoop = 0; uiLoop < uiCount; uiLoop++) { - if (RC_BAD( rc = fdictCopyCollection( &m_dictPool, + if (RC_BAD( rc = fdictCopyCollection( m_pDictPool, &m_ppCollectionTbl [uiLoop], pSrcDict->m_ppCollectionTbl [uiLoop]))) { @@ -2916,7 +2943,7 @@ RCODE F_Dict::cloneDict( for (uiLoop = 0; uiLoop < uiCount; uiLoop++) { - if (RC_BAD( rc = fdictCopyPrefix( &m_dictPool, + if (RC_BAD( rc = fdictCopyPrefix( m_pDictPool, &m_ppPrefixTbl [uiLoop], pSrcDict->m_ppPrefixTbl [uiLoop]))) { @@ -2942,7 +2969,7 @@ RCODE F_Dict::cloneDict( for (uiLoop = 0; uiLoop < uiCount; uiLoop++) { - if (RC_BAD( rc = fdictCopyEncDef( &m_dictPool, + if (RC_BAD( rc = fdictCopyEncDef( m_pDictPool, &m_ppEncDefTbl [uiLoop], pSrcDict->m_ppEncDefTbl [uiLoop]))) { @@ -3275,8 +3302,7 @@ Desc: Maps a string to an element or attribute data type. ***************************************************************************/ RCODE fdictGetDataType( char * pszDataType, - FLMUINT * puiDataType - ) + FLMUINT * puiDataType) { RCODE rc = NE_XFLM_OK; FLMUINT uiDataType; @@ -3913,7 +3939,7 @@ RCODE F_Db::getElmAttrInfo( F_DOMNode * pDocNode = NULL; F_DOMNode * pAttr = NULL; F_CachedNode * pCachedDocNode; - FLMBYTE szTmpBuf[ 80]; + char szTmpBuf[ 80]; FLMUINT uiNameId; FLMUNICODE * puzName = NULL; FLMBOOL bNamespaceDecl = FALSE; @@ -4023,7 +4049,7 @@ RCODE F_Db::getElmAttrInfo( case ATTR_TYPE_TAG: { - if( RC_BAD( rc = pAttr->getUTF8( this, szTmpBuf, + if( RC_BAD( rc = pAttr->getUTF8( this, (FLMBYTE *)szTmpBuf, sizeof( szTmpBuf), 0, ~((FLMUINT)0)))) { goto Exit; @@ -4048,7 +4074,8 @@ RCODE F_Db::getElmAttrInfo( case ATTR_STATE_TAG: { if (RC_BAD( rc = pAttr->getUTF8( - this, szTmpBuf, sizeof( szTmpBuf), 0, ~((FLMUINT)0)))) + this, (FLMBYTE *)szTmpBuf, + sizeof( szTmpBuf), 0, ~((FLMUINT)0)))) { goto Exit; } @@ -4108,7 +4135,7 @@ RCODE F_Db::getElmAttrInfo( goto Exit; } bHadUniqueSubElementTag = TRUE; - if( RC_BAD( rc = pAttr->getUTF8( this, szTmpBuf, + if( RC_BAD( rc = pAttr->getUTF8( this, (FLMBYTE *)szTmpBuf, sizeof( szTmpBuf), 0, ~((FLMUINT)0)))) { goto Exit; @@ -5070,7 +5097,7 @@ RCODE F_Db::getIndexDef( F_DOMNode * pAttr = NULL; FLMBOOL bHadIndexNumber = FALSE; FLMBOOL bHadIndexName = FALSE; - FLMBYTE szTmpBuf[ 80]; + char szTmpBuf[ 80]; FLMUNICODE * puzCollectionName = NULL; FLMUINT uiNameCollectionNum = 0; FLMUINT uiNameId; @@ -5234,30 +5261,29 @@ RCODE F_Db::getIndexDef( case ATTR_LANGUAGE_TAG: { - if( RC_BAD( rc = pAttr->getUTF8( this, szTmpBuf, + if( RC_BAD( rc = pAttr->getUTF8( this, (FLMBYTE *)szTmpBuf, sizeof( szTmpBuf), 0, ~((FLMUINT)0)))) { goto Exit; } - *puiLanguage = F_DbSystem::languageToNum( (char *)szTmpBuf); + *puiLanguage = f_languageToNum( (char *)szTmpBuf); break; } case ATTR_INDEX_OPTIONS_TAG: { - FLMBYTE * pszTmp; - FLMBYTE * pszOption; + char * pszTmp; + char * pszOption; - if( RC_BAD( rc = pAttr->getUTF8( this, szTmpBuf, + if( RC_BAD( rc = pAttr->getUTF8( this, (FLMBYTE *)szTmpBuf, sizeof( szTmpBuf), 0, ~((FLMUINT)0)))) { goto Exit; } pszTmp = &szTmpBuf [0]; - while ((pszOption = - (FLMBYTE *)fdictGetOption( (char **)&pszTmp)) != NULL) + while ((pszOption = fdictGetOption( (char **)&pszTmp)) != NULL) { if (f_stricmp( pszOption, XFLM_ABS_POS_OPTION_STR) == 0) @@ -5277,13 +5303,13 @@ RCODE F_Db::getIndexDef( { FLMUINT uiState; - if (RC_BAD( rc = pAttr->getUTF8( this, szTmpBuf, + if (RC_BAD( rc = pAttr->getUTF8( this, (FLMBYTE *)szTmpBuf, sizeof( szTmpBuf), 0, ~((FLMUINT)0)))) { goto Exit; } - if (RC_BAD( rc = fdictGetIndexState( (char *)szTmpBuf, &uiState))) + if (RC_BAD( rc = fdictGetIndexState( szTmpBuf, &uiState))) { goto Exit; } @@ -5440,15 +5466,15 @@ RCODE F_Db::getIndexComponentDef( F_CachedNode * pCachedNode; ICD * pTmpIcd; ICD * pPrevIcd; - FLMBYTE szTmpBuf[ 200]; + char szTmpBuf[ 200]; + char * pszTmp; + char * pszOption; FLMUNICODE * puzName = NULL; FLMUNICODE * puzNamespace = NULL; FLMUINT uiKeyComponent; FLMUINT uiDataComponent; FLMUINT uiNameDictNumber = 0; FLMUINT uiDataType= 0; - FLMBYTE * pszTmp; - FLMBYTE * pszOption; FLMBOOL bLimitSet = FALSE; FLMBOOL bRequiredSet = FALSE; FLMBOOL bIndexOnSet = FALSE; @@ -5539,7 +5565,7 @@ RCODE F_Db::getIndexComponentDef( break; case ATTR_INDEX_ON_TAG: - if( RC_BAD( rc = pAttr->getUTF8( this, szTmpBuf, + if( RC_BAD( rc = pAttr->getUTF8( this, (FLMBYTE *)szTmpBuf, sizeof( szTmpBuf), 0, ~((FLMUINT)0)))) { goto Exit; @@ -5583,7 +5609,7 @@ RCODE F_Db::getIndexComponentDef( break; case ATTR_REQUIRED_TAG: - if( RC_BAD( rc = pAttr->getUTF8( this, szTmpBuf, + if( RC_BAD( rc = pAttr->getUTF8( this, (FLMBYTE *)szTmpBuf, sizeof( szTmpBuf), 0, ~((FLMUINT)0)))) { goto Exit; @@ -5617,15 +5643,14 @@ RCODE F_Db::getIndexComponentDef( break; case ATTR_COMPARE_RULES_TAG: - if (RC_BAD( rc = pAttr->getUTF8( this, szTmpBuf, + if (RC_BAD( rc = pAttr->getUTF8( this, (FLMBYTE *)szTmpBuf, sizeof( szTmpBuf), 0, ~((FLMUINT)0)))) { goto Exit; } pszTmp = &szTmpBuf [0]; - while ((pszOption = - (FLMBYTE *)fdictGetOption( (char **)&pszTmp)) != NULL) + while ((pszOption = fdictGetOption( &pszTmp)) != NULL) { if (f_stricmp( pszOption, XFLM_CASE_INSENSITIVE_OPTION_STR) == 0) @@ -6266,7 +6291,7 @@ RCODE F_Dict::updateIndexDef( ) { RCODE rc = NE_XFLM_OK; - void * pvMark = m_dictPool.poolMark(); + void * pvMark = m_pDictPool->poolMark(); FLMUNICODE * puzIndexName = NULL; F_DOMNode * pNode = NULL; FLMUINT uiElementId; @@ -6389,7 +6414,7 @@ RCODE F_Dict::updateIndexDef( // Allocate a new IXD - if (RC_BAD( rc = m_dictPool.poolCalloc( sizeof( IXD), (void **)&pIxd))) + if (RC_BAD( rc = m_pDictPool->poolCalloc( sizeof( IXD), (void **)&pIxd))) { goto Exit; } @@ -6445,7 +6470,7 @@ RCODE F_Dict::updateIndexDef( // Allocate an ICD and link in - if (RC_BAD( rc = m_dictPool.poolCalloc( sizeof( ICD), + if (RC_BAD( rc = m_pDictPool->poolCalloc( sizeof( ICD), (void **)&pIcd))) { goto Exit; @@ -6698,7 +6723,7 @@ Get_Sibling: // Discard the new IXD, it is not needed. - m_dictPool.poolReset( pvMark); + m_pDictPool->poolReset( pvMark); } else { @@ -6810,7 +6835,7 @@ Exit: if (RC_BAD( rc)) { - m_dictPool.poolReset( pvMark); + m_pDictPool->poolReset( pvMark); } return( rc); @@ -7047,7 +7072,7 @@ RCODE F_Dict::updateCollectionDef( // Allocate a new collection - if (RC_BAD( rc = m_dictPool.poolCalloc( sizeof( F_COLLECTION), + if (RC_BAD( rc = m_pDictPool->poolCalloc( sizeof( F_COLLECTION), (void **)&pCollection))) { goto Exit; @@ -7211,7 +7236,7 @@ RCODE F_Db::getPrefixDef( } uiBufferSize = sizeof( FLMUNICODE) * (uiPrefixLen + 1); - if( RC_BAD( rc = pDict->m_dictPool.poolAlloc( uiBufferSize, + if( RC_BAD( rc = pDict->m_pDictPool->poolAlloc( uiBufferSize, (void **)ppuzPrefixName))) { goto Exit; @@ -7313,7 +7338,7 @@ RCODE F_Dict::updatePrefixDef( F_PREFIX * pOldPrefix = NULL; FLMUNICODE * puzPrefixName = NULL; FLMUINT uiTmp; - void * pvMark = m_dictPool.poolMark(); + void * pvMark = m_pDictPool->poolMark(); if (bOpeningDict) { @@ -7359,7 +7384,7 @@ RCODE F_Dict::updatePrefixDef( // Allocate a new prefix - if (RC_BAD( rc = m_dictPool.poolCalloc( sizeof( F_PREFIX), + if (RC_BAD( rc = m_pDictPool->poolCalloc( sizeof( F_PREFIX), (void **)&pPrefix))) { goto Exit; @@ -7419,7 +7444,7 @@ Exit: { if( pvMark) { - m_dictPool.poolReset( pvMark); + m_pDictPool->poolReset( pvMark); } } @@ -7520,7 +7545,7 @@ RCODE F_Db::getEncDefDef( } uiBufferSize = sizeof( FLMUNICODE) * (uiEncDefLen + 1); - if( RC_BAD( rc = pDict->m_dictPool.poolAlloc( uiBufferSize, + if( RC_BAD( rc = pDict->m_pDictPool->poolAlloc( uiBufferSize, (void **)ppuzEncDefName))) { goto Exit; @@ -7884,7 +7909,7 @@ RCODE F_Dict::updateEncDef( F_ENCDEF * pOldEncDef; FLMUNICODE * puzEncDefName = NULL; FLMUINT uiTmp; - void * pvMark = m_dictPool.poolMark(); + void * pvMark = m_pDictPool->poolMark(); F_CCS * pCcs = NULL; FLMUINT uiEncKeySize = 0; @@ -7938,7 +7963,7 @@ RCODE F_Dict::updateEncDef( { // Allocate a new encdef - if (RC_BAD( rc = m_dictPool.poolCalloc( sizeof( F_ENCDEF), + if (RC_BAD( rc = m_pDictPool->poolCalloc( sizeof( F_ENCDEF), (void **)&pEncDef))) { goto Exit; @@ -8006,7 +8031,7 @@ Exit: { if( pvMark) { - m_dictPool.poolReset( pvMark); + m_pDictPool->poolReset( pvMark); } } @@ -8199,7 +8224,7 @@ RCODE F_Dict::setupPredefined( // Allocate memory for the predefined collections - if (RC_BAD( rc = m_dictPool.poolCalloc( sizeof( F_COLLECTION) * 3, + if (RC_BAD( rc = m_pDictPool->poolCalloc( sizeof( F_COLLECTION) * 3, (void **)&m_pDictCollection))) { goto Exit; @@ -8220,7 +8245,7 @@ RCODE F_Dict::setupPredefined( // Allocate IXDs for the predefined indexes. - if (RC_BAD( rc = m_dictPool.poolCalloc( sizeof( IXD) * 2, + if (RC_BAD( rc = m_pDictPool->poolCalloc( sizeof( IXD) * 2, (void **)&m_pNameIndex))) { goto Exit; @@ -8273,7 +8298,7 @@ RCODE F_Dict::setupPredefined( // Set up the ICDs for the name index - if (RC_BAD( rc = m_dictPool.poolCalloc( sizeof( ICD) * 4, + if (RC_BAD( rc = m_pDictPool->poolCalloc( sizeof( ICD) * 4, (void **)&m_pNameIndex->pIcdTree))) { goto Exit; @@ -8368,7 +8393,7 @@ RCODE F_Dict::setupPredefined( // Set up the ICDs for the number index - if (RC_BAD( rc = m_dictPool.poolCalloc( sizeof( ICD) * 2, + if (RC_BAD( rc = m_pDictPool->poolCalloc( sizeof( ICD) * 2, (void **)&m_pNumberIndex->pIcdTree))) { goto Exit; @@ -9228,7 +9253,7 @@ RCODE F_Db::dictReadLFH( void) RCODE rc = NE_XFLM_OK; LFILE * pLFile; F_COLLECTION * pCollection; - F_CachedBlock * pSCache; + F_CachedBlock * pSCache = NULL; FLMBOOL bReleaseCache = FALSE; F_BLK_HDR * pBlkHdr; FLMUINT uiBlkAddress; @@ -9709,6 +9734,11 @@ RCODE F_Db::dictOpen( void) rc = RC_SET( NE_XFLM_MEM); goto Exit; } + + if( RC_BAD( rc = m_pDict->setup())) + { + goto Exit; + } // Allocate the name table @@ -9870,7 +9900,7 @@ RCODE F_Db::dictCreate( char * pszXMLBuffer = NULL; FLMUINT64 ui64FileSize; FLMUINT uiBytesRead; - F_BufferIStream stream; + IF_BufferIStream * pStream = NULL; // This should never be called for a temporary database. @@ -9925,8 +9955,8 @@ RCODE F_Db::dictCreate( if (!pszDictBuf && pszDictPath) { - if (RC_BAD( rc = gv_pFileSystem->Open( - pszDictPath, XFLM_IO_RDONLY, &pDictFileHdl))) + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->openFile( + pszDictPath, FLM_IO_RDONLY, &pDictFileHdl))) { goto Exit; } @@ -9934,7 +9964,7 @@ RCODE F_Db::dictCreate( // Get the file size and allocate a buffer to hold the entire thing. - if (RC_BAD( rc = pDictFileHdl->Size( &ui64FileSize))) + if (RC_BAD( rc = pDictFileHdl->size( &ui64FileSize))) { goto Exit; } @@ -9948,7 +9978,7 @@ RCODE F_Db::dictCreate( // Read the entire file into the buffer - if (RC_BAD( rc = pDictFileHdl->Read( 0, (FLMUINT)ui64FileSize, + if (RC_BAD( rc = pDictFileHdl->read( 0, (FLMUINT)ui64FileSize, pszXMLBuffer, &uiBytesRead))) { goto Exit; @@ -9970,13 +10000,18 @@ RCODE F_Db::dictCreate( // and calls documentDone when the document is complete. // The documentDone method checks the dictionary syntax, // adds to the dictionary, etc. - - if (RC_BAD( rc = stream.open( (FLMBYTE *)pszDictBuf, 0))) + + if( RC_BAD( rc = FlmAllocBufferIStream( &pStream))) { goto Exit; } - if (RC_BAD( import( &stream, XFLM_DICT_COLLECTION))) + if (RC_BAD( rc = pStream->open( pszDictBuf, 0))) + { + goto Exit; + } + + if (RC_BAD( import( pStream, XFLM_DICT_COLLECTION))) { goto Exit; } @@ -9985,17 +10020,22 @@ RCODE F_Db::dictCreate( Exit: - if (bFileOpen) + if( pStream) { - pDictFileHdl->Close(); + pStream->Release(); } - if (pDictFileHdl) + if( bFileOpen) + { + pDictFileHdl->close(); + } + + if( pDictFileHdl) { pDictFileHdl->Release(); } - if (pszXMLBuffer) + if( pszXMLBuffer) { f_free( pszXMLBuffer); } diff --git a/xflaim/src/fdict.h b/xflaim/src/fdict.h index 8a1febb..72bb635 100644 --- a/xflaim/src/fdict.h +++ b/xflaim/src/fdict.h @@ -38,7 +38,6 @@ struct IXD; struct ICD; class F_Database; -class F_Pool; class F_CCS; class F_AttrItem; @@ -84,7 +83,7 @@ typedef struct ExtAttrElmDef /***************************************************************************** Desc: Dictionary definition info object *****************************************************************************/ -class F_AttrElmInfo : public XF_RefCount, public XF_Base +class F_AttrElmInfo : public F_Object { public: @@ -212,10 +211,10 @@ typedef struct LFILE FLMUINT uiRootBlk; // Address of root block. FLMUINT uiBlkAddress; // Block address of LFile entry. - FLMUINT uiOffsetInBlk; // Offset within block of entry. - FLMUINT uiLfNum; // Index number or collection number. - eLFileType eLfType; // Type of logical file - FLMUINT uiEncId; // Encryption Id (0 if not encrypted) + FLMUINT uiOffsetInBlk; // Offset within block of entry. + FLMUINT uiLfNum; // Index number or collection number. + eLFileType eLfType; // Type of logical file + FLMUINT uiEncId; // Encryption Id (0 if not encrypted) } LFILE; /**************************************************************************** @@ -402,7 +401,7 @@ typedef struct ReservedTag /************************************************************************** Desc: This class is the FLAIM dictionary class. **************************************************************************/ -class F_Dict : public XF_RefCount, public XF_Base +class F_Dict : public F_Object { public: @@ -411,6 +410,8 @@ public: F_Dict(); ~F_Dict(); + + RCODE setup( void); void resetDict( void); @@ -924,7 +925,7 @@ private: // to a database. FLMUINT m_uiDictSeq; // This is the sequence number of the // dictionary - F_Pool m_dictPool; // Pool for all allocations except tables. + IF_Pool * m_pDictPool; // Pool for all allocations except tables. // Fixed element definition table - used for elements whose tag numbers // are less than or equal to FLM_HIGH_FIXED_ELEMENT_NUM diff --git a/xflaim/src/fdir.h b/xflaim/src/fdir.h deleted file mode 100644 index f6982da..0000000 --- a/xflaim/src/fdir.h +++ /dev/null @@ -1,157 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: This interface encapsulates the concept of a file system directory. -// -// Tabs: 3 -// -// Copyright (c) 1998-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: fdir.h 3108 2006-01-19 13:05:19 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#ifndef FDIR_H -#define FDIR_H - -class F_DirHdl; - -#if defined( FLM_WIN) - - typedef struct - { - HANDLE findHandle; - WIN32_FIND_DATA findBuffer; - char szSearchPath[ F_PATH_MAX_SIZE]; - FLMUINT uiSearchAttrib; - } F_IO_FIND_DATA; - - #define XF_IO_FA_NORMAL FILE_ATTRIBUTE_NORMAL // Normal file - #define XF_IO_FA_RDONLY FILE_ATTRIBUTE_READONLY // Read only attribute - #define XF_IO_FA_HIDDEN FILE_ATTRIBUTE_HIDDEN // Hidden file - #define XF_IO_FA_SYSTEM FILE_ATTRIBUTE_SYSTEM // System file - #define XF_IO_FA_VOLUME FILE_ATTRIBUTE_VOLUME // Volume label - #define XF_IO_FA_DIRECTORY FILE_ATTRIBUTE_DIRECTORY // Directory - #define XF_IO_FA_ARCHIVE FILE_ATTRIBUTE_ARCHIVE // Archive - -#elif defined( FLM_UNIX) || defined( FLM_NLM) - - typedef struct _DirInfo - { - mode_t mode_flag; - struct stat FileStat; - char name[ F_PATH_MAX_SIZE+1]; - char search_path[ F_PATH_MAX_SIZE+1]; - char full_path[ F_PATH_MAX_SIZE]; - char pattern_str[ F_PATH_MAX_SIZE]; - char dirpath[ F_PATH_MAX_SIZE]; - glob_t globbuf; - } F_IO_FIND_DATA; - - #define XF_IO_FA_NORMAL 0x01 // Normal file, no attributes - #define XF_IO_FA_RDONLY 0x02 // Read only attribute - #define XF_IO_FA_HIDDEN 0x04 // Hidden file - #define XF_IO_FA_SYSTEM 0x08 // System file - #define XF_IO_FA_VOLUME 0x10 // Volume label - #define XF_IO_FA_DIRECTORY 0x20 // Directory - #define XF_IO_FA_ARCHIVE 0x40 // Archive - -#else - #error Platform not supported -#endif - -RCODE f_fileFindFirst( - char * pszSearchPath, - FLMUINT uiSearchAttrib, - F_IO_FIND_DATA * find_data, - char * pszFoundPath, - FLMUINT * puiFoundAttrib); - -RCODE f_fileFindNext( - F_IO_FIND_DATA * pFindData, - char * pszFoundPath, - FLMUINT * puiFoundAttrib); - -void f_fileFindClose( - F_IO_FIND_DATA * pFindData); - -/**************************************************************************** -Class: F_Dir -Desc: Implementation of the F_Directory interface for Win32 and Unix -****************************************************************************/ -class F_DirHdl : public IF_DirHdl, public XF_Base -{ -public: - - F_DirHdl(); - - virtual ~F_DirHdl() - { - - if( m_bFindOpen) - { - f_fileFindClose( &m_FindData); - } - } - - /*-- Iteration Methods ---------------------------------------------------*/ - /* Methods to enumerate the contents of a directory. */ - - RCODE XFLMAPI Next( void); // Set the iteration cursor to the next - // item in the directory - - /* --- Methods for accessing the current item (that the cursor is on) ----*/ - - const char * XFLMAPI CurrentItemName( void); - - FINLINE void XFLMAPI CurrentItemPath( - char * pszPath) - { - if( RC_OK( m_rc)) - { - f_strcpy( pszPath, m_szDirectoryPath); - gv_pFileSystem->pathAppend( pszPath, m_szFileName); - } - } - - FLMUINT64 XFLMAPI CurrentItemSize( void); - - FLMBOOL XFLMAPI CurrentItemIsDir( void); - - RCODE XFLMAPI OpenDir( // Open directory - const char * pszDirName, // Directory to be opened. - const char * pszPattern); // File name pattern. - - RCODE XFLMAPI CreateDir( // Create a directory. - const char * pszDirName); // Name of directory to be created. - - RCODE XFLMAPI RemoveDir( // Remove a directory - const char * pszDirPath); // Name of directory to be removed - -private: - - char m_szDirectoryPath[ F_PATH_MAX_SIZE]; // Path to directory - char m_szPattern[ F_PATH_MAX_SIZE]; // Pattern for matching - FLMUINT32 m_ui32RefCount; - RCODE m_rc; - FLMBOOL m_bFirstTime; // Indicates whether to use FindFirst or FindNext - FLMBOOL m_bFindOpen; // Indicates if need to call f_fileFindClose - FLMBOOL m_EOF; // Indicates if EndOfDirectory has been reached - char m_szFileName[ F_PATH_MAX_SIZE]; // Next item found in directory - FLMUINT m_uiAttrib; - F_IO_FIND_DATA m_FindData; -}; - -#endif // #ifndef FDIR_H diff --git a/xflaim/src/fdllmain.cpp b/xflaim/src/fdllmain.cpp index e2e7e75..3c3e146 100644 --- a/xflaim/src/fdllmain.cpp +++ b/xflaim/src/fdllmain.cpp @@ -24,45 +24,25 @@ //------------------------------------------------------------------------------ #include "flaimsys.h" -#include "fcomfact.h" static F_DbSystem * gv_pDbSystem = NULL; static FLMATOMIC gv_lockCount = 0; -XFLMEXTC RCODE XFLMAPI DllCanUnloadNow( void); - -XFLMEXTC RCODE XFLMAPI DllGetClassObject( - RXFLMCLSID rclsid, - RXFLMIID riid, - void ** ppv); - -XFLMEXTC RCODE XFLMAPI DllStart( void); - -XFLMEXTC RCODE XFLMAPI DllStop( void); +FLMEXTC RCODE FLMAPI DllCanUnloadNow( void); +FLMEXTC RCODE FLMAPI DllStart( void); +FLMEXTC RCODE FLMAPI DllStop( void); #if defined( FLM_UNIX) -#ifdef __GNUC__ - void __attribute__ ((constructor)) flaim_init( void) {} - void __attribute__ ((destructor)) flaim_fini( void) {} -#elif !defined( FLM_SOLARIS) - extern "C" void _init(void) {} - extern "C" void _fini(void) {} -#endif - #elif defined( FLM_WIN) #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif - static HMODULE s_module; - #pragma comment(linker, "/export:DllCanUnloadNow=_DllCanUnloadNow@0,PRIVATE") - #pragma comment(linker, "/export:DllGetClassObject=_DllGetClassObject@12,PRIVATE") #pragma comment(linker, "/export:DllStart=_DllStart@0,PRIVATE") #pragma comment(linker, "/export:DllStop=_DllStop@0,PRIVATE") - #pragma comment(linker, "/export:_XTCOM_Table,DATA") #elif !defined( FLM_NLM) #error platform not supported. @@ -73,7 +53,7 @@ Desc: ******************************************************************************/ void LockModule(void) { - flmAtomicInc( &gv_lockCount); + f_atomicInc( &gv_lockCount); } /****************************************************************************** @@ -81,14 +61,14 @@ Desc: ******************************************************************************/ void UnlockModule(void) { - flmAtomicDec( &gv_lockCount); + f_atomicDec( &gv_lockCount); } /****************************************************************************** Desc: Returns 0 if it's okay to unload, or a non-zero status code if not. ******************************************************************************/ -XFLMEXTC RCODE XFLMAPI DllCanUnloadNow( void) +FLMEXTC RCODE FLMAPI DllCanUnloadNow( void) { RCODE rc = NE_XFLM_OK; @@ -100,12 +80,8 @@ XFLMEXTC RCODE XFLMAPI DllCanUnloadNow( void) } else { - // gv_lockCount should be 1 because gv_pDbSystem is non-null. - flmAssert( gv_lockCount == 1); - // Check for open databases - f_mutexLock( gv_XFlmSysData.hShareMutex); if (gv_XFlmSysData.pDatabaseHashTbl) @@ -131,35 +107,14 @@ XFLMEXTC RCODE XFLMAPI DllCanUnloadNow( void) return( rc); } -/****************************************************************************** -Desc: Returns the desired interface to the class object for - the specified service class. -******************************************************************************/ -XFLMEXTC RCODE XFLMAPI DllGetClassObject( - RXFLMCLSID rclsid, - RXFLMIID riid, - void ** ppv) -{ - static F_DbSystemFactory gv_DbSysFactory; - - if( f_memcmp( &rclsid, &Internal_CLSID_F_DbSystemFactory, - sizeof( Internal_CLSID_F_DbSystemFactory)) == 0) - { - return( gv_DbSysFactory.QueryInterface( riid, ppv)); - } - - *ppv = NULL; - return( RC_SET( NE_XFLM_CLASS_NOT_AVAILABLE)); -} - /****************************************************************************** Desc: Called by PSA when it loads the library. Must return 0 for success, or a non-zero error code. ******************************************************************************/ -XFLMEXTC RCODE XFLMAPI DllStart( void) +FLMEXTC RCODE FLMAPI DllStart( void) { RCODE rc = NE_XFLM_OK; - + if( (gv_pDbSystem = f_new F_DbSystem) == NULL) { rc = NE_XFLM_MEM; @@ -189,7 +144,7 @@ Exit: Desc: Called by PSA when it unloads the library. The return value is ignored. ******************************************************************************/ -XFLMEXTC RCODE XFLMAPI DllStop( void) +FLMEXTC RCODE FLMAPI DllStop( void) { if( gv_pDbSystem) { @@ -206,7 +161,7 @@ XFLMEXTC RCODE XFLMAPI DllStop( void) /****************************************************************************** Desc: ******************************************************************************/ -XFLMEXTC RCODE XFLMAPI DllRegisterServer( +FLMEXTC RCODE FLMAPI DllRegisterServer( const char *) { return( NE_XFLM_OK); @@ -215,16 +170,7 @@ XFLMEXTC RCODE XFLMAPI DllRegisterServer( /****************************************************************************** Desc: ******************************************************************************/ -XFLMEXTC RCODE XFLMAPI DllUnregisterServer( void) +FLMEXTC RCODE FLMAPI DllUnregisterServer( void) { return( NE_XFLM_OK); } - -/****************************************************************************** -Desc: This is an array of all the CLSID's that XFlaim implements. -******************************************************************************/ -extern "C" const XFLMCLSID * XTCOM_Table[] = -{ - &Internal_CLSID_F_DbSystemFactory, - 0 -}; diff --git a/xflaim/src/fdom.cpp b/xflaim/src/fdom.cpp index 1219ee8..fe14ba7 100644 --- a/xflaim/src/fdom.cpp +++ b/xflaim/src/fdom.cpp @@ -25,10 +25,6 @@ #include "flaimsys.h" -// External data - -extern FLMBYTE gv_ucSENLengthArray[]; - // Local constants #define SEN_RESERVE_BYTES 5 @@ -56,7 +52,7 @@ FINLINE RCODE F_Db::attrIsInIndexDef( Desc: This class converts a text stream of Unicode or UTF8 to an ASCII text stream. ******************************************************************************/ -class F_AsciiIStream : public IF_IStream, public XF_Base +class F_AsciiIStream : public IF_IStream { public: @@ -84,12 +80,12 @@ public: { } - RCODE XFLMAPI read( + RCODE FLMAPI read( void * pvBuffer, FLMUINT uiBytesToRead, FLMUINT * puiBytesRead); - FINLINE RCODE XFLMAPI close( void) + FINLINE RCODE FLMAPI close( void) { return( NE_XFLM_OK); } @@ -106,7 +102,7 @@ private: /***************************************************************************** Desc: ******************************************************************************/ -FLMINT XFLMAPI F_BTreeIStream::Release( void) +FLMINT FLMAPI F_BTreeIStream::Release( void) { FLMATOMIC refCnt = --m_refCnt; @@ -203,7 +199,7 @@ Exit: /**************************************************************************** Desc: ****************************************************************************/ -FLMINT XFLMAPI F_DOMNode::Release( void) +FLMINT FLMAPI F_DOMNode::Release( void) { FLMINT iRefCnt = --m_refCnt; @@ -945,7 +941,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getDataLength( +RCODE FLMAPI F_DOMNode::getDataLength( IF_Db * ifpDb, FLMUINT * puiLength) { @@ -1019,7 +1015,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::insertBefore( +RCODE FLMAPI F_DOMNode::insertBefore( IF_Db * ifpDb, IF_DOMNode * ifpNewChild, IF_DOMNode * ifpRefChild) @@ -1873,9 +1869,9 @@ RCODE F_DOMNode::setNumber64( f_i64toa( i64Value, (char *)&ucNumBuf[ 1]); } - uiValLen = f_strlen( ucNumBuf); + uiValLen = f_strlen( (const char *)ucNumBuf); pucSen = &ucNumBuf[ 0]; - uiSenLen = flmEncodeSEN( uiValLen, &pucSen, (FLMUINT)0); + uiSenLen = f_encodeSEN( uiValLen, &pucSen, (FLMUINT)0); flmAssert( uiSenLen == 1); uiValLen += uiSenLen + 1; @@ -2301,19 +2297,11 @@ RCODE F_CachedNode::openPendingInput( flmAssert( m_ui64LowTransId == pDb->m_ui64CurrTransID); -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif - m_nodeInfo.uiDataLength = 0; m_nodeInfo.uiDataType = uiNewDataType; unsetFlags( FDOM_UNSIGNED_QUICK_VAL | FDOM_SIGNED_QUICK_VAL); setFlags( FDOM_VALUE_ON_DISK | FDOM_FIXED_SIZE_HEADER); -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif - flmAssert( !pDatabase->m_uiUpdByteCount); flmAssert( !pDatabase->m_uiUpdCharCount); @@ -2345,10 +2333,6 @@ RCODE F_CachedNode::flushPendingInput( FLMUINT uiOutputLength; FLMUINT uiLeftoverLength; -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif - uiKeyLen = sizeof( ucKey); if( RC_BAD( rc = flmNumber64ToStorage( m_nodeInfo.ui64NodeId, &uiKeyLen, ucKey, FALSE, TRUE))) @@ -2553,10 +2537,6 @@ RCODE F_CachedNode::flushPendingInput( Exit: -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif - if( RC_BAD( rc)) { pDb->setMustAbortTrans( rc); @@ -2568,7 +2548,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::setMetaValue( +RCODE FLMAPI F_DOMNode::setMetaValue( IF_Db * ifpDb, FLMUINT64 ui64Value) { @@ -2671,7 +2651,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getMetaValue( +RCODE FLMAPI F_DOMNode::getMetaValue( IF_Db * ifpDb, FLMUINT64 * pui64Value) { @@ -2705,7 +2685,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::isDataLocalToNode( +RCODE FLMAPI F_DOMNode::isDataLocalToNode( IF_Db * ifpDb, FLMBOOL * pbDataIsLocal) { @@ -2779,7 +2759,7 @@ RCODE F_AsciiIStream::read( } else // UTF8 { - if( RC_BAD( rc = flmGetCharFromUTF8Buf( + if( RC_BAD( rc = f_getCharFromUTF8Buf( &m_pucCurrPtr, m_pucEnd, &uzChar))) { goto Exit; @@ -2818,7 +2798,7 @@ Exit: Desc: This class converts a storage text stream to an ASCII text stream. ******************************************************************************/ -class F_AsciiStorageStream : public IF_IStream, public XF_Base +class F_AsciiStorageStream : public IF_IStream { public: @@ -2832,12 +2812,12 @@ public: close(); } - RCODE XFLMAPI read( + RCODE FLMAPI read( void * pvBuffer, FLMUINT uiBytesToRead, FLMUINT * puiBytesRead); - FINLINE RCODE XFLMAPI close( void) + FINLINE RCODE FLMAPI close( void) { if( m_pIStream) { @@ -2883,7 +2863,7 @@ RCODE F_AsciiStorageStream::open( goto Exit; } - if( (uiSENLen = flmGetSENLength( ucSENBuf[ 0])) > 1) + if( (uiSENLen = f_getSENLength( ucSENBuf[ 0])) > 1) { uiLen = uiSENLen - 1; if( RC_BAD( rc = m_pIStream->read( @@ -2925,7 +2905,7 @@ RCODE F_AsciiStorageStream::read( while( uiBytesRead < uiBytesToRead) { - if( RC_BAD( rc = flmReadUTF8CharAsUnicode( m_pIStream, &uzChar))) + if( RC_BAD( rc = f_readUTF8CharAsUnicode( m_pIStream, &uzChar))) { if( rc == NE_XFLM_EOF_HIT) { @@ -2971,7 +2951,7 @@ Exit: Desc: This class converts a binary stream to an ASCII text storage stream. ******************************************************************************/ -class F_BinaryToTextStream : public IF_IStream, public XF_Base +class F_BinaryToTextStream : public IF_IStream { public: @@ -2985,12 +2965,12 @@ public: close(); } - RCODE XFLMAPI read( + RCODE FLMAPI read( void * pvBuffer, FLMUINT uiBytesToRead, FLMUINT * puiBytesRead); - FINLINE RCODE XFLMAPI close( void) + FINLINE RCODE FLMAPI close( void) { if( m_pEncoderStream) { @@ -3008,10 +2988,10 @@ public: private: - FLMBYTE m_ucSENBuf [16]; - FLMUINT m_uiSENLen; - FLMUINT m_uiCurrOffset; - F_Base64EncoderIStream * m_pEncoderStream; + FLMBYTE m_ucSENBuf [16]; + FLMUINT m_uiSENLen; + FLMUINT m_uiCurrOffset; + IF_IStream * m_pEncoderStream; }; /***************************************************************************** @@ -3042,7 +3022,7 @@ RCODE F_BinaryToTextStream::open( } pucSen = &m_ucSENBuf [0]; - m_uiSENLen = flmEncodeSEN( (FLMUINT64)uiOutputLen, &pucSen, (FLMUINT)0); + m_uiSENLen = f_encodeSEN( (FLMUINT64)uiOutputLen, &pucSen, (FLMUINT)0); m_uiCurrOffset = 0; // Need to include the data length, SEN length, and the terminating null @@ -3052,13 +3032,8 @@ RCODE F_BinaryToTextStream::open( // Set up the encoder stream - if( (m_pEncoderStream = f_new F_Base64EncoderIStream) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = m_pEncoderStream->open( pIStream, FALSE))) + if( RC_BAD( rc = FlmOpenBase64EncoderIStream( pIStream, + FALSE, &m_pEncoderStream))) { goto Exit; } @@ -3294,23 +3269,24 @@ RCODE F_DOMNode::storeTextAsBinary( FLMUINT uiNumBytesInBuffer, FLMUINT uiEncDefId) { - RCODE rc = NE_XFLM_OK; - FLMBYTE ucBuf[ 64]; - F_AsciiIStream asciiStream( (FLMBYTE *)pvValue, + RCODE rc = NE_XFLM_OK; + FLMBYTE ucBuf[ 64]; + F_AsciiIStream asciiStream( (FLMBYTE *)pvValue, uiNumBytesInBuffer, XFLM_UTF8_TEXT); - F_Base64DecoderIStream decoderStream; - FLMBYTE ucDynaBuf[ 64]; - F_DynaBuf dynaBuf( ucDynaBuf, sizeof( ucDynaBuf)); - FLMUINT uiBytesRead; + IF_IStream * pDecoderStream = NULL; + FLMBYTE ucDynaBuf[ 64]; + F_DynaBuf dynaBuf( ucDynaBuf, sizeof( ucDynaBuf)); + FLMUINT uiBytesRead; - if( RC_BAD( rc = decoderStream.open( &asciiStream))) + if( RC_BAD( rc = FlmOpenBase64DecoderIStream( + &asciiStream, &pDecoderStream))) { goto Exit; } - + for( ;;) { - if( RC_BAD( rc = decoderStream.read( ucBuf, sizeof( ucBuf), &uiBytesRead))) + if( RC_BAD( rc = pDecoderStream->read( ucBuf, sizeof( ucBuf), &uiBytesRead))) { if( rc != NE_XFLM_EOF_HIT) { @@ -3336,6 +3312,11 @@ RCODE F_DOMNode::storeTextAsBinary( Exit: + if( pDecoderStream) + { + pDecoderStream->Release(); + } + return( rc); } @@ -3350,25 +3331,27 @@ RCODE F_DOMNode::storeBinaryAsText( { RCODE rc = NE_XFLM_OK; FLMBYTE ucBuf[ 64]; - F_BufferIStream bufferStream; - F_Base64EncoderIStream encoderStream; + IF_PosIStream * pIStream = NULL; + IF_IStream * pEncoderStream = NULL; FLMBYTE ucDynaBuf[ 64]; F_DynaBuf dynaBuf( ucDynaBuf, sizeof( ucDynaBuf)); FLMUINT uiBytesRead; - if( RC_BAD( rc = bufferStream.open( (FLMBYTE *)pvValue, uiLength))) + if( RC_BAD( rc = FlmOpenBufferIStream( + (const char *)pvValue, uiLength, &pIStream))) { goto Exit; } - - if( RC_BAD( rc = encoderStream.open( &bufferStream, FALSE))) + + if( RC_BAD( rc = FlmOpenBase64EncoderIStream( pIStream, + FALSE, &pEncoderStream))) { goto Exit; } for( ;;) { - if( RC_BAD( rc = encoderStream.read( + if( RC_BAD( rc = pEncoderStream->read( ucBuf, sizeof( ucBuf), &uiBytesRead))) { if( rc != NE_XFLM_EOF_HIT) @@ -3394,6 +3377,16 @@ RCODE F_DOMNode::storeBinaryAsText( Exit: + if( pEncoderStream) + { + pEncoderStream->Release(); + } + + if( pIStream) + { + pIStream->Release(); + } + return( rc); } @@ -3607,7 +3600,7 @@ RCODE F_DOMNode::setTextStreaming( while( *puCurChar && uiNumBytesInBuffer >= sizeof( FLMUNICODE)) { uiLen = uiUpdBufferSize - pDatabase->m_uiUpdByteCount; - if( RC_BAD( rc = flmUni2UTF8( *puCurChar, + if( RC_BAD( rc = f_uni2UTF8( *puCurChar, &pucUpdBuffer[ pDatabase->m_uiUpdByteCount], &uiLen))) { if( rc == NE_XFLM_CONV_DEST_OVERFLOW) @@ -3646,7 +3639,7 @@ RCODE F_DOMNode::setTextStreaming( } } - if( RC_BAD( rc = flmGetUTF8CharFromUTF8Buf( &pucCurByte, + if( RC_BAD( rc = f_getUTF8CharFromUTF8Buf( &pucCurByte, pucEnd, &pucUpdBuffer[ pDatabase->m_uiUpdByteCount], &uiLen))) { goto Exit; @@ -3704,7 +3697,7 @@ RCODE F_DOMNode::setTextStreaming( // output a padded SEN. pucTmp = ucTmpSen; - flmEncodeSEN( pDatabase->m_uiUpdCharCount, &pucTmp); + f_encodeSEN( pDatabase->m_uiUpdCharCount, &pucTmp); uiSenLen = (FLMUINT)(pucTmp - ucTmpSen); // Copy the value into the node @@ -3760,7 +3753,7 @@ RCODE F_DOMNode::setTextStreaming( } pucTmp = ucTmpSen; - flmEncodeSEN( pDatabase->m_uiUpdCharCount, + f_encodeSEN( pDatabase->m_uiUpdCharCount, &pucTmp, SEN_RESERVE_BYTES); flmAssert( (FLMUINT)(pucTmp - ucTmpSen) == SEN_RESERVE_BYTES); @@ -3941,7 +3934,7 @@ RCODE F_DOMNode::setTextFastPath( else { uiReadLen = sizeof( ucUTFCharBuf); - if( RC_BAD( rc = flmUni2UTF8( *puCurChar, + if( RC_BAD( rc = f_uni2UTF8( *puCurChar, ucUTFCharBuf, &uiReadLen))) { goto Exit; @@ -3970,7 +3963,7 @@ RCODE F_DOMNode::setTextFastPath( } else if( eTextType == XFLM_UTF8_TEXT) { - if( RC_BAD( rc = flmGetUTF8Length( (FLMBYTE *)pvValue, uiNumBytesInBuffer, + if( RC_BAD( rc = f_getUTF8Length( (FLMBYTE *)pvValue, uiNumBytesInBuffer, &uiNumBytesInBuffer, &uiNumCharsInBuffer))) { goto Exit; @@ -4144,7 +4137,7 @@ RCODE F_DOMNode::setTextFastPath( bNullTerminate = TRUE; } - uiSenLen = flmGetSENByteCount( uiNumCharsInBuffer); + uiSenLen = f_getSENByteCount( uiNumCharsInBuffer); uiValLen = uiNumBytesInBuffer + uiSenLen + (bNullTerminate ? 1 : 0); if( calcDataBufSize( uiValLen) > getDataBufSize()) @@ -4156,7 +4149,7 @@ RCODE F_DOMNode::setTextFastPath( } pucTmp = getDataPtr(); - flmEncodeSENKnownLength( uiNumCharsInBuffer, uiSenLen, &pucTmp); + f_encodeSENKnownLength( uiNumCharsInBuffer, uiSenLen, &pucTmp); f_memcpy( pucTmp, pucValue, uiNumBytesInBuffer); if( bNullTerminate) @@ -4940,7 +4933,7 @@ RCODE F_CachedNode::getIStream( FLMUINT * puiDataLength) { RCODE rc = NE_XFLM_OK; - F_PosIStream * pIStream = NULL; + IF_PosIStream * pIStream = NULL; F_DOMNode * pNode = NULL; F_CachedNode * pCachedNode = this; eDomNodeType eNodeType = getNodeType(); @@ -5067,8 +5060,9 @@ RCODE F_CachedNode::getIStream( pIStream = pNodeBufferIStream; - if( RC_BAD( rc = pNodeBufferIStream->open( pCachedNode->getDataPtr(), - pCachedNode->getDataLength()))) + if( RC_BAD( rc = pNodeBufferIStream->open( + (const char *)pCachedNode->getDataPtr(), + pCachedNode->getDataLength()))) { goto Exit; } @@ -5119,7 +5113,7 @@ RCODE F_CachedNode::getRawIStream( IF_PosIStream ** ppIStream) { RCODE rc = NE_XFLM_OK; - F_PosIStream * pIStream = NULL; + IF_PosIStream * pIStream = NULL; F_BTreeIStream * pBTreeIStream; eDomNodeType eNodeType = getNodeType(); @@ -5296,7 +5290,7 @@ RCODE F_DOMNode::getTextIStream( if( (*ppIStream)->remainingSize()) { - if( RC_BAD( rc = flmReadSEN( *ppIStream, puiNumChars))) + if( RC_BAD( rc = f_readSEN( *ppIStream, puiNumChars))) { goto Exit; } @@ -5419,7 +5413,7 @@ Exit: /***************************************************************************** Desc: Allocate data for a unicode element and retrieve it. *****************************************************************************/ -RCODE XFLMAPI F_DOMNode::getUnicode( +RCODE FLMAPI F_DOMNode::getUnicode( IF_Db * ifpDb, FLMUNICODE ** ppuzUnicode) { @@ -5481,7 +5475,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getUnicode( +RCODE FLMAPI F_DOMNode::getUnicode( IF_Db * ifpDb, FLMUNICODE * puzBuffer, FLMUINT uiBufSize, @@ -5544,7 +5538,7 @@ Exit: /***************************************************************************** Desc: *****************************************************************************/ -RCODE XFLMAPI F_DOMNode::getUnicode( +RCODE FLMAPI F_DOMNode::getUnicode( IF_Db * ifpDb, IF_DynaBuf * pBuffer) { @@ -5593,7 +5587,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getUTF8( +RCODE FLMAPI F_DOMNode::getUTF8( IF_Db * ifpDb, FLMBYTE * pszValue, FLMUINT uiBufferSize, @@ -5702,7 +5696,7 @@ SlowDecode: if( pucBuffer) { - if( RC_BAD( rc = flmDecodeSEN( &pucBuffer, pucEnd, &uiCharCount))) + if( RC_BAD( rc = f_decodeSEN( &pucBuffer, pucEnd, &uiCharCount))) { goto Exit; } @@ -5762,7 +5756,7 @@ Exit: /***************************************************************************** Desc: *****************************************************************************/ -RCODE XFLMAPI F_DOMNode::getUTF8( +RCODE FLMAPI F_DOMNode::getUTF8( IF_Db * ifpDb, FLMBYTE ** ppszUTF8) { @@ -5814,7 +5808,7 @@ Exit: /***************************************************************************** Desc: *****************************************************************************/ -RCODE XFLMAPI F_DOMNode::getUTF8( +RCODE FLMAPI F_DOMNode::getUTF8( IF_Db * ifpDb, IF_DynaBuf * pBuffer) { @@ -5862,7 +5856,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getBinary( +RCODE FLMAPI F_DOMNode::getBinary( IF_Db * ifpDb, void * pvValue, FLMUINT uiByteOffset, @@ -5872,6 +5866,7 @@ RCODE XFLMAPI F_DOMNode::getBinary( RCODE rc = NE_XFLM_OK; FLMBYTE * pucValue = (FLMBYTE *)pvValue; IF_PosIStream * pIStream = NULL; + IF_IStream * pDecoderStream = NULL; F_NodeBufferIStream bufferIStream; F_Db * pDb = (F_Db *)ifpDb; FLMUINT uiTmp; @@ -5928,15 +5923,14 @@ RCODE XFLMAPI F_DOMNode::getBinary( } else { - F_Base64DecoderIStream decoderStream; - - if( RC_BAD( rc = decoderStream.open( &asciiStream))) + if( RC_BAD( rc = FlmOpenBase64DecoderIStream( + &asciiStream, &pDecoderStream))) { goto Exit; } - + if( RC_BAD( rc = flmReadStorageAsBinary( - &decoderStream, (FLMBYTE *)pucValue, + pDecoderStream, (FLMBYTE *)pucValue, uiBytesRequested, uiByteOffset, puiBytesReturned))) { goto Exit; @@ -5955,6 +5949,11 @@ RCODE XFLMAPI F_DOMNode::getBinary( Exit: + if( pDecoderStream) + { + pDecoderStream->Release(); + } + if( pIStream) { pIStream->Release(); @@ -5971,7 +5970,7 @@ Exit: /***************************************************************************** Desc: *****************************************************************************/ -RCODE XFLMAPI F_DOMNode::getBinary( +RCODE FLMAPI F_DOMNode::getBinary( IF_Db * ifpDb, IF_DynaBuf * pBuffer) { @@ -6117,7 +6116,7 @@ RCODE F_DOMNode::getAttributeValueText( if( pucStart) { - if( RC_BAD( rc = flmDecodeSEN( &pucStart, pucEnd, &uiCharCount))) + if( RC_BAD( rc = f_decodeSEN( &pucStart, pucEnd, &uiCharCount))) { goto Exit; } @@ -6182,7 +6181,7 @@ Exit: /***************************************************************************** Desc: *****************************************************************************/ -RCODE XFLMAPI F_DOMNode::getAttributeValueUnicode( +RCODE FLMAPI F_DOMNode::getAttributeValueUnicode( IF_Db * ifpDb, FLMUINT uiAttrName, IF_DynaBuf * pBuffer) @@ -6218,7 +6217,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getAttributeValueUnicode( +RCODE FLMAPI F_DOMNode::getAttributeValueUnicode( IF_Db * ifpDb, FLMUINT uiAttrName, FLMUNICODE ** ppuzUnicode) @@ -6258,7 +6257,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getAttributeValueUTF8( +RCODE FLMAPI F_DOMNode::getAttributeValueUTF8( IF_Db * ifpDb, FLMUINT uiAttrName, FLMBYTE ** ppszValue) @@ -6298,7 +6297,7 @@ Exit: /***************************************************************************** Desc: *****************************************************************************/ -RCODE XFLMAPI F_DOMNode::getAttributeValueUTF8( +RCODE FLMAPI F_DOMNode::getAttributeValueUTF8( IF_Db * ifpDb, FLMUINT uiAttrName, IF_DynaBuf * pBuffer) @@ -6334,7 +6333,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getAttributeValueBinary( +RCODE FLMAPI F_DOMNode::getAttributeValueBinary( IF_Db * ifpDb, FLMUINT uiAttrName, void * pvValue, @@ -6380,7 +6379,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getAttributeValueBinary( +RCODE FLMAPI F_DOMNode::getAttributeValueBinary( IF_Db * ifpDb, FLMUINT uiAttrName, IF_DynaBuf * pBuffer) @@ -6554,7 +6553,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::setAttributeValueUnicode( +RCODE FLMAPI F_DOMNode::setAttributeValueUnicode( IF_Db * ifpDb, FLMUINT uiAttrName, const FLMUNICODE * puzValue, @@ -6618,7 +6617,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::setAttributeValueBinary( +RCODE FLMAPI F_DOMNode::setAttributeValueBinary( IF_Db * ifpDb, FLMUINT uiAttrName, const void * pvValue, @@ -6735,7 +6734,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::setAttributeValueUTF8( +RCODE FLMAPI F_DOMNode::setAttributeValueUTF8( IF_Db * ifpDb, FLMUINT uiAttrName, const FLMBYTE * pucValue, @@ -6793,7 +6792,7 @@ RCODE XFLMAPI F_DOMNode::setAttributeValueUTF8( bMustAbortOnError = TRUE; - if( RC_BAD( rc = flmGetUTF8Length( pucValue, uiLength, + if( RC_BAD( rc = f_getUTF8Length( pucValue, uiLength, &uiLength, &uiNumCharsInBuffer))) { goto Exit; @@ -7469,7 +7468,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::deleteAttribute( +RCODE FLMAPI F_DOMNode::deleteAttribute( IF_Db * ifpDb, FLMUINT uiAttrName) { @@ -7666,7 +7665,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::hasAttribute( +RCODE FLMAPI F_DOMNode::hasAttribute( IF_Db * ifpDb, FLMUINT uiNameId, IF_DOMNode ** ifppAttr) @@ -8270,7 +8269,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::createChildElement( +RCODE FLMAPI F_DOMNode::createChildElement( IF_Db * ifpDb, FLMUINT uiNameId, eNodeInsertLoc eLocation, @@ -8779,7 +8778,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::hasAnnotation( +RCODE FLMAPI F_DOMNode::hasAnnotation( IF_Db * ifpDb, FLMBOOL * pbHasAnnotation) { @@ -8862,7 +8861,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getDocumentId( +RCODE FLMAPI F_DOMNode::getDocumentId( IF_Db * ifpDb, FLMUINT64 * pui64DocId) { @@ -8896,7 +8895,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getNodeId( +RCODE FLMAPI F_DOMNode::getNodeId( IF_Db * ifpDb, FLMUINT64 * pui64NodeId) { @@ -8979,7 +8978,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getParentId( +RCODE FLMAPI F_DOMNode::getParentId( IF_Db * ifpDb, FLMUINT64 * pui64ParentId) { @@ -9014,7 +9013,7 @@ Exit: Desc: COM version of the getPrevSibId method. This method ensures that the DOM node is up-to-date. ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getPrevSibId( +RCODE FLMAPI F_DOMNode::getPrevSibId( IF_Db * ifpDb, FLMUINT64 * pui64PrevSibId) { @@ -9056,7 +9055,7 @@ Exit: Desc: COM version of the getNextSibId method. This method ensures that the DOM node is up-to-date. ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getNextSibId( +RCODE FLMAPI F_DOMNode::getNextSibId( IF_Db * ifpDb, FLMUINT64 * pui64NextSibId) { @@ -9097,7 +9096,7 @@ Exit: Desc: COM version of the getFirstChildId method. This method ensures that the DOM node is up-to-date. ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getFirstChildId( +RCODE FLMAPI F_DOMNode::getFirstChildId( IF_Db * ifpDb, FLMUINT64 * pui64FirstChildId) { @@ -9139,7 +9138,7 @@ Exit: Desc: COM version of the getLastChildId method. This method ensures that the DOM node is up-to-date. ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getLastChildId( +RCODE FLMAPI F_DOMNode::getLastChildId( IF_Db * ifpDb, FLMUINT64 * pui64LastChildId) { @@ -9179,7 +9178,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::isNamespaceDecl( +RCODE FLMAPI F_DOMNode::isNamespaceDecl( IF_Db * ifpDb, FLMBOOL * pbIsNamespaceDecl) { @@ -9443,7 +9442,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getPrefixId( +RCODE FLMAPI F_DOMNode::getPrefixId( IF_Db * ifpDb, FLMUINT * puiPrefixId) { @@ -9629,7 +9628,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getAncestorElement( +RCODE FLMAPI F_DOMNode::getAncestorElement( IF_Db * ifpDb, FLMUINT uiNameId, IF_DOMNode ** ifppAncestor) @@ -9713,7 +9712,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getDescendantElement( +RCODE FLMAPI F_DOMNode::getDescendantElement( IF_Db * ifpDb, FLMUINT uiNameId, IF_DOMNode ** ifppDescendant) @@ -9825,7 +9824,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getDocumentNode( +RCODE FLMAPI F_DOMNode::getDocumentNode( IF_Db * ifpDb, IF_DOMNode ** ifppDoc) { @@ -9878,7 +9877,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getParentNode( +RCODE FLMAPI F_DOMNode::getParentNode( IF_Db * ifpDb, IF_DOMNode ** ifppParent) { @@ -9922,7 +9921,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getFirstChild( +RCODE FLMAPI F_DOMNode::getFirstChild( IF_Db * ifpDb, IF_DOMNode ** ifppChild) { @@ -9966,7 +9965,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getLastChild( +RCODE FLMAPI F_DOMNode::getLastChild( IF_Db * ifpDb, IF_DOMNode ** ifppChild) { @@ -10010,7 +10009,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getChild( +RCODE FLMAPI F_DOMNode::getChild( IF_Db * ifpDb, eDomNodeType eNodeType, IF_DOMNode ** ppChild) @@ -10106,7 +10105,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getChildElement( +RCODE FLMAPI F_DOMNode::getChildElement( IF_Db * ifpDb, FLMUINT uiNameId, IF_DOMNode ** ppChild, @@ -10251,7 +10250,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getSiblingElement( +RCODE FLMAPI F_DOMNode::getSiblingElement( IF_Db * ifpDb, FLMUINT uiNameId, FLMBOOL bNext, @@ -10340,7 +10339,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getPreviousSibling( +RCODE FLMAPI F_DOMNode::getPreviousSibling( IF_Db * ifpDb, IF_DOMNode ** ifppSib) { @@ -10401,7 +10400,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getNextSibling( +RCODE FLMAPI F_DOMNode::getNextSibling( IF_Db * ifpDb, IF_DOMNode ** ifppSib) { @@ -10462,7 +10461,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getPreviousDocument( +RCODE FLMAPI F_DOMNode::getPreviousDocument( IF_Db * ifpDb, IF_DOMNode ** ifppDoc) { @@ -10632,7 +10631,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_DOMNode::getNextDocument( +RCODE FLMAPI F_DOMNode::getNextDocument( IF_Db * ifpDb, IF_DOMNode ** ifppDoc) { @@ -10799,266 +10798,6 @@ Exit: return( rc); } -/***************************************************************************** -Desc: -******************************************************************************/ -RCODE flmReadSEN( - IF_IStream * pIStream, - FLMUINT * puiValue, - FLMUINT * puiLength) -{ - RCODE rc; - FLMUINT64 ui64Tmp; - - if( RC_BAD( rc = flmReadSEN64( pIStream, &ui64Tmp, puiLength))) - { - goto Exit; - } - - if( ui64Tmp > ~((FLMUINT)0)) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_CONV_DEST_OVERFLOW); - goto Exit; - } - - if( puiValue) - { - *puiValue = (FLMUINT)ui64Tmp; - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: -******************************************************************************/ -RCODE flmReadSEN64( - IF_IStream * pIStream, - FLMUINT64 * pui64Value, - FLMUINT * puiLength) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiLen; - FLMUINT uiSENLength; - FLMBYTE ucBuffer[ FLM_MAX_NUM_BUF_SIZE]; - const FLMBYTE * pucBuffer; - - uiLen = 1; - if( RC_BAD( rc = pIStream->read( - (char *)&ucBuffer[ 0], uiLen, &uiLen))) - { - goto Exit; - } - - uiSENLength = gv_ucSENLengthArray[ ucBuffer[ 0]]; - uiLen = uiSENLength - 1; - - if( puiLength) - { - *puiLength = uiSENLength; - } - - if( pui64Value) - { - pucBuffer = &ucBuffer[ 1]; - } - else - { - pucBuffer = NULL; - } - - if( uiLen) - { - if( RC_BAD( rc = pIStream->read( - (char *)pucBuffer, uiLen, &uiLen))) - { - goto Exit; - } - } - - if( pui64Value) - { - pucBuffer = &ucBuffer[ 0]; - if( RC_BAD( rc = flmDecodeSEN64( &pucBuffer, - &ucBuffer[ FLM_MAX_NUM_BUF_SIZE], pui64Value))) - { - goto Exit; - } - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Reads the next UTF-8 character from the stream -****************************************************************************/ -RCODE flmReadUTF8CharAsUnicode( - IF_IStream * pIStream, - FLMUNICODE * puChar) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE ucBuf[ 3]; - FLMUINT uiLen; - - uiLen = 1; - if( RC_BAD( rc = pIStream->read( &ucBuf[ 0], uiLen, &uiLen))) - { - goto Exit; - } - - if( ucBuf[ 0] <= 0x7F) - { - if( !ucBuf [0]) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - *puChar = (FLMUNICODE)ucBuf[ 0]; - goto Exit; - } - - uiLen = 1; - if( RC_BAD( rc = pIStream->read( &ucBuf[ 1], uiLen, &uiLen))) - { - goto Exit; - } - - if( (ucBuf[ 1] >> 6) != 0x02) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_BAD_UTF8); - goto Exit; - } - - if( (ucBuf[ 0] >> 5) == 0x06) - { - *puChar = ((FLMUNICODE)( ucBuf[ 0] - 0xC0) << 6) + - (FLMUNICODE)(ucBuf[ 1] - 0x80); - goto Exit; - } - - uiLen = 1; - if( RC_BAD( rc = pIStream->read( &ucBuf[ 2], uiLen, &uiLen))) - { - goto Exit; - } - - if( (ucBuf[ 0] >> 4) != 0x0E || (ucBuf[ 2] >> 6) != 0x02) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_BAD_UTF8); - goto Exit; - } - - *puChar = ((FLMUNICODE)(ucBuf[ 0] - 0xE0) << 12) + - ((FLMUNICODE)(ucBuf[ 1] - 0x80) << 6) + - (FLMUNICODE)(ucBuf[ 2] - 0x80); - -Exit: - - if( RC_BAD( rc)) - { - *puChar = 0; - } - - return( rc); -} - -/***************************************************************************** -Desc: -Notes: pucBuf must be able to contain at least 3 bytes -******************************************************************************/ -RCODE flmReadUTF8CharAsUTF8( - IF_IStream * pIStream, - FLMBYTE * pucBuf, - FLMUINT * puiLen) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiLen; - - if( *puiLen == 0) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_CONV_DEST_OVERFLOW); - goto Exit; - } - - uiLen = 1; - if( RC_BAD( rc = pIStream->read( pucBuf, uiLen, &uiLen))) - { - goto Exit; - } - - if( pucBuf[ 0] <= 0x7F) - { - if( !pucBuf[ 0]) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - - *puiLen = 1; - goto Exit; - } - - if( *puiLen < 2) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_CONV_DEST_OVERFLOW); - goto Exit; - } - - uiLen = 1; - if( RC_BAD( rc = pIStream->read( &pucBuf[ 1], uiLen, &uiLen))) - { - if( rc == NE_XFLM_EOF_HIT) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_BAD_UTF8); - } - goto Exit; - } - - if( (pucBuf[ 1] >> 6) != 0x02) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_BAD_UTF8); - goto Exit; - } - - if( (pucBuf[ 0] >> 5) == 0x06) - { - *puiLen = 2; - goto Exit; - } - - if( *puiLen < 3) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_CONV_DEST_OVERFLOW); - goto Exit; - } - - uiLen = 1; - if( RC_BAD( rc = pIStream->read( &pucBuf[ 2], uiLen, &uiLen))) - { - if( rc == NE_XFLM_EOF_HIT) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_BAD_UTF8); - } - goto Exit; - } - - if( (pucBuf[ 0] >> 4) != 0x0E || (pucBuf[ 2] >> 6) != 0x02) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_BAD_UTF8); - goto Exit; - } - - *puiLen = 3; - -Exit: - - return( rc); -} - /***************************************************************************** Desc: ******************************************************************************/ @@ -11090,7 +10829,7 @@ RCODE flmReadStorageAsText( FLMBYTE ucConvBuf[ 64]; FLMUINT uiLastUTFLen = 0; IF_IStream * pStream = pIStream; - F_BufferIStream convStream; + IF_BufferIStream * pConvStream = NULL; F_BinaryToTextStream binaryToTextStream; // If the value is a number, convert to text @@ -11136,24 +10875,35 @@ RCODE flmReadStorageAsText( goto Exit; } - if( RC_BAD( rc = convStream.open( ucConvBuf, uiDataLen))) + if( RC_BAD( rc = FlmAllocBufferIStream( &pConvStream))) + { + goto Exit; + } + + if( RC_BAD( rc = pConvStream->open( (const char *)ucConvBuf, uiDataLen))) { goto Exit; } - pStream = &convStream; + pStream = pConvStream; pucStorageData = NULL; } else if( uiDataType == XFLM_BINARY_TYPE) { if( !pStream) { - if( RC_BAD( rc = convStream.open( pucStorageData, uiDataLen))) + if( RC_BAD( rc = FlmAllocBufferIStream( &pConvStream))) { goto Exit; } - pStream = &convStream; + if( RC_BAD( rc = pConvStream->open( + (const char *)pucStorageData, uiDataLen))) + { + goto Exit; + } + + pStream = pConvStream; } if( RC_BAD( rc = binaryToTextStream.open( pStream, @@ -11225,7 +10975,7 @@ Empty_String: uiDataLen--; } - if( (uiSENLen = flmGetSENLength( ucSENBuf[ 0])) > 1) + if( (uiSENLen = f_getSENLength( ucSENBuf[ 0])) > 1) { uiLen = uiSENLen - 1; @@ -11253,7 +11003,7 @@ Empty_String: } pucTmp = &ucSENBuf[ 0]; - if( RC_BAD( rc = flmDecodeSEN( + if( RC_BAD( rc = f_decodeSEN( &pucTmp, &ucSENBuf[ uiSENLen], &uiNumChars))) { goto Exit; @@ -11349,7 +11099,7 @@ Empty_String: { if( pStream) { - if( RC_BAD( rc = flmReadUTF8CharAsUnicode( pStream, &uChar))) + if( RC_BAD( rc = f_readUTF8CharAsUnicode( pStream, &uChar))) { if( rc == NE_XFLM_EOF_HIT) { @@ -11487,7 +11237,7 @@ Unicode_EOF_Hit: if( pStream) { - if( RC_BAD( rc = flmReadUTF8CharAsUTF8( + if( RC_BAD( rc = f_readUTF8CharAsUTF8( pStream, pszOutBuf, &uiLen))) { if( rc == NE_XFLM_CONV_DEST_OVERFLOW) @@ -11666,6 +11416,11 @@ Overflow_Error: Exit: + if( pConvStream) + { + pConvStream->Release(); + } + if( puiCharsRead) { *puiCharsRead = uiCharsOutput; @@ -11779,7 +11534,7 @@ RCODE flmReadStorageAsNumber( // Skip the character count - if( RC_BAD( rc = flmReadSEN64( pIStream, NULL, NULL))) + if( RC_BAD( rc = f_readSEN64( pIStream, NULL, NULL))) { if( rc == NE_XFLM_EOF_HIT) { @@ -11792,7 +11547,7 @@ RCODE flmReadStorageAsNumber( for( uiLoop = 0;; uiLoop++) { - if( RC_BAD( rc = flmReadUTF8CharAsUnicode( + if( RC_BAD( rc = f_readUTF8CharAsUnicode( pIStream, &uChar))) { if( rc == NE_XFLM_EOF_HIT) @@ -11923,7 +11678,7 @@ RCODE flmReadLine( { if( RC_BAD( rc = pIStream->read( (char *)&ucByte, 1, NULL))) { - if( rc == NE_XFLM_IO_END_OF_FILE) + if( rc == NE_FLM_IO_END_OF_FILE) { rc = NE_XFLM_OK; break; @@ -12084,7 +11839,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_BTreeIStream::positionTo( +RCODE FLMAPI F_BTreeIStream::positionTo( FLMUINT64 ui64Position) { RCODE rc = NE_XFLM_OK; @@ -12788,7 +12543,7 @@ Exit: /**************************************************************************** Desc: *****************************************************************************/ -RCODE XFLMAPI F_DOMNode::getQualifiedName( +RCODE FLMAPI F_DOMNode::getQualifiedName( IF_Db * ifpDb, FLMUNICODE * puzQualifiedName, FLMUINT uiBufSize, @@ -12865,7 +12620,7 @@ Exit: /**************************************************************************** Desc: *****************************************************************************/ -RCODE XFLMAPI F_DOMNode::getQualifiedName( +RCODE FLMAPI F_DOMNode::getQualifiedName( IF_Db * ifpDb, char * pszQualifiedName, FLMUINT uiBufSize, @@ -13046,7 +12801,7 @@ Exit: /**************************************************************************** Desc: *****************************************************************************/ -RCODE XFLMAPI F_DOMNode::setPrefixId( +RCODE FLMAPI F_DOMNode::setPrefixId( IF_Db * ifpDb, FLMUINT uiPrefixId) { @@ -13195,7 +12950,7 @@ Exit: /**************************************************************************** Desc: Method to compare two dom nodes. *****************************************************************************/ -FLMUINT XFLMAPI F_DOMNode::compareNode( +FLMUINT FLMAPI F_DOMNode::compareNode( IF_DOMNode * pNode, IF_Db * pDb1, IF_Db * pDb2, @@ -13620,7 +13375,7 @@ Exit: /**************************************************************************** Desc: *****************************************************************************/ -RCODE XFLMAPI F_Db::getDictionaryDef( +RCODE FLMAPI F_Db::getDictionaryDef( FLMUINT uiDictType, FLMUINT uiDictNumber, IF_DOMNode ** ppDocumentNode) @@ -13674,7 +13429,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_Db::getElementNameId( +RCODE FLMAPI F_Db::getElementNameId( const FLMUNICODE * puzNamespaceURI, const FLMUNICODE * puzElementName, FLMUINT * puiElementNameId) @@ -13718,7 +13473,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_Db::getElementNameId( +RCODE FLMAPI F_Db::getElementNameId( const char * pszNamespaceURI, const char * pszElementName, FLMUINT * puiElementNameId) @@ -13791,7 +13546,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_Db::getAttributeNameId( +RCODE FLMAPI F_Db::getAttributeNameId( const FLMUNICODE * puzNamespaceURI, const FLMUNICODE * puzAttributeName, FLMUINT * puiAttributeNameId) @@ -13835,7 +13590,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_Db::getAttributeNameId( +RCODE FLMAPI F_Db::getAttributeNameId( const char * pszNamespaceURI, const char * pszAttributeName, FLMUINT * puiAttributeNameId) @@ -13908,7 +13663,7 @@ Exit: /***************************************************************************** Desc: Get a collection number from collection name. ******************************************************************************/ -RCODE XFLMAPI F_Db::getCollectionNumber( +RCODE FLMAPI F_Db::getCollectionNumber( const char * pszCollectionName, FLMUINT * puiCollectionNumber) { @@ -13951,7 +13706,7 @@ Exit: /***************************************************************************** Desc: Get a collection number from collection name. ******************************************************************************/ -RCODE XFLMAPI F_Db::getCollectionNumber( +RCODE FLMAPI F_Db::getCollectionNumber( const FLMUNICODE * puzCollectionName, FLMUINT * puiCollectionNumber) { @@ -13994,7 +13749,7 @@ Exit: /***************************************************************************** Desc: Get an index number from index name. ******************************************************************************/ -RCODE XFLMAPI F_Db::getIndexNumber( +RCODE FLMAPI F_Db::getIndexNumber( const char * pszIndexName, FLMUINT * puiIndexNumber) { @@ -14037,7 +13792,7 @@ Exit: /***************************************************************************** Desc: Get an index number from index name. ******************************************************************************/ -RCODE XFLMAPI F_Db::getIndexNumber( +RCODE FLMAPI F_Db::getIndexNumber( const FLMUNICODE * puzIndexName, FLMUINT * puiIndexNumber) { @@ -14468,10 +14223,10 @@ RCODE F_Db::flushNode( flmAssert( pNodeItem->uiNameId > uiPrevNameId); flmAssert( pNodeItem->ui64NodeId > ui64ElmNodeId); - uiTmpOffset += flmEncodeSEN( pNodeItem->uiNameId - uiPrevNameId, + uiTmpOffset += f_encodeSEN( pNodeItem->uiNameId - uiPrevNameId, &pucTmp); - uiTmpOffset += flmEncodeSEN( pNodeItem->ui64NodeId - ui64ElmNodeId, + uiTmpOffset += f_encodeSEN( pNodeItem->ui64NodeId - ui64ElmNodeId, &pucTmp); uiPrevNameId = pNodeItem->uiNameId; @@ -15163,7 +14918,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_Db::getAttribute( +RCODE FLMAPI F_Db::getAttribute( FLMUINT uiCollection, FLMUINT64 ui64ElementId, FLMUINT uiAttrName, @@ -15245,7 +15000,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_Db::getFirstDocument( +RCODE FLMAPI F_Db::getFirstDocument( FLMUINT uiCollection, IF_DOMNode ** ppDocumentNode) { @@ -15288,7 +15043,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_Db::getLastDocument( +RCODE FLMAPI F_Db::getLastDocument( FLMUINT uiCollection, IF_DOMNode ** ppDocumentNode) { @@ -15331,7 +15086,7 @@ Exit: /***************************************************************************** Desc: ******************************************************************************/ -RCODE XFLMAPI F_Db::getDocument( +RCODE FLMAPI F_Db::getDocument( FLMUINT uiCollection, FLMUINT uiFlags, FLMUINT64 ui64DocumentId, @@ -15807,7 +15562,6 @@ RCODE F_Db::import( F_XMLImport xmlImport; F_DOMNode * pNode = NULL; F_DOMNode * pNewNode = NULL; - F_IStream * pStream = (F_IStream *)ifpStream; if( RC_BAD( rc = xmlImport.setup())) { @@ -15821,7 +15575,7 @@ RCODE F_Db::import( for( ;;) { - if( RC_BAD( rc = xmlImport.import( pStream, this, uiCollection, + if( RC_BAD( rc = xmlImport.import( ifpStream, this, uiCollection, FLM_XML_COMPRESS_WHITESPACE_FLAG | FLM_XML_TRANSLATE_ESC_FLAG | FLM_XML_EXTEND_DICT_FLAG, pNode, eInsertLoc, @@ -15893,7 +15647,6 @@ RCODE F_Db::importDocument( RCODE rc = NE_XFLM_OK; F_XMLImport xmlImport; F_DOMNode * pNode = NULL; - F_IStream * pIStream = (F_IStream *)ifpStream; if( pNode) { @@ -15905,7 +15658,7 @@ RCODE F_Db::importDocument( goto Exit; } - if( RC_BAD( rc = xmlImport.import( pIStream, this, uiCollection, + if( RC_BAD( rc = xmlImport.import( ifpStream, this, uiCollection, FLM_XML_COMPRESS_WHITESPACE_FLAG | FLM_XML_TRANSLATE_ESC_FLAG | FLM_XML_EXTEND_DICT_FLAG, NULL, XFLM_LAST_CHILD, &pNode, pImportStats))) @@ -16403,7 +16156,7 @@ Exit: /**************************************************************************** Desc: *****************************************************************************/ -RCODE XFLMAPI F_Db::getPrefixId( +RCODE FLMAPI F_Db::getPrefixId( const FLMUNICODE * puzPrefixName, FLMUINT * puiPrefixNumber) { @@ -16434,7 +16187,7 @@ Exit: /**************************************************************************** Desc: *****************************************************************************/ -RCODE XFLMAPI F_Db::getPrefixId( +RCODE FLMAPI F_Db::getPrefixId( const char * pszPrefixName, FLMUINT * puiPrefixNumber) { @@ -16465,7 +16218,7 @@ Exit: /**************************************************************************** Desc: *****************************************************************************/ -RCODE XFLMAPI F_Db::getEncDefId( +RCODE FLMAPI F_Db::getEncDefId( const char * pszEncDefName, FLMUINT * puiEncDefNumber) { @@ -16496,7 +16249,7 @@ Exit: /**************************************************************************** Desc: *****************************************************************************/ -RCODE XFLMAPI F_Db::getEncDefId( +RCODE FLMAPI F_Db::getEncDefId( const FLMUNICODE * puzEncDefName, FLMUINT * puiEncDefNumber) { @@ -16690,9 +16443,6 @@ RCODE F_Db::flushDirtyNodes( void) // Need to increment the use count on the node to prevent it from // being moved while we are flushing it to disk. -#ifdef FLM_CACHE_PROTECT - pNode->unprotectCachedItem(); -#endif pNode->incrNodeUseCount(); f_mutexUnlock( gv_XFlmSysData.hNodeCacheMutex); @@ -16714,9 +16464,6 @@ RCODE F_Db::flushDirtyNodes( void) f_mutexLock( gv_XFlmSysData.hNodeCacheMutex); pNode->decrNodeUseCount(); -#ifdef FLM_CACHE_PROTECT - pNode->protectCachedItem(); -#endif if( rc == NE_XFLM_NOT_FOUND) { @@ -16776,10 +16523,6 @@ RCODE F_Db::flushDirtyNode( f_mutexLock( gv_XFlmSysData.hNodeCacheMutex); bMutexLocked = TRUE; -#ifdef FLM_CACHE_PROTECT - pNode->unprotectCachedItem(); -#endif - pNode->incrNodeUseCount(); f_mutexUnlock( gv_XFlmSysData.hNodeCacheMutex); bMutexLocked = FALSE; @@ -16790,9 +16533,6 @@ RCODE F_Db::flushDirtyNode( bMutexLocked = TRUE; pNode->decrNodeUseCount(); -#ifdef FLM_CACHE_PROTECT - pNode->protectCachedItem(); -#endif if( RC_BAD( rc)) { @@ -17381,9 +17121,9 @@ RCODE F_CachedNode::setNumber64( f_ui64toa( ui64Value, (char *)&ucNumBuf[ 1]); } - uiValLen = f_strlen( &ucNumBuf[ 1]); + uiValLen = f_strlen( (const char *)&ucNumBuf[ 1]); pucSen = &ucNumBuf [0]; - uiSenLen = flmEncodeSEN( uiValLen, &pucSen, (FLMUINT)0); + uiSenLen = f_encodeSEN( uiValLen, &pucSen, (FLMUINT)0); flmAssert( uiSenLen == 1); uiValLen += uiSenLen + 1; break; @@ -17712,7 +17452,7 @@ RCODE F_CachedNode::setUTF8( bNullTerminate = TRUE; } - uiSenLen = flmGetSENByteCount( uiNumCharsInValue); + uiSenLen = f_getSENByteCount( uiNumCharsInValue); uiValLen = uiNumBytesInValue + uiSenLen + (bNullTerminate ? 1 : 0); } else @@ -17731,7 +17471,7 @@ RCODE F_CachedNode::setUTF8( { FLMBYTE * pucTmp = pAttrItem->getAttrDataPtr(); - flmEncodeSENKnownLength( uiNumCharsInValue, uiSenLen, &pucTmp); + f_encodeSENKnownLength( uiNumCharsInValue, uiSenLen, &pucTmp); f_memcpy( pucTmp, pucValue, uiNumBytesInValue); if( bNullTerminate) @@ -17970,7 +17710,7 @@ RCODE F_CachedNode::getIStream( flmAssert( pAttrItem->m_uiIVLen); if( RC_BAD( rc = pNodeBufferIStream->open( NULL, - pAttrItem->getAttrDataBufferSize(), &pucAllocatedBuffer))) + pAttrItem->getAttrDataBufferSize(), (char **)&pucAllocatedBuffer))) { goto Exit; } @@ -17988,7 +17728,8 @@ RCODE F_CachedNode::getIStream( else { if( RC_BAD( rc = pNodeBufferIStream->open( - pAttrItem->getAttrDataPtr(), pAttrItem->getAttrDataLength()))) + (const char *)pAttrItem->getAttrDataPtr(), + pAttrItem->getAttrDataLength()))) { goto Exit; } @@ -18058,7 +17799,7 @@ RCODE F_AttrItem::resizePayloadBuffer( bMutexLocked = TRUE; } m_pucPayload -= sizeof( F_AttrItem *); - gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.freeBuf( m_uiPayloadLen + + gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->freeBuf( m_uiPayloadLen + sizeof( F_AttrItem *), &m_pucPayload); } else @@ -18087,7 +17828,7 @@ RCODE F_AttrItem::resizePayloadBuffer( if( uiCurrentSize && uiCurrentSize > sizeof( FLMBYTE *)) { m_pucPayload -= sizeof( F_AttrItem *); - if( RC_BAD( rc = gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.reallocBuf( + if( RC_BAD( rc = gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->reallocBuf( &gv_XFlmSysData.pNodeCacheMgr->m_attrBufferRelocator, m_uiPayloadLen + sizeof( F_AttrItem *), uiTotalNeeded + sizeof( F_AttrItem *), @@ -18098,7 +17839,7 @@ RCODE F_AttrItem::resizePayloadBuffer( } else { - if( RC_BAD( rc = gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.allocBuf( + if( RC_BAD( rc = gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->allocBuf( &gv_XFlmSysData.pNodeCacheMgr->m_attrBufferRelocator, uiTotalNeeded + sizeof( F_AttrItem *), &pAttrItem, sizeof( F_AttrItem *), &m_pucPayload))) @@ -18214,3 +17955,38 @@ Exit: return( rc); } + +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE FLMAPI F_NodeBufferIStream::open( + const char * pucBuffer, + FLMUINT uiLength, + char ** ppucAllocatedBuffer) +{ + RCODE rc = NE_XFLM_OK; + IF_BufferIStream * pBufferIStream = NULL; + + if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferIStream))) + { + goto Exit; + } + + if( RC_BAD( rc = pBufferIStream->open( pucBuffer, + uiLength, ppucAllocatedBuffer))) + { + goto Exit; + } + + m_pBufferIStream = pBufferIStream; + pBufferIStream = NULL; + +Exit: + + if( pBufferIStream) + { + pBufferIStream->Release(); + } + + return( rc); +} diff --git a/xflaim/src/fdynbtre.cpp b/xflaim/src/fdynbtre.cpp index 6bfbabf..0bd22a0 100644 --- a/xflaim/src/fdynbtre.cpp +++ b/xflaim/src/fdynbtre.cpp @@ -1072,7 +1072,7 @@ RCODE FBtreeBlk::readBlk( RCODE rc = NE_XFLM_OK; FLMUINT uiBytesRead; - if (RC_BAD( rc = pFileHdl->Read( + if (RC_BAD( rc = pFileHdl->read( uiBlkAddr * DYNSSET_BLOCK_SIZE, DYNSSET_BLOCK_SIZE, m_pucBlkBuf, &uiBytesRead))) { @@ -1103,7 +1103,7 @@ RCODE FBtreeBlk::writeBlk( FLMUINT uiBytesWritten; FLMUINT uiBlkAddr = blkAddr(); - if (RC_BAD( rc = pFileHdl->Write( + if (RC_BAD( rc = pFileHdl->write( uiBlkAddr * DYNSSET_BLOCK_SIZE, DYNSSET_BLOCK_SIZE, m_pucBlkBuf, @@ -1176,9 +1176,9 @@ RCODE FBtreeRoot::openFile( void) if (!m_pFileHdl) { - rc = gv_pFileSystem->CreateUnique( m_pszFileName, + rc = gv_XFlmSysData.pFileSystem->createUniqueFile( m_pszFileName, FRSET_FILENAME_EXTENSION, - XFLM_IO_RDWR | XFLM_IO_CREATE_DIR, &m_pFileHdl); + FLM_IO_RDWR | FLM_IO_CREATE_DIR, &m_pFileHdl); } return( rc); } @@ -1190,8 +1190,8 @@ void FBtreeRoot::closeFile( void) { if (m_pFileHdl) { - m_pFileHdl->Close(); - gv_pFileSystem->Delete( m_pszFileName); + m_pFileHdl->close(); + gv_XFlmSysData.pFileSystem->deleteFile( m_pszFileName); m_pFileHdl->Release(); m_pFileHdl = NULL; } diff --git a/xflaim/src/fdynbuf.h b/xflaim/src/fdynbuf.h index 5b16ebb..e71ea96 100644 --- a/xflaim/src/fdynbuf.h +++ b/xflaim/src/fdynbuf.h @@ -27,7 +27,7 @@ Desc: Utility class to help prepare a character buffer for printing when the output buffer size is not known in advance. *****************************************************************************/ -class F_DynamicBuffer : public XF_RefCount, public XF_Base +class F_DynamicBuffer : public F_Object { public: diff --git a/xflaim/src/fdynsset.cpp b/xflaim/src/fdynsset.cpp index b229603..1135f42 100644 --- a/xflaim/src/fdynsset.cpp +++ b/xflaim/src/fdynsset.cpp @@ -53,7 +53,7 @@ RCODE FDynSearchSet::setup( } else { - f_memset( &m_szFileName, 0, F_PATH_MAX_SIZE); + f_memset( m_szFileName, 0, F_PATH_MAX_SIZE); } m_uiEntrySize = uiEntrySize; diff --git a/xflaim/src/fdynsset.h b/xflaim/src/fdynsset.h index a00da37..be14986 100644 --- a/xflaim/src/fdynsset.h +++ b/xflaim/src/fdynsset.h @@ -81,7 +81,7 @@ typedef enum eBlkTypes FBlkTypes; /*=========================================================================== Virtual FFixedBlk ===========================================================================*/ -class FFixedBlk : public XF_RefCount, public XF_Base +class FFixedBlk : public F_Object { public: @@ -152,7 +152,7 @@ protected: ** Source: fdynsset.cpp ***** *****************************************************************************/ -class FDynSearchSet : public XF_RefCount, public XF_Base +class FDynSearchSet : public F_Object { public: diff --git a/xflaim/src/ffilehdl.cpp b/xflaim/src/ffilehdl.cpp deleted file mode 100644 index 14ea1c2..0000000 --- a/xflaim/src/ffilehdl.cpp +++ /dev/null @@ -1,602 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Contains the methods for the F_FileHdlMgr and F_FileHdl classes. -// -// Tabs: 3 -// -// Copyright (c) 1997-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: ffilehdl.cpp 3112 2006-01-19 13:12:40 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -/**************************************************************************** -Name: f_filecpy -Desc: quick and easy way to write a string to a file. The contents of - pszSourceFile becomes pszData. -****************************************************************************/ -RCODE f_filecpy( - const char * pszSourceFile, - const char * pszData) -{ - IF_FileHdl * pFileHdl = NULL; - F_FileSystem fileSystem; - RCODE rc = NE_XFLM_OK; - - //if it exists, delete it - if (RC_OK( rc = fileSystem.Exists( pszSourceFile))) - { - if ( RC_BAD( rc = fileSystem.Delete( pszSourceFile))) - { - goto Exit; - } - } - - if ( RC_BAD( rc = fileSystem.Create( pszSourceFile, XFLM_IO_RDWR, - &pFileHdl))) - { - goto Exit; - } - - { - FLMUINT uiBytesWritten = 0; - if ( RC_BAD( rc = pFileHdl->Write( - 0, - f_strlen( pszData), - (void *)pszData, - &uiBytesWritten))) - { - goto Exit; - } - } -Exit: - if ( pFileHdl) - { - pFileHdl->Close(); - pFileHdl->Release(); - pFileHdl = NULL; - } - return rc; -} - -/**************************************************************************** -Name: f_filecat -Desc: quick and easy way to append a string to a file. The contents of - pszData are appended to pszSourceFile. -****************************************************************************/ -RCODE f_filecat( - const char * pszSourceFile, - const char * pszData) -{ - IF_FileHdl * pFileHdl = NULL; - F_FileSystem fileSystem; - RCODE rc = NE_XFLM_OK; - - if (RC_BAD( rc = fileSystem.Exists( pszSourceFile))) - { - //create file if it doesn't already exist - if ( rc == NE_XFLM_IO_PATH_NOT_FOUND) - { - rc = fileSystem.Create( pszSourceFile, XFLM_IO_RDWR, - &pFileHdl); - } - else - { - goto Exit; - } - } - else - { - rc = fileSystem.Open( pszSourceFile, - XFLM_IO_RDWR, &pFileHdl); - } - - if (RC_BAD( rc)) - { - goto Exit; - } - - { - FLMUINT64 ui64FileSize = 0; - FLMUINT uiBytesWritten = 0; - - if ( RC_BAD( rc = pFileHdl->Size( &ui64FileSize))) - { - goto Exit; - } - - if( RC_BAD( rc = pFileHdl->Write( ui64FileSize, f_strlen( pszData), - (void *)pszData, &uiBytesWritten))) - { - goto Exit; - } - } - -Exit: - - if( pFileHdl) - { - pFileHdl->Close(); - pFileHdl->Release(); - pFileHdl = NULL; - } - - return( rc); -} - -/**************************************************************************** -Desc: Initializes variables -****************************************************************************/ -F_FileHdlMgr::F_FileHdlMgr() -{ - m_hMutex = F_MUTEX_NULL; - - //m_uiOpenThreshold = ~0; <- this creates a compiler warning! - m_uiOpenThreshold = 0xFFFF; // No limit - this should be enough - FLM_SECS_TO_TIMER_UNITS( 30 * 60, m_uiMaxAvailTime); // 30 minutes - m_bIsSetup = FALSE; - - m_uiFileIdCounter = 0; - - m_pFirstAvail = NULL; - m_pLastAvail = NULL; - m_uiNumAvail = 0; - - m_pFirstUsed = NULL; - m_pLastUsed = NULL; - m_uiNumUsed = 0; - -} - -/**************************************************************************** -Desc: Setup the File handle manager. -****************************************************************************/ -RCODE F_FileHdlMgr::setupFileHdlMgr( - FLMUINT uiOpenThreshold, - FLMUINT uiMaxAvailTime) -{ - RCODE rc = NE_XFLM_OK; - - // Need to allocate a mutex - - if (RC_BAD( rc = f_mutexCreate( &m_hMutex))) - { - goto Exit; - } - m_uiOpenThreshold = uiOpenThreshold; - m_uiMaxAvailTime = uiMaxAvailTime; - m_bIsSetup = TRUE; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Return the next available file handle that matches the uiFileId. -****************************************************************************/ -void F_FileHdlMgr::findAvail( - FLMUINT uiFileId, // Desired FileHdr's ID - FLMBOOL bReadOnlyFlag, // TRUE if file is read only - F_FileHdl ** ppFileHdl) // [out] returned FileHdl object. -{ - F_FileHdl * pFileHdl; - - lockMutex( FALSE); - pFileHdl = m_pFirstAvail; - while (pFileHdl) - { - if (pFileHdl->m_uiFileId == uiFileId && - pFileHdl->m_bOpenedReadOnly == bReadOnlyFlag) - { - - // Move this file handle out of the available list into - // the used list. - - // NOTE: To prevent this file handle from being freed this code - // performs an AddRef while its being relinked. This reference - // will be kept for the caller. - - pFileHdl->AddRef(); // LOCK WHILE MOVING FILE HDL - - removeFromList( TRUE, - pFileHdl, &m_pFirstAvail, &m_pLastAvail, &m_uiNumAvail); - insertInList( TRUE, pFileHdl, FALSE, - &m_pFirstUsed, &m_pLastUsed, &m_uiNumUsed); - - // NOTE: DO NOT CALL RELEASE -- Keep reference for caller. - - break; - } - pFileHdl = pFileHdl->m_pNext; - } - unlockMutex( FALSE); - *ppFileHdl = pFileHdl; -} - -/**************************************************************************** -Desc: Make the specified F_FileHdl available for someone else to use. -****************************************************************************/ -void F_FileHdlMgr::makeAvailAndRelease( - FLMBOOL bMutexAlreadyLocked, - F_FileHdl * pFileHdl) // FileHdl to move to the avail list. -{ - pFileHdl->m_uiAvailTime = (FLMUINT)FLM_GET_TIMER(); - - lockMutex( bMutexAlreadyLocked); - - // NOTE: To prevent this file handle from being freed this code - // performs an AddRef/Release while its being relinked. - - pFileHdl->AddRef(); // LOCK WHILE MOVING FILE HDL - - removeFromList( TRUE, - pFileHdl, &m_pFirstUsed, &m_pLastUsed, &m_uiNumUsed); - insertInList( TRUE, pFileHdl, TRUE, - &m_pFirstAvail, &m_pLastAvail, &m_uiNumAvail); - - pFileHdl->Release(); // UNLOCK NOW THAT MOVE IS DONE! - - // Release the caller's reference to the file handle - - pFileHdl->Release(); - - unlockMutex( bMutexAlreadyLocked); -} - -/**************************************************************************** -Desc: Remove (close&free) all FileHdl's that have the specified FileId. - Remove from the avail and used lists. -****************************************************************************/ -void F_FileHdlMgr::removeFileHdls( - FLMUINT uiFileId - ) -{ - F_FileHdl * pFileHdl; - F_FileHdl * pNextFileHdl; - - lockMutex( FALSE); - - // Free all matching file handles in the available list. - - pFileHdl = m_pFirstAvail; - while (pFileHdl) - { - pNextFileHdl = pFileHdl->m_pNext; - if (pFileHdl->m_uiFileId == uiFileId) - { - removeFromList( TRUE, - pFileHdl, &m_pFirstAvail, &m_pLastAvail, &m_uiNumAvail); - } - pFileHdl = pNextFileHdl; - } - - // Free all matching file handles in the used list. - - pFileHdl = m_pFirstUsed; - while (pFileHdl) - { - pNextFileHdl = pFileHdl->m_pNext; - if (pFileHdl->m_uiFileId == uiFileId) - { - removeFromList( TRUE, - pFileHdl, &m_pFirstUsed, &m_pLastUsed, &m_uiNumUsed); - } - pFileHdl = pNextFileHdl; - } - - unlockMutex( FALSE); -} - -/**************************************************************************** -Desc: Remove all handles from the avail list. -****************************************************************************/ -void F_FileHdlMgr::freeAvailList( - FLMBOOL bMutexAlreadyLocked) -{ - F_FileHdl * pFileHdl; - F_FileHdl * pNextFileHdl; - - lockMutex( bMutexAlreadyLocked); - pFileHdl = m_pFirstAvail; - while (pFileHdl) - { - pFileHdl->m_bInList = FALSE; - pNextFileHdl = pFileHdl->m_pNext; - pFileHdl->Release(); - pFileHdl = pNextFileHdl; - } - m_pFirstAvail = NULL; - m_pLastAvail = NULL; - m_uiNumAvail = 0; - unlockMutex( bMutexAlreadyLocked); -} - -/**************************************************************************** -Desc: Remove all handles from the used list. -****************************************************************************/ -void F_FileHdlMgr::freeUsedList( - FLMBOOL bMutexAlreadyLocked) -{ - F_FileHdl * pFileHdl; - F_FileHdl * pNextFileHdl; - - lockMutex( bMutexAlreadyLocked); - pFileHdl = m_pFirstUsed; - while (pFileHdl) - { - pFileHdl->m_bInList = FALSE; - pNextFileHdl = pFileHdl->m_pNext; - pFileHdl->Release(); - pFileHdl = pNextFileHdl; - } - m_pFirstUsed = NULL; - m_pLastUsed = NULL; - m_uiNumUsed = 0; - unlockMutex( bMutexAlreadyLocked); -} - -/**************************************************************************** -Desc: Insert a handle into either the avail or used list. -****************************************************************************/ -void F_FileHdlMgr::insertInList( - FLMBOOL bMutexAlreadyLocked, - F_FileHdl * pFileHdl, - FLMBOOL bInsertAtEnd, - F_FileHdl ** ppFirst, - F_FileHdl ** ppLast, - FLMUINT * puiCount - ) -{ - lockMutex( bMutexAlreadyLocked); - - flmAssert( !pFileHdl->m_bInList); - - if (bInsertAtEnd) - { - pFileHdl->m_pNext = NULL; - if ((pFileHdl->m_pPrev = *ppLast) != NULL) - { - pFileHdl->m_pPrev->m_pNext = pFileHdl; - } - else - { - *ppFirst = pFileHdl; - } - *ppLast = pFileHdl; - } - else - { - pFileHdl->m_pPrev = NULL; - if ((pFileHdl->m_pNext = *ppFirst) != NULL) - { - pFileHdl->m_pNext->m_pPrev = pFileHdl; - } - else - { - *ppLast = pFileHdl; - } - *ppFirst = pFileHdl; - } - (*puiCount)++; - pFileHdl->m_bInList = TRUE; - pFileHdl->AddRef(); - unlockMutex( bMutexAlreadyLocked); -} - -/**************************************************************************** -Desc: Remove a handle into either the avail or used list. -****************************************************************************/ -void F_FileHdlMgr::removeFromList( - FLMBOOL bMutexAlreadyLocked, - F_FileHdl * pFileHdl, - F_FileHdl ** ppFirst, - F_FileHdl ** ppLast, - FLMUINT * puiCount - ) -{ - lockMutex( bMutexAlreadyLocked); - - flmAssert( pFileHdl->m_bInList); - if (pFileHdl->m_pNext) - { - pFileHdl->m_pNext->m_pPrev = pFileHdl->m_pPrev; - } - else - { - *ppLast = pFileHdl->m_pPrev; - } - if (pFileHdl->m_pPrev) - { - pFileHdl->m_pPrev->m_pNext = pFileHdl->m_pNext; - } - else - { - *ppFirst = pFileHdl->m_pNext; - } - flmAssert( *puiCount); - (*puiCount)--; - pFileHdl->m_bInList = FALSE; - pFileHdl->Release(); - unlockMutex( bMutexAlreadyLocked); -} - -/**************************************************************************** -Desc: Check items in the avail list and if over a certain age then - remove them from the avail list. This will cause file handles - that have been opened for a long time to be closed. Also added - code to reduce the total number of file handles if it is more - than the open threshold. -****************************************************************************/ -void F_FileHdlMgr::checkAgedFileHdls( - FLMUINT uiMinTimeOpened - ) -{ - FLMUINT uiTime; - FLMUINT uiMaxAvailTicks; - - uiTime = (FLMUINT)FLM_GET_TIMER(); - - FLM_SECS_TO_TIMER_UNITS( uiMinTimeOpened, uiMaxAvailTicks); - - lockMutex( FALSE); - - // Loop while the open count is greater than the open threshold. - - while (m_uiNumAvail && (m_uiNumAvail + m_uiNumUsed > m_uiOpenThreshold)) - { - - // Release until the threshold is down. - - releaseOneAvail( TRUE); - } - - // Reduce all items older than the specified time. - - while (m_pFirstAvail) - { - - // All file handles are in order of oldest first. - // m_uiMaxAvailTime may be a zero value. - - if (FLM_ELAPSED_TIME( uiTime, m_pFirstAvail->m_uiAvailTime) < - uiMaxAvailTicks) - { - break; // All files are newer so we are done. - } - removeFromList( TRUE, - m_pFirstAvail, &m_pFirstAvail, &m_pLastAvail, &m_uiNumAvail); - } - - unlockMutex( FALSE); -} - -/**************************************************************************** -Desc: Do a partial copy from one file into another file. -****************************************************************************/ -RCODE flmCopyPartial( - IF_FileHdl * pSrcFileHdl, // Source file handle. - FLMUINT64 ui64SrcOffset, // Offset to start copying from. - FLMUINT64 ui64SrcSize, // Bytes to copy - IF_FileHdl * pDestFileHdl, // Destination file handle - FLMUINT64 ui64DestOffset, // Destination start offset. - FLMUINT64 * pui64BytesCopiedRV) // Returns number of bytes copied -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE * pucBuffer = NULL; - FLMUINT uiAllocSize = 65536; - FLMUINT uiBytesToRead; - FLMUINT64 ui64CopySize; - FLMUINT64 ui64FileOffset; - FLMUINT uiBytesRead; - FLMUINT uiBytesWritten; - - ui64CopySize = ui64SrcSize; - *pui64BytesCopiedRV = 0; - - // Set the buffer size for use during the file copy - - if( ui64CopySize < uiAllocSize) - { - uiAllocSize = (FLMUINT)ui64CopySize; - } - - // Allocate a buffer - - if( RC_BAD( rc = f_alloc( uiAllocSize, &pucBuffer))) - { - goto Exit; - } - - // Position the file pointers - - if( RC_BAD( rc = pSrcFileHdl->Seek( ui64SrcOffset, XFLM_IO_SEEK_SET, - &ui64FileOffset))) - { - goto Exit; - } - - if( RC_BAD( rc = pDestFileHdl->Seek( ui64DestOffset, XFLM_IO_SEEK_SET, - &ui64FileOffset))) - { - goto Exit; - } - - // Begin copying the data - - while( ui64CopySize) - { - if( ui64CopySize > uiAllocSize) - { - uiBytesToRead = uiAllocSize; - } - else - { - uiBytesToRead = (FLMUINT)ui64CopySize; - } - - rc = pSrcFileHdl->Read( XFLM_IO_CURRENT_POS, uiBytesToRead, - pucBuffer, &uiBytesRead); - - if (rc == NE_XFLM_IO_END_OF_FILE) - { - rc = NE_XFLM_OK; - } - - if (RC_BAD( rc)) - { - rc = RC_SET( NE_XFLM_IO_COPY_ERR); - goto Exit; - } - - uiBytesWritten = 0; - if( RC_BAD( rc = pDestFileHdl->Write( XFLM_IO_CURRENT_POS, uiBytesRead, - pucBuffer, &uiBytesWritten))) - { - if (rc == NE_XFLM_IO_DISK_FULL) - { - *pui64BytesCopiedRV += uiBytesWritten; - } - else - { - rc = RC_SET( NE_XFLM_IO_COPY_ERR); - } - - goto Exit; - } - - *pui64BytesCopiedRV += uiBytesWritten; - - if( uiBytesRead < uiBytesToRead) - { - rc = RC_SET( NE_XFLM_IO_END_OF_FILE); - goto Exit; - } - - ui64CopySize -= uiBytesRead; - } - -Exit: - - if (pucBuffer) - { - (void)f_free( &pucBuffer); - } - - return( rc); -} diff --git a/xflaim/src/ffilehdl.h b/xflaim/src/ffilehdl.h deleted file mode 100644 index 6580576..0000000 --- a/xflaim/src/ffilehdl.h +++ /dev/null @@ -1,260 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: This include file contains the class definitions for FLAIM's -// FileHdlMgr and FileHdl classes. -// -// Tabs: 3 -// -// Copyright (c) 1997-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: ffilehdl.h 3108 2006-01-19 13:05:19 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#ifndef FFILEHDL_H -#define FFILEHDL_H - -class F_FileHdl; // Forward Reference -class F_FileHdlMgr; // Forward Reference -class F_FileHdlMgrPage; // Source: imonfmgr.cpp -class F_FileHdlPage; // Source: imonfhdl.cpp - -#define FHM_AVAIL_LIST 0 -#define FHM_USED_LIST 1 -#define FHM_LNODE_COUNT 2 - -RCODE DetermineLockMgr( - F_Database * pDatabase, - F_FileHdl * pFileHdl); - -RCODE flmCopyPartial( - IF_FileHdl * pSrcFileHdl, - FLMUINT64 ui64SrcOffset, - FLMUINT64 ui64SrcSize, - IF_FileHdl * pDestFileHdl, - FLMUINT64 ui64DestOffset, - FLMUINT64 * pui64BytesCopiedRV); - -RCODE f_filecpy( - const char * pszSourceFile, - const char * pszData); - -RCODE f_filecat( - const char * pszSourceFile, - const char * pszData); - -#include "fwin.h" -#include "fposix.h" - -/*=========================================================================== -Class: F_FileHdlMgr -Desc: The F_FileHdlMgr class manages F_FileHdl objects. - The F_FileHdlMgr maintains two lists: - 1) Available F_FileHdl's - F_FileHdl's not currently being used. - 2) Used F_FileHdl's - F_FileHdl's that have been checked out. -===========================================================================*/ -class F_FileHdlMgr : public XF_RefCount, public XF_Base -{ -public: - - F_FileHdlMgr(); - - FINLINE ~F_FileHdlMgr() - { - if (m_hMutex != F_MUTEX_NULL) - { - lockMutex( FALSE); - freeUsedList( TRUE); - freeAvailList( TRUE); - unlockMutex( FALSE); - f_mutexDestroy( &m_hMutex); - } - } - - RCODE setupFileHdlMgr( // Setup the F_FileHdlMgr object - FLMUINT uiOpenThreshold = XFLM_DEFAULT_OPEN_THRESHOLD, - // High water mark for open handles. - FLMUINT uiMaxAvailTime = XFLM_DEFAULT_MAX_AVAIL_TIME); - // Max avail time to wait to close files. - - FINLINE void setOpenThreshold( - FLMUINT uiOpenThreshold) - { - if (m_bIsSetup) - { - lockMutex( FALSE); - m_uiOpenThreshold = uiOpenThreshold; - unlockMutex( FALSE); - } - } - - FINLINE void setMaxAvailTime( - FLMUINT uiMaxAvailTime) - { - if (m_bIsSetup) - { - lockMutex( FALSE); - m_uiMaxAvailTime = uiMaxAvailTime; - unlockMutex( FALSE); - } - } - - FINLINE FLMUINT getUniqueId( void) - { - FLMUINT uiTemp; - - lockMutex( FALSE); - uiTemp = ++m_uiFileIdCounter; - unlockMutex( FALSE); - return( uiTemp); - } - - // Methods for Avail & Used List Management - - void findAvail( // Determines if the F_FileHdlMgr has an - // available F_FileHdl for the specified FileId - FLMUINT uiFileId, // Desired FileHdr's ID - FLMBOOL bReadOnlyFlag, // TRUE if looking for read only file - F_FileHdl ** ppFileHdl); // [out] returned F_FileHdl object. - - void makeAvailAndRelease( // Make the specified F_FileHdl available for - // someone else to use. - FLMBOOL bMutexAlreadyLocked, - F_FileHdl * pFileHdl); // F_FileHdl to move to the available list. - - void removeFileHdls( // Remove (close&free) all FileHdl's that - // have the specified FileId. - FLMUINT uiFileId); - - void checkAgedFileHdls( // Remove aged items older than - FLMUINT uiMinSecondsOpened); // minimum seconds opened. - - void FINLINE releaseOneAvail( - FLMBOOL bMutexAlreadyLocked - ) - { - lockMutex( bMutexAlreadyLocked); - if (m_pFirstAvail) - { - removeFromList( TRUE, - m_pFirstAvail, &m_pFirstAvail, &m_pLastAvail, &m_uiNumAvail); - } - unlockMutex( bMutexAlreadyLocked); - } - - // Manager Statistics Methods - - FINLINE FLMUINT getOpenThreshold( void) - { - return m_uiOpenThreshold; - } - - FINLINE FLMUINT getOpenedFiles( void) - { - FLMUINT uiTemp; - - lockMutex( FALSE); - uiTemp = m_uiNumUsed + m_uiNumAvail; - unlockMutex( FALSE); - return( uiTemp); - } - - FINLINE FLMUINT getMaxAvailTime( void) - { - return m_uiMaxAvailTime; - } - - // Misc. Methods - - void freeAvailList( - FLMBOOL bMutexAlreadyLocked); - - void freeUsedList( - FLMBOOL bMutexAlreadyLocked); - - FINLINE void insertInUsedList( - FLMBOOL bMutexAlreadyLocked, - F_FileHdl * pFileHdl, - FLMBOOL bInsertAtEnd - ) - { - insertInList( bMutexAlreadyLocked, - pFileHdl, bInsertAtEnd, - &m_pFirstUsed, &m_pLastUsed, &m_uiNumUsed); - } - -private: - - void insertInList( - FLMBOOL bMutexAlreadyLocked, - F_FileHdl * pFileHdl, - FLMBOOL bInsertAtEnd, - F_FileHdl ** ppFirst, - F_FileHdl ** ppLast, - FLMUINT * puiCount); - - void removeFromList( - FLMBOOL bMutexAlreadyLocked, - F_FileHdl * pFileHdl, - F_FileHdl ** ppFirst, - F_FileHdl ** ppLast, - FLMUINT * puiCount); - - FINLINE void lockMutex( - FLMBOOL bMutexAlreadyLocked) - { - if (m_hMutex != F_MUTEX_NULL && !bMutexAlreadyLocked) - { - f_mutexLock( m_hMutex); - } - } - - FINLINE void unlockMutex( - FLMBOOL bMutexAlreadyLocked) - { - if (m_hMutex != F_MUTEX_NULL && !bMutexAlreadyLocked) - { - f_mutexUnlock( m_hMutex); - } - } - - // Private variables - - F_MUTEX m_hMutex; - FLMUINT m_uiOpenThreshold; // FileHdl open threshold. - FLMUINT m_uiMaxAvailTime; // Time to close any available files. - - // Used list - - F_FileHdl * m_pFirstUsed; - F_FileHdl * m_pLastUsed; - FLMUINT m_uiNumUsed; - - // Avail list - - F_FileHdl * m_pFirstAvail; - F_FileHdl * m_pLastAvail; - FLMUINT m_uiNumAvail; - - FLMBOOL m_bIsSetup; // TRUE when list manager is set up. - FLMUINT m_uiFileIdCounter; // Used for getUniqueId() call. - -friend class F_FileHdlMgrPage; -friend class F_FileHdl; - -}; - -#endif // #ifndef FFILEHDL_H diff --git a/xflaim/src/ffilehdr.cpp b/xflaim/src/ffilehdr.cpp index 5a16e88..67e0f2b 100644 --- a/xflaim/src/ffilehdr.cpp +++ b/xflaim/src/ffilehdr.cpp @@ -65,7 +65,7 @@ void flmInitDbHdr( // If pCreateOpts is non-NULL, copy it into the file header. - f_strcpy( pDbHdr->szSignature, XFLM_DB_SIGNATURE); + f_strcpy( (char *)pDbHdr->szSignature, XFLM_DB_SIGNATURE); pDbHdr->ui8IsLittleEndian = XFLM_NATIVE_IS_LITTLE_ENDIAN; if (pCreateOpts) @@ -395,10 +395,10 @@ RCODE flmReadAndVerifyHdrInfo( // Read the database header. f_memset( pDbHdr, 0, sizeof( XFLM_DB_HDR)); - if (RC_BAD( rc = pFileHdl->Read( (FLMUINT)0, sizeof( XFLM_DB_HDR), + if (RC_BAD( rc = pFileHdl->read( (FLMUINT)0, sizeof( XFLM_DB_HDR), pDbHdr, &uiBytesRead))) { - if (rc != NE_XFLM_IO_END_OF_FILE) + if (rc != NE_FLM_IO_END_OF_FILE) { if (pDbStats) { diff --git a/xflaim/src/ffilesys.cpp b/xflaim/src/ffilesys.cpp deleted file mode 100644 index 40aa43d..0000000 --- a/xflaim/src/ffilesys.cpp +++ /dev/null @@ -1,927 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Contains the methods for the F_FileSystem class. -// -// Tabs: 3 -// -// Copyright (c) 1998-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: ffilesys.cpp 3112 2006-01-19 13:12:40 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -/**************************************************************************** -Desc: Create a file, return a file handle to created file. -****************************************************************************/ -RCODE XFLMAPI F_FileSystem::Create( - const char * pszFileName, - FLMUINT uiIoFlags, - IF_FileHdl ** ppFileHdl) -{ - RCODE rc = NE_XFLM_OK; - F_FileHdl * pFileHdl = NULL; - - if ((pFileHdl = f_new F_FileHdl) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if (RC_BAD( rc = pFileHdl->Create( pszFileName, uiIoFlags))) - { - pFileHdl->Release(); - pFileHdl = NULL; - goto Exit; - } - -Exit: - - *ppFileHdl = (IF_FileHdl *)pFileHdl; - return( rc); -} - -/**************************************************************************** -Desc: Create a block-oriented file, return a file handle to created file. -****************************************************************************/ -RCODE XFLMAPI F_FileSystem::CreateBlockFile( - const char * pszFileName, // Name of file to be created - FLMUINT uiIoFlags, // Access amd Mode flags - FLMUINT uiBlockSize, // Block size for file - IF_FileHdl ** ppFileHdl) // Returns open file handle object. -{ - RCODE rc = NE_XFLM_OK; - F_FileHdl * pFileHdl = NULL; - - if ((pFileHdl = f_new F_FileHdl) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - pFileHdl->SetBlockSize( uiBlockSize); - - if (RC_BAD( rc = pFileHdl->Create( pszFileName, uiIoFlags))) - { - pFileHdl->Release(); - pFileHdl = NULL; - goto Exit; - } - -Exit: - - *ppFileHdl = (IF_FileHdl *)pFileHdl; - return( rc); -} - -/**************************************************************************** -Desc: Create a unique file, return a file handle to created file. -****************************************************************************/ -RCODE XFLMAPI F_FileSystem::CreateUnique( - const char * pszDirName, // Directory where file is to be created. - const char * pszFileExtension, // Extension to be used on file. - FLMUINT uiIoFlags, // Access and Mode flags. - IF_FileHdl ** ppFileHdl) // Returns open file handle object. -{ - RCODE rc; - F_FileHdl * pFileHdl = NULL; - - if ((pFileHdl = f_new F_FileHdl) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - if( RC_BAD( rc = pFileHdl->CreateUnique( pszDirName, pszFileExtension, uiIoFlags))) - { - pFileHdl->Release(); - pFileHdl = NULL; - goto Exit; - } - -Exit: - - *ppFileHdl = (IF_FileHdl *)pFileHdl; - return( rc); -} - -/**************************************************************************** -Desc: Open a file, return a file handle to opened file. -****************************************************************************/ -RCODE XFLMAPI F_FileSystem::Open( - const char * pszFileName, // Name of file to be opened. - FLMUINT uiIoFlags, // Access and Mode flags. - IF_FileHdl ** ppFileHdl) // Returns open file handle object. -{ - RCODE rc = NE_XFLM_OK; - F_FileHdl * pFileHdl = NULL; - - if ((pFileHdl = f_new F_FileHdl) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - if (RC_BAD( rc = pFileHdl->Open( pszFileName, uiIoFlags))) - { - pFileHdl->Release(); - pFileHdl = NULL; - goto Exit; - } - -Exit: - - *ppFileHdl = (IF_FileHdl *)pFileHdl; - return( rc); -} - -/**************************************************************************** -Desc: Open a block-oriented file, return a file handle to opened file. -****************************************************************************/ -RCODE XFLMAPI F_FileSystem::OpenBlockFile( - const char * pszFileName, // Name of file to be opened. - FLMUINT uiIoFlags, // Access and Mode flags. - FLMUINT uiBlockSize, // Block size for file - IF_FileHdl ** ppFileHdl) // Returns open file handle object. -{ - RCODE rc = NE_XFLM_OK; - F_FileHdl * pFileHdl = NULL; - - if ((pFileHdl = f_new F_FileHdl) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - pFileHdl->SetBlockSize( uiBlockSize); - - if (RC_BAD( rc = pFileHdl->Open( pszFileName, uiIoFlags))) - { - pFileHdl->Release(); - pFileHdl = NULL; - goto Exit; - } - -Exit: - - *ppFileHdl = (IF_FileHdl *)pFileHdl; - return( rc); -} - -/**************************************************************************** -Desc: Open a directory, return a file handle to opened directory. -****************************************************************************/ -RCODE XFLMAPI F_FileSystem::OpenDir( - const char * pszDirName, // Directory to be opened. - const char * pszPattern, // File name pattern. - IF_DirHdl ** ppDirHdl) // Returns open directory handle object. -{ - RCODE rc = NE_XFLM_OK; - F_DirHdl * pDirHdl = NULL; - - if ((pDirHdl = f_new F_DirHdl) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - if (RC_BAD( rc = pDirHdl->OpenDir( pszDirName, pszPattern))) - { - pDirHdl->Release(); - pDirHdl = NULL; - } - -Exit: - - *ppDirHdl = (IF_DirHdl *)pDirHdl; - return( rc); -} - -/**************************************************************************** -Desc: Create a directory. -****************************************************************************/ -RCODE XFLMAPI F_FileSystem::CreateDir( - const char * pszDirName) // Directory to be created. -{ - RCODE rc = NE_XFLM_OK; - F_DirHdl * pDirHdl = NULL; - - if ((pDirHdl = f_new F_DirHdl) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - rc = pDirHdl->CreateDir( pszDirName); - -Exit: - - if (pDirHdl) - { - pDirHdl->Release(); - } - return( rc); -} - -/**************************************************************************** -Desc: Remove a directory -****************************************************************************/ -RCODE XFLMAPI F_FileSystem::RemoveDir( - const char * pszDirName, // Directory to delete - FLMBOOL bClear) // OK to delete files if dir is not empty? -{ - RCODE rc = NE_XFLM_OK; - IF_DirHdl * pDirHdl = NULL; - char szFilePath[ F_PATH_MAX_SIZE]; - - if( bClear) - { - // Note: '*' = all files - if( RC_BAD( rc = OpenDir( pszDirName, (char *)"*", &pDirHdl))) - { - goto Exit; - } - - // Delete everything in the directory - for ( rc = pDirHdl->Next(); RC_OK( rc) ; rc = pDirHdl->Next()) - { - pDirHdl->CurrentItemPath( szFilePath); - if( !pDirHdl->CurrentItemIsDir()) - { - if( RC_BAD( rc = Delete( szFilePath))) - { - if( rc == NE_XFLM_IO_PATH_NOT_FOUND || rc == NE_XFLM_IO_INVALID_FILENAME) - { - rc = NE_XFLM_OK; - } - else - { - goto Exit; - } - } - } - else - { - if( RC_BAD( rc = RemoveDir( szFilePath, bClear))) - { - if( rc == NE_XFLM_IO_PATH_NOT_FOUND || rc == NE_XFLM_IO_INVALID_FILENAME) - { - rc = NE_XFLM_OK; - } - else - { - goto Exit; - } - } - } - } - - // Need to release the directory handle so the - // directory will be closed when we try to delete it - // below. - - pDirHdl->Release(); - pDirHdl = NULL; - } - - if ((pDirHdl = f_new F_DirHdl) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = pDirHdl->RemoveDir( pszDirName))) - { - goto Exit; - } - -Exit: - - if (pDirHdl) - { - pDirHdl->Release(); - } - - return( rc); -} - -/**************************************************************************** -Desc: Determine if a file or directory exists. -****************************************************************************/ -RCODE XFLMAPI F_FileSystem::Exists( - const char * pszPath) // Name of file or directory to check. -{ -#if defined( FLM_NLM) - - return( flmNetWareTestIfFileExists( pszPath)); - -#elif defined( FLM_WIN) - - DWORD dwFileAttr = GetFileAttributes( (LPTSTR)pszPath); - - if( dwFileAttr == (DWORD)-1) - return RC_SET( NE_XFLM_IO_PATH_NOT_FOUND); - - return NE_XFLM_OK; - -#else - - if( access( pszPath, F_OK) == -1) - { - return( MapErrnoToFlaimErr( errno, NE_XFLM_CHECKING_FILE_EXISTENCE)); - } - - return( NE_XFLM_OK); - -#endif -} - -/**************************************************************************** -Desc: Get the time stamp of the last modification to this file. -Notes: - puiTimeStamp is assumed to point to a DWORD. - -NLM Notes: - We could call MapPathToDirectoryNumber and GetDirectoryEntry directly. - This works, providing that the high byte of the directory entry (returned - by MapPathToDirectoryNumber) is masked off. Otherwise, GetDirectoryEntry - will generate an abend. - We have opted to call a higher level function, GetEntryFromPathStringBase, - which calls the lower level functions for us. -****************************************************************************/ -RCODE XFLMAPI F_FileSystem::GetTimeStamp( - const char * pszPath, - FLMUINT * puiTimeStamp) -{ -#if defined( FLM_NLM) - - return( flmNetWareGetFileTimeStamp( pszPath, puiTimeStamp)); - -#elif defined( FLM_WIN) - - WIN32_FIND_DATA find_data; - FILETIME ftLocalFileTime; - SYSTEMTIME stLastFileWriteTime; - HANDLE hSearch = INVALID_HANDLE_VALUE; - RCODE rc = NE_XFLM_OK; - F_TMSTAMP tmstamp; - - hSearch = FindFirstFile( (LPTSTR)pszPath, &find_data); - if( hSearch == INVALID_HANDLE_VALUE) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_OPENING_FILE); - switch( rc) - { - case NE_XFLM_IO_NO_MORE_FILES: - rc = RC_SET( NE_XFLM_IO_PATH_NOT_FOUND); - goto Exit; - default: - goto Exit; - } /* End switch. */ - } - - // Convert it to a local time, so we can adjust based on our own - // GroupWise time zone. - - if( FileTimeToLocalFileTime( &(find_data.ftLastWriteTime), - &ftLocalFileTime) == FALSE) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_OPENING_FILE); - goto Exit; - } - - // Convert the local time to a system time so we can map it into - // a GroupWise Date\Time structure - - if( FileTimeToSystemTime( &ftLocalFileTime, - &stLastFileWriteTime) == FALSE) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_OPENING_FILE); - goto Exit; - } - - /* Fill the Time Stamp structure */ - f_memset( &tmstamp, 0, sizeof( F_TMSTAMP)); - tmstamp.hour = (FLMBYTE)stLastFileWriteTime.wHour; - tmstamp.minute = (FLMBYTE)stLastFileWriteTime.wMinute; - tmstamp.second = (FLMBYTE)stLastFileWriteTime.wSecond; - tmstamp.hundredth = (FLMBYTE)stLastFileWriteTime.wMilliseconds; - tmstamp.year = (FLMUINT16)stLastFileWriteTime.wYear; - tmstamp.month = (FLMBYTE)(stLastFileWriteTime.wMonth - 1); - tmstamp.day = (FLMBYTE)stLastFileWriteTime.wDay; - - /* Convert and return the file time stamp as seconds since January 1, 1970 */ - f_timeDateToSeconds( &tmstamp, puiTimeStamp); - -Exit: - if( hSearch != INVALID_HANDLE_VALUE) - FindClose( hSearch); - - if( RC_OK(rc)) - *puiTimeStamp = flmLocalToUTC( *puiTimeStamp); - - return( rc); - -#else - - struct stat filestatus; - - if( stat( pszPath, &filestatus) == -1) - { - return( MapErrnoToFlaimErr( errno, NE_XFLM_GETTING_FILE_INFO)); - } - - *puiTimeStamp = (FLMUINT)filestatus.st_mtime; // st_mtime is UTC - return NE_XFLM_OK; - -#endif -} - -/**************************************************************************** -Desc: Determine if a path is a directory. -****************************************************************************/ -FLMBOOL XFLMAPI F_FileSystem::IsDir( - const char * pszDirName) -{ -#if defined( FLM_WIN) - - DWORD FileAttr = GetFileAttributes( (LPTSTR)pszDirName); - - if( FileAttr == 0xFFFFFFFF) - { - return( FALSE); - } - - return (FileAttr & FILE_ATTRIBUTE_DIRECTORY) ? TRUE : FALSE; - -#else - - struct stat filestatus; - - if( stat( (char *)pszDirName, &filestatus) == -1) - { - return FALSE; - } - - return ( S_ISDIR( filestatus.st_mode)) ? TRUE : FALSE; -#endif -} - -/**************************************************************************** -Desc: Delete a file or directory -****************************************************************************/ -RCODE XFLMAPI F_FileSystem::Delete( - const char * pszFileName) -{ -#if defined( FLM_NLM) - - return( flmNetWareDeleteFile( pszFileName)); - -#elif defined( FLM_WIN) - - if( DeleteFile( (LPTSTR)pszFileName) == FALSE) - { - return( MapWinErrorToFlaim( GetLastError(), NE_XFLM_IO_DELETING_FILE)); - } - - return( NE_XFLM_OK); - -#else - - struct stat FileStat; - - if( stat( (char *)pszFileName, &FileStat) == -1) - { - return( MapErrnoToFlaimErr( errno, NE_XFLM_GETTING_FILE_INFO)); - } - - // Ensure that the path does NOT designate a directory for deletion - - if( S_ISDIR(FileStat.st_mode)) - { - return( RC_SET( NE_XFLM_IO_ACCESS_DENIED)); - } - - // Delete the file - - if( unlink( (char *)pszFileName) == -1) - { - return( MapErrnoToFlaimErr( errno, NE_XFLM_IO_DELETING_FILE)); - } - - return( NE_XFLM_OK); - -#endif -} - -/**************************************************************************** -Desc: Copy a file. -****************************************************************************/ -RCODE XFLMAPI F_FileSystem::Copy( - const char * pszSrcFileName, // Name of source file to be copied. - const char * pszDestFileName, // Name of destination file. - FLMBOOL bOverwrite, // Overwrite destination file? - FLMUINT64 * pui64BytesCopied) // Returns number of bytes copied. -{ - RCODE rc = NE_XFLM_OK; - IF_FileHdl * pSrcFileHdl = NULL; - IF_FileHdl * pDestFileHdl = NULL; - FLMBOOL bCreatedDest = FALSE; - FLMUINT64 ui64SrcSize; - - /* - See if the destination file exists. If it does, see if it is - OK to overwrite it. If so, delete it. - */ - - if (Exists( pszDestFileName) == NE_XFLM_OK) - { - if (!bOverwrite) - { - rc = RC_SET( NE_XFLM_IO_ACCESS_DENIED); - goto Exit; - } - if (RC_BAD( rc = Delete( pszDestFileName))) - { - goto Exit; - } - } - - // Open the source file. - - if( RC_BAD( rc = Open( pszSrcFileName, XFLM_IO_RDONLY | XFLM_IO_SH_DENYNONE, - &pSrcFileHdl))) - { - goto Exit; - } - - if (RC_BAD( rc = pSrcFileHdl->Size( &ui64SrcSize))) - { - goto Exit; - } - - // Create the destination file. - - if( RC_BAD( rc = Create( pszDestFileName, XFLM_IO_RDWR | XFLM_IO_SH_DENYNONE, - &pDestFileHdl))) - { - goto Exit; - } - bCreatedDest = TRUE; - - // Do the copy. - - if( RC_BAD( rc = flmCopyPartial( pSrcFileHdl, 0, ui64SrcSize, - pDestFileHdl, 0, pui64BytesCopied))) - { - goto Exit; - } - -Exit: - - if( pSrcFileHdl) - { - pSrcFileHdl->Close(); - pSrcFileHdl->Release(); - } - - if( pDestFileHdl) - { - pDestFileHdl->Close(); - pDestFileHdl->Release(); - } - - if( RC_BAD( rc)) - { - if( bCreatedDest) - { - (void)Delete( pszDestFileName); - } - - *pui64BytesCopied = 0; - } - - return( rc); -} - -/**************************************************************************** -Desc: Rename a file. -****************************************************************************/ -RCODE XFLMAPI F_FileSystem::Rename( - const char * pszFileName, - const char * pszNewFileName) -{ -#if defined( FLM_NLM) - - return( flmNetWareRenameFile( pszFileName, pszNewFileName)); - -#elif defined( FLM_WIN) - - DWORD error; - RCODE rc = NE_XFLM_OK; - FLMUINT64 ui64BytesCopied; - - // Try to move the file by doing a rename first, otherwise copy the file - - if( (MoveFile( (LPTSTR)pszFileName, (LPTSTR)pszNewFileName)) != TRUE) - { - error = GetLastError(); - switch( error) - { - case ERROR_NOT_SAME_DEVICE: - case ERROR_NO_MORE_FILES: - case NO_ERROR: - if( Copy( pszFileName, pszNewFileName, TRUE, &ui64BytesCopied)) - { - rc = RC_SET( NE_XFLM_IO_COPY_ERR); - } - else - { - rc = F_FileSystem::Delete( pszFileName); - } - break; - default: - rc = MapWinErrorToFlaim( error, NE_XFLM_RENAMING_FILE); - break; - } - } - - return( rc); - -#else - - RCODE rc; - FLMBOOL bSrcIsDir; - FLMUINT64 ui64BytesCopied; - - if( RC_BAD( rc = unix_TargetIsDir( (char*)pszFileName, &bSrcIsDir))) - { - return( rc); - } - - errno = 0; - - if( RC_BAD( unix_RenameSafe( pszFileName, pszNewFileName))) - { - switch( errno) - { - case EXDEV: - { - if( bSrcIsDir) - { - return( RC_SET( NE_XFLM_IO_PATH_CREATE_FAILURE)); - } - else - { - if( Copy( pszFileName, pszNewFileName, TRUE, &ui64BytesCopied)) - { - return( RC_SET( NE_XFLM_IO_COPY_ERR)); - } - - F_FileSystem::Delete( pszFileName); - return( NE_XFLM_OK); - } - } - - default: - { - if( errno == ENOENT) - { - return( RC_SET( NE_XFLM_IO_RENAME_FAILURE)); - } - else - { - return( MapErrnoToFlaimErr( errno, NE_XFLM_RENAMING_FILE)); - } - } - } - } - - return( NE_XFLM_OK); -#endif -} - -/**************************************************************************** -Desc: Get the sector size (not supported on all platforms). -****************************************************************************/ -RCODE XFLMAPI F_FileSystem::GetSectorSize( - const char * pszFileName, - FLMUINT * puiSectorSize) -{ -#ifdef FLM_NLM - - F_UNREFERENCED_PARM( pszFileName); - *puiSectorSize = NETWARE_SECTOR_SIZE; - return( NE_XFLM_OK); - -#elif defined( FLM_WIN) - - RCODE rc = NE_XFLM_OK; - DWORD udSectorsPerCluster; - DWORD udBytesPerSector; - DWORD udNumberOfFreeClusters; - DWORD udTotalNumberOfClusters; - char szVolume [256]; - char * pszVolume; - FLMUINT uiLen; - - if (!pszFileName) - { - pszVolume = NULL; - } - else - { - pathParse( pszFileName, NULL, szVolume, NULL, NULL); - if (!szVolume [0]) - { - pszVolume = NULL; - } - else - { - uiLen = f_strlen( szVolume); - if (szVolume [uiLen - 1] == ':') - { - szVolume [uiLen] = '\\'; - szVolume [uiLen + 1] = 0; - } - pszVolume = &szVolume [0]; - } - } - - if (!GetDiskFreeSpace( (LPCTSTR)pszVolume, &udSectorsPerCluster, - &udBytesPerSector, &udNumberOfFreeClusters, - &udTotalNumberOfClusters)) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_INITIALIZING_IO_SYSTEM); - *puiSectorSize = 0; - goto Exit; - } - *puiSectorSize = (FLMUINT)udBytesPerSector; - -Exit: - - return( rc); - -#else - F_UNREFERENCED_PARM( pszFileName); - *puiSectorSize = (FLMUINT)sysconf( _SC_PAGESIZE); - return( NE_XFLM_OK); -#endif -} - -/**************************************************************************** -Desc: Set the Read-Only Attribute (not supported on all platforms). -****************************************************************************/ -RCODE F_FileSystem::SetReadOnly( - const char * pszFileName, - FLMBOOL bReadOnly) -{ - RCODE rc = NE_XFLM_OK; - -#if defined( FLM_UNIX) - struct stat filestatus; - - if( stat( (char *)pszFileName, &filestatus)) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_FAILURE); - goto Exit; - } - - if ( bReadOnly) - { - filestatus.st_mode &= ~S_IWUSR; - } - else - { - filestatus.st_mode |= S_IWUSR; - } - - if ( chmod( (char *)pszFileName, filestatus.st_mode)) - { - rc = RC_SET( NE_XFLM_FAILURE); - goto Exit; - } - -#elif defined( FLM_WIN) - - DWORD dwAttr; - - dwAttr = GetFileAttributes( (LPTSTR)pszFileName); - if( dwAttr == (DWORD)-1) - { - rc = RC_SET( NE_XFLM_IO_PATH_NOT_FOUND); - goto Exit; - } - - if ( bReadOnly) - { - dwAttr |= XF_IO_FA_RDONLY; - } - else - { - dwAttr &= ~XF_IO_FA_RDONLY; - } - - if( !SetFileAttributes( (LPTSTR)pszFileName, dwAttr)) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_FAILURE); - goto Exit; - } -#elif defined( FLM_NLM) - - if ( RC_BAD( rc = flmNetWareSetReadOnly( pszFileName, bReadOnly))) - { - goto Exit; - } -#else - rc = RC_SET_AND_ASSERT( NE_XFLM_NOT_IMPLEMENTED); -#endif - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: stat tpath to see if it is a directory -****************************************************************************/ -#if defined( FLM_UNIX) -RCODE F_FileSystem::unix_TargetIsDir( - const char * tpath, - FLMBOOL * isdir) -{ - struct stat sbuf; - RCODE rc = NE_XFLM_OK; - - *isdir = 0; - if( stat(tpath, &sbuf) < 0) - { - rc = MapErrnoToFlaimErr( errno, NE_XFLM_IO_ACCESS_DENIED); - } - else if( (sbuf.st_mode & S_IFMT) == S_IFDIR) - { - *isdir = 1; - } - - return( rc); -} -#endif - -/**************************************************************************** -Desc: Rename an existing file (typically an "X" locked file to an - unlocked file) using a safe (non-race) method. To ensure that - an existing file is not being overwritten by a rename operation, - we will first create a new file with the desired name (using the - CREAT and EXCL options, (ensuring a unique file name)). Then, - the source file will be renamed to new name. -****************************************************************************/ -#if defined( FLM_UNIX) -RCODE F_FileSystem::unix_RenameSafe( - const char * pszSrcFile, - const char * pszDestFile) -{ - RCODE rc = NE_XFLM_OK; - struct stat temp_stat_buf; - - errno = 0; - if( stat( pszDestFile, &temp_stat_buf) != -1) - { - // If we were able to stat it, then the file obviously exists... - - rc = RC_SET( NE_XFLM_IO_RENAME_FAILURE); - goto Exit; - } - else - { - if (errno != ENOENT) - { - // ENOENT means the file didn't exist, which is what we were - // hoping for. - - rc = MapErrnoToFlaimErr( errno, NE_XFLM_IO_RENAME_FAILURE); - goto Exit; - } - } - - errno = 0; - if( rename( pszSrcFile, pszDestFile) != 0) - { - rc = MapErrnoToFlaimErr( errno, NE_XFLM_IO_RENAME_FAILURE); - } - -Exit: - - return( rc); -} -#endif diff --git a/xflaim/src/ffilesys.h b/xflaim/src/ffilesys.h deleted file mode 100644 index a85a948..0000000 --- a/xflaim/src/ffilesys.h +++ /dev/null @@ -1,173 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: This include file contains the class definitions for FLAIM's -// file system class. -// -// Tabs: 3 -// -// Copyright (c) 1998-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: ffilesys.h 3108 2006-01-19 13:05:19 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#ifndef FFILESYS_H -#define FFILESYS_H - -/*=========================================================================== -Desc: The F_FileSystem class provides a file system abstraction for - interacting with the underlying O/S file system. -===========================================================================*/ -class F_FileSystem : public IF_FileSystem, public XF_Base -{ -public: - - F_FileSystem() - { - } - - virtual ~F_FileSystem() // Destructor - { - } - - RCODE XFLMAPI Create( // Create a new file handle - const char * pszFileName, // Name of file to be created - FLMUINT uiIoFlags, // Access amd Mode flags - IF_FileHdl ** ppFileHdl); // Returns open file handle object. - - RCODE XFLMAPI CreateBlockFile( // Create a new block-oriented file handle - const char * pszFileName, // Name of file to be created - FLMUINT uiIoFlags, // Access amd Mode flags - FLMUINT uiBlockSize, // Block size - IF_FileHdl ** ppFileHdl); // Returns open file handle object. - - RCODE XFLMAPI CreateUnique( // Create a new file (with a unique - // file name). - const char * pszDirName, // Directory where file is to be - // created. - const char * pszFileExtension, // Extension to be used on file. - FLMUINT uiIoFlags, // Access and Mode flags. - IF_FileHdl ** ppFileHdl); // Returns open file handle object. - - RCODE XFLMAPI Open( // Open an existing file. - const char * pszFileName, // Name of file to be opened. - FLMUINT uiIoFlags, // Access and Mode flags. - IF_FileHdl ** ppFileHdl); // Returns open file handle object. - - RCODE XFLMAPI OpenBlockFile( // Open an existing block-oriented file. - const char * pszFileName, // Name of file to be opened. - FLMUINT uiIoFlags, // Access and Mode flags. - FLMUINT uiBlockSize, // Block size. - IF_FileHdl ** ppFileHdl); // Returns open file handle object. - - RCODE XFLMAPI OpenDir( // Open a directory - const char * pszDirName, // Directory to be opened. - const char * pszPattern, // File name pattern. - IF_DirHdl ** ppDirHdl); // Returns open directory handle - // object. - - RCODE XFLMAPI CreateDir( // Create a directory - const char * pszDirName); // Directory to be created. - - RCODE XFLMAPI RemoveDir( // Remove a directory - const char * pszDirName, // Directory to be removed. - FLMBOOL bClear = FALSE); // OK to delete files if dir is not empty? - - RCODE XFLMAPI Exists( // See if a file or directory exists. - const char * pszFileName); // Name of file or directory to check. - - FLMBOOL XFLMAPI IsDir( // See if a path is a directory. - const char * pszFileName); // Name of path to check. - - RCODE XFLMAPI GetTimeStamp( // Get the date/time when the file - // was last updated. - const char * pszFileName, // Path to file - FLMUINT * puiTimeStamp); // Buffer in which time stamp is - // returned. - - RCODE XFLMAPI Delete( // Delete a file or directory - const char * pszFileName); // Name of file or directory to delete. - - RCODE XFLMAPI Copy( // Copy a file. - const char * pszSrcFileName, // Name of source file to be copied. - const char * pszDestFileName, // Name of destination file. - FLMBOOL bOverwrite, // Overwrite destination file? - FLMUINT64 * pui64BytesCopied);// Number of bytes copied. - - RCODE XFLMAPI Rename( // Rename a file. - const char * pszFileName, // File to be renamed - const char * pszNewFileName); // New file name - - void XFLMAPI pathParse( // ftkpath.cpp - const char * pszPath, - char * pszServer, - char * pszVolume, - char * pszDirPath, - char * pszFileName); - - RCODE XFLMAPI pathReduce( // ftkpath.cpp - const char * pszSourcePath, - char * pszDestPath, - char * pszString); - - RCODE XFLMAPI pathAppend( // ftkpath.cpp - char * pszPath, - const char * pszPathComponent); - - RCODE XFLMAPI pathToStorageString( // ftkpath.cpp - const char * pszPath, - char * pszString); - - void XFLMAPI pathCreateUniqueName( // ftkpath.cpp - FLMUINT * puiTime, - char * pszFileName, - const char * pszFileExt, - FLMBYTE * pHighChars, - FLMBOOL bModext); - - FLMBOOL XFLMAPI doesFileMatch( // ftkpath.cpp - const char * pszFileName, - const char * pszTemplate); - - RCODE XFLMAPI GetSectorSize( // Get the sector size of the volume for - const char * pszFileName, // this file. - FLMUINT * puiSectorSize); - - RCODE SetReadOnly( - const char * pszFileName, - FLMBOOL bReadOnly); - -private: - -#if defined( FLM_UNIX) - RCODE unix_RenameSafe( - const char * pszSrcFile, - const char * pszDestFile); - - RCODE unix_TargetIsDir( - const char * tpath, - FLMBOOL * isdir); -#endif -}; - -#ifndef ALLOCATE_SYS_DATA -extern F_FileSystem * gv_pFileSystem; -#else -F_FileSystem * gv_pFileSystem; -#endif - -#endif // #ifndef FFILESYS_H - diff --git a/xflaim/src/filesys.h b/xflaim/src/filesys.h index 7e8414a..f9b4023 100644 --- a/xflaim/src/filesys.h +++ b/xflaim/src/filesys.h @@ -78,14 +78,6 @@ void ScaReleaseCache( F_CachedBlock * pSCache, FLMBOOL bMutexAlreadyLocked); -#if defined( FLM_NLM) || defined( FLM_WIN) - void FastBlockCheckSum( - void * pBlk, - FLMUINT * puiChecksum, - FLMUINT * puiXORData, - FLMUINT uiNumberOfBytes); -#endif - /*============================================================================ File system Btree Cache Routines ============================================================================*/ @@ -189,87 +181,6 @@ void flmDoEventCallback( FLMUINT64 ui64NodeId, RCODE rc); -#define FLM_MAX_SEN_LEN 9 - -FLMUINT flmGetSENByteCount( - FLMUINT64 ui64Num); - -FLMUINT flmEncodeSEN( - FLMUINT64 ui64Value, - FLMBYTE ** ppucBuffer, - FLMUINT uiBytesWanted = 0); - -RCODE flmEncodeSEN( - FLMUINT64 ui64Value, - FLMBYTE ** ppucBuffer, - FLMBYTE * pucEnd); - -FLMUINT flmEncodeSENKnownLength( - FLMUINT64 ui64Value, - FLMUINT uiSenLen, - FLMBYTE ** ppucBuffer); - -RCODE flmDecodeSEN64( - const FLMBYTE ** ppucBuffer, - const FLMBYTE * pucEnd, - FLMUINT64 * pui64Value); - -FINLINE RCODE flmDecodeSEN( - const FLMBYTE ** ppucBuffer, - const FLMBYTE * pucEnd, - FLMUINT * puiValue) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT64 ui64Value; - - if( RC_BAD( rc = flmDecodeSEN64( ppucBuffer, pucEnd, &ui64Value))) - { - return( rc); - } - - if( ui64Value > FLM_MAX_UINT) - { - return( RC_SET_AND_ASSERT( NE_XFLM_CONV_NUM_OVERFLOW)); - } - - if( puiValue) - { - *puiValue = (FLMUINT)ui64Value; - } - - return( rc); -} - -#ifdef ALLOCATE_SYS_DATA - FLMBYTE gv_ucSENLengthArray[] = - { - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0 - 15 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 16 - 31 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 32 - 47 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 48 - 63 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 64 - 79 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 80 - 95 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 96 - 111 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 112 - 127 - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 128 - 143 - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 144 - 159 - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 160 - 175 - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 176 - 191 - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 192 - 207 - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 208 - 223 - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, // 224 - 239 - 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 8, 9 // 240 - 255 - }; -#else - extern FLMBYTE gv_ucSENLengthArray[]; -#endif - -FINLINE FLMUINT flmGetSENLength( - FLMBYTE ucByte) -{ - return( gv_ucSENLengthArray[ ucByte]); -} - void flmLogError( RCODE rc, const char * pszDoing, @@ -327,13 +238,6 @@ RCODE KYCollateValue( FLMBOOL * pbDataTruncated, FLMBOOL * pbOriginalCharsLost); -RCODE flmGetNextMetaphone( - IF_IStream * pIStream, - FLMUINT * puiMetaphone, - FLMUINT * puiAltMetaphone = NULL); - -RCODE flmVerifyMetaphoneRoutines( void); - #define UNDF_CHR 0x0000 // Undefined char - ignore for now #define IGNR_CHR 0x0001 // Ignore this char #define SDWD_CHR 0x0002 // Space delimited word chr @@ -382,7 +286,7 @@ F_BKGND_IX * flmBackgroundIndexGet( FLMUINT * puiThreadId = NULL); RCODE flmGetHdrInfo( - F_SuperFileHdl_p pSFileHdl, + F_SuperFileHdl * pSFileHdl, XFLM_DB_HDR * pDbHdr, FLMUINT32 * pui32CalcCRC = NULL); diff --git a/xflaim/src/flaimsys.h b/xflaim/src/flaimsys.h index 1be580a..3a7bd8b 100644 --- a/xflaim/src/flaimsys.h +++ b/xflaim/src/flaimsys.h @@ -35,6 +35,25 @@ #include "../config.h" #endif +#if defined( FLM_WIN) + // Conversion from XXX to YYY, possible loss of data + #pragma warning( disable : 4244) + + // Local variable XXX may be used without having been initialized + #pragma warning( disable : 4701) + + // Function XXX not inlined + #pragma warning( disable : 4710) +#endif + +#if defined( FLM_WATCOM_NLM) + + // Disable "Warning! W549: col(XX) 'sizeof' operand contains + // compiler generated information" + + #pragma warning 549 9 +#endif + // Put all forward references here class F_Database; @@ -51,7 +70,6 @@ class F_DbRebuild; class F_DbCheck; class F_DbInfo; class F_KeyCollector; -class F_Thread; class FSIndexCursor; class FSCollectionCursor; class FlmRecord; @@ -64,7 +82,6 @@ class F_BlockCacheMgr; class F_NodeCacheMgr; class F_NodeBufferIStream; class F_BTreeIStream; -class F_IniFile; class F_QueryResultSet; class F_BTreeInfo; class F_AttrItem; @@ -73,34 +90,23 @@ class F_RebuildNodeIStream; // Internal includes -#include "ftk.h" -#include "fbuff.h" #include "fcollate.h" #include "fdict.h" #include "fxml.h" #include "fstructs.h" #include "fcache.h" #include "flmstat.h" -#include "ffilehdl.h" -#include "ffilesys.h" -#include "f64bitfh.h" -#include "frset.h" #include "fxpath.h" #include "fbtrset.h" -#include "frecread.h" #include "fsrvlock.h" #include "fquery.h" -#include "ftkthrd.h" #include "fcollate.h" -#include "fsrvlock.h" -#include "fdir.h" #include "f_btree.h" #include "f_btpool.h" #include "rfl.h" #include "fsuperfl.h" #include "filesys.h" #include "flog.h" -#include "flfixed.h" #include "f_nici.h" RCODE MapErrnoToFlaimErr( @@ -145,14 +151,6 @@ GV_EXTERN FLMUINT64 gv_ui64MaxSignedIntVal #endif ; -#if defined( FLM_WIN) || defined( FLM_NLM) - #define FLM_CAN_GET_PHYS_MEM -#elif defined( FLM_UNIX) - #if defined( _SC_AVPHYS_PAGES) - #define FLM_CAN_GET_PHYS_MEM - #endif -#endif - // A global module lock allows us to properly implement DllCanUnloadNow // This is only used in a COM environment. The functions are actually // defined in fdllmain.cpp @@ -363,30 +361,26 @@ Some simple inline functions for dealing with tag numbers ============================================================================*/ FINLINE FLMBOOL elementIsUserDefined( - FLMUINT uiNum - ) + FLMUINT uiNum) { return( uiNum <= XFLM_MAX_ELEMENT_NUM ? TRUE : FALSE); } FINLINE FLMBOOL attributeIsUserDefined( - FLMUINT uiNum - ) + FLMUINT uiNum) { return( uiNum <= XFLM_MAX_ATTRIBUTE_NUM ? TRUE : FALSE); } FINLINE FLMBOOL elementIsReservedTag( - FLMUINT uiNum - ) + FLMUINT uiNum) { return( uiNum >= XFLM_FIRST_RESERVED_ELEMENT_TAG && uiNum <= XFLM_LAST_RESERVED_ELEMENT_TAG ? TRUE : FALSE); } FINLINE FLMBOOL attributeIsReservedTag( - FLMUINT uiNum - ) + FLMUINT uiNum) { return( uiNum >= XFLM_FIRST_RESERVED_ATTRIBUTE_TAG && uiNum <= XFLM_LAST_RESERVED_ATTRIBUTE_TAG ? TRUE : FALSE); @@ -408,7 +402,7 @@ typedef struct FlmTagInfoTag /**************************************************************************** Desc: Class for name/number lookup. ****************************************************************************/ -class F_NameTable : public XF_RefCount, public XF_Base +class F_NameTable : public F_Object { public: @@ -502,9 +496,9 @@ public: return m_bLoadedAllAttributes; } - FLMINT XFLMAPI AddRef( void); + virtual FLMINT FLMAPI AddRef( void); - FLMINT XFLMAPI Release( void); + virtual FLMINT FLMAPI Release( void); private: @@ -554,7 +548,7 @@ private: FLMUNICODE * puzNamespace, FLMUINT uiInsertPos); - F_Pool m_pool; + IF_Pool * m_pPool; FLMUINT m_uiMemoryAllocated; FLM_TAG_INFO ** m_ppSortedByTagTypeAndName; FLM_TAG_INFO ** m_ppSortedByTagTypeAndNum; @@ -724,6 +718,9 @@ FINLINE RCODE FlmStorage2UTF8( pBuffer, puiOutBufLenRV, pOutBuffer)); } +/**************************************************************************** +Desc: +****************************************************************************/ typedef struct FlmVectorElementTag { FLMUINT64 ui64ID; @@ -744,7 +741,7 @@ typedef struct FlmVectorElementTag /***************************************************************************** Desc: Used to build keys and data components *****************************************************************************/ -class F_DataVector : public IF_DataVector, public XF_Base +class F_DataVector : public IF_DataVector { public: @@ -755,48 +752,48 @@ public: // Setter methods - FINLINE void XFLMAPI setDocumentID( + FINLINE void FLMAPI setDocumentID( FLMUINT64 ui64DocumentID) { m_ui64DocumentID = ui64DocumentID; } - RCODE XFLMAPI setID( + RCODE FLMAPI setID( FLMUINT uiElementNumber, FLMUINT64 ui64ID); - RCODE XFLMAPI setNameId( + RCODE FLMAPI setNameId( FLMUINT uiElementNumber, FLMUINT uiNameId, FLMBOOL bIsAttr, FLMBOOL bIsData); - RCODE XFLMAPI setINT( + RCODE FLMAPI setINT( FLMUINT uiElementNumber, FLMINT iNum); - RCODE XFLMAPI setINT64( + RCODE FLMAPI setINT64( FLMUINT uiElementNumber, FLMINT64 i64Num); - RCODE XFLMAPI setUINT( + RCODE FLMAPI setUINT( FLMUINT uiElementNumber, FLMUINT uiNum); - RCODE XFLMAPI setUINT64( + RCODE FLMAPI setUINT64( FLMUINT uiElementNumber, FLMUINT64 ui64Num); - RCODE XFLMAPI setUnicode( + RCODE FLMAPI setUnicode( FLMUINT uiElementNumber, const FLMUNICODE * puzUnicode); - RCODE XFLMAPI setUTF8( + RCODE FLMAPI setUTF8( FLMUINT uiElementNumber, const FLMBYTE * pszUtf8, FLMUINT uiBytesInBuffer = 0); - FINLINE RCODE XFLMAPI setBinary( + FINLINE RCODE FLMAPI setBinary( FLMUINT uiElementNumber, const void * pvBinary, FLMUINT uiBinaryLen) @@ -805,7 +802,7 @@ public: XFLM_BINARY_TYPE, (FLMBYTE *)pvBinary, uiBinaryLen)); } - FINLINE void XFLMAPI setRightTruncated( + FINLINE void FLMAPI setRightTruncated( FLMUINT uiElementNumber) { F_VECTOR_ELEMENT * pVector; @@ -822,7 +819,7 @@ public: } } - FINLINE void XFLMAPI setLeftTruncated( + FINLINE void FLMAPI setLeftTruncated( FLMUINT uiElementNumber) { F_VECTOR_ELEMENT * pVector; @@ -839,7 +836,7 @@ public: } } - FINLINE void XFLMAPI clearRightTruncated( + FINLINE void FLMAPI clearRightTruncated( FLMUINT uiElementNumber) { F_VECTOR_ELEMENT * pVector; @@ -856,7 +853,7 @@ public: } } - FINLINE void XFLMAPI clearLeftTruncated( + FINLINE void FLMAPI clearLeftTruncated( FLMUINT uiElementNumber) { F_VECTOR_ELEMENT * pVector; @@ -873,7 +870,7 @@ public: } } - FINLINE FLMBOOL XFLMAPI isRightTruncated( + FINLINE FLMBOOL FLMAPI isRightTruncated( FLMUINT uiElementNumber) { F_VECTOR_ELEMENT * pVector; @@ -886,7 +883,7 @@ public: return( FALSE); } - FINLINE FLMBOOL XFLMAPI isLeftTruncated( + FINLINE FLMBOOL FLMAPI isLeftTruncated( FLMUINT uiElementNumber) { F_VECTOR_ELEMENT * pVector; @@ -901,12 +898,12 @@ public: // Getter methods - FINLINE FLMUINT64 XFLMAPI getDocumentID( void) + FINLINE FLMUINT64 FLMAPI getDocumentID( void) { return( m_ui64DocumentID); } - FINLINE FLMUINT64 XFLMAPI getID( + FINLINE FLMUINT64 FLMAPI getID( FLMUINT uiElementNumber) { F_VECTOR_ELEMENT * pVector; @@ -921,7 +918,7 @@ public: } } - FINLINE FLMUINT XFLMAPI getNameId( + FINLINE FLMUINT FLMAPI getNameId( FLMUINT uiElementNumber) { F_VECTOR_ELEMENT * pVector; @@ -936,7 +933,7 @@ public: } } - FINLINE FLMBOOL XFLMAPI isAttr( + FINLINE FLMBOOL FLMAPI isAttr( FLMUINT uiElementNumber) { F_VECTOR_ELEMENT * pVector; @@ -951,7 +948,7 @@ public: } } - FINLINE FLMBOOL XFLMAPI isDataComponent( + FINLINE FLMBOOL FLMAPI isDataComponent( FLMUINT uiElementNumber) { F_VECTOR_ELEMENT * pVector; @@ -966,7 +963,7 @@ public: } } - FINLINE FLMBOOL XFLMAPI isKeyComponent( + FINLINE FLMBOOL FLMAPI isKeyComponent( FLMUINT uiElementNumber) { F_VECTOR_ELEMENT * pVector; @@ -981,7 +978,7 @@ public: } } - FLMUINT XFLMAPI getDataLength( + FLMUINT FLMAPI getDataLength( FLMUINT uiElementNumber) { F_VECTOR_ELEMENT * pVector; @@ -996,7 +993,7 @@ public: } } - FLMUINT XFLMAPI getDataType( + FLMUINT FLMAPI getDataType( FLMUINT uiElementNumber) { F_VECTOR_ELEMENT * pVector; @@ -1011,12 +1008,12 @@ public: } } - RCODE XFLMAPI getUTF8Ptr( + RCODE FLMAPI getUTF8Ptr( FLMUINT uiElementNumber, const FLMBYTE ** ppszUTF8, FLMUINT * puiBufLen); - FINLINE RCODE XFLMAPI getINT( + FINLINE RCODE FLMAPI getINT( FLMUINT uiElementNumber, FLMINT * piNum) { @@ -1031,7 +1028,7 @@ public: : RC_SET( NE_XFLM_NOT_FOUND))); } - FINLINE RCODE XFLMAPI getINT64( + FINLINE RCODE FLMAPI getINT64( FLMUINT uiElementNumber, FLMINT64 * pi64Num) { @@ -1046,7 +1043,7 @@ public: : RC_SET( NE_XFLM_NOT_FOUND))); } - FINLINE RCODE XFLMAPI getUINT( + FINLINE RCODE FLMAPI getUINT( FLMUINT uiElementNumber, FLMUINT * puiNum) { @@ -1061,7 +1058,7 @@ public: : RC_SET( NE_XFLM_NOT_FOUND))); } - FINLINE RCODE XFLMAPI getUINT64( + FINLINE RCODE FLMAPI getUINT64( FLMUINT uiElementNumber, FLMUINT64 * pui64Num) { @@ -1076,11 +1073,11 @@ public: : RC_SET( NE_XFLM_NOT_FOUND))); } - RCODE XFLMAPI getUnicode( + RCODE FLMAPI getUnicode( FLMUINT uiElementNumber, FLMUNICODE ** ppuzUnicode); - FINLINE RCODE XFLMAPI getUnicode( + FINLINE RCODE FLMAPI getUnicode( FLMUINT uiElementNumber, IF_DynaBuf * pBuffer) { @@ -1095,7 +1092,7 @@ public: : RC_SET( NE_XFLM_NOT_FOUND))); } - FINLINE RCODE XFLMAPI getUnicode( + FINLINE RCODE FLMAPI getUnicode( FLMUINT uiElementNumber, FLMUNICODE * puzUnicode, FLMUINT * puiBufLen) @@ -1111,7 +1108,7 @@ public: : RC_SET( NE_XFLM_NOT_FOUND))); } - FINLINE RCODE XFLMAPI getUTF8( + FINLINE RCODE FLMAPI getUTF8( FLMUINT uiElementNumber, FLMBYTE * pszUTF8, FLMUINT * puiBufLen) @@ -1127,7 +1124,7 @@ public: : RC_SET( NE_XFLM_NOT_FOUND))); } - FINLINE RCODE XFLMAPI getBinary( + FINLINE RCODE FLMAPI getBinary( FLMUINT uiElementNumber, void * pvBuffer, FLMUINT * puiLength) @@ -1152,7 +1149,7 @@ public: return( RC_SET( NE_XFLM_NOT_FOUND)); } - FINLINE RCODE XFLMAPI getBinary( + FINLINE RCODE FLMAPI getBinary( FLMUINT uiElementNumber, IF_DynaBuf * pBuffer) { @@ -1168,7 +1165,7 @@ public: return( RC_SET( NE_XFLM_NOT_FOUND)); } - RCODE XFLMAPI outputKey( + RCODE FLMAPI outputKey( IF_Db * pDb, FLMUINT uiIndexNum, FLMUINT uiMatchFlags, @@ -1176,20 +1173,20 @@ public: FLMUINT uiKeyBufSize, FLMUINT * puiKeyLen); - RCODE XFLMAPI outputData( + RCODE FLMAPI outputData( IF_Db * pDb, FLMUINT uiIndexNum, FLMBYTE * pucDataBuf, FLMUINT uiDataBufSize, FLMUINT * puiDataLen); - RCODE XFLMAPI inputKey( + RCODE FLMAPI inputKey( IF_Db * pDb, FLMUINT uiIndexNum, const FLMBYTE * pucKey, FLMUINT uiKeyLen); - RCODE XFLMAPI inputData( + RCODE FLMAPI inputData( IF_Db * pDb, FLMUINT uiIndexNum, const FLMBYTE * pucData, @@ -1197,9 +1194,9 @@ public: // Miscellaneous methods - void XFLMAPI reset( void); + void FLMAPI reset( void); - FINLINE const void * XFLMAPI getDataPtr( + FINLINE const void * FLMAPI getDataPtr( FLMUINT uiElementNumber) { return( getDataPtr( getVector( uiElementNumber, VECT_SLOT_HAS_DATA))); @@ -1388,96 +1385,34 @@ friend class F_QueryResultSet; // Sweep operation scheduled due to a // dictionary change during the transaction -class F_ThreadInfo : public IF_ThreadInfo, public XF_Base -{ -public: - - F_ThreadInfo() - { - m_Pool.poolInit( 1024); - m_uiNumThreads = 0; - m_pThreadInfoArray = NULL; - } - - virtual ~F_ThreadInfo() - { - m_Pool.poolFree(); - } - - FLMUINT XFLMAPI getNumThreads( void) - { - return( m_uiNumThreads); - } - - FINLINE void XFLMAPI getThreadInfo( - FLMUINT uiThreadNum, - FLMUINT * puiThreadId, - FLMUINT * puiThreadGroup, - FLMUINT * puiAppId, - FLMUINT * puiStartTime, - const char ** ppszThreadName, - const char ** ppszThreadStatus) - { - if (uiThreadNum < m_uiNumThreads) - { - F_THREAD_INFO * pThrdInfo = &m_pThreadInfoArray [uiThreadNum]; - - *puiThreadId = pThrdInfo->uiThreadId; - *puiThreadGroup = pThrdInfo->uiThreadGroup; - *puiAppId = pThrdInfo->uiAppId; - *puiStartTime = pThrdInfo->uiStartTime; - *ppszThreadName = pThrdInfo->pszThreadName; - *ppszThreadStatus = pThrdInfo->pszThreadStatus; - } - else - { - *puiThreadId = 0; - *puiThreadGroup = 0; - *puiAppId = 0; - *puiStartTime = 0; - *ppszThreadName = NULL; - *ppszThreadStatus = NULL; - } - } - -private: - - F_Pool m_Pool; - F_THREAD_INFO * m_pThreadInfoArray; - FLMUINT m_uiNumThreads; - -friend class F_DbSystem; - -}; - /***************************************************************************** Desc: Class for performing database backup. *****************************************************************************/ -class F_Backup : public IF_Backup, public XF_Base +class F_Backup : public IF_Backup { public: F_Backup(); virtual ~F_Backup(); - FINLINE FLMUINT64 XFLMAPI getBackupTransId( void) + FINLINE FLMUINT64 FLMAPI getBackupTransId( void) { return( m_ui64TransId); } - FINLINE FLMUINT64 XFLMAPI getLastBackupTransId( void) + FINLINE FLMUINT64 FLMAPI getLastBackupTransId( void) { return( m_ui64LastBackupTransId); } - RCODE XFLMAPI backup( + RCODE FLMAPI backup( const char * pszBackupPath, const char * pszPassword, IF_BackupClient * pClient, IF_BackupStatus * pStatus, FLMUINT * puiIncSeqNum); - RCODE XFLMAPI endBackup( void); + RCODE FLMAPI endBackup( void); private: @@ -1509,7 +1444,7 @@ friend class F_Db; Desc: An implementation of IF_Backup_Client that backs up to the local hard disk. *****************************************************************************/ -class F_DefaultBackupClient : public IF_BackupClient, public XF_Base +class F_DefaultBackupClient : public IF_BackupClient { public: @@ -1518,21 +1453,21 @@ public: virtual ~F_DefaultBackupClient(); - RCODE XFLMAPI WriteData( + RCODE FLMAPI WriteData( const void * pvBuffer, FLMUINT uiBytesToWrite); - FINLINE FLMUINT getRefCount( void) + virtual FLMINT FLMAPI getRefCount( void) { return( IF_BackupClient::getRefCount()); } - virtual FINLINE FLMINT XFLMAPI AddRef( void) + virtual FLMINT FLMAPI AddRef( void) { return( IF_BackupClient::AddRef()); } - virtual FINLINE FLMINT XFLMAPI Release( void) + virtual FLMINT FLMAPI Release( void) { return( IF_BackupClient::Release()); } @@ -1540,7 +1475,7 @@ public: private: char m_szPath[ F_PATH_MAX_SIZE]; - F_64BitFileHandle * m_pFileHdl64; + IF_MultiFileHdl * m_pMultiFileHdl; FLMUINT64 m_ui64Offset; RCODE m_rc; }; @@ -1549,7 +1484,7 @@ private: Desc: The F_FSRestore class is used to read backup and RFL files from a disk file system. *****************************************************************************/ -class F_FSRestore : public IF_RestoreClient, public XF_Base +class F_FSRestore : public IF_RestoreClient { public: @@ -1561,34 +1496,34 @@ public: const char * pszBackupSetPath, const char * pszRflDir); - RCODE XFLMAPI openBackupSet( void); + RCODE FLMAPI openBackupSet( void); - RCODE XFLMAPI openIncFile( + RCODE FLMAPI openIncFile( FLMUINT uiFileNum); - RCODE XFLMAPI openRflFile( + RCODE FLMAPI openRflFile( FLMUINT uiFileNum); - RCODE XFLMAPI read( + RCODE FLMAPI read( FLMUINT uiLength, void * pvBuffer, FLMUINT * puiBytesRead); - RCODE XFLMAPI close( void); + RCODE FLMAPI close( void); - RCODE XFLMAPI abortFile( void); + RCODE FLMAPI abortFile( void); - FINLINE FLMUINT getRefCount( void) + virtual FLMINT FLMAPI getRefCount( void) { return( IF_RestoreClient::getRefCount()); } - virtual FINLINE FLMINT XFLMAPI AddRef( void) + virtual FLMINT FLMAPI AddRef( void) { return( IF_RestoreClient::AddRef()); } - virtual FINLINE FLMINT XFLMAPI Release( void) + virtual FLMINT FLMAPI Release( void) { return( IF_RestoreClient::Release()); } @@ -1596,7 +1531,7 @@ public: protected: IF_FileHdl * m_pFileHdl; - F_64BitFileHandle * m_pFileHdl64; + IF_MultiFileHdl * m_pMultiFileHdl; FLMUINT64 m_ui64Offset; FLMUINT m_uiDbVersion; char m_szDbPath[ F_PATH_MAX_SIZE]; @@ -1610,7 +1545,7 @@ protected: Desc: Default implementation of a restore status object than can be inherited by a user implementation. *****************************************************************************/ -class F_DefaultRestoreStatus : public IF_RestoreStatus, public XF_Base +class F_DefaultRestoreStatus : public IF_RestoreStatus { public: @@ -1618,7 +1553,7 @@ public: { } - RCODE XFLMAPI reportProgress( + RCODE FLMAPI reportProgress( eRestoreAction * peAction, FLMUINT64, // ui64BytesToDo, FLMUINT64) // ui64BytesDone @@ -1627,7 +1562,7 @@ public: return( NE_XFLM_OK); } - RCODE XFLMAPI reportError( + RCODE FLMAPI reportError( eRestoreAction * peAction, RCODE) // rcErr { @@ -1635,7 +1570,7 @@ public: return( NE_XFLM_OK); } - RCODE XFLMAPI reportBeginTrans( + RCODE FLMAPI reportBeginTrans( eRestoreAction * peAction, FLMUINT64) // ui64TransId { @@ -1643,7 +1578,7 @@ public: return( NE_XFLM_OK); } - RCODE XFLMAPI reportCommitTrans( + RCODE FLMAPI reportCommitTrans( eRestoreAction * peAction, FLMUINT64) // ui64TransId { @@ -1651,7 +1586,7 @@ public: return( NE_XFLM_OK); } - RCODE XFLMAPI reportAbortTrans( + RCODE FLMAPI reportAbortTrans( eRestoreAction * peAction, FLMUINT64) // ui64TransId { @@ -1659,7 +1594,7 @@ public: return( NE_XFLM_OK); } - RCODE XFLMAPI reportRemoveData( + RCODE FLMAPI reportRemoveData( eRestoreAction * peAction, FLMUINT64, // ui64TransId, FLMUINT, // uiLfNum, @@ -1670,7 +1605,7 @@ public: return( NE_XFLM_OK); } - RCODE XFLMAPI reportInsertData( + RCODE FLMAPI reportInsertData( eRestoreAction * peAction, FLMUINT64, // ui64TransId, FLMUINT, // uiLfNum, @@ -1681,7 +1616,7 @@ public: return( NE_XFLM_OK); } - RCODE XFLMAPI reportReplaceData( + RCODE FLMAPI reportReplaceData( eRestoreAction * peAction, FLMUINT64, // ui64TransId, FLMUINT, // uiLfNum, @@ -1692,7 +1627,7 @@ public: return( NE_XFLM_OK); } - RCODE XFLMAPI reportLFileCreate( + RCODE FLMAPI reportLFileCreate( eRestoreAction * peAction, FLMUINT64, // ui64TransId, FLMUINT) // uiLfNum @@ -1701,7 +1636,7 @@ public: return( NE_XFLM_OK); } - RCODE XFLMAPI reportLFileUpdate( + RCODE FLMAPI reportLFileUpdate( eRestoreAction * peAction, FLMUINT64, // ui64TransId, FLMUINT, // uiLfNum, @@ -1715,7 +1650,7 @@ public: return( NE_XFLM_OK); } - RCODE XFLMAPI reportUpdateDict( + RCODE FLMAPI reportUpdateDict( eRestoreAction * peAction, FLMUINT64, // ui64TransId, FLMUINT, // uiDictType, @@ -1726,7 +1661,7 @@ public: return( NE_XFLM_OK); } - RCODE XFLMAPI reportIndexSuspend( + RCODE FLMAPI reportIndexSuspend( eRestoreAction * peAction, FLMUINT64, // ui64TransId, FLMUINT) // uiIndexNum @@ -1735,7 +1670,7 @@ public: return( NE_XFLM_OK); } - RCODE XFLMAPI reportIndexResume( + RCODE FLMAPI reportIndexResume( eRestoreAction * peAction, FLMUINT64, // ui64TransId, FLMUINT) // uiIndexNum @@ -1744,7 +1679,7 @@ public: return( NE_XFLM_OK); } - RCODE XFLMAPI reportReduce( + RCODE FLMAPI reportReduce( eRestoreAction * peAction, FLMUINT64, // ui64TransId, FLMUINT) // uiCount @@ -1753,7 +1688,7 @@ public: return( NE_XFLM_OK); } - RCODE XFLMAPI reportUpgrade( + RCODE FLMAPI reportUpgrade( eRestoreAction * peAction, FLMUINT64, // ui64TransId, FLMUINT, // uiOldDbVersion, @@ -1763,7 +1698,7 @@ public: return( NE_XFLM_OK); } - RCODE XFLMAPI reportEnableEncryption( + RCODE FLMAPI reportEnableEncryption( eRestoreAction * peAction, FLMUINT64 // ui64TransId ) @@ -1772,7 +1707,7 @@ public: return( NE_XFLM_OK); } - RCODE XFLMAPI reportWrapKey( + RCODE FLMAPI reportWrapKey( eRestoreAction * peAction, FLMUINT64) // ui64TransId { @@ -1780,7 +1715,7 @@ public: return( NE_XFLM_OK); } - RCODE XFLMAPI reportOpenRflFile( + RCODE FLMAPI reportOpenRflFile( eRestoreAction * peAction, FLMUINT) // uiFileNum { @@ -1788,7 +1723,7 @@ public: return( NE_XFLM_OK); } - RCODE XFLMAPI reportRflRead( + RCODE FLMAPI reportRflRead( eRestoreAction * peAction, FLMUINT, // uiFileNum, FLMUINT) // uiBytesRead @@ -1797,17 +1732,17 @@ public: return( NE_XFLM_OK); } - FINLINE FLMUINT getRefCount( void) + virtual FLMINT FLMAPI getRefCount( void) { return( IF_RestoreStatus::getRefCount()); } - virtual FINLINE FLMINT XFLMAPI AddRef( void) + virtual FLMINT FLMAPI AddRef( void) { return( IF_RestoreStatus::AddRef()); } - virtual FINLINE FLMINT XFLMAPI Release( void) + virtual FLMINT FLMAPI Release( void) { return( IF_RestoreStatus::Release()); } @@ -1860,7 +1795,7 @@ typedef struct OLD_NODE_DATA /***************************************************************************** Desc: Thread's database object - returned by dbOpen, dbCreate in F_DbSystem class *****************************************************************************/ -class F_OldNodeList : public XF_RefCount, public XF_Base +class F_OldNodeList : public F_Object { public: @@ -1869,10 +1804,12 @@ public: m_pNodeList = NULL; m_uiListSize = 0; m_uiNodeCount = 0; - m_pool.poolInit( 512); + m_pPool = NULL; } ~F_OldNodeList(); + + RCODE setup( void); FLMBOOL findNodeInList( eDomNodeType eNodeType, @@ -1897,7 +1834,7 @@ public: private: OLD_NODE_DATA * m_pNodeList; - F_Pool m_pool; + IF_Pool * m_pPool; FLMUINT m_uiListSize; FLMUINT m_uiNodeCount; }; @@ -1905,7 +1842,7 @@ private: /***************************************************************************** Desc: Thread's database object - returned by dbOpen, dbCreate in F_DbSystem class *****************************************************************************/ -class F_Db : public IF_Db, public XF_Base +class F_Db : public IF_Db { public: @@ -1913,41 +1850,43 @@ public: FLMBOOL bInternalOpen); virtual ~F_Db(); + + RCODE setup( void); - RCODE XFLMAPI transBegin( + RCODE FLMAPI transBegin( eDbTransType eTransType, FLMUINT uiMaxLockWait = XFLM_NO_TIMEOUT, FLMUINT uiFlags = 0, XFLM_DB_HDR * pDbHeader = NULL); - RCODE XFLMAPI transBegin( + RCODE FLMAPI transBegin( IF_Db * pDb); - RCODE XFLMAPI transCommit( + RCODE FLMAPI transCommit( FLMBOOL * pbEmpty = NULL); - RCODE XFLMAPI transAbort( void); + RCODE FLMAPI transAbort( void); - FINLINE eDbTransType XFLMAPI getTransType( void) + FINLINE eDbTransType FLMAPI getTransType( void) { return( m_eTransType); } - RCODE XFLMAPI doCheckpoint( + RCODE FLMAPI doCheckpoint( FLMUINT uiTimeout); - RCODE XFLMAPI dbLock( + RCODE FLMAPI dbLock( eDbLockType eLockType, FLMINT iPriority, FLMUINT uiTimeout); - RCODE XFLMAPI dbUnlock( void); + RCODE FLMAPI dbUnlock( void); - RCODE XFLMAPI getLockType( + RCODE FLMAPI getLockType( eDbLockType * peLockType, FLMBOOL * pbImplicit); - RCODE XFLMAPI getLockInfo( + RCODE FLMAPI getLockInfo( FLMINT iPriority, eDbLockType * peCurrLockType, FLMUINT * puiThreadId, @@ -1968,79 +1907,79 @@ public: // Index methods - RCODE XFLMAPI indexStatus( + RCODE FLMAPI indexStatus( FLMUINT uiIndexNum, XFLM_INDEX_STATUS * pIndexStatus); - RCODE XFLMAPI indexGetNext( + RCODE FLMAPI indexGetNext( FLMUINT * puiIndexNum); - RCODE XFLMAPI indexSuspend( + RCODE FLMAPI indexSuspend( FLMUINT uiIndexNum); - RCODE XFLMAPI indexResume( + RCODE FLMAPI indexResume( FLMUINT uiIndexNum); // Retrieval Functions - RCODE XFLMAPI keyRetrieve( + RCODE FLMAPI keyRetrieve( FLMUINT uiIndex, IF_DataVector * ifpSearchKey, FLMUINT uiFlags, IF_DataVector * ifpFoundKey); - RCODE XFLMAPI enableEncryption( void); + RCODE FLMAPI enableEncryption( void); - RCODE XFLMAPI wrapKey( + RCODE FLMAPI wrapKey( const char * pszPassword = NULL); - RCODE XFLMAPI rollOverDbKey( void); + RCODE FLMAPI rollOverDbKey( void); - RCODE XFLMAPI changeItemState( + RCODE FLMAPI changeItemState( FLMUINT uiDictType, FLMUINT uiDictNum, const char * pszState); - RCODE XFLMAPI reduceSize( + RCODE FLMAPI reduceSize( FLMUINT uiCount, FLMUINT * puiCountRV); - RCODE XFLMAPI upgrade( + RCODE FLMAPI upgrade( IF_UpgradeClient * pUpgradeClient); - RCODE XFLMAPI createRootElement( + RCODE FLMAPI createRootElement( FLMUINT uiCollection, FLMUINT uiNameId, IF_DOMNode ** ppElementNode, FLMUINT64 * pui64NodeId = NULL); - RCODE XFLMAPI createDocument( + RCODE FLMAPI createDocument( FLMUINT uiCollection, IF_DOMNode ** ppDocumentNode, FLMUINT64 * pui64NodeId = NULL); - RCODE XFLMAPI getFirstDocument( + RCODE FLMAPI getFirstDocument( FLMUINT uiCollection, IF_DOMNode ** ppDocumentNode); - RCODE XFLMAPI getLastDocument( + RCODE FLMAPI getLastDocument( FLMUINT uiCollection, IF_DOMNode ** ppDocumentNode); - RCODE XFLMAPI getDocument( + RCODE FLMAPI getDocument( FLMUINT uiCollection, FLMUINT uiFlags, FLMUINT64 ui64DocumentId, IF_DOMNode ** ppDocumentNode); - RCODE XFLMAPI documentDone( + RCODE FLMAPI documentDone( FLMUINT uiCollection, FLMUINT64 ui64RootId); - RCODE XFLMAPI documentDone( + RCODE FLMAPI documentDone( IF_DOMNode * pDocNode); - FINLINE RCODE XFLMAPI createElementDef( + FINLINE RCODE FLMAPI createElementDef( const char * pszNamespaceURI, const char * pszElementName, FLMUINT uiDataType, @@ -2052,7 +1991,7 @@ public: puiElementNameId, (F_DOMNode **)ppDocumentNode)); } - FINLINE RCODE XFLMAPI createElementDef( + FINLINE RCODE FLMAPI createElementDef( const FLMUNICODE * puzNamespaceURI, const FLMUNICODE * puzElementName, FLMUINT uiDataType, @@ -2064,7 +2003,7 @@ public: puiElementNameId, (F_DOMNode **)ppDocumentNode)); } - FINLINE RCODE XFLMAPI createUniqueElmDef( + FINLINE RCODE FLMAPI createUniqueElmDef( const char * pszNamespaceURI, const char * pszElementName, FLMUINT * puiElementNameId = NULL, @@ -2075,7 +2014,7 @@ public: puiElementNameId, (F_DOMNode **)ppDocumentNode)); } - FINLINE RCODE XFLMAPI createUniqueElmDef( + FINLINE RCODE FLMAPI createUniqueElmDef( const FLMUNICODE * puzNamespaceURI, const FLMUNICODE * puzElementName, FLMUINT * puiElementNameId = NULL, @@ -2086,17 +2025,17 @@ public: puiElementNameId, (F_DOMNode **)ppDocumentNode)); } - RCODE XFLMAPI getElementNameId( + RCODE FLMAPI getElementNameId( const char * pszNamespaceURI, const char * pszElementName, FLMUINT * puiElementNameId); - RCODE XFLMAPI getElementNameId( + RCODE FLMAPI getElementNameId( const FLMUNICODE * puzNamespaceURI, const FLMUNICODE * puzElementName, FLMUINT * puiElementNameId); - FINLINE RCODE XFLMAPI createAttributeDef( + FINLINE RCODE FLMAPI createAttributeDef( const char * pszNamespaceURI, const char * pszAttributeName, FLMUINT uiDataType, @@ -2108,7 +2047,7 @@ public: (F_DOMNode **)ppDocumentNode)); } - FINLINE RCODE XFLMAPI createAttributeDef( + FINLINE RCODE FLMAPI createAttributeDef( const FLMUNICODE * puzNamespaceURI, const FLMUNICODE * puzAttributeName, FLMUINT uiDataType, @@ -2120,39 +2059,39 @@ public: (F_DOMNode **)ppDocumentNode)); } - RCODE XFLMAPI getAttributeNameId( + RCODE FLMAPI getAttributeNameId( const char * pszNamespaceURI, const char * pszAttributeName, FLMUINT * puiAttributeNameId); - RCODE XFLMAPI getAttributeNameId( + RCODE FLMAPI getAttributeNameId( const FLMUNICODE * puzNamespaceURI, const FLMUNICODE * puzAttributeName, FLMUINT * puiAttributeNameId); - FINLINE RCODE XFLMAPI createPrefixDef( + FINLINE RCODE FLMAPI createPrefixDef( const char * pszPrefixName, FLMUINT * puiPrefixNumber) { return( createPrefixDef( FALSE, pszPrefixName, puiPrefixNumber)); } - FINLINE RCODE XFLMAPI createPrefixDef( + FINLINE RCODE FLMAPI createPrefixDef( const FLMUNICODE * puzPrefixName, FLMUINT * puiPrefixNumber) { return( createPrefixDef( TRUE, puzPrefixName, puiPrefixNumber)); } - RCODE XFLMAPI getPrefixId( + RCODE FLMAPI getPrefixId( const char * pszPrefixName, FLMUINT * puiPrefixNumber); - RCODE XFLMAPI getPrefixId( + RCODE FLMAPI getPrefixId( const FLMUNICODE * puzPrefixName, FLMUINT * puiPrefixNumber); - FINLINE RCODE XFLMAPI createEncDef( + FINLINE RCODE FLMAPI createEncDef( const char * pszEncType, const char * pszEncName, FLMUINT uiKeySize = 0, @@ -2162,7 +2101,7 @@ public: uiKeySize, puiEncDefNumber)); } - FINLINE RCODE XFLMAPI createEncDef( + FINLINE RCODE FLMAPI createEncDef( const FLMUNICODE * puzEncType, const FLMUNICODE * puzEncName, FLMUINT uiKeySize = 0, @@ -2172,15 +2111,15 @@ public: uiKeySize, puiEncDefNumber)); } - RCODE XFLMAPI getEncDefId( + RCODE FLMAPI getEncDefId( const char * pszEncDefName, FLMUINT * puiEncDefNumber); - RCODE XFLMAPI getEncDefId( + RCODE FLMAPI getEncDefId( const FLMUNICODE * puzEncDefName, FLMUINT * puiEncDefNumber); - FINLINE RCODE XFLMAPI createCollectionDef( + FINLINE RCODE FLMAPI createCollectionDef( const char * pszCollectionName, FLMUINT * puiCollectionNumber, FLMUINT uiEncNumber = 0) @@ -2189,7 +2128,7 @@ public: puiCollectionNumber, uiEncNumber)); } - FINLINE RCODE XFLMAPI createCollectionDef( + FINLINE RCODE FLMAPI createCollectionDef( const FLMUNICODE * puzCollectionName, FLMUINT * puiCollectionNumber, FLMUINT uiEncNumber = 0) @@ -2198,28 +2137,28 @@ public: puiCollectionNumber, uiEncNumber)); } - RCODE XFLMAPI getCollectionNumber( + RCODE FLMAPI getCollectionNumber( const char * pszCollectionName, FLMUINT * puiCollectionNumber); - RCODE XFLMAPI getCollectionNumber( + RCODE FLMAPI getCollectionNumber( const FLMUNICODE * puzCollectionName, FLMUINT * puiCollectionNumber); - RCODE XFLMAPI getIndexNumber( + RCODE FLMAPI getIndexNumber( const char * pszIndexName, FLMUINT * puiIndexNumber); - RCODE XFLMAPI getIndexNumber( + RCODE FLMAPI getIndexNumber( const FLMUNICODE * puzIndexName, FLMUINT * puiIndexNumber); - RCODE XFLMAPI getDictionaryDef( + RCODE FLMAPI getDictionaryDef( FLMUINT uiDictType, FLMUINT uiDictNumber, IF_DOMNode ** ppDocumentNode); - RCODE XFLMAPI getDictionaryName( + RCODE FLMAPI getDictionaryName( FLMUINT uiDictType, FLMUINT uiDictNumber, char * pszName, @@ -2227,7 +2166,7 @@ public: char * pszNamespace = NULL, FLMUINT * puiNamespaceBufSize = NULL); - RCODE XFLMAPI getDictionaryName( + RCODE FLMAPI getDictionaryName( FLMUINT uiDictType, FLMUINT uiDictNumber, FLMUNICODE * puzName, @@ -2235,7 +2174,7 @@ public: FLMUNICODE * puzNamespace = NULL, FLMUINT * puiNamespaceBufSize = NULL); - RCODE XFLMAPI getNode( + RCODE FLMAPI getNode( FLMUINT uiCollection, FLMUINT64 ui64NodeId, IF_DOMNode ** ifppNode) @@ -2260,121 +2199,121 @@ public: return( getNode( uiCollection, ui64NodeId, XFLM_EXCL, ppNode)); } - RCODE XFLMAPI getAttribute( + RCODE FLMAPI getAttribute( FLMUINT uiCollection, FLMUINT64 ui64ElementId, FLMUINT uiAttrName, IF_DOMNode ** ppNode); - RCODE XFLMAPI getDataType( + RCODE FLMAPI getDataType( FLMUINT uiDictType, FLMUINT uiNameId, FLMUINT * puiDataType); - RCODE XFLMAPI backupBegin( + RCODE FLMAPI backupBegin( eDbBackupType eBackupType, eDbTransType eTransType, FLMUINT uiMaxLockWait, IF_Backup ** ppBackup); - void XFLMAPI getRflFileName( + void FLMAPI getRflFileName( FLMUINT uiFileNum, FLMBOOL bBaseOnly, char * pszFileName, FLMUINT * puiFileNameBufSize, FLMBOOL * pbNameTruncated = NULL); - RCODE XFLMAPI import( + RCODE FLMAPI import( IF_IStream * pIStream, FLMUINT uiCollection, IF_DOMNode * pNodeToLinkTo = NULL, eNodeInsertLoc eInsertLoc = XFLM_LAST_CHILD, XFLM_IMPORT_STATS * pImportStats = NULL); - RCODE XFLMAPI importDocument( + RCODE FLMAPI importDocument( IF_IStream * ifpStream, FLMUINT uiCollection, IF_DOMNode ** ppDocumentNode = NULL, XFLM_IMPORT_STATS * pImportStats = NULL); - RCODE XFLMAPI exportXML( + RCODE FLMAPI exportXML( IF_DOMNode * pStartNode, IF_OStream * pOStream, eExportFormatType eFormat = XFLM_EXPORT_INDENT); - RCODE XFLMAPI setNextNodeId( + RCODE FLMAPI setNextNodeId( FLMUINT uiCollection, FLMUINT64 ui64NextNodeId); - RCODE XFLMAPI setNextDictNum( + RCODE FLMAPI setNextDictNum( FLMUINT uiDictType, FLMUINT uiDictNumber); // Configuration methods - RCODE XFLMAPI setRflKeepFilesFlag( + RCODE FLMAPI setRflKeepFilesFlag( FLMBOOL bKeep); - RCODE XFLMAPI getRflKeepFlag( + RCODE FLMAPI getRflKeepFlag( FLMBOOL * pbKeep); - RCODE XFLMAPI setRflDir( + RCODE FLMAPI setRflDir( const char * pszNewRflDir); - void XFLMAPI getRflDir( + void FLMAPI getRflDir( char * pszRflDir); - RCODE XFLMAPI getRflFileNum( + RCODE FLMAPI getRflFileNum( FLMUINT * puiRflFileNum); - RCODE XFLMAPI getHighestNotUsedRflFileNum( + RCODE FLMAPI getHighestNotUsedRflFileNum( FLMUINT * puiHighestNotUsedRflFileNum); - RCODE XFLMAPI setRflFileSizeLimits( + RCODE FLMAPI setRflFileSizeLimits( FLMUINT uiMinRflSize, FLMUINT uiMaxRflSize); - RCODE XFLMAPI getRflFileSizeLimits( + RCODE FLMAPI getRflFileSizeLimits( FLMUINT * puiRflMinFileSize, FLMUINT * puiRflMaxFileSize); - RCODE XFLMAPI rflRollToNextFile( void); + RCODE FLMAPI rflRollToNextFile( void); - RCODE XFLMAPI setKeepAbortedTransInRflFlag( + RCODE FLMAPI setKeepAbortedTransInRflFlag( FLMBOOL bKeep); - RCODE XFLMAPI getKeepAbortedTransInRflFlag( + RCODE FLMAPI getKeepAbortedTransInRflFlag( FLMBOOL * pbKeep); - RCODE XFLMAPI setAutoTurnOffKeepRflFlag( + RCODE FLMAPI setAutoTurnOffKeepRflFlag( FLMBOOL bAutoTurnOff); - RCODE XFLMAPI getAutoTurnOffKeepRflFlag( + RCODE FLMAPI getAutoTurnOffKeepRflFlag( FLMBOOL * pbAutoTurnOff); - FINLINE void XFLMAPI setFileExtendSize( + FINLINE void FLMAPI setFileExtendSize( FLMUINT uiFileExtendSize) { m_pDatabase->m_uiFileExtendSize = uiFileExtendSize; } - FINLINE FLMUINT XFLMAPI getFileExtendSize( void) + FINLINE FLMUINT FLMAPI getFileExtendSize( void) { return( m_pDatabase->m_uiFileExtendSize); } - FINLINE void XFLMAPI setAppData( + FINLINE void FLMAPI setAppData( void * pvAppData) { m_pvAppData = pvAppData; } - FINLINE void * XFLMAPI getAppData( void) + FINLINE void * FLMAPI getAppData( void) { return( m_pvAppData); } - FINLINE void XFLMAPI setDeleteStatusObject( + FINLINE void FLMAPI setDeleteStatusObject( IF_DeleteStatus * pDeleteStatus) { if (m_pDeleteStatus) @@ -2387,7 +2326,7 @@ public: } } - FINLINE void XFLMAPI setCommitClientObject( + FINLINE void FLMAPI setCommitClientObject( IF_CommitClient * pCommitClient) { if (m_pCommitClient) @@ -2403,7 +2342,7 @@ public: } } - FINLINE void XFLMAPI setIndexingClientObject( + FINLINE void FLMAPI setIndexingClientObject( IF_IxClient * pIxClient) { if (m_pIxClient) @@ -2417,7 +2356,7 @@ public: } } - FINLINE void XFLMAPI setIndexingStatusObject( + FINLINE void FLMAPI setIndexingStatusObject( IF_IxStatus * ifpIxStatus) { if (m_pIxStatus) @@ -2433,22 +2372,22 @@ public: // Configuration information getting methods - FINLINE FLMUINT XFLMAPI getDbVersion( void) + FINLINE FLMUINT FLMAPI getDbVersion( void) { return( (FLMUINT)m_pDatabase->m_lastCommittedDbHdr.ui32DbVersion); } - FINLINE FLMUINT XFLMAPI getBlockSize( void) + FINLINE FLMUINT FLMAPI getBlockSize( void) { return( m_pDatabase->m_uiBlockSize); } - FINLINE FLMUINT XFLMAPI getDefaultLanguage( void) + FINLINE FLMUINT FLMAPI getDefaultLanguage( void) { return( m_pDatabase->m_uiDefaultLanguage); } - FINLINE FLMUINT64 XFLMAPI getTransID( void) + FINLINE FLMUINT64 FLMAPI getTransID( void) { if (m_eTransType != XFLM_NO_TRANS) { @@ -2462,10 +2401,10 @@ public: return( 0); } - void XFLMAPI getCheckpointInfo( + void FLMAPI getCheckpointInfo( XFLM_CHECKPOINT_INFO * pCheckpointInfo); - RCODE XFLMAPI getDbControlFileName( + RCODE FLMAPI getDbControlFileName( char * pszControlFileName, FLMUINT uiControlFileBufSize) { @@ -2487,32 +2426,32 @@ public: return( m_pDatabase->m_pDatabaseLockObj->ThreadWaitingLock()); } - RCODE XFLMAPI getLockWaiters( + RCODE FLMAPI getLockWaiters( IF_LockInfoClient * pLockInfo); - RCODE XFLMAPI getLastBackupTransID( + RCODE FLMAPI getLastBackupTransID( FLMUINT64 * pui64LastBackupTransID); - RCODE XFLMAPI getBlocksChangedSinceBackup( + RCODE FLMAPI getBlocksChangedSinceBackup( FLMUINT * puiBlocksChangedSinceBackup); - RCODE XFLMAPI getNextIncBackupSequenceNum( + RCODE FLMAPI getNextIncBackupSequenceNum( FLMUINT * puiNextIncBackupSequenceNum); - void XFLMAPI getSerialNumber( + void FLMAPI getSerialNumber( char * pucSerialNumber); - RCODE XFLMAPI getDiskSpaceUsage( + RCODE FLMAPI getDiskSpaceUsage( FLMUINT64 * pui64DataSize, FLMUINT64 * pui64RollbackSize, FLMUINT64 * pui64RflSize); - FINLINE RCODE XFLMAPI getMustCloseRC( void) + FINLINE RCODE FLMAPI getMustCloseRC( void) { return( m_pDatabase->m_rcMustClose); } - FINLINE RCODE XFLMAPI getAbortRC( void) + FINLINE RCODE FLMAPI getAbortRC( void) { return( m_AbortRc); } @@ -2558,7 +2497,7 @@ public: return( startTransaction( eReqTransType, pbStartedTrans)); } - FINLINE void XFLMAPI setMustAbortTrans( + FINLINE void FLMAPI setMustAbortTrans( RCODE rc) { if( RC_BAD( rc) && RC_OK( m_AbortRc)) @@ -2640,7 +2579,7 @@ public: } RCODE backgroundIndexBuild( - F_Thread * pThread, + IF_Thread * pThread, FLMBOOL * pbShutdown, FLMINT * piErrorLine); @@ -2756,7 +2695,7 @@ private: XFLM_CREATE_OPTS * pCreateOpts); RCODE beginBackgroundTrans( - F_Thread * pThread); + IF_Thread * pThread); RCODE beginTrans( eDbTransType eTransType, @@ -3026,7 +2965,7 @@ private: IF_IxClient * ifpIxClient, XFLM_INDEX_STATUS * pIndexStatus, FLMBOOL * pbHitEnd, - F_Thread * pThread = NULL); + IF_Thread * pThread = NULL); RCODE setIxStateInfo( FLMUINT uiIndexNum, @@ -3110,7 +3049,7 @@ private: FLMUINT64 * pui64NodeId = NULL); RCODE sweep( - F_Thread * pThread); + IF_Thread * pThread); RCODE sweepGatherList( ELM_ATTR_STATE_INFO ** ppStateTbl, @@ -3234,12 +3173,12 @@ private: // in the pool. FLMBYTE * m_pucKrefKeyBuf; // Pointer to temporary key buffer. FLMBOOL m_bKrefSetup; // True if the KRef table has been initialized. - F_Pool * m_pKrefPool; // Memory pool to use + IF_Pool * m_pKrefPool; // Memory pool to use FLMBOOL m_bReuseKrefPool; // Reuse pool instead of free it? FLMBOOL m_bKrefCompoundKey; // True if a compound key has been processed. void * m_pKrefReset; // Used to reset the Kref pool on // indexing failures - F_Pool m_tmpKrefPool; // KREF pool to be used during + IF_Pool * m_pTmpKrefPool; // KREF pool to be used during // read transactions - only used when // checking indexes. @@ -3288,7 +3227,7 @@ private: // 2) a 'purge' element or attribute // can be deleted - F_Pool m_TempPool; // Temporary memory pool. It + IF_Pool * m_pTempPool; // Temporary memory pool. It // is only used for the duration of // a FLAIM operation and then reset. // The first block in the pool is @@ -3483,231 +3422,10 @@ typedef struct ExprState EXPR_STATE_p pNext; } EXPR_STATE; -/***************************************************************************** -Desc: Object for using a buffer on the stack until we outgrow it. -*****************************************************************************/ -class F_DynaBuf : public IF_DynaBuf -{ -public: - - F_DynaBuf( - FLMBYTE * pucBuffer, - FLMUINT uiBufferSize) - { - m_pucBuffer = pucBuffer; - m_uiBufferSize = uiBufferSize; - m_uiOffset = 0; - m_bAllocatedBuffer = FALSE; - } - - virtual ~F_DynaBuf() - { - if( m_bAllocatedBuffer) - { - f_free( &m_pucBuffer); - } - } - - FINLINE void truncateData( - FLMUINT uiSize) - { - if( uiSize < m_uiOffset) - { - m_uiOffset = uiSize; - } - } - - FINLINE RCODE allocSpace( - FLMUINT uiSize, - void ** ppvPtr) - { - RCODE rc = NE_XFLM_OK; - - if( m_uiOffset + uiSize >= m_uiBufferSize) - { - if( RC_BAD( rc = resizeBuffer( m_uiOffset + uiSize + 512))) - { - goto Exit; - } - } - - *ppvPtr = &m_pucBuffer[ m_uiOffset]; - m_uiOffset += uiSize; - - Exit: - - return( rc); - } - - FINLINE RCODE appendData( - const void * pvData, - FLMUINT uiSize) - { - RCODE rc = NE_XFLM_OK; - void * pvTmp; - - if( RC_BAD( rc = allocSpace( uiSize, &pvTmp))) - { - goto Exit; - } - - if( uiSize == 1) - { - *((FLMBYTE *)pvTmp) = *((FLMBYTE *)pvData); - } - else - { - f_memcpy( pvTmp, pvData, uiSize); - } - - Exit: - - return( rc); - } - - FINLINE RCODE appendByte( - FLMBYTE ucChar) - { - RCODE rc = NE_XFLM_OK; - FLMBYTE * pucTmp; - - if( RC_BAD( rc = allocSpace( 1, (void **)&pucTmp))) - { - goto Exit; - } - - *pucTmp = ucChar; - - Exit: - - return( rc); - } - - FINLINE RCODE appendUniChar( - FLMUNICODE uChar) - { - RCODE rc = NE_XFLM_OK; - FLMUNICODE * puTmp; - - if( RC_BAD( rc = allocSpace( sizeof( FLMUNICODE), (void **)&puTmp))) - { - goto Exit; - } - - *puTmp = uChar; - - Exit: - - return( rc); - } - - FINLINE FLMBYTE * getBufferPtr( void) - { - return( m_pucBuffer); - } - - FINLINE FLMUNICODE * getUnicodePtr( void) - { - if( m_uiOffset >= sizeof( FLMUNICODE)) - { - return( (FLMUNICODE *)m_pucBuffer); - } - - return( NULL); - } - - FINLINE FLMUINT getUnicodeLength( void) - { - if( m_uiOffset <= sizeof( FLMUNICODE)) - { - return( 0); - } - - return( (m_uiOffset >> 1) - 1); - } - - FINLINE FLMUINT getDataLength( void) - { - return( m_uiOffset); - } - - FINLINE RCODE copyFromBuffer( - F_DynaBuf * pSource) - { - RCODE rc = NE_XFLM_OK; - - if( RC_BAD( rc = resizeBuffer( pSource->m_uiBufferSize))) - { - goto Exit; - } - - if( (m_uiOffset = pSource->m_uiOffset) != 0) - { - f_memcpy( m_pucBuffer, pSource->m_pucBuffer, pSource->m_uiOffset); - } - - Exit: - - return( rc); - } - -private: - - RCODE resizeBuffer( - FLMUINT uiNewSize) - { - RCODE rc = NE_XFLM_OK; - - if( !m_bAllocatedBuffer) - { - if( uiNewSize > m_uiBufferSize) - { - FLMBYTE * pucOriginalBuf = m_pucBuffer; - - if( RC_BAD( rc = f_alloc( uiNewSize, &m_pucBuffer))) - { - m_pucBuffer = pucOriginalBuf; - goto Exit; - } - - m_bAllocatedBuffer = TRUE; - - if( m_uiOffset) - { - f_memcpy( m_pucBuffer, pucOriginalBuf, m_uiOffset); - } - } - } - else - { - if( RC_BAD( rc = f_realloc( uiNewSize, &m_pucBuffer))) - { - goto Exit; - } - - if( uiNewSize < m_uiOffset) - { - m_uiOffset = uiNewSize; - } - } - - m_uiBufferSize = uiNewSize; - - Exit: - - return( rc); - } - - FLMBOOL m_bAllocatedBuffer; - FLMBYTE * m_pucBuffer; - FLMUINT m_uiBufferSize; - FLMUINT m_uiOffset; -}; - /***************************************************************************** Desc: Object for gathering node information. *****************************************************************************/ -class F_NodeInfo : public IF_NodeInfo, public XF_Base +class F_NodeInfo : public IF_NodeInfo { public: @@ -3720,24 +3438,24 @@ public: { } - FINLINE void XFLMAPI clearNodeInfo( void) + FINLINE void FLMAPI clearNodeInfo( void) { f_memset( &m_nodeInfo, 0, sizeof( m_nodeInfo)); m_ui64TotalNodes = 0; } - RCODE XFLMAPI addNodeInfo( + RCODE FLMAPI addNodeInfo( IF_Db * pDb, IF_DOMNode * pNode, FLMBOOL bDoSubTree, FLMBOOL bDoSelf = TRUE); - FINLINE FLMUINT64 XFLMAPI getTotalNodeCount( void) + FINLINE FLMUINT64 FLMAPI getTotalNodeCount( void) { return( m_ui64TotalNodes); } - FINLINE void XFLMAPI getNodeInfo( + FINLINE void FLMAPI getNodeInfo( XFLM_NODE_INFO * pNodeInfo) { f_memcpy( pNodeInfo, &m_nodeInfo, sizeof( m_nodeInfo)); @@ -3760,7 +3478,7 @@ typedef struct BTREE_INFO /***************************************************************************** Desc: Object for gathering B-Tree information. *****************************************************************************/ -class F_BTreeInfo : public IF_BTreeInfo, public XF_Base +class F_BTreeInfo : public IF_BTreeInfo { public: F_BTreeInfo() @@ -3771,7 +3489,7 @@ public: m_pCollectionArray = NULL; m_uiCollectionArraySize = 0; m_uiNumCollections = 0; - m_pool.poolInit( 512); + m_pPool = NULL; } virtual ~F_BTreeInfo() @@ -3784,36 +3502,45 @@ public: { f_free( &m_pCollectionArray); } - m_pool.poolFree(); + + if( m_pPool) + { + m_pPool->Release(); + } } - FINLINE void XFLMAPI clearBTreeInfo( void) + FINLINE RCODE setup( void) + { + return( FlmAllocPool( &m_pPool, 512)); + } + + FINLINE void FLMAPI clearBTreeInfo( void) { m_uiNumIndexes = 0; m_uiNumCollections = 0; } - RCODE XFLMAPI collectIndexInfo( + RCODE FLMAPI collectIndexInfo( IF_Db * pDb, FLMUINT uiIndexNum, IF_BTreeInfoStatus * pInfoStatus); - RCODE XFLMAPI collectCollectionInfo( + RCODE FLMAPI collectCollectionInfo( IF_Db * pDb, FLMUINT uiCollectionNum, IF_BTreeInfoStatus * pInfoStatus); - FINLINE FLMUINT XFLMAPI getNumIndexes( void) + FINLINE FLMUINT FLMAPI getNumIndexes( void) { return( m_uiNumIndexes); } - FINLINE FLMUINT XFLMAPI getNumCollections( void) + FINLINE FLMUINT FLMAPI getNumCollections( void) { return( m_uiNumCollections); } - FINLINE FLMBOOL XFLMAPI getIndexInfo( + FINLINE FLMBOOL FLMAPI getIndexInfo( FLMUINT uiNthIndex, FLMUINT * puiIndexNum, char ** ppszIndexName, @@ -3835,7 +3562,7 @@ public: } } - FINLINE FLMBOOL XFLMAPI getCollectionInfo( + FINLINE FLMBOOL FLMAPI getCollectionInfo( FLMUINT uiNthCollection, FLMUINT * puiCollectionNum, char ** ppszCollectionName, @@ -3857,7 +3584,7 @@ public: } } - FINLINE FLMBOOL XFLMAPI getIndexLevelInfo( + FINLINE FLMBOOL FLMAPI getIndexLevelInfo( FLMUINT uiNthIndex, FLMUINT uiBTreeLevel, XFLM_BTREE_LEVEL_INFO * pLevelInfo) @@ -3876,7 +3603,7 @@ public: } } - FINLINE FLMBOOL XFLMAPI getCollectionLevelInfo( + FINLINE FLMBOOL FLMAPI getCollectionLevelInfo( FLMUINT uiNthCollection, FLMUINT uiBTreeLevel, XFLM_BTREE_LEVEL_INFO * pLevelInfo) @@ -3931,7 +3658,7 @@ private: BTREE_INFO * m_pCollectionArray; FLMUINT m_uiCollectionArraySize; FLMUINT m_uiNumCollections; - F_Pool m_pool; + IF_Pool * m_pPool; // Items for the callback function. @@ -3963,7 +3690,7 @@ RCODE ixKeyCompare( /******************************************************************** Desc: Class for comparing two keys in an index. ********************************************************************/ -class IXKeyCompare : public IF_ResultSetCompare, public XF_Base +class IXKeyCompare : public IF_ResultSetCompare { public: @@ -3989,7 +3716,7 @@ public: } } - FINLINE RCODE XFLMAPI compare( + FINLINE RCODE FLMAPI compare( const void * pvKey1, FLMUINT uiKeyLen1, const void * pvKey2, @@ -4038,17 +3765,17 @@ public: m_bCompareDocId = bCompareDocId; } - FINLINE FLMUINT getRefCount( void) + virtual FLMINT FLMAPI getRefCount( void) { return( IF_ResultSetCompare::getRefCount()); } - virtual FINLINE FLMINT XFLMAPI AddRef( void) + virtual FLMINT FLMAPI AddRef( void) { return( IF_ResultSetCompare::AddRef()); } - virtual FINLINE FLMINT XFLMAPI Release( void) + virtual FLMINT FLMAPI Release( void) { return( IF_ResultSetCompare::Release()); } @@ -4066,7 +3793,7 @@ private: /*============================================================================= Desc: Result set class for queries that do sorting. =============================================================================*/ -class F_QueryResultSet : public XF_RefCount, public XF_Base +class F_QueryResultSet : public F_Object { public: @@ -4208,18 +3935,19 @@ typedef struct RS_WAITER /**************************************************************************** Desc: Class for setting up query criteria ****************************************************************************/ -class F_Query : public IF_Query, public XF_Base +class F_Query : public IF_Query { public: - // Constructor and Destructor - F_Query(); + virtual ~F_Query(); + + RCODE setup( void); // Methods for constructing a query - FINLINE RCODE XFLMAPI setLanguage( + FINLINE RCODE FLMAPI setLanguage( FLMUINT uiLanguage) { @@ -4233,7 +3961,7 @@ public: return( NE_XFLM_OK); } - FINLINE RCODE XFLMAPI setCollection( + FINLINE RCODE FLMAPI setCollection( FLMUINT uiCollection ) { @@ -4248,68 +3976,68 @@ public: return( NE_XFLM_OK); } - FINLINE RCODE XFLMAPI setupQueryExpr( + FINLINE RCODE FLMAPI setupQueryExpr( IF_Db * pDb, const FLMUNICODE * puzQuery) { return( setupQueryExpr( TRUE, pDb, (void *)puzQuery)); } - FINLINE RCODE XFLMAPI setupQueryExpr( + FINLINE RCODE FLMAPI setupQueryExpr( IF_Db * pDb, const char * pszQuery) { return( setupQueryExpr( FALSE, pDb, (void *)pszQuery)); } - RCODE XFLMAPI copyCriteria( + RCODE FLMAPI copyCriteria( IF_Query * pSrcQuery); - RCODE XFLMAPI addXPathComponent( + RCODE FLMAPI addXPathComponent( eXPathAxisTypes eXPathAxis, eDomNodeType eNodeType, FLMUINT uiNameId, IF_QueryNodeSource * pNodeSource); - RCODE XFLMAPI addOperator( + RCODE FLMAPI addOperator( eQueryOperators eOperator, FLMUINT uiCompareRules = 0, IF_OperandComparer * pOpComparer = NULL); - RCODE XFLMAPI addUnicodeValue( + RCODE FLMAPI addUnicodeValue( const FLMUNICODE * puzVal); - RCODE XFLMAPI addUTF8Value( + RCODE FLMAPI addUTF8Value( const char * pszVal, FLMUINT uiUTF8Len = 0); - RCODE XFLMAPI addBinaryValue( + RCODE FLMAPI addBinaryValue( const void * pvVal, FLMUINT uiValLen); - RCODE XFLMAPI addUINTValue( + RCODE FLMAPI addUINTValue( FLMUINT uiVal); - RCODE XFLMAPI addINTValue( + RCODE FLMAPI addINTValue( FLMINT iVal); - RCODE XFLMAPI addUINT64Value( + RCODE FLMAPI addUINT64Value( FLMUINT64 ui64Val); - RCODE XFLMAPI addINT64Value( + RCODE FLMAPI addINT64Value( FLMINT64 i64Val); - RCODE XFLMAPI addBoolean( + RCODE FLMAPI addBoolean( FLMBOOL bVal, FLMBOOL bUnknown = FALSE); - FINLINE RCODE XFLMAPI addFunction( + FINLINE RCODE FLMAPI addFunction( eQueryFunctions eFunction) { return( addFunction( eFunction, NULL, FALSE)); } - FINLINE RCODE XFLMAPI addFunction( + FINLINE RCODE FLMAPI addFunction( IF_QueryValFunc * pFuncObj, FLMBOOL bHasXPathExpr) { @@ -4320,55 +4048,55 @@ public: return( addFunction( XFLM_FUNC_xxx, pFuncObj, bHasXPathExpr)); } - RCODE XFLMAPI getFirst( + RCODE FLMAPI getFirst( IF_Db * pDb, IF_DOMNode ** ppNode, FLMUINT uiTimeLimit = 0); - RCODE XFLMAPI getLast( + RCODE FLMAPI getLast( IF_Db * pDb, IF_DOMNode ** ppNode, FLMUINT uiTimeLimit = 0); - RCODE XFLMAPI getNext( + RCODE FLMAPI getNext( IF_Db * pDb, IF_DOMNode ** ppNode, FLMUINT uiTimeLimit = 0, FLMUINT uiNumToSkip = 0, FLMUINT * puiNumSkipped = NULL); - RCODE XFLMAPI getPrev( + RCODE FLMAPI getPrev( IF_Db * pDb, IF_DOMNode ** ppNode, FLMUINT uiTimeLimit = 0, FLMUINT uiNumToSkip = 0, FLMUINT * puiNumSkipped = NULL); - RCODE XFLMAPI getCurrent( + RCODE FLMAPI getCurrent( IF_Db * pDb, IF_DOMNode ** ppNode); - void XFLMAPI resetQuery( void); + void FLMAPI resetQuery( void); - RCODE XFLMAPI getStatsAndOptInfo( + RCODE FLMAPI getStatsAndOptInfo( FLMUINT * puiNumOptInfos, XFLM_OPT_INFO ** ppOptInfo); - void XFLMAPI freeStatsAndOptInfo( + void FLMAPI freeStatsAndOptInfo( XFLM_OPT_INFO ** ppOptInfo); - void XFLMAPI setDupHandling( + void FLMAPI setDupHandling( FLMBOOL bRemoveDups); - RCODE XFLMAPI setIndex( + RCODE FLMAPI setIndex( FLMUINT uiIndex); - RCODE XFLMAPI getIndex( + RCODE FLMAPI getIndex( IF_Db * pDb, FLMUINT * puiIndex, FLMBOOL * pbHaveMultiple); - RCODE XFLMAPI addSortKey( + RCODE FLMAPI addSortKey( void * pvSortKeyContext, FLMBOOL bChildToContext, FLMBOOL bElement, @@ -4380,7 +4108,7 @@ public: FLMBOOL bSortMissingHigh, void ** ppvContext); - FINLINE RCODE XFLMAPI enablePositioning( void) + FINLINE RCODE FLMAPI enablePositioning( void) { if (m_bOptimized) { @@ -4393,30 +4121,30 @@ public: return( NE_XFLM_OK); } - RCODE XFLMAPI positionTo( + RCODE FLMAPI positionTo( IF_Db * pDb, IF_DOMNode ** ppNode, FLMUINT uiTimeLimit, FLMUINT uiPosition); - RCODE XFLMAPI positionTo( + RCODE FLMAPI positionTo( IF_Db * pDb, IF_DOMNode ** ppNode, FLMUINT uiTimeLimit, IF_DataVector * pSearchKey, FLMUINT uiFlags); - RCODE XFLMAPI getPosition( + RCODE FLMAPI getPosition( IF_Db * pDb, FLMUINT * puiPosition); - RCODE XFLMAPI buildResultSet( + RCODE FLMAPI buildResultSet( IF_Db * pDb, FLMUINT uiTimeLimit); - void XFLMAPI stopBuildingResultSet( void); + void FLMAPI stopBuildingResultSet( void); - RCODE XFLMAPI getCounts( + RCODE FLMAPI getCounts( IF_Db * pDb, FLMUINT uiTimeLimit, FLMBOOL bPartialCountOk, @@ -4425,12 +4153,12 @@ public: FLMUINT * puiPositionableToCount, FLMBOOL * pbDoneBuildingResultSet = NULL); - FINLINE void XFLMAPI enableResultSetEncryption( void) + FINLINE void FLMAPI enableResultSetEncryption( void) { m_bEncryptResultSet = TRUE; } - FINLINE void XFLMAPI setQueryStatusObject( + FINLINE void FLMAPI setQueryStatusObject( IF_QueryStatus * pQueryStatus) { if (m_pQueryStatus) @@ -4443,7 +4171,7 @@ public: } } - FINLINE void XFLMAPI setQueryValidatorObject( + FINLINE void FLMAPI setQueryValidatorObject( IF_QueryValidator * pQueryValidator) { if (m_pQueryValidator) @@ -4458,7 +4186,7 @@ public: private: - RCODE XFLMAPI addFunction( + RCODE FLMAPI addFunction( eQueryFunctions eFunction, IF_QueryValFunc * pFuncObj, FLMBOOL bHasXPathExpr); @@ -4745,14 +4473,14 @@ private: IF_DOMNode * pContextNode, FLMBOOL bForward, FQNODE * pCurrNode, - F_DynaBuf * pDynaBuf); + IF_DynaBuf * pDynaBuf); RCODE getFuncValue( IF_DOMNode * pContextNode, FLMBOOL bForward, FQNODE ** ppCurrNode, FLMBOOL * pbGetNodeValue, - F_DynaBuf * pDynaBuf); + IF_DynaBuf * pDynaBuf); RCODE getXPathValue( IF_DOMNode * pContextNode, @@ -4814,7 +4542,7 @@ private: FLMBOOL bSkipCurrKey); RCODE objectAddRef( - XF_RefCount * pObject); + F_Object * pObject); RCODE setupQueryExpr( FLMBOOL bUnicode, @@ -4954,7 +4682,7 @@ private: FLMUINT64 m_ui64RSDocsRead; FLMUINT64 m_ui64RSDocsPassed; EXPR_STATE * m_pCurExprState; - F_Pool m_Pool; + IF_Pool * m_pPool; FLMBOOL m_bOptimized; FLMUINT m_uiLanguage; FLMUINT m_uiCollection; @@ -4971,7 +4699,7 @@ private: F_Db * m_pDb; F_Query * m_pNext; // Next query off of database F_Query * m_pPrev; // Prev query off of database - XF_RefCount ** m_ppObjectList; + F_Object ** m_ppObjectList; FLMUINT m_uiObjectListSize; FLMUINT m_uiObjectCount; FLMBOOL m_bRemoveDups; @@ -4990,7 +4718,7 @@ friend class F_IStream; /***************************************************************************** Desc: FLAIM database system object ******************************************************************************/ -class F_DbSystem : public IF_DbSystem, public F_OSBase +class F_DbSystem : public IF_DbSystem { public: @@ -5005,30 +4733,22 @@ public: UnlockModule(); } - FLMINT XFLMAPI AddRef( void); + virtual FLMINT FLMAPI AddRef( void); - FLMINT XFLMAPI Release( void); + virtual FLMINT FLMAPI Release( void); - RCODE XFLMAPI QueryInterface( - RXFLMIID riid, - void ** ppv); + RCODE FLMAPI init( void); - RCODE XFLMAPI init( void); - - RCODE XFLMAPI updateIniFile( + RCODE FLMAPI updateIniFile( const char * pszParamName, const char * pszValue); - void XFLMAPI exit(); + void FLMAPI exit(); - FINLINE void XFLMAPI getFileSystem( - IF_FileSystem ** ppFileSystem) - { - *ppFileSystem = (IF_FileSystem *)gv_pFileSystem; - (*ppFileSystem)->AddRef(); - } - - RCODE XFLMAPI dbCreate( + void FLMAPI getFileSystem( + IF_FileSystem ** ppFileSystem); + + RCODE FLMAPI dbCreate( const char * pszDbFileName, const char * pszDataDir, const char * pszRflDir, @@ -5038,7 +4758,7 @@ public: FLMBOOL bTempDb, IF_Db ** ppDb); - FINLINE RCODE XFLMAPI dbCreate( + FINLINE RCODE FLMAPI dbCreate( const char * pszDbFileName, const char * pszDataDir, const char * pszRflDir, @@ -5051,7 +4771,7 @@ public: pszDictBuf, pCreateOpts, FALSE, ppDb)); } - FINLINE RCODE XFLMAPI dbOpen( + FINLINE RCODE FLMAPI dbOpen( const char * pszDbFileName, const char * pszDataDir, const char * pszRflDir, @@ -5065,7 +4785,7 @@ public: pszPassword, uiOpenFlags, ppDb)); } - RCODE XFLMAPI dbRebuild( + RCODE FLMAPI dbRebuild( const char * pszSourceDbPath, const char * pszSourceDataDir, const char * pszDestDbPath, @@ -5079,7 +4799,7 @@ public: FLMUINT64 * pui64QuarantinedNodes, IF_DbRebuildStatus * pRebuildStatus); - RCODE XFLMAPI dbCheck( + RCODE FLMAPI dbCheck( const char * pszDbFileName, const char * pszDataDir, const char * pszRflDir, @@ -5088,7 +4808,7 @@ public: IF_DbInfo ** ppDbInfo, IF_DbCheckStatus * pDbCheck); - FINLINE RCODE XFLMAPI dbDup( + FINLINE RCODE FLMAPI dbDup( IF_Db * ifpDb, IF_Db ** ppDb) { @@ -5098,7 +4818,7 @@ public: FALSE, NULL, NULL, NULL, ppDb)); } - FINLINE RCODE XFLMAPI setDynamicMemoryLimit( + FINLINE RCODE FLMAPI setDynamicMemoryLimit( FLMUINT uiCacheAdjustPercent, FLMUINT uiCacheAdjustMin, FLMUINT uiCacheAdjustMax, @@ -5109,7 +4829,7 @@ public: uiCacheAdjustMax, uiCacheAdjustMinToLeave)); } - FINLINE RCODE XFLMAPI setHardMemoryLimit( + FINLINE RCODE FLMAPI setHardMemoryLimit( FLMUINT uiPercent, FLMBOOL bPercentOfAvail, FLMUINT uiMin, @@ -5123,7 +4843,7 @@ public: // Determine if dyamic cache adjusting is supported. - FINLINE FLMBOOL XFLMAPI getDynamicCacheSupported( void) + FINLINE FLMBOOL FLMAPI getDynamicCacheSupported( void) { #ifdef FLM_CAN_GET_PHYS_MEM return( TRUE); @@ -5132,7 +4852,7 @@ public: #endif } - FINLINE void XFLMAPI getCacheInfo( + FINLINE void FLMAPI getCacheInfo( XFLM_CACHE_INFO * pCacheInfo) { gv_XFlmSysData.pGlobalCacheMgr->getCacheInfo( pCacheInfo); @@ -5140,14 +4860,14 @@ public: // Enable/disable cache debugging mode - void XFLMAPI enableCacheDebug( + void FLMAPI enableCacheDebug( FLMBOOL bDebug); - FLMBOOL XFLMAPI cacheDebugEnabled( void); + FLMBOOL FLMAPI cacheDebugEnabled( void); // Clear cache - FINLINE RCODE XFLMAPI clearCache( + FINLINE RCODE FLMAPI clearCache( IF_Db * pDb) { return( gv_XFlmSysData.pGlobalCacheMgr->clearCache( pDb)); @@ -5156,131 +4876,120 @@ public: // Close all files that have not been used for the specified number of // seconds. - RCODE XFLMAPI closeUnusedFiles( + RCODE FLMAPI closeUnusedFiles( FLMUINT uiSeconds); - // Maximum number of file handles available. - - void XFLMAPI setOpenThreshold( - FLMUINT uiThreshold); - - FLMUINT XFLMAPI getOpenThreshold( void); - - // Get the number of open files - - FLMUINT XFLMAPI getOpenFileCount( void); - // Start gathering statistics. - void XFLMAPI startStats( void); + void FLMAPI startStats( void); // Stop gathering statistics. - void XFLMAPI stopStats( void); + void FLMAPI stopStats( void); // Reset statistics. - void XFLMAPI resetStats( void); + void FLMAPI resetStats( void); - RCODE XFLMAPI getStats( + RCODE FLMAPI getStats( XFLM_STATS * pFlmStats); - void XFLMAPI freeStats( + void FLMAPI freeStats( XFLM_STATS * pFlmStats); // Set the maximum number of queries to save. - void XFLMAPI setQuerySaveMax( + void FLMAPI setQuerySaveMax( FLMUINT uiMaxToSave); - FLMUINT XFLMAPI getQuerySaveMax( void); + FLMUINT FLMAPI getQuerySaveMax( void); // Set temporary directory. - RCODE XFLMAPI setTempDir( + RCODE FLMAPI setTempDir( const char * pszPath); - RCODE XFLMAPI getTempDir( + RCODE FLMAPI getTempDir( char * pszPath); // Maximum seconds between checkpoints. - void XFLMAPI setCheckpointInterval( + void FLMAPI setCheckpointInterval( FLMUINT uiSeconds); - FLMUINT XFLMAPI getCheckpointInterval( void); + FLMUINT FLMAPI getCheckpointInterval( void); // Set interval for dynamically adjusting cache limit. - void XFLMAPI setCacheAdjustInterval( + void FLMAPI setCacheAdjustInterval( FLMUINT uiSeconds); - FLMUINT XFLMAPI getCacheAdjustInterval( void); + FLMUINT FLMAPI getCacheAdjustInterval( void); // Set interval for dynamically cleaning out old cache blocks and records. - void XFLMAPI setCacheCleanupInterval( + void FLMAPI setCacheCleanupInterval( FLMUINT uiSeconds); - FLMUINT XFLMAPI getCacheCleanupInterval( void); + FLMUINT FLMAPI getCacheCleanupInterval( void); // Set interval for cleaning up unused structures. - void XFLMAPI setUnusedCleanupInterval( + void FLMAPI setUnusedCleanupInterval( FLMUINT uiSeconds); - FLMUINT XFLMAPI getUnusedCleanupInterval( void); + FLMUINT FLMAPI getUnusedCleanupInterval( void); // Set maximum time for an item to be unused. - void XFLMAPI setMaxUnusedTime( + void FLMAPI setMaxUnusedTime( FLMUINT uiSeconds); - FLMUINT XFLMAPI getMaxUnusedTime( void); + FLMUINT FLMAPI getMaxUnusedTime( void); // Specify the logger object - void XFLMAPI setLogger( + void FLMAPI setLogger( IF_LoggerClient * pLogger); // Enable or disable use of ESM - void XFLMAPI enableExtendedServerMemory( + void FLMAPI enableExtendedServerMemory( FLMBOOL bEnable); - FLMBOOL XFLMAPI extendedServerMemoryEnabled( void); + FLMBOOL FLMAPI extendedServerMemoryEnabled( void); - void XFLMAPI deactivateOpenDb( + void FLMAPI deactivateOpenDb( const char * pszDbFileName, const char * pszDataDir); // Maximum dirty cache. - void XFLMAPI setDirtyCacheLimits( + void FLMAPI setDirtyCacheLimits( FLMUINT uiMaxDirty, FLMUINT uiLowDirty); - void XFLMAPI getDirtyCacheLimits( + void FLMAPI getDirtyCacheLimits( FLMUINT * puiMaxDirty, FLMUINT * puiLowDirty); - RCODE XFLMAPI getThreadInfo( + RCODE FLMAPI getThreadInfo( IF_ThreadInfo ** ppThreadInfo); - RCODE XFLMAPI registerForEvent( + RCODE FLMAPI registerForEvent( eEventCategory eCategory, IF_EventClient * pEventClient); - void XFLMAPI deregisterForEvent( + void FLMAPI deregisterForEvent( eEventCategory eCategory, IF_EventClient * pEventClient); - RCODE XFLMAPI getNextMetaphone( + RCODE FLMAPI getNextMetaphone( IF_IStream * pIStream, FLMUINT * puiMetaphone, FLMUINT * puiAltMetaphone = NULL); - RCODE XFLMAPI dbCopy( + RCODE FLMAPI dbCopy( const char * pszSrcDbName, const char * pszSrcDataDir, const char * pszSrcRflDir, @@ -5289,13 +4998,13 @@ public: const char * pszDestRflDir, IF_DbCopyStatus * ifpStatus); - RCODE XFLMAPI dbRemove( + RCODE FLMAPI dbRemove( const char * pszDbName, const char * pszDataDir, const char * pszRflDir, FLMBOOL bRemoveRflFiles); - RCODE XFLMAPI dbRename( + RCODE FLMAPI dbRename( const char * pszDbName, const char * pszDataDir, const char * pszRflDir, @@ -5303,7 +5012,7 @@ public: FLMBOOL bOverwriteDestOk, IF_DbRenameStatus * ifpStatus); - RCODE XFLMAPI dbRestore( + RCODE FLMAPI dbRestore( const char * pszDbPath, const char * pszDataDir, const char * pszRflDir, @@ -5312,14 +5021,14 @@ public: IF_RestoreClient * pRestoreObj, IF_RestoreStatus * pRestoreStatus); - RCODE XFLMAPI strCmp( + RCODE FLMAPI strCmp( FLMUINT uiCompFlags, FLMUINT uiLanguage, FLMUNICODE * uzStr1, FLMUNICODE * uzStr2, FLMINT * piCmp); - FLMBOOL XFLMAPI errorIsFileCorrupt( + FLMBOOL FLMAPI errorIsFileCorrupt( RCODE rc); static FLMBOOL _errorIsFileCorrupt( @@ -5330,10 +5039,10 @@ public: return( dbSystem.errorIsFileCorrupt( rc)); } - const char * XFLMAPI errorString( + const char * FLMAPI errorString( RCODE rc); - const char * XFLMAPI checkErrorToStr( + const char * FLMAPI checkErrorToStr( FLMINT iCheckErrorCode); static const char * _errorString( @@ -5344,88 +5053,83 @@ public: return( dbSystem.errorString( rc)); } - RCODE XFLMAPI openBufferIStream( + RCODE FLMAPI openBufferIStream( const char * pucBuffer, FLMUINT uiLength, IF_PosIStream ** ppIStream); - RCODE XFLMAPI openFileIStream( + RCODE FLMAPI openFileIStream( const char * pszPath, IF_PosIStream ** ppIStream); - RCODE XFLMAPI openMultiFileIStream( + RCODE FLMAPI openMultiFileIStream( const char * pszDirectory, const char * pszBaseName, IF_IStream ** ppIStream); - RCODE XFLMAPI openBufferedIStream( + RCODE FLMAPI openBufferedIStream( IF_IStream * pIStream, FLMUINT uiBufferSize, IF_IStream ** ppIStream); - RCODE XFLMAPI openUncompressingIStream( + RCODE FLMAPI openUncompressingIStream( IF_IStream * pIStream, IF_IStream ** ppIStream); - RCODE XFLMAPI openFileOStream( + RCODE FLMAPI openFileOStream( const char * pszFileName, FLMBOOL bTruncateIfExists, IF_OStream ** ppOStream); - RCODE XFLMAPI openMultiFileOStream( + RCODE FLMAPI openMultiFileOStream( const char * pszDirectory, const char * pszBaseName, FLMUINT uiMaxFileSize, FLMBOOL bOverwrite, IF_OStream ** ppStream); - RCODE XFLMAPI removeMultiFileStream( + RCODE FLMAPI removeMultiFileStream( const char * pszDirectory, const char * pszBaseName); - RCODE XFLMAPI openBufferedOStream( + RCODE FLMAPI openBufferedOStream( IF_OStream * pOStream, FLMUINT uiBufferSize, IF_OStream ** ppOStream); - RCODE XFLMAPI openCompressingOStream( + RCODE FLMAPI openCompressingOStream( IF_OStream * pOStream, IF_OStream ** ppOStream); - RCODE XFLMAPI writeToOStream( + RCODE FLMAPI writeToOStream( IF_IStream * pIStream, IF_OStream * pOStream); - RCODE XFLMAPI openBase64Encoder( + RCODE FLMAPI openBase64Encoder( IF_IStream * pInputStream, FLMBOOL bInsertLineBreaks, IF_IStream ** ppEncodedStream); - RCODE XFLMAPI openBase64Decoder( + RCODE FLMAPI openBase64Decoder( IF_IStream * pInputStream, IF_IStream ** ppDecodedStream); - FINLINE RCODE XFLMAPI createMemoryPool( + FINLINE RCODE FLMAPI createMemoryPool( IF_Pool ** ppPool) { - if( (*ppPool = f_new F_Pool) == NULL) - { - return( RC_SET( NE_XFLM_MEM)); - } + return( FlmAllocPool( ppPool)); + } - return( NE_XFLM_OK); - } - - RCODE XFLMAPI createIFDataVector( + RCODE FLMAPI createIFDataVector( IF_DataVector ** ifppDV); - RCODE XFLMAPI createIFResultSet( + RCODE FLMAPI createIFResultSet( IF_ResultSet ** ppResultSet); - RCODE XFLMAPI createIFQuery( + RCODE FLMAPI createIFQuery( IF_Query ** ppQuery); - FINLINE void XFLMAPI freeMem( + FINLINE void FLMAPI freeMem( void ** ppMem) { f_free( ppMem); @@ -5454,11 +5158,6 @@ public: FLMUINT uiOpenFlags, IF_Db ** ppDb); - void enableOutOfMemorySimulation( - FLMBOOL bEnable); - - FLMBOOL outOfMemorySimulationEnabled( void); - static FINLINE FLMBOOL validBlockSize( FLMUINT uiBlockSize) { @@ -5470,19 +5169,12 @@ public: return( FALSE); } - static FLMUINT languageToNum( - const char * pszLanguage); - - static void languageToStr( - FLMINT iLangNum, - char * pszLanguage); - static void getDbBasePath( char * pszBaseDbName, const char * pszDbName, FLMUINT * puiBaseDbNameLen); - RCODE XFLMAPI compareUTF8Strings( + RCODE FLMAPI compareUTF8Strings( const FLMBYTE * pucLString, FLMUINT uiLStrBytes, FLMBOOL bLeftWild, @@ -5493,7 +5185,7 @@ public: FLMUINT uiLanguage, FLMINT * piResult); - RCODE XFLMAPI compareUnicodeStrings( + RCODE FLMAPI compareUnicodeStrings( const FLMUNICODE * puzLString, FLMUINT uiLStrBytes, FLMBOOL bLeftWild, @@ -5504,44 +5196,44 @@ public: FLMUINT uiLanguage, FLMINT * piResult); - RCODE XFLMAPI utf8IsSubStr( + RCODE FLMAPI utf8IsSubStr( const FLMBYTE * pszString, const FLMBYTE * pszSubString, FLMUINT uiCompareRules, FLMUINT uiLanguage, FLMBOOL * pbExists); - FLMBOOL XFLMAPI uniIsUpper( + FLMBOOL FLMAPI uniIsUpper( FLMUNICODE uzChar); - FLMBOOL XFLMAPI uniIsLower( + FLMBOOL FLMAPI uniIsLower( FLMUNICODE uzChar); - FLMBOOL XFLMAPI uniIsAlpha( + FLMBOOL FLMAPI uniIsAlpha( FLMUNICODE uzChar); - FLMBOOL XFLMAPI uniIsDecimalDigit( + FLMBOOL FLMAPI uniIsDecimalDigit( FLMUNICODE uzChar); - FLMUNICODE XFLMAPI uniToLower( + FLMUNICODE FLMAPI uniToLower( FLMUNICODE uzChar); - RCODE XFLMAPI nextUCS2Char( + RCODE FLMAPI nextUCS2Char( const FLMBYTE ** ppszUTF8, const FLMBYTE * pszEndOfUTF8String, FLMUNICODE * puzChar); - RCODE XFLMAPI numUCS2Chars( + RCODE FLMAPI numUCS2Chars( const FLMBYTE * pszUTF8, FLMUINT * puiNumChars); - RCODE XFLMAPI waitToClose( + RCODE FLMAPI waitToClose( const char * pszDbPath); - RCODE XFLMAPI createIFNodeInfo( + RCODE FLMAPI createIFNodeInfo( IF_NodeInfo ** ifppNodeInfo); - RCODE XFLMAPI createIFBTreeInfo( + RCODE FLMAPI createIFBTreeInfo( IF_BTreeInfo ** ifppBTreeInfo); private: @@ -5551,17 +5243,16 @@ private: RCODE readIniFile( void); RCODE setCacheParams( - F_IniFile * pIniFile); + IF_IniFile * pIniFile); void cleanup( void); FINLINE RCODE internalDbDup( - F_Db * pDb, - F_Db ** ppDb - ) + F_Db * pDb, + F_Db ** ppDb) { - RCODE rc = NE_XFLM_OK; - IF_Db * ifpDb; + RCODE rc = NE_XFLM_OK; + IF_Db * ifpDb; if (RC_OK( rc = openDatabase( pDb->m_pDatabase, NULL, NULL, NULL, NULL, 0, TRUE, NULL, NULL, NULL, &ifpDb))) @@ -5576,12 +5267,8 @@ private: void unlockSysData( void); - RCODE initCharMappingTables( void); - void initFastBlockCheckSum( void); - void freeCharMappingTables( void); - RCODE checkErrorCodeTables( void); RCODE allocDb( @@ -5626,10 +5313,10 @@ private: IF_DbCopyStatus * ifpStatus); static RCODE monitorThrd( - F_Thread * pThread); + IF_Thread * pThread); static RCODE cacheCleanupThrd( - F_Thread * pThread); + IF_Thread * pThread); static void checkNotUsedObjects( void); @@ -5657,25 +5344,6 @@ typedef enum #define FLM_DATA_LEFT_TRUNCATED 0x10 // Data is left truncated #define FLM_DATA_RIGHT_TRUNCATED 0x20 // Data is right truncated -RCODE flmReadSEN( - IF_IStream * pIStream, - FLMUINT * puiValue, - FLMUINT * puiLength = NULL); - -RCODE flmReadSEN64( - IF_IStream * pIStream, - FLMUINT64 * pui64Value, - FLMUINT * puiLength = NULL); - -RCODE flmReadUTF8CharAsUnicode( - IF_IStream * pStream, - FLMUNICODE * puChar); - -RCODE flmReadUTF8CharAsUTF8( - IF_IStream * pIStream, - FLMBYTE * pucBuf, - FLMUINT * puiLen); - RCODE flmReadStorageAsText( IF_IStream * pIStream, FLMBYTE * pucStorageData, @@ -5707,193 +5375,12 @@ RCODE flmReadLine( FLMBYTE * pucBuffer, FLMUINT * puiSize); -typedef struct F_CollStreamPos -{ - FLMUINT64 ui64Position; - FLMUNICODE uNextChar; -} F_CollStreamPos; - -/***************************************************************************** -Desc: -******************************************************************************/ -class F_CollIStream : public F_PosIStream -{ -public: - - F_CollIStream() - { - m_pIStream = NULL; - m_uiLanguage = 0; - m_bMayHaveWildCards = FALSE; - m_bUnicodeStream = FALSE; - m_uNextChar = 0; - } - - virtual ~F_CollIStream() - { - if( m_pIStream) - { - m_pIStream->Release(); - } - } - - RCODE open( - IF_PosIStream * pIStream, - FLMBOOL bUnicodeStream, - FLMUINT uiLanguage, - FLMUINT uiCompareRules, - FLMBOOL bMayHaveWildCards) - { - if( m_pIStream) - { - m_pIStream->Release(); - } - - m_pIStream = pIStream; - m_pIStream->AddRef(); - m_uiLanguage = uiLanguage; - m_uiCompareRules = uiCompareRules; - m_bCaseSensitive = (uiCompareRules & XFLM_COMP_CASE_INSENSITIVE) - ? FALSE - : TRUE; - m_bMayHaveWildCards = bMayHaveWildCards; - m_bUnicodeStream = bUnicodeStream; - m_ui64EndOfLeadingSpacesPos = 0; - return( NE_XFLM_OK); - } - - RCODE XFLMAPI close( void) - { - if( m_pIStream) - { - m_pIStream->Release(); - m_pIStream = NULL; - } - - return( NE_XFLM_OK); - } - - RCODE XFLMAPI read( - void * pvBuffer, - FLMUINT uiBytesToRead, - FLMUINT * puiBytesRead) - { - RCODE rc = NE_XFLM_OK; - - if( RC_BAD( rc = m_pIStream->read( pvBuffer, - uiBytesToRead, puiBytesRead))) - { - goto Exit; - } - - Exit: - - return( rc); - } - - RCODE read( - FLMBOOL bAllowTwoIntoOne, - FLMUNICODE * puChar, - FLMBOOL * pbCharIsWild, - FLMUINT16 * pui16Col, - FLMUINT16 * pui16SubCol, - FLMBYTE * pucCase); - - FINLINE FLMUINT64 XFLMAPI totalSize( void) - { - if( m_pIStream) - { - return( m_pIStream->totalSize()); - } - - return( 0); - } - - FINLINE FLMUINT64 XFLMAPI remainingSize( void) - { - if( m_pIStream) - { - return( m_pIStream->remainingSize()); - } - - return( 0); - } - - FINLINE RCODE XFLMAPI positionTo( - FLMUINT64) - { - return( RC_SET_AND_ASSERT( NE_XFLM_NOT_IMPLEMENTED)); - } - - FINLINE RCODE XFLMAPI positionTo( - F_CollStreamPos * pPos) - { - - // Should never be able to position back to before the - // leading spaces. - - m_uNextChar = pPos->uNextChar; - flmAssert( pPos->ui64Position >= m_ui64EndOfLeadingSpacesPos); - return( m_pIStream->positionTo( pPos->ui64Position)); - } - - FINLINE FLMUINT64 XFLMAPI getCurrPosition( void) - { - flmAssert( 0); - return( 0); - } - - FINLINE void XFLMAPI getCurrPosition( - F_CollStreamPos * pPos) - { - pPos->uNextChar = m_uNextChar; - pPos->ui64Position = m_pIStream->getCurrPosition(); - } - -private: - - FINLINE RCODE readCharFromStream( - FLMUNICODE * puChar) - { - RCODE rc = NE_XFLM_OK; - - if( m_bUnicodeStream) - { - if( RC_BAD( rc = m_pIStream->read( puChar, sizeof( FLMUNICODE), NULL))) - { - goto Exit; - } - } - else - { - if( RC_BAD( rc = flmReadUTF8CharAsUnicode( - m_pIStream, puChar))) - { - goto Exit; - } - } - - Exit: - - return( rc); - } - - IF_PosIStream * m_pIStream; - FLMUINT m_uiLanguage; - FLMBOOL m_bCaseSensitive; - FLMUINT m_uiCompareRules; - FLMUINT64 m_ui64EndOfLeadingSpacesPos; - FLMBOOL m_bMayHaveWildCards; - FLMBOOL m_bUnicodeStream; - FLMUNICODE m_uNextChar; -}; - #define FLM_ENCRYPT_CHUNK_SIZE 512 /***************************************************************************** Desc: ******************************************************************************/ -class F_BTreeIStream : public F_PosIStream +class F_BTreeIStream : public IF_PosIStream { public: @@ -5961,36 +5448,36 @@ public: FLMUINT32 ui32BlkAddr = 0, FLMUINT uiOffsetIndex = 0); - FINLINE FLMUINT64 XFLMAPI totalSize( void) + FINLINE FLMUINT64 FLMAPI totalSize( void) { return( m_uiStreamSize); } - FINLINE FLMUINT64 XFLMAPI remainingSize( void) + FINLINE FLMUINT64 FLMAPI remainingSize( void) { return( m_uiStreamSize - (m_uiBufferStartOffset + m_uiBufferOffset)); } - FINLINE RCODE XFLMAPI close( void) + FINLINE RCODE FLMAPI close( void) { reset(); return( NE_XFLM_OK); } - RCODE XFLMAPI positionTo( + RCODE FLMAPI positionTo( FLMUINT64 ui64Position); - FINLINE FLMUINT64 XFLMAPI getCurrPosition( void) + FINLINE FLMUINT64 FLMAPI getCurrPosition( void) { return( m_uiBufferStartOffset + m_uiBufferOffset); } - RCODE XFLMAPI read( + RCODE FLMAPI read( void * pvBuffer, FLMUINT uiBytesToRead, FLMUINT * puiBytesRead); - FLMINT XFLMAPI Release( void); + FLMINT FLMAPI Release( void); FINLINE FLMUINT32 getBlkAddr( void) { @@ -6035,13 +5522,14 @@ friend class F_Db; /***************************************************************************** Desc: ******************************************************************************/ -class F_NodeBufferIStream : public F_BufferIStream +class F_NodeBufferIStream : public IF_PosIStream { public: F_NodeBufferIStream() { m_pCachedNode = NULL; + m_pBufferIStream = NULL; reset(); } @@ -6050,9 +5538,62 @@ public: reset(); } + RCODE FLMAPI open( + const char * pucBuffer, + FLMUINT uiLength, + char ** ppucAllocatedBuffer = NULL); + + FINLINE FLMUINT64 FLMAPI totalSize( void) + { + return( m_pBufferIStream->totalSize()); + } + + FINLINE FLMUINT64 FLMAPI remainingSize( void) + { + return( m_pBufferIStream->remainingSize()); + } + + FINLINE RCODE FLMAPI close( void) + { + RCODE rc = NE_FLM_OK; + + if( m_pBufferIStream) + { + m_pBufferIStream->Release(); + m_pBufferIStream = NULL; + } + + return( rc); + } + + FINLINE RCODE FLMAPI positionTo( + FLMUINT64 ui64Position) + { + return( m_pBufferIStream->positionTo( ui64Position)); + } + + FINLINE FLMUINT64 FLMAPI getCurrPosition( void) + { + return( m_pBufferIStream->getCurrPosition()); + } + + FINLINE RCODE FLMAPI read( + void * pvBuffer, + FLMUINT uiBytesToRead, + FLMUINT * puiBytesRead) + { + return( m_pBufferIStream->read( pvBuffer, uiBytesToRead, puiBytesRead)); + } + + FINLINE void FLMAPI truncate( + FLMUINT uiOffset) + { + m_pBufferIStream->truncate( uiOffset); + } + FINLINE void reset( void) { - if (m_pCachedNode) + if( m_pCachedNode) { f_mutexLock( gv_XFlmSysData.hNodeCacheMutex); m_pCachedNode->decrNodeUseCount(); @@ -6060,16 +5601,23 @@ public: f_mutexUnlock( gv_XFlmSysData.hNodeCacheMutex); m_pCachedNode = NULL; } + + if( m_pBufferIStream) + { + m_pBufferIStream->Release(); + m_pBufferIStream = NULL; + } } F_CachedNode * m_pCachedNode; + IF_BufferIStream * m_pBufferIStream; friend class F_CachedNode; }; /***************************************************************************** Desc: ******************************************************************************/ -class F_DOMNode : public IF_DOMNode, public XF_Base +class F_DOMNode : public IF_DOMNode { public: @@ -6105,9 +5653,9 @@ public: } } - FLMINT XFLMAPI Release( void); + FLMINT FLMAPI Release( void); - RCODE XFLMAPI createNode( + RCODE FLMAPI createNode( IF_Db * pDb, eDomNodeType eNodeType, FLMUINT uiNameId, @@ -6115,34 +5663,34 @@ public: IF_DOMNode ** ppNewNode, FLMUINT64 * pui64NodeId = NULL); - RCODE XFLMAPI createChildElement( + RCODE FLMAPI createChildElement( IF_Db * pDb, FLMUINT uiChildElementNameId, eNodeInsertLoc eLocation, IF_DOMNode ** ppNewChildElementNode, FLMUINT64 * pui64NodeId = NULL); - RCODE XFLMAPI deleteNode( + RCODE FLMAPI deleteNode( IF_Db * pDb); - RCODE XFLMAPI deleteChildren( + RCODE FLMAPI deleteChildren( IF_Db * pDb, FLMUINT uiNameId = 0); - RCODE XFLMAPI createAttribute( + RCODE FLMAPI createAttribute( IF_Db * pDb, FLMUINT uiAttrNameId, IF_DOMNode ** ppAttrNode); - RCODE XFLMAPI getFirstAttribute( + RCODE FLMAPI getFirstAttribute( IF_Db * pDb, IF_DOMNode ** ppAttrNode); - RCODE XFLMAPI getLastAttribute( + RCODE FLMAPI getLastAttribute( IF_Db * pDb, IF_DOMNode ** ppAttrNode); - FINLINE RCODE XFLMAPI getAttribute( + FINLINE RCODE FLMAPI getAttribute( IF_Db * pDb, FLMUINT uiAttrNameId, IF_DOMNode ** ppAttrNode) @@ -6150,36 +5698,36 @@ public: return( hasAttribute( pDb, uiAttrNameId, ppAttrNode)); } - RCODE XFLMAPI deleteAttribute( + RCODE FLMAPI deleteAttribute( IF_Db * pDb, FLMUINT uiAttrNameId); - RCODE XFLMAPI hasAttribute( + RCODE FLMAPI hasAttribute( IF_Db * pDb, FLMUINT uiAttrNameId, IF_DOMNode ** ppAttrNode = NULL); - RCODE XFLMAPI hasAttributes( + RCODE FLMAPI hasAttributes( IF_Db * pDb, FLMBOOL * pbHasAttrs); - RCODE XFLMAPI hasNextSibling( + RCODE FLMAPI hasNextSibling( IF_Db * pDb, FLMBOOL * pbHasNextSibling); - RCODE XFLMAPI hasPreviousSibling( + RCODE FLMAPI hasPreviousSibling( IF_Db * pDb, FLMBOOL * pbHasPreviousSibling); - RCODE XFLMAPI hasChildren( + RCODE FLMAPI hasChildren( IF_Db * pDb, FLMBOOL * pbHasChildren); - RCODE XFLMAPI isNamespaceDecl( + RCODE FLMAPI isNamespaceDecl( IF_Db * pDb, FLMBOOL * pbIsNamespaceDecl); - FINLINE eDomNodeType XFLMAPI getNodeType( void) + FINLINE eDomNodeType FLMAPI getNodeType( void) { if( m_uiAttrNameId) { @@ -6194,51 +5742,51 @@ public: return( INVALID_NODE); } - RCODE XFLMAPI getNodeId( + RCODE FLMAPI getNodeId( IF_Db * pDb, FLMUINT64 * pui64NodeId); - RCODE XFLMAPI getParentId( + RCODE FLMAPI getParentId( IF_Db * pDb, FLMUINT64 * pui64ParentId); - RCODE XFLMAPI getDocumentId( + RCODE FLMAPI getDocumentId( IF_Db * pDb, FLMUINT64 * pui64DocumentId); - RCODE XFLMAPI getPrevSibId( + RCODE FLMAPI getPrevSibId( IF_Db * pDb, FLMUINT64 * pui64PrevSibId); - RCODE XFLMAPI getNextSibId( + RCODE FLMAPI getNextSibId( IF_Db * pDb, FLMUINT64 * pui64NextSibId); - RCODE XFLMAPI getFirstChildId( + RCODE FLMAPI getFirstChildId( IF_Db * pDb, FLMUINT64 * pui64FirstChildId); - RCODE XFLMAPI getLastChildId( + RCODE FLMAPI getLastChildId( IF_Db * pDb, FLMUINT64 * pui64LastChildId); - RCODE XFLMAPI getNameId( + RCODE FLMAPI getNameId( IF_Db * pDb, FLMUINT * puiNameId); - virtual RCODE XFLMAPI getEncDefId( + virtual RCODE FLMAPI getEncDefId( IF_Db * pDb, FLMUINT * puiEncDefId); - RCODE XFLMAPI getDataType( + RCODE FLMAPI getDataType( IF_Db * pDb, FLMUINT * puiDataType); - RCODE XFLMAPI getDataLength( + RCODE FLMAPI getDataLength( IF_Db * pDb, FLMUINT * puiLength); - FINLINE RCODE XFLMAPI getUINT32( + FINLINE RCODE FLMAPI getUINT32( IF_Db * pDb, FLMUINT32 * pui32Value) { @@ -6253,7 +5801,7 @@ public: return( convertToUINT32( ui64Value, FALSE, pui32Value)); } - FINLINE RCODE XFLMAPI getUINT( + FINLINE RCODE FLMAPI getUINT( IF_Db * pDb, FLMUINT * puiValue) { @@ -6268,14 +5816,14 @@ public: return( convertToUINT( ui64Value, FALSE, puiValue)); } - FINLINE RCODE XFLMAPI getUINT64( + FINLINE RCODE FLMAPI getUINT64( IF_Db * pDb, FLMUINT64 * pui64Value) { return( getNumber64( (F_Db *)pDb, pui64Value, NULL)); } - FINLINE RCODE XFLMAPI getINT32( + FINLINE RCODE FLMAPI getINT32( IF_Db * pDb, FLMINT32 * pi32Value) { @@ -6291,7 +5839,7 @@ public: return( convertToINT32( ui64Value, bNeg, pi32Value)); } - FINLINE RCODE XFLMAPI getINT( + FINLINE RCODE FLMAPI getINT( IF_Db * pDb, FLMINT * piValue) { @@ -6307,7 +5855,7 @@ public: return( convertToINT( ui64Value, bNeg, piValue)); } - FINLINE RCODE XFLMAPI getINT64( + FINLINE RCODE FLMAPI getINT64( IF_Db * pDb, FLMINT64 * pi64Value) { @@ -6323,18 +5871,18 @@ public: return( convertToINT64( ui64Value, bNeg, pi64Value)); } - RCODE XFLMAPI getMetaValue( + RCODE FLMAPI getMetaValue( IF_Db * pDb, FLMUINT64 * pui64Value); - FINLINE RCODE XFLMAPI getUnicodeChars( + FINLINE RCODE FLMAPI getUnicodeChars( IF_Db * pDb, FLMUINT * puiNumChars) { return( getUnicode( pDb, NULL, 0, 0, FLM_MAX_UINT, puiNumChars)); } - RCODE XFLMAPI getUnicode( + RCODE FLMAPI getUnicode( IF_Db * pDb, FLMUNICODE * puzValueBuffer, FLMUINT uiBufferSize, @@ -6343,15 +5891,15 @@ public: FLMUINT * puiCharsReturned = NULL, FLMUINT * puiBufferBytesUsed = NULL); - RCODE XFLMAPI getUnicode( + RCODE FLMAPI getUnicode( IF_Db * pDb, FLMUNICODE ** ppuzUnicodeValue); - RCODE XFLMAPI getUnicode( + RCODE FLMAPI getUnicode( IF_Db * pDb, IF_DynaBuf * pDynaBuf); - RCODE XFLMAPI getUTF8( + RCODE FLMAPI getUTF8( IF_Db * pDb, FLMBYTE * pszValueBuffer, FLMUINT uiBufferSize, @@ -6360,26 +5908,26 @@ public: FLMUINT * puiCharsReturned = NULL, FLMUINT * puiBufferBytesUsed = NULL); - RCODE XFLMAPI getUTF8( + RCODE FLMAPI getUTF8( IF_Db * pDb, FLMBYTE ** ppszUTF8Value); - RCODE XFLMAPI getUTF8( + RCODE FLMAPI getUTF8( IF_Db * pDb, IF_DynaBuf * pDynaBuf); - RCODE XFLMAPI getBinary( + RCODE FLMAPI getBinary( IF_Db * pDb, void * pvValue, FLMUINT uiByteOffset, FLMUINT uiBytesRequested, FLMUINT * puiBytesReturned); - RCODE XFLMAPI getBinary( + RCODE FLMAPI getBinary( IF_Db * pDb, IF_DynaBuf * pBuffer); - FINLINE RCODE XFLMAPI getAttributeValueUINT32( + FINLINE RCODE FLMAPI getAttributeValueUINT32( IF_Db * pDb, FLMUINT uiAttrName, FLMUINT32 * pui32Num) @@ -6397,7 +5945,7 @@ public: return( convertToUINT32( ui64Num, bNeg, pui32Num)); } - FINLINE RCODE XFLMAPI getAttributeValueUINT32( + FINLINE RCODE FLMAPI getAttributeValueUINT32( IF_Db * pDb, FLMUINT uiAttrName, FLMUINT32 * pui32Num, @@ -6420,7 +5968,7 @@ public: return( rc); } - FINLINE RCODE XFLMAPI getAttributeValueUINT( + FINLINE RCODE FLMAPI getAttributeValueUINT( IF_Db * pDb, FLMUINT uiAttrName, FLMUINT * puiNum) @@ -6438,7 +5986,7 @@ public: return( convertToUINT( ui64Num, bNeg, puiNum)); } - FINLINE RCODE XFLMAPI getAttributeValueUINT( + FINLINE RCODE FLMAPI getAttributeValueUINT( IF_Db * pDb, FLMUINT uiAttrName, FLMUINT * puiNum, @@ -6461,7 +6009,7 @@ public: return( rc); } - FINLINE RCODE XFLMAPI getAttributeValueUINT64( + FINLINE RCODE FLMAPI getAttributeValueUINT64( IF_Db * pDb, FLMUINT uiAttrName, FLMUINT64 * pui64Num) @@ -6479,7 +6027,7 @@ public: return( convertToUINT64( ui64Num, bNeg, pui64Num)); } - FINLINE RCODE XFLMAPI getAttributeValueUINT64( + FINLINE RCODE FLMAPI getAttributeValueUINT64( IF_Db * pDb, FLMUINT uiAttrName, FLMUINT64 * pui64Num, @@ -6502,7 +6050,7 @@ public: return( rc); } - FINLINE RCODE XFLMAPI getAttributeValueINT( + FINLINE RCODE FLMAPI getAttributeValueINT( IF_Db * pDb, FLMUINT uiAttrName, FLMINT * piNum) @@ -6520,7 +6068,7 @@ public: return( convertToINT( ui64Num, bNeg, piNum)); } - FINLINE RCODE XFLMAPI getAttributeValueINT( + FINLINE RCODE FLMAPI getAttributeValueINT( IF_Db * pDb, FLMUINT uiAttrName, FLMINT * piNum, @@ -6543,7 +6091,7 @@ public: return( rc); } - FINLINE RCODE XFLMAPI getAttributeValueINT64( + FINLINE RCODE FLMAPI getAttributeValueINT64( IF_Db * pDb, FLMUINT uiAttrName, FLMINT64 * pi64Num) @@ -6561,7 +6109,7 @@ public: return( convertToINT64( ui64Num, bNeg, pi64Num)); } - FINLINE RCODE XFLMAPI getAttributeValueINT64( + FINLINE RCODE FLMAPI getAttributeValueINT64( IF_Db * pDb, FLMUINT uiAttrName, FLMINT64 * pi64Num, @@ -6584,7 +6132,7 @@ public: return( rc); } - FINLINE RCODE XFLMAPI getAttributeValueUnicode( + FINLINE RCODE FLMAPI getAttributeValueUnicode( IF_Db * pDb, FLMUINT uiAttrName, FLMUNICODE * puzValueBuffer, @@ -6596,17 +6144,17 @@ public: puzValueBuffer, uiBufferSize, puiCharsReturned, puiBufferBytesUsed)); } - RCODE XFLMAPI getAttributeValueUnicode( + RCODE FLMAPI getAttributeValueUnicode( IF_Db * pDb, FLMUINT uiAttrName, FLMUNICODE ** ppuzValueBuffer); - RCODE XFLMAPI getAttributeValueUnicode( + RCODE FLMAPI getAttributeValueUnicode( IF_Db * pDb, FLMUINT uiAttrName, IF_DynaBuf * pDynaBuf); - RCODE XFLMAPI getAttributeValueUTF8( + RCODE FLMAPI getAttributeValueUTF8( IF_Db * pDb, FLMUINT uiAttrName, FLMBYTE * pucValueBuffer, @@ -6618,29 +6166,29 @@ public: pucValueBuffer, uiBufferSize, puiCharsReturned, puiBufferBytesUsed)); } - RCODE XFLMAPI getAttributeValueUTF8( + RCODE FLMAPI getAttributeValueUTF8( IF_Db * pDb, FLMUINT uiAttrNameId, FLMBYTE ** ppszValueBuffer); - RCODE XFLMAPI getAttributeValueUTF8( + RCODE FLMAPI getAttributeValueUTF8( IF_Db * pDb, FLMUINT uiAttrName, IF_DynaBuf * pDynaBuf); - RCODE XFLMAPI getAttributeValueBinary( + RCODE FLMAPI getAttributeValueBinary( IF_Db * pDb, FLMUINT uiAttrName, void * pvValueBuffer, FLMUINT uiBufferSize, FLMUINT * puiValueLength); - RCODE XFLMAPI getAttributeValueBinary( + RCODE FLMAPI getAttributeValueBinary( IF_Db * pDb, FLMUINT uiAttrName, IF_DynaBuf * pDynaBuf); - FINLINE RCODE XFLMAPI setUINT( + FINLINE RCODE FLMAPI setUINT( IF_Db * pDb, FLMUINT uiValue, FLMUINT uiEncDefId = 0) @@ -6648,7 +6196,7 @@ public: return( setNumber64( pDb, 0, uiValue, uiEncDefId)); } - FINLINE RCODE XFLMAPI setUINT64( + FINLINE RCODE FLMAPI setUINT64( IF_Db * pDb, FLMUINT64 ui64Value, FLMUINT uiEncDefId = 0) @@ -6656,7 +6204,7 @@ public: return( setNumber64( pDb, 0, ui64Value, uiEncDefId)); } - FINLINE RCODE XFLMAPI setINT( + FINLINE RCODE FLMAPI setINT( IF_Db * pDb, FLMINT iValue, FLMUINT uiEncDefId = 0) @@ -6664,7 +6212,7 @@ public: return( setNumber64( pDb, iValue, 0, uiEncDefId)); } - FINLINE RCODE XFLMAPI setINT64( + FINLINE RCODE FLMAPI setINT64( IF_Db * pDb, FLMINT64 i64Value, FLMUINT uiEncDefId = 0) @@ -6672,11 +6220,11 @@ public: return( setNumber64( pDb, i64Value, 0, uiEncDefId)); } - RCODE XFLMAPI setMetaValue( + RCODE FLMAPI setMetaValue( IF_Db * pDb, FLMUINT64 ui64Value); - FINLINE RCODE XFLMAPI setUnicode( + FINLINE RCODE FLMAPI setUnicode( IF_Db * pDb, const FLMUNICODE * puzValue, FLMUINT uiValueLength = 0, @@ -6697,7 +6245,7 @@ public: } } - FINLINE RCODE XFLMAPI setUTF8( + FINLINE RCODE FLMAPI setUTF8( IF_Db * pDb, const FLMBYTE * pszValue, FLMUINT uiValueLength = 0, @@ -6718,7 +6266,7 @@ public: } } - FINLINE RCODE XFLMAPI setBinary( + FINLINE RCODE FLMAPI setBinary( IF_Db * pDb, const void * pvValue, FLMUINT uiValueLength, @@ -6739,7 +6287,7 @@ public: } } - FINLINE RCODE XFLMAPI setAttributeValueUINT( + FINLINE RCODE FLMAPI setAttributeValueUINT( IF_Db * pDb, FLMUINT uiAttrName, FLMUINT uiValue, @@ -6749,7 +6297,7 @@ public: 0, uiValue, uiEncDefId)); } - FINLINE RCODE XFLMAPI setAttributeValueUINT64( + FINLINE RCODE FLMAPI setAttributeValueUINT64( IF_Db * pDb, FLMUINT uiAttrName, FLMUINT64 ui64Value, @@ -6759,7 +6307,7 @@ public: 0, ui64Value, uiEncDefId)); } - FINLINE RCODE XFLMAPI setAttributeValueINT( + FINLINE RCODE FLMAPI setAttributeValueINT( IF_Db * pDb, FLMUINT uiAttrName, FLMINT iValue, @@ -6769,7 +6317,7 @@ public: iValue, 0, uiEncDefId)); } - FINLINE RCODE XFLMAPI setAttributeValueINT64( + FINLINE RCODE FLMAPI setAttributeValueINT64( IF_Db * pDb, FLMUINT uiAttrName, FLMINT64 i64Value, @@ -6779,91 +6327,91 @@ public: i64Value, 0, uiEncDefId)); } - RCODE XFLMAPI setAttributeValueUnicode( + RCODE FLMAPI setAttributeValueUnicode( IF_Db * pDb, FLMUINT uiAttrName, const FLMUNICODE * puzValue, FLMUINT uiEncDefId = 0); - RCODE XFLMAPI setAttributeValueUTF8( + RCODE FLMAPI setAttributeValueUTF8( IF_Db * pDb, FLMUINT uiAttrName, const FLMBYTE * pszValue, FLMUINT uiLength, FLMUINT uiEncDefId = 0); - RCODE XFLMAPI setAttributeValueBinary( + RCODE FLMAPI setAttributeValueBinary( IF_Db * pDb, FLMUINT uiAttrName, const void * pvValue, FLMUINT uiLength, FLMUINT uiEncDefId = 0); - RCODE XFLMAPI getDocumentNode( + RCODE FLMAPI getDocumentNode( IF_Db * pDb, IF_DOMNode ** ppDocument); - RCODE XFLMAPI getNextDocument( + RCODE FLMAPI getNextDocument( IF_Db * pDb, IF_DOMNode ** ppNextDocument); - RCODE XFLMAPI getPreviousDocument( + RCODE FLMAPI getPreviousDocument( IF_Db * pDb, IF_DOMNode ** ppPrevDocument); - RCODE XFLMAPI getParentNode( + RCODE FLMAPI getParentNode( IF_Db * pDb, IF_DOMNode ** ppParent); - RCODE XFLMAPI getFirstChild( + RCODE FLMAPI getFirstChild( IF_Db * pDb, IF_DOMNode ** ppFirstChild); - RCODE XFLMAPI getLastChild( + RCODE FLMAPI getLastChild( IF_Db * pDb, IF_DOMNode ** ppLastChild); - RCODE XFLMAPI getNextSibling( + RCODE FLMAPI getNextSibling( IF_Db * pDb, IF_DOMNode ** ppNextSibling); - RCODE XFLMAPI getPreviousSibling( + RCODE FLMAPI getPreviousSibling( IF_Db * pDb, IF_DOMNode ** ppPrevSibling); - RCODE XFLMAPI getChild( + RCODE FLMAPI getChild( IF_Db * pDb, eDomNodeType eNodeType, IF_DOMNode ** ppChild); - RCODE XFLMAPI getChildElement( + RCODE FLMAPI getChildElement( IF_Db * pDb, FLMUINT uiElementNameId, IF_DOMNode ** ppChild, FLMUINT uiFlags = 0); - RCODE XFLMAPI getSiblingElement( + RCODE FLMAPI getSiblingElement( IF_Db * pDb, FLMUINT uiElementNameId, FLMBOOL bNext, IF_DOMNode ** ppSibling); - RCODE XFLMAPI getAncestorElement( + RCODE FLMAPI getAncestorElement( IF_Db * pDb, FLMUINT uiElementNameId, IF_DOMNode ** ppAncestor); - RCODE XFLMAPI getDescendantElement( + RCODE FLMAPI getDescendantElement( IF_Db * pDb, FLMUINT uiElementNameId, IF_DOMNode ** ppDescendant); - RCODE XFLMAPI insertBefore( + RCODE FLMAPI insertBefore( IF_Db * pDb, IF_DOMNode * pNewChild, IF_DOMNode * pRefChild); - FINLINE RCODE XFLMAPI getPrefix( + FINLINE RCODE FLMAPI getPrefix( IF_Db * pDb, FLMUNICODE * puzPrefixBuffer, FLMUINT uiBufferSize, @@ -6873,7 +6421,7 @@ public: puiCharsReturned)); } - FINLINE RCODE XFLMAPI getPrefix( + FINLINE RCODE FLMAPI getPrefix( IF_Db * pDb, char * pszPrefixBuffer, FLMUINT uiBufferSize, @@ -6883,29 +6431,29 @@ public: puiCharsReturned)); } - RCODE XFLMAPI getPrefixId( + RCODE FLMAPI getPrefixId( IF_Db * pDb, FLMUINT * puiPrefixId); - FINLINE RCODE XFLMAPI setPrefix( + FINLINE RCODE FLMAPI setPrefix( IF_Db * pDb, const FLMUNICODE * puzPrefix) { return setPrefix( TRUE, pDb, (void *)puzPrefix); } - FINLINE RCODE XFLMAPI setPrefix( + FINLINE RCODE FLMAPI setPrefix( IF_Db * pDb, const char * pszPrefix) { return setPrefix( FALSE, pDb, (void *)pszPrefix); } - RCODE XFLMAPI setPrefixId( + RCODE FLMAPI setPrefixId( IF_Db * pDb, FLMUINT uiPrefixId); - FINLINE RCODE XFLMAPI getNamespaceURI( + FINLINE RCODE FLMAPI getNamespaceURI( IF_Db * pDb, FLMUNICODE * puzNamespaceURIBuffer, FLMUINT uiBufferSize, @@ -6915,7 +6463,7 @@ public: (void *)puzNamespaceURIBuffer, uiBufferSize, puiCharsReturned); } - FINLINE RCODE XFLMAPI getNamespaceURI( + FINLINE RCODE FLMAPI getNamespaceURI( IF_Db * pDb, char * pszNamespaceURIBuffer, FLMUINT uiBufferSize, @@ -6925,7 +6473,7 @@ public: (void *)pszNamespaceURIBuffer, uiBufferSize, puiCharsReturned); } - FINLINE RCODE XFLMAPI getLocalName( + FINLINE RCODE FLMAPI getLocalName( IF_Db * pDb, FLMUNICODE * puzLocalNameBuffer, FLMUINT uiBufferSize, @@ -6935,7 +6483,7 @@ public: uiBufferSize, puiCharsReturned)); } - FINLINE RCODE XFLMAPI getLocalName( + FINLINE RCODE FLMAPI getLocalName( IF_Db * pDb, char * pszLocalNameBuffer, FLMUINT uiBufferSize, @@ -6945,19 +6493,19 @@ public: puiCharsReturned)); } - RCODE XFLMAPI getQualifiedName( + RCODE FLMAPI getQualifiedName( IF_Db * pDb, FLMUNICODE * puzQualifiedNameBuffer, FLMUINT uiBufferSize, FLMUINT * puiCharsReturned); - RCODE XFLMAPI getQualifiedName( + RCODE FLMAPI getQualifiedName( IF_Db * pDb, char * pszQualifiedNameBuffer, FLMUINT uiBufferSize, FLMUINT * puiCharsReturned); - FINLINE RCODE XFLMAPI getCollection( + FINLINE RCODE FLMAPI getCollection( IF_Db *, // pDb, FLMUINT * puiCollection) { @@ -6965,24 +6513,24 @@ public: return( NE_XFLM_OK); } - RCODE XFLMAPI createAnnotation( + RCODE FLMAPI createAnnotation( IF_Db * pDb, IF_DOMNode ** ppAnnotation, FLMUINT64 * pui64NodeId = NULL); - RCODE XFLMAPI getAnnotation( + RCODE FLMAPI getAnnotation( IF_Db * pDb, IF_DOMNode ** ppAnnotation); - RCODE XFLMAPI getAnnotationId( + RCODE FLMAPI getAnnotationId( IF_Db * pDb, FLMUINT64 * pui64AnnotationId); - RCODE XFLMAPI hasAnnotation( + RCODE FLMAPI hasAnnotation( IF_Db * pDb, FLMBOOL * pbHasAnnotation); - FINLINE RCODE XFLMAPI getIStream( + FINLINE RCODE FLMAPI getIStream( IF_Db * pDb, IF_PosIStream ** ppIStream, FLMUINT * puiDataType = NULL, @@ -6992,7 +6540,7 @@ public: puiDataType, puiDataLength)); } - FINLINE RCODE XFLMAPI getTextIStream( + FINLINE RCODE FLMAPI getTextIStream( IF_Db * pDb, IF_PosIStream ** ppIStream, FLMUINT * puiNumChars = NULL) @@ -7000,14 +6548,14 @@ public: return( getTextIStream( (F_Db *)pDb, NULL, ppIStream, puiNumChars)); } - FLMUINT XFLMAPI compareNode( + FLMUINT FLMAPI compareNode( IF_DOMNode * pNode, IF_Db * pDb1, IF_Db * pDb2, char * pszErrBuff, FLMUINT uiErrBuffLen); - RCODE XFLMAPI isDataLocalToNode( + RCODE FLMAPI isDataLocalToNode( IF_Db * pDb, FLMBOOL * pbDataIsLocal); @@ -7023,7 +6571,7 @@ public: return( FALSE); } - RCODE XFLMAPI setTextFastPath( + RCODE FLMAPI setTextFastPath( F_Db * pDb, const void * pvValue, FLMUINT uiNumBytesInBuffer, @@ -7837,7 +7385,7 @@ friend class F_NodeInfo; /*=========================================================================== Desc: Pool manager for DOM nodes ===========================================================================*/ -class F_NodePool : public XF_RefCount, public XF_Base +class F_NodePool : public F_Object { public: @@ -7893,7 +7441,7 @@ typedef struct Recov_Dict_Node typedef struct Recov_Dict_Info { RECOV_DICT_NODE * pRecovNodes; - F_Pool pool; + IF_Pool * pPool; } RECOV_DICT_INFO; typedef struct RSIxKeyTag @@ -7907,7 +7455,7 @@ typedef struct RSIxKeyTag /****************************************************************************** Desc: ******************************************************************************/ -class F_KeyCollector : public XF_RefCount, public XF_Base +class F_KeyCollector : public F_Object { public: @@ -8020,7 +7568,7 @@ typedef struct State_Info /****************************************************************************** Desc: ******************************************************************************/ -class F_NodeVerifier : public XF_RefCount, public XF_Base +class F_NodeVerifier : public F_Object { public: @@ -8109,7 +7657,7 @@ typedef struct /****************************************************************************** Desc: ******************************************************************************/ -class RebuildNodeInfoStack : public XF_RefCount, public XF_Base +class RebuildNodeInfoStack : public F_Object { public: @@ -8147,7 +7695,7 @@ typedef struct /****************************************************************************** Desc: DbCheck object for verifying the condition of the database. ******************************************************************************/ -class F_DbCheck : public XF_RefCount, public XF_Base +class F_DbCheck : public F_Object { public: @@ -8343,7 +7891,7 @@ private: FLMBOOL m_bSkipDOMLinkCheck; F_BtResultSet * m_pXRefRS; F_BtPool * m_pBtPool; - F_RandomGenerator * m_pRandGen; + IF_RandomGenerator * m_pRandGen; char m_szResultSetDibName [F_PATH_MAX_SIZE]; F_Db * m_pResultSetDb; IF_DbCheckStatus * m_pDbCheckStatus; @@ -8494,7 +8042,7 @@ friend class F_KeyCollector; ** REFLECTED IN THE FlmCorruptStrings TABLE FOUND IN FLERRSTR.CPP */ -class F_DbInfo : public IF_DbInfo, public XF_Base +class F_DbInfo : public IF_DbInfo { public: @@ -8537,32 +8085,32 @@ public: m_uiNumCollections = 0; } - FINLINE FLMUINT XFLMAPI getNumCollections( void) + FINLINE FLMUINT FLMAPI getNumCollections( void) { return( m_uiNumCollections); } - FINLINE FLMUINT XFLMAPI getNumIndexes( void) + FINLINE FLMUINT FLMAPI getNumIndexes( void) { return( m_uiNumIndexes); } - FINLINE FLMUINT XFLMAPI getNumLogicalFiles( void) + FINLINE FLMUINT FLMAPI getNumLogicalFiles( void) { return( m_uiNumLogicalFiles); } - FINLINE FLMUINT64 XFLMAPI getFileSize( void) + FINLINE FLMUINT64 FLMAPI getFileSize( void) { return( m_ui64FileSize); } - FINLINE XFLM_DB_HDR * XFLMAPI getDbHdr( void) + FINLINE XFLM_DB_HDR * FLMAPI getDbHdr( void) { return( &m_dbHdr); } - FINLINE void XFLMAPI getAvailBlockStats( + FINLINE void FLMAPI getAvailBlockStats( FLMUINT64 * pui64BytesUsed, FLMUINT * puiBlockCount, FLMINT * piLastError, @@ -8574,7 +8122,7 @@ public: *puiNumErrors = m_AvailBlocks.uiNumErrors; } - FINLINE void XFLMAPI getLFHBlockStats( + FINLINE void FLMAPI getLFHBlockStats( FLMUINT64 * pui64BytesUsed, FLMUINT * puiBlockCount, FLMINT * piLastError, @@ -8586,14 +8134,14 @@ public: *puiNumErrors = m_LFHBlocks.uiNumErrors; } - void XFLMAPI getBTreeInfo( + void FLMAPI getBTreeInfo( FLMUINT uiNthLogicalFile, FLMUINT * puiLfNum, eLFileType * peLfType, FLMUINT * puiRootBlkAddress, FLMUINT * puiNumLevels); - void XFLMAPI getBTreeBlockStats( + void FLMAPI getBTreeBlockStats( FLMUINT uiNthLogicalFile, FLMUINT uiLevel, FLMUINT64 * pui64KeyCount, @@ -8668,7 +8216,7 @@ typedef struct Desc: Class to rebuild a broken database. This class is used by F_DbSystem::dbRebuild() =============================================================================*/ -class F_DbRebuild : public XF_RefCount, public XF_Base +class F_DbRebuild : public F_Object { public: @@ -8713,7 +8261,7 @@ public: FLMUINT uiCurrentTime = FLM_GET_TIMER(); FLMUINT uiElapTime = FLM_ELAPSED_TIME( uiCurrentTime, m_uiLastStatusTime); - FLM_TIMER_UNITS_TO_SECS( uiElapTime, uiElapTime); + uiElapTime = FLM_TIMER_UNITS_TO_SECS( uiElapTime); if( bForce || uiElapTime >= 1) { @@ -8774,10 +8322,11 @@ private: FLMBYTE * pucBuffer) { pucBuffer[ 0] = ucPrefix; - longToByte( (FLMUINT32)uiCollection, &pucBuffer[ 1]); - long64ToByte( ui64NodeId, &pucBuffer[ 5]); - longToByte( (FLMUINT32)uiBlockAddr, &pucBuffer[ 13]); - longToByte( (FLMUINT32)uiElmNumber, &pucBuffer[ 17]); + + f_UINT32ToByte( (FLMUINT32)uiCollection, &pucBuffer[ 1]); + f_UINT64ToByte( ui64NodeId, &pucBuffer[ 5]); + f_UINT32ToByte( (FLMUINT32)uiBlockAddr, &pucBuffer[ 13]); + f_UINT32ToByte( (FLMUINT32)uiElmNumber, &pucBuffer[ 17]); } FINLINE void extractRSetEntry( @@ -8789,28 +8338,28 @@ private: { if( puiCollection) { - *puiCollection = byteToLong( &pucBuffer[ 1]); + *puiCollection = f_byteToUINT32( &pucBuffer[ 1]); } if( pui64NodeId) { - *pui64NodeId = byteToLong64( &pucBuffer[ 5]); + *pui64NodeId = f_byteToUINT64( &pucBuffer[ 5]); } if( puiBlockAddr) { - *puiBlockAddr = byteToLong( &pucBuffer[ 13]); + *puiBlockAddr = f_byteToUINT32( &pucBuffer[ 13]); } if( puiElmNumber) { - *puiElmNumber = byteToLong( &pucBuffer[ 17]); + *puiElmNumber = f_byteToUINT32( &pucBuffer[ 17]); } } RCODE recoverTree( F_RebuildNodeIStream * pIStream, - FResultSet * pNonRootRSet, + IF_ResultSet * pNonRootRSet, F_DOMNode * pParentNode, F_CachedNode * pRecovCachedNode, FLMBYTE * pucNodeIV); @@ -8948,4 +8497,227 @@ FINLINE RCODE F_NodeCacheMgr::makeWriteCopy( return( NE_XFLM_OK); } +/**************************************************************************** +Desc: +*****************************************************************************/ +class F_DynaBuf : public IF_DynaBuf +{ +public: + + F_DynaBuf( + FLMBYTE * pucBuffer, + FLMUINT uiBufferSize) + { + m_pucBuffer = pucBuffer; + m_uiBufferSize = uiBufferSize; + m_uiOffset = 0; + m_bAllocatedBuffer = FALSE; + } + + virtual ~F_DynaBuf() + { + if( m_bAllocatedBuffer) + { + f_free( &m_pucBuffer); + } + } + + FINLINE void FLMAPI truncateData( + FLMUINT uiSize) + { + if( uiSize < m_uiOffset) + { + m_uiOffset = uiSize; + } + } + + FINLINE RCODE FLMAPI allocSpace( + FLMUINT uiSize, + void ** ppvPtr) + { + RCODE rc = NE_FLM_OK; + + if( m_uiOffset + uiSize >= m_uiBufferSize) + { + if( RC_BAD( rc = resizeBuffer( m_uiOffset + uiSize + 512))) + { + goto Exit; + } + } + + *ppvPtr = &m_pucBuffer[ m_uiOffset]; + m_uiOffset += uiSize; + + Exit: + + return( rc); + } + + FINLINE RCODE FLMAPI appendData( + const void * pvData, + FLMUINT uiSize) + { + RCODE rc = NE_FLM_OK; + void * pvTmp; + + if( RC_BAD( rc = allocSpace( uiSize, &pvTmp))) + { + goto Exit; + } + + if( uiSize == 1) + { + *((FLMBYTE *)pvTmp) = *((FLMBYTE *)pvData); + } + else + { + f_memcpy( pvTmp, pvData, uiSize); + } + + Exit: + + return( rc); + } + + FINLINE RCODE FLMAPI appendByte( + FLMBYTE ucChar) + { + RCODE rc = NE_FLM_OK; + FLMBYTE * pucTmp; + + if( RC_BAD( rc = allocSpace( 1, (void **)&pucTmp))) + { + goto Exit; + } + + *pucTmp = ucChar; + + Exit: + + return( rc); + } + + FINLINE RCODE FLMAPI appendUniChar( + FLMUNICODE uChar) + { + RCODE rc = NE_FLM_OK; + FLMUNICODE * puTmp; + + if( RC_BAD( rc = allocSpace( sizeof( FLMUNICODE), (void **)&puTmp))) + { + goto Exit; + } + + *puTmp = uChar; + + Exit: + + return( rc); + } + + FINLINE FLMBYTE * FLMAPI getBufferPtr( void) + { + return( m_pucBuffer); + } + + FINLINE FLMUNICODE * FLMAPI getUnicodePtr( void) + { + if( m_uiOffset >= sizeof( FLMUNICODE)) + { + return( (FLMUNICODE *)m_pucBuffer); + } + + return( NULL); + } + + FINLINE FLMUINT FLMAPI getUnicodeLength( void) + { + if( m_uiOffset <= sizeof( FLMUNICODE)) + { + return( 0); + } + + return( (m_uiOffset >> 1) - 1); + } + + FINLINE FLMUINT FLMAPI getDataLength( void) + { + return( m_uiOffset); + } + + FINLINE RCODE FLMAPI copyFromBuffer( + IF_DynaBuf * pSource) + { + RCODE rc = NE_FLM_OK; + + if( RC_BAD( rc = resizeBuffer( + ((F_DynaBuf *)pSource)->m_uiBufferSize))) + { + goto Exit; + } + + if( (m_uiOffset = ((F_DynaBuf *)pSource)->m_uiOffset) != 0) + { + f_memcpy( m_pucBuffer, ((F_DynaBuf *)pSource)->m_pucBuffer, + ((F_DynaBuf *)pSource)->m_uiOffset); + } + + Exit: + + return( rc); + } + +private: + + FINLINE RCODE resizeBuffer( + FLMUINT uiNewSize) + { + RCODE rc = NE_FLM_OK; + + if( !m_bAllocatedBuffer) + { + if( uiNewSize > m_uiBufferSize) + { + FLMBYTE * pucOriginalBuf = m_pucBuffer; + + if( RC_BAD( rc = f_alloc( uiNewSize, &m_pucBuffer))) + { + m_pucBuffer = pucOriginalBuf; + goto Exit; + } + + m_bAllocatedBuffer = TRUE; + + if( m_uiOffset) + { + f_memcpy( m_pucBuffer, pucOriginalBuf, m_uiOffset); + } + } + } + else + { + if( RC_BAD( rc = f_realloc( uiNewSize, &m_pucBuffer))) + { + goto Exit; + } + + if( uiNewSize < m_uiOffset) + { + m_uiOffset = uiNewSize; + } + } + + m_uiBufferSize = uiNewSize; + + Exit: + + return( rc); + } + + FLMBOOL m_bAllocatedBuffer; + FLMBYTE * m_pucBuffer; + FLMUINT m_uiBufferSize; + FLMUINT m_uiOffset; +}; + #endif // FLAIMSYS_H diff --git a/xflaim/src/flalloc.cpp b/xflaim/src/flalloc.cpp deleted file mode 100644 index ab2f2bf..0000000 --- a/xflaim/src/flalloc.cpp +++ /dev/null @@ -1,1798 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: This file contains the f_alloc, f_calloc, f_realloc, f_recalloc, -// and f_free routines. -// -// Tabs: 3 -// -// Copyright (c) 1991, 1993, 1995-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: flalloc.cpp 3112 2006-01-19 13:12:40 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -#ifdef FLM_WIN - - // This pragma is needed because FLAIM may be built with a - // packing other than 8-bytes for Windows (such as 1-byte packing). - // Code in FLAIM that uses windows structures and system calls - // MUST use 8-byte packing (the packing used by the O/S). - // See Microsoft technical article Q117388. - - #pragma pack( push, enter_windows, 8) - #include - #pragma pack( pop, enter_windows) -#endif - -#ifdef FLM_UNIX - #ifdef HAVE_DLADDR - #include - #endif -#endif - -#if defined( FLM_UNIX) || defined( FLM_NLM) || defined( FLM_WIN) - #define PTR_IN_MBLK(p,bp,offs) (((FLMBYTE *)(p) > (FLMBYTE *)(bp)) && \ - ((FLMBYTE *)(p) <= (FLMBYTE *)(bp) + (offs))) -#else - #error Platform not supported -#endif - -#ifdef USE_ALT_MEM_MANAGER - - // If USE_ALT_MEM_MANAGER is defined, memory allocations will be based on - // a user-supplied module that implements f_alt_malloc, f_alt_free, and - // f_alt_realloc. - - // Prototypes - - extern "C" - { - void * f_alt_malloc( unsigned size); - void f_alt_free( void * memblock); - void * f_alt_realloc( void * memblock, unsigned size); - } - -#endif - -#define MEM_PTR_INIT_ARRAY_SIZE 512 -#define MEM_MAX_STACK_WALK_DEPTH 32 - -// If stack tracking is on, leak checking also -// needs to be on. - -#ifndef FLM_DEBUG - #ifdef DEBUG_SIM_OUT_OF_MEM - #undef DEBUG_SIM_OUT_OF_MEM - #endif -#endif - -#ifdef FLM_DEBUG - -// Platform specific stuff needed for tracking leaks - -#ifdef FLM_NLM - extern "C" - { - void GetClosestSymbol( - BYTE * szBuffer, - LONG udAddress); - } -#endif - -// Local function prototypes - -FSTATIC FLMBOOL initMemTracking( - void); - -FSTATIC void saveMemTrackingInfo( - F_MEM_HDR * pHdr); - -FSTATIC void updateMemTrackingInfo( - F_MEM_HDR * pHdr); - -FSTATIC void freeMemTrackingInfo( - FLMBOOL bMutexAlreadyLocked, - FLMUINT uiId, - FLMUINT * puiStack); - -#ifdef DEBUG_SIM_OUT_OF_MEM - -//one of every OUT_OF_MEM_FREQUENCY calls will fail - -#define OUT_OF_MEM_FREQUENCY 40000 - -//OUT_OF_MEM_SEQUENCE_LENGTH calls in a row will fail - -#define OUT_OF_MEM_SEQUENCE_LENGTH 10 - -FLMBOOL SimulateOutOfMemory() -{ - if ( - //is the flag turned on - (gv_XFlmSysData.uiOutOfMemSimEnabledFlag == - (FLMUINT)OUT_OF_MEM_SIM_ENABLED_FLAG) && - - //continuing a sequence of failures - ((gv_XFlmSysData.uiSimOutOfMemFailSequence > 0) || - - //failing randomly for the first time, and starting a new sequence - (f_randomChoice( &gv_XFlmSysData.memSimRandomGen, 0, OUT_OF_MEM_FREQUENCY) == 0) - )) - { - gv_XFlmSysData.uiSimOutOfMemFailTotal++; - gv_XFlmSysData.uiSimOutOfMemFailSequence++; - //if reached the end of failure sequence, reset back to 0 so the - //sequence will cease - if ( gv_XFlmSysData.uiSimOutOfMemFailSequence >= OUT_OF_MEM_SEQUENCE_LENGTH) - { - gv_XFlmSysData.uiSimOutOfMemFailSequence = 0; - } - return TRUE; - } - else - { - return FALSE; - } -} - -#endif //#ifdef DEBUG_SIM_OUT_OF_MEM - -#if defined( FLM_NLM) - -/************************************************************************ -Desc: Returns the current value of EBP--the value of the caller's stack - frame pointer. -*************************************************************************/ -void * memGetEBP(void); - -#ifdef FLM_MWERKS_NLM - - void * memGetEBP(void) - { - __asm - { - mov eax,[ebp] - } - } - -#else - - #pragma aux memGetEBP = "mov eax,ebp"; - -#endif - -/************************************************************************ -Desc: Returns the value at SS:[POS+OFFSET]. -*************************************************************************/ -void * memValueAtStackOffset(void *pos, int offset); - -#ifdef FLM_MWERKS_NLM - - void *memValueAtStackOffset(void *, int) - { - __asm - { - mov eax,[ebp+0x8] - mov ebx,[ebp+0xC] - mov eax,ss:[eax+ebx] - } - } - -#else - - #pragma aux memValueAtStackOffset = "mov eax,ss:[eax+ebx]" parm [eax] [ebx]; - -#endif - -/************************************************************************ -Desc: -*************************************************************************/ -FLMUINT * memWalkStack() -{ - FLMUINT uiLoop; - FLMUINT uiRtnAddr; - FLMUINT uiEbp = (FLMUINT) memGetEBP(); - FLMUINT uiAddresses [MEM_MAX_STACK_WALK_DEPTH + 1]; - FLMUINT * puiAddresses; - - uiEbp = (FLMUINT) memValueAtStackOffset( (void *)uiEbp, 0); // skip addrs we already know - uiRtnAddr = (FLMUINT) memValueAtStackOffset( (void *)uiEbp, 4); // Caller's return addr - - for (uiLoop = 0; uiLoop < MEM_MAX_STACK_WALK_DEPTH; uiLoop++) - { - FLMUINT uiOldEbp; - - uiAddresses [uiLoop] = uiRtnAddr; - if (!uiEbp) - { - break; - } - - uiOldEbp = uiEbp; - uiEbp = (FLMUINT) memValueAtStackOffset( (void *)uiEbp, 0); // Caller's frame ptr - - if (!uiEbp || uiEbp <= uiOldEbp || uiEbp > uiOldEbp + 5000) - { - break; - } - - uiRtnAddr = (FLMUINT) memValueAtStackOffset( (void *) uiEbp, 4); // Caller's return addr - } - uiAddresses [uiLoop] = 0; - if ((puiAddresses = (FLMUINT *)os_malloc( - sizeof( FLMUINT) * (uiLoop+1))) != NULL) - { - f_memcpy( puiAddresses, &uiAddresses [0], sizeof( FLMUINT) * (uiLoop + 1)); - } - return( puiAddresses); -} - -#elif defined( FLM_WIN) - -/******************************************************************** -Desc: Walk the call stack. -*********************************************************************/ -FLMUINT * memWalkStack() -{ - STACKFRAME64 stackFrame; - CONTEXT context; - DWORD machineType; - FLMUINT uiLoop; - FLMUINT uiAddresses [MEM_MAX_STACK_WALK_DEPTH + 1]; - FLMUINT * puiAddresses; - HANDLE hThread; - HANDLE hProcess; - FLMUINT uiAddrCount; - - f_memset( &stackFrame, 0, sizeof( stackFrame)); - f_memset( &context, 0, sizeof( context)); - -#ifdef FLM_64BIT - machineType = IMAGE_FILE_MACHINE_IA64; -#else - machineType = IMAGE_FILE_MACHINE_I386; -#endif - - // While you can continue walking the stack... - - unsigned vEBP, vEIP; - __asm mov vEBP, ebp - __asm call near nextinstr -nextinstr: - __asm pop vEIP; - - context.Ebp = vEBP; - context.Eip = vEIP; - stackFrame.AddrPC.Offset = vEIP; - stackFrame.AddrFrame.Offset = vEBP; - stackFrame.AddrPC.Mode = AddrModeFlat; - stackFrame.AddrFrame.Mode = AddrModeFlat; - - // Must lock the mutex because StackWalk is not thread safe. - - f_mutexLock( gv_XFlmSysData.hMemTrackingMutex); - hProcess = OpenProcess( PROCESS_VM_READ, FALSE, GetCurrentProcessId()); - hThread = OpenThread( THREAD_GET_CONTEXT | THREAD_SUSPEND_RESUME, - FALSE, GetCurrentThreadId()); - - // We have already processed the address inside memWalkStack - - uiAddrCount = 1; - uiLoop = 0; - for (;;) - { - if (!StackWalk64( machineType, hProcess, hThread, &stackFrame, - &context, NULL, - SymFunctionTableAccess64, SymGetModuleBase64, NULL)) - { - break; - } - - // Skip the first two addresses. These represent the following: - // 1) memWalkStack - // 2) saveMemTrackingInfo or updateMemTrackingInfo - // We don't need to see them in the stack trace. - - uiAddrCount++; - if (uiAddrCount > 2) - { - uiAddresses [uiLoop] = (FLMUINT)stackFrame.AddrReturn.Offset; - uiLoop++; - if (uiLoop == MEM_MAX_STACK_WALK_DEPTH) - { - break; - } - } - } - - f_mutexUnlock( gv_XFlmSysData.hMemTrackingMutex); - - uiAddresses [uiLoop] = 0; - if ((puiAddresses = (FLMUINT *)os_malloc( - sizeof( FLMUINT) * (uiLoop+1))) != NULL) - { - f_memcpy( puiAddresses, &uiAddresses [0], sizeof( FLMUINT) * (uiLoop + 1)); - } - return( puiAddresses); -} -#else -FLMUINT * memWalkStack() -{ - return( NULL); -} -#endif - -/******************************************************************** -Desc: Initialize memory tracking -*********************************************************************/ -FSTATIC FLMBOOL initMemTracking( void) -{ - RCODE rc; - F_MUTEX memMutex; - - if (!gv_XFlmSysData.bMemTrackingInitialized && !gv_XFlmSysData.uiInitThreadId) - { - gv_XFlmSysData.uiInitThreadId = f_threadId(); - rc = f_mutexCreate( &memMutex); - f_sleep( 50); - - // Only set to initialized if we were the last thread - // to set gv_XFlmSysData.uiInitThreadId - - if (f_threadId() == gv_XFlmSysData.uiInitThreadId) - { - if (RC_OK( rc)) - { - gv_XFlmSysData.hMemTrackingMutex = memMutex; - } - else - { - gv_XFlmSysData.hMemTrackingMutex = F_MUTEX_NULL; - } -#ifdef FLM_WIN - SymSetOptions( SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS); - gv_XFlmSysData.hMemProcess = GetCurrentProcess(); - SymInitialize( gv_XFlmSysData.hMemProcess, NULL, TRUE); -#endif - gv_XFlmSysData.bMemTrackingInitialized = TRUE; - } - else - { - if (RC_OK( rc)) - { - f_mutexDestroy( &memMutex); - } - } - } - - // Go into a loop until we see initialized flag set to TRUE - // Could be another thread that is doing it. - - while (!gv_XFlmSysData.bMemTrackingInitialized) - { - f_sleep( 10); - } - return( (gv_XFlmSysData.hMemTrackingMutex != F_MUTEX_NULL) ? TRUE : FALSE); -} - -/******************************************************************** -Desc: Save memory tracking information - called on alloc or realloc. -*********************************************************************/ -FSTATIC void saveMemTrackingInfo( - F_MEM_HDR * pHdr) -{ - FLMUINT uiNewCnt; - FLMUINT uiId; - void ** pNew; - - if (gv_XFlmSysData.bTrackLeaks && initMemTracking()) - { - f_mutexLock( gv_XFlmSysData.hMemTrackingMutex); - - // See if there is enough room in the array - - if (gv_XFlmSysData.uiMemNumPtrs == gv_XFlmSysData.uiMemTrackingPtrArraySize) - { - - // If array is not initialized, use initial count. Otherwise - // double the size. - - uiNewCnt = (FLMUINT)((!gv_XFlmSysData.uiMemTrackingPtrArraySize) - ? MEM_PTR_INIT_ARRAY_SIZE - : gv_XFlmSysData.uiMemTrackingPtrArraySize * 2); - if ((pNew = (void **)os_malloc( sizeof( void *) * uiNewCnt)) != NULL) - { - - // Copy the pointers from the old array, if any, - // into the newly allocated array. - - if (gv_XFlmSysData.uiMemTrackingPtrArraySize) - { - f_memcpy( pNew, gv_XFlmSysData.ppvMemTrackingPtrs, - sizeof( void *) * gv_XFlmSysData.uiMemTrackingPtrArraySize); - os_free( gv_XFlmSysData.ppvMemTrackingPtrs); - gv_XFlmSysData.ppvMemTrackingPtrs = NULL; - } - f_memset( &pNew [gv_XFlmSysData.uiMemTrackingPtrArraySize], 0, - sizeof( void *) * (uiNewCnt - gv_XFlmSysData.uiMemTrackingPtrArraySize)); - gv_XFlmSysData.ppvMemTrackingPtrs = pNew; - gv_XFlmSysData.uiMemTrackingPtrArraySize = uiNewCnt; - } - } - - // If we are still full, we were not able to reallocate memory, so we - // do nothing. - - if (gv_XFlmSysData.uiMemNumPtrs == gv_XFlmSysData.uiMemTrackingPtrArraySize) - { - pHdr->uiAllocationId = 0; - } - else - { - // Find an empty slot - there has to be one! - - uiId = gv_XFlmSysData.uiMemNextPtrSlotToUse; - while (gv_XFlmSysData.ppvMemTrackingPtrs [uiId]) - { - if (++uiId == gv_XFlmSysData.uiMemTrackingPtrArraySize) - { - uiId = 0; - } - } - - // Allocation ID in the header is offset by one to avoid - // using a value of zero. - - pHdr->uiAllocationId = uiId + 1; - gv_XFlmSysData.ppvMemTrackingPtrs [uiId] = pHdr; - gv_XFlmSysData.uiMemNumPtrs++; - if ((gv_XFlmSysData.uiMemNextPtrSlotToUse = uiId + 1) == - gv_XFlmSysData.uiMemTrackingPtrArraySize) - { - gv_XFlmSysData.uiMemNextPtrSlotToUse = 0; - } - } - pHdr->uiAllocCnt = ++gv_XFlmSysData.uiAllocCnt; - f_mutexUnlock( gv_XFlmSysData.hMemTrackingMutex); - } - else - { - pHdr->uiAllocationId = 0; - pHdr->uiAllocCnt = 0; - } - - // Follow the stack. - - if (gv_XFlmSysData.bTrackLeaks && gv_XFlmSysData.bStackWalk) - { - pHdr->puiStack = memWalkStack(); - } - else - { - pHdr->puiStack = NULL; - } -} - -/******************************************************************** -Desc: Update memory tracking information - called after realloc -*********************************************************************/ -FSTATIC void updateMemTrackingInfo( - F_MEM_HDR * pHdr) -{ - if (pHdr->puiStack) - { - os_free( pHdr->puiStack); - pHdr->puiStack = NULL; - } - if (gv_XFlmSysData.bTrackLeaks && gv_XFlmSysData.bStackWalk) - { - pHdr->puiStack = memWalkStack(); - } -} - -/******************************************************************** -Desc: Free memory tracking information - called on free. -*********************************************************************/ -FSTATIC void freeMemTrackingInfo( - FLMBOOL bMutexAlreadyLocked, - FLMUINT uiId, - FLMUINT * puiStack - ) -{ - if (uiId) - { - // NOTE: If uiId is non-zero, it means we had to have - // successfully initialized, so we are guaranteed to - // have a mutex. - - if ( !bMutexAlreadyLocked) - { - f_mutexLock( gv_XFlmSysData.hMemTrackingMutex); - } - - // Allocation ID in the header is offset by one so that it - // is never zero - a value of zero means that the allocation - // does not have a slot for tracking it in the array. - - gv_XFlmSysData.ppvMemTrackingPtrs [uiId - 1] = NULL; - flmAssert( gv_XFlmSysData.uiMemNumPtrs); - gv_XFlmSysData.uiMemNumPtrs--; - - if ( !bMutexAlreadyLocked) - { - f_mutexUnlock( gv_XFlmSysData.hMemTrackingMutex); - } - } - - // Free the stack information, if any. - - if (puiStack) - { - os_free( puiStack); - } -} - -/******************************************************************** -Desc: Log memory leaks. -*********************************************************************/ -void logMemLeak( - F_MEM_HDR * pHdr) -{ - char szTmpBuffer [1024]; - FLMUINT uiMsgBufSize; - char * pszMessageBuffer; - char * pszTmp; - IF_FileHdl * pFileHdl = NULL; - F_FileSystem fileSys; - FLMBOOL bClearFileSys = FALSE; - FLMBOOL bSaveTrackLeaks = gv_XFlmSysData.bTrackLeaks; - - gv_XFlmSysData.bTrackLeaks = FALSE; - - // Need a big buffer to show an entire stack. - - uiMsgBufSize = 20480; - if ((pszMessageBuffer = (char *)os_malloc( uiMsgBufSize)) == NULL) - { - pszMessageBuffer = &szTmpBuffer [0]; - uiMsgBufSize = sizeof( szTmpBuffer); - } - pszTmp = pszMessageBuffer; - - if( !gv_pFileSystem) - { - gv_pFileSystem = &fileSys; - bClearFileSys = TRUE; - } - - // Format message to be logged. - - f_strcpy( pszTmp, "Abort=Debug, Retry=Continue, Ignore=Don't Show\r\n"); - while (*pszTmp) - { - pszTmp++; - } -#if defined( FLM_WIN) && defined( FLM_64BIT) - f_sprintf( pszTmp, "Unfreed Pointer: 0x%016I64x\r\n", (FLMUINT)(&pHdr [1])); -#else - f_sprintf( pszTmp, "Unfreed Pointer: 0x%08x\r\n", - (unsigned)((FLMUINT)(&pHdr [1]))); -#endif - while (*pszTmp) - { - pszTmp++; - } - - if (pHdr->pszFileName) - { - f_sprintf( pszTmp, "Source: %s, Line#: %u\r\n", pHdr->pszFileName, - (unsigned)pHdr->iLineNumber); - while (*pszTmp) - { - pszTmp++; - } - } - - if (pHdr->uiAllocCnt) - { - f_sprintf( pszTmp, "Malloc #: %u\r\n", (unsigned)pHdr->uiAllocCnt); - while (*pszTmp) - { - pszTmp++; - } - } - f_sprintf( (char *)pszTmp, "Size: %u bytes\r\n", (unsigned)pHdr->uiDataSize); - while (*pszTmp) - { - pszTmp++; - } - - if (pHdr->puiStack) - { - FLMUINT * puiStack = pHdr->puiStack; - FLMUINT uiLen = pszTmp - pszMessageBuffer; - char szFuncName [200]; - char * pszFuncName; -#ifdef FLM_WIN - IMAGEHLP_SYMBOL * pImgHlpSymbol; - - pImgHlpSymbol = (IMAGEHLP_SYMBOL *)os_malloc( - sizeof( IMAGEHLP_SYMBOL) + 100); -#endif - - while (*puiStack) - { - szFuncName [0] = 0; -#ifdef FLM_WIN - if (pImgHlpSymbol) - { - #ifdef FLM_64BIT - DWORD64 udDisplacement; - #else - DWORD udDisplacement; - #endif - - pImgHlpSymbol->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL); - pImgHlpSymbol->Address = *puiStack; - pImgHlpSymbol->MaxNameLength = 100; - - if (SymGetSymFromAddr( gv_XFlmSysData.hMemProcess, *puiStack, - &udDisplacement, pImgHlpSymbol)) - { - f_sprintf( szFuncName, "\t%s + %X\r\n", - (char *)(&pImgHlpSymbol->Name [0]), - udDisplacement); - } - } -#elif defined( FLM_NLM) - { - szFuncName [0] = '\t'; - GetClosestSymbol( (BYTE *)(&szFuncName[1]), (LONG)(*puiStack)); - } -#else - -#ifdef HAVE_DLADDR - { - Dl_info dlip; - - if (dladdr( (void *)(*puiStack), &dlip) != 0 && dlip.dli_sname) - { - const char * pszFileName; - if (dlip.dli_saddr != (void *)(*puiStack)) - { - pszFileName = strrchr(dlip.dli_fname, '/'); - if (!pszFileName) - { - pszFileName = dlip.dli_fname; - } - else - { - pszFileName++; // skip over slash - } - f_sprintf( szFuncName, "\t0x%08x (%s)\r\n", - (unsigned)(*puiStack), pszFileName); - } - else - { - f_sprintf( szFuncName, "\t%s\r\n", dlip.dli_sname); - } - } - } -#endif - -#endif - - // If szFuncName [0] is zero, we didn't find a name, so we - // just output the address in HEX. - - if (!szFuncName [0]) - { - f_sprintf( szFuncName, "\t0x%08X\r\n", (unsigned)*puiStack ); - } - - // Output whatever portion of the name will fit into the - // message buffer. - - pszFuncName = &szFuncName [0]; - while (*pszFuncName && uiLen < uiMsgBufSize - 1) - { - *pszTmp++ = *pszFuncName++; - uiLen++; - } - - // Process next address in the stack. - - puiStack++; - } - *pszTmp = 0; -#ifdef FLM_WIN - if (pImgHlpSymbol) - { - os_free( pImgHlpSymbol); - } -#endif - } - -#ifdef FLM_WIN - FLMINT iRet; - - iRet = MessageBox( NULL, (LPCTSTR)pszMessageBuffer, "WIN32 Memory Testing", - MB_ABORTRETRYIGNORE | MB_ICONINFORMATION | MB_TASKMODAL - | MB_SETFOREGROUND | MB_DEFBUTTON2); - if (iRet == IDIGNORE) - { - gv_XFlmSysData.bLogLeaks = TRUE; - } - else if (iRet == IDABORT) - { - flmAssert( 0); - } -#else - gv_XFlmSysData.bLogLeaks = TRUE; -#endif - - if (gv_XFlmSysData.bLogLeaks) - { - F_FileSystem FileSystem; - RCODE rc; - FLMUINT uiDummy; -#ifdef FLM_NLM - const char * pszErrPath = "sys:\\memtest.ert"; -#else - const char * pszErrPath = "memtest.ert"; -#endif - - if (RC_BAD( rc = FileSystem.Open( pszErrPath, XFLM_IO_RDWR | XFLM_IO_SH_DENYNONE, - &pFileHdl))) - { - if (rc == NE_XFLM_IO_PATH_NOT_FOUND) - { - rc = FileSystem.Create( pszErrPath, XFLM_IO_RDWR | XFLM_IO_SH_DENYNONE, - &pFileHdl); - } - } - else - { - // Position to append to file. - - rc = pFileHdl->Seek( 0, XFLM_IO_SEEK_END, NULL); - } - - // If we successfully opened the file, write to it. - - if (RC_OK( rc)) - { - if (RC_OK( pFileHdl->Write( XFLM_IO_CURRENT_POS, - (FLMUINT)(pszTmp - pszMessageBuffer), - pszMessageBuffer, &uiDummy))) - { - (void)pFileHdl->Flush(); - } - pFileHdl->Close(); - } - } -//Exit: - if (pFileHdl) - { - pFileHdl->Release(); - } - - if( bClearFileSys) - { - gv_pFileSystem = NULL; - } - if (pszMessageBuffer != &szTmpBuffer [0]) - { - os_free( pszMessageBuffer); - } - - gv_XFlmSysData.bTrackLeaks = bSaveTrackLeaks; -} -#endif - -/******************************************************************** -Desc: Initialize memory - if not already done. -*********************************************************************/ -void f_memoryInit( void) -{ -#ifdef FLM_DEBUG - (void)initMemTracking(); -#endif -} - -/******************************************************************** -Desc: Clean up memory and check for unfreed memory. -*********************************************************************/ -void f_memoryCleanup( void) -{ - -#ifdef FLM_DEBUG - if (initMemTracking()) - { - FLMUINT uiId; - F_MEM_HDR * pHdr; - - f_mutexLock( gv_XFlmSysData.hMemTrackingMutex); - for (uiId = 0; uiId < gv_XFlmSysData.uiMemTrackingPtrArraySize; uiId++) - { - if ((pHdr = (F_MEM_HDR *)gv_XFlmSysData.ppvMemTrackingPtrs [uiId]) != NULL) - { - logMemLeak( pHdr); - freeMemTrackingInfo( TRUE, uiId + 1, pHdr->puiStack); - } - } - - // Free the memory pointer array. - - os_free( gv_XFlmSysData.ppvMemTrackingPtrs); - gv_XFlmSysData.ppvMemTrackingPtrs = NULL; - gv_XFlmSysData.uiMemTrackingPtrArraySize = 0; - gv_XFlmSysData.uiMemNumPtrs = 0; - - f_mutexUnlock( gv_XFlmSysData.hMemTrackingMutex); - - // Free up the mutex. - - f_mutexDestroy( &gv_XFlmSysData.hMemTrackingMutex); - - // Reset to unitialized state. - - gv_XFlmSysData.uiInitThreadId = 0; - gv_XFlmSysData.hMemTrackingMutex = F_MUTEX_NULL; - gv_XFlmSysData.bMemTrackingInitialized = FALSE; -#ifdef FLM_WIN - SymCleanup( gv_XFlmSysData.hMemProcess); -#endif - } -#endif -} - -/******************************************************************** -Desc: Allocate Memory. -*********************************************************************/ -#ifdef FLM_DEBUG -RCODE f_allocImp( - FLMUINT uiSize, - void ** ppvPtr, - FLMBOOL bAllocFromNewOp, - const char * pszFileName, - FLMINT iLineNumber - ) -#else -RCODE f_allocImp( - FLMUINT uiSize, - void ** ppvPtr - ) -#endif -{ - RCODE rc = NE_XFLM_OK; - F_MEM_HDR * pHdr; - -#ifdef DEBUG_SIM_OUT_OF_MEM - if ( SimulateOutOfMemory()) - { - *ppvPtr = NULL; - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } -#endif - - if ((pHdr = (F_MEM_HDR *)os_malloc( uiSize + - sizeof( F_MEM_HDR) + - F_PICKET_FENCE_SIZE)) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - pHdr->uiDataSize = uiSize; - *ppvPtr = (void *)(&pHdr [1]); -#ifdef FLM_DEBUG - pHdr->bAllocFromNewOp = bAllocFromNewOp; - pHdr->iLineNumber = iLineNumber; - pHdr->pszFileName = pszFileName; - saveMemTrackingInfo( pHdr); - - #if F_PICKET_FENCE_SIZE - - f_memcpy( ((FLMBYTE *)(*ppvPtr)) + uiSize, - F_PICKET_FENCE, F_PICKET_FENCE_SIZE); - - #endif - -#endif -Exit: - return( rc); -} - -/******************************************************************** -Desc: Allocate and initialize memory. -*********************************************************************/ -#ifdef FLM_DEBUG -RCODE f_callocImp( - FLMUINT uiSize, - void ** ppvPtr, - const char * pszFileName, - FLMINT iLineNumber - ) -#else -RCODE f_callocImp( - FLMUINT uiSize, - void ** ppvPtr - ) -#endif -{ - RCODE rc = NE_XFLM_OK; - F_MEM_HDR * pHdr; - -#ifdef DEBUG_SIM_OUT_OF_MEM - if ( SimulateOutOfMemory()) - { - *ppvPtr = NULL; - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } -#endif - - if ((pHdr = (F_MEM_HDR *)os_malloc( uiSize + - sizeof( F_MEM_HDR) + - F_PICKET_FENCE_SIZE)) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - pHdr->uiDataSize = uiSize; - *ppvPtr = (void *)(&pHdr [1]); - f_memset( *ppvPtr, 0, uiSize); -#ifdef FLM_DEBUG - pHdr->bAllocFromNewOp = FALSE; - pHdr->iLineNumber = iLineNumber; - pHdr->pszFileName = pszFileName; - saveMemTrackingInfo( pHdr); - - #if F_PICKET_FENCE_SIZE - - f_memcpy( ((FLMBYTE *)(*ppvPtr)) + uiSize, - F_PICKET_FENCE, F_PICKET_FENCE_SIZE); - - #endif - -#endif -Exit: - return( rc); -} - -/******************************************************************** -Desc: Reallocate memory. -*********************************************************************/ -#ifdef FLM_DEBUG -RCODE f_reallocImp( - FLMUINT uiSize, - void ** ppvPtr, - const char * pszFileName, - FLMINT iLineNumber - ) -#else -RCODE f_reallocImp( - FLMUINT uiSize, - void ** ppvPtr - ) -#endif -{ - RCODE rc = NE_XFLM_OK; - F_MEM_HDR * pNewHdr; -#ifdef FLM_DEBUG - F_MEM_HDR * pOldHdr; - FLMUINT uiOldAllocationId; - FLMUINT * puiOldStack; -#endif - -#ifdef DEBUG_SIM_OUT_OF_MEM - if ( SimulateOutOfMemory()) - { - *ppvPtr = NULL; - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } -#endif - - if (!(*ppvPtr)) - { -#ifdef FLM_DEBUG - rc = f_allocImp( uiSize, ppvPtr, FALSE, pszFileName, iLineNumber); -#else - rc = f_allocImp( uiSize, ppvPtr); -#endif - goto Exit; - } - -#ifdef FLM_DEBUG - pOldHdr = (F_MEM_HDR *)F_GET_ALLOC_PTR( *ppvPtr); - - #if F_PICKET_FENCE_SIZE - - // Verify the old picket fence - - if (f_memcmp( ((FLMBYTE *)(*ppvPtr)) + pOldHdr->uiDataSize, - F_PICKET_FENCE, F_PICKET_FENCE_SIZE) != 0) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_MEM); - goto Exit; - } - - #endif - - // Cannot realloc memory that was allocated via a new operator - - if (pOldHdr->bAllocFromNewOp) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_MEM); - goto Exit; - } - - uiOldAllocationId = pOldHdr->uiAllocationId; - puiOldStack = pOldHdr->puiStack; -#endif - - if ((pNewHdr = (F_MEM_HDR *)os_realloc( F_GET_ALLOC_PTR( *ppvPtr), - uiSize + sizeof( F_MEM_HDR) + - F_PICKET_FENCE_SIZE)) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - pNewHdr->uiDataSize = uiSize; - *ppvPtr = (void *)(&pNewHdr [1]); -#ifdef FLM_DEBUG - pNewHdr->bAllocFromNewOp = FALSE; - pNewHdr->iLineNumber = iLineNumber; - pNewHdr->pszFileName = pszFileName; - if (pNewHdr != pOldHdr) - { - freeMemTrackingInfo( FALSE, uiOldAllocationId, puiOldStack); - saveMemTrackingInfo( pNewHdr); - } - else - { - updateMemTrackingInfo( pNewHdr); - } - - #if F_PICKET_FENCE_SIZE - - f_memcpy( ((FLMBYTE *)(*ppvPtr)) + uiSize, - F_PICKET_FENCE, F_PICKET_FENCE_SIZE); - - #endif - -#endif - -Exit: - return( rc); -} - -/******************************************************************** -Desc: Reallocate memory, and initialize the new part. -*********************************************************************/ -#ifdef FLM_DEBUG -RCODE f_recallocImp( - FLMUINT uiSize, - void ** ppvPtr, - const char * pszFileName, - FLMINT iLineNumber - ) -#else -RCODE f_recallocImp( - FLMUINT uiSize, - void ** ppvPtr - ) -#endif -{ - RCODE rc = NE_XFLM_OK; - F_MEM_HDR * pNewHdr; - FLMUINT uiOldSize; -#ifdef FLM_DEBUG - F_MEM_HDR * pOldHdr; - FLMUINT uiOldAllocationId; - FLMUINT * puiOldStack; -#endif - -#ifdef DEBUG_SIM_OUT_OF_MEM - if ( SimulateOutOfMemory()) - { - *ppvPtr = NULL; - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } -#endif - - if (!(*ppvPtr)) - { -#ifdef FLM_DEBUG - rc = f_callocImp( uiSize, ppvPtr, pszFileName, iLineNumber); -#else - rc = f_callocImp( uiSize, ppvPtr); -#endif - goto Exit; - } - -#ifdef FLM_DEBUG - pOldHdr = (F_MEM_HDR *)F_GET_ALLOC_PTR( *ppvPtr); - - #if F_PICKET_FENCE_SIZE - - // Verify the old picket fence - - if (f_memcmp( ((FLMBYTE *)(*ppvPtr)) + pOldHdr->uiDataSize, - F_PICKET_FENCE, F_PICKET_FENCE_SIZE) != 0) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_MEM); - goto Exit; - } - - #endif - - // Cannot realloc memory that was allocated via a new operator - - if (pOldHdr->bAllocFromNewOp) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_MEM); - goto Exit; - } - - uiOldAllocationId = pOldHdr->uiAllocationId; - puiOldStack = pOldHdr->puiStack; - -#endif - - uiOldSize = F_GET_MEM_DATA_SIZE( *ppvPtr); - if ((pNewHdr = (F_MEM_HDR *)os_realloc( F_GET_ALLOC_PTR( *ppvPtr), - uiSize + sizeof( F_MEM_HDR) + - F_PICKET_FENCE_SIZE)) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - pNewHdr->uiDataSize = uiSize; - *ppvPtr = (void *)(&pNewHdr [1]); - if (uiOldSize < uiSize) - { - f_memset( ((FLMBYTE *)(*ppvPtr)) + uiOldSize, 0, - uiSize - uiOldSize); - } -#ifdef FLM_DEBUG - pNewHdr->bAllocFromNewOp = FALSE; - pNewHdr->iLineNumber = iLineNumber; - pNewHdr->pszFileName = pszFileName; - if (pNewHdr != pOldHdr) - { - freeMemTrackingInfo( FALSE, uiOldAllocationId, puiOldStack); - saveMemTrackingInfo( pNewHdr); - } - else - { - updateMemTrackingInfo( pNewHdr); - } - - #if F_PICKET_FENCE_SIZE - - f_memcpy( ((FLMBYTE *)(*ppvPtr)) + uiSize, - F_PICKET_FENCE, F_PICKET_FENCE_SIZE); - - #endif - -#endif -Exit: - return( rc); -} - -/******************************************************************** -Desc: Free previously allocated memory. -*********************************************************************/ -void f_freeImp( - void ** ppvPtr, - FLMBOOL bFreeFromDeleteOp) -{ -#ifndef FLM_DEBUG - F_UNREFERENCED_PARM( bFreeFromDeleteOp); -#endif - - if (*ppvPtr) - { -#ifdef FLM_DEBUG - - F_MEM_HDR * pHdr = (F_MEM_HDR *)F_GET_ALLOC_PTR( *ppvPtr); - - if (pHdr->bAllocFromNewOp && !bFreeFromDeleteOp || - !pHdr->bAllocFromNewOp && bFreeFromDeleteOp) - { - - // Either trying to free memory using f_free when - // allocated from new, or trying to free memory - // using delete when allocated from f_alloc, - // f_calloc, f_realloc, or f_recalloc. - - RC_UNEXPECTED_ASSERT( NE_XFLM_MEM); - return; - } - - #if F_PICKET_FENCE_SIZE - - // Check the picket fence - - if (f_memcmp( ((FLMBYTE *)(*ppvPtr)) + pHdr->uiDataSize, - F_PICKET_FENCE, F_PICKET_FENCE_SIZE) != 0) - { - RC_UNEXPECTED_ASSERT( NE_XFLM_MEM); - } - - #endif - - freeMemTrackingInfo( FALSE, pHdr->uiAllocationId, pHdr->puiStack); -#endif - os_free( F_GET_ALLOC_PTR( *ppvPtr)); - *ppvPtr = NULL; - } -} - -#ifdef FLM_DEBUG -/******************************************************************** -Desc: Reset the stack information for an allocation. -*********************************************************************/ -void f_resetStackInfoImp( - void * pvPtr, - const char * pszFileName, - FLMINT iLineNumber - ) -{ - if (pvPtr) - { - - F_MEM_HDR * pHdr = (F_MEM_HDR *)F_GET_ALLOC_PTR( pvPtr); - - pHdr->iLineNumber = iLineNumber; - pHdr->pszFileName = pszFileName; - f_mutexLock( gv_XFlmSysData.hMemTrackingMutex); - pHdr->uiAllocCnt = ++gv_XFlmSysData.uiAllocCnt; - f_mutexUnlock( gv_XFlmSysData.hMemTrackingMutex); - updateMemTrackingInfo( pHdr); - } -} -#endif - - -/************************************************************************ -Desc: Destructor -*************************************************************************/ -F_Pool::~F_Pool() -{ - poolFree(); -} - -/************************************************************************ -Desc: Initialize a smart pool memory structure. A smart pool is one that - will adjust it's block allocation size based on statistics it - gathers within the POOL_STATS structure. For each pool that user - wants to use smart memory management a global POOL_STATS structure - should be declared. The POOL_STATS structure is used to track the - total bytes allocated and determine what the correct pool block - size should be. -*************************************************************************/ -void F_Pool::smartPoolInit( - POOL_STATS * pPoolStats) -{ - m_pPoolStats = pPoolStats; - if (m_pPoolStats && m_pPoolStats->uiCount) - { - setInitialSmartPoolBlkSize(); - } - else - { - m_uiBlockSize = 2048; - } -} - -/**************************************************************************** -Desc: Allocates a block of memory from a memory pool. -Note: If the number of bytes is more than the what is left in the - current block then a new block will be allocated and the lbkl element - of the PMS will be updated. -****************************************************************************/ -RCODE F_Pool::poolAlloc( - FLMUINT uiSize, - void ** ppvPtr - ) -{ - RCODE rc = NE_XFLM_OK; - MBLK * pBlock = m_pLastBlock; - MBLK * pOldLastBlock = pBlock; - FLMBYTE * pucFreePtr; - FLMUINT uiBlockSize; - - // Adjust the size to a machine word boundary - // NOTE: ORed and ANDed 0x800.. & 0x7FFF to prevent partial - // stalls on Netware - - if (uiSize & (FLM_ALLOC_ALIGN | 0x80000000)) - { - uiSize = ((uiSize + FLM_ALLOC_ALIGN) & (~(FLM_ALLOC_ALIGN) & 0x7FFFFFFF)); - } - - // Check if room in block - - if (!pBlock || uiSize > pBlock->uiFreeSize) - { - - // Check if previous block has space for allocation - - if (pBlock && - pBlock->pPrevBlock && - uiSize <= pBlock->pPrevBlock->uiFreeSize) - { - pBlock = pBlock->pPrevBlock; - goto Exit; - } - - // Not enough memory in block - allocate new block - - // Determine the block size: - // 1) start with max of last block size, initial pool size, or alloc size - // 2) if this is an extra block alloc then increase the size by 1/2 - // 3) adjust size to include block header - - uiBlockSize = (pBlock) ? pBlock->uiBlockSize : m_uiBlockSize; - uiBlockSize = f_max( uiSize, uiBlockSize); - - if (pBlock && - uiBlockSize == pBlock->uiBlockSize && - uiBlockSize <= 32769) - { - uiBlockSize += uiBlockSize / 2; - } - - // Add in extra bytes for block overhead - - uiBlockSize += sizeof( MBLK); - - if (RC_BAD( rc = f_alloc( uiBlockSize, &pBlock))) - { - goto Exit; - } - - // Initialize the block elements - - pBlock->uiBlockSize = uiBlockSize; - pBlock->uiFreeOffset = sizeof( MBLK); - pBlock->uiFreeSize = uiBlockSize - sizeof( MBLK); - - // Link in newly allocated block - - m_pLastBlock = pBlock; - pBlock->pPrevBlock = pOldLastBlock; - } - -Exit: - - if (RC_OK( rc)) - { - pucFreePtr = (FLMBYTE *)pBlock; - pucFreePtr += pBlock->uiFreeOffset; // Point to free space - pBlock->uiFreeOffset += uiSize; // Modify free offset - pBlock->uiFreeSize -= uiSize; // Modify free size - - m_uiBytesAllocated += uiSize; - *ppvPtr = (void *)pucFreePtr; - } - else - { - *ppvPtr = NULL; - } - return( rc); -} - -/**************************************************************************** -Desc: Allocates a block of memory from a memory pool. -****************************************************************************/ -RCODE F_Pool::poolCalloc( - FLMUINT uiSize, - void ** ppvPtr) -{ - RCODE rc; - - if (RC_OK( rc = poolAlloc( uiSize, ppvPtr))) - { - f_memset( *ppvPtr, 0, uiSize); - } - return( rc); -} - -/**************************************************************************** -Desc : Releases all memory allocated to a pool. -Note : All memory allocated to the pool is returned to the operating system. -*****************************************************************************/ -void F_Pool::poolFree( void) -{ - MBLK * pBlock = m_pLastBlock; - MBLK * pPrevBlock; - - // Free all blocks in chain - - while (pBlock) - { - pPrevBlock = pBlock->pPrevBlock; - f_free( &pBlock); - pBlock = pPrevBlock; - } - - m_pLastBlock = NULL; - - // For Smart Pools update pool statictics - - if (m_pPoolStats) - { - updateSmartPoolStats(); - } -} - -/**************************************************************************** -Desc: Resets memory blocks allocated to a pool. -Note: Will reset the free space in the first memory block, and if - any extra blocks exist they will be freed (destroyed). -*****************************************************************************/ -void F_Pool::poolReset( - void * pvMark, - // [IN] If pvMark is NULL, the first pool block is emptied and all - // other blocks in the list are released to the operating system. - // If pvMark is non-NULL, the pool list is searched for the block - // containing pvMark. All pool blocks following pvMark are - // released and the block containing pvMark is is reset to - // the byte referenced by pvMark. - FLMBOOL bReduceFirstBlock - ) -{ - MBLK * pBlock = m_pLastBlock; - MBLK * pPrevBlock; - - if (!pBlock) - { - return; - } - - // For Smart Pools update pool statictics - - if (m_pPoolStats) - { - updateSmartPoolStats(); - } - - if (pvMark) - { - freeToMark( pvMark); - return; - } - - // Free all blocks except last one in chain -- which is really - // the first block allocated. This will help us keep memory from - // getting fragmented. - - while (pBlock->pPrevBlock) - { - pPrevBlock = pBlock->pPrevBlock; - f_free( &pBlock); - pBlock = pPrevBlock; - } - - if (pBlock->uiBlockSize - sizeof(MBLK) > m_uiBlockSize && bReduceFirstBlock) - { - - // The first block was not the default size, so free it - - f_free( &pBlock); - m_pLastBlock = NULL; - } - else - { - - // Reset the allocation pointers in the first block - - pBlock->uiFreeOffset = sizeof( MBLK); - pBlock->uiFreeSize = pBlock->uiBlockSize - sizeof( MBLK); - m_pLastBlock = pBlock; - -#ifdef FLM_MEM_CHK - { - /* memset the reset memory so someone pointing to it will get a error. */ - FLMBYTE * pucPtr = (FLMBYTE *) pBlock; - pucPtr += pBlock->uiFreeOffset; - f_memset( pucPtr, 'r', pBlock->uiFreeSize); // Set memory to 'r' for Reset - } -#endif - } - - // on smart pools adjust the initial block size on pool resets - - if (m_pPoolStats) - { - setInitialSmartPoolBlkSize(); - } -} - -/**************************************************************************** -Desc: Frees memory until the pvMark is found. -****************************************************************************/ -void F_Pool::freeToMark( - void * pvMark) // free until pvMark found -{ - MBLK * pBlock = m_pLastBlock; - MBLK * pPrevBlock; - - // Initialize pool to no blocks - - m_pLastBlock = NULL; - while (pBlock) - { - pPrevBlock = pBlock->pPrevBlock; - - // Check for mark point - - if (PTR_IN_MBLK( pvMark, pBlock, pBlock->uiBlockSize)) - { - FLMUINT uiOldFreeOffset = pBlock->uiFreeOffset; - - // Reset uiFreeOffset and uiFreeSize variables - - pBlock->uiFreeOffset = (FLMUINT)((FLMBYTE *)pvMark - - (FLMBYTE *)pBlock); - pBlock->uiFreeSize = pBlock->uiBlockSize - pBlock->uiFreeOffset; - -#if defined( FLM_MEM_CHK) || defined( MEM_TEST) - { - // memset the memory so someone pointing to it will get a error. - FLMBYTE * pucPtr = (FLMBYTE *)pBlock; - pucPtr += pBlock->uiFreeOffset; - f_memset( pucPtr, 'r', pBlock->uiFreeSize); // Set memory to 'r' for Reset - } -#endif - - // For Smart Pools deduct the bytes allocated since pool mark - - if (m_pPoolStats) - { - flmAssert( uiOldFreeOffset >= pBlock->uiFreeOffset); - m_uiBytesAllocated -= (uiOldFreeOffset - pBlock->uiFreeOffset); - } - - break; - } - - if (m_pPoolStats) - { - m_uiBytesAllocated -= (pBlock->uiFreeOffset - sizeof( MBLK)); - } - - f_free( &pBlock); - pBlock = pPrevBlock; - } - - if (pBlock) - { - m_pLastBlock = pBlock; - } -} - -#undef new -#undef delete -/**************************************************************************** -Desc: -****************************************************************************/ -void * XF_Base::operator new( - FLMSIZET uiSize) -{ - void * pvReturnPtr = NULL; - - // NOTICE: You should be using f_new so that we can track memory leaks - - RC_UNEXPECTED_ASSERT( NE_XFLM_MEM); - -#ifdef FLM_DEBUG - f_allocImp( uiSize, &pvReturnPtr, TRUE, "unknown", 0); -#else - f_allocImp( uiSize, &pvReturnPtr); -#endif - - return( pvReturnPtr); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void * XF_Base::operator new[]( - FLMSIZET uiSize) -{ - void * pvReturnPtr = NULL; - - // NOTICE: You should be using f_new[] so that we can track memory leaks - -#ifdef FLM_DEBUG - f_allocImp( uiSize, &pvReturnPtr, TRUE, "unknown", 0); -#else - f_allocImp( uiSize, &pvReturnPtr); -#endif - - return( pvReturnPtr); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -#ifdef FLM_DEBUG -void * XF_Base::operator new( - FLMSIZET uiSize, - const char * pszFile, - int iLine) -{ - void * pvReturnPtr = NULL; - - f_allocImp( uiSize, &pvReturnPtr, TRUE, pszFile, iLine); - - return( pvReturnPtr); -} -#endif - -/**************************************************************************** -Desc: -****************************************************************************/ -#ifdef FLM_DEBUG -void * XF_Base::operator new[]( - FLMSIZET uiSize, - const char * pszFile, - int iLine) -{ - void * pvReturnPtr = NULL; - - f_allocImp( uiSize, &pvReturnPtr, TRUE, pszFile, iLine); - - return( pvReturnPtr); -} -#endif - -/**************************************************************************** -Desc: -****************************************************************************/ -void XF_Base::operator delete( - void * ptr) -{ - if( !ptr) - { - return; - } - f_freeImp( &ptr, TRUE); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void XF_Base::operator delete[]( - void * ptr) -{ - if( !ptr) - { - return; - } - f_freeImp( &ptr, TRUE); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -#if defined( FLM_DEBUG) && !defined( FLM_WATCOM_NLM) && !defined( FLM_SOLARIS) -void XF_Base::operator delete( - void * ptr, - const char *, // file - int) // line -{ - if( !ptr) - { - return; - } - - f_freeImp( &ptr, TRUE); -} -#endif - -/**************************************************************************** -Desc: -****************************************************************************/ -#if defined( FLM_DEBUG) && !defined( FLM_WATCOM_NLM) && !defined( FLM_SOLARIS) -void XF_Base::operator delete[]( - void * ptr, - const char *, // file - int) // line -{ - if( !ptr) - { - return; - } - - f_freeImp( &ptr, TRUE); -} -#endif - -/************************************************************************ -Desc: -*************************************************************************/ -void * F_OSBase::operator new( - FLMSIZET uiSize) -{ - return( os_malloc( uiSize)); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -#ifdef FLM_DEBUG -void * F_OSBase::operator new( - FLMSIZET uiSize, - const char *, // pszFile, - int) // iLine) -{ - return( os_malloc( uiSize)); -} -#endif - -/************************************************************************ -Desc: -*************************************************************************/ -void F_OSBase::operator delete( - void * ptr) -{ - os_free( ptr); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void F_OSBase::operator delete[]( - void * ptr) -{ - os_free( &ptr); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -#if defined( FLM_DEBUG) && !defined( FLM_WATCOM_NLM) && !defined( FLM_SOLARIS) -void F_OSBase::operator delete( - void * ptr, - const char *, // file - int) // line -{ - os_free( &ptr); -} -#endif - -/**************************************************************************** -Desc: -****************************************************************************/ -#if defined( FLM_DEBUG) && !defined( FLM_WATCOM_NLM) && !defined( FLM_SOLARIS) -void F_OSBase::operator delete[]( - void * ptr, - const char *, // file - int) // line -{ - os_free( &ptr); -} -#endif diff --git a/xflaim/src/flbackup.cpp b/xflaim/src/flbackup.cpp index 3ef9a84..0bd496d 100644 --- a/xflaim/src/flbackup.cpp +++ b/xflaim/src/flbackup.cpp @@ -35,7 +35,7 @@ typedef struct // Local classes -class F_BackerStream : public XF_RefCount, public XF_Base +class F_BackerStream : public F_Object { public: @@ -87,10 +87,10 @@ private: RCODE _setup( void); static RCODE readThread( - F_Thread * pThread); + IF_Thread * pThread); static RCODE writeThread( - F_Thread * pThread); + IF_Thread * pThread); // Data @@ -102,7 +102,7 @@ private: IF_RestoreClient * m_pRestoreObj; F_SEM m_hDataSem; F_SEM m_hIdleSem; - F_Thread * m_pThread; + IF_Thread * m_pThread; RCODE m_rc; FLMBYTE * m_pucInBuf; FLMUINT * m_puiInOffset; @@ -117,7 +117,7 @@ private: // Constants #define FLM_BACKER_SIGNATURE_OFFSET 0 -#define FLM_BACKER_SIGNATURE ((FLMBYTE *) "!DB_BACKUP_FILE!") +#define FLM_BACKER_SIGNATURE "!DB_BACKUP_FILE!" #define FLM_BACKER_SIGNATURE_SIZE 16 #define FLM_BACKER_VERSION_OFFSET 16 #define FLM_BACKER_VERSION_5_0_0 500 @@ -426,6 +426,10 @@ RCODE F_Backup::backup( *puiIncSeqNum = 0; } + // Setup the status callback info + + f_memset( &backupInfo, 0, sizeof( DB_BACKUP_INFO)); + // Make sure a backup attempt has not been made with this // backup handle. @@ -496,10 +500,6 @@ RCODE F_Backup::backup( goto Exit; } - // Setup the status callback info - - f_memset( &backupInfo, 0, sizeof( DB_BACKUP_INFO)); - // Setup the backup file header uiBlkBufOffset = 0; @@ -1073,7 +1073,8 @@ RCODE F_DbSystem::dbRestore( // Create the control file and set up the super file object - if( RC_BAD( rc = gv_pFileSystem->Create( pszDbPath, XFLM_IO_RDWR, &pFileHdl))) + if( RC_BAD( rc = gv_XFlmSysData.pFileSystem->createFile( + pszDbPath, FLM_IO_RDWR, &pFileHdl))) { goto Exit; } @@ -1087,8 +1088,7 @@ RCODE F_DbSystem::dbRestore( goto Exit; } - if( RC_BAD( rc = pSFile->Setup( - pDatabase->m_pFileIdList, pszDbPath, pszDataDir))) + if( RC_BAD( rc = pSFile->setup( pszDbPath, pszDataDir))) { goto Exit; } @@ -1135,7 +1135,7 @@ RCODE F_DbSystem::dbRestore( uiCurrentIncNum = uiNextIncNum; if( RC_BAD( rc = pRestoreObj->openIncFile( uiCurrentIncNum))) { - if( rc == NE_XFLM_IO_PATH_NOT_FOUND) + if( rc == NE_FLM_IO_PATH_NOT_FOUND) { rc = NE_XFLM_OK; break; @@ -1215,7 +1215,7 @@ RCODE F_DbSystem::dbRestore( // Force everything out to disk - if( RC_BAD( rc = pSFile->Flush())) + if( RC_BAD( rc = pSFile->flush())) { goto Exit; } @@ -1412,14 +1412,14 @@ FSTATIC RCODE flmRestoreFile( // Get the path of the .DB file (file 0). - if( RC_BAD( rc = pSFile->GetFilePath( 0, szPath))) + if( RC_BAD( rc = pSFile->getFilePath( 0, szPath))) { goto Exit; } // Get the sector size - if( RC_BAD( rc = gv_pFileSystem->GetSectorSize( + if( RC_BAD( rc = gv_XFlmSysData.pFileSystem->getSectorSize( szPath, &uiSectorSize))) { goto Exit; @@ -1433,20 +1433,11 @@ FSTATIC RCODE flmRestoreFile( { uiBlkBufSize = (((uiBlkBufSize / uiSectorSize) + 1) * uiSectorSize); } - -#ifdef FLM_WIN - if ((pucBlkBuf = (FLMBYTE *)VirtualAlloc( NULL, - (DWORD)uiBlkBufSize, MEM_COMMIT, PAGE_READWRITE)) == NULL) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_MEM); - goto Exit; - } -#else - if (RC_BAD( rc = f_alloc( uiBlkBufSize, &pucBlkBuf))) + + if( RC_BAD( rc = f_allocAlignedBuffer( uiBlkBufSize, (void **)&pucBlkBuf))) { goto Exit; } -#endif // Read and verify the backup header @@ -1462,7 +1453,7 @@ FSTATIC RCODE flmRestoreFile( goto Exit; } - if( f_strncmp( &pucBlkBuf[ FLM_BACKER_SIGNATURE_OFFSET], + if( f_strncmp( (const char *)&pucBlkBuf[ FLM_BACKER_SIGNATURE_OFFSET], FLM_BACKER_SIGNATURE, FLM_BACKER_SIGNATURE_SIZE) != 0) { rc = RC_SET( NE_XFLM_UNSUPPORTED_VERSION); @@ -1586,7 +1577,7 @@ FSTATIC RCODE flmRestoreFile( if( !bIncremental) { - pSFile->SetBlockSize( uiBlockSize); + pSFile->setBlockSize( uiBlockSize); } // Make sure the maximum block file size matches what was read from the @@ -1634,7 +1625,7 @@ FSTATIC RCODE flmRestoreFile( // Compare the incremental backup sequence number to the value in the // database's DB header. - if( RC_BAD( rc = pSFile->ReadHeader( 0, sizeof( XFLM_DB_HDR), + if( RC_BAD( rc = pSFile->readHeader( 0, sizeof( XFLM_DB_HDR), &dbHdr, &uiTmp))) { goto Exit; @@ -1696,7 +1687,7 @@ FSTATIC RCODE flmRestoreFile( // Write the database header - if( RC_BAD( rc = pSFile->WriteHeader( 0, + if( RC_BAD( rc = pSFile->writeHeader( 0, uiBlockSize, pucBlkBuf, &uiBytesWritten))) { goto Exit; @@ -1780,17 +1771,17 @@ FSTATIC RCODE flmRestoreFile( // block buffer is less than a full sector, the Unix SectorWrite will only // write out the amount requested, not a full sector. - if( RC_BAD( rc = pSFile->WriteBlock( uiBlkAddr, + if( RC_BAD( rc = pSFile->writeBlock( uiBlkAddr, uiBlockSize, pucBlkBuf, uiBlockSize, NULL, &uiBytesWritten))) #else - if( RC_BAD( rc = pSFile->WriteBlock( uiBlkAddr, + if( RC_BAD( rc = pSFile->writeBlock( uiBlkAddr, uiBlockSize, pucBlkBuf, uiBlkBufSize, NULL, &uiBytesWritten))) #endif { - if( rc == NE_XFLM_IO_PATH_NOT_FOUND || - rc == NE_XFLM_IO_INVALID_FILENAME) + if( rc == NE_FLM_IO_PATH_NOT_FOUND || + rc == NE_FLM_IO_INVALID_FILENAME) { // Create a new block file @@ -1800,18 +1791,17 @@ FSTATIC RCODE flmRestoreFile( goto Exit; } - if( RC_BAD( rc = pSFile->CreateFile( - FSGetFileNumber( uiBlkAddr)))) + if( RC_BAD( rc = pSFile->createFile( FSGetFileNumber( uiBlkAddr)))) { goto Exit; } #ifdef FLM_UNIX - if( RC_BAD( rc = pSFile->WriteBlock( uiBlkAddr, + if( RC_BAD( rc = pSFile->writeBlock( uiBlkAddr, uiBlockSize, pucBlkBuf, uiBlockSize, NULL, &uiBytesWritten))) #else - if( RC_BAD( rc = pSFile->WriteBlock( uiBlkAddr, + if( RC_BAD( rc = pSFile->writeBlock( uiBlkAddr, uiBlockSize, pucBlkBuf, uiBlkBufSize, NULL, &uiBytesWritten))) #endif @@ -1869,11 +1859,7 @@ Exit: if( pucBlkBuf) { -#ifdef FLM_WIN - (void)VirtualFree( pucBlkBuf, 0, MEM_RELEASE); -#else - f_free( &pucBlkBuf); -#endif + f_freeAlignedBuffer( (void **)&pucBlkBuf); } if( pBackerStream) @@ -1890,7 +1876,7 @@ Desc: Constructor F_DefaultBackupClient::F_DefaultBackupClient( const char * pszBackupPath) { - m_pFileHdl64 = NULL; + m_pMultiFileHdl = NULL; m_ui64Offset = 0; m_rc = NE_XFLM_OK; @@ -1902,10 +1888,10 @@ Desc: Destructor ****************************************************************************/ F_DefaultBackupClient::~F_DefaultBackupClient() { - if (m_pFileHdl64) + if (m_pMultiFileHdl) { - m_pFileHdl64->Close(); - m_pFileHdl64->Release(); + m_pMultiFileHdl->close(); + m_pMultiFileHdl->Release(); } } @@ -1925,34 +1911,33 @@ RCODE F_DefaultBackupClient::WriteData( goto Exit; } - if( m_pFileHdl64 == 0) + if( m_pMultiFileHdl == 0) { // Remove any existing backup files - - if( (m_pFileHdl64 = f_new F_64BitFileHandle) == NULL) + + if( RC_BAD( rc = FlmAllocMultiFileHdl( &m_pMultiFileHdl))) { - rc = RC_SET( NE_XFLM_MEM); goto Exit; } - if( RC_BAD( rc = m_pFileHdl64->Delete( m_szPath)) && - rc != NE_XFLM_IO_PATH_NOT_FOUND && - rc != NE_XFLM_IO_INVALID_FILENAME) + if( RC_BAD( rc = m_pMultiFileHdl->deleteMultiFile( m_szPath)) && + rc != NE_FLM_IO_PATH_NOT_FOUND && + rc != NE_FLM_IO_INVALID_FILENAME) { - m_pFileHdl64->Release(); - m_pFileHdl64 = NULL; + m_pMultiFileHdl->Release(); + m_pMultiFileHdl = NULL; goto Exit; } - if( RC_BAD( rc = m_pFileHdl64->Create( m_szPath))) + if( RC_BAD( rc = m_pMultiFileHdl->create( m_szPath))) { - m_pFileHdl64->Release(); - m_pFileHdl64 = NULL; + m_pMultiFileHdl->Release(); + m_pMultiFileHdl = NULL; goto Exit; } } - rc = m_pFileHdl64->Write( m_ui64Offset, + rc = m_pMultiFileHdl->write( m_ui64Offset, uiBytesToWrite, (FLMBYTE *)pvBuffer, &uiBytesWritten); m_ui64Offset += uiBytesWritten; @@ -1961,10 +1946,10 @@ Exit: if( RC_BAD( rc)) { m_rc = rc; - if( m_pFileHdl64) + if( m_pMultiFileHdl) { - m_pFileHdl64->Release(); - m_pFileHdl64 = NULL; + m_pMultiFileHdl->Release(); + m_pMultiFileHdl = NULL; } } @@ -2067,18 +2052,18 @@ RCODE F_BackerStream::startThreads( void) if( m_pClient) { - if( RC_BAD( rc = f_threadCreate( &m_pThread, + if( RC_BAD( rc = gv_XFlmSysData.pThreadMgr->createThread( &m_pThread, F_BackerStream::writeThread, "backup", - FLM_DEFAULT_THREAD_GROUP, 0, (void *)this))) + 0, 0, (void *)this))) { goto Exit; } } else if( m_pRestoreObj) { - if( RC_BAD( rc = f_threadCreate( &m_pThread, + if( RC_BAD( rc = gv_XFlmSysData.pThreadMgr->createThread( &m_pThread, F_BackerStream::readThread, "restore", - FLM_DEFAULT_THREAD_GROUP, 0, (void *)this))) + 0, 0, (void *)this))) { goto Exit; } @@ -2105,7 +2090,9 @@ void F_BackerStream::shutdownThreads( void) m_pThread->setShutdownFlag(); f_semSignal( m_hDataSem); - f_threadDestroy( &m_pThread); + m_pThread->stopThread(); + m_pThread->Release(); + m_pThread = NULL; // Now that the thread has terminated, it is safe // to destroy the data and idle semaphores. @@ -2461,7 +2448,7 @@ RCODE F_BackerStream::signalThread( void) // Check the error code - if( rc == NE_XFLM_IO_END_OF_FILE && !m_bFinalRead) + if( rc == NE_FLM_IO_END_OF_FILE && !m_bFinalRead) { m_bFinalRead = TRUE; } @@ -2498,7 +2485,7 @@ Exit: Desc: This thread reads data in the background ****************************************************************************/ RCODE F_BackerStream::readThread( - F_Thread * pThread) + IF_Thread * pThread) { F_BackerStream * pBackerStream = (F_BackerStream *)pThread->getParm1(); RCODE rc = NE_XFLM_OK; @@ -2537,7 +2524,7 @@ Exit: Desc: This thread writes data in the background ****************************************************************************/ RCODE F_BackerStream::writeThread( - F_Thread * pThread) + IF_Thread * pThread) { F_BackerStream * pBackerStream = (F_BackerStream *)pThread->getParm1(); RCODE rc = NE_XFLM_OK; diff --git a/xflaim/src/flblddb.cpp b/xflaim/src/flblddb.cpp index e04f01a..11f23a8 100644 --- a/xflaim/src/flblddb.cpp +++ b/xflaim/src/flblddb.cpp @@ -99,7 +99,7 @@ FINLINE void bldFreeCachedNode( /**************************************************************************** Desc: ****************************************************************************/ -class F_RebuildNodeIStream : public IF_IStream, public XF_Base +class F_RebuildNodeIStream : public IF_IStream { public: @@ -121,9 +121,9 @@ public: F_DbRebuild * pRebuild, FLMBOOL bRecovDictionary); - RCODE XFLMAPI close( void); + RCODE FLMAPI close( void); - RCODE XFLMAPI read( + RCODE FLMAPI read( void * pvBuffer, FLMUINT uiBytesToRead, FLMUINT * puiBytesRead); @@ -198,9 +198,9 @@ private: /*************************************************************************** Desc: Comparison object for node result sets ***************************************************************************/ -class F_NodeResultSetCompare : public IF_ResultSetCompare, public XF_Base +class F_NodeResultSetCompare : public IF_ResultSetCompare { - inline RCODE XFLMAPI compare( + inline RCODE FLMAPI compare( const void * pvData1, FLMUINT uiLength1, const void * pvData2, @@ -231,8 +231,8 @@ class F_NodeResultSetCompare : public IF_ResultSetCompare, public XF_Base } else { - uiCollection1 = byteToLong( &pucData1[ 1]); - uiCollection2 = byteToLong( &pucData2[ 1]); + uiCollection1 = f_byteToUINT32( &pucData1[ 1]); + uiCollection2 = f_byteToUINT32( &pucData2[ 1]); if( uiCollection1 < uiCollection2) { @@ -244,8 +244,8 @@ class F_NodeResultSetCompare : public IF_ResultSetCompare, public XF_Base } else { - ui64NodeId1 = byteToLong64( &pucData1[ 5]); - ui64NodeId2 = byteToLong64( &pucData2[ 5]); + ui64NodeId1 = f_byteToUINT64( &pucData1[ 5]); + ui64NodeId2 = f_byteToUINT64( &pucData2[ 5]); if( ui64NodeId1 < ui64NodeId2) { @@ -265,12 +265,12 @@ class F_NodeResultSetCompare : public IF_ResultSetCompare, public XF_Base return( NE_XFLM_OK); } - virtual FINLINE FLMINT XFLMAPI AddRef( void) + virtual FLMINT FLMAPI AddRef( void) { return( IF_ResultSetCompare::AddRef()); } - virtual FINLINE FLMINT XFLMAPI Release( void) + virtual FLMINT FLMAPI Release( void) { return( IF_ResultSetCompare::Release()); } @@ -481,8 +481,7 @@ Retry: goto Exit; } - if( RC_BAD( rc = m_pSFileHdl->Setup( NULL, - pszSourceDbPath, pszSourceDataDir))) + if( RC_BAD( rc = m_pSFileHdl->setup( pszSourceDbPath, pszSourceDataDir))) { goto Exit; } @@ -610,7 +609,7 @@ Retry: if( RC_BAD( rc = dbSystem.dbRemove( pszDestDbPath, pszDestDataDir, pszDestRflDir, TRUE))) { - if( rc == NE_XFLM_IO_PATH_NOT_FOUND || rc == NE_XFLM_IO_INVALID_FILENAME) + if( rc == NE_FLM_IO_PATH_NOT_FOUND || rc == NE_FLM_IO_INVALID_FILENAME) { rc = NE_XFLM_OK; } @@ -628,7 +627,7 @@ Retry: pCreateOpts->uiBlockSize = m_dbHdr.ui16BlockSize; } - m_pSFileHdl->SetBlockSize( m_dbHdr.ui16BlockSize); + m_pSFileHdl->setBlockSize( m_dbHdr.ui16BlockSize); // Create the destination database @@ -777,7 +776,7 @@ Exit: if( pLockFileHdl) { - (void)pLockFileHdl->Close(); + pLockFileHdl->close(); pLockFileHdl->Release(); pLockFileHdl = NULL; } @@ -915,8 +914,8 @@ RCODE F_DbRebuild::recoverNodes( FLMBOOL bRecoverDictionary) { RCODE rc = NE_XFLM_OK; - FResultSet * pRootRSet = NULL; - FResultSet * pNonRootRSet = NULL; + IF_ResultSet * pRootRSet = NULL; + IF_ResultSet * pNonRootRSet = NULL; F_CachedNode * pRecovRoot = NULL; F_RebuildNodeIStream * pIStream = NULL; FLMUINT64 ui64RootCount; @@ -946,27 +945,25 @@ RCODE F_DbRebuild::recoverNodes( rc = RC_SET( NE_XFLM_MEM); goto Exit; } - - if( (pRootRSet = f_new FResultSet( REBUILD_BLK_SIZE)) == NULL) + + if( RC_BAD( rc = FlmAllocResultSet( &pRootRSet))) { - rc = RC_SET( NE_XFLM_MEM); goto Exit; } - if( RC_BAD( rc = pRootRSet->setupResultSet( (char *)".", - pCompareRSEntry, 0, TRUE, FALSE))) + if( RC_BAD( rc = pRootRSet->setupResultSet( ".", pCompareRSEntry, 0, + TRUE, FALSE))) + { + goto Exit; + } + + if( RC_BAD( rc = FlmAllocResultSet( &pNonRootRSet))) { goto Exit; } - if( (pNonRootRSet = f_new FResultSet( REBUILD_BLK_SIZE)) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = pNonRootRSet->setupResultSet( (char *)".", - pCompareRSEntry, 0, TRUE, FALSE))) + if( RC_BAD( rc = pNonRootRSet->setupResultSet( ".", pCompareRSEntry, 0, + TRUE, FALSE))) { goto Exit; } @@ -1054,7 +1051,7 @@ RCODE F_DbRebuild::recoverNodes( } m_callbackData.ui64TotNodes = ui64RootCount + ui64NonRootCount; - FLM_SECS_TO_TIMER_UNITS( 30, uiMaxTransTime); + uiMaxTransTime = FLM_SECS_TO_TIMER_UNITS( 30); // Add the nodes to the destination database @@ -1225,7 +1222,7 @@ Desc: *****************************************************************************/ RCODE F_DbRebuild::recoverTree( F_RebuildNodeIStream * pIStream, - FResultSet * pNonRootRSet, + IF_ResultSet * pNonRootRSet, F_DOMNode * pParentNode, F_CachedNode * pRecovCachedNode, FLMBYTE * pucNodeIV) @@ -1770,7 +1767,7 @@ Notes: All the important stuff is handled by the F_DbRebuild::dbRebuild function (below). All this call does is create an F_DbRebuild object, call dbRebuild on it, delete the obj and return the RCODE. ****************************************************************************/ -RCODE XFLMAPI F_DbSystem::dbRebuild( +RCODE FLMAPI F_DbSystem::dbRebuild( const char * pszSourceDbPath, const char * pszSourceDataDir, const char * pszDestDbPath, @@ -1907,14 +1904,14 @@ RCODE F_RebuildNodeIStream::readBlock( if( !pFileHdl) { - if( RC_BAD( rc = m_pDbRebuild->m_pSFileHdl->GetFileHdl( + if( RC_BAD( rc = m_pDbRebuild->m_pSFileHdl->getFileHdl( uiFileNumber, FALSE, &pFileHdl))) { goto Exit; } } - if( RC_BAD( rc = pFileHdl->SectorRead( uiFileOffset, uiBlockSize, + if( RC_BAD( rc = pFileHdl->sectorRead( uiFileOffset, uiBlockSize, pucBlk, NULL))) { goto Exit; @@ -2047,11 +2044,11 @@ TryNextFile: goto Exit; } - if( RC_BAD( rc = m_pDbRebuild->m_pSFileHdl->GetFileHdl( + if( RC_BAD( rc = m_pDbRebuild->m_pSFileHdl->getFileHdl( pScanState->uiFileNumber, FALSE, &pFileHdl))) { - if( rc == NE_XFLM_IO_PATH_NOT_FOUND || - rc == NE_XFLM_IO_INVALID_FILENAME) + if( rc == NE_FLM_IO_PATH_NOT_FOUND || + rc == NE_FLM_IO_INVALID_FILENAME) { rc = NE_XFLM_OK; uiTryNextCount++; @@ -2069,7 +2066,7 @@ TryNextFile: if( RC_BAD( rc = readBlock( pFileHdl, pScanState->uiFileNumber, pScanState->uiFileOffset, pScanState))) { - if( rc == NE_XFLM_IO_END_OF_FILE) + if( rc == NE_FLM_IO_END_OF_FILE) { rc = NE_XFLM_OK; goto TryNextFile; @@ -2782,10 +2779,10 @@ TryNextFile: uiOffset = 0; uiFileNumber++; - if( RC_BAD( rc = m_pSFileHdl->GetFileHdl( uiFileNumber, + if( RC_BAD( rc = m_pSFileHdl->getFileHdl( uiFileNumber, FALSE, &pFileHdl))) { - if( rc == NE_XFLM_IO_PATH_NOT_FOUND) + if( rc == NE_FLM_IO_PATH_NOT_FOUND) { rc = NE_XFLM_OK; break; @@ -2795,7 +2792,7 @@ TryNextFile: } } - if( RC_BAD( rc = pFileHdl->Read( uiOffset, + if( RC_BAD( rc = pFileHdl->read( uiOffset, SIZEOF_STD_BLK_HDR, &blkHdr, &uiBytesRead))) { if( rc != NE_XFLM_EOF_HIT) diff --git a/xflaim/src/flblksum.cpp b/xflaim/src/flblksum.cpp deleted file mode 100644 index 724d97b..0000000 --- a/xflaim/src/flblksum.cpp +++ /dev/null @@ -1,120 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: This file contains the routine which calculates a block checksum. -// -// Tabs: 3 -// -// Copyright (c) 1991-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: flblksum.cpp 3112 2006-01-19 13:12:40 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -/******************************************************************** -Desc: Calculate the checksum for a block. NOTE: This is ALWAYS done - on the raw image that will be written to disk. This means - that if the block needs to be converted before writing it out, - it should be done before calculating the checksum. -*********************************************************************/ -FLMUINT32 calcBlkCRC( - F_BLK_HDR * pBlkHdr, - FLMUINT uiBlkEnd) -{ - FLMUINT32 ui32SaveCRC; - FLMUINT uiAdds; - FLMUINT uiXORs; - FLMBYTE * pucBlkPtr; - - // Calculate CRC on everything except for the ui32BlkCRC value. - // To do this, we temporarily change it to zero. The saved - // value will be restored after calculating the CRC. - - ui32SaveCRC = pBlkHdr->ui32BlkCRC; - pBlkHdr->ui32BlkCRC = 0; - uiAdds = 0; - uiXORs = 0; - pucBlkPtr = (FLMBYTE *)pBlkHdr; - -#if defined( FLM_NLM) || (defined( FLM_WIN) && !defined( FLM_64BIT)) - - FastBlockCheckSum( pucBlkPtr, &uiAdds, &uiXORs, - (unsigned long)uiBlkEnd); - -#else - - FLMBYTE * pucCur = pucBlkPtr; - FLMBYTE * pucEnd = pucCur + uiBlkEnd; - - while( pucCur < pucEnd) - { - uiAdds += *pucCur; - uiXORs ^= *pucCur++; - } - - uiAdds &= 0xFF; -#endif - - // Restore the CRC that was in the block. - - pBlkHdr->ui32BlkCRC = ui32SaveCRC; - return( (FLMUINT32)((uiAdds << 16) + uiXORs)); -} - -/******************************************************************** -Desc: Calculate the CRC for the database header. -*********************************************************************/ -FLMUINT32 calcDbHdrCRC( - XFLM_DB_HDR * pDbHdr) -{ - FLMUINT32 ui32SaveCRC; - FLMUINT uiAdds; - FLMUINT uiXORs; - FLMBYTE * pucHdr; - - // Checksum everything except for the ui32HdrCRC value. - - ui32SaveCRC = pDbHdr->ui32HdrCRC; - pDbHdr->ui32HdrCRC = 0; - - uiAdds = 0; - uiXORs = 0; - pucHdr = (FLMBYTE *)pDbHdr; - -#if defined( FLM_NLM) || (defined( FLM_WIN) && !defined( FLM_64BIT)) - - FastBlockCheckSum( pucHdr, &uiAdds, &uiXORs, - (unsigned long)sizeof( XFLM_DB_HDR)); - -#else - FLMBYTE * pucCur = pucHdr; - FLMBYTE * pucEnd = pucHdr + sizeof( XFLM_DB_HDR); - - while( pucCur < pucEnd) - { - uiAdds += *pucCur; - uiXORs ^= *pucCur++; - } - - uiAdds &= 0xFF; -#endif - - // Restore the checksum that was in the header - - pDbHdr->ui32HdrCRC = ui32SaveCRC; - return( (FLMUINT32)((uiAdds << 16) + uiXORs)); -} diff --git a/xflaim/src/flchkdb.cpp b/xflaim/src/flchkdb.cpp index a72a298..8c5053b 100644 --- a/xflaim/src/flchkdb.cpp +++ b/xflaim/src/flchkdb.cpp @@ -95,7 +95,7 @@ RCODE F_DbCheck::createAndOpenResultSetDb( void) // Generate a random file name f_sprintf( m_szResultSetDibName, - "%d.db", (int)m_pRandGen->randomChoice( 100, 20000)); + "%d.db", (int)m_pRandGen->getINT32( 100, 20000)); if (RC_OK( rc = dbSystem.dbCreate( m_szResultSetDibName, NULL, NULL, NULL, NULL, &createOpts, TRUE, @@ -103,7 +103,7 @@ RCODE F_DbCheck::createAndOpenResultSetDb( void) { break; } - if (rc == NE_XFLM_FILE_EXISTS || rc == NE_XFLM_IO_ACCESS_DENIED) + if (rc == NE_XFLM_FILE_EXISTS || rc == NE_FLM_IO_ACCESS_DENIED) { rc = NE_XFLM_OK; } @@ -189,7 +189,7 @@ RCODE F_DbCheck::getBtResultSet( // Now create a new collection. Randomly select a collection number to use. - uiCollection = m_pRandGen->randomChoice( 100, XFLM_MAX_COLLECTION_NUM); + uiCollection = m_pRandGen->getINT32( 100, XFLM_MAX_COLLECTION_NUM); // Check to see if it already exists. @@ -343,14 +343,13 @@ RCODE F_DbCheck::dbCheck( } // Setup the result set database. - - if ((m_pRandGen = f_new F_RandomGenerator) == NULL) + + if( RC_BAD( rc = FlmAllocRandomGenerator( &m_pRandGen))) { - rc = RC_SET( NE_XFLM_MEM); goto Exit; } - m_pRandGen->randomSetSeed( 9768); + m_pRandGen->setSeed( 9768); if (RC_BAD( rc = createAndOpenResultSetDb())) { @@ -388,7 +387,7 @@ Begin_Check: uiLoop <= MAX_DATA_BLOCK_FILE_NUMBER; uiLoop++) { - if (RC_BAD( m_pDb->m_pSFileHdl->GetFileSize( uiLoop, &ui64TmpSize))) + if (RC_BAD( m_pDb->m_pSFileHdl->getFileSize( uiLoop, &ui64TmpSize))) { break; } @@ -786,7 +785,7 @@ Exit: Desc: Returns the next B-Tree information that was collected during the database check. ****************************************************************************/ -void XFLMAPI F_DbInfo::getBTreeInfo( +void FLMAPI F_DbInfo::getBTreeInfo( FLMUINT uiNthLogicalFile, FLMUINT * puiLfNum, eLFileType * peLfType, @@ -817,7 +816,7 @@ void XFLMAPI F_DbInfo::getBTreeInfo( Desc: Returns block information on the specified b-tree and level within that b-tree. ****************************************************************************/ -void XFLMAPI F_DbInfo::getBTreeBlockStats( +void FLMAPI F_DbInfo::getBTreeBlockStats( FLMUINT uiNthLogicalFile, FLMUINT uiLevel, FLMUINT64 * pui64KeyCount, @@ -868,7 +867,7 @@ Note: The routine verifies the database by first reading through verify the linked lists, we can keep ourselves from getting into an infinite loop if there is a loop in the lists. ****************************************************************************/ -RCODE XFLMAPI F_DbSystem::dbCheck( +RCODE FLMAPI F_DbSystem::dbCheck( const char * pszDbFileName, // [IN] Full path and file name of the database which // is to be checked. NULL can be passed as the value of diff --git a/xflaim/src/flchkix.cpp b/xflaim/src/flchkix.cpp index f240eb3..e1a025a 100644 --- a/xflaim/src/flchkix.cpp +++ b/xflaim/src/flchkix.cpp @@ -819,7 +819,7 @@ RCODE F_DbCheck::reportIxError( // memory for new CDL entries from the DB pool. If the pool is not // reset, it grows during the check and becomes VERY large. - pDbPoolMark = m_pDb->m_TempPool.poolMark(); + pDbPoolMark = m_pDb->m_pTempPool->poolMark(); // Set up the KRef so that flmGetRecKeys will work @@ -868,7 +868,7 @@ Exit: // Reset the index check pool - m_pDb->m_TempPool.poolReset(pDbPoolMark); + m_pDb->m_pTempPool->poolReset(pDbPoolMark); return( rc); } diff --git a/xflaim/src/flchktr.cpp b/xflaim/src/flchktr.cpp index 06b7cec..6de31a8 100644 --- a/xflaim/src/flchktr.cpp +++ b/xflaim/src/flchktr.cpp @@ -192,10 +192,10 @@ FSTATIC RCODE chkReadBlkFromDisk( FLMUINT uiBlkSize = (FLMUINT)pDbHdr->ui16BlockSize; F_Dict * pDict; - if (RC_BAD( rc = pSFileHdl->ReadBlock( uiFilePos, uiBlkSize, + if (RC_BAD( rc = pSFileHdl->readBlock( uiFilePos, uiBlkSize, (FLMBYTE *)pBlkHdr, &uiBytesRead))) { - if (rc == NE_XFLM_IO_END_OF_FILE) + if (rc == NE_FLM_IO_END_OF_FILE) { rc = RC_SET( NE_XFLM_DATA_ERROR); } diff --git a/xflaim/src/flclose.cpp b/xflaim/src/flclose.cpp index d2e88bd..d2a7ede 100644 --- a/xflaim/src/flclose.cpp +++ b/xflaim/src/flclose.cpp @@ -68,6 +68,11 @@ F_Db::~F_Db() f_free( &m_pKrefTbl); m_uiKrefTblSize = 0; } + + if( m_pKrefPool) + { + m_pKrefPool->Release(); + } if( m_pucKrefKeyBuf) { @@ -108,6 +113,16 @@ F_Db::~F_Db() { f_semDestroy( &m_hWaitSem); } + + if (m_pTmpKrefPool) + { + m_pTmpKrefPool->Release(); + } + + if( m_pTempPool) + { + m_pTempPool->Release(); + } // Unlink the F_Db from the F_Database and F_Dict structures. // IMPORTANT NOTE: The call to unlinkFromDatabase needs to @@ -129,7 +144,7 @@ F_Db::~F_Db() /**************************************************************************** Desc: Wait for a specific database to close ****************************************************************************/ -RCODE XFLMAPI F_DbSystem::waitToClose( +RCODE FLMAPI F_DbSystem::waitToClose( const char * pszDbPath) { RCODE rc = NE_XFLM_OK; @@ -145,7 +160,7 @@ RCODE XFLMAPI F_DbSystem::waitToClose( goto Exit; } - if( RC_BAD( rc = gv_pFileSystem->pathToStorageString( + if( RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathToStorageString( pszDbPath, szDbPathStr1))) { goto Exit; diff --git a/xflaim/src/flconvrt.cpp b/xflaim/src/flconvrt.cpp index b14a2a4..eabd3ef 100644 --- a/xflaim/src/flconvrt.cpp +++ b/xflaim/src/flconvrt.cpp @@ -28,7 +28,7 @@ /**************************************************************************** Desc : Upgrades a database to the latest FLAIM version. ****************************************************************************/ -RCODE XFLMAPI F_Db::upgrade( +RCODE FLMAPI F_Db::upgrade( IF_UpgradeClient * // pUpgradeClient ) { @@ -220,7 +220,7 @@ Exit: /************************************************************************ Desc : Enable encryption on the database. *************************************************************************/ -RCODE XFLMAPI F_Db::enableEncryption( void) +RCODE FLMAPI F_Db::enableEncryption( void) { RCODE rc = NE_XFLM_OK; F_Rfl * pRfl = m_pDatabase->m_pRfl; @@ -352,7 +352,7 @@ Desc : Change the database key from wrapped in the NICI server NICI server key. If a password is specified, the key will be shrouded in it. ****************************************************************************/ -RCODE XFLMAPI F_Db::wrapKey( +RCODE FLMAPI F_Db::wrapKey( const char * pszPassword) { RCODE rc = NE_XFLM_OK; @@ -554,7 +554,7 @@ Desc : Generate a new database key and re-wrap all existing keys in it NOTE: New database key will be wrapped in NICI server key, even if the previous key was wrapped in a password. ****************************************************************************/ -RCODE XFLMAPI F_Db::rollOverDbKey( void) +RCODE FLMAPI F_Db::rollOverDbKey( void) { RCODE rc = NE_XFLM_OK; F_Rfl * pRfl = m_pDatabase->m_pRfl; @@ -564,7 +564,7 @@ RCODE XFLMAPI F_Db::rollOverDbKey( void) F_ENCDEF * pEncDef; F_DOMNode * pNode = NULL; F_DOMNode * pAttrNode = NULL; - FLMBYTE * pucBuf; + FLMBYTE * pucBuf = NULL; FLMBOOL bLocked = FALSE; FLMBOOL bStartedTrans = FALSE; FLMUINT32 ui32BufLen = 0; @@ -612,7 +612,7 @@ RCODE XFLMAPI F_Db::rollOverDbKey( void) goto Exit; } - f_memcpy( &m_pDatabase->m_uncommittedDbHdr.DbKey, + f_memcpy( m_pDatabase->m_uncommittedDbHdr.DbKey, pucWrappingKey, ui32KeyLen); m_pDatabase->m_uncommittedDbHdr.ui32DbKeyLen = ui32KeyLen; diff --git a/xflaim/src/flcreate.cpp b/xflaim/src/flcreate.cpp index d034569..6f56d55 100644 --- a/xflaim/src/flcreate.cpp +++ b/xflaim/src/flcreate.cpp @@ -28,7 +28,7 @@ /*API~*********************************************************************** Desc: Creates a new FLAIM database. *END************************************************************************/ -RCODE XFLMAPI F_DbSystem::dbCreate( +RCODE FLMAPI F_DbSystem::dbCreate( const char * pszFilePath, // [IN] Full path file name of the database which is to be created. const char * pszDataDir, @@ -67,7 +67,7 @@ RCODE XFLMAPI F_DbSystem::dbCreate( { RCODE rc = NE_XFLM_OK; F_Db * pDb = NULL; - F_Database * pDatabase; + F_Database * pDatabase = NULL; FLMBOOL bDatabaseCreated = FALSE; FLMBOOL bNewDatabase = FALSE; FLMBOOL bMutexLocked = FALSE; @@ -77,7 +77,7 @@ RCODE XFLMAPI F_DbSystem::dbCreate( if (!pszFilePath || !pszFilePath [0]) { - rc = RC_SET( NE_XFLM_IO_INVALID_FILENAME); + rc = RC_SET( NE_FLM_IO_INVALID_FILENAME); goto Exit; } @@ -118,7 +118,7 @@ RCODE XFLMAPI F_DbSystem::dbCreate( if (pDatabase->m_uiOpenIFDbCount || (pDatabase->m_uiFlags & DBF_BEING_OPENED)) { - rc = RC_SET( NE_XFLM_IO_ACCESS_DENIED); + rc = RC_SET( NE_FLM_IO_ACCESS_DENIED); goto Exit; } @@ -154,15 +154,15 @@ RCODE XFLMAPI F_DbSystem::dbCreate( if (pCreateOpts != NULL) { - pDb->m_pSFileHdl->SetBlockSize( + pDb->m_pSFileHdl->setBlockSize( flmAdjustBlkSize( pCreateOpts->uiBlockSize)); } else { - pDb->m_pSFileHdl->SetBlockSize( XFLM_DEFAULT_BLKSIZ); + pDb->m_pSFileHdl->setBlockSize( XFLM_DEFAULT_BLKSIZ); } - if (RC_OK( gv_pFileSystem->Exists( pszFilePath))) + if (RC_OK( gv_XFlmSysData.pFileSystem->doesFileExist( pszFilePath))) { rc = RC_SET( NE_XFLM_FILE_EXISTS); goto Exit; @@ -172,7 +172,7 @@ RCODE XFLMAPI F_DbSystem::dbCreate( pDb->m_pSFileHdl->setMaxAutoExtendSize( gv_XFlmSysData.uiMaxFileSize); pDb->m_pSFileHdl->setExtendSize( pDb->m_pDatabase->m_uiFileExtendSize); - if (RC_BAD( rc = pDb->m_pSFileHdl->CreateFile( 0))) + if (RC_BAD( rc = pDb->m_pSFileHdl->createFile( 0))) { goto Exit; } @@ -327,7 +327,7 @@ RCODE F_Db::initDbFiles( if (!m_pDatabase->m_bTempDb) { - if (RC_BAD( rc = m_pSFileHdl->CreateFile( 1))) + if (RC_BAD( rc = m_pSFileHdl->createFile( 1))) { goto Exit; } @@ -406,7 +406,7 @@ RCODE F_Db::initDbFiles( if (!m_pDatabase->m_bTempDb) { pBlkHdr->ui32BlkCRC = calcBlkCRC( pBlkHdr, SIZEOF_STD_BLK_HDR); - if (RC_BAD( rc = m_pSFileHdl->WriteBlock( + if (RC_BAD( rc = m_pSFileHdl->writeBlock( (FLMUINT)pBlkHdr->ui32BlkAddr, uiBlkSize, pucBuf, uiBlkSize, NULL, &uiWriteBytes))) @@ -416,7 +416,7 @@ RCODE F_Db::initDbFiles( // Force things to disk. - if (RC_BAD( rc = m_pSFileHdl->Flush())) + if (RC_BAD( rc = m_pSFileHdl->flush())) { goto Exit; } diff --git a/xflaim/src/fldbglog.cpp b/xflaim/src/fldbglog.cpp index e93938a..2889b2a 100644 --- a/xflaim/src/fldbglog.cpp +++ b/xflaim/src/fldbglog.cpp @@ -80,7 +80,7 @@ void flmDbgLogInit( void) // Create the file - truncate if it exists already. - if( RC_BAD( rc = gv_pFileSystem->Create( szLogPath, + if( RC_BAD( rc = gv_XFlmSysData.pFileSystem->Create( szLogPath, XFLM_IO_RDWR | XFLM_IO_SH_DENYNONE | XFLM_IO_DIRECT, &g_pLogFile))) { goto Exit; diff --git a/xflaim/src/flerror.cpp b/xflaim/src/flerror.cpp index 1a5a7db..53eb9ef 100644 --- a/xflaim/src/flerror.cpp +++ b/xflaim/src/flerror.cpp @@ -25,6 +25,372 @@ #include "flaimsys.h" +/**************************************************************************** +Desc: Error code to string mapping tables +****************************************************************************/ +typedef struct +{ + RCODE rc; + const char * pszErrorStr; +} F_ERROR_CODE_MAP; + +#define flmErrorCodeEntry(c) { c, #c } + +/**************************************************************************** +Desc: +****************************************************************************/ +F_ERROR_CODE_MAP gv_FlmGeneralErrors[ + NE_XFLM_LAST_GENERAL_ERROR - NE_XFLM_FIRST_GENERAL_ERROR - 1] = +{ + flmErrorCodeEntry( NE_XFLM_BAD_PREFIX), + flmErrorCodeEntry( NE_XFLM_ATTRIBUTE_PURGED), + flmErrorCodeEntry( NE_XFLM_BAD_COLLECTION), + flmErrorCodeEntry( NE_XFLM_DATABASE_LOCK_REQ_TIMEOUT), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_DATA_COMPONENT), + flmErrorCodeEntry( NE_XFLM_MUST_INDEX_ON_PRESENCE), + flmErrorCodeEntry( NE_XFLM_BAD_IX), + flmErrorCodeEntry( NE_XFLM_BACKUP_ACTIVE), + flmErrorCodeEntry( NE_XFLM_SERIAL_NUM_MISMATCH), + flmErrorCodeEntry( NE_XFLM_BAD_RFL_DB_SERIAL_NUM), + flmErrorCodeEntry( NE_XFLM_BAD_RFL_FILE_NUMBER), + flmErrorCodeEntry( NE_XFLM_CANNOT_DEL_ELEMENT), + flmErrorCodeEntry( NE_XFLM_CANNOT_MOD_DATA_TYPE), + flmErrorCodeEntry( NE_XFLM_CANNOT_INDEX_DATA_TYPE), + flmErrorCodeEntry( NE_XFLM_BAD_ELEMENT_NUM), + flmErrorCodeEntry( NE_XFLM_BAD_ATTRIBUTE_NUM), + flmErrorCodeEntry( NE_XFLM_BAD_ENCDEF_NUM), + flmErrorCodeEntry( NE_XFLM_INVALID_FILE_SEQUENCE), + flmErrorCodeEntry( NE_XFLM_DUPLICATE_ELEMENT_NUM), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_TRANS_TYPE), + flmErrorCodeEntry( NE_XFLM_UNSUPPORTED_VERSION), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_TRANS_OP), + flmErrorCodeEntry( NE_XFLM_INCOMPLETE_LOG), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_INDEX_DEF), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_INDEX_ON), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_STATE_CHANGE), + flmErrorCodeEntry( NE_XFLM_BAD_RFL_SERIAL_NUM), + flmErrorCodeEntry( NE_XFLM_NEWER_FLAIM), + flmErrorCodeEntry( NE_XFLM_CANNOT_MOD_ELEMENT_STATE), + flmErrorCodeEntry( NE_XFLM_CANNOT_MOD_ATTRIBUTE_STATE), + flmErrorCodeEntry( NE_XFLM_NO_MORE_ELEMENT_NUMS), + flmErrorCodeEntry( NE_XFLM_NO_TRANS_ACTIVE), + flmErrorCodeEntry( NE_XFLM_NOT_FLAIM), + flmErrorCodeEntry( NE_XFLM_OLD_VIEW), + flmErrorCodeEntry( NE_XFLM_SHARED_LOCK), + flmErrorCodeEntry( NE_XFLM_TRANS_ACTIVE), + flmErrorCodeEntry( NE_XFLM_RFL_TRANS_GAP), + flmErrorCodeEntry( NE_XFLM_BAD_COLLATED_KEY), + flmErrorCodeEntry( NE_XFLM_MUST_DELETE_INDEXES), + flmErrorCodeEntry( NE_XFLM_RFL_INCOMPLETE), + flmErrorCodeEntry( NE_XFLM_CANNOT_RESTORE_RFL_FILES), + flmErrorCodeEntry( NE_XFLM_INCONSISTENT_BACKUP), + flmErrorCodeEntry( NE_XFLM_BLOCK_CRC), + flmErrorCodeEntry( NE_XFLM_ABORT_TRANS), + flmErrorCodeEntry( NE_XFLM_NOT_RFL), + flmErrorCodeEntry( NE_XFLM_BAD_RFL_PACKET), + flmErrorCodeEntry( NE_XFLM_DATA_PATH_MISMATCH), + flmErrorCodeEntry( NE_XFLM_MUST_CLOSE_DATABASE), + flmErrorCodeEntry( NE_XFLM_INVALID_ENCKEY_CRC), + flmErrorCodeEntry( NE_XFLM_HDR_CRC), + flmErrorCodeEntry( NE_XFLM_NO_NAME_TABLE), + flmErrorCodeEntry( NE_XFLM_UNALLOWED_UPGRADE), + flmErrorCodeEntry( NE_XFLM_DUPLICATE_ATTRIBUTE_NUM), + flmErrorCodeEntry( NE_XFLM_DUPLICATE_INDEX_NUM), + flmErrorCodeEntry( NE_XFLM_DUPLICATE_COLLECTION_NUM), + flmErrorCodeEntry( NE_XFLM_DUPLICATE_ELEMENT_NAME), + flmErrorCodeEntry( NE_XFLM_DUPLICATE_ATTRIBUTE_NAME), + flmErrorCodeEntry( NE_XFLM_DUPLICATE_INDEX_NAME), + flmErrorCodeEntry( NE_XFLM_DUPLICATE_COLLECTION_NAME), + flmErrorCodeEntry( NE_XFLM_ELEMENT_PURGED), + flmErrorCodeEntry( NE_XFLM_TOO_MANY_OPEN_DATABASES), + flmErrorCodeEntry( NE_XFLM_DATABASE_OPEN), + flmErrorCodeEntry( NE_XFLM_CACHE_ERROR), + flmErrorCodeEntry( NE_XFLM_DB_FULL), + flmErrorCodeEntry( NE_XFLM_QUERY_SYNTAX), + flmErrorCodeEntry( NE_XFLM_INDEX_OFFLINE), + flmErrorCodeEntry( NE_XFLM_RFL_DISK_FULL), + flmErrorCodeEntry( NE_XFLM_MUST_WAIT_CHECKPOINT), + flmErrorCodeEntry( NE_XFLM_MISSING_ENC_ALGORITHM), + flmErrorCodeEntry( NE_XFLM_INVALID_ENC_ALGORITHM), + flmErrorCodeEntry( NE_XFLM_INVALID_ENC_KEY_SIZE), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_DATA_TYPE), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_STATE), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_ELEMENT_NAME), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_ATTRIBUTE_NAME), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_COLLECTION_NAME), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_INDEX_NAME), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_ELEMENT_NUMBER), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_ATTRIBUTE_NUMBER), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_COLLECTION_NUMBER), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_INDEX_NUMBER), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_ENCDEF_NUMBER), + flmErrorCodeEntry( NE_XFLM_COLLECTION_NAME_MISMATCH), + flmErrorCodeEntry( NE_XFLM_ELEMENT_NAME_MISMATCH), + flmErrorCodeEntry( NE_XFLM_ATTRIBUTE_NAME_MISMATCH), + flmErrorCodeEntry( NE_XFLM_INVALID_COMPARE_RULE), + flmErrorCodeEntry( NE_XFLM_DUPLICATE_KEY_COMPONENT), + flmErrorCodeEntry( NE_XFLM_DUPLICATE_DATA_COMPONENT), + flmErrorCodeEntry( NE_XFLM_MISSING_KEY_COMPONENT), + flmErrorCodeEntry( NE_XFLM_MISSING_DATA_COMPONENT), + flmErrorCodeEntry( NE_XFLM_INVALID_INDEX_OPTION), + flmErrorCodeEntry( NE_XFLM_NO_MORE_ATTRIBUTE_NUMS), + flmErrorCodeEntry( NE_XFLM_MISSING_ELEMENT_NAME), + flmErrorCodeEntry( NE_XFLM_MISSING_ATTRIBUTE_NAME), + flmErrorCodeEntry( NE_XFLM_MISSING_ELEMENT_NUMBER), + flmErrorCodeEntry( NE_XFLM_MISSING_ATTRIBUTE_NUMBER), + flmErrorCodeEntry( NE_XFLM_MISSING_INDEX_NAME), + flmErrorCodeEntry( NE_XFLM_MISSING_INDEX_NUMBER), + flmErrorCodeEntry( NE_XFLM_MISSING_COLLECTION_NAME), + flmErrorCodeEntry( NE_XFLM_MISSING_COLLECTION_NUMBER), + flmErrorCodeEntry( NE_XFLM_MISSING_ENCDEF_NAME), + flmErrorCodeEntry( NE_XFLM_MISSING_ENCDEF_NUMBER), + flmErrorCodeEntry( NE_XFLM_NO_MORE_INDEX_NUMS), + flmErrorCodeEntry( NE_XFLM_NO_MORE_COLLECTION_NUMS), + flmErrorCodeEntry( NE_XFLM_CANNOT_DEL_ATTRIBUTE), + flmErrorCodeEntry( NE_XFLM_TOO_MANY_PENDING_NODES), + flmErrorCodeEntry( NE_XFLM_BAD_USE_OF_ELM_ROOT_TAG), + flmErrorCodeEntry( NE_XFLM_DUP_SIBLING_IX_COMPONENTS), + flmErrorCodeEntry( NE_XFLM_RFL_FILE_NOT_FOUND), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_KEY_COMPONENT_NUM), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_DATA_COMPONENT_NUM), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_PREFIX_NUMBER), + flmErrorCodeEntry( NE_XFLM_MISSING_PREFIX_NAME), + flmErrorCodeEntry( NE_XFLM_MISSING_PREFIX_NUMBER), + flmErrorCodeEntry( NE_XFLM_UNDEFINED_ELEMENT_NAME), + flmErrorCodeEntry( NE_XFLM_UNDEFINED_ATTRIBUTE_NAME), + flmErrorCodeEntry( NE_XFLM_DUPLICATE_PREFIX_NAME), + flmErrorCodeEntry( NE_XFLM_NAMESPACE_NOT_ALLOWED), + flmErrorCodeEntry( NE_XFLM_INVALID_NAMESPACE_DECL), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_NAMESPACE_DECL_DATATYPE), + flmErrorCodeEntry( NE_XFLM_NO_MORE_PREFIX_NUMS), + flmErrorCodeEntry( NE_XFLM_NO_MORE_ENCDEF_NUMS), + flmErrorCodeEntry( NE_XFLM_COLLECTION_OFFLINE), + flmErrorCodeEntry( NE_XFLM_DELETE_NOT_ALLOWED), + flmErrorCodeEntry( NE_XFLM_RESET_NEEDED), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_REQUIRED_VALUE), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_INDEX_COMPONENT), + flmErrorCodeEntry( NE_XFLM_ILLEGAL_UNIQUE_SUB_ELEMENT_VALUE), + flmErrorCodeEntry( NE_XFLM_DATA_TYPE_MUST_BE_NO_DATA), + flmErrorCodeEntry( NE_XFLM_CANNOT_SET_REQUIRED), + flmErrorCodeEntry( NE_XFLM_CANNOT_SET_LIMIT), + flmErrorCodeEntry( NE_XFLM_CANNOT_SET_INDEX_ON), + flmErrorCodeEntry( NE_XFLM_CANNOT_SET_COMPARE_RULES), + flmErrorCodeEntry( NE_XFLM_INPUT_PENDING), + flmErrorCodeEntry( NE_XFLM_INVALID_NODE_TYPE), + flmErrorCodeEntry( NE_XFLM_INVALID_CHILD_ELM_NODE_ID), + flmErrorCodeEntry( NE_XFLM_RFL_END) +}; + +/**************************************************************************** +Desc: +****************************************************************************/ +F_ERROR_CODE_MAP gv_FlmDomErrors[ + NE_XFLM_LAST_DOM_ERROR - NE_XFLM_FIRST_DOM_ERROR - 1] = +{ + flmErrorCodeEntry( NE_XFLM_DOM_HIERARCHY_REQUEST_ERR), + flmErrorCodeEntry( NE_XFLM_DOM_WRONG_DOCUMENT_ERR), + flmErrorCodeEntry( NE_XFLM_DOM_DATA_ERROR), + flmErrorCodeEntry( NE_XFLM_DOM_NODE_NOT_FOUND), + flmErrorCodeEntry( NE_XFLM_DOM_INVALID_CHILD_TYPE), + flmErrorCodeEntry( NE_XFLM_DOM_NODE_DELETED), + flmErrorCodeEntry( NE_XFLM_DOM_DUPLICATE_ELEMENT) +}; + +/**************************************************************************** +Desc: +****************************************************************************/ +F_ERROR_CODE_MAP gv_FlmQueryErrors[ + NE_XFLM_LAST_QUERY_ERROR - NE_XFLM_FIRST_QUERY_ERROR - 1] = +{ + flmErrorCodeEntry( NE_XFLM_Q_UNMATCHED_RPAREN), + flmErrorCodeEntry( NE_XFLM_Q_UNEXPECTED_LPAREN), + flmErrorCodeEntry( NE_XFLM_Q_UNEXPECTED_RPAREN), + flmErrorCodeEntry( NE_XFLM_Q_EXPECTING_OPERAND), + flmErrorCodeEntry( NE_XFLM_Q_EXPECTING_OPERATOR), + flmErrorCodeEntry( NE_XFLM_Q_UNEXPECTED_COMMA), + flmErrorCodeEntry( NE_XFLM_Q_EXPECTING_LPAREN), + flmErrorCodeEntry( NE_XFLM_Q_UNEXPECTED_VALUE), + flmErrorCodeEntry( NE_XFLM_Q_INVALID_NUM_FUNC_ARGS), + flmErrorCodeEntry( NE_XFLM_Q_UNEXPECTED_XPATH_COMPONENT), + flmErrorCodeEntry( NE_XFLM_Q_ILLEGAL_LBRACKET), + flmErrorCodeEntry( NE_XFLM_Q_ILLEGAL_RBRACKET), + flmErrorCodeEntry( NE_XFLM_Q_ILLEGAL_OPERAND), + flmErrorCodeEntry( NE_XFLM_Q_ALREADY_OPTIMIZED), + flmErrorCodeEntry( NE_XFLM_Q_MISMATCHED_DB), + flmErrorCodeEntry( NE_XFLM_Q_ILLEGAL_OPERATOR), + flmErrorCodeEntry( NE_XFLM_Q_ILLEGAL_COMPARE_RULES), + flmErrorCodeEntry( NE_XFLM_Q_INCOMPLETE_QUERY_EXPR), + flmErrorCodeEntry( NE_XFLM_Q_NOT_POSITIONED), + flmErrorCodeEntry( NE_XFLM_Q_INVALID_NODE_ID_VALUE), + flmErrorCodeEntry( NE_XFLM_Q_INVALID_META_DATA_TYPE), + flmErrorCodeEntry( NE_XFLM_Q_NEW_EXPR_NOT_ALLOWED), + flmErrorCodeEntry( NE_XFLM_Q_INVALID_CONTEXT_POS), + flmErrorCodeEntry( NE_XFLM_Q_INVALID_FUNC_ARG), + flmErrorCodeEntry( NE_XFLM_Q_EXPECTING_RPAREN), + flmErrorCodeEntry( NE_XFLM_Q_TOO_LATE_TO_ADD_SORT_KEYS), + flmErrorCodeEntry( NE_XFLM_Q_INVALID_SORT_KEY_COMPONENT), + flmErrorCodeEntry( NE_XFLM_Q_DUPLICATE_SORT_KEY_COMPONENT), + flmErrorCodeEntry( NE_XFLM_Q_MISSING_SORT_KEY_COMPONENT), + flmErrorCodeEntry( NE_XFLM_Q_NO_SORT_KEY_COMPONENTS_SPECIFIED), + flmErrorCodeEntry( NE_XFLM_Q_SORT_KEY_CONTEXT_MUST_BE_ELEMENT), + flmErrorCodeEntry( NE_XFLM_Q_INVALID_ELEMENT_NUM_IN_SORT_KEYS), + flmErrorCodeEntry( NE_XFLM_Q_INVALID_ATTR_NUM_IN_SORT_KEYS), + flmErrorCodeEntry( NE_XFLM_Q_NON_POSITIONABLE_QUERY), + flmErrorCodeEntry( NE_XFLM_Q_INVALID_POSITION) +}; + +F_ERROR_CODE_MAP gv_FlmNiciErrors[ + NE_XFLM_LAST_NICI_ERROR - NE_XFLM_FIRST_NICI_ERROR - 1] = +{ + flmErrorCodeEntry( NE_XFLM_NICI_CONTEXT), + flmErrorCodeEntry( NE_XFLM_NICI_ATTRIBUTE_VALUE), + flmErrorCodeEntry( NE_XFLM_NICI_BAD_ATTRIBUTE), + flmErrorCodeEntry( NE_XFLM_NICI_WRAPKEY_FAILED), + flmErrorCodeEntry( NE_XFLM_NICI_UNWRAPKEY_FAILED), + flmErrorCodeEntry( NE_XFLM_NICI_INVALID_ALGORITHM), + flmErrorCodeEntry( NE_XFLM_NICI_GENKEY_FAILED), + flmErrorCodeEntry( NE_XFLM_NICI_BAD_RANDOM), + flmErrorCodeEntry( NE_XFLM_PBE_ENCRYPT_FAILED), + flmErrorCodeEntry( NE_XFLM_PBE_DECRYPT_FAILED), + flmErrorCodeEntry( NE_XFLM_DIGEST_INIT_FAILED), + flmErrorCodeEntry( NE_XFLM_DIGEST_FAILED), + flmErrorCodeEntry( NE_XFLM_INJECT_KEY_FAILED), + flmErrorCodeEntry( NE_XFLM_NICI_FIND_INIT), + flmErrorCodeEntry( NE_XFLM_NICI_FIND_OBJECT), + flmErrorCodeEntry( NE_XFLM_NICI_KEY_NOT_FOUND), + flmErrorCodeEntry( NE_XFLM_NICI_ENC_INIT_FAILED), + flmErrorCodeEntry( NE_XFLM_NICI_ENCRYPT_FAILED), + flmErrorCodeEntry( NE_XFLM_NICI_DECRYPT_INIT_FAILED), + flmErrorCodeEntry( NE_XFLM_NICI_DECRYPT_FAILED), + flmErrorCodeEntry( NE_XFLM_NICI_WRAPKEY_NOT_FOUND), + flmErrorCodeEntry( NE_XFLM_NOT_EXPECTING_PASSWORD), + flmErrorCodeEntry( NE_XFLM_EXPECTING_PASSWORD), + flmErrorCodeEntry( NE_XFLM_EXTRACT_KEY_FAILED), + flmErrorCodeEntry( NE_XFLM_NICI_INIT_FAILED), + flmErrorCodeEntry( NE_XFLM_BAD_ENCKEY_SIZE), + flmErrorCodeEntry( NE_XFLM_ENCRYPTION_UNAVAILABLE) +}; + +/**************************************************************************** +Desc: +****************************************************************************/ +char * FlmCorruptStrings[ FLM_NUM_CORRUPT_ERRORS] = +{ + "BAD_CHAR", /*1*/ + "BAD_ASIAN_CHAR", /*2*/ + "BAD_CHAR_SET", /*3*/ + "BAD_TEXT_FIELD", /*4*/ + "BAD_NUMBER_FIELD", /*5*/ + "BAD_FIELD_TYPE", /*6*/ + "BAD_IX_DEF", /*7*/ + "MISSING_REQ_KEY_FIELD", /*8*/ + "BAD_TEXT_KEY_COLL_CHAR", /*9*/ + "BAD_TEXT_KEY_CASE_MARKER", /*10*/ + "BAD_NUMBER_KEY", /*11*/ + "BAD_BINARY_KEY", /*12*/ + "BAD_CONTEXT_KEY", /*13*/ + "BAD_KEY_FIELD_TYPE", /*14*/ + "Not_Used_15", /*15*/ + "Not_Used_16", /*16*/ + "Not_Used_17", /*17*/ + "BAD_KEY_LEN", /*18*/ + "BAD_LFH_LIST_PTR", /*19*/ + "BAD_LFH_LIST_END", /*20*/ + "INCOMPLETE_NODE", /*21*/ + "BAD_BLK_END", /*22*/ + "KEY_COUNT_MISMATCH", /*23*/ + "REF_COUNT_MISMATCH", /*24*/ + "BAD_CONTAINER_IN_KEY", /*25*/ + "BAD_BLK_HDR_ADDR", /*26*/ + "BAD_BLK_HDR_LEVEL", /*27*/ + "BAD_BLK_HDR_PREV", /*28*/ + +// WARNING: ANY CHANGES MADE TO THE FlmCorruptStrings TABLE MUST BE +// REFLECTED IN THE CHECK CODE DEFINES FOUND IN flaimsys.h + + "BAD_BLK_HDR_NEXT", /*29*/ + "BAD_BLK_HDR_TYPE", /*30*/ + "BAD_BLK_HDR_ROOT_BIT", /*31*/ + "BAD_BLK_HDR_BLK_END", /*32*/ + "BAD_BLK_HDR_LF_NUM", /*33*/ + "BAD_AVAIL_LIST_END", /*34*/ + "BAD_PREV_BLK_NEXT", /*35*/ + "BAD_FIRST_LAST_ELM_FLAG", /*36*/ + "nu", /*37*/ + "BAD_LEM", /*38*/ + "BAD_ELM_LEN", /*39*/ + "BAD_ELM_KEY_SIZE", /*40*/ + "BAD_ELM_KEY", /*41*/ + "BAD_ELM_KEY_ORDER", /*42*/ + "nu", /*43*/ + "BAD_CONT_ELM_KEY", /*44*/ + "NON_UNIQUE_FIRST_ELM_KEY", /*45*/ + "BAD_ELM_OFFSET", /*46*/ + "BAD_ELM_INVALID_LEVEL", /*47*/ + "BAD_ELM_FLD_NUM", /*48*/ + "BAD_ELM_FLD_LEN", /*49*/ + "BAD_ELM_FLD_TYPE", /*50*/ + "BAD_ELM_END", /*51*/ + "BAD_PARENT_KEY", /*52*/ + "BAD_ELM_DOMAIN_SEN", /*53*/ + "BAD_ELM_BASE_SEN", /*54*/ + "BAD_ELM_IX_REF", /*55*/ + "BAD_ELM_ONE_RUN_SEN", /*56*/ + "BAD_ELM_DELTA_SEN", /*57*/ + "BAD_ELM_DOMAIN", /*58*/ + +// WARNING: ANY CHANGES MADE TO THE FlmCorruptStrings TABLE MUST BE +// REFLECTED IN THE CHECK CODE DEFINES FOUND IN flaimsys.h + + "BAD_LAST_BLK_NEXT", /*59*/ + "BAD_FIELD_PTR", /*60*/ + "REBUILD_REC_EXISTS", /*61*/ + "REBUILD_KEY_NOT_UNIQUE", /*62*/ + "NON_UNIQUE_ELM_KEY_REF", /*63*/ + "OLD_VIEW", /*64*/ + "COULD_NOT_SYNC_BLK", /*65*/ + "IX_REF_REC_NOT_FOUND", /*66*/ + "IX_KEY_NOT_FOUND_IN_REC", /*67*/ + "KEY_NOT_IN_KEY_REFSET", /*68*/ + "BAD_BLK_CHECKSUM", /*69*/ + "BAD_LAST_DRN", /*70*/ + "BAD_FILE_SIZE", /*71*/ + "nu", /*72*/ + "BAD_DATE_FIELD", /*73*/ + "BAD_TIME_FIELD", /*74*/ + "BAD_TMSTAMP_FIELD", /*75*/ + "BAD_DATE_KEY", /*76*/ + "BAD_TIME_KEY", /*77*/ + "BAD_TMSTAMP_KEY", /*78*/ + "BAD_BLOB_FIELD", /*79*/ + +// WARNING: ANY CHANGES MADE TO THE FlmCorruptStrings TABLE MUST BE +// REFLECTED IN THE CHECK CODE DEFINES FOUND IN flaimsys.h + + "BAD_PCODE_IXD_TBL", /*80*/ + "NODE_QUARANTINED", /*81*/ + "BAD_BLK_TYPE", /*82*/ + "BAD_ELEMENT_CHAIN", /*83*/ + "BAD_ELM_EXTR_DATA", /*84*/ + "BAD_BLOCK_STRUCTURE", /*85*/ + "BAD_ROOT_PARENT", /*86*/ + "BAD_ROOT_LINK", /*87*/ + "BAD_PARENT_LINK", /*88*/ + "BAD_INVALID_ROOT", /*89*/ + "BAD_FIRST_CHILD_LINK", /*90*/ + "BAD_LAST_CHILD_LINK", /*91*/ + "BAD_PREV_SIBLING_LINK", /*92*/ + "BAD_NEXT_SIBLING_LINK", /*93*/ + "BAD_ANNOTATION_LINK", /*95*/ + "UNSUPPORTED_NODE_TYPE", /*96*/ + "BAD_INVALID_NAME_ID", /*97*/ + "BAD_INVALID_PREFIX_ID", /*98*/ + "BAD_DATA_BLOCK_COUNT", /*99*/ + "FLM_BAD_AVAIL_SIZE", /*100*/ + "BAD_NODE_TYPE", /*101*/ + "BAD_CHILD_ELM_COUNT", /*102*/ +}; + /**************************************************************************** Desc: The primary purpose of this function is to provide a way to easily trap errors when they occur. Just put a breakpoint in this function @@ -53,7 +419,7 @@ RCODE flmMakeErr( break; case NE_XFLM_EOF_HIT: break; - case NE_XFLM_END: + case NE_XFLM_RFL_END: break; case NE_XFLM_EXISTS: break; @@ -66,7 +432,7 @@ RCODE flmMakeErr( switch(rc) { - case NE_XFLM_IO_BAD_FILE_HANDLE: + case NE_FLM_IO_BAD_FILE_HANDLE: break; case NE_XFLM_DATA_ERROR: flmLogError( rc, "", pszFile, iLine); @@ -124,3 +490,134 @@ Exit: return( 0); } #endif + +/**************************************************************************** +Desc: Returns a pointer to the string representation of a corruption + error code. +****************************************************************************/ +const char * FLMAPI F_DbSystem::checkErrorToStr( + FLMINT iCheckErrorCode) +{ + if( (iCheckErrorCode >= 1) && (iCheckErrorCode <= FLM_NUM_CORRUPT_ERRORS)) + { + return( FlmCorruptStrings [iCheckErrorCode - 1]); + } + else if( iCheckErrorCode == 0) + { + return( "OK"); + } + else + { + return( "Unknown Error"); + } +} + +/**************************************************************************** +Desc: Returns a pointer to the ASCII string representation + of a return code. +****************************************************************************/ +const char * F_DbSystem::errorString( + RCODE rc) +{ + const char * pszErrorStr; + + if( rc == NE_XFLM_OK) + { + pszErrorStr = "NE_XFLM_OK"; + } + else if( f_isToolkitError( rc)) + { + pszErrorStr = f_errorString( rc); + } + else if( rc > NE_XFLM_FIRST_GENERAL_ERROR && + rc < NE_XFLM_LAST_GENERAL_ERROR) + { + pszErrorStr = gv_FlmGeneralErrors[ + rc - NE_XFLM_FIRST_GENERAL_ERROR - 1].pszErrorStr; + } + else if( rc > NE_XFLM_FIRST_DOM_ERROR && + rc < NE_XFLM_LAST_DOM_ERROR) + { + pszErrorStr = gv_FlmDomErrors[ + rc - NE_XFLM_FIRST_DOM_ERROR - 1].pszErrorStr; + } + else if( rc > NE_XFLM_FIRST_QUERY_ERROR && + rc < NE_XFLM_LAST_QUERY_ERROR) + { + pszErrorStr = gv_FlmQueryErrors[ + rc - NE_XFLM_FIRST_QUERY_ERROR - 1].pszErrorStr; + } + else if( rc > NE_XFLM_FIRST_NICI_ERROR && + rc < NE_XFLM_LAST_NICI_ERROR) + { + pszErrorStr = gv_FlmNiciErrors[ + rc - NE_XFLM_FIRST_NICI_ERROR - 1].pszErrorStr; + } + else + { + pszErrorStr = "Unknown error"; + } + + return( pszErrorStr); +} + +/**************************************************************************** +Desc: Checks the error code mapping tables on startup +****************************************************************************/ +RCODE F_DbSystem::checkErrorCodeTables( void) +{ + RCODE rc = NE_XFLM_OK; + FLMUINT uiLoop; + + for( uiLoop = 0; + uiLoop < (NE_XFLM_LAST_GENERAL_ERROR - NE_XFLM_FIRST_GENERAL_ERROR - 1); + uiLoop++) + { + if( gv_FlmGeneralErrors[ uiLoop].rc != + (RCODE)(uiLoop + NE_XFLM_FIRST_GENERAL_ERROR + 1)) + { + rc = RC_SET_AND_ASSERT( NE_XFLM_BAD_RCODE_TABLE); + goto Exit; + } + } + + for( uiLoop = 0; + uiLoop < (NE_XFLM_LAST_DOM_ERROR - NE_XFLM_FIRST_DOM_ERROR - 1); + uiLoop++) + { + if( gv_FlmDomErrors[ uiLoop].rc != + (RCODE)(uiLoop + NE_XFLM_FIRST_DOM_ERROR + 1)) + { + rc = RC_SET_AND_ASSERT( NE_XFLM_BAD_RCODE_TABLE); + goto Exit; + } + } + + for( uiLoop = 0; + uiLoop < (NE_XFLM_LAST_QUERY_ERROR - NE_XFLM_FIRST_QUERY_ERROR - 1); + uiLoop++) + { + if( gv_FlmQueryErrors[ uiLoop].rc != + (RCODE)(uiLoop + NE_XFLM_FIRST_QUERY_ERROR + 1)) + { + rc = RC_SET_AND_ASSERT( NE_XFLM_BAD_RCODE_TABLE); + goto Exit; + } + } + + for( uiLoop = 0; + uiLoop < (NE_XFLM_LAST_NICI_ERROR - NE_XFLM_FIRST_NICI_ERROR - 1); + uiLoop++) + { + if( gv_FlmNiciErrors[ uiLoop].rc != + (RCODE)(uiLoop + NE_XFLM_FIRST_NICI_ERROR + 1)) + { + rc = RC_SET_AND_ASSERT( NE_XFLM_BAD_RCODE_TABLE); + goto Exit; + } + } + +Exit: + + return( rc); +} diff --git a/xflaim/src/flerrstr.cpp b/xflaim/src/flerrstr.cpp deleted file mode 100644 index 13c19b2..0000000 --- a/xflaim/src/flerrstr.cpp +++ /dev/null @@ -1,176 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: This module contains the checkErrorToStr method - which returns -// a pointer to a string which corresponds to a corruption code. -// -// Tabs: 3 -// -// Copyright (c) 1992-1997,2000-2003,2005-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: flerrstr.cpp 3113 2006-01-19 13:20:35 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -// WARNING: ANY CHANGES MADE TO THE FlmCorruptStrings TABLE MUST BE -// REFLECTED IN THE CHECK CODE DEFINES FOUND IN flaimsys.h - -char * FlmCorruptStrings[ FLM_NUM_CORRUPT_ERRORS] -= { - "BAD_CHAR", /*1*/ - "BAD_ASIAN_CHAR", /*2*/ - "BAD_CHAR_SET", /*3*/ - "BAD_TEXT_FIELD", /*4*/ - "BAD_NUMBER_FIELD", /*5*/ - "BAD_FIELD_TYPE", /*6*/ - "BAD_IX_DEF", /*7*/ - "MISSING_REQ_KEY_FIELD", /*8*/ - "BAD_TEXT_KEY_COLL_CHAR", /*9*/ - "BAD_TEXT_KEY_CASE_MARKER", /*10*/ - "BAD_NUMBER_KEY", /*11*/ - "BAD_BINARY_KEY", /*12*/ - "BAD_CONTEXT_KEY", /*13*/ - "BAD_KEY_FIELD_TYPE", /*14*/ - "Not_Used_15", /*15*/ - "Not_Used_16", /*16*/ - "Not_Used_17", /*17*/ - "BAD_KEY_LEN", /*18*/ - "BAD_LFH_LIST_PTR", /*19*/ - "BAD_LFH_LIST_END", /*20*/ - "INCOMPLETE_NODE", /*21*/ - "BAD_BLK_END", /*22*/ - "KEY_COUNT_MISMATCH", /*23*/ - "REF_COUNT_MISMATCH", /*24*/ - "BAD_CONTAINER_IN_KEY", /*25*/ - "BAD_BLK_HDR_ADDR", /*26*/ - "BAD_BLK_HDR_LEVEL", /*27*/ - "BAD_BLK_HDR_PREV", /*28*/ - -// WARNING: ANY CHANGES MADE TO THE FlmCorruptStrings TABLE MUST BE -// REFLECTED IN THE CHECK CODE DEFINES FOUND IN flaimsys.h - - "BAD_BLK_HDR_NEXT", /*29*/ - "BAD_BLK_HDR_TYPE", /*30*/ - "BAD_BLK_HDR_ROOT_BIT", /*31*/ - "BAD_BLK_HDR_BLK_END", /*32*/ - "BAD_BLK_HDR_LF_NUM", /*33*/ - "BAD_AVAIL_LIST_END", /*34*/ - "BAD_PREV_BLK_NEXT", /*35*/ - "BAD_FIRST_LAST_ELM_FLAG", /*36*/ - "nu", /*37*/ - "BAD_LEM", /*38*/ - "BAD_ELM_LEN", /*39*/ - "BAD_ELM_KEY_SIZE", /*40*/ - "BAD_ELM_KEY", /*41*/ - "BAD_ELM_KEY_ORDER", /*42*/ - "nu", /*43*/ - "BAD_CONT_ELM_KEY", /*44*/ - "NON_UNIQUE_FIRST_ELM_KEY", /*45*/ - "BAD_ELM_OFFSET", /*46*/ - "BAD_ELM_INVALID_LEVEL", /*47*/ - "BAD_ELM_FLD_NUM", /*48*/ - "BAD_ELM_FLD_LEN", /*49*/ - "BAD_ELM_FLD_TYPE", /*50*/ - "BAD_ELM_END", /*51*/ - "BAD_PARENT_KEY", /*52*/ - "BAD_ELM_DOMAIN_SEN", /*53*/ - "BAD_ELM_BASE_SEN", /*54*/ - "BAD_ELM_IX_REF", /*55*/ - "BAD_ELM_ONE_RUN_SEN", /*56*/ - "BAD_ELM_DELTA_SEN", /*57*/ - "BAD_ELM_DOMAIN", /*58*/ - -// WARNING: ANY CHANGES MADE TO THE FlmCorruptStrings TABLE MUST BE -// REFLECTED IN THE CHECK CODE DEFINES FOUND IN flaimsys.h - - "BAD_LAST_BLK_NEXT", /*59*/ - "BAD_FIELD_PTR", /*60*/ - "REBUILD_REC_EXISTS", /*61*/ - "REBUILD_KEY_NOT_UNIQUE", /*62*/ - "NON_UNIQUE_ELM_KEY_REF", /*63*/ - "OLD_VIEW", /*64*/ - "COULD_NOT_SYNC_BLK", /*65*/ - "IX_REF_REC_NOT_FOUND", /*66*/ - "IX_KEY_NOT_FOUND_IN_REC", /*67*/ - "KEY_NOT_IN_KEY_REFSET", /*68*/ - "BAD_BLK_CHECKSUM", /*69*/ - "BAD_LAST_DRN", /*70*/ - "BAD_FILE_SIZE", /*71*/ - "nu", /*72*/ - "BAD_DATE_FIELD", /*73*/ - "BAD_TIME_FIELD", /*74*/ - "BAD_TMSTAMP_FIELD", /*75*/ - "BAD_DATE_KEY", /*76*/ - "BAD_TIME_KEY", /*77*/ - "BAD_TMSTAMP_KEY", /*78*/ - "BAD_BLOB_FIELD", /*79*/ - -// WARNING: ANY CHANGES MADE TO THE FlmCorruptStrings TABLE MUST BE -// REFLECTED IN THE CHECK CODE DEFINES FOUND IN flaimsys.h - - "BAD_PCODE_IXD_TBL", /*80*/ - "NODE_QUARANTINED", /*81*/ - "BAD_BLK_TYPE", /*82*/ - "BAD_ELEMENT_CHAIN", /*83*/ - "BAD_ELM_EXTR_DATA", /*84*/ - "BAD_BLOCK_STRUCTURE", /*85*/ - "BAD_ROOT_PARENT", /*86*/ - "BAD_ROOT_LINK", /*87*/ - "BAD_PARENT_LINK", /*88*/ - "BAD_INVALID_ROOT", /*89*/ - "BAD_FIRST_CHILD_LINK", /*90*/ - "BAD_LAST_CHILD_LINK", /*91*/ - "BAD_PREV_SIBLING_LINK", /*92*/ - "BAD_NEXT_SIBLING_LINK", /*93*/ - "BAD_ANNOTATION_LINK", /*95*/ - "UNSUPPORTED_NODE_TYPE", /*96*/ - "BAD_INVALID_NAME_ID", /*97*/ - "BAD_INVALID_PREFIX_ID", /*98*/ - "BAD_DATA_BLOCK_COUNT", /*99*/ - "FLM_BAD_AVAIL_SIZE", /*100*/ - "BAD_NODE_TYPE", /*101*/ - "BAD_CHILD_ELM_COUNT", /*102*/ - }; - -// WARNING: ANY CHANGES MADE TO THE FlmCorruptStrings TABLE MUST BE -// REFLECTED IN THE CHECK CODE DEFINES FOUND IN flaimsys.h - - - -/*API~*********************************************************************** -Area : INFORMATION -Desc : Returns a pointer to the string representation of a corruption - error code. -Notes: Linking in this routine will bring in static string arrays. -*END************************************************************************/ -const char * XFLMAPI F_DbSystem::checkErrorToStr( - FLMINT iCheckErrorCode) -{ - if( (iCheckErrorCode >= 1) && (iCheckErrorCode <= FLM_NUM_CORRUPT_ERRORS)) - { - return( FlmCorruptStrings [iCheckErrorCode - 1]); - } - else if( iCheckErrorCode == 0) - { - return( "OK"); - } - else - { - return( "Unknown Error"); - } -} - diff --git a/xflaim/src/flfixed.cpp b/xflaim/src/flfixed.cpp deleted file mode 100644 index 2351055..0000000 --- a/xflaim/src/flfixed.cpp +++ /dev/null @@ -1,2502 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Special allocators for making many fixed-size allocations. -// -// Tabs: 3 -// -// Copyright (c) 2004-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: flfixed.cpp 3113 2006-01-19 13:20:35 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -#ifdef FLM_SOLARIS - #include -#endif - -#ifdef FLM_NLM - extern "C" - { - extern LONG gv_lAllocRTag; - } -#endif - -/**************************************************************************** -Desc: -****************************************************************************/ -F_SlabManager::F_SlabManager() -{ - m_hMutex = F_MUTEX_NULL; - m_uiTotalBytesAllocated = 0; - m_pFirstInSlabList = NULL; - m_pLastInSlabList = NULL; - m_uiTotalSlabs = 0; - m_uiAvailSlabs = 0; - m_uiInUseSlabs = 0; - m_uiPreallocSlabs = 0; -#ifdef FLM_SOLARIS - m_DevZero = -1; -#endif -} - -/**************************************************************************** -Desc: -****************************************************************************/ -F_SlabManager::~F_SlabManager() -{ - - flmAssert( !m_uiInUseSlabs); - flmAssert( m_uiAvailSlabs == m_uiTotalSlabs); - - freeAllSlabs(); - - flmAssert( !m_uiTotalBytesAllocated); - - if( m_hMutex != F_MUTEX_NULL) - { - f_mutexDestroy( &m_hMutex); - } - -#ifdef FLM_SOLARIS - if( m_DevZero > 0) - { - close( m_DevZero); - } -#endif -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE F_SlabManager::setup( - FLMUINT uiPreallocSize) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiSysSlabSize = 0; - FLMUINT uiSlabSize = 64 * 1024; - - if( RC_BAD( rc = f_mutexCreate( &m_hMutex))) - { - goto Exit; - } - - // Determine the slab size - -#ifdef FLM_WIN - { - SYSTEM_INFO sysInfo; - - GetSystemInfo( &sysInfo); - uiSysSlabSize = sysInfo.dwAllocationGranularity; - } -#endif - -#ifdef FLM_SOLARIS - if( (m_DevZero = open( "/dev/zero", O_RDWR)) == -1) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } -#endif - - if( !uiSysSlabSize) - { - uiSysSlabSize = uiSlabSize; - } - - // Round the given slab size up to the closest operating - // system slab size so we don't waste any memory. - - if( uiSlabSize % uiSysSlabSize) - { - m_uiSlabSize = ((uiSlabSize / uiSysSlabSize) + 1) * uiSysSlabSize; - } - else - { - m_uiSlabSize = uiSlabSize; - } - - // Pre-allocate the requested amount of memory from the system - - if( uiPreallocSize) - { - lockMutex(); - - if( RC_BAD( rc = resize( uiPreallocSize, NULL, TRUE))) - { - goto Exit; - } - - unlockMutex(); - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE F_SlabManager::resize( - FLMUINT uiNumBytes, - FLMUINT * puiActualSize, - FLMBOOL bMutexLocked) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiSlabsNeeded; - void * pSlab; - FLMBOOL bUnlockMutex = FALSE; - - if( !bMutexLocked) - { - lockMutex(); - bUnlockMutex = TRUE; - } - - if( puiActualSize) - { - *puiActualSize = 0; - } - - uiSlabsNeeded = (uiNumBytes / m_uiSlabSize) + - ((uiNumBytes % m_uiSlabSize) ? 1 : 0); - - if( !uiSlabsNeeded && !m_uiInUseSlabs) - { - freeAllSlabs(); - } - else if( m_uiTotalSlabs > uiSlabsNeeded) - { - // Do the best we can to free slabs. We can only get rid of - // slabs that aren't in use. - - if( RC_BAD( rc = sortSlabList())) - { - goto Exit; - } - - while( m_pLastInSlabList && m_uiTotalSlabs > uiSlabsNeeded) - { - pSlab = m_pLastInSlabList; - if( (m_pLastInSlabList = ((SLABHEADER *)pSlab)->pPrev) != NULL) - { - ((SLABHEADER *)m_pLastInSlabList)->pNext = NULL; - } - else - { - m_pFirstInSlabList = NULL; - } - - releaseSlabToSystem( pSlab); - - flmAssert( m_uiTotalSlabs); - flmAssert( m_uiInUseSlabs); - - m_uiAvailSlabs--; - m_uiTotalSlabs--; - } - } - else - { - // Allocate the required number of slabs - - while( m_uiTotalSlabs < uiSlabsNeeded) - { - if( (pSlab = allocSlabFromSystem()) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - // Touch every byte in the slab so that the operating system is - // forced to immediately assign physical memory. - - f_memset( pSlab, 0, m_uiSlabSize); - - // Link the slab into the avail list - - if( m_pFirstInSlabList) - { - ((SLABHEADER *)m_pFirstInSlabList)->pPrev = pSlab; - } - - ((SLABHEADER *)pSlab)->pNext = m_pFirstInSlabList; - m_pFirstInSlabList = pSlab; - - if( !m_pLastInSlabList) - { - m_pLastInSlabList = pSlab; - } - - m_uiTotalSlabs++; - m_uiAvailSlabs++; - } - } - - if( puiActualSize) - { - *puiActualSize = m_uiTotalSlabs * m_uiSlabSize; - } - - m_uiPreallocSlabs = m_uiTotalSlabs; - -Exit: - - if( RC_BAD( rc)) - { - freeAllSlabs(); - } - - if( bUnlockMutex) - { - unlockMutex(); - } - - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE F_SlabManager::allocSlab( - void ** ppSlab, - FLMBOOL bMutexLocked) -{ - RCODE rc = NE_XFLM_OK; - FLMBOOL bUnlockMutex = FALSE; - - if( !bMutexLocked) - { - lockMutex(); - bUnlockMutex = TRUE; - } - - if( m_pFirstInSlabList) - { - *ppSlab = m_pFirstInSlabList; - if( (m_pFirstInSlabList = - ((SLABHEADER *)m_pFirstInSlabList)->pNext) != NULL) - { - ((SLABHEADER *)m_pFirstInSlabList)->pPrev = NULL; - } - else - { - m_pLastInSlabList = NULL; - } - - ((SLABHEADER *)*ppSlab)->pNext = NULL; - - flmAssert( m_uiAvailSlabs); - m_uiAvailSlabs--; - m_uiInUseSlabs++; - } - else - { - flmAssert( !m_uiAvailSlabs); - - if( (*ppSlab = allocSlabFromSystem()) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - m_uiTotalSlabs++; - m_uiInUseSlabs++; - } - -Exit: - - if( bUnlockMutex) - { - unlockMutex(); - } - - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void F_SlabManager::freeSlab( - void ** ppSlab, - FLMBOOL bMutexLocked) -{ - FLMBOOL bUnlockMutex = FALSE; - - flmAssert( ppSlab && *ppSlab); - - if( !bMutexLocked) - { - lockMutex(); - bUnlockMutex = TRUE; - } - - if( m_uiTotalSlabs <= m_uiPreallocSlabs) - { - ((SLABHEADER *)*ppSlab)->pPrev = NULL; - if( (((SLABHEADER *)*ppSlab)->pNext = m_pFirstInSlabList) != NULL) - { - ((SLABHEADER *)m_pFirstInSlabList)->pPrev = *ppSlab; - } - else - { - m_pLastInSlabList = *ppSlab; - } - - m_pFirstInSlabList = *ppSlab; - *ppSlab = NULL; - - flmAssert( m_uiInUseSlabs); - m_uiInUseSlabs--; - m_uiAvailSlabs++; - } - else - { - releaseSlabToSystem( *ppSlab); - *ppSlab = NULL; - - flmAssert( m_uiTotalSlabs); - flmAssert( m_uiInUseSlabs); - - m_uiTotalSlabs--; - m_uiInUseSlabs--; - } - - if( bUnlockMutex) - { - unlockMutex(); - } -} - -/**************************************************************************** -Desc: Assumes that the mutex is locked -****************************************************************************/ -void F_SlabManager::freeAllSlabs( void) -{ - void * pNextSlab; - SLABHEADER * pSlabHeader; - - while( m_pFirstInSlabList) - { - pSlabHeader = (SLABHEADER *)m_pFirstInSlabList; - pNextSlab = pSlabHeader->pNext; - releaseSlabToSystem( m_pFirstInSlabList); - m_pFirstInSlabList = pNextSlab; - m_uiTotalSlabs--; - m_uiAvailSlabs--; - } - - flmAssert( !m_uiAvailSlabs); - m_pLastInSlabList = NULL; -} - -/**************************************************************************** -Desc: Assumes that the mutex is locked -****************************************************************************/ -void * F_SlabManager::allocSlabFromSystem( void) -{ - void * pSlab; - -#ifdef FLM_WIN - pSlab = VirtualAlloc( NULL, - (DWORD)m_uiSlabSize, MEM_COMMIT, PAGE_READWRITE); -#elif defined( FLM_SOLARIS) - if( (pSlab = mmap( 0, m_uiSlabSize, - PROT_READ | PROT_WRITE, MAP_PRIVATE, m_DevZero, 0)) == MAP_FAILED) - { - return( NULL); - } -#elif defined( FLM_UNIX) - -#ifndef MAP_ANONYMOUS - #define MAP_ANONYMOUS MAP_ANON -#endif - - if( (pSlab = mmap( 0, m_uiSlabSize, - PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0)) == MAP_FAILED) - { - return( NULL); - } -#else - if( RC_BAD( f_alloc( m_uiSlabSize, &pSlab))) - { - return( NULL); - } -#endif - - incrementTotalBytesAllocated( m_uiSlabSize, TRUE); - - return( pSlab); -} - -/**************************************************************************** -Desc: Assumes that the mutex is locked -****************************************************************************/ -void F_SlabManager::releaseSlabToSystem( - void * pSlab) -{ - flmAssert( pSlab); - -#ifdef FLM_WIN - VirtualFree( pSlab, 0, MEM_RELEASE); -#elif defined( FLM_SOLARIS) - munmap( (char *)pSlab, m_uiSlabSize); -#elif defined( FLM_UNIX) - munmap( pSlab, m_uiSlabSize); -#else - f_free( &pSlab); -#endif - - decrementTotalBytesAllocated( m_uiSlabSize, TRUE); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -#ifdef FLM_CACHE_PROTECT -void F_SlabManager::protectSlab( - void * pSlab) -{ -#ifdef FLM_WIN - (void)pSlab; - DWORD dOldProtect; - VirtualProtect( pSlab, m_uiSlabSize, PAGE_READONLY, &dOldProtect); - flmAssert( dOldProtect == PAGE_READWRITE); -#elif defined( FLM_UNIX) - mprotect( pSlab, m_uiSlabSize, PROT_READ); -#endif -} -#endif - -/**************************************************************************** -Desc: -****************************************************************************/ -#ifdef FLM_CACHE_PROTECT -void F_SlabManager::unprotectSlab( - void * pSlab) -{ -#ifdef FLM_WIN - (void)pSlab; - DWORD dOldProtect; - VirtualProtect( pSlab, m_uiSlabSize, PAGE_READWRITE, &dOldProtect); - flmAssert( dOldProtect == PAGE_READONLY); -#elif defined( FLM_UNIX) - mprotect( pSlab, m_uiSlabSize, PROT_READ | PROT_WRITE); -#endif -} -#endif - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMINT F_SlabManager::slabAddrCompareFunc( - void * pvBuffer, - FLMUINT uiPos1, - FLMUINT uiPos2) -{ - void * pSlab1 = (((void **)pvBuffer)[ uiPos1]); - void * pSlab2 = (((void **)pvBuffer)[ uiPos2]); - - flmAssert( pSlab1 != pSlab2); - - if( pSlab1 < pSlab2) - { - return( -1); - } - - return( 1); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void F_SlabManager::slabAddrSwapFunc( - void * pvBuffer, - FLMUINT uiPos1, - FLMUINT uiPos2) -{ - void ** ppSlab1 = &(((void **)pvBuffer)[ uiPos1]); - void ** ppSlab2 = &(((void **)pvBuffer)[ uiPos2]); - void * pTmp; - - pTmp = *ppSlab1; - *ppSlab1 = *ppSlab2; - *ppSlab2 = pTmp; -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE F_SlabManager::sortSlabList( void) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiLoop; - void ** pSortBuf = NULL; - FLMUINT uiMaxSortEntries; - FLMUINT uiSortEntries = 0; -#define SMALL_SORT_BUF_SIZE 256 - void * smallSortBuf[ SMALL_SORT_BUF_SIZE]; - void * pCurSlab; - void * pPrevSib; - - if( m_uiAvailSlabs <= 1) - { - goto Exit; - } - - uiMaxSortEntries = m_uiAvailSlabs; - - // Sort the avail list according to the starting memory addresses of the - // slabs - - if( uiMaxSortEntries <= SMALL_SORT_BUF_SIZE) - { - pSortBuf = smallSortBuf; - } - else - { - if( RC_BAD( rc = f_alloc( uiMaxSortEntries * sizeof( void *), &pSortBuf))) - { - goto Exit; - } - } - - pCurSlab = m_pFirstInSlabList; - - while( pCurSlab) - { - flmAssert( uiSortEntries != uiMaxSortEntries); - pSortBuf[ uiSortEntries++] = pCurSlab; - pCurSlab = ((SLABHEADER *)pCurSlab)->pNext; - } - - flmAssert( uiSortEntries == uiMaxSortEntries); - - // Quick sort - - flmAssert( uiSortEntries); - - f_qsort( (FLMBYTE *)pSortBuf, 0, uiSortEntries - 1, - F_SlabManager::slabAddrCompareFunc, - F_SlabManager::slabAddrSwapFunc); - - // Re-link the items in the list according to the new - // sort order - - m_pFirstInSlabList = NULL; - m_pLastInSlabList = NULL; - - pCurSlab = NULL; - pPrevSib = NULL; - - for( uiLoop = 0; uiLoop < uiSortEntries; uiLoop++) - { - pCurSlab = pSortBuf[ uiLoop]; - ((SLABHEADER *)pCurSlab)->pNext = NULL; - ((SLABHEADER *)pCurSlab)->pPrev = NULL; - - if( pPrevSib) - { - ((SLABHEADER *)pCurSlab)->pPrev = pPrevSib; - ((SLABHEADER *)pPrevSib)->pNext = pCurSlab; - } - else - { - m_pFirstInSlabList = pCurSlab; - } - - pPrevSib = pCurSlab; - } - - m_pLastInSlabList = pCurSlab; - -Exit: - - if( pSortBuf && pSortBuf != smallSortBuf) - { - f_free( &pSortBuf); - } - - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -F_FixedAlloc::F_FixedAlloc() -{ - m_pSlabManager = NULL; - m_pFirstSlab = NULL; - m_pLastSlab = NULL; - m_pRelocator = NULL; - m_pFirstSlabWithAvailCells = NULL; - m_pLastSlabWithAvailCells = NULL; - m_uiSlabsWithAvailCells = 0; - m_bAvailListSorted = TRUE; - m_uiTotalFreeCells = 0; - m_uiSlabSize = 0; - m_pUsageStats = NULL; - -#ifdef FLM_CACHE_PROTECT - m_bMemProtectionEnabled = FALSE; -#endif -} - -/**************************************************************************** -Desc: Destructor for F_FixedAlloc. checks for memory leaks, and - frees all memory in use. -****************************************************************************/ -F_FixedAlloc::~F_FixedAlloc() -{ -#ifdef FLM_DEBUG - testForLeaks(); -#endif - - freeAll(); - - if( m_pSlabManager) - { - m_pSlabManager->Release(); - } -} - -/**************************************************************************** -Desc: Setup method for any setup that can fail -****************************************************************************/ -RCODE F_FixedAlloc::setup( - IF_Relocator * pRelocator, - F_SlabManager * pSlabManager, - FLMBOOL bMemProtect, - FLMUINT uiCellSize, - XFLM_SLAB_USAGE * pUsageStats) -{ - RCODE rc = NE_XFLM_OK; - - flmAssert( pSlabManager); - flmAssert( uiCellSize); - flmAssert( pUsageStats != NULL); - - m_pUsageStats = pUsageStats; - m_pSlabManager = pSlabManager; - m_pSlabManager->AddRef(); - m_pRelocator = pRelocator; - m_uiCellSize = uiCellSize; - m_uiSlabSize = m_pSlabManager->getSlabSize(); - - // Get the alloc-aligned versions of all the sizes - - m_uiSlabHeaderSize = getAllocAlignedSize( sizeof( SLAB)); - if (pRelocator) - { - m_uiCellHeaderSize = getAllocAlignedSize( sizeof( CELLHEADER)); - } - else - { - m_uiCellHeaderSize = getAllocAlignedSize( sizeof( CELLHEADER2)); - } - m_uiCellSize = getAllocAlignedSize( m_uiCellSize); - - // Ensure that there's enough space for our overhead - - flmAssert( m_uiCellSize >= sizeof( CELLAVAILNEXT)); - - m_uiSizeOfCellAndHeader = m_uiCellHeaderSize + m_uiCellSize; - - m_uiCellsPerSlab = - (m_uiSlabSize - m_uiSlabHeaderSize) / - m_uiSizeOfCellAndHeader; - - flmAssert( m_uiCellsPerSlab); - flmAssert( m_uiCellsPerSlab <= FLM_MAX_UINT16); - flmAssert( (m_uiCellsPerSlab * m_uiCellSize) < m_uiSlabSize); - -#ifdef FLM_CACHE_PROTECT - m_bMemProtectionEnabled = bMemProtect; -#else - F_UNREFERENCED_PARM( bMemProtect); -#endif - - return( rc); -} - -/**************************************************************************** -Desc: Private, internal method to fetch a cell -****************************************************************************/ -void * F_FixedAlloc::getCell( - IF_Relocator * pRelocator) -{ - SLAB * pSlab = NULL; - FLMBYTE * pCell = NULL; - CELLHEADER * pHeader; - - // If there's a slab that has an avail cell, that one gets priority - - if( (pSlab = m_pFirstSlabWithAvailCells) != NULL) - { -#ifdef FLM_CACHE_PROTECT - unprotectSlab( pSlab, TRUE); -#endif - - flmAssert( pSlab->ui16AvailCellCount <= m_uiTotalFreeCells); - flmAssert( m_uiTotalFreeCells); - flmAssert( pSlab->ui16AllocatedCells < m_uiCellsPerSlab); - - pCell = m_pFirstSlabWithAvailCells->pLocalAvailCellListHead; - flmAssert( pCell); - - pHeader = (CELLHEADER *)((FLMBYTE *)pCell - m_uiCellHeaderSize); - pSlab->ui16AllocatedCells++; - pSlab->ui16AvailCellCount--; - m_uiTotalFreeCells--; - - // An avail cell holds as its contents the next pointer in the avail chain. - // Avail chains do not span slabs. - - pSlab->pLocalAvailCellListHead = ((CELLAVAILNEXT *)pCell)->pNextInList; - - // If there are no other avail cells in this slab at this point, - // then we need to unlink the slab from the - // slabs-with-avail-cells list, headed by m_pFirstSlabWithAvailCells - - if( !pSlab->pLocalAvailCellListHead) - { - // Save a copy of the slab we're going to unlink - - SLAB * pSlabToUnlink = pSlab; - - // Need to keep the NULLNESS of the content of the cell consistent - // with the slab's ui16AvailCellCount being equal to 0 - - flmAssert( !pSlabToUnlink->ui16AvailCellCount); - - // There can't be a pPrevSlabWithAvailCells since - // we're positioned to the first one - - flmAssert( !pSlabToUnlink->pPrevSlabWithAvailCells); - - // Update m_pFirstSlabWithAvailCells to point to the next one - - if( (m_pFirstSlabWithAvailCells = - pSlabToUnlink->pNextSlabWithAvailCells) == NULL) - { - flmAssert( m_pLastSlabWithAvailCells == pSlabToUnlink); - m_pLastSlabWithAvailCells = NULL; - } - - // Unlink from slabs-with-avail-cells list - - if( pSlabToUnlink->pNextSlabWithAvailCells) - { -#ifdef FLM_CACHE_PROTECT - unprotectSlab( pSlabToUnlink->pNextSlabWithAvailCells, TRUE); -#endif - - pSlabToUnlink-> - pNextSlabWithAvailCells->pPrevSlabWithAvailCells = - pSlabToUnlink->pPrevSlabWithAvailCells; - -#ifdef FLM_CACHE_PROTECT - protectSlab( pSlabToUnlink->pNextSlabWithAvailCells, TRUE); -#endif - pSlabToUnlink->pNextSlabWithAvailCells = NULL; - } - - // Decrement the slab count - - flmAssert( m_uiSlabsWithAvailCells); - m_uiSlabsWithAvailCells--; - } - } - else - { - // If our m_pFirstSlab is completely full, or there is no - // m_pFirstSlab, it is time to allocate a new slab - - if( !m_pFirstSlab || - (m_pFirstSlab->ui16NextNeverUsedCell == m_uiCellsPerSlab)) - { - SLAB * pNewSlab; - - if( (pNewSlab = getAnotherSlab()) == NULL) - { - goto Exit; - } - - if( m_pFirstSlab) - { -#ifdef FLM_CACHE_PROTECT - unprotectSlab( pNewSlab, TRUE); -#endif - pNewSlab->pNext = m_pFirstSlab; -#ifdef FLM_CACHE_PROTECT - protectSlab( pNewSlab, TRUE); -#endif - -#ifdef FLM_CACHE_PROTECT - unprotectSlab( m_pFirstSlab, TRUE); -#endif - m_pFirstSlab->pPrev = pNewSlab; -#ifdef FLM_CACHE_PROTECT - protectSlab( m_pFirstSlab, TRUE); -#endif - } - else - { - m_pLastSlab = pNewSlab; - } - - m_pFirstSlab = pNewSlab; - } - - pSlab = m_pFirstSlab; - -#ifdef FLM_CACHE_PROTECT - unprotectSlab( pSlab, TRUE); -#endif - pSlab->ui16AllocatedCells++; - -#ifdef FLM_CACHE_PROTECT - flmAssert( pSlab->ui16AllocatedCells <= m_uiCellsPerSlab); -#endif - - pHeader = (CELLHEADER *) - ((FLMBYTE *)pSlab + m_uiSlabHeaderSize + - (m_uiSizeOfCellAndHeader * m_pFirstSlab->ui16NextNeverUsedCell)); - - pCell = ((FLMBYTE *)pHeader + m_uiCellHeaderSize); - m_pFirstSlab->ui16NextNeverUsedCell++; - } - - pHeader->pContainingSlab = pSlab; - -#ifdef FLM_DEBUG - if (gv_XFlmSysData.bTrackLeaks && gv_XFlmSysData.bStackWalk) - { - pHeader->puiStack = memWalkStack(); - } - else - { - pHeader->puiStack = NULL; - } -#endif - if (!m_pRelocator) - { - ((CELLHEADER2 *)pHeader)->pRelocator = pRelocator; - } - -#ifdef FLM_CACHE_PROTECT - protectSlab( pSlab, TRUE); -#endif - - m_pUsageStats->ui64AllocatedCells++; - -Exit: - - return( pCell); -} - -/**************************************************************************** -Desc: Public method to free a cell of memory back to the system. -****************************************************************************/ -void F_FixedAlloc::freeCell( - void * pCell, - FLMBOOL bMutexLocked, - FLMBOOL bFreeIfEmpty, - FLMBOOL * pbFreedSlab) -{ - CELLAVAILNEXT * pCellContents; - CELLHEADER * pHeader; - SLAB * pSlab; - FLMBOOL bUnlockMutex = FALSE; -#ifdef FLM_CACHE_PROTECT - FLMBOOL bProtectSlab = FALSE; -#endif - - if( pbFreedSlab) - { - *pbFreedSlab = FALSE; - } - - if( !pCell) - { - return; - } - - if( !bMutexLocked) - { - m_pSlabManager->lockMutex(); - bUnlockMutex = TRUE; - } - - pCellContents = (CELLAVAILNEXT *)pCell; - pHeader = (CELLHEADER *)(((FLMBYTE *)pCell) - m_uiCellHeaderSize); - pSlab = pHeader->pContainingSlab; - - // Memory corruption detected! - - if( !pSlab || pSlab->pvAllocator != (void *)this) - { - flmAssert( 0); - goto Exit; - } - -#ifdef FLM_CACHE_PROTECT - unprotectSlab( pSlab, TRUE); - bProtectSlab = TRUE; -#endif - - pHeader->pContainingSlab = NULL; -#ifdef FLM_DEBUG - if( pHeader->puiStack) - { - os_free( pHeader->puiStack); - pHeader->puiStack = NULL; - } -#endif - - // Should always be set on a free - - flmAssert( m_pFirstSlab); - - // Add the cell to the pSlab's free list - - pCellContents->pNextInList = pSlab->pLocalAvailCellListHead; - -#ifdef FLM_DEBUG - // Write out a string that's easy to see in memory when debugging - - f_strcpy( pCellContents->szDebugPattern, (FLMBYTE*)"FREECELL"); -#endif - - flmAssert( pCell); - pSlab->pLocalAvailCellListHead = (FLMBYTE *)pCell; - pSlab->ui16AvailCellCount++; - - flmAssert( pSlab->ui16AllocatedCells); - pSlab->ui16AllocatedCells--; - - // If there's no chain, make this one the first - - if( !m_pFirstSlabWithAvailCells) - { - m_pFirstSlabWithAvailCells = pSlab; - m_pLastSlabWithAvailCells = pSlab; - flmAssert( !pSlab->pNextSlabWithAvailCells); - flmAssert( !pSlab->pPrevSlabWithAvailCells); - m_uiSlabsWithAvailCells++; - m_bAvailListSorted = TRUE; - } - else if( pSlab->ui16AvailCellCount == 1) - { - // This item is not linked in to the chain, so link it in - - if( m_bAvailListSorted && pSlab > m_pFirstSlabWithAvailCells) - { - m_bAvailListSorted = FALSE; - } - - pSlab->pNextSlabWithAvailCells = m_pFirstSlabWithAvailCells; - pSlab->pPrevSlabWithAvailCells = NULL; - -#ifdef FLM_CACHE_PROTECT - unprotectSlab( m_pFirstSlabWithAvailCells, TRUE); -#endif - m_pFirstSlabWithAvailCells->pPrevSlabWithAvailCells = pSlab; -#ifdef FLM_CACHE_PROTECT - protectSlab( m_pFirstSlabWithAvailCells, TRUE); -#endif - m_pFirstSlabWithAvailCells = pSlab; - m_uiSlabsWithAvailCells++; - } - - // Adjust counter, because the cell is now considered free - - m_uiTotalFreeCells++; - - // If this slab is now totally avail - - if( pSlab->ui16AvailCellCount == m_uiCellsPerSlab) - { - flmAssert( !pSlab->ui16AllocatedCells); - - // If we have met our threshold for being able to free a slab - - if( m_uiTotalFreeCells >= m_uiCellsPerSlab || bFreeIfEmpty) - { -#ifdef FLM_CACHE_PROTECT - protectSlab( pSlab, TRUE); - bProtectSlab = FALSE; -#endif - - freeSlab( pSlab); - - if( pbFreedSlab) - { - *pbFreedSlab = TRUE; - } - } - else if( pSlab != m_pFirstSlabWithAvailCells) - { - // Link the slab to the front of the avail list so that - // it can be freed quickly at some point in the future - - if( pSlab->pPrevSlabWithAvailCells) - { - pSlab->pPrevSlabWithAvailCells->pNextSlabWithAvailCells = - pSlab->pNextSlabWithAvailCells; - } - - if( pSlab->pNextSlabWithAvailCells) - { - pSlab->pNextSlabWithAvailCells->pPrevSlabWithAvailCells = - pSlab->pPrevSlabWithAvailCells; - } - else - { - flmAssert( m_pLastSlabWithAvailCells == pSlab); - m_pLastSlabWithAvailCells = pSlab->pPrevSlabWithAvailCells; - } - - if( m_pFirstSlabWithAvailCells) - { - m_pFirstSlabWithAvailCells->pPrevSlabWithAvailCells = pSlab; - } - - pSlab->pPrevSlabWithAvailCells = NULL; - pSlab->pNextSlabWithAvailCells = m_pFirstSlabWithAvailCells; - m_pFirstSlabWithAvailCells = pSlab; - } - } - - m_pUsageStats->ui64AllocatedCells--; - -Exit: - -#ifdef FLM_CACHE_PROTECT - if( bProtectSlab) - { - protectSlab( pSlab, TRUE); - } -#endif - - if( bUnlockMutex) - { - m_pSlabManager->unlockMutex(); - } - - return; -} - -/**************************************************************************** -Desc: Grabs another slab of memory from the operating system -****************************************************************************/ -F_FixedAlloc::SLAB * F_FixedAlloc::getAnotherSlab( void) -{ - SLAB * pSlab = NULL; - - if( RC_BAD( m_pSlabManager->allocSlab( (void **)&pSlab, TRUE))) - { - goto Exit; - } - - // Initialize the slab header fields - - f_memset( pSlab, 0, sizeof( SLAB)); - pSlab->pvAllocator = (void *)this; - m_pUsageStats->ui64Slabs++; - -#ifdef FLM_CACHE_PROTECT - if( m_bMemProtectionEnabled) - { - m_pSlabManager->protectSlab( pSlab); - } -#endif - -Exit: - - return( pSlab); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -#ifdef FLM_CACHE_PROTECT -void F_FixedAlloc::protectSlab( - SLAB * pSlab, - FLMBOOL bMutexLocked) -{ - FLMBOOL bUnlockMutex = FALSE; - - if( !m_bMemProtectionEnabled) - { - return; - } - - if( !bMutexLocked) - { - m_pSlabManager->lockMutex(); - bUnlockMutex = TRUE; - } - - flmAssert( pSlab->pvAllocator == this); - flmAssert( pSlab->ui16UnprotectCount); - - pSlab->ui16UnprotectCount--; - - if( !pSlab->ui16UnprotectCount) - { - m_pSlabManager->protectSlab( pSlab); - } - - if( bUnlockMutex) - { - m_pSlabManager->unlockMutex(); - } -} -#endif - -/**************************************************************************** -Desc: -****************************************************************************/ -#ifdef FLM_CACHE_PROTECT -void F_FixedAlloc::unprotectSlab( - SLAB * pSlab, - FLMBOOL bMutexLocked) -{ - FLMBOOL bUnlockMutex = FALSE; - - if( !m_bMemProtectionEnabled) - { - return; - } - - flmAssert( pSlab->pvAllocator == this); - - if( !bMutexLocked) - { - m_pSlabManager->lockMutex(); - bUnlockMutex = TRUE; - } - - if( !pSlab->ui16UnprotectCount) - { - m_pSlabManager->unprotectSlab( pSlab); - } - - pSlab->ui16UnprotectCount++; - - if( bUnlockMutex) - { - m_pSlabManager->unlockMutex(); - } -} -#endif - -/**************************************************************************** -Desc: -****************************************************************************/ -#ifdef FLM_CACHE_PROTECT -void F_FixedAlloc::protectCell( - void * pvCell) -{ - CELLHEADER * pCellHeader; - - m_pSlabManager->lockMutex(); - pCellHeader = (CELLHEADER *)((FLMBYTE *)pvCell - m_uiCellHeaderSize); - protectSlab( pCellHeader->pContainingSlab, TRUE); - m_pSlabManager->unlockMutex(); -} -#endif - -/**************************************************************************** -Desc: -****************************************************************************/ -#ifdef FLM_CACHE_PROTECT -void F_FixedAlloc::unprotectCell( - void * pvCell) -{ - CELLHEADER * pCellHeader; - - m_pSlabManager->lockMutex(); - pCellHeader = (CELLHEADER *)((FLMBYTE *)pvCell - m_uiCellHeaderSize); - unprotectSlab( pCellHeader->pContainingSlab, TRUE); - m_pSlabManager->unlockMutex(); -} -#endif - -/**************************************************************************** -Desc: Private internal method to free an unused empty slab back to the OS. -****************************************************************************/ -void F_FixedAlloc::freeSlab( - SLAB * pSlab) -{ -#ifdef FLM_DEBUG - CELLAVAILNEXT * pAvailNext = NULL; - FLMUINT32 ui32AvailCount = 0; -#endif - - flmAssert( pSlab); -#ifdef FLM_CACHE_PROTECT - flmAssert( !pSlab->ui16UnprotectCount); -#endif - - // Memory corruption detected! - - if( pSlab->ui16AllocatedCells || pSlab->pvAllocator != this) - { - flmAssert( 0); - return; - } - -#ifdef FLM_DEBUG - // Walk the avail chain as a sanity check - - pAvailNext = (CELLAVAILNEXT *)pSlab->pLocalAvailCellListHead; - while( pAvailNext) - { - ui32AvailCount++; - pAvailNext = (CELLAVAILNEXT *)pAvailNext->pNextInList; - } - - flmAssert( pSlab->ui16AvailCellCount == ui32AvailCount); - flmAssert( pSlab->ui16NextNeverUsedCell >= ui32AvailCount); -#endif - - // Unlink from all-slabs-list - - if( pSlab->pNext) - { -#ifdef FLM_CACHE_PROTECT - unprotectSlab( pSlab->pNext, TRUE); -#endif - pSlab->pNext->pPrev = pSlab->pPrev; -#ifdef FLM_CACHE_PROTECT - protectSlab( pSlab->pNext, TRUE); -#endif - } - else - { - m_pLastSlab = pSlab->pPrev; - } - - if( pSlab->pPrev) - { -#ifdef FLM_CACHE_PROTECT - unprotectSlab( pSlab->pPrev, TRUE); -#endif - pSlab->pPrev->pNext = pSlab->pNext; -#ifdef FLM_CACHE_PROTECT - protectSlab( pSlab->pPrev, TRUE); -#endif - } - else - { - m_pFirstSlab = pSlab->pNext; - } - - // Unlink from slabs-with-avail-cells list - - if( pSlab->pNextSlabWithAvailCells) - { -#ifdef FLM_CACHE_PROTECT - unprotectSlab( pSlab->pNextSlabWithAvailCells, TRUE); -#endif - pSlab->pNextSlabWithAvailCells->pPrevSlabWithAvailCells = - pSlab->pPrevSlabWithAvailCells; -#ifdef FLM_CACHE_PROTECT - protectSlab( pSlab->pNextSlabWithAvailCells, TRUE); -#endif - } - else - { - m_pLastSlabWithAvailCells = pSlab->pPrevSlabWithAvailCells; - } - - if( pSlab->pPrevSlabWithAvailCells) - { -#ifdef FLM_CACHE_PROTECT - unprotectSlab( pSlab->pPrevSlabWithAvailCells, TRUE); -#endif - pSlab->pPrevSlabWithAvailCells->pNextSlabWithAvailCells = - pSlab->pNextSlabWithAvailCells; -#ifdef FLM_CACHE_PROTECT - protectSlab( pSlab->pPrevSlabWithAvailCells, TRUE); -#endif - } - else - { - m_pFirstSlabWithAvailCells = pSlab->pNextSlabWithAvailCells; - } - - flmAssert( m_uiSlabsWithAvailCells); - m_uiSlabsWithAvailCells--; - flmAssert( m_uiTotalFreeCells >= pSlab->ui16AvailCellCount); - m_uiTotalFreeCells -= pSlab->ui16AvailCellCount; - m_pUsageStats->ui64Slabs--; - -#ifdef FLM_CACHE_PROTECT - unprotectSlab( pSlab, TRUE); -#endif - m_pSlabManager->freeSlab( (void **)&pSlab, TRUE); -} - -/**************************************************************************** -Desc: Public method to free all the memory in the system. -****************************************************************************/ -void F_FixedAlloc::freeAll( void) -{ - SLAB * pFreeMe; - - m_pSlabManager->lockMutex(); - - while( m_pFirstSlab) - { - pFreeMe = m_pFirstSlab; - m_pFirstSlab = m_pFirstSlab->pNext; - freeSlab( pFreeMe); - } - - flmAssert( !m_uiTotalFreeCells); - - m_pFirstSlab = NULL; - m_pLastSlab = NULL; - m_pFirstSlabWithAvailCells = NULL; - m_pLastSlabWithAvailCells = NULL; - m_uiSlabsWithAvailCells = 0; - m_bAvailListSorted = TRUE; - m_uiTotalFreeCells = 0; - f_memset( m_pUsageStats, 0, sizeof( XFLM_SLAB_USAGE)); - - m_pSlabManager->unlockMutex(); -} - -/**************************************************************************** -Desc: If a relocation callback function has been registered, and memory - can be compressed, the avail list will be compressed -****************************************************************************/ -void F_FixedAlloc::defragmentMemory( void) -{ - SLAB * pCurSlab; - SLAB * pPrevSib; - CELLHEADER * pCellHeader; - FLMBOOL bSlabFreed; - FLMBYTE * pucOriginal; - FLMBYTE * pucReloc = NULL; - FLMUINT uiLoop; - SLAB ** pSortBuf = NULL; - FLMUINT uiMaxSortEntries; - FLMUINT uiSortEntries = 0; -#define SMALL_SORT_BUF_SIZE 256 - SLAB * smallSortBuf[ SMALL_SORT_BUF_SIZE]; - - m_pSlabManager->lockMutex(); - - if( m_uiTotalFreeCells < m_uiCellsPerSlab) - { - goto Exit; - } - - uiMaxSortEntries = m_uiSlabsWithAvailCells; - - // Re-sort the slabs in the avail list according to - // their memory addresses to help reduce logical fragmentation - - if( !m_bAvailListSorted && uiMaxSortEntries > 1) - { - if( uiMaxSortEntries <= SMALL_SORT_BUF_SIZE) - { - pSortBuf = smallSortBuf; - } - else - { - if( RC_BAD( f_alloc( uiMaxSortEntries * sizeof( SLAB *), &pSortBuf))) - { - goto Exit; - } - } - - pCurSlab = m_pFirstSlabWithAvailCells; - - while( pCurSlab) - { - flmAssert( uiSortEntries != uiMaxSortEntries); - pSortBuf[ uiSortEntries++] = pCurSlab; - pCurSlab = pCurSlab->pNextSlabWithAvailCells; - } - - // Quick sort - - flmAssert( uiSortEntries); - - f_qsort( (FLMBYTE *)pSortBuf, 0, uiSortEntries - 1, - F_FixedAlloc::slabAddrCompareFunc, - F_FixedAlloc::slabAddrSwapFunc); - - // Re-link the items in the list according to the new - // sort order - - m_pFirstSlabWithAvailCells = NULL; - m_pLastSlabWithAvailCells = NULL; - - pCurSlab = NULL; - pPrevSib = NULL; - - for( uiLoop = 0; uiLoop < uiSortEntries; uiLoop++) - { - pCurSlab = pSortBuf[ uiLoop]; -#ifdef FLM_CACHE_PROTECT - unprotectSlab( pCurSlab, TRUE); -#endif - - pCurSlab->pNextSlabWithAvailCells = NULL; - pCurSlab->pPrevSlabWithAvailCells = NULL; - - if( pPrevSib) - { - pCurSlab->pPrevSlabWithAvailCells = pPrevSib; -#ifdef FLM_CACHE_PROTECT - unprotectSlab( pPrevSib, TRUE); -#endif - pPrevSib->pNextSlabWithAvailCells = pCurSlab; -#ifdef FLM_CACHE_PROTECT - protectSlab( pPrevSib, TRUE); -#endif - } - else - { - m_pFirstSlabWithAvailCells = pCurSlab; - } - -#ifdef FLM_CACHE_PROTECT - protectSlab( pCurSlab, TRUE); -#endif - pPrevSib = pCurSlab; - } - - m_pLastSlabWithAvailCells = pCurSlab; - m_bAvailListSorted = TRUE; - } - - // Process the avail list (which should be sorted unless - // we are too low on memory) - - pCurSlab = m_pLastSlabWithAvailCells; - - while( pCurSlab) - { - if( m_uiTotalFreeCells < m_uiCellsPerSlab) - { - // No need to continue ... we aren't above the - // free cell threshold - - goto Exit; - } - - pPrevSib = pCurSlab->pPrevSlabWithAvailCells; - - if( pCurSlab == m_pFirstSlabWithAvailCells || - !pCurSlab->ui16AvailCellCount) - { - // We've either hit the beginning of the avail list or - // the slab that we are now positioned on has been - // removed from the avail list. In either case, - // we are done. - - break; - } - - if( pCurSlab->ui16AvailCellCount == m_uiCellsPerSlab || - pCurSlab->ui16NextNeverUsedCell == pCurSlab->ui16AvailCellCount) - { - freeSlab( pCurSlab); - pCurSlab = pPrevSib; - continue; - } - - for( uiLoop = 0; uiLoop < pCurSlab->ui16NextNeverUsedCell && - pCurSlab != m_pFirstSlabWithAvailCells && - m_uiTotalFreeCells >= m_uiCellsPerSlab; uiLoop++) - { - IF_Relocator * pRelocator; - - pCellHeader = (CELLHEADER *) - ((FLMBYTE *)pCurSlab + m_uiSlabHeaderSize + - (uiLoop * m_uiSizeOfCellAndHeader)); - if ((pRelocator = m_pRelocator) == NULL) - { - pRelocator = ((CELLHEADER2 *)pCellHeader)->pRelocator; - } - - if( pCellHeader->pContainingSlab) - { - - // If pContainingSlab is non-NULL, the cell is currently allocated - - flmAssert( pCellHeader->pContainingSlab == pCurSlab); - - pucOriginal = ((FLMBYTE *)pCellHeader + m_uiCellHeaderSize); - - if( pRelocator->canRelocate( pucOriginal)) - { - if( (pucReloc = (FLMBYTE *)getCell( pRelocator)) == NULL) - { - goto Exit; - } - -#ifdef FLM_CACHE_PROTECT - unprotectSlab( ((CELLHEADER *)(pucReloc - - m_uiCellHeaderSize))->pContainingSlab, TRUE); -#endif - - f_memcpy( pucReloc, pucOriginal, m_uiCellSize); - pRelocator->relocate( pucOriginal, pucReloc); - -#ifdef FLM_CACHE_PROTECT - protectSlab( ((CELLHEADER *)(pucReloc - - m_uiCellHeaderSize))->pContainingSlab, TRUE); -#endif - - freeCell( pucOriginal, TRUE, TRUE, &bSlabFreed); - - if( bSlabFreed) - { - break; - } - } - } - } - - pCurSlab = pPrevSib; - } - -Exit: - - m_pSlabManager->unlockMutex(); - - if( pSortBuf && pSortBuf != smallSortBuf) - { - f_free( &pSortBuf); - } -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void F_FixedAlloc::freeUnused( void) -{ - SLAB * pSlab; - - m_pSlabManager->lockMutex(); - - if( (pSlab = m_pFirstSlabWithAvailCells) != NULL && - !pSlab->ui16AllocatedCells) - { - freeSlab( pSlab); - } - - if( (pSlab = m_pFirstSlab) != NULL && - !pSlab->ui16AllocatedCells) - { - freeSlab( pSlab); - } - - m_pSlabManager->unlockMutex(); -} - -/**************************************************************************** -Desc: Debug method to do mem leak testing. Any cells allocated via - allocCell but not freed via freeCell() will be triggered here. -****************************************************************************/ -#ifdef FLM_DEBUG -void F_FixedAlloc::testForLeaks( void) -{ - SLAB * pSlabRover = m_pFirstSlab; - CELLHEADER * pHeader; - FLMUINT uiLoop; - F_MEM_HDR memHeader; - - // Test for leaks - - while( pSlabRover) - { - for( uiLoop = 0; uiLoop < pSlabRover->ui16NextNeverUsedCell; uiLoop++) - { - pHeader = (CELLHEADER *) - ((FLMBYTE *)pSlabRover + m_uiSlabHeaderSize + - (uiLoop * m_uiSizeOfCellAndHeader)); - - // Nonzero here means we have a leak - - if( pHeader->pContainingSlab) - { - // We have a leak, so let's call logMemLeak with the - // appropriate header passed in - - f_memset( &memHeader, 0, sizeof( F_MEM_HDR)); - memHeader.uiDataSize = m_uiCellSize; - memHeader.puiStack = pHeader->puiStack; - logMemLeak( &memHeader); - } - } - - pSlabRover = pSlabRover->pNext; - } -} -#endif - -/**************************************************************************** -Desc: -****************************************************************************/ -F_BufferAlloc::~F_BufferAlloc() -{ - FLMUINT uiLoop; - - for (uiLoop = 0; uiLoop < NUM_BUF_ALLOCATORS; uiLoop++) - { - if( m_ppAllocators[ uiLoop]) - { - m_ppAllocators[ uiLoop]->Release(); - m_ppAllocators[ uiLoop] = NULL; - } - } - - if( m_pSlabManager) - { - m_pSlabManager->Release(); - } -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE F_BufferAlloc::setup( - F_SlabManager * pSlabManager, - FLMBOOL bMemProtect, - XFLM_SLAB_USAGE * pUsageStats) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiLoop; - FLMUINT uiSize; - - flmAssert( pSlabManager); - m_pSlabManager = pSlabManager; - m_pSlabManager->AddRef(); - - for( uiLoop = 0; uiLoop < NUM_BUF_ALLOCATORS; uiLoop++) - { - if( (m_ppAllocators[ uiLoop] = f_new F_FixedAlloc) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - switch (uiLoop) - { - case 0: - uiSize = CELL_SIZE_0; - break; - case 1: - uiSize = CELL_SIZE_1; - break; - case 2: - uiSize = CELL_SIZE_2; - break; - case 3: - uiSize = CELL_SIZE_3; - break; - case 4: - uiSize = CELL_SIZE_4; - break; - case 5: - uiSize = CELL_SIZE_5; - break; - case 6: - uiSize = CELL_SIZE_6; - break; - case 7: - uiSize = CELL_SIZE_7; - break; - case 8: - uiSize = CELL_SIZE_8; - break; - case 9: - uiSize = CELL_SIZE_9; - break; - case 10: - uiSize = CELL_SIZE_10; - break; - case 11: - uiSize = CELL_SIZE_11; - break; - case 12: - uiSize = CELL_SIZE_12; - break; - case 13: - uiSize = CELL_SIZE_13; - break; - case 14: - uiSize = CELL_SIZE_14; - break; - case 15: - uiSize = CELL_SIZE_15; - break; - case 16: - uiSize = CELL_SIZE_16; - break; - case 17: - uiSize = CELL_SIZE_17; - break; - case 18: - uiSize = CELL_SIZE_18; - break; - case 19: - uiSize = CELL_SIZE_19; - break; - case 20: - uiSize = CELL_SIZE_20; - break; - case 21: - uiSize = CELL_SIZE_21; - break; - default: - uiSize = 0; - rc = RC_SET_AND_ASSERT( NE_XFLM_NOT_IMPLEMENTED); - goto Exit; - } - - if (RC_BAD( rc = m_ppAllocators[ uiLoop]->setup( NULL, - pSlabManager, bMemProtect, uiSize, pUsageStats))) - { - goto Exit; - } - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE F_BufferAlloc::allocBuf( - IF_Relocator * pRelocator, - FLMUINT uiSize, - void * pvInitialData, - FLMUINT uiDataSize, - FLMBYTE ** ppucBuffer, - FLMBOOL * pbAllocatedOnHeap) -{ - RCODE rc = NE_XFLM_OK; - F_FixedAlloc * pAllocator = getAllocator( uiSize); - - if( pbAllocatedOnHeap) - { - *pbAllocatedOnHeap = FALSE; - } - - if( pAllocator) - { - flmAssert( pAllocator->getCellSize() >= uiSize); - - if( (*ppucBuffer = (FLMBYTE *)pAllocator->allocCell( pRelocator, - pvInitialData, uiDataSize)) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - } - else - { - if( RC_BAD( rc = f_alloc( uiSize, ppucBuffer))) - { - goto Exit; - } - - m_pSlabManager->incrementTotalBytesAllocated( - f_msize( *ppucBuffer), FALSE); - - if( pvInitialData) - { - f_memcpy( *ppucBuffer, pvInitialData, uiDataSize); - } - - if( pbAllocatedOnHeap) - { - *pbAllocatedOnHeap = TRUE; - } - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE F_BufferAlloc::reallocBuf( - IF_Relocator * pRelocator, - FLMUINT uiOldSize, - FLMUINT uiNewSize, - void * pvInitialData, - FLMUINT uiDataSize, - FLMBYTE ** ppucBuffer, - FLMBOOL * pbAllocatedOnHeap) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE * pucTmp; - F_FixedAlloc * pOldAllocator; - F_FixedAlloc * pNewAllocator; - FLMBOOL bLockedMutex = FALSE; - - flmAssert( uiNewSize); - - if( !uiOldSize) - { - rc = allocBuf( pRelocator, uiNewSize, pvInitialData, uiDataSize, - ppucBuffer, pbAllocatedOnHeap); - goto Exit; - } - - pOldAllocator = getAllocator( uiOldSize); - pNewAllocator = getAllocator( uiNewSize); - - if( pOldAllocator && pOldAllocator == pNewAllocator) - { - // The allocation will still fit in the same cell - - goto Exit; - } - - m_pSlabManager->lockMutex(); - bLockedMutex = TRUE; - - if( pbAllocatedOnHeap) - { - *pbAllocatedOnHeap = FALSE; - } - - if( pOldAllocator) - { - if( pNewAllocator) - { - flmAssert( pOldAllocator != pNewAllocator); - - if( (pucTmp = (FLMBYTE *)pNewAllocator->allocCell( pRelocator, - NULL, 0, TRUE)) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - } - else - { - if( RC_BAD( rc = f_alloc( uiNewSize, &pucTmp))) - { - goto Exit; - } - - m_pSlabManager->incrementTotalBytesAllocated( - f_msize( pucTmp), FALSE); - - if( pbAllocatedOnHeap) - { - *pbAllocatedOnHeap = TRUE; - } - } - - f_memcpy( pucTmp, *ppucBuffer, f_min( uiOldSize, uiNewSize)); - pOldAllocator->freeCell( *ppucBuffer, TRUE); - *ppucBuffer = pucTmp; - } - else - { - if( pNewAllocator) - { - if( (pucTmp = (FLMBYTE *)pNewAllocator->allocCell( pRelocator, - *ppucBuffer, f_min( uiOldSize, uiNewSize))) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - m_pSlabManager->decrementTotalBytesAllocated( - f_msize( *ppucBuffer), TRUE); - f_free( ppucBuffer); - *ppucBuffer = pucTmp; - } - else - { - FLMUINT uiOldAllocSize = f_msize( *ppucBuffer); - - flmAssert( uiOldSize > m_ppAllocators[ NUM_BUF_ALLOCATORS - 1]->getCellSize()); - flmAssert( uiNewSize > m_ppAllocators[ NUM_BUF_ALLOCATORS - 1]->getCellSize()); - - if( RC_BAD( rc = f_realloc( uiNewSize, ppucBuffer))) - { - goto Exit; - } - - m_pSlabManager->decrementTotalBytesAllocated( - uiOldAllocSize, TRUE); - m_pSlabManager->incrementTotalBytesAllocated( - f_msize( *ppucBuffer), TRUE); - - if( pbAllocatedOnHeap) - { - *pbAllocatedOnHeap = TRUE; - } - } - } - -Exit: - - if( bLockedMutex) - { - m_pSlabManager->unlockMutex(); - } - - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void F_BufferAlloc::freeBuf( - FLMUINT uiSize, - FLMBYTE ** ppucBuffer) -{ - F_FixedAlloc * pAllocator = getAllocator( uiSize); - - if( pAllocator) - { - pAllocator->freeCell( *ppucBuffer, FALSE, TRUE, NULL); - *ppucBuffer = NULL; - } - else - { - m_pSlabManager->decrementTotalBytesAllocated( - f_msize( *ppucBuffer), FALSE); - f_free( ppucBuffer); - } -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void F_BufferAlloc::defragmentMemory( void) -{ - FLMUINT uiLoop; - - for( uiLoop = 0; uiLoop < NUM_BUF_ALLOCATORS; uiLoop++) - { - if( m_ppAllocators[ uiLoop]) - { - m_ppAllocators[ uiLoop]->defragmentMemory(); - m_ppAllocators[ uiLoop]->freeUnused(); - } - - uiLoop++; - } -} - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMUINT F_BufferAlloc::getTrueSize( - FLMUINT uiSize, - FLMBYTE * pucBuffer) -{ - FLMUINT uiTrueSize; - F_FixedAlloc * pAllocator; - - if( !uiSize) - { - uiTrueSize = 0; - } - else if( (pAllocator = getAllocator( uiSize)) != NULL) - { - uiTrueSize = pAllocator->getCellSize(); - } - else - { - uiTrueSize = f_msize( pucBuffer); - } - - return( uiTrueSize); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -F_FixedAlloc * F_BufferAlloc::getAllocator( - FLMUINT uiSize) -{ - F_FixedAlloc * pAllocator; - - flmAssert( uiSize); - - if( uiSize <= CELL_SIZE_10) - { - if( uiSize <= CELL_SIZE_4) - { - if( uiSize <= CELL_SIZE_2) - { - if( uiSize <= CELL_SIZE_0) - { - pAllocator = (F_FixedAlloc *)m_ppAllocators [0]; - } - else - { - pAllocator = (F_FixedAlloc *)(uiSize <= CELL_SIZE_1 - ? m_ppAllocators [1] - : m_ppAllocators [2]); - } - } - else - { - pAllocator = (F_FixedAlloc *)(uiSize <= CELL_SIZE_3 - ? m_ppAllocators [3] - : m_ppAllocators [4]); - } - } - else if( uiSize <= CELL_SIZE_7) - { - if( uiSize <= CELL_SIZE_5) - { - pAllocator = (F_FixedAlloc *)m_ppAllocators [5]; - } - else - { - pAllocator = (F_FixedAlloc *)(uiSize <= CELL_SIZE_6 - ? m_ppAllocators [6] - : m_ppAllocators [7]); - } - } - else - { - if( uiSize <= CELL_SIZE_8) - { - pAllocator = (F_FixedAlloc *)m_ppAllocators [8]; - } - else - { - pAllocator = (F_FixedAlloc *)(uiSize <= CELL_SIZE_9 - ? m_ppAllocators [9] - : m_ppAllocators [10]); - } - } - } - else if( uiSize <= CELL_SIZE_16) - { - if( uiSize <= CELL_SIZE_13) - { - if( uiSize <= CELL_SIZE_11) - { - pAllocator = (F_FixedAlloc *)m_ppAllocators [11]; - } - else - { - pAllocator = (F_FixedAlloc *)(uiSize <= CELL_SIZE_12 - ? m_ppAllocators [12] - : m_ppAllocators [13]); - } - } - else - { - if( uiSize <= CELL_SIZE_14) - { - pAllocator = (F_FixedAlloc *)m_ppAllocators [14]; - } - else - { - pAllocator = (F_FixedAlloc *)(uiSize <= CELL_SIZE_15 - ? m_ppAllocators [15] - : m_ppAllocators [16]); - } - } - } - else if( uiSize <= CELL_SIZE_19) - { - if( uiSize <= CELL_SIZE_17) - { - pAllocator = (F_FixedAlloc *)m_ppAllocators [17]; - } - else - { - pAllocator = (F_FixedAlloc *)(uiSize <= CELL_SIZE_18 - ? m_ppAllocators [18] - : m_ppAllocators [19]); - } - } - else if( uiSize <= CELL_SIZE_21) - { - pAllocator = (F_FixedAlloc *)(uiSize <= CELL_SIZE_20 - ? m_ppAllocators [20] - : m_ppAllocators [21]); - } - else - { - pAllocator = NULL; - } - - return( pAllocator); -} -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE F_MultiAlloc::setup( - F_SlabManager * pSlabManager, - FLMBOOL bMemProtect, - FLMUINT * puiCellSizes, - XFLM_SLAB_USAGE * pUsageStats) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiLoop; - FLMUINT uiCellCount; - - m_pSlabManager = pSlabManager; - m_pSlabManager->AddRef(); - - uiCellCount = 0; - while( puiCellSizes[ uiCellCount]) - { - uiCellCount++; - } - - if( !uiCellCount) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_INVALID_PARM); - goto Exit; - } - - f_qsort( puiCellSizes, 0, uiCellCount - 1, - flmQSortUINTCompare, flmQSortUINTSwap); - - if( RC_BAD( rc = f_alloc( - sizeof( FLMUINT *) * (uiCellCount + 1), &m_puiCellSizes))) - { - goto Exit; - } - - m_pSlabManager->incrementTotalBytesAllocated( - f_msize( m_puiCellSizes), FALSE); - - f_memcpy( m_puiCellSizes, puiCellSizes, - (uiCellCount + 1) * sizeof( FLMUINT)); - - // Set up the allocators - - if( RC_BAD( rc = f_calloc( - sizeof( F_FixedAlloc *) * (uiCellCount + 1), &m_ppAllocators))) - { - goto Exit; - } - - m_pSlabManager->incrementTotalBytesAllocated( - f_msize( m_ppAllocators), FALSE); - - uiLoop = 0; - while( m_puiCellSizes[ uiLoop]) - { - if( (m_ppAllocators[ uiLoop] = f_new F_FixedAlloc) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = m_ppAllocators[ uiLoop]->setup( NULL, - pSlabManager, bMemProtect, m_puiCellSizes[ uiLoop], pUsageStats))) - { - goto Exit; - } - - uiLoop++; - } - -Exit: - - if( RC_BAD( rc)) - { - cleanup(); - } - - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void F_MultiAlloc::cleanup( void) -{ - FLMUINT uiLoop = 0; - - if( !m_puiCellSizes || !m_ppAllocators) - { - goto Exit; - } - - while( m_puiCellSizes[ uiLoop]) - { - if( m_ppAllocators[ uiLoop]) - { - m_ppAllocators[ uiLoop]->Release(); - m_ppAllocators[ uiLoop] = NULL; - } - - uiLoop++; - } - -Exit: - - if( m_puiCellSizes) - { - m_pSlabManager->decrementTotalBytesAllocated( - f_msize( m_puiCellSizes), FALSE); - f_free( &m_puiCellSizes); - } - - if( m_ppAllocators) - { - m_pSlabManager->decrementTotalBytesAllocated( - f_msize( m_ppAllocators), FALSE); - f_free( &m_ppAllocators); - } - - if( m_pSlabManager) - { - m_pSlabManager->Release(); - m_pSlabManager = NULL; - } -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE F_MultiAlloc::allocBuf( - IF_Relocator * pRelocator, - FLMUINT uiSize, - FLMBYTE ** ppucBuffer, - FLMBOOL bMutexLocked) -{ - RCODE rc = NE_XFLM_OK; - F_FixedAlloc * pAllocator = getAllocator( uiSize); - - flmAssert( pAllocator); - flmAssert( pAllocator->getCellSize() >= uiSize); - - if( (*ppucBuffer = (FLMBYTE *)pAllocator->allocCell( pRelocator, - NULL, 0, bMutexLocked)) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE F_MultiAlloc::reallocBuf( - IF_Relocator * pRelocator, - FLMUINT uiNewSize, - FLMBYTE ** ppucBuffer, - FLMBOOL bMutexLocked) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE * pucTmp; - F_FixedAlloc * pOldAllocator; - F_FixedAlloc * pNewAllocator; - FLMBOOL bLockedMutex = FALSE; - - flmAssert( uiNewSize); - - if( !(*ppucBuffer)) - { - rc = allocBuf( pRelocator, uiNewSize, ppucBuffer); - goto Exit; - } - - pOldAllocator = getAllocator( *ppucBuffer); - pNewAllocator = getAllocator( uiNewSize); - - if( pOldAllocator == pNewAllocator) - { - // The allocation will still fit in the same cell - - goto Exit; - } - - if( !bMutexLocked) - { - m_pSlabManager->lockMutex(); - bLockedMutex = TRUE; - } - - if( (pucTmp = (FLMBYTE *)pNewAllocator->allocCell( pRelocator, *ppucBuffer, - f_min( uiNewSize, pOldAllocator->m_uiCellSize), TRUE)) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - pOldAllocator->freeCell( *ppucBuffer, TRUE); - *ppucBuffer = pucTmp; - -Exit: - - if( bLockedMutex) - { - m_pSlabManager->unlockMutex(); - } - - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void F_MultiAlloc::defragmentMemory( void) -{ - FLMUINT uiLoop = 0; - - while( m_puiCellSizes[ uiLoop]) - { - if( m_ppAllocators[ uiLoop]) - { - m_ppAllocators[ uiLoop]->defragmentMemory(); - m_ppAllocators[ uiLoop]->freeUnused(); - } - - uiLoop++; - } -} - -/**************************************************************************** -Desc: -****************************************************************************/ -F_FixedAlloc * F_MultiAlloc::getAllocator( - FLMUINT uiSize) -{ - F_FixedAlloc * pAllocator = NULL; - FLMUINT uiLoop; - - flmAssert( uiSize); - - for( uiLoop = 0; m_puiCellSizes[ uiLoop]; uiLoop++) - { - if( m_puiCellSizes[ uiLoop] >= uiSize) - { - pAllocator = m_ppAllocators[ uiLoop]; - break; - } - } - - return( pAllocator); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -F_FixedAlloc * F_MultiAlloc::getAllocator( - FLMBYTE * pucBuffer) -{ - F_FixedAlloc::CELLHEADER * pHeader; - F_FixedAlloc::SLAB * pSlab; - F_FixedAlloc * pAllocator = NULL; - - m_pSlabManager->lockMutex(); - - pHeader = (F_FixedAlloc::CELLHEADER *)(pucBuffer - - F_FixedAlloc::getAllocAlignedSize( - sizeof( F_FixedAlloc::CELLHEADER2))); - pSlab = pHeader->pContainingSlab; - pAllocator = (F_FixedAlloc *)pSlab->pvAllocator; - - m_pSlabManager->unlockMutex(); - return( pAllocator); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -#ifdef FLM_CACHE_PROTECT -void F_MultiAlloc::protectBuffer( - void * pvBuffer, - FLMBOOL bMutexLocked) -{ - F_FixedAlloc::CELLHEADER * pHeader; - F_FixedAlloc::SLAB * pSlab; - F_FixedAlloc * pAllocator = NULL; - FLMBYTE * pucBuffer = (FLMBYTE *)pvBuffer; - - if( !bMutexLocked) - { - m_pSlabManager->lockMutex(); - } - - pHeader = (F_FixedAlloc::CELLHEADER *)(pucBuffer - - F_FixedAlloc::getAllocAlignedSize( - sizeof( F_FixedAlloc::CELLHEADER2))); - pSlab = pHeader->pContainingSlab; - pAllocator = (F_FixedAlloc *)pSlab->pvAllocator; - pAllocator->protectSlab( pSlab, TRUE); - - if( !bMutexLocked) - { - m_pSlabManager->unlockMutex(); - } -} -#endif - -/**************************************************************************** -Desc: -****************************************************************************/ -#ifdef FLM_CACHE_PROTECT -void F_MultiAlloc::unprotectBuffer( - void * pvBuffer, - FLMBOOL bMutexLocked) -{ - F_FixedAlloc::CELLHEADER * pHeader; - F_FixedAlloc::SLAB * pSlab; - F_FixedAlloc * pAllocator = NULL; - FLMBYTE * pucBuffer = (FLMBYTE *)pvBuffer; - - if( !bMutexLocked) - { - m_pSlabManager->lockMutex(); - } - - pHeader = (F_FixedAlloc::CELLHEADER *)(pucBuffer - - F_FixedAlloc::getAllocAlignedSize( - sizeof( F_FixedAlloc::CELLHEADER2))); - pSlab = pHeader->pContainingSlab; - pAllocator = (F_FixedAlloc *)pSlab->pvAllocator; - pAllocator->unprotectSlab( pSlab, TRUE); - - if( !bMutexLocked) - { - m_pSlabManager->unlockMutex(); - } -} -#endif diff --git a/xflaim/src/flfixed.h b/xflaim/src/flfixed.h deleted file mode 100644 index aa15beb..0000000 --- a/xflaim/src/flfixed.h +++ /dev/null @@ -1,585 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Special allocators for making many fixed-size allocations. -// -// Tabs: 3 -// -// Copyright (c) 2004-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: flfixed.h 3108 2006-01-19 13:05:19 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#ifndef FLFIXED_H -#define FLFIXED_H - -// Cell sizes for buffer allocator - -#define CELL_SIZE_0 16 -#define CELL_SIZE_1 32 -#define CELL_SIZE_2 64 -#define CELL_SIZE_3 128 -#define CELL_SIZE_4 192 -#define CELL_SIZE_5 320 -#define CELL_SIZE_6 512 -#define CELL_SIZE_7 672 -#define CELL_SIZE_8 832 -#define CELL_SIZE_9 1088 -#define CELL_SIZE_10 1344 -#define CELL_SIZE_11 1760 -#define CELL_SIZE_12 2176 -#define CELL_SIZE_13 2848 -#define CELL_SIZE_14 3520 -#define CELL_SIZE_15 4608 -#define CELL_SIZE_16 5152 -#define CELL_SIZE_17 5696 -#define CELL_SIZE_18 8164 -#define CELL_SIZE_19 13068 -#define CELL_SIZE_20 16340 -#define CELL_SIZE_21 21796 -#define MAX_CELL_SIZE CELL_SIZE_21 - -#define NUM_BUF_ALLOCATORS 22 - -/**************************************************************************** -Desc: -****************************************************************************/ -class F_SlabManager : public XF_RefCount, public XF_Base -{ -public: - - F_SlabManager(); - - virtual ~F_SlabManager(); - - RCODE setup( - FLMUINT uiPreallocSize); - - RCODE allocSlab( - void ** ppSlab, - FLMBOOL bMutexLocked); - - void freeSlab( - void ** ppSlab, - FLMBOOL bMutexLocked); - - RCODE resize( - FLMUINT uiNumBytes, - FLMUINT * puiActualSize = NULL, - FLMBOOL bMutexLocked = FALSE); - - FINLINE void incrementTotalBytesAllocated( - FLMUINT uiCount, - FLMBOOL bMutexLocked) - { - if( !bMutexLocked) - { - lockMutex(); - } - - m_uiTotalBytesAllocated += uiCount; - - if( !bMutexLocked) - { - unlockMutex(); - } - } - - FINLINE void decrementTotalBytesAllocated( - FLMUINT uiCount, - FLMBOOL bMutexLocked) - { - if( !bMutexLocked) - { - lockMutex(); - } - - flmAssert( m_uiTotalBytesAllocated >= uiCount); - m_uiTotalBytesAllocated -= uiCount; - - if( !bMutexLocked) - { - unlockMutex(); - } - } - - FINLINE FLMUINT getSlabSize( void) - { - return( m_uiSlabSize); - } - - FINLINE FLMUINT getTotalSlabs( void) - { - return( m_uiTotalSlabs); - } - - FINLINE void lockMutex( void) - { - f_mutexLock( m_hMutex); - } - - FINLINE void unlockMutex( void) - { - f_mutexUnlock( m_hMutex); - } - - FINLINE FLMUINT totalBytesAllocated( void) - { - return( m_uiTotalBytesAllocated); - } - - FINLINE FLMUINT availSlabs( void) - { - return( m_uiAvailSlabs); - } - -#ifdef FLM_CACHE_PROTECT - void protectSlab( - void * pSlab); - - void unprotectSlab( - void * pSlab); -#endif - -private: - - void freeAllSlabs( void); - - void * allocSlabFromSystem( void); - - void releaseSlabToSystem( - void * pSlab); - - RCODE sortSlabList( void); - - typedef struct - { - void * pPrev; - void * pNext; - } SLABHEADER; - - static FLMINT slabAddrCompareFunc( - void * pvBuffer, - FLMUINT uiPos1, - FLMUINT uiPos2); - - static void slabAddrSwapFunc( - void * pvBuffer, - FLMUINT uiPos1, - FLMUINT uiPos2); - - F_MUTEX m_hMutex; - FLMUINT m_uiTotalBytesAllocated; - void * m_pFirstInSlabList; - void * m_pLastInSlabList; - FLMUINT m_uiSlabSize; - FLMUINT m_uiTotalSlabs; - FLMUINT m_uiAvailSlabs; - FLMUINT m_uiInUseSlabs; - FLMUINT m_uiPreallocSlabs; -#ifdef FLM_SOLARIS - int m_DevZero; -#endif - -friend class F_FixedAlloc; -}; - -/**************************************************************************** -Desc: Class with two virtual functions - canRelocate and relocate. -****************************************************************************/ -class IF_Relocator -{ -public: - - virtual ~IF_Relocator() - { - } - - virtual void relocate( - void * pvOldAlloc, - void * pvNewAlloc) = 0; - - virtual FLMBOOL canRelocate( - void * pvOldAlloc) = 0; -}; - -/**************************************************************************** -Desc: Class to provide an efficient means of providing many allocations - of a fixed size. -****************************************************************************/ -class F_FixedAlloc : public XF_RefCount, public XF_Base -{ -public: - - F_FixedAlloc(); - - virtual ~F_FixedAlloc(); - - RCODE setup( - IF_Relocator * pRelocator, - F_SlabManager * pSlabManager, - FLMBOOL bMemProtect, - FLMUINT uiCellSize, - XFLM_SLAB_USAGE * pUsageStats); - - FINLINE void * allocCell( - IF_Relocator * pRelocator, - void * pvInitialData = NULL, - FLMUINT uiDataSize = 0, - FLMBOOL bMutexLocked = FALSE) - { - void * pvCell; - - flmAssert( pRelocator); - - if( !bMutexLocked) - { - m_pSlabManager->lockMutex(); - } - - if( (pvCell = getCell( pRelocator)) == NULL) - { - goto Exit; - } - - if( uiDataSize == sizeof( FLMUINT *)) - { - *((FLMUINT *)pvCell) = *((FLMUINT *)pvInitialData); - } - else if( uiDataSize) - { - f_memcpy( pvCell, pvInitialData, uiDataSize); - } - - Exit: - - if( !bMutexLocked) - { - m_pSlabManager->unlockMutex(); - } - - return( pvCell); - } - - FINLINE void freeCell( - void * ptr, - FLMBOOL bMutexLocked) - { - freeCell( ptr, bMutexLocked, FALSE, NULL); - } - - void freeUnused( void); - - void freeAll( void); - - FINLINE FLMUINT getCellSize( void) - { - return( m_uiCellSize); - } - - void defragmentMemory( void); - -#ifdef FLM_CACHE_PROTECT - void protectCell( - void * pvCell); - - void unprotectCell( - void * pvCell); -#endif - - typedef struct Slab - { - void * pvAllocator; - Slab * pNext; - Slab * pPrev; - Slab * pNextSlabWithAvailCells; - Slab * pPrevSlabWithAvailCells; - FLMBYTE * pLocalAvailCellListHead; - FLMUINT16 ui16NextNeverUsedCell; - FLMUINT16 ui16AvailCellCount; - FLMUINT16 ui16AllocatedCells; -#ifdef FLM_CACHE_PROTECT - FLMUINT32 ui16UnprotectCount; -#endif - } SLAB; - - typedef struct CELLHEADER - { - SLAB * pContainingSlab; -#ifdef FLM_DEBUG - FLMUINT * puiStack; -#endif - } CELLHEADER; - - typedef struct CELLHEADER2 - { - CELLHEADER cellHeader; - IF_Relocator * pRelocator; - } CELLHEADER2; - - typedef struct CellAvailNext - { - FLMBYTE * pNextInList; -#ifdef FLM_DEBUG - FLMBYTE szDebugPattern[ 8]; -#endif - } CELLAVAILNEXT; - -private: - -#ifdef FLM_CACHE_PROTECT - void protectSlab( - SLAB * pSlab, - FLMBOOL bMutexLocked); - - void unprotectSlab( - SLAB * pSlab, - FLMBOOL bMutexLocked); -#endif - - void * getCell( - IF_Relocator * pRelocator); - - SLAB * getAnotherSlab( void); - - static FINLINE FLMUINT getAllocAlignedSize( - FLMUINT uiAskedForSize) - { - return( (uiAskedForSize + FLM_ALLOC_ALIGN) & (~FLM_ALLOC_ALIGN)); - } - - void freeSlab( - SLAB * pSlab); - - void freeCell( - void * pCell, - FLMBOOL bMutexLocked, - FLMBOOL bFreeIfEmpty, - FLMBOOL * pbFreedSlab); - -#ifdef FLM_DEBUG - void testForLeaks( void); -#endif - - FINLINE static FLMINT slabAddrCompareFunc( - void * pvBuffer, - FLMUINT uiPos1, - FLMUINT uiPos2) - { - SLAB * pSlab1 = (((SLAB **)pvBuffer)[ uiPos1]); - SLAB * pSlab2 = (((SLAB **)pvBuffer)[ uiPos2]); - - flmAssert( pSlab1 != pSlab2); - - if( pSlab1 < pSlab2) - { - return( -1); - } - - return( 1); - } - - FINLINE static void slabAddrSwapFunc( - void * pvBuffer, - FLMUINT uiPos1, - FLMUINT uiPos2) - { - SLAB ** ppSlab1 = &(((SLAB **)pvBuffer)[ uiPos1]); - SLAB ** ppSlab2 = &(((SLAB **)pvBuffer)[ uiPos2]); - SLAB * pTmp; - - pTmp = *ppSlab1; - *ppSlab1 = *ppSlab2; - *ppSlab2 = pTmp; - } - - F_SlabManager * m_pSlabManager; - SLAB * m_pFirstSlab; - SLAB * m_pLastSlab; - SLAB * m_pFirstSlabWithAvailCells; - SLAB * m_pLastSlabWithAvailCells; - IF_Relocator * m_pRelocator; - FLMBOOL m_bAvailListSorted; - FLMUINT m_uiSlabsWithAvailCells; - FLMUINT m_uiSlabHeaderSize; - FLMUINT m_uiCellHeaderSize; - FLMUINT m_uiCellSize; - FLMUINT m_uiSizeOfCellAndHeader; - FLMUINT m_uiTotalFreeCells; - FLMUINT m_uiCellsPerSlab; - FLMUINT m_uiSlabSize; - - // Members specifically for stats - - XFLM_SLAB_USAGE * m_pUsageStats; - - // Memory protection - -#ifdef FLM_CACHE_PROTECT - FLMBOOL m_bMemProtectionEnabled; -#endif - -friend class F_BufferAlloc; -friend class F_MultiAlloc; -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -class F_BufferAlloc : public XF_RefCount, public XF_Base -{ -public: - - F_BufferAlloc() - { - f_memset( m_ppAllocators, 0, sizeof( m_ppAllocators)); - m_pSlabManager = NULL; - } - - virtual ~F_BufferAlloc(); - - RCODE setup( - F_SlabManager * pSlabManager, - FLMBOOL bMemProtect, - XFLM_SLAB_USAGE * pUsageStats); - - RCODE allocBuf( - IF_Relocator * pRelocator, - FLMUINT uiSize, - void * pvInitialData, - FLMUINT uiDataSize, - FLMBYTE ** ppucBuffer, - FLMBOOL * pbAllocatedOnHeap = NULL); - - RCODE reallocBuf( - IF_Relocator * pRelocator, - FLMUINT uiOldSize, - FLMUINT uiNewSize, - void * pvInitialData, - FLMUINT uiDataSize, - FLMBYTE ** ppucBuffer, - FLMBOOL * pbAllocatedOnHeap = NULL); - - void freeBuf( - FLMUINT uiSize, - FLMBYTE ** ppucBuffer); - - FLMUINT getTrueSize( - FLMUINT uiSize, - FLMBYTE * pucBuffer); - - void defragmentMemory( void); - -private: - - F_FixedAlloc * getAllocator( - FLMUINT uiSize); - - F_SlabManager * m_pSlabManager; - F_FixedAlloc * m_ppAllocators[ NUM_BUF_ALLOCATORS]; -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -class F_MultiAlloc : public XF_RefCount, public XF_Base -{ -public: - - F_MultiAlloc() - { - m_pSlabManager = NULL; - m_puiCellSizes = NULL; - m_ppAllocators = NULL; - } - - ~F_MultiAlloc() - { - cleanup(); - } - - RCODE setup( - F_SlabManager * pSlabManager, - FLMBOOL bMemProtect, - FLMUINT * puiCellSizes, - XFLM_SLAB_USAGE * pUsageStats); - - RCODE allocBuf( - IF_Relocator * pRelocator, - FLMUINT uiSize, - FLMBYTE ** ppucBuffer, - FLMBOOL bMutexLocked = FALSE); - - RCODE reallocBuf( - IF_Relocator * pRelocator, - FLMUINT uiNewSize, - FLMBYTE ** ppucBuffer, - FLMBOOL bMutexLocked = FALSE); - - FINLINE void freeBuf( - FLMBYTE ** ppucBuffer) - { - if( ppucBuffer && *ppucBuffer) - { - getAllocator( *ppucBuffer)->freeCell( *ppucBuffer, FALSE); - *ppucBuffer = NULL; - } - } - - void defragmentMemory( void); - - FINLINE FLMUINT getTrueSize( - FLMBYTE * pucBuffer) - { - return( getAllocator( pucBuffer)->getCellSize()); - } - -#ifdef FLM_CACHE_PROTECT - void protectBuffer( - void * pvBuffer, - FLMBOOL bMutexLocked = FALSE); - - void unprotectBuffer( - void * pvBuffer, - FLMBOOL bMutexLocked = FALSE); -#endif - - FINLINE void lockMutex( void) - { - m_pSlabManager->lockMutex(); - } - - FINLINE void unlockMutex( void) - { - m_pSlabManager->unlockMutex(); - } - -private: - - F_FixedAlloc * getAllocator( - FLMUINT uiSize); - - F_FixedAlloc * getAllocator( - FLMBYTE * pucBuffer); - - void cleanup( void); - - F_SlabManager * m_pSlabManager; - FLMUINT * m_puiCellSizes; - F_FixedAlloc ** m_ppAllocators; -}; - -#endif // FLFIXED_H diff --git a/xflaim/src/flgethdr.cpp b/xflaim/src/flgethdr.cpp index cbba4a9..6bc54f4 100644 --- a/xflaim/src/flgethdr.cpp +++ b/xflaim/src/flgethdr.cpp @@ -40,7 +40,7 @@ RCODE flmGetHdrInfo( RCODE rc = NE_XFLM_OK; IF_FileHdl * pCFileHdl; - if( RC_BAD( rc = pSFileHdl->GetFileHdl( 0, FALSE, &pCFileHdl))) + if( RC_BAD( rc = pSFileHdl->getFileHdl( 0, FALSE, &pCFileHdl))) { goto Exit; } diff --git a/xflaim/src/flindex.cpp b/xflaim/src/flindex.cpp index 2ac5581..5ba3630 100644 --- a/xflaim/src/flindex.cpp +++ b/xflaim/src/flindex.cpp @@ -26,13 +26,13 @@ #include "flaimsys.h" FSTATIC RCODE flmBackgroundIndexBuildThrd( - F_Thread * pThread); - + IF_Thread * pThread); + /**************************************************************************** Desc : Return the status of the index. Notes: ****************************************************************************/ -RCODE XFLMAPI F_Db::indexStatus( +RCODE FLMAPI F_Db::indexStatus( FLMUINT uiIndexNum, XFLM_INDEX_STATUS * pIndexStatus) { @@ -133,7 +133,7 @@ Exit: Desc: Return the number of the next index. Pass in zero to get the first index. ****************************************************************************/ -RCODE XFLMAPI F_Db::indexGetNext( +RCODE FLMAPI F_Db::indexGetNext( FLMUINT * puiIndexNum) { RCODE rc = NE_XFLM_OK; @@ -832,7 +832,7 @@ RCODE F_Db::startIndexBuild( // Generate the thread name - if (RC_BAD( rc = gv_pFileSystem->pathReduce( m_pDatabase->m_pszDbPath, + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathReduce( m_pDatabase->m_pszDbPath, szThreadName, szBaseName))) { goto Exit; @@ -844,9 +844,9 @@ RCODE F_Db::startIndexBuild( // Start the thread in the background indexing thread group. // The new thread will cleanup pBackgroundIx on termination. - if (RC_BAD( rc = f_threadCreate( NULL, + if (RC_BAD( rc = gv_XFlmSysData.pThreadMgr->createThread( NULL, flmBackgroundIndexBuildThrd, szThreadName, - FLM_BACKGROUND_INDEXING_THREAD_GROUP, uiIndexNum, + gv_XFlmSysData.uiIndexingThreadGroup, uiIndexNum, (void *)pBackgroundIx, NULL, 24000))) { goto Exit; @@ -867,10 +867,9 @@ Desc: This routine is called by the thread that performs background indexing. ****************************************************************************/ RCODE F_Db::backgroundIndexBuild( - F_Thread * pThread, + IF_Thread * pThread, FLMBOOL * pbShutdown, - FLMINT * piErrorLine - ) + FLMINT * piErrorLine) { RCODE rc = NE_XFLM_OK; IXD * pIxd; @@ -1019,7 +1018,7 @@ Desc: Thread that will build an index in the background. freed at the conclusion of the routine. ****************************************************************************/ FSTATIC RCODE flmBackgroundIndexBuildThrd( - F_Thread * pThread) + IF_Thread * pThread) { RCODE rc = NE_XFLM_OK; F_BKGND_IX * pBackgroundIx = (F_BKGND_IX *)pThread->getParm1(); @@ -1084,7 +1083,7 @@ Exit: if (RC_BAD(rc) && !bForcedShutdown) { - if (rc == NE_XFLM_MEM || rc == NE_XFLM_IO_DISK_FULL || + if (rc == NE_XFLM_MEM || rc == NE_FLM_IO_DISK_FULL || rc == NE_XFLM_MUST_WAIT_CHECKPOINT) { // Log the error @@ -1138,7 +1137,7 @@ F_BKGND_IX * flmBackgroundIndexGet( FLMUINT * puiThreadId) { RCODE rc = NE_XFLM_OK; - F_Thread * pThread; + IF_Thread * pThread; FLMUINT uiThreadId; F_BKGND_IX * pBackgroundIx = NULL; @@ -1151,7 +1150,7 @@ F_BKGND_IX * flmBackgroundIndexGet( for( ;;) { if (RC_BAD( rc = gv_XFlmSysData.pThreadMgr->getNextGroupThread( - &pThread, FLM_BACKGROUND_INDEXING_THREAD_GROUP, &uiThreadId))) + &pThread, gv_XFlmSysData.uiIndexingThreadGroup, &uiThreadId))) { if( rc == NE_XFLM_NOT_FOUND) { diff --git a/xflaim/src/flkeyret.cpp b/xflaim/src/flkeyret.cpp index d450df8..9c3b88c 100644 --- a/xflaim/src/flkeyret.cpp +++ b/xflaim/src/flkeyret.cpp @@ -46,7 +46,7 @@ RCODE F_Db::keyRetrieve( LFILE * pLFile; FLMBYTE * pucSearchKey = NULL; FLMBYTE * pucFoundKey = NULL; - void * pvMark = m_TempPool.poolMark(); + void * pvMark = m_pTempPool->poolMark(); FLMUINT uiSearchKeyLen = 0; FLMUINT uiFoundKeyLen; FLMUINT uiOriginalFlags; @@ -91,14 +91,14 @@ RCODE F_Db::keyRetrieve( if (pSearchKey) { - if (RC_BAD( rc = m_TempPool.poolAlloc( XFLM_MAX_KEY_SIZE, + if (RC_BAD( rc = m_pTempPool->poolAlloc( XFLM_MAX_KEY_SIZE, (void **)&pucSearchKey))) { goto Exit; } } - if (RC_BAD( rc = m_TempPool.poolAlloc( XFLM_MAX_KEY_SIZE, (void **)&pucFoundKey))) + if (RC_BAD( rc = m_pTempPool->poolAlloc( XFLM_MAX_KEY_SIZE, (void **)&pucFoundKey))) { goto Exit; } @@ -288,7 +288,7 @@ RCODE F_Db::keyRetrieve( else { uiDataBufSize = uiDataLen; - if (RC_BAD( rc = m_TempPool.poolAlloc( uiDataBufSize, + if (RC_BAD( rc = m_pTempPool->poolAlloc( uiDataBufSize, (void **)&pucData))) { goto Exit; @@ -315,7 +315,7 @@ RCODE F_Db::keyRetrieve( Exit: - m_TempPool.poolReset( pvMark); + m_pTempPool->poolReset( pvMark); if (pbtree) { diff --git a/xflaim/src/flog.cpp b/xflaim/src/flog.cpp index c952b6c..0f53a44 100644 --- a/xflaim/src/flog.cpp +++ b/xflaim/src/flog.cpp @@ -25,396 +25,6 @@ #include "flaimsys.h" -FSTATIC void flmLogProcessFormatString( - FLMUINT uiLen, - IF_LogMessageClient * pLogMessage, ...); - -FSTATIC void flmLogParsePrintfArgs( - FLMBYTE * pszFormat, - f_va_list * args, - IF_LogMessageClient * pLogMessage); - -FSTATIC void flmLogStringFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - IF_LogMessageClient * pLogMessage, - f_va_list * args); - -FSTATIC void flmLogNumberFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - IF_LogMessageClient * pLogMessage, - f_va_list * args); - -FSTATIC void flmLogErrorFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - IF_LogMessageClient * pLogMessage, - f_va_list * args); - -FSTATIC void flmLogColorFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - IF_LogMessageClient * pLogMessage, - f_va_list * args); - -FSTATIC void flmLogCharFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - IF_LogMessageClient * pLogMessage, - f_va_list * args); - -FSTATIC void flmLogNotHandledFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - IF_LogMessageClient * pLogMessage, - f_va_list * args); - -/**************************************************************************** -Desc: Handle text portions of the format string -****************************************************************************/ -FSTATIC void flmLogProcessFormatString( - FLMUINT uiLen, - IF_LogMessageClient * pLogMessage, ...) -{ - f_va_list args; - - f_va_start( args, pLogMessage); - if( uiLen) - { - flmLogStringFormatter( 0, uiLen, uiLen, 0, pLogMessage, &args); - } - f_va_end(args); -} - -/**************************************************************************** -Desc: Parse arguments in format string, calling appropriate handlers -****************************************************************************/ -FSTATIC void flmLogParsePrintfArgs( - FLMBYTE * pszFormat, - f_va_list * args, - IF_LogMessageClient * pLogMessage) -{ - FLMBYTE ucChar; - FLMUINT uiFlags; - FLMUINT uiWidth; - FLMUINT uiPrecision; - FLMBYTE * pszTextStart = pszFormat; - - while( (ucChar = *pszFormat++) != 0) - { - if( ucChar != '%') - { - // Handle invalid characters - if( ucChar < ASCII_SPACE || ucChar > ASCII_TILDE) - { - uiWidth = (FLMUINT)(pszFormat - pszTextStart - 1); - - if( uiWidth) - { - flmLogProcessFormatString( uiWidth, - pLogMessage, pszTextStart); - } - - // Only call newline() if ASCII_NEWLINE character. - // We will skip ASCII_CR characters - - if( ucChar == ASCII_NEWLINE) - { - pLogMessage->newline(); - } - pszTextStart = pszFormat; - } - - continue; - } - - uiWidth = (FLMUINT)(pszFormat - pszTextStart - 1); - flmLogProcessFormatString( uiWidth, pLogMessage, pszTextStart); - - flmSprintfProcessFieldInfo( &pszFormat, &uiWidth, - &uiPrecision, &uiFlags, args); - - ucChar = (unsigned char)*pszFormat++; - switch( ucChar) - { - case '%': - case 'c': - flmLogCharFormatter( ucChar, uiWidth, - uiPrecision, uiFlags, pLogMessage, args); - break; - case 'C': - flmLogColorFormatter( ucChar, uiWidth, - uiPrecision, uiFlags, pLogMessage, args); - break; - case 'd': - case 'o': - case 'u': - case 'x': - case 'X': - flmLogNumberFormatter( ucChar, uiWidth, - uiPrecision, uiFlags, pLogMessage, args); - break; - case 's': - case 'S': - flmLogStringFormatter( ucChar, uiWidth, - uiPrecision, uiFlags, pLogMessage, args); - break; - case 'e': - flmLogErrorFormatter( ucChar, uiWidth, - uiPrecision, uiFlags, pLogMessage, args); - break; - default: - flmLogNotHandledFormatter( ucChar, uiWidth, - uiPrecision, uiFlags, pLogMessage, args); - break; - } - - pszTextStart = pszFormat; - } - - flmLogProcessFormatString( (FLMUINT)(pszFormat - pszTextStart - 1), - pLogMessage, pszTextStart); -} - -/**************************************************************************** -Desc: Default string formatter. -****************************************************************************/ -FSTATIC void flmLogStringFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - IF_LogMessageClient * pLogMessage, - f_va_list * args) -{ - FLMBYTE ucOutputBuf[ 128]; - FLMBYTE * pszDest = &ucOutputBuf[ 0]; - FLMUINT uiMaxLen = sizeof( ucOutputBuf) - 1; - void * pAllocBuf = NULL; - F_SPRINTF_INFO info; - - if( uiWidth >= uiMaxLen) - { - // Need to allocate a temporary buffer - - uiMaxLen = uiWidth; - if (RC_BAD( f_alloc( (FLMUINT)(uiMaxLen + 1), &pAllocBuf))) - { - uiWidth = uiMaxLen; - } - else - { - pszDest = (FLMBYTE *)pAllocBuf; - } - } - - f_memset( &info, 0, sizeof( info)); - info.pszDestStr = pszDest; - - flmSprintfStringFormatter( ucFormatChar, uiWidth, uiPrecision, - uiFlags, &info, args); - - pLogMessage->appendString( (char *)pszDest); - - if( pAllocBuf) - { - f_free( &pAllocBuf); - } -} - -/**************************************************************************** -Desc: Default number formatter. -****************************************************************************/ -FSTATIC void flmLogNumberFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - IF_LogMessageClient * pLogMessage, - f_va_list * args) -{ - FLMBYTE ucOutputBuf[ 128]; - F_SPRINTF_INFO info; - - f_memset( &info, 0, sizeof( info)); - info.pszDestStr = &ucOutputBuf[ 0]; - flmSprintfNumberFormatter( ucFormatChar, uiWidth, - uiPrecision, uiFlags, &info, args); - pLogMessage->appendString( (char *)ucOutputBuf); -} - -/**************************************************************************** -Desc: Default error formatter. -****************************************************************************/ -FSTATIC void flmLogErrorFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - IF_LogMessageClient * pLogMessage, - f_va_list * args) -{ - FLMBYTE ucOutputBuf[ 128]; - F_SPRINTF_INFO info; - - f_memset( &info, 0, sizeof( info)); - info.pszDestStr = &ucOutputBuf[ 0]; - flmSprintfErrorFormatter( ucFormatChar, uiWidth, - uiPrecision, uiFlags, &info, args); - pLogMessage->appendString( (char *)ucOutputBuf); -} - -/**************************************************************************** -Desc: Color formatter -****************************************************************************/ -FSTATIC void flmLogColorFormatter( - FLMBYTE, // ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - IF_LogMessageClient * pLogMessage, - f_va_list * // args - ) -{ - if( uiFlags & FLM_PRINTF_PLUS_FLAG) - { - // Push a color onto the stack - - if( !uiWidth) - { - // Foreground - - pLogMessage->pushForegroundColor(); - } - else - { - // Background - - pLogMessage->pushBackgroundColor(); - } - } - else if( uiFlags & FLM_PRINTF_MINUS_FLAG) - { - // Pop a color from the color stack - - if( !uiWidth) - { - // Foreground - - pLogMessage->popForegroundColor(); - } - else - { - // Background - - pLogMessage->popBackgroundColor(); - } - } - else - { - eColorType eForeground = (eColorType)(uiWidth + 1); - eColorType eBackground = (eColorType)(uiPrecision + 1); - - // Set a new foreground and/or background color - - if( eForeground >= XFLM_NUM_COLORS || eBackground >= XFLM_NUM_COLORS) - { - goto Exit; - } - - pLogMessage->changeColor( eForeground, eBackground); - } - -Exit: - - return; -} - -/**************************************************************************** -Desc: Default character formatter. - Prints the character specified by VALUE in 'c', or the '%' character. - Format: %[flags][width][.prec]'c' - flags = - width = - prec = -****************************************************************************/ -FSTATIC void flmLogCharFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - IF_LogMessageClient * pLogMessage, - f_va_list * args) -{ - FLMBYTE ucOutputBuf[ 32]; - F_SPRINTF_INFO info; - - f_memset( &info, 0, sizeof( info)); - info.pszDestStr = &ucOutputBuf[ 0]; - flmSprintfCharFormatter( ucFormatChar, uiWidth, - uiPrecision, uiFlags, &info, args); - pLogMessage->appendString( (char *)ucOutputBuf); -} - -/**************************************************************************** -Desc: Unhandled format strings -****************************************************************************/ -FSTATIC void flmLogNotHandledFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - IF_LogMessageClient * pLogMessage, - f_va_list * args) -{ - FLMBYTE ucOutputBuf[ 64]; - F_SPRINTF_INFO info; - - f_memset( &info, 0, sizeof( info)); - info.pszDestStr = &ucOutputBuf[ 0]; - flmSprintfNotHandledFormatter( ucFormatChar, uiWidth, - uiPrecision, uiFlags, &info, args); - pLogMessage->appendString( (char *)ucOutputBuf); -} - -/**************************************************************************** -Desc: Main entry point for printf functionality. -****************************************************************************/ -void flmLogPrintf( - IF_LogMessageClient * pLogMessage, - const char * szFormatStr, ...) -{ - f_va_list args; - - f_va_start( args, szFormatStr); - flmLogParsePrintfArgs( (FLMBYTE *)szFormatStr, &args, pLogMessage); - f_va_end( args); -} - -/**************************************************************************** -Desc: Printf routine that accepts a va_list argument -****************************************************************************/ -void flmLogVPrintf( - IF_LogMessageClient * pLogMessage, - const char * szFormatStr, - f_va_list * args) -{ - flmLogParsePrintfArgs( (FLMBYTE *)szFormatStr, args, pLogMessage); -} - /**************************************************************************** Desc: Returns an IF_LogMessageClient object if logging is enabled for the specified message type @@ -469,7 +79,7 @@ void flmLogError( f_sprintf( (char *)pszMsgBuf, "Error %s: %e.", pszDoing, rc); } - pLogMsg->changeColor( XFLM_YELLOW, XFLM_BLACK); + pLogMsg->changeColor( FLM_YELLOW, FLM_BLACK); pLogMsg->appendString( (char *)pszMsgBuf); } flmEndLogMessage( &pLogMsg); diff --git a/xflaim/src/flopen.cpp b/xflaim/src/flopen.cpp index 1db2d21..8b8221d 100644 --- a/xflaim/src/flopen.cpp +++ b/xflaim/src/flopen.cpp @@ -31,8 +31,8 @@ FSTATIC void flmFreeCPInfo( CP_INFO ** ppCPInfoRV); FSTATIC RCODE flmCPThread( - F_Thread * pThread); - + IF_Thread * pThread); + /*************************************************************************** Desc: Does most of the actual work of opening an existing database, but doesn't provide COM interfaces... @@ -50,7 +50,7 @@ RCODE F_DbSystem::openDb( *ppDb = NULL; if (!pszDbFileName || *pszDbFileName == 0) { - rc = RC_SET( NE_XFLM_IO_INVALID_FILENAME); + rc = RC_SET( NE_FLM_IO_INVALID_FILENAME); goto Exit; } @@ -129,8 +129,34 @@ F_Db::F_Db( m_bKrefCompoundKey = FALSE; m_pKrefReset = NULL; - m_tmpKrefPool.poolInit( 8192); - m_TempPool.poolInit( XFLM_MAX_KEY_SIZE * 4); + m_pTmpKrefPool = NULL; + m_pTempPool = NULL; +} + +/*************************************************************************** +Desc: +****************************************************************************/ +RCODE F_Db::setup( void) +{ + RCODE rc = NE_XFLM_OK; + + if( RC_BAD( rc = FlmAllocPool( &m_pTmpKrefPool))) + { + goto Exit; + } + + m_pTmpKrefPool->poolInit( 8192); + + if( RC_BAD( rc = FlmAllocPool( &m_pTempPool))) + { + goto Exit; + } + + m_pTempPool->poolInit( XFLM_MAX_KEY_SIZE * 4); + +Exit: + + return( rc); } /*************************************************************************** @@ -154,6 +180,11 @@ RCODE F_DbSystem::allocDb( goto Exit; } + if( RC_BAD( rc = pDb->setup())) + { + goto Exit; + } + if( RC_BAD( rc = f_semCreate( &pDb->m_hWaitSem))) { goto Exit; @@ -467,7 +498,7 @@ RCODE F_Database::verifyOkToUse( if (m_uiFlags & DBF_BEING_CLOSED) { - rc = RC_SET( NE_XFLM_IO_ACCESS_DENIED); + rc = RC_SET( NE_FLM_IO_ACCESS_DENIED); goto Exit; } @@ -522,11 +553,11 @@ RCODE flmCreateLckFile( char szLockPath [F_PATH_MAX_SIZE]; char szDbBaseName [F_FILENAME_SIZE]; char * pszFileExt; - F_FileHdl * pLockFileHdl = NULL; + IF_FileHdl * pLockFileHdl = NULL; char szFilePathStr[ F_PATH_MAX_SIZE]; + FLMUINT uiIoFlags; - - if( RC_BAD( rc = gv_pFileSystem->pathToStorageString( + if( RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathToStorageString( pszFilePath, szFilePathStr))) { goto Exit; @@ -535,7 +566,8 @@ RCODE flmCreateLckFile( // Extract the 8.3 name and put a .lck extension on it to create // the full path for the .lck file. - if (RC_BAD( rc = gv_pFileSystem->pathReduce( szFilePathStr, szLockPath, szDbBaseName))) + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathReduce( + szFilePathStr, szLockPath, szDbBaseName))) { goto Exit; } @@ -544,7 +576,8 @@ RCODE flmCreateLckFile( pszFileExt++; f_strcpy( pszFileExt, ".lck"); - if (RC_BAD( rc = gv_pFileSystem->pathAppend( szLockPath, szDbBaseName))) + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathAppend( + szLockPath, szDbBaseName))) { goto Exit; } @@ -556,52 +589,41 @@ RCODE flmCreateLckFile( // then attempt to create the file again. If it, or the 2nd create // fail, we simply return an access denied error. - if ((pLockFileHdl = f_new F_FileHdl) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - +uiIoFlags = FLM_IO_RDWR | FLM_IO_EXCL | FLM_IO_SH_DENYRW; #ifndef FLM_UNIX - pLockFileHdl->setupFileHdl( 0, TRUE); -#else - - // On Unix, we do not want to delete the file because it - // will succeed even if someone else has the file open. - - pLockFileHdl->setupFileHdl( 0, FALSE); + uiIoFlags |= FLM_IO_DELETE_ON_RELEASE; #endif - if( RC_BAD( pLockFileHdl->Create( szLockPath, - XFLM_IO_RDWR | XFLM_IO_EXCL | XFLM_IO_SH_DENYRW))) + if( RC_BAD( gv_XFlmSysData.pFileSystem->createFile( + szLockPath, uiIoFlags, &pLockFileHdl))) { #ifndef FLM_UNIX - if (RC_BAD( gv_pFileSystem->Delete( szLockPath))) + if (RC_BAD( gv_XFlmSysData.pFileSystem->deleteFile( szLockPath))) { - rc = RC_SET( NE_XFLM_IO_ACCESS_DENIED); + rc = RC_SET( NE_FLM_IO_ACCESS_DENIED); goto Exit; } - else if (RC_BAD( pLockFileHdl->Create( szLockPath, - XFLM_IO_RDWR | XFLM_IO_EXCL | XFLM_IO_SH_DENYRW))) + else if (RC_BAD( gv_XFlmSysData.pFileSystem->createFile( + szLockPath, uiIoFlags, &pLockFileHdl))) { - rc = RC_SET( NE_XFLM_IO_ACCESS_DENIED); + rc = RC_SET( NE_FLM_IO_ACCESS_DENIED); goto Exit; } #else - if( RC_BAD( pLockFileHdl->Open( szLockPath, - XFLM_IO_RDWR | XFLM_IO_SH_DENYRW))) + if( RC_BAD( gv_XFlmSysData.pFileSystem->openFile( + szLockPath, FLM_IO_RDWR | FLM_IO_SH_DENYRW, &pLockFileHdl))) { - rc = RC_SET( NE_XFLM_IO_ACCESS_DENIED); + rc = RC_SET( NE_FLM_IO_ACCESS_DENIED); goto Exit; } #endif } #ifdef FLM_UNIX - if( RC_BAD( pLockFileHdl->Lock())) + if( RC_BAD( pLockFileHdl->lock())) { - rc = RC_SET( NE_XFLM_IO_ACCESS_DENIED); + rc = RC_SET( NE_FLM_IO_ACCESS_DENIED); goto Exit; } #endif @@ -611,7 +633,7 @@ RCODE flmCreateLckFile( Exit: if (pLockFileHdl) { - (void)pLockFileHdl->Close(); + (void)pLockFileHdl->close(); pLockFileHdl->Release(); pLockFileHdl = NULL; } @@ -801,7 +823,7 @@ Exit: if (RC_BAD( rc)) { - (void)pDb->m_pSFileHdl->ReleaseFiles( TRUE); + (void)pDb->m_pSFileHdl->releaseFiles( TRUE); } return( rc); @@ -861,7 +883,8 @@ RCODE F_DbSystem::findDatabase( // NOTE: On non-UNIX, non-WIN platforms, this will basically convert // the string to upper case. - if (RC_BAD( rc = gv_pFileSystem->pathToStorageString( pszDbPath, szDbPathStr1))) + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathToStorageString( + pszDbPath, szDbPathStr1))) { goto Exit; } @@ -896,7 +919,7 @@ Retry: if (pszDataDir && *pszDataDir) { - if (RC_BAD( rc = gv_pFileSystem->pathToStorageString( + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathToStorageString( pszDataDir, szDbPathStr2))) { goto Exit; @@ -1054,11 +1077,13 @@ F_Database::F_Database( { m_uiFileExtendSize = 65536; } + m_pRfl = NULL; + f_memset( &m_lastCommittedDbHdr, 0, sizeof( m_lastCommittedDbHdr)); f_memset( &m_checkpointDbHdr, 0, sizeof( m_checkpointDbHdr)); f_memset( &m_uncommittedDbHdr, 0, sizeof( m_uncommittedDbHdr)); - m_pFileIdList = NULL; + m_pBufferMgr = NULL; m_pCurrLogBuffer = NULL; m_uiCurrLogWriteOffset = 0; @@ -1248,18 +1273,6 @@ F_Database::~F_Database() freeBlockCache(); freeNodeCache(); - // Free the database ID list. This will also remove all file handles - // associated with this database. - - if (m_pFileIdList) - { - FLMUINT uiRefCnt; - - uiRefCnt = m_pFileIdList->Release(); - flmAssert( !uiRefCnt); - m_pFileIdList = NULL; - } - // Release the lock objects. if (m_pWriteLockObj) @@ -1278,7 +1291,7 @@ F_Database::~F_Database() if (m_pLockFileHdl) { - (void)m_pLockFileHdl->Close(); + (void)m_pLockFileHdl->close(); m_pLockFileHdl->Release(); m_pLockFileHdl = NULL; } @@ -1295,15 +1308,7 @@ F_Database::~F_Database() if (m_pDbHdrWriteBuf) { -#ifdef FLM_WIN - (void)VirtualFree( m_pDbHdrWriteBuf, 0, MEM_RELEASE); - m_pDbHdrWriteBuf = NULL; -#elif defined( FLM_LINUX) || defined( FLM_SOLARIS) - free( m_pDbHdrWriteBuf); - m_pDbHdrWriteBuf = NULL; -#else - f_free( &m_pDbHdrWriteBuf); -#endif + f_freeAlignedBuffer( (void **)&m_pDbHdrWriteBuf); } // Free the update buffer @@ -1313,8 +1318,12 @@ F_Database::~F_Database() f_free( &m_pucUpdBuffer); m_uiUpdBufferSize = 0; } + + if( m_pKrefPool) + { + m_pKrefPool->Release(); + } - m_krefPool.poolFree(); if (m_ppBlocksDone) { f_free( &m_ppBlocksDone); @@ -1410,7 +1419,7 @@ RCODE F_Database::setupDatabase( char szDbPathStr[ F_PATH_MAX_SIZE]; char szDataDirStr[ F_PATH_MAX_SIZE]; - if( RC_BAD( rc = gv_pFileSystem->pathToStorageString( + if( RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathToStorageString( pszDbPath, szDbPathStr))) { goto Exit; @@ -1419,7 +1428,7 @@ RCODE F_Database::setupDatabase( if( pszDataDir && *pszDataDir) { - if( RC_BAD( rc = gv_pFileSystem->pathToStorageString( + if( RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathToStorageString( pszDataDir, szDataDirStr))) { goto Exit; @@ -1445,8 +1454,13 @@ RCODE F_Database::setupDatabase( { goto Exit; } + + if( RC_BAD( rc = FlmAllocPool( &m_pKrefPool))) + { + goto Exit; + } - m_krefPool.poolInit( DEFAULT_KREF_POOL_BLOCK_SIZE * 8); + m_pKrefPool->poolInit( DEFAULT_KREF_POOL_BLOCK_SIZE * 8); // Allocate a buffer for writing the DB header // If we are a temporary database, there is no need @@ -1454,43 +1468,17 @@ RCODE F_Database::setupDatabase( if (!m_bTempDb) { -#ifdef FLM_WIN - if ((m_pDbHdrWriteBuf = (XFLM_DB_HDR *)VirtualAlloc( NULL, - XFLM_MAX_BLOCK_SIZE, MEM_COMMIT, PAGE_READWRITE)) == NULL) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_MEM); - goto Exit; - } - f_memset( m_pDbHdrWriteBuf, 0, XFLM_MAX_BLOCK_SIZE); -#elif defined( FLM_LINUX) - if( posix_memalign( (void **)&m_pDbHdrWriteBuf, - sysconf( _SC_PAGESIZE), XFLM_MAX_BLOCK_SIZE) != 0) - { - rc = MapErrnoToFlaimErr( errno, NE_XFLM_MEM); - goto Exit; - } - f_memset( m_pDbHdrWriteBuf, 0, XFLM_MAX_BLOCK_SIZE); -#elif defined( FLM_SOLARIS) - if( (m_pDbHdrWriteBuf = (XFLM_DB_HDR *)memalign( - sysconf( _SC_PAGESIZE), XFLM_MAX_BLOCK_SIZE)) == NULL) - { - rc = MapErrnoToFlaimErr( errno, NE_XFLM_MEM); - goto Exit; - } - f_memset( m_pDbHdrWriteBuf, 0, XFLM_MAX_BLOCK_SIZE); -#else - if (RC_BAD( rc = f_calloc( XFLM_MAX_BLOCK_SIZE, &m_pDbHdrWriteBuf))) + if( RC_BAD( rc = f_allocAlignedBuffer( + XFLM_MAX_BLOCK_SIZE, (void **)&m_pDbHdrWriteBuf))) { goto Exit; } -#endif } // Setup the write buffer managers. - - if ((m_pBufferMgr = f_new F_IOBufferMgr) == NULL) + + if( RC_BAD( rc = FlmAllocIOBufferMgr( &m_pBufferMgr))) { - rc = RC_SET( NE_XFLM_MEM); goto Exit; } @@ -1534,19 +1522,6 @@ RCODE F_Database::setupDatabase( goto Exit; } - // Allocate and initialize the file ID list - - if ((m_pFileIdList = f_new F_FileIdList) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = m_pFileIdList->setup())) - { - goto Exit; - } - // Allocate a lock object for write locking. if ((m_pWriteLockObj = gv_XFlmSysData.pServerLockMgr->GetLockObject( @@ -1636,7 +1611,7 @@ RCODE F_Database::readDbHdr( RCODE rc = NE_XFLM_OK; IF_FileHdl * pCFileHdl = NULL; - if (RC_BAD( rc = pSFileHdl->GetFileHdl( 0, FALSE, &pCFileHdl))) + if (RC_BAD( rc = pSFileHdl->getFileHdl( 0, FALSE, &pCFileHdl))) { goto Exit; } @@ -1662,11 +1637,13 @@ RCODE F_Database::readDbHdr( { f_free( &m_pszDbPasswd); } - if ( RC_BAD( rc = f_alloc( (f_strlen( pszPassword) + 1), &m_pszDbPasswd))) + if ( RC_BAD( rc = f_alloc( + (f_strlen( (const char *)pszPassword) + 1), &m_pszDbPasswd))) { goto Exit; } - f_strcpy(m_pszDbPasswd, pszPassword); + + f_strcpy( (char *)m_pszDbPasswd, (const char *)pszPassword); } if ((m_pWrappingKey = f_new F_CCS()) == NULL) @@ -1709,8 +1686,8 @@ Exit: if (pCFileHdl) { - (void)pSFileHdl->ReleaseFile( (FLMUINT)0, TRUE); - pSFileHdl->SetBlockSize( m_uiBlockSize); + (void)pSFileHdl->releaseFile( (FLMUINT)0, TRUE); + pSFileHdl->setBlockSize( m_uiBlockSize); } return( rc); @@ -1783,15 +1760,14 @@ RCODE F_Database::startCPThread( void) // Set up the super file - if (RC_BAD( rc = pCPInfo->pSFileHdl->Setup( m_pFileIdList, - m_pszDbPath, m_pszDataDir))) + if (RC_BAD( rc = pCPInfo->pSFileHdl->setup( m_pszDbPath, m_pszDataDir))) { goto Exit; } if (m_lastCommittedDbHdr.ui32DbVersion) { - pCPInfo->pSFileHdl->SetBlockSize( m_uiBlockSize); + pCPInfo->pSFileHdl->setBlockSize( m_uiBlockSize); } f_memset( &pCPInfo->Stats, 0, sizeof( XFLM_STATS)); @@ -1799,7 +1775,7 @@ RCODE F_Database::startCPThread( void) // Generate the thread name - if (RC_BAD( rc = gv_pFileSystem->pathReduce( m_pszDbPath, + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathReduce( m_pszDbPath, szThreadName, szBaseName))) { goto Exit; @@ -1809,9 +1785,9 @@ RCODE F_Database::startCPThread( void) // Start the checkpoint thread. - if (RC_BAD( rc = f_threadCreate( &m_pCPThrd, - flmCPThread, szThreadName, - FLM_CHECKPOINT_THREAD_GROUP, 0, pCPInfo, NULL, 32000))) + if (RC_BAD( rc = gv_XFlmSysData.pThreadMgr->createThread( &m_pCPThrd, + flmCPThread, szThreadName, gv_XFlmSysData.uiCheckpointThreadGroup, + 0, pCPInfo, NULL, 32000))) { goto Exit; } @@ -1834,7 +1810,7 @@ Desc: Try to perform a checkpoint on the database. Returns TRUE if we need to terminate. ****************************************************************************/ FLMBOOL F_Database::tryCheckpoint( - F_Thread * pThread, + IF_Thread * pThread, CP_INFO * pCPInfo) { RCODE rc = NE_XFLM_OK; @@ -1978,7 +1954,7 @@ Desc: This routine functions as a thread. It monitors open files and close time. ****************************************************************************/ FSTATIC RCODE flmCPThread( - F_Thread * pThread) + IF_Thread * pThread) { CP_INFO * pCPInfo = (CP_INFO *)pThread->getParm1(); F_Database * pDatabase = pCPInfo->pDatabase; diff --git a/xflaim/src/flprintf.cpp b/xflaim/src/flprintf.cpp deleted file mode 100644 index 4825570..0000000 --- a/xflaim/src/flprintf.cpp +++ /dev/null @@ -1,769 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: sprintf and vsprintf -// -// Tabs: 3 -// -// Copyright (c) 2002-2003,2005-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: flprintf.cpp 3113 2006-01-19 13:20:35 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -FSTATIC void flmSprintfParseArgs( - FLMBYTE * pszFormat, - F_SPRINTF_INFO * pInfo, - f_va_list * args); - -FSTATIC void flmProcessFormatString( - FLMUINT uiLen, - F_SPRINTF_INFO * pInfo, - ...); - -FSTATIC FLMUINT flmPrintNumber( - FLMUINT64 ui64Val, - FLMUINT uiBase, - FLMBOOL bUpperCase, - FLMBOOL bCommas, - FLMBYTE * pszBuf); - -/**************************************************************************** -Desc: Parameter 'format' points to text following a '%' sign. Process - legal field information. Leave 'format' pointing at the format - specifier char. -****************************************************************************/ -void flmSprintfProcessFieldInfo( - FLMBYTE ** ppszFormat, - FLMUINT * puiWidth, - FLMUINT * puiPrecision, - FLMUINT * puiFlags, - f_va_list * args) -{ - FLMBYTE * pszFormat = *ppszFormat; - - // Process flags - - *puiFlags = 0; - for( ;;) - { - switch( *pszFormat) - { - case '-': - *puiFlags |= FLM_PRINTF_MINUS_FLAG; - break; - - case '+': - *puiFlags |= FLM_PRINTF_PLUS_FLAG; - break; - - case ' ': - *puiFlags |= FLM_PRINTF_SPACE_FLAG; - break; - - case '#': - *puiFlags |= FLM_PRINTF_POUND_FLAG; - break; - - case '0': - *puiFlags |= FLM_PRINTF_ZERO_FLAG; - break; - - case ',': - *puiFlags |= FLM_PRINTF_COMMA_FLAG; - break; - - default: - goto NoMoreFlags; - } - - pszFormat++; - } - -NoMoreFlags: - - // Process width - - *puiWidth = 0; - if( *pszFormat == '*') - { - *puiWidth = f_va_arg( *args, unsigned int); - pszFormat++; - } - else - { - while( *pszFormat >= '0' && *pszFormat <= '9') - { - *puiWidth = (*puiWidth * 10) + (*pszFormat - '0'); - pszFormat++; - } - } - - // Process precision - - *puiPrecision = 0; - if( *pszFormat == '.') - { - pszFormat++; - if( *pszFormat == '*') - { - *puiPrecision = f_va_arg( *args, unsigned int); - pszFormat++; - } - else while( *pszFormat >= '0' && *pszFormat <= '9') - { - *puiPrecision = (*puiPrecision * 10) + (*pszFormat - '0'); - pszFormat++; - } - } - - // Size modifiers - switch( *pszFormat) - { - case 'I': - if( pszFormat[ 1] == '6' && pszFormat[ 2] == '4') - { - *puiFlags |= FLM_PRINTF_INT64_FLAG; - pszFormat += 3; - } - else - { - flmAssert( 0); - } - break; - - case 'L': - *puiFlags |= FLM_PRINTF_DOUBLE_FLAG; - pszFormat++; - break; - - case 'l': - *puiFlags |= FLM_PRINTF_LONG_FLAG; - pszFormat++; - break; - - case 'h': - *puiFlags |= FLM_PRINTF_SHORT_FLAG; - pszFormat++; - break; - } - - *ppszFormat = pszFormat; - return; -} - -/**************************************************************************** -Desc: Handle text portions of the format string -****************************************************************************/ -FSTATIC void flmProcessFormatString( - FLMUINT uiLen, - F_SPRINTF_INFO * pInfo, - ...) -{ - f_va_list args; - - f_va_start( args, pInfo); - if( uiLen) - { - flmSprintfStringFormatter( 0, uiLen, uiLen, 0, pInfo, &args); - } - f_va_end( args); -} - -/**************************************************************************** -Desc: Parse arguments in format string, calling appropriate handlers -****************************************************************************/ -FSTATIC void flmSprintfParseArgs( - FLMBYTE * pszFormat, - F_SPRINTF_INFO * pInfo, - f_va_list * args) -{ - FLMBYTE ucFormatChar; - FLMUINT uiFlags; - FLMUINT uiWidth; - FLMUINT uiPrecision; - FLMBYTE * pszTextStart = pszFormat; - - while( (ucFormatChar = (FLMBYTE)*pszFormat++) != 0) - { - if( ucFormatChar != '%') - { - continue; - } - - uiWidth = (FLMUINT)(pszFormat - pszTextStart - 1); - flmProcessFormatString( uiWidth, pInfo, pszTextStart); - - flmSprintfProcessFieldInfo( &pszFormat, &uiWidth, - &uiPrecision, &uiFlags, args); - - ucFormatChar = (unsigned char)*pszFormat++; - switch( ucFormatChar) - { - case '%': - case 'c': - flmSprintfCharFormatter( ucFormatChar, uiWidth, - uiPrecision, uiFlags, pInfo, args); - break; - - case 'd': - case 'i': - case 'o': - case 'u': - case 'x': - case 'X': - case 'p': - if( ucFormatChar == 'i') - { - ucFormatChar = 'd'; - } - - flmSprintfNumberFormatter( ucFormatChar, uiWidth, - uiPrecision, uiFlags, pInfo, args); - break; - - case 's': - case 'S': - case 'U': - flmSprintfStringFormatter( ucFormatChar, uiWidth, - uiPrecision, uiFlags, pInfo, args); - break; - - case 'e': - case 'E': - flmSprintfErrorFormatter( ucFormatChar, uiWidth, - uiPrecision, uiFlags, pInfo, args); - break; - - default: - flmSprintfNotHandledFormatter( ucFormatChar, uiWidth, - uiPrecision, uiFlags, pInfo, args); - break; - } - pszTextStart = pszFormat; - } - - flmProcessFormatString( (FLMUINT)(pszFormat - pszTextStart - 1), - pInfo, pszTextStart); -} - -/**************************************************************************** -Desc: Default string formatter. -****************************************************************************/ -void flmSprintfStringFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - F_SPRINTF_INFO * pInfo, - f_va_list * args) -{ - static FLMBYTE pszNullPointerStr[] = ""; - FLMUINT uiOutputLen; - FLMUINT uiCount; - FLMUNICODE * pUnicode; - FLMBYTE * pszStr = (FLMBYTE *)f_va_arg( *args, char *); - FLMBYTE * pszDest = pInfo->pszDestStr; - - if( !pszStr) - { - uiOutputLen = f_strlen( pszNullPointerStr); - } - else if( ucFormatChar == 'S') - { - uiOutputLen = *pszStr++; - } - else - { - if( ucFormatChar == 'U') - { - uiOutputLen = 0; - pUnicode = (FLMUNICODE *)pszStr; - while( *pUnicode) - { - if( *pUnicode >= 32 && *pUnicode <= 127) - { - uiOutputLen++; - } - else - { - uiOutputLen += 7; - } - pUnicode++; - } - } - else - { - uiOutputLen = f_strlen( pszStr); - } - } - - if( uiPrecision > 0 && uiOutputLen > uiPrecision) - { - uiOutputLen = uiPrecision; - } - - uiCount = uiWidth - uiOutputLen; - - if( uiOutputLen < uiWidth && !(uiFlags & FLM_PRINTF_MINUS_FLAG)) - { - // Right justify - - f_memset( pszDest, ' ', uiCount); - pszDest += uiCount; - } - - if( !pszStr) - { - f_memcpy( pszDest, pszNullPointerStr, uiOutputLen); - pszDest += uiOutputLen; - } - else if( ucFormatChar == 'U') - { - FLMUINT uiBytesOutput = 0; - - for( pUnicode = (FLMUNICODE *)pszStr; - uiBytesOutput < uiOutputLen && *pUnicode; pUnicode++) - { - if( *pUnicode >= 32 && *pUnicode <= 127) - { - *pszDest++ = (FLMBYTE)(*pUnicode); - uiBytesOutput++; - } - else - { - FLMBYTE szTmpBuf[ 8]; - FLMUINT uiTmpLen; - FLMBYTE * pszTmp; - - szTmpBuf[ 0] = '~'; - szTmpBuf[ 1] = '['; - uiTmpLen = flmPrintNumber( (FLMUINT64)(*pUnicode), - 16, TRUE, FALSE, &szTmpBuf[ 2]); - uiTmpLen += 2; - szTmpBuf[ uiTmpLen] = ']'; - szTmpBuf[ uiTmpLen + 1] = 0; - - pszTmp = szTmpBuf; - while( *pszTmp && uiBytesOutput < uiOutputLen) - { - *pszDest++ = *pszTmp; - pszTmp++; - uiBytesOutput++; - } - } - } - } - else - { - f_memcpy( pszDest, pszStr, uiOutputLen); - pszDest += uiOutputLen; - } - - if( uiOutputLen < uiWidth && (uiFlags & FLM_PRINTF_MINUS_FLAG)) - { - // Left justify - - f_memset( pszDest, ' ', uiCount); - pszDest += uiCount; - } - - *pszDest = 0; - uiCount = (FLMUINT)(pszDest - pInfo->pszDestStr); - pInfo->pszDestStr = pszDest; -} - -/**************************************************************************** -Desc: Converts a number to a string -****************************************************************************/ -FSTATIC FLMUINT flmPrintNumber( - FLMUINT64 ui64Val, - FLMUINT uiBase, - FLMBOOL bUpperCase, - FLMBOOL bCommas, - FLMBYTE * pszBuf) -{ - FLMBYTE ucChar; - FLMUINT uiOffset = 0; - FLMUINT uiDigitCount = 0; - FLMUINT uiLoop; - - // We don't support commas on bases other than 10 - - if( uiBase != 10) - { - bCommas = FALSE; - } - - // Build the number string from the value - - for( ;;) - { - ucChar = (FLMBYTE)(ui64Val % uiBase); - pszBuf[ uiOffset++] = (FLMBYTE)(ucChar > 9 - ? ucChar + (bUpperCase ? 'A' : 'a') - 10 - : ucChar + '0'); - uiDigitCount++; - - if( (ui64Val = (ui64Val / uiBase)) == 0) - { - break; - } - - if( bCommas && (uiDigitCount % 3) == 0) - { - pszBuf[ uiOffset++] = (FLMBYTE)','; - } - } - - // Reverse the string - - for( uiLoop = 0; uiLoop < uiOffset / 2; uiLoop++) - { - ucChar = pszBuf[ uiLoop]; - pszBuf[ uiLoop] = pszBuf[ uiOffset - uiLoop - 1]; - pszBuf[ uiOffset - uiLoop - 1] = ucChar; - } - - pszBuf[ uiOffset] = 0; - return( uiOffset); -} - -/**************************************************************************** -Desc: Default number formatter. - Format: %[flags][width][.prec]'E' -****************************************************************************/ -void flmSprintfNumberFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - F_SPRINTF_INFO * pInfo, - f_va_list * args) -{ - FLMUINT uiCount; - FLMUINT uiPrefix = FLM_PREFIX_NONE; - FLMUINT uiLength; - FLMUINT uiBase = 10; - FLMBYTE ucNumberBuffer[ 64]; - FLMBOOL bUpperCase = FALSE; - FLMBOOL bCommas = FALSE; - FLMBYTE * pszTmp; - FLMBYTE * pszDest = pInfo->pszDestStr; - FLMUINT64 ui64Val; - - if( ucFormatChar == 'p') - { - ui64Val = (FLMUINT64)((FLMUINT)f_va_arg( *args, void *)); - uiFlags |= FLM_PRINTF_POUND_FLAG; - } - else if( ucFormatChar != 'd') - { - // Unsigned number - - if( uiFlags & FLM_PRINTF_SHORT_FLAG) - { - ui64Val = (FLMUINT64)((unsigned int)f_va_arg( *args, int)); - } - else if( uiFlags & (FLM_PRINTF_LONG_FLAG | FLM_PRINTF_DOUBLE_FLAG)) - { - ui64Val = (FLMUINT64)((unsigned long int)f_va_arg( *args, long int)); - } - else if( uiFlags & FLM_PRINTF_INT64_FLAG) - { - ui64Val = f_va_arg( *args, FLMUINT64); - } - else - { - ui64Val = (FLMUINT64)((unsigned int)f_va_arg( *args, int)); - } - } - else - { - // Signed number - - if( uiFlags & FLM_PRINTF_SHORT_FLAG) - { - ui64Val = (FLMUINT64)((FLMINT64)f_va_arg( *args, int)); - } - else if( uiFlags & (FLM_PRINTF_LONG_FLAG | FLM_PRINTF_DOUBLE_FLAG)) - { - ui64Val = (FLMUINT64)((FLMINT64)f_va_arg( *args, long int)); - } - else if( uiFlags & FLM_PRINTF_INT64_FLAG) - { - ui64Val = (FLMUINT64)f_va_arg( *args, FLMINT64); - } - else - { - ui64Val = (FLMUINT64)((FLMINT64)f_va_arg( *args, int)); - } - } - - switch( ucFormatChar) - { - case 'd': - { - if( ((FLMINT64)ui64Val) < 0) - { - uiPrefix = FLM_PREFIX_MINUS; - if( uiWidth > 0) - { - uiWidth--; - } - ui64Val = (FLMUINT64)(-(FLMINT64)ui64Val); - } - else if( uiFlags & FLM_PRINTF_PLUS_FLAG) - { - uiPrefix = FLM_PREFIX_PLUS; - if( uiWidth > 0) - { - uiWidth--; - } - } - break; - } - - case 'o': - { - uiBase = 8; - break; - } - - case 'x': - case 'X': - case 'p': - { - if( (uiFlags & FLM_PRINTF_POUND_FLAG) && ui64Val) - { - uiPrefix = FLM_PREFIX_POUND; - if( uiWidth > 1) - { - uiWidth -= 2; - } - } - uiBase = 16; - break; - } - } - - if( ucFormatChar == 'X') - { - bUpperCase = TRUE; - } - - if( (uiFlags & FLM_PRINTF_COMMA_FLAG) && uiBase == 10) - { - bCommas = TRUE; - } - - uiLength = flmPrintNumber( ui64Val, uiBase, bUpperCase, - bCommas, ucNumberBuffer); - - if( uiWidth < uiLength) - { - uiWidth = uiLength; - } - - if( uiFlags & FLM_PRINTF_ZERO_FLAG) - { - // Zero fill - - uiPrecision = uiWidth; - } - else if( !(uiFlags & FLM_PRINTF_MINUS_FLAG)) - { - // Right justify - - while( uiWidth > uiLength && uiWidth > uiPrecision) - { - *pszDest++ = ' '; - uiWidth--; - } - } - - // Handle the prefix (if any) - - switch( uiPrefix) - { - case FLM_PREFIX_NONE: - break; - - case FLM_PREFIX_MINUS: - *pszDest++ = '-'; - break; - - case FLM_PREFIX_PLUS: - *pszDest++ = '+'; - break; - - case FLM_PREFIX_POUND: - { - *pszDest++ = '0'; - *pszDest++ = 'x'; - break; - } - - default: - flmAssert( 0); - break; - } - - // Handle the precision - - if( bCommas && uiPrecision && (uiPrecision % 4) == 0) - { - uiPrecision--; - } - - while( uiLength < uiPrecision) - { - if( bCommas && (uiPrecision % 4) == 0) - { - *pszDest++ = ','; - uiPrecision--; - uiWidth--; - continue; - } - - *pszDest++ = '0'; - uiPrecision--; - uiWidth--; - } - - // Output the number - - for( uiCount = uiLength, pszTmp = &ucNumberBuffer[ 0]; - uiCount > 0; uiCount--) - { - *pszDest++ = *pszTmp++; - } - - if( uiFlags & FLM_PRINTF_MINUS_FLAG) - { - // Left justify - while( uiLength < uiWidth) - { - *pszDest++ = ' '; - uiWidth--; - } - } - - *pszDest = 0; - pInfo->pszDestStr = pszDest; -} - -/**************************************************************************** -Desc: Default character formatter. - Prints the character specified by VALUE in 'c', or the '%' character. - Format: %[flags][width][.prec]'c' - flags = - width = - prec = -****************************************************************************/ -void flmSprintfCharFormatter( - FLMBYTE ucFormatChar, - FLMUINT , // uiWidth, - FLMUINT , // uiPrecision, - FLMUINT , // uiFlags, - F_SPRINTF_INFO * pInfo, - f_va_list * args) -{ - *pInfo->pszDestStr++ = (FLMBYTE)((ucFormatChar == '%') - ? '%' - : f_va_arg( *args, int)); - *pInfo->pszDestStr = 0; -} - -/**************************************************************************** -Desc: Default error formatter. -****************************************************************************/ -void flmSprintfErrorFormatter( - FLMBYTE ucFormatChar, - FLMUINT , // uiWidth, - FLMUINT , // uiPrecision, - FLMUINT , // uiFlags, - F_SPRINTF_INFO * pInfo, - f_va_list * args) -{ - FLMUINT uiErrorCode = (FLMUINT)f_va_arg( *args, unsigned); - - if( ucFormatChar == 'e') - { - pInfo->pszDestStr += - f_sprintf( (char *)pInfo->pszDestStr, "%s (%04X)", - (char *)F_DbSystem::_errorString( (RCODE)uiErrorCode), - (unsigned)uiErrorCode); - } - else - { - pInfo->pszDestStr += - f_sprintf( (char *)pInfo->pszDestStr, "%04X", - (unsigned)uiErrorCode); - } -} - -/**************************************************************************** -Desc: Unknown format handler -****************************************************************************/ -void flmSprintfNotHandledFormatter( - FLMBYTE , // ucFormatChar, - FLMUINT , // uiWidth, - FLMUINT , // uiPrecision, - FLMUINT , // uiFlags, - F_SPRINTF_INFO * pInfo, - f_va_list * ) // args) -{ - flmAssert( 0); - *pInfo->pszDestStr++ = '?'; - *pInfo->pszDestStr = 0; -} - -/**************************************************************************** -Desc: FLAIM's vsprintf -****************************************************************************/ -FLMINT f_vsprintf( - char * pszDestStr, - const char * pszFormat, - f_va_list * args) -{ - F_SPRINTF_INFO info; - - info.pszDestStr = (FLMBYTE *)pszDestStr; - flmSprintfParseArgs( (FLMBYTE *)pszFormat, &info, args); - *info.pszDestStr = 0; - - return( (FLMINT)(info.pszDestStr - (FLMBYTE *)pszDestStr)); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMINT f_sprintf( - char * pszDestStr, - const char * pszFormat, - ...) -{ - FLMINT iLen; - f_va_list args; - - f_va_start(args, pszFormat); - iLen = f_vsprintf( pszDestStr, pszFormat, &args); - f_va_end(args); - - return( iLen); -} diff --git a/xflaim/src/flreduce.cpp b/xflaim/src/flreduce.cpp index 2c727d8..ee28bf1 100644 --- a/xflaim/src/flreduce.cpp +++ b/xflaim/src/flreduce.cpp @@ -34,7 +34,7 @@ Notes: The size of the database file is reduced by freeing a specified available block list is empty, FLAIM will attemp to add blocks to the list by freeing log extent blocks. ****************************************************************************/ -RCODE XFLMAPI F_Db::reduceSize( +RCODE FLMAPI F_Db::reduceSize( FLMUINT uiCount, FLMUINT * puiCount) { @@ -137,13 +137,13 @@ RCODE XFLMAPI F_Db::reduceSize( FLMUINT64 ui64FileSize; FLMUINT64 ui64Temp; - if (RC_BAD( rc = m_pSFileHdl->GetFileHdl( + if (RC_BAD( rc = m_pSFileHdl->getFileHdl( uiFileNumber, TRUE, &pFileHdl))) { goto Exit; } - if (RC_BAD( rc = pFileHdl->Size( &ui64FileSize))) + if (RC_BAD( rc = pFileHdl->size( &ui64FileSize))) { goto Exit; } @@ -219,13 +219,13 @@ RCODE XFLMAPI F_Db::reduceSize( // Compute the end of the previous block file. - if (RC_BAD( rc = m_pSFileHdl->GetFileHdl( + if (RC_BAD( rc = m_pSFileHdl->getFileHdl( uiFileNumber, TRUE, &pFileHdl))) { goto Exit; } - if (RC_BAD( rc = pFileHdl->Size( &ui64FileOffset))) + if (RC_BAD( rc = pFileHdl->size( &ui64FileOffset))) { goto Exit; } @@ -327,7 +327,7 @@ RCODE F_Db::readBlkHdr( F_CachedBlock * pBlkSCache; XFLM_LFILE_STATS * pLFileStats; F_TMSTAMP StartTime; - FLMUINT64 ui64ElapMilli; + FLMUINT64 ui64ElapMilli = 0; // First see if the block is in cache. // Previous writes may not have been forced out to cache. @@ -351,10 +351,10 @@ RCODE F_Db::readBlkHdr( f_timeGetTimeStamp( &StartTime); } - if (RC_OK( rc = m_pSFileHdl->GetFileHdl( + if (RC_OK( rc = m_pSFileHdl->getFileHdl( FSGetFileNumber( uiBlkAddress), TRUE, &pTmpFileHdl))) { - rc = pTmpFileHdl->Read( FSGetFileOffset( uiBlkAddress), + rc = pTmpFileHdl->read( FSGetFileOffset( uiBlkAddress), SIZEOF_LARGEST_BLK_HDR, pBlkHdr, &uiBytesRead); } @@ -412,9 +412,9 @@ RCODE F_Db::readBlkHdr( if (RC_BAD( rc)) { - if (rc != NE_XFLM_IO_END_OF_FILE && rc != NE_XFLM_MEM) + if (rc != NE_FLM_IO_END_OF_FILE && rc != NE_XFLM_MEM) { - m_pSFileHdl->ReleaseFile( FSGetFileNumber( uiBlkAddress), + m_pSFileHdl->releaseFile( FSGetFileNumber( uiBlkAddress), TRUE); } goto Exit; @@ -447,7 +447,7 @@ RCODE F_Database::moveBtreeBlk( IXD * pIxd; LFILE * pLFile; F_COLLECTION * pCollection = NULL; - F_CachedBlock * pFreeSCache; + F_CachedBlock * pFreeSCache = NULL; FLMBOOL bReleaseCache = FALSE; F_Btree * pbtree = NULL; FLMBOOL bHaveCounts; @@ -587,7 +587,7 @@ RCODE F_Database::moveLFHBlk( RCODE rc; F_CachedBlock * pSCache; FLMBOOL bReleaseCache = FALSE; - F_CachedBlock * pFreeSCache; + F_CachedBlock * pFreeSCache = NULL; FLMBOOL bReleaseCache2 = FALSE; F_BLK_HDR * pBlkHdr; F_LF_HDR * pLfHdr; diff --git a/xflaim/src/flsweep.cpp b/xflaim/src/flsweep.cpp index 90d42de..d502950 100644 --- a/xflaim/src/flsweep.cpp +++ b/xflaim/src/flsweep.cpp @@ -37,7 +37,7 @@ Desc: Provides the ability to scan a FLAIM database to delete or check for usage of elements and attributes. ****************************************************************************/ RCODE F_Db::sweep( - F_Thread * pThread) + IF_Thread * pThread) { RCODE rc = NE_XFLM_OK; FLMBOOL bStartedTrans = FALSE; @@ -47,7 +47,7 @@ RCODE F_Db::sweep( FLMUINT uiCollection; F_Btree * pbtree = NULL; FLMBYTE ucKey [FLM_MAX_NUM_BUF_SIZE]; - FLMUINT uiKeyLen; + FLMUINT uiKeyLen = 0; FLMUINT64 ui64NodeId; FLMBOOL bNeg; FLMUINT uiBytesProcessed; diff --git a/xflaim/src/fltrbeg.cpp b/xflaim/src/fltrbeg.cpp index 27950b7..b091b74 100644 --- a/xflaim/src/fltrbeg.cpp +++ b/xflaim/src/fltrbeg.cpp @@ -594,7 +594,7 @@ Exit: Area : TRANSACTION Desc : Starts a transaction. *END************************************************************************/ -RCODE XFLMAPI F_Db::transBegin( +RCODE FLMAPI F_Db::transBegin( eDbTransType eTransType, // [IN] Specifies the type of transaction to begin. // Possible values are: @@ -668,7 +668,7 @@ Exit: Area : TRANSACTION Desc : Starts a transaction. *END************************************************************************/ -RCODE XFLMAPI F_Db::transBegin( +RCODE FLMAPI F_Db::transBegin( IF_Db * pDb // [IN] Start a transaction that has the same view as whatever // transaction is running on this database. NOTE: If pDb is @@ -712,7 +712,7 @@ Exit: Area : TRANSACTION Desc : Obtains a a lock on the database. *END************************************************************************/ -RCODE XFLMAPI F_Db::dbLock( +RCODE FLMAPI F_Db::dbLock( eDbLockType eLockType, // [IN] Type of lock request - must be FLM_LOCK_EXCLUSIVE or // FLM_LOCK_SHARED @@ -774,7 +774,7 @@ Exit: Area : TRANSACTION Desc : Releases a lock on the database *END************************************************************************/ -RCODE XFLMAPI F_Db::dbUnlock( void) +RCODE FLMAPI F_Db::dbUnlock( void) { RCODE rc = NE_XFLM_OK; @@ -815,7 +815,7 @@ Area : TRANSACTION Desc : Returns information about current and pending locks on the database. *END************************************************************************/ -RCODE XFLMAPI F_Db::getLockInfo( +RCODE FLMAPI F_Db::getLockInfo( FLMINT iPriority, // [IN] A count of all locks with a priority >= to this priority // level will be returned in pLockInfo. @@ -847,7 +847,7 @@ Exit: Desc : Returns information about the lock held by the specified database handle. *END************************************************************************/ -RCODE XFLMAPI F_Db::getLockType( +RCODE FLMAPI F_Db::getLockType( eDbLockType * peLockType, FLMBOOL * pbImplicit) { @@ -899,7 +899,7 @@ Exit: Area : TRANSACTION Desc : Forces a checkpoint on the database. *END************************************************************************/ -RCODE XFLMAPI F_Db::doCheckpoint( +RCODE FLMAPI F_Db::doCheckpoint( FLMUINT uiTimeout // [IN] Seconds to wait to obtain lock on the database. // XFLM_NO_TIMEOUT means that it will wait forever for diff --git a/xflaim/src/fltrcmit.cpp b/xflaim/src/fltrcmit.cpp index 9f583e0..018f269 100644 --- a/xflaim/src/fltrcmit.cpp +++ b/xflaim/src/fltrcmit.cpp @@ -565,7 +565,7 @@ Exit: Area : TRANSACTION Desc : Commits an active transaction. *END************************************************************************/ -RCODE XFLMAPI F_Db::transCommit( +RCODE FLMAPI F_Db::transCommit( FLMBOOL * pbEmpty) // may be NULL { RCODE rc = NE_XFLM_OK; diff --git a/xflaim/src/flutil.cpp b/xflaim/src/flutil.cpp deleted file mode 100644 index e373af7..0000000 --- a/xflaim/src/flutil.cpp +++ /dev/null @@ -1,4937 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Routines to support NATIVE to/from internal numeric types and -// string comparision/shift routines. -// -// Tabs: 3 -// -// Copyright (c) 1991-1993, 1996-1998, 2000, 2002-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: flutil.cpp 3114 2006-01-19 13:22:45 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -#define UNICODE_DECIMAL_DIGIT_MASK 0x08 -#define UNICODE_ALPHABETIC_MASK 0x04 -#define UNICODE_UPPERCASE_MASK 0x02 -#define UNICODE_LOWERCASE_MASK 0x01 - -const unsigned char UnicodeProperties[ 32768] = -{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 136, 136, 136, 136, 136, 0, 0, 0, - 6, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 96, 0, 0, - 5, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 80, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 80, 0, 0, 0, 0, 5, 0, 0, 80, 0, 0, - 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 96, 102, 102, 102, 101, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 80, 85, 85, 85, 85, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 86, 86, 86, 86, - 86, 86, 86, 86, 85, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 102, 86, 86, 85, - 86, 101, 101, 102, 86, 102, 85, 102, 102, 86, 101, 102, 101, 85, 102, 86, - 101, 101, 101, 102, 86, 85, 101, 102, 86, 102, 86, 86, 101, 84, 101, 85, - 68, 68, 100, 86, 69, 100, 86, 86, 86, 86, 86, 86, 86, 86, 85, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 86, 69, 101, 102, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 85, 80, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 84, 68, 68, 68, - 85, 0, 0, 68, 68, 68, 68, 68, 68, 0, 0, 0, 0, 0, 0, 0, - 85, 85, 80, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, 0, - 0, 0, 0, 96, 102, 96, 96, 102, 86, 102, 102, 102, 102, 102, 102, 102, - 102, 6, 102, 102, 102, 102, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 80, 85, 102, 101, 85, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 85, 85, 101, 6, 86, 101, 0, 0, - 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 102, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 0, 0, 0, 0, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 102, 86, 86, 86, 86, 86, 86, 80, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 0, 101, 0, 0, 0, - 101, 101, 101, 101, 101, 101, 101, 101, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 6, 102, 102, 102, 102, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 96, 4, 0, 0, 0, - 5, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 68, 68, 68, 68, 68, 4, 68, 4, - 4, 64, 64, 0, 0, 0, 0, 0, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 64, 0, 0, 68, 64, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 68, 68, 68, 0, 0, 0, 0, 0, - 4, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 64, 0, 0, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 0, 0, 0, 0, - 136, 136, 136, 136, 136, 0, 0, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 4, 68, 68, 68, 64, 0, - 4, 68, 68, 68, 64, 0, 4, 68, 136, 136, 136, 136, 136, 68, 64, 4, - 0, 0, 0, 0, 0, 0, 0, 0, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 0, 0, 0, 0, 0, 0, 4, 68, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 0, 4, 68, - 68, 68, 68, 68, 68, 68, 64, 0, 64, 0, 0, 0, 68, 68, 68, 68, - 68, 68, 0, 136, 136, 136, 136, 136, 0, 0, 0, 0, 0, 0, 0, 0, - 4, 68, 4, 68, 68, 68, 64, 4, 64, 4, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 64, 68, 68, 68, 64, 64, 0, 68, 68, 0, 4, 68, - 68, 68, 64, 4, 64, 4, 64, 0, 0, 0, 0, 4, 0, 0, 68, 4, - 68, 68, 0, 136, 136, 136, 136, 136, 68, 0, 0, 0, 0, 0, 0, 0, - 4, 68, 4, 68, 68, 64, 0, 4, 64, 4, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 64, 68, 68, 68, 64, 68, 4, 64, 68, 0, 0, 68, - 68, 64, 0, 4, 64, 4, 64, 0, 0, 0, 0, 0, 4, 68, 64, 64, - 0, 0, 0, 136, 136, 136, 136, 136, 68, 68, 64, 0, 0, 0, 0, 0, - 4, 68, 4, 68, 68, 68, 68, 4, 68, 4, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 64, 68, 68, 68, 64, 68, 4, 68, 68, 0, 4, 68, - 68, 68, 68, 4, 68, 4, 64, 0, 64, 0, 0, 0, 0, 0, 0, 0, - 68, 68, 0, 136, 136, 136, 136, 136, 0, 0, 0, 0, 0, 0, 0, 0, - 4, 68, 4, 68, 68, 68, 64, 4, 64, 4, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 64, 68, 68, 68, 64, 68, 4, 68, 68, 0, 4, 68, - 68, 68, 0, 4, 64, 4, 64, 0, 0, 0, 0, 68, 0, 0, 68, 4, - 68, 0, 0, 136, 136, 136, 136, 136, 4, 0, 0, 0, 0, 0, 0, 0, - 0, 68, 4, 68, 68, 64, 0, 68, 64, 68, 68, 0, 4, 64, 64, 68, - 0, 4, 64, 0, 68, 64, 0, 68, 68, 68, 68, 4, 68, 0, 0, 68, - 68, 64, 0, 68, 64, 68, 64, 0, 0, 0, 0, 4, 0, 0, 0, 0, - 0, 0, 0, 8, 136, 136, 136, 136, 0, 0, 0, 0, 0, 0, 0, 0, - 4, 68, 4, 68, 68, 68, 64, 68, 64, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 64, 68, 68, 68, 68, 68, 4, 68, 68, 0, 0, 68, - 68, 68, 64, 68, 64, 68, 64, 0, 0, 0, 4, 64, 0, 0, 0, 0, - 68, 0, 0, 136, 136, 136, 136, 136, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 68, 4, 68, 68, 68, 64, 68, 64, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 64, 68, 68, 68, 68, 68, 4, 68, 68, 0, 4, 68, - 68, 68, 64, 68, 64, 68, 64, 0, 0, 0, 4, 64, 0, 0, 0, 64, - 68, 0, 0, 136, 136, 136, 136, 136, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 68, 4, 68, 68, 68, 64, 68, 64, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 64, 68, 68, 68, 68, 68, 68, 68, 68, 0, 0, 68, - 68, 68, 0, 68, 64, 68, 64, 0, 0, 0, 0, 4, 0, 0, 0, 0, - 68, 0, 0, 136, 136, 136, 136, 136, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 68, 4, 68, 68, 68, 68, 68, 68, 68, 68, 64, 0, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 4, 68, 68, 68, 68, 4, 0, - 68, 68, 68, 64, 0, 0, 0, 4, 68, 68, 64, 64, 68, 68, 68, 68, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, - 4, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 64, 0, 0, - 68, 68, 68, 64, 0, 0, 4, 0, 136, 136, 136, 136, 136, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4, 64, 64, 4, 64, 64, 4, 0, 0, 0, 68, 68, 4, 68, 68, 68, - 4, 68, 4, 4, 0, 68, 4, 68, 68, 68, 68, 68, 68, 4, 68, 0, - 68, 68, 64, 64, 0, 0, 4, 0, 136, 136, 136, 136, 136, 0, 68, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 136, 136, 136, 136, 136, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 68, 68, 68, 68, 4, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 64, 0, 0, 4, 68, 68, 68, 68, 68, 68, 68, - 68, 0, 0, 0, 68, 68, 0, 0, 68, 68, 68, 68, 4, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 64, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 4, 68, 68, 4, 64, 68, 68, 68, 64, 0, 64, 64, 0, 0, 0, - 136, 136, 136, 136, 136, 0, 0, 0, 68, 68, 68, 68, 68, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, - 102, 102, 102, 0, 0, 0, 0, 0, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 64, 0, 0, 0, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 0, 0, 4, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 64, 0, 0, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 0, 0, 0, - 68, 68, 68, 64, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 64, 64, 68, 68, 0, 68, 68, 68, 64, 64, 68, 68, 0, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 64, 64, 68, 68, 0, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 64, 64, 68, 68, 0, 68, 68, 68, 64, - 64, 68, 68, 0, 68, 68, 68, 64, 68, 68, 68, 64, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 64, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 64, 64, 68, 68, 0, 68, 68, 68, 64, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 64, 68, 68, 68, 68, 68, 68, 68, 68, 68, 64, 0, 0, - 0, 0, 0, 0, 8, 136, 136, 136, 136, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 64, 0, 0, 0, 0, 0, - 4, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 64, 4, 68, 68, 68, 64, 0, 0, 0, 0, - 4, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 64, 0, 0, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 64, 0, 68, 64, 0, 0, 0, 0, 0, 0, 0, - 68, 68, 68, 68, 68, 68, 64, 68, 68, 68, 0, 0, 0, 0, 0, 0, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 0, 0, 0, 0, 0, 0, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 0, 0, 0, 0, 0, 0, - 68, 68, 68, 68, 68, 68, 64, 68, 64, 68, 0, 0, 0, 0, 0, 0, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 0, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 64, 0, 0, 0, 0, 0, 0, 4, 0, 0, 64, 0, - 136, 136, 136, 136, 136, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 136, 136, 136, 136, 136, 0, 0, 0, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 0, 0, 0, 0, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 64, 0, - 68, 68, 68, 68, 68, 68, 0, 0, 68, 68, 68, 68, 64, 0, 0, 0, - 0, 0, 0, 136, 136, 136, 136, 136, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 0, 68, 68, 64, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 85, 85, 85, 0, 0, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 0, 0, 0, - 85, 85, 85, 85, 102, 102, 102, 102, 85, 85, 85, 0, 102, 102, 102, 0, - 85, 85, 85, 85, 102, 102, 102, 102, 85, 85, 85, 85, 102, 102, 102, 102, - 85, 85, 85, 0, 102, 102, 102, 0, 85, 85, 85, 85, 6, 6, 6, 6, - 85, 85, 85, 85, 102, 102, 102, 102, 85, 85, 85, 85, 85, 85, 85, 0, - 85, 85, 85, 85, 68, 68, 68, 68, 85, 85, 85, 85, 68, 68, 68, 68, - 85, 85, 85, 85, 68, 68, 68, 68, 85, 85, 80, 85, 102, 102, 64, 80, - 0, 85, 80, 85, 102, 102, 64, 0, 85, 85, 0, 85, 102, 102, 0, 0, - 85, 85, 85, 85, 102, 102, 96, 0, 0, 85, 80, 85, 102, 102, 64, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 5, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 96, 0, 6, 0, 86, 102, 85, 102, 101, 6, 0, 6, 102, 102, 0, - 0, 0, 96, 96, 96, 102, 102, 5, 102, 6, 84, 68, 69, 0, 5, 102, - 0, 0, 6, 85, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 102, 102, 102, 102, 102, 102, 102, 102, 85, 85, 85, 85, 85, 85, 85, 85, - 68, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4, 68, 68, 68, 68, 0, 0, 0, 4, 68, 68, 0, 68, 68, 64, 0, - 4, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 64, 0, 0, 4, 68, - 4, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 64, 68, 68, - 0, 0, 4, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 64, 0, 4, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 64, 0, 0, 0, 0, 0, 0, 0, 0, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 68, 68, 68, 68, 68, 68, 68, 68, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 0, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 85, 85, 85, 80, 0, 0, 0, 0, 0, 5, 85, 85, 0, 0, 4, 68, - 68, 68, 68, 68, 64, 68, 68, 68, 68, 68, 68, 64, 68, 68, 64, 64, - 68, 4, 64, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 0, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 68, 68, 68, 68, 68, 68, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 68, 68, 64, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 64, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 136, 136, 136, 136, 136, 0, 0, 0, - 6, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 96, 0, 0, - 5, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 80, 0, 0, - 0, 0, 0, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 64, - 0, 68, 68, 68, 0, 68, 68, 68, 0, 68, 68, 68, 0, 68, 64, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -#define HANDLE_NEGATIVE \ - if( value < 0) \ - { *ptr++ = '-'; \ - absValue = (FLMUINT)(-(value)); \ - } \ - else absValue = (FLMUINT)value; - -#define HANDLE_DNEGATIVE \ - if( value < 0) \ - { *ptr++ = '-'; \ - absValue = (FLMUINT)(-(value)); \ - } \ - else absValue = (FLMUINT)value; - -#define PUSH_DIGITS( v) \ - {register FLMUINT reg = v; \ - do{ *sp++ = (char)((reg % 10) + '0'); \ - } while( reg /= 10); \ - } - -#define POP_DIGITS \ - while( stack < sp--) \ - *ptr++ = *sp; \ - *ptr = '\0'; - -/**************************************************************************** -Desc: Unsigned word to NATIVE value - null terminate the native string -Return: char pointer to the NULL byte in the native string -Notes: Radix not defined because it is not needed -****************************************************************************/ -char * f_uwtoa( - FLMUINT16 value, - char * ptr) -{ - char stack[ 10]; - char * sp = stack; - - PUSH_DIGITS( value); - - POP_DIGITS; - - return( ptr); -} - -/**************************************************************************** -Desc: Native to UDWORD value. Supports 0x codes. Non digits NOT ALLOWED - NO LEADING SPACES ALLOWED ! ! ! No checks for overflow over 4 bytes! -Return: UDWORD value of what is being pointed to -Notes: This algorithm is NOT standard, assumes UNSIGNED char arithmetic - so (20 - 30) should be 245 and NOT -10. -****************************************************************************/ -FLMUINT f_atoud( - char * pszBuf, - FLMBOOL bAllowUnprefixedHex) -{ - FLMUINT uiValue; - FLMBOOL bAllowHex = FALSE; - - if( *pszBuf == NATIVE_ZERO && - (*(pszBuf + 1) == NATIVE_LOWER_X || *(pszBuf + 1) == NATIVE_UPPER_X)) - { - pszBuf += 2; - bAllowHex = TRUE; - } - else if( bAllowUnprefixedHex) - { - bAllowHex = TRUE; - } - - uiValue = 0; - while( *pszBuf) - { - if( *pszBuf >= '0' && *pszBuf <= '9') - { - if( !bAllowHex) - { - uiValue *= 10; - } - else - { - uiValue <<= 4; - } - - uiValue += (FLMUINT)(*pszBuf - '0'); - } - else if( bAllowHex) - { - if( *pszBuf >= 'A' && *pszBuf <= 'F') - { - uiValue <<= 4; - uiValue += (FLMUINT)(*pszBuf - 'A') + 10; - } - else if( *pszBuf >= 'a' && *pszBuf <= 'f') - { - uiValue <<= 4; - uiValue += (FLMUINT)(*pszBuf - 'a') + 10; - } - else - { - break; - } - } - else - { - break; - } - pszBuf++; - } - - return( uiValue); -} - -/**************************************************************************** -Desc: Native to FLMUINT64 value. Supports 0x codes. Non digits - NOT ALLOWED NO LEADING SPACES ALLOWED! No checks for overflow - over 4 bytes! -Return: FLMUINT64 value of what is being pointed to -Notes: This algorithm is NOT standard, assumes UNSIGNED char arithmetic - so (20 - 30) should be 245 and NOT -10. -****************************************************************************/ -FLMUINT64 f_atou64( - char * pszBuf) -{ - FLMUINT64 ui64Value; - FLMBOOL bAllowHex = FALSE; - - if( *pszBuf == NATIVE_ZERO && - (*(pszBuf + 1) == NATIVE_LOWER_X || *(pszBuf + 1) == NATIVE_UPPER_X)) - { - pszBuf += 2; - bAllowHex = TRUE; - } - - ui64Value = 0; - while( *pszBuf) - { - if( *pszBuf >= '0' && *pszBuf <= '9') - { - if( !bAllowHex) - { - ui64Value *= 10; - } - else - { - ui64Value <<= 4; - } - - ui64Value += (FLMUINT64)(*pszBuf - '0'); - } - else if( bAllowHex) - { - if( *pszBuf >= 'A' && *pszBuf <= 'F') - { - ui64Value <<= 4; - ui64Value += (FLMUINT64)(*pszBuf - 'A') + 10; - } - else if( *pszBuf >= 'a' && *pszBuf <= 'f') - { - ui64Value <<= 4; - ui64Value += (FLMUINT64)(*pszBuf - 'a') + 10; - } - else - { - break; - } - } - else - { - break; - } - pszBuf++; - } - - return( ui64Value); -} - -/**************************************************************************** -Desc: Unsigned double (4 byte) number to native value & null terminate -Return: char pointer to the NULL byte in the native string -Notes: Radix not defined. -****************************************************************************/ -char * f_udtoa( - FLMUINT value, - char * ptr) -{ - char stack[ 10]; - char * sp = stack; - - PUSH_DIGITS( value); - - POP_DIGITS; - - return( ptr); -} - -/**************************************************************************** -Desc: Word to native value - null terminate the native string -Return: char pointer to the NULL byte in the native string -Notes: Radix not defined because it is not needed -****************************************************************************/ -char * f_wtoa( - FLMINT16 value, - char * ptr) -{ - char stack[ 10]; - char * sp = stack; - FLMUINT absValue; - - HANDLE_NEGATIVE; - - PUSH_DIGITS( absValue); - - POP_DIGITS; - - return( ptr); -} - -/**************************************************************************** -Desc: Double (4 byte) number to native value - null terminate the string -Return: char pointer to the NULL byte in the native string -****************************************************************************/ -char * f_dtoa( - FLMINT value, - char * ptr) -{ - char stack[ 10]; - char * sp = stack; - FLMUINT absValue; - - HANDLE_DNEGATIVE; - - PUSH_DIGITS( absValue); - - POP_DIGITS; - - return( ptr); -} - -/***************************************************************************** -Desc: Convert unsigned 64 bit value to ASCII. -*****************************************************************************/ -char * f_ui64toa( - FLMUINT64 ui64Value, - char * pszAscii) -{ - char szStack [30]; - char * pszStack = &szStack [0]; - - do - { - *pszStack++ = (char)((ui64Value % 10) + '0'); - } - while ((ui64Value /= 10) > 0); - - pszStack--; - for (;;) - { - *pszAscii++ = *pszStack; - if (pszStack == &szStack [0]) - { - break; - } - pszStack--; - } - *pszAscii = 0; - - // Return pointer to terminating null character - - return( pszAscii); -} - -/***************************************************************************** -Desc: Convert signed 64 bit value to ASCII. -*****************************************************************************/ -char * f_i64toa( - FLMINT64 i64Value, - char * pszAscii) -{ - if (i64Value < 0) - { - *pszAscii++ = '-'; - i64Value = -i64Value; - } - return( f_ui64toa( (FLMUINT64)i64Value, pszAscii)); -} - -/**************************************************************************** -Desc: Ascii to integer -****************************************************************************/ -FLMINT f_atoi( - char * pszStr) -{ - return( f_atod( pszStr)); -} - -/**************************************************************************** -Desc: native to long -****************************************************************************/ -FLMINT f_atol( - char * pszStr) -{ - return( f_atod( pszStr)); -} - -/**************************************************************************** -Desc: native to DWORD value. Supports 0x codes. Non digits NOT ALLOWED - NO LEADING SPACES ALLOWED ! ! ! No checks for overflow over 4 bytes! -Return: DWORD value of what is being pointed to -Notes: This algorithm is NOT standard! Assumes UNSIGNED char arithmetic - so (20 - 30) should be 245 and NOT -10. -****************************************************************************/ -FLMINT f_atod( - char * pszBuf) -{ - FLMINT iValue; - FLMBOOL bNeg = FALSE; - - if( *pszBuf == '-') - { - bNeg = TRUE; - pszBuf++; - } - else if( *pszBuf == '+') - { - pszBuf++; - } - - iValue = (FLMINT)f_atoud( pszBuf); - return( bNeg ? -iValue : iValue); -} - -/**************************************************************************** -Desc: Utility function to return the maximum size of a hex number - represented as a string. -****************************************************************************/ -FINLINE FLMUINT maxHexSize( - FLMUINT uiSizeOfPtr) -{ - return uiSizeOfPtr * 2; -} - -/**************************************************************************** -Desc: Utility function to return the maximum size of a decimal number - represented as a string. -****************************************************************************/ -FINLINE FLMUINT maxDecimalSize( - FLMUINT uiSizeOfPtr) -{ - switch (uiSizeOfPtr) - { - case 4: - return 10; - case 8: - return 20; - default: - flmAssert( 0); - return 0; - } -} - -/**************************************************************************** -Desc: Returns the length of a unicode string -****************************************************************************/ -FLMUINT f_unilen( - const FLMUNICODE * puzStr) -{ - FLMUINT uiLen = 0; - - if( !puzStr) - { - goto Exit; - } - - while( *puzStr) - { - puzStr++; - uiLen++; - } - -Exit: - - return( uiLen); -} - -/**************************************************************************** -Desc: Copies a unicode string -****************************************************************************/ -FLMUNICODE * f_unicpy( - FLMUNICODE * puzDestStr, - const FLMUNICODE * puzSrcStr) -{ - const FLMUNICODE * puzSrc = puzSrcStr; - FLMUNICODE * puzDest = puzDestStr; - - while( *puzSrc) - { - *puzDest++ = *puzSrc++; - } - - *puzDest = 0; - return( puzDestStr); -} - -/**************************************************************************** -Desc: A rather trivial unicode monocase function. -****************************************************************************/ -FLMUNICODE f_unitolower( - FLMUNICODE uChar) -{ - static const FLMUNICODE basicAlpha[ 0x600] = - { - 0x0000, /* Monocases to self */ - 0x0001, /* Monocases to self */ - 0x0002, /* Monocases to self */ - 0x0003, /* Monocases to self */ - 0x0004, /* Monocases to self */ - 0x0005, /* Monocases to self */ - 0x0006, /* Monocases to self */ - 0x0007, /* Monocases to self */ - 0x0008, /* Monocases to self */ - 0x0009, /* Monocases to self */ - 0x000A, /* Monocases to self */ - 0x000B, /* Monocases to self */ - 0x000C, /* Monocases to self */ - 0x000D, /* Monocases to self */ - 0x000E, /* Monocases to self */ - 0x000F, /* Monocases to self */ - 0x0010, /* Monocases to self */ - 0x0011, /* Monocases to self */ - 0x0012, /* Monocases to self */ - 0x0013, /* Monocases to self */ - 0x0014, /* Monocases to self */ - 0x0015, /* Monocases to self */ - 0x0016, /* Monocases to self */ - 0x0017, /* Monocases to self */ - 0x0018, /* Monocases to self */ - 0x0019, /* Monocases to self */ - 0x001A, /* Monocases to self */ - 0x001B, /* Monocases to self */ - 0x001C, /* Monocases to self */ - 0x001D, /* Monocases to self */ - 0x001E, /* Monocases to self */ - 0x001F, /* Monocases to self */ - 0x0020, /* Monocases to self */ - 0x0021, /* Monocases to self */ - 0x0022, /* Monocases to self */ - 0x0023, /* Monocases to self */ - 0x0024, /* Monocases to self */ - 0x0025, /* Monocases to self */ - 0x0026, /* Monocases to self */ - 0x0027, /* Monocases to self */ - 0x0028, /* Monocases to self */ - 0x0029, /* Monocases to self */ - 0x002A, /* Monocases to self */ - 0x002B, /* Monocases to self */ - 0x002C, /* Monocases to self */ - 0x002D, /* Monocases to self */ - 0x002E, /* Monocases to self */ - 0x002F, /* Monocases to self */ - 0x0030, /* Monocases to self */ - 0x0031, /* Monocases to self */ - 0x0032, /* Monocases to self */ - 0x0033, /* Monocases to self */ - 0x0034, /* Monocases to self */ - 0x0035, /* Monocases to self */ - 0x0036, /* Monocases to self */ - 0x0037, /* Monocases to self */ - 0x0038, /* Monocases to self */ - 0x0039, /* Monocases to self */ - 0x003A, /* Monocases to self */ - 0x003B, /* Monocases to self */ - 0x003C, /* Monocases to self */ - 0x003D, /* Monocases to self */ - 0x003E, /* Monocases to self */ - 0x003F, /* Monocases to self */ - 0x0040, /* Monocases to self */ - 0x0061, /* LATIN LETTER A */ - 0x0062, /* LATIN LETTER B */ - 0x0063, /* LATIN LETTER C */ - 0x0064, /* LATIN LETTER D */ - 0x0065, /* LATIN LETTER E */ - 0x0066, /* LATIN LETTER F */ - 0x0067, /* LATIN LETTER G */ - 0x0068, /* LATIN LETTER H */ - 0x0069, /* LATIN LETTER I */ - 0x006A, /* LATIN LETTER J */ - 0x006B, /* LATIN LETTER K */ - 0x006C, /* LATIN LETTER L */ - 0x006D, /* LATIN LETTER M */ - 0x006E, /* LATIN LETTER N */ - 0x006F, /* LATIN LETTER O */ - 0x0070, /* LATIN LETTER P */ - 0x0071, /* LATIN LETTER Q */ - 0x0072, /* LATIN LETTER R */ - 0x0073, /* LATIN LETTER S */ - 0x0074, /* LATIN LETTER T */ - 0x0075, /* LATIN LETTER U */ - 0x0076, /* LATIN LETTER V */ - 0x0077, /* LATIN LETTER W */ - 0x0078, /* LATIN LETTER X */ - 0x0079, /* LATIN LETTER Y */ - 0x007A, /* LATIN LETTER Z */ - 0x005B, /* Monocases to self */ - 0x005C, /* Monocases to self */ - 0x005D, /* Monocases to self */ - 0x005E, /* Monocases to self */ - 0x005F, /* Monocases to self */ - 0x0060, /* Monocases to self */ - 0x0061, /* Monocases to self */ - 0x0062, /* Monocases to self */ - 0x0063, /* Monocases to self */ - 0x0064, /* Monocases to self */ - 0x0065, /* Monocases to self */ - 0x0066, /* Monocases to self */ - 0x0067, /* Monocases to self */ - 0x0068, /* Monocases to self */ - 0x0069, /* Monocases to self */ - 0x006A, /* Monocases to self */ - 0x006B, /* Monocases to self */ - 0x006C, /* Monocases to self */ - 0x006D, /* Monocases to self */ - 0x006E, /* Monocases to self */ - 0x006F, /* Monocases to self */ - 0x0070, /* Monocases to self */ - 0x0071, /* Monocases to self */ - 0x0072, /* Monocases to self */ - 0x0073, /* Monocases to self */ - 0x0074, /* Monocases to self */ - 0x0075, /* Monocases to self */ - 0x0076, /* Monocases to self */ - 0x0077, /* Monocases to self */ - 0x0078, /* Monocases to self */ - 0x0079, /* Monocases to self */ - 0x007A, /* Monocases to self */ - 0x007B, /* Monocases to self */ - 0x007C, /* Monocases to self */ - 0x007D, /* Monocases to self */ - 0x007E, /* Monocases to self */ - 0x007F, /* Monocases to self */ - 0x0080, /* Monocases to self */ - 0x0081, /* Monocases to self */ - 0x0082, /* Monocases to self */ - 0x0083, /* Monocases to self */ - 0x0084, /* Monocases to self */ - 0x0085, /* Monocases to self */ - 0x0086, /* Monocases to self */ - 0x0087, /* Monocases to self */ - 0x0088, /* Monocases to self */ - 0x0089, /* Monocases to self */ - 0x008A, /* Monocases to self */ - 0x008B, /* Monocases to self */ - 0x008C, /* Monocases to self */ - 0x008D, /* Monocases to self */ - 0x008E, /* Monocases to self */ - 0x008F, /* Monocases to self */ - 0x0090, /* Monocases to self */ - 0x0091, /* Monocases to self */ - 0x0092, /* Monocases to self */ - 0x0093, /* Monocases to self */ - 0x0094, /* Monocases to self */ - 0x0095, /* Monocases to self */ - 0x0096, /* Monocases to self */ - 0x0097, /* Monocases to self */ - 0x0098, /* Monocases to self */ - 0x0099, /* Monocases to self */ - 0x009A, /* Monocases to self */ - 0x009B, /* Monocases to self */ - 0x009C, /* Monocases to self */ - 0x009D, /* Monocases to self */ - 0x009E, /* Monocases to self */ - 0x009F, /* Monocases to self */ - 0x00A0, /* Monocases to self */ - 0x00A1, /* Monocases to self */ - 0x00A2, /* Monocases to self */ - 0x00A3, /* Monocases to self */ - 0x00A4, /* Monocases to self */ - 0x00A5, /* Monocases to self */ - 0x00A6, /* Monocases to self */ - 0x00A7, /* Monocases to self */ - 0x00A8, /* Monocases to self */ - 0x00A9, /* Monocases to self */ - 0x00AA, /* Monocases to self */ - 0x00AB, /* Monocases to self */ - 0x00AC, /* Monocases to self */ - 0x00AD, /* Monocases to self */ - 0x00AE, /* Monocases to self */ - 0x00AF, /* Monocases to self */ - 0x00B0, /* Monocases to self */ - 0x00B1, /* Monocases to self */ - 0x00B2, /* Monocases to self */ - 0x00B3, /* Monocases to self */ - 0x00B4, /* Monocases to self */ - 0x00B5, /* Monocases to self */ - 0x00B6, /* Monocases to self */ - 0x00B7, /* Monocases to self */ - 0x00B8, /* Monocases to self */ - 0x00B9, /* Monocases to self */ - 0x00BA, /* Monocases to self */ - 0x00BB, /* Monocases to self */ - 0x00BC, /* Monocases to self */ - 0x00BD, /* Monocases to self */ - 0x00BE, /* Monocases to self */ - 0x00BF, /* Monocases to self */ - 0x00E0, /* LATIN LETTER A GRAVE */ - 0x00E1, /* LATIN LETTER A ACUTE */ - 0x00E2, /* LATIN LETTER A CIRCUMFLEX */ - 0x00E3, /* LATIN LETTER A TILDE */ - 0x00E4, /* LATIN LETTER A DIAERESIS */ - 0x00E5, /* LATIN LETTER A RING */ - 0x00E6, /* LATIN LETTER A E */ - 0x00E7, /* LATIN LETTER C CEDILLA */ - 0x00E8, /* LATIN LETTER E GRAVE */ - 0x00E9, /* LATIN LETTER E ACUTE */ - 0x00EA, /* LATIN LETTER E CIRCUMFLEX */ - 0x00EB, /* LATIN LETTER E DIAERESIS */ - 0x00EC, /* LATIN LETTER I GRAVE */ - 0x00ED, /* LATIN LETTER I ACUTE */ - 0x00EE, /* LATIN LETTER I CIRCUMFLEX */ - 0x00EF, /* LATIN LETTER I DIAERESIS */ - 0x00F0, /* LATIN LETTER ETH */ - 0x00F1, /* LATIN LETTER N TILDE */ - 0x00F2, /* LATIN LETTER O GRAVE */ - 0x00F3, /* LATIN LETTER O ACUTE */ - 0x00F4, /* LATIN LETTER O CIRCUMFLEX */ - 0x00F5, /* LATIN LETTER O TILDE */ - 0x00F6, /* LATIN LETTER O DIAERESIS */ - 0x00D7, /* Monocases to self */ - 0x00F8, /* LATIN LETTER O SLASH */ - 0x00F9, /* LATIN LETTER U GRAVE */ - 0x00FA, /* LATIN LETTER U ACUTE */ - 0x00FB, /* LATIN LETTER U CIRCUMFLEX */ - 0x00FC, /* LATIN LETTER U DIAERESIS */ - 0x00FD, /* LATIN LETTER Y ACUTE */ - 0x00FE, /* LATIN LETTER THORN */ - 0x00DF, /* Monocases to self */ - 0x00E0, /* Monocases to self */ - 0x00E1, /* Monocases to self */ - 0x00E2, /* Monocases to self */ - 0x00E3, /* Monocases to self */ - 0x00E4, /* Monocases to self */ - 0x00E5, /* Monocases to self */ - 0x00E6, /* Monocases to self */ - 0x00E7, /* Monocases to self */ - 0x00E8, /* Monocases to self */ - 0x00E9, /* Monocases to self */ - 0x00EA, /* Monocases to self */ - 0x00EB, /* Monocases to self */ - 0x00EC, /* Monocases to self */ - 0x00ED, /* Monocases to self */ - 0x00EE, /* Monocases to self */ - 0x00EF, /* Monocases to self */ - 0x00F0, /* Monocases to self */ - 0x00F1, /* Monocases to self */ - 0x00F2, /* Monocases to self */ - 0x00F3, /* Monocases to self */ - 0x00F4, /* Monocases to self */ - 0x00F5, /* Monocases to self */ - 0x00F6, /* Monocases to self */ - 0x00F7, /* Monocases to self */ - 0x00F8, /* Monocases to self */ - 0x00F9, /* Monocases to self */ - 0x00FA, /* Monocases to self */ - 0x00FB, /* Monocases to self */ - 0x00FC, /* Monocases to self */ - 0x00FD, /* Monocases to self */ - 0x00FE, /* Monocases to self */ - 0x00FF, /* Monocases to self */ - 0x0101, /* LATIN LETTER A MACRON */ - 0x0101, /* Monocases to self */ - 0x0103, /* LATIN LETTER A BREVE */ - 0x0103, /* Monocases to self */ - 0x0105, /* LATIN LETTER A OGONEK */ - 0x0105, /* Monocases to self */ - 0x0107, /* LATIN LETTER C ACUTE */ - 0x0107, /* Monocases to self */ - 0x0109, /* LATIN LETTER C CIRCUMFLEX */ - 0x0109, /* Monocases to self */ - 0x010B, /* LATIN LETTER C DOT */ - 0x010B, /* Monocases to self */ - 0x010D, /* LATIN LETTER C HACEK */ - 0x010D, /* Monocases to self */ - 0x010F, /* LATIN LETTER D HACEK */ - 0x010F, /* Monocases to self */ - 0x0111, /* LATIN LETTER D BAR */ - 0x0111, /* Monocases to self */ - 0x0113, /* LATIN LETTER E MACRON */ - 0x0113, /* Monocases to self */ - 0x0115, /* LATIN LETTER E BREVE */ - 0x0115, /* Monocases to self */ - 0x0117, /* LATIN LETTER E DOT */ - 0x0117, /* Monocases to self */ - 0x0119, /* LATIN LETTER E OGONEK */ - 0x0119, /* Monocases to self */ - 0x011B, /* LATIN LETTER E HACEK */ - 0x011B, /* Monocases to self */ - 0x011D, /* LATIN LETTER G CIRCUMFLEX */ - 0x011D, /* Monocases to self */ - 0x011F, /* LATIN LETTER G BREVE */ - 0x011F, /* Monocases to self */ - 0x0121, /* LATIN LETTER G DOT */ - 0x0121, /* Monocases to self */ - 0x0123, /* LATIN LETTER G CEDILLA */ - 0x0123, /* Monocases to self */ - 0x0125, /* LATIN LETTER H CIRCUMFLEX */ - 0x0125, /* Monocases to self */ - 0x0127, /* LATIN LETTER H BAR */ - 0x0127, /* Monocases to self */ - 0x0129, /* LATIN LETTER I TILDE */ - 0x0129, /* Monocases to self */ - 0x012B, /* LATIN LETTER I MACRON */ - 0x012B, /* Monocases to self */ - 0x012D, /* LATIN LETTER I BREVE */ - 0x012D, /* Monocases to self */ - 0x012F, /* LATIN LETTER I OGONEK */ - 0x012F, /* Monocases to self */ - 0x0069, /* LATIN LETTER I DOT */ - 0x0131, /* Monocases to self */ - 0x0133, /* LATIN LETTER I J */ - 0x0133, /* Monocases to self */ - 0x0135, /* LATIN LETTER J CIRCUMFLEX */ - 0x0135, /* Monocases to self */ - 0x0137, /* LATIN LETTER K CEDILLA */ - 0x0137, /* Monocases to self */ - 0x0138, /* Monocases to self */ - 0x013A, /* LATIN LETTER L ACUTE */ - 0x013A, /* Monocases to self */ - 0x013C, /* LATIN LETTER L CEDILLA */ - 0x013C, /* Monocases to self */ - 0x013E, /* LATIN LETTER L HACEK */ - 0x013E, /* Monocases to self */ - 0x0140, /* LATIN LETTER L WITH MIDDLE DOT */ - 0x0140, /* Monocases to self */ - 0x0142, /* LATIN LETTER L SLASH */ - 0x0142, /* Monocases to self */ - 0x0144, /* LATIN LETTER N ACUTE */ - 0x0144, /* Monocases to self */ - 0x0146, /* LATIN LETTER N CEDILLA */ - 0x0146, /* Monocases to self */ - 0x0148, /* LATIN LETTER N HACEK */ - 0x0148, /* Monocases to self */ - 0x0149, /* Monocases to self */ - 0x014B, /* LATIN LETTER ENG */ - 0x014B, /* Monocases to self */ - 0x014D, /* LATIN LETTER O MACRON */ - 0x014D, /* Monocases to self */ - 0x014F, /* LATIN LETTER O BREVE */ - 0x014F, /* Monocases to self */ - 0x0151, /* LATIN LETTER O DOUBLE ACUTE */ - 0x0151, /* Monocases to self */ - 0x0153, /* LATIN LETTER O E */ - 0x0153, /* Monocases to self */ - 0x0155, /* LATIN LETTER R ACUTE */ - 0x0155, /* Monocases to self */ - 0x0157, /* LATIN LETTER R CEDILLA */ - 0x0157, /* Monocases to self */ - 0x0159, /* LATIN LETTER R HACEK */ - 0x0159, /* Monocases to self */ - 0x015B, /* LATIN LETTER S ACUTE */ - 0x015B, /* Monocases to self */ - 0x015D, /* LATIN LETTER S CIRCUMFLEX */ - 0x015D, /* Monocases to self */ - 0x015F, /* LATIN LETTER S CEDILLA */ - 0x015F, /* Monocases to self */ - 0x0161, /* LATIN LETTER S HACEK */ - 0x0161, /* Monocases to self */ - 0x0163, /* LATIN LETTER T CEDILLA */ - 0x0163, /* Monocases to self */ - 0x0165, /* LATIN LETTER T HACEK */ - 0x0165, /* Monocases to self */ - 0x0167, /* LATIN LETTER T BAR */ - 0x0167, /* Monocases to self */ - 0x0169, /* LATIN LETTER U TILDE */ - 0x0169, /* Monocases to self */ - 0x016B, /* LATIN LETTER U MACRON */ - 0x016B, /* Monocases to self */ - 0x016D, /* LATIN LETTER U BREVE */ - 0x016D, /* Monocases to self */ - 0x016F, /* LATIN LETTER U RING */ - 0x016F, /* Monocases to self */ - 0x0171, /* LATIN LETTER U DOUBLE ACUTE */ - 0x0171, /* Monocases to self */ - 0x0173, /* LATIN LETTER U OGONEK */ - 0x0173, /* Monocases to self */ - 0x0175, /* LATIN LETTER W CIRCUMFLEX */ - 0x0175, /* Monocases to self */ - 0x0177, /* LATIN LETTER Y CIRCUMFLEX */ - 0x0177, /* Monocases to self */ - 0x00FF, /* LATIN LETTER Y DIAERESIS */ - 0x017A, /* LATIN LETTER Z ACUTE */ - 0x017A, /* Monocases to self */ - 0x017C, /* LATIN LETTER Z DOT */ - 0x017C, /* Monocases to self */ - 0x017E, /* LATIN LETTER Z HACEK */ - 0x017E, /* Monocases to self */ - 0x017F, /* Monocases to self */ - 0x0180, /* Monocases to self */ - 0x0253, /* LATIN LETTER B HOOK */ - 0x0183, /* LATIN LETTER B TOPBAR */ - 0x0183, /* Monocases to self */ - 0x0185, /* LATIN LETTER TONE SIX */ - 0x0185, /* Monocases to self */ - 0x0254, /* LATIN LETTER OPEN O */ - 0x0188, /* LATIN LETTER C HOOK */ - 0x0188, /* Monocases to self */ - 0x0256, /* LATIN LETTER AFRICAN D */ - 0x0257, /* LATIN LETTER D HOOK */ - 0x018C, /* LATIN LETTER D TOPBAR */ - 0x018C, /* Monocases to self */ - 0x018D, /* Monocases to self */ - 0x01DD, /* LATIN LETTER TURNED E */ - 0x0259, /* LATIN LETTER SCHWA */ - 0x025B, /* LATIN LETTER EPSILON */ - 0x0192, /* LATIN LETTER F HOOK */ - 0x0192, /* Monocases to self */ - 0x0260, /* LATIN LETTER G HOOK */ - 0x0263, /* LATIN LETTER GAMMA */ - 0x0195, /* Monocases to self */ - 0x0269, /* LATIN LETTER IOTA */ - 0x0268, /* LATIN LETTER BARRED I */ - 0x0199, /* LATIN LETTER K HOOK */ - 0x0199, /* Monocases to self */ - 0x019A, /* Monocases to self */ - 0x019B, /* Monocases to self */ - 0x026F, /* LATIN LETTER TURNED M */ - 0x0272, /* LATIN LETTER N HOOK */ - 0x019E, /* Monocases to self */ - 0x0275, /* LATIN LETTER BARRED O */ - 0x01A1, /* LATIN LETTER O HORN */ - 0x01A1, /* Monocases to self */ - 0x01A3, /* LATIN LETTER O I */ - 0x01A3, /* Monocases to self */ - 0x01A5, /* LATIN LETTER P HOOK */ - 0x01A5, /* Monocases to self */ - 0x01A6, /* Monocases to self */ - 0x01A8, /* LATIN LETTER TONE TWO */ - 0x01A8, /* Monocases to self */ - 0x0283, /* LATIN LETTER ESH */ - 0x01AA, /* Monocases to self */ - 0x01AB, /* Monocases to self */ - 0x01AD, /* LATIN LETTER T HOOK */ - 0x01AD, /* Monocases to self */ - 0x0288, /* LATIN LETTER T RETROFLEX HOOK */ - 0x01B0, /* LATIN LETTER U HORN */ - 0x01B0, /* Monocases to self */ - 0x028A, /* LATIN LETTER UPSILON */ - 0x028B, /* LATIN LETTER SCRIPT V */ - 0x01B4, /* LATIN LETTER Y HOOK */ - 0x01B4, /* Monocases to self */ - 0x01B6, /* LATIN LETTER Z BAR */ - 0x01B6, /* Monocases to self */ - 0x0292, /* LATIN LETTER YOGH */ - 0x01B9, /* LATIN LETTER REVERSED YOGH */ - 0x01B9, /* Monocases to self */ - 0x01BA, /* Monocases to self */ - 0x01BB, /* Monocases to self */ - 0x01BD, /* LATIN LETTER TONE FIVE */ - 0x01BD, /* Monocases to self */ - 0x01BE, /* Monocases to self */ - 0x01BF, /* Monocases to self */ - 0x01C0, /* Monocases to self */ - 0x01C1, /* Monocases to self */ - 0x01C2, /* Monocases to self */ - 0x01C3, /* Monocases to self */ - 0x01C6, /* LATIN LETTER D Z HACEK */ - 0x01C6, /* LATIN LETTER CAPITAL D SMALL Z HACEK */ - 0x01C6, /* Monocases to self */ - 0x01C9, /* LATIN LETTER CAPITAL L CAPTIAL J */ - 0x01C9, /* LATIN LETTER CAPITAL L SMALL J */ - 0x01C9, /* Monocases to self */ - 0x01CC, /* LATIN LETTER CAPITAL N CAPITAL J */ - 0x01CC, /* LATIN LETTER CAPITAL N SMALL J */ - 0x01CC, /* Monocases to self */ - 0x01CE, /* LATIN LETTER A HACEK */ - 0x01CE, /* Monocases to self */ - 0x01D0, /* LATIN LETTER I HACEK */ - 0x01D0, /* Monocases to self */ - 0x01D2, /* LATIN LETTER O HACEK */ - 0x01D2, /* Monocases to self */ - 0x01D4, /* LATIN LETTER U HACEK */ - 0x01D4, /* Monocases to self */ - 0x01D6, /* LATIN LETTER U DIAERESIS MACRON */ - 0x01D6, /* Monocases to self */ - 0x01D8, /* LATIN LETTER U DIAERESIS ACUTE */ - 0x01D8, /* Monocases to self */ - 0x01DA, /* LATIN LETTER U DIAERESIS HACEK */ - 0x01DA, /* Monocases to self */ - 0x01DC, /* LATIN LETTER U DIAERESIS GRAVE */ - 0x01DC, /* Monocases to self */ - 0x01DD, /* Monocases to self */ - 0x01DF, /* LATIN LETTER A DIAERESIS MACRON */ - 0x01DF, /* Monocases to self */ - 0x01E1, /* LATIN LETTER A DOT MACRON */ - 0x01E1, /* Monocases to self */ - 0x01E3, /* LATIN LETTER A E MACRON */ - 0x01E3, /* Monocases to self */ - 0x01E5, /* LATIN LETTER G BAR */ - 0x01E5, /* Monocases to self */ - 0x01E7, /* LATIN LETTER G HACEK */ - 0x01E7, /* Monocases to self */ - 0x01E9, /* LATIN LETTER K HACEK */ - 0x01E9, /* Monocases to self */ - 0x01EB, /* LATIN LETTER O OGONEK */ - 0x01EB, /* Monocases to self */ - 0x01ED, /* LATIN LETTER O OGONEK MACRON */ - 0x01ED, /* Monocases to self */ - 0x01EF, /* LATIN LETTER YOGH HACEK */ - 0x01EF, /* Monocases to self */ - 0x01F0, /* Monocases to self */ - 0x01F1, /* Monocases to self */ - 0x01F2, /* Monocases to self */ - 0x01F3, /* Monocases to self */ - 0x01F4, /* Monocases to self */ - 0x01F5, /* Monocases to self */ - 0x01F6, /* Monocases to self */ - 0x01F7, /* Monocases to self */ - 0x01F8, /* Monocases to self */ - 0x01F9, /* Monocases to self */ - 0x01FA, /* Monocases to self */ - 0x01FB, /* Monocases to self */ - 0x01FC, /* Monocases to self */ - 0x01FD, /* Monocases to self */ - 0x01FE, /* Monocases to self */ - 0x01FF, /* Monocases to self */ - 0x0200, /* Monocases to self */ - 0x0201, /* Monocases to self */ - 0x0202, /* Monocases to self */ - 0x0203, /* Monocases to self */ - 0x0204, /* Monocases to self */ - 0x0205, /* Monocases to self */ - 0x0206, /* Monocases to self */ - 0x0207, /* Monocases to self */ - 0x0208, /* Monocases to self */ - 0x0209, /* Monocases to self */ - 0x020A, /* Monocases to self */ - 0x020B, /* Monocases to self */ - 0x020C, /* Monocases to self */ - 0x020D, /* Monocases to self */ - 0x020E, /* Monocases to self */ - 0x020F, /* Monocases to self */ - 0x0210, /* Monocases to self */ - 0x0211, /* Monocases to self */ - 0x0212, /* Monocases to self */ - 0x0213, /* Monocases to self */ - 0x0214, /* Monocases to self */ - 0x0215, /* Monocases to self */ - 0x0216, /* Monocases to self */ - 0x0217, /* Monocases to self */ - 0x0218, /* Monocases to self */ - 0x0219, /* Monocases to self */ - 0x021A, /* Monocases to self */ - 0x021B, /* Monocases to self */ - 0x021C, /* Monocases to self */ - 0x021D, /* Monocases to self */ - 0x021E, /* Monocases to self */ - 0x021F, /* Monocases to self */ - 0x0220, /* Monocases to self */ - 0x0221, /* Monocases to self */ - 0x0222, /* Monocases to self */ - 0x0223, /* Monocases to self */ - 0x0224, /* Monocases to self */ - 0x0225, /* Monocases to self */ - 0x0226, /* Monocases to self */ - 0x0227, /* Monocases to self */ - 0x0228, /* Monocases to self */ - 0x0229, /* Monocases to self */ - 0x022A, /* Monocases to self */ - 0x022B, /* Monocases to self */ - 0x022C, /* Monocases to self */ - 0x022D, /* Monocases to self */ - 0x022E, /* Monocases to self */ - 0x022F, /* Monocases to self */ - 0x0230, /* Monocases to self */ - 0x0231, /* Monocases to self */ - 0x0232, /* Monocases to self */ - 0x0233, /* Monocases to self */ - 0x0234, /* Monocases to self */ - 0x0235, /* Monocases to self */ - 0x0236, /* Monocases to self */ - 0x0237, /* Monocases to self */ - 0x0238, /* Monocases to self */ - 0x0239, /* Monocases to self */ - 0x023A, /* Monocases to self */ - 0x023B, /* Monocases to self */ - 0x023C, /* Monocases to self */ - 0x023D, /* Monocases to self */ - 0x023E, /* Monocases to self */ - 0x023F, /* Monocases to self */ - 0x0240, /* Monocases to self */ - 0x0241, /* Monocases to self */ - 0x0242, /* Monocases to self */ - 0x0243, /* Monocases to self */ - 0x0244, /* Monocases to self */ - 0x0245, /* Monocases to self */ - 0x0246, /* Monocases to self */ - 0x0247, /* Monocases to self */ - 0x0248, /* Monocases to self */ - 0x0249, /* Monocases to self */ - 0x024A, /* Monocases to self */ - 0x024B, /* Monocases to self */ - 0x024C, /* Monocases to self */ - 0x024D, /* Monocases to self */ - 0x024E, /* Monocases to self */ - 0x024F, /* Monocases to self */ - 0x0250, /* Monocases to self */ - 0x0251, /* Monocases to self */ - 0x0252, /* Monocases to self */ - 0x0253, /* Monocases to self */ - 0x0254, /* Monocases to self */ - 0x0255, /* Monocases to self */ - 0x0256, /* Monocases to self */ - 0x0257, /* Monocases to self */ - 0x0258, /* Monocases to self */ - 0x0259, /* Monocases to self */ - 0x025A, /* Monocases to self */ - 0x025B, /* Monocases to self */ - 0x025C, /* Monocases to self */ - 0x025D, /* Monocases to self */ - 0x025E, /* Monocases to self */ - 0x025F, /* Monocases to self */ - 0x0260, /* Monocases to self */ - 0x0261, /* Monocases to self */ - 0x0262, /* Monocases to self */ - 0x0263, /* Monocases to self */ - 0x0264, /* Monocases to self */ - 0x0265, /* Monocases to self */ - 0x0266, /* Monocases to self */ - 0x0267, /* Monocases to self */ - 0x0268, /* Monocases to self */ - 0x0269, /* Monocases to self */ - 0x026A, /* Monocases to self */ - 0x026B, /* Monocases to self */ - 0x026C, /* Monocases to self */ - 0x026D, /* Monocases to self */ - 0x026E, /* Monocases to self */ - 0x026F, /* Monocases to self */ - 0x0270, /* Monocases to self */ - 0x0271, /* Monocases to self */ - 0x0272, /* Monocases to self */ - 0x0273, /* Monocases to self */ - 0x0274, /* Monocases to self */ - 0x0275, /* Monocases to self */ - 0x0276, /* Monocases to self */ - 0x0277, /* Monocases to self */ - 0x0278, /* Monocases to self */ - 0x0279, /* Monocases to self */ - 0x027A, /* Monocases to self */ - 0x027B, /* Monocases to self */ - 0x027C, /* Monocases to self */ - 0x027D, /* Monocases to self */ - 0x027E, /* Monocases to self */ - 0x027F, /* Monocases to self */ - 0x0280, /* Monocases to self */ - 0x0281, /* Monocases to self */ - 0x0282, /* Monocases to self */ - 0x0283, /* Monocases to self */ - 0x0284, /* Monocases to self */ - 0x0285, /* Monocases to self */ - 0x0286, /* Monocases to self */ - 0x0287, /* Monocases to self */ - 0x0288, /* Monocases to self */ - 0x0289, /* Monocases to self */ - 0x028A, /* Monocases to self */ - 0x028B, /* Monocases to self */ - 0x028C, /* Monocases to self */ - 0x028D, /* Monocases to self */ - 0x028E, /* Monocases to self */ - 0x028F, /* Monocases to self */ - 0x0290, /* Monocases to self */ - 0x0291, /* Monocases to self */ - 0x0292, /* Monocases to self */ - 0x0293, /* Monocases to self */ - 0x0294, /* Monocases to self */ - 0x0295, /* Monocases to self */ - 0x0296, /* Monocases to self */ - 0x0297, /* Monocases to self */ - 0x0298, /* Monocases to self */ - 0x0299, /* Monocases to self */ - 0x029A, /* Monocases to self */ - 0x029B, /* Monocases to self */ - 0x029C, /* Monocases to self */ - 0x029D, /* Monocases to self */ - 0x029E, /* Monocases to self */ - 0x029F, /* Monocases to self */ - 0x02A0, /* Monocases to self */ - 0x02A1, /* Monocases to self */ - 0x02A2, /* Monocases to self */ - 0x02A3, /* Monocases to self */ - 0x02A4, /* Monocases to self */ - 0x02A5, /* Monocases to self */ - 0x02A6, /* Monocases to self */ - 0x02A7, /* Monocases to self */ - 0x02A8, /* Monocases to self */ - 0x02A9, /* Monocases to self */ - 0x02AA, /* Monocases to self */ - 0x02AB, /* Monocases to self */ - 0x02AC, /* Monocases to self */ - 0x02AD, /* Monocases to self */ - 0x02AE, /* Monocases to self */ - 0x02AF, /* Monocases to self */ - 0x02B0, /* Monocases to self */ - 0x02B1, /* Monocases to self */ - 0x02B2, /* Monocases to self */ - 0x02B3, /* Monocases to self */ - 0x02B4, /* Monocases to self */ - 0x02B5, /* Monocases to self */ - 0x02B6, /* Monocases to self */ - 0x02B7, /* Monocases to self */ - 0x02B8, /* Monocases to self */ - 0x02B9, /* Monocases to self */ - 0x02BA, /* Monocases to self */ - 0x02BB, /* Monocases to self */ - 0x02BC, /* Monocases to self */ - 0x02BD, /* Monocases to self */ - 0x02BE, /* Monocases to self */ - 0x02BF, /* Monocases to self */ - 0x02C0, /* Monocases to self */ - 0x02C1, /* Monocases to self */ - 0x02C2, /* Monocases to self */ - 0x02C3, /* Monocases to self */ - 0x02C4, /* Monocases to self */ - 0x02C5, /* Monocases to self */ - 0x02C6, /* Monocases to self */ - 0x02C7, /* Monocases to self */ - 0x02C8, /* Monocases to self */ - 0x02C9, /* Monocases to self */ - 0x02CA, /* Monocases to self */ - 0x02CB, /* Monocases to self */ - 0x02CC, /* Monocases to self */ - 0x02CD, /* Monocases to self */ - 0x02CE, /* Monocases to self */ - 0x02CF, /* Monocases to self */ - 0x02D0, /* Monocases to self */ - 0x02D1, /* Monocases to self */ - 0x02D2, /* Monocases to self */ - 0x02D3, /* Monocases to self */ - 0x02D4, /* Monocases to self */ - 0x02D5, /* Monocases to self */ - 0x02D6, /* Monocases to self */ - 0x02D7, /* Monocases to self */ - 0x02D8, /* Monocases to self */ - 0x02D9, /* Monocases to self */ - 0x02DA, /* Monocases to self */ - 0x02DB, /* Monocases to self */ - 0x02DC, /* Monocases to self */ - 0x02DD, /* Monocases to self */ - 0x02DE, /* Monocases to self */ - 0x02DF, /* Monocases to self */ - 0x02E0, /* Monocases to self */ - 0x02E1, /* Monocases to self */ - 0x02E2, /* Monocases to self */ - 0x02E3, /* Monocases to self */ - 0x02E4, /* Monocases to self */ - 0x02E5, /* Monocases to self */ - 0x02E6, /* Monocases to self */ - 0x02E7, /* Monocases to self */ - 0x02E8, /* Monocases to self */ - 0x02E9, /* Monocases to self */ - 0x02EA, /* Monocases to self */ - 0x02EB, /* Monocases to self */ - 0x02EC, /* Monocases to self */ - 0x02ED, /* Monocases to self */ - 0x02EE, /* Monocases to self */ - 0x02EF, /* Monocases to self */ - 0x02F0, /* Monocases to self */ - 0x02F1, /* Monocases to self */ - 0x02F2, /* Monocases to self */ - 0x02F3, /* Monocases to self */ - 0x02F4, /* Monocases to self */ - 0x02F5, /* Monocases to self */ - 0x02F6, /* Monocases to self */ - 0x02F7, /* Monocases to self */ - 0x02F8, /* Monocases to self */ - 0x02F9, /* Monocases to self */ - 0x02FA, /* Monocases to self */ - 0x02FB, /* Monocases to self */ - 0x02FC, /* Monocases to self */ - 0x02FD, /* Monocases to self */ - 0x02FE, /* Monocases to self */ - 0x02FF, /* Monocases to self */ - 0x0300, /* Monocases to self */ - 0x0301, /* Monocases to self */ - 0x0302, /* Monocases to self */ - 0x0303, /* Monocases to self */ - 0x0304, /* Monocases to self */ - 0x0305, /* Monocases to self */ - 0x0306, /* Monocases to self */ - 0x0307, /* Monocases to self */ - 0x0308, /* Monocases to self */ - 0x0309, /* Monocases to self */ - 0x030A, /* Monocases to self */ - 0x030B, /* Monocases to self */ - 0x030C, /* Monocases to self */ - 0x030D, /* Monocases to self */ - 0x030E, /* Monocases to self */ - 0x030F, /* Monocases to self */ - 0x0310, /* Monocases to self */ - 0x0311, /* Monocases to self */ - 0x0312, /* Monocases to self */ - 0x0313, /* Monocases to self */ - 0x0314, /* Monocases to self */ - 0x0315, /* Monocases to self */ - 0x0316, /* Monocases to self */ - 0x0317, /* Monocases to self */ - 0x0318, /* Monocases to self */ - 0x0319, /* Monocases to self */ - 0x031A, /* Monocases to self */ - 0x031B, /* Monocases to self */ - 0x031C, /* Monocases to self */ - 0x031D, /* Monocases to self */ - 0x031E, /* Monocases to self */ - 0x031F, /* Monocases to self */ - 0x0320, /* Monocases to self */ - 0x0321, /* Monocases to self */ - 0x0322, /* Monocases to self */ - 0x0323, /* Monocases to self */ - 0x0324, /* Monocases to self */ - 0x0325, /* Monocases to self */ - 0x0326, /* Monocases to self */ - 0x0327, /* Monocases to self */ - 0x0328, /* Monocases to self */ - 0x0329, /* Monocases to self */ - 0x032A, /* Monocases to self */ - 0x032B, /* Monocases to self */ - 0x032C, /* Monocases to self */ - 0x032D, /* Monocases to self */ - 0x032E, /* Monocases to self */ - 0x032F, /* Monocases to self */ - 0x0330, /* Monocases to self */ - 0x0331, /* Monocases to self */ - 0x0332, /* Monocases to self */ - 0x0333, /* Monocases to self */ - 0x0334, /* Monocases to self */ - 0x0335, /* Monocases to self */ - 0x0336, /* Monocases to self */ - 0x0337, /* Monocases to self */ - 0x0338, /* Monocases to self */ - 0x0339, /* Monocases to self */ - 0x033A, /* Monocases to self */ - 0x033B, /* Monocases to self */ - 0x033C, /* Monocases to self */ - 0x033D, /* Monocases to self */ - 0x033E, /* Monocases to self */ - 0x033F, /* Monocases to self */ - 0x0340, /* Monocases to self */ - 0x0341, /* Monocases to self */ - 0x0342, /* Monocases to self */ - 0x0343, /* Monocases to self */ - 0x0344, /* Monocases to self */ - 0x0345, /* Monocases to self */ - 0x0346, /* Monocases to self */ - 0x0347, /* Monocases to self */ - 0x0348, /* Monocases to self */ - 0x0349, /* Monocases to self */ - 0x034A, /* Monocases to self */ - 0x034B, /* Monocases to self */ - 0x034C, /* Monocases to self */ - 0x034D, /* Monocases to self */ - 0x034E, /* Monocases to self */ - 0x034F, /* Monocases to self */ - 0x0350, /* Monocases to self */ - 0x0351, /* Monocases to self */ - 0x0352, /* Monocases to self */ - 0x0353, /* Monocases to self */ - 0x0354, /* Monocases to self */ - 0x0355, /* Monocases to self */ - 0x0356, /* Monocases to self */ - 0x0357, /* Monocases to self */ - 0x0358, /* Monocases to self */ - 0x0359, /* Monocases to self */ - 0x035A, /* Monocases to self */ - 0x035B, /* Monocases to self */ - 0x035C, /* Monocases to self */ - 0x035D, /* Monocases to self */ - 0x035E, /* Monocases to self */ - 0x035F, /* Monocases to self */ - 0x0360, /* Monocases to self */ - 0x0361, /* Monocases to self */ - 0x0362, /* Monocases to self */ - 0x0363, /* Monocases to self */ - 0x0364, /* Monocases to self */ - 0x0365, /* Monocases to self */ - 0x0366, /* Monocases to self */ - 0x0367, /* Monocases to self */ - 0x0368, /* Monocases to self */ - 0x0369, /* Monocases to self */ - 0x036A, /* Monocases to self */ - 0x036B, /* Monocases to self */ - 0x036C, /* Monocases to self */ - 0x036D, /* Monocases to self */ - 0x036E, /* Monocases to self */ - 0x036F, /* Monocases to self */ - 0x0370, /* Monocases to self */ - 0x0371, /* Monocases to self */ - 0x0372, /* Monocases to self */ - 0x0373, /* Monocases to self */ - 0x0374, /* Monocases to self */ - 0x0375, /* Monocases to self */ - 0x0376, /* Monocases to self */ - 0x0377, /* Monocases to self */ - 0x0378, /* Monocases to self */ - 0x0379, /* Monocases to self */ - 0x037A, /* Monocases to self */ - 0x037B, /* Monocases to self */ - 0x037C, /* Monocases to self */ - 0x037D, /* Monocases to self */ - 0x037E, /* Monocases to self */ - 0x037F, /* Monocases to self */ - 0x0380, /* Monocases to self */ - 0x0381, /* Monocases to self */ - 0x0382, /* Monocases to self */ - 0x0383, /* Monocases to self */ - 0x0384, /* Monocases to self */ - 0x0385, /* Monocases to self */ - 0x03AC, /* GREEK LETTER ALPHA TONOS */ - 0x0387, /* Monocases to self */ - 0x03AD, /* GREEK LETTER EPSILON TONOS */ - 0x03AE, /* GREEK LETTER ETA TONOS */ - 0x03AF, /* GREEK LETTER IOTA TONOS */ - 0x038B, /* Monocases to self */ - 0x03CC, /* GREEK LETTER OMICRON TONOS */ - 0x038D, /* Monocases to self */ - 0x03CD, /* GREEK LETTER UPSILON TONOS */ - 0x03CE, /* GREEK LETTER OMEGA TONOS */ - 0x0390, /* Monocases to self */ - 0x03B1, /* GREEK LETTER ALPHA */ - 0x03B2, /* GREEK LETTER BETA */ - 0x03B3, /* GREEK LETTER GAMMA */ - 0x03B4, /* GREEK LETTER DELTA */ - 0x03B5, /* GREEK LETTER EPSILON */ - 0x03B6, /* GREEK LETTER ZETA */ - 0x03B7, /* GREEK LETTER ETA */ - 0x03B8, /* GREEK LETTER THETA */ - 0x03B9, /* GREEK LETTER IOTA */ - 0x03BA, /* GREEK LETTER KAPPA */ - 0x03BB, /* GREEK LETTER LAMBDA */ - 0x03BC, /* GREEK LETTER MU */ - 0x03BD, /* GREEK LETTER NU */ - 0x03BE, /* GREEK LETTER Xl */ - 0x03BF, /* GREEK LETTER OMICRON */ - 0x03C0, /* GREEK LETTER PI */ - 0x03C1, /* GREEK LETTER RHO */ - 0x03A2, /* Monocases to self */ - 0x03C3, /* GREEK LETTER SIGMA */ - 0x03C4, /* GREEK LETTER TAU */ - 0x03C5, /* GREEK LETTER UPSILON */ - 0x03C6, /* GREEK LETTER PHI */ - 0x03C7, /* GREEK LETTER CHI */ - 0x03C8, /* GREEK LETTER PSI */ - 0x03C9, /* GREEK LETTER OMEGA */ - 0x03CA, /* GREEK LETTER IOTA DIAERESIS */ - 0x03CB, /* GREEK LETTER UPSILON DIAERESIS */ - 0x03AC, /* Monocases to self */ - 0x03AD, /* Monocases to self */ - 0x03AE, /* Monocases to self */ - 0x03AF, /* Monocases to self */ - 0x03B0, /* Monocases to self */ - 0x03B1, /* Monocases to self */ - 0x03B2, /* Monocases to self */ - 0x03B3, /* Monocases to self */ - 0x03B4, /* Monocases to self */ - 0x03B5, /* Monocases to self */ - 0x03B6, /* Monocases to self */ - 0x03B7, /* Monocases to self */ - 0x03B8, /* Monocases to self */ - 0x03B9, /* Monocases to self */ - 0x03BA, /* Monocases to self */ - 0x03BB, /* Monocases to self */ - 0x03BC, /* Monocases to self */ - 0x03BD, /* Monocases to self */ - 0x03BE, /* Monocases to self */ - 0x03BF, /* Monocases to self */ - 0x03C0, /* Monocases to self */ - 0x03C1, /* Monocases to self */ - 0x03C2, /* Monocases to self */ - 0x03C3, /* Monocases to self */ - 0x03C4, /* Monocases to self */ - 0x03C5, /* Monocases to self */ - 0x03C6, /* Monocases to self */ - 0x03C7, /* Monocases to self */ - 0x03C8, /* Monocases to self */ - 0x03C9, /* Monocases to self */ - 0x03CA, /* Monocases to self */ - 0x03CB, /* Monocases to self */ - 0x03CC, /* Monocases to self */ - 0x03CD, /* Monocases to self */ - 0x03CE, /* Monocases to self */ - 0x03CF, /* Monocases to self */ - 0x03D0, /* Monocases to self */ - 0x03D1, /* Monocases to self */ - 0x03C5, /* GREEK LETTER UPSILON HOOK */ - 0x03CD, /* GREEK LETTER UPSILON HOOK TONOS */ - 0x03CB, /* GREEK LETTER UPSILON HOOK DIAERESIS */ - 0x03D5, /* Monocases to self */ - 0x03D6, /* Monocases to self */ - 0x03D7, /* Monocases to self */ - 0x03D8, /* Monocases to self */ - 0x03D9, /* Monocases to self */ - 0x03DB, /* GREEK LETTER STIGMA */ - 0x03DB, /* Monocases to self */ - 0x03DD, /* GREEK LETTER DIGAMMA */ - 0x03DD, /* Monocases to self */ - 0x03DF, /* GREEK LETTER KOPPA */ - 0x03DF, /* Monocases to self */ - 0x03E1, /* GREEK LETTER SAMPI */ - 0x03E1, /* Monocases to self */ - 0x03E3, /* GREEK LETTER SHEI */ - 0x03E3, /* Monocases to self */ - 0x03E5, /* GREEK LETTER FEI */ - 0x03E5, /* Monocases to self */ - 0x03E7, /* GREEK LETTER KHEI */ - 0x03E7, /* Monocases to self */ - 0x03E9, /* GREEK LETTER HORI */ - 0x03E9, /* Monocases to self */ - 0x03EB, /* GREEK LETTER GANGIA */ - 0x03EB, /* Monocases to self */ - 0x03ED, /* GREEK LETTER SHIMA */ - 0x03ED, /* Monocases to self */ - 0x03EF, /* GREEK LETTER DEI */ - 0x03EF, /* Monocases to self */ - 0x03F0, /* Monocases to self */ - 0x03F1, /* Monocases to self */ - 0x03F2, /* Monocases to self */ - 0x03F3, /* Monocases to self */ - 0x03F4, /* Monocases to self */ - 0x03F5, /* Monocases to self */ - 0x03F6, /* Monocases to self */ - 0x03F7, /* Monocases to self */ - 0x03F8, /* Monocases to self */ - 0x03F9, /* Monocases to self */ - 0x03FA, /* Monocases to self */ - 0x03FB, /* Monocases to self */ - 0x03FC, /* Monocases to self */ - 0x03FD, /* Monocases to self */ - 0x03FE, /* Monocases to self */ - 0x03FF, /* Monocases to self */ - 0x0400, /* Monocases to self */ - 0x0451, /* CYRILLIC LETTER IO */ - 0x0452, /* CYRILLIC LETTER DJE */ - 0x0453, /* CYRILLIC LETTER GJE */ - 0x0454, /* CYRILLIC LETTER E */ - 0x0455, /* CYRILLIC LETTER DZE */ - 0x0456, /* CYRILLIC LETTER I */ - 0x0457, /* CYRILLIC LETTER YI */ - 0x0458, /* CYRILLIC LETTER JE */ - 0x0459, /* CYRILLIC LETTER LJE */ - 0x045A, /* CYRILLIC LETTER NJE */ - 0x045B, /* CYRILLIC LETTER TSHE */ - 0x045C, /* CYRILLIC LETTER KJE */ - 0x040D, /* Monocases to self */ - 0x045E, /* CYRILLIC LETTER SHORT U */ - 0x045F, /* CYRILLIC LETTER DZHE */ - 0x0430, /* CYRILLIC LETTER A */ - 0x0431, /* CYRILLIC LETTER BE */ - 0x0432, /* CYRILLIC LETTER VE */ - 0x0433, /* CYRILLIC LETTER GE */ - 0x0434, /* CYRILLIC LETTER DE */ - 0x0435, /* CYRILLIC LETTER IE */ - 0x0436, /* CYRILLIC LETTER ZHE */ - 0x0437, /* CYRILLIC LETTER ZE */ - 0x0438, /* CYRILLIC LETTER II */ - 0x0439, /* CYRILLIC LETTER SHORT II */ - 0x043A, /* CYRILLIC LETTER KA */ - 0x043B, /* CYRILLIC LETTER EL */ - 0x043C, /* CYRILLIC LETTER EM */ - 0x043D, /* CYRILLIC LETTER EN */ - 0x043E, /* CYRILLIC LETTER O */ - 0x043F, /* CYRILLIC LETTER PE */ - 0x0440, /* CYRILLIC LETTER ER */ - 0x0441, /* CYRILLIC LETTER ES */ - 0x0442, /* CYRILLIC LETTER TE */ - 0x0443, /* CYRILLIC LETTER U */ - 0x0444, /* CYRILLIC LETTER EF */ - 0x0445, /* CYRILLIC LETTER KHA */ - 0x0446, /* CYRILLIC LETTER TSE */ - 0x0447, /* CYRILLIC LETTER CHE */ - 0x0448, /* CYRILLIC LETTER SHA */ - 0x0449, /* CYRILLIC LETTER SHCHA */ - 0x044A, /* CYRILLIC LETTER HARD SIGN */ - 0x044B, /* CYRILLIC LETTER YERI */ - 0x044C, /* CYRILLIC LETTER SOFT SIGN */ - 0x044D, /* CYRILLIC LETTER REVERSED E */ - 0x044E, /* CYRILLIC LETTER IU */ - 0x044F, /* CYRILLIC LETTER IA */ - 0x0430, /* Monocases to self */ - 0x0431, /* Monocases to self */ - 0x0432, /* Monocases to self */ - 0x0433, /* Monocases to self */ - 0x0434, /* Monocases to self */ - 0x0435, /* Monocases to self */ - 0x0436, /* Monocases to self */ - 0x0437, /* Monocases to self */ - 0x0438, /* Monocases to self */ - 0x0439, /* Monocases to self */ - 0x043A, /* Monocases to self */ - 0x043B, /* Monocases to self */ - 0x043C, /* Monocases to self */ - 0x043D, /* Monocases to self */ - 0x043E, /* Monocases to self */ - 0x043F, /* Monocases to self */ - 0x0440, /* Monocases to self */ - 0x0441, /* Monocases to self */ - 0x0442, /* Monocases to self */ - 0x0443, /* Monocases to self */ - 0x0444, /* Monocases to self */ - 0x0445, /* Monocases to self */ - 0x0446, /* Monocases to self */ - 0x0447, /* Monocases to self */ - 0x0448, /* Monocases to self */ - 0x0449, /* Monocases to self */ - 0x044A, /* Monocases to self */ - 0x044B, /* Monocases to self */ - 0x044C, /* Monocases to self */ - 0x044D, /* Monocases to self */ - 0x044E, /* Monocases to self */ - 0x044F, /* Monocases to self */ - 0x0450, /* Monocases to self */ - 0x0451, /* Monocases to self */ - 0x0452, /* Monocases to self */ - 0x0453, /* Monocases to self */ - 0x0454, /* Monocases to self */ - 0x0455, /* Monocases to self */ - 0x0456, /* Monocases to self */ - 0x0457, /* Monocases to self */ - 0x0458, /* Monocases to self */ - 0x0459, /* Monocases to self */ - 0x045A, /* Monocases to self */ - 0x045B, /* Monocases to self */ - 0x045C, /* Monocases to self */ - 0x045D, /* Monocases to self */ - 0x045E, /* Monocases to self */ - 0x045F, /* Monocases to self */ - 0x0461, /* CYRILLIC LETTER OMEGA */ - 0x0461, /* Monocases to self */ - 0x0463, /* CYRILLIC LETTER YAT */ - 0x0463, /* Monocases to self */ - 0x0465, /* CYRILLIC LETTER IOTIFIED E */ - 0x0465, /* Monocases to self */ - 0x0467, /* CYRILLIC LETTER LITTLE YUS */ - 0x0467, /* Monocases to self */ - 0x0469, /* CYRILLIC LETTER IOTIFIED LITTLE YUS */ - 0x0469, /* Monocases to self */ - 0x046B, /* CYRILLIC LETTER BIG YUS */ - 0x046B, /* Monocases to self */ - 0x046D, /* CYRILLIC LETTER IOTIFIED BIG YUS */ - 0x046D, /* Monocases to self */ - 0x046F, /* CYRILLIC LETTER KSI */ - 0x046F, /* Monocases to self */ - 0x0471, /* CYRILLIC LETTER PSI */ - 0x0471, /* Monocases to self */ - 0x0473, /* CYRILLIC LETTER FITA */ - 0x0473, /* Monocases to self */ - 0x0475, /* CYRILLIC LETTER IZHITSA */ - 0x0475, /* Monocases to self */ - 0x0477, /* CYRILLIC LETTER IZHITSA DOUBLE GRAVE */ - 0x0477, /* Monocases to self */ - 0x0479, /* CYRILLIC LETTER UK DIGRAPH */ - 0x0479, /* Monocases to self */ - 0x047B, /* CYRILLIC LETTER ROUND OMEGA */ - 0x047B, /* Monocases to self */ - 0x047D, /* CYRILLIC LETTER OMEGA TITLO */ - 0x047D, /* Monocases to self */ - 0x047F, /* CYRILLIC LETTER OT */ - 0x047F, /* Monocases to self */ - 0x0481, /* CYRILLIC LETTER KOPPA */ - 0x0481, /* Monocases to self */ - 0x0482, /* Monocases to self */ - 0x0483, /* Monocases to self */ - 0x0484, /* Monocases to self */ - 0x0485, /* Monocases to self */ - 0x0486, /* Monocases to self */ - 0x0487, /* Monocases to self */ - 0x0488, /* Monocases to self */ - 0x0489, /* Monocases to self */ - 0x048A, /* Monocases to self */ - 0x048B, /* Monocases to self */ - 0x048C, /* Monocases to self */ - 0x048D, /* Monocases to self */ - 0x048E, /* Monocases to self */ - 0x048F, /* Monocases to self */ - 0x0491, /* CYRILLIC LETTER GE WITH UPTURN */ - 0x0491, /* Monocases to self */ - 0x0493, /* CYRILLIC LETTER GE BAR */ - 0x0493, /* Monocases to self */ - 0x0495, /* CYRILLIC LETTER GE HOOK */ - 0x0495, /* Monocases to self */ - 0x0497, /* CYRILLIC LETTER ZHE WITH RIGHT DESCENDER */ - 0x0497, /* Monocases to self */ - 0x0499, /* CYRILLIC LETTER ZE CEDILLA */ - 0x0499, /* Monocases to self */ - 0x049B, /* CYRILLIC LETTER KA WITH RIGHT DESCENDER */ - 0x049B, /* Monocases to self */ - 0x049D, /* CYRILLIC LETTER KA VERTICAL BAR */ - 0x049D, /* Monocases to self */ - 0x049F, /* CYRILLIC LETTER KA BAR */ - 0x049F, /* Monocases to self */ - 0x04A1, /* CYRILLIC LETTER REVERSED GE KA */ - 0x04A1, /* Monocases to self */ - 0x04A3, /* CYRILLIC LETTER EN WITH RIGHT DESCENDER */ - 0x04A3, /* Monocases to self */ - 0x04A5, /* CYRILLIC LETTER EN GE */ - 0x04A5, /* Monocases to self */ - 0x04A7, /* CYRILLIC LETTER PE HOOK */ - 0x04A7, /* Monocases to self */ - 0x04A9, /* CYRILLIC LETTER O HOOK */ - 0x04A9, /* Monocases to self */ - 0x04AB, /* CYRILLIC LETTER ES CEDILLA */ - 0x04AB, /* Monocases to self */ - 0x04AD, /* CYRILLIC LETTER TE WITH RIGHT DESCENDER */ - 0x04AD, /* Monocases to self */ - 0x04AF, /* CYRILLIC LETTER STRAIGHT U */ - 0x04AF, /* Monocases to self */ - 0x04B1, /* CYRILLIC LETTER STRAIGHT U BAR */ - 0x04B1, /* Monocases to self */ - 0x04B3, /* CYRILLIC LETTER KHA WITH RIGHT DESCENDER */ - 0x04B3, /* Monocases to self */ - 0x04B5, /* CYRILLIC LETTER TE TSE */ - 0x04B5, /* Monocases to self */ - 0x04B7, /* CYRILLIC LETTER CHE WITH RIGHT DESCENDER */ - 0x04B7, /* Monocases to self */ - 0x04B9, /* CYRILLIC LETTER CHE VERTICAL BAR */ - 0x04B9, /* Monocases to self */ - 0x04BB, /* CYRILLIC LETTER H */ - 0x04BB, /* Monocases to self */ - 0x04BD, /* CYRILLIC LETTER IE HOOK */ - 0x04BD, /* Monocases to self */ - 0x04BF, /* CYRILLIC LETTER IE HOOK OGONEK */ - 0x04BF, /* Monocases to self */ - 0x04C0, /* Monocases to self */ - 0x04C2, /* CYRILLIC LETTER SHORT ZHE */ - 0x04C2, /* Monocases to self */ - 0x04C4, /* CYRILLIC LETTER KA HOOK */ - 0x04C4, /* Monocases to self */ - 0x04C6, /* CYRILLIC LETTER KA OGONEK */ - 0x04C6, /* Monocases to self */ - 0x04C8, /* CYRILLIC LETTER EN HOOK */ - 0x04C8, /* Monocases to self */ - 0x04CA, /* CYRILLIC LETTER KHA OGONEK */ - 0x04CA, /* Monocases to self */ - 0x04CC, /* CYRILLIC LETTER CHE WITH LEFT DESCENDER */ - 0x04CC, /* Monocases to self */ - 0x04CD, /* Monocases to self */ - 0x04CE, /* Monocases to self */ - 0x04CF, /* Monocases to self */ - 0x04D0, /* Monocases to self */ - 0x04D1, /* Monocases to self */ - 0x04D2, /* Monocases to self */ - 0x04D3, /* Monocases to self */ - 0x04D4, /* Monocases to self */ - 0x04D5, /* Monocases to self */ - 0x04D6, /* Monocases to self */ - 0x04D7, /* Monocases to self */ - 0x04D8, /* Monocases to self */ - 0x04D9, /* Monocases to self */ - 0x04DA, /* Monocases to self */ - 0x04DB, /* Monocases to self */ - 0x04DC, /* Monocases to self */ - 0x04DD, /* Monocases to self */ - 0x04DE, /* Monocases to self */ - 0x04DF, /* Monocases to self */ - 0x04E0, /* Monocases to self */ - 0x04E1, /* Monocases to self */ - 0x04E2, /* Monocases to self */ - 0x04E3, /* Monocases to self */ - 0x04E4, /* Monocases to self */ - 0x04E5, /* Monocases to self */ - 0x04E6, /* Monocases to self */ - 0x04E7, /* Monocases to self */ - 0x04E8, /* Monocases to self */ - 0x04E9, /* Monocases to self */ - 0x04EA, /* Monocases to self */ - 0x04EB, /* Monocases to self */ - 0x04EC, /* Monocases to self */ - 0x04ED, /* Monocases to self */ - 0x04EE, /* Monocases to self */ - 0x04EF, /* Monocases to self */ - 0x04F0, /* Monocases to self */ - 0x04F1, /* Monocases to self */ - 0x04F2, /* Monocases to self */ - 0x04F3, /* Monocases to self */ - 0x04F4, /* Monocases to self */ - 0x04F5, /* Monocases to self */ - 0x04F6, /* Monocases to self */ - 0x04F7, /* Monocases to self */ - 0x04F8, /* Monocases to self */ - 0x04F9, /* Monocases to self */ - 0x04FA, /* Monocases to self */ - 0x04FB, /* Monocases to self */ - 0x04FC, /* Monocases to self */ - 0x04FD, /* Monocases to self */ - 0x04FE, /* Monocases to self */ - 0x04FF, /* Monocases to self */ - 0x0500, /* Monocases to self */ - 0x0501, /* Monocases to self */ - 0x0502, /* Monocases to self */ - 0x0503, /* Monocases to self */ - 0x0504, /* Monocases to self */ - 0x0505, /* Monocases to self */ - 0x0506, /* Monocases to self */ - 0x0507, /* Monocases to self */ - 0x0508, /* Monocases to self */ - 0x0509, /* Monocases to self */ - 0x050A, /* Monocases to self */ - 0x050B, /* Monocases to self */ - 0x050C, /* Monocases to self */ - 0x050D, /* Monocases to self */ - 0x050E, /* Monocases to self */ - 0x050F, /* Monocases to self */ - 0x0510, /* Monocases to self */ - 0x0511, /* Monocases to self */ - 0x0512, /* Monocases to self */ - 0x0513, /* Monocases to self */ - 0x0514, /* Monocases to self */ - 0x0515, /* Monocases to self */ - 0x0516, /* Monocases to self */ - 0x0517, /* Monocases to self */ - 0x0518, /* Monocases to self */ - 0x0519, /* Monocases to self */ - 0x051A, /* Monocases to self */ - 0x051B, /* Monocases to self */ - 0x051C, /* Monocases to self */ - 0x051D, /* Monocases to self */ - 0x051E, /* Monocases to self */ - 0x051F, /* Monocases to self */ - 0x0520, /* Monocases to self */ - 0x0521, /* Monocases to self */ - 0x0522, /* Monocases to self */ - 0x0523, /* Monocases to self */ - 0x0524, /* Monocases to self */ - 0x0525, /* Monocases to self */ - 0x0526, /* Monocases to self */ - 0x0527, /* Monocases to self */ - 0x0528, /* Monocases to self */ - 0x0529, /* Monocases to self */ - 0x052A, /* Monocases to self */ - 0x052B, /* Monocases to self */ - 0x052C, /* Monocases to self */ - 0x052D, /* Monocases to self */ - 0x052E, /* Monocases to self */ - 0x052F, /* Monocases to self */ - 0x0530, /* Monocases to self */ - 0x0561, /* ARMENIAN LETTER AYB */ - 0x0562, /* ARMENIAN LETTER BEN */ - 0x0563, /* ARMENIAN LETTER GIM */ - 0x0564, /* ARMENIAN LETTER DA */ - 0x0565, /* ARMENIAN LETTER ECH */ - 0x0566, /* ARMENIAN LETTER ZA */ - 0x0567, /* ARMENIAN LETTER EH */ - 0x0568, /* ARMENIAN LETTER ET */ - 0x0569, /* ARMENIAN LETTER TO */ - 0x056A, /* ARMENIAN LETTER ZHE */ - 0x056B, /* ARMENIAN LETTER INI */ - 0x056C, /* ARMENIAN LETTER LIWN */ - 0x056D, /* ARMENIAN LETTER XEH */ - 0x056E, /* ARMENIAN LETTER CA */ - 0x056F, /* ARMENIAN LETTER KEN */ - 0x0570, /* ARMENIAN LETTER HO */ - 0x0571, /* ARMENIAN LETTER JA */ - 0x0572, /* ARMENIAN LETTER LAD */ - 0x0573, /* ARMENIAN LETTER CHEH */ - 0x0574, /* ARMENIAN LETTER MEN */ - 0x0575, /* ARMENIAN LETTER YI */ - 0x0576, /* ARMENIAN LETTER NOW */ - 0x0577, /* ARMENIAN LETTER SHA */ - 0x0578, /* ARMENIAN LETTER VO */ - 0x0579, /* ARMENIAN LETTER CHA */ - 0x057A, /* ARMENIAN LETTER PEH */ - 0x057B, /* ARMENIAN LETTER JHEH */ - 0x057C, /* ARMENIAN LETTER RA */ - 0x057D, /* ARMENIAN LETTER SEH */ - 0x057E, /* ARMENIAN LETTER VEW */ - 0x057F, /* ARMENIAN LETTER TIWN */ - 0x0580, /* ARMENIAN LETTER REH */ - 0x0581, /* ARMENIAN LETTER CO */ - 0x0582, /* ARMENIAN LETTER YIWN */ - 0x0583, /* ARMENIAN LETTER PIWR */ - 0x0584, /* ARMENIAN LETTER KEH */ - 0x0585, /* ARMENIAN LETTER OH */ - 0x0586, /* ARMENIAN LETTER FEH */ - 0x0557, /* Monocases to self */ - 0x0558, /* Monocases to self */ - 0x0559, /* Monocases to self */ - 0x055A, /* Monocases to self */ - 0x055B, /* Monocases to self */ - 0x055C, /* Monocases to self */ - 0x055D, /* Monocases to self */ - 0x055E, /* Monocases to self */ - 0x055F, /* Monocases to self */ - 0x0560, /* Monocases to self */ - 0x0561, /* Monocases to self */ - 0x0562, /* Monocases to self */ - 0x0563, /* Monocases to self */ - 0x0564, /* Monocases to self */ - 0x0565, /* Monocases to self */ - 0x0566, /* Monocases to self */ - 0x0567, /* Monocases to self */ - 0x0568, /* Monocases to self */ - 0x0569, /* Monocases to self */ - 0x056A, /* Monocases to self */ - 0x056B, /* Monocases to self */ - 0x056C, /* Monocases to self */ - 0x056D, /* Monocases to self */ - 0x056E, /* Monocases to self */ - 0x056F, /* Monocases to self */ - 0x0570, /* Monocases to self */ - 0x0571, /* Monocases to self */ - 0x0572, /* Monocases to self */ - 0x0573, /* Monocases to self */ - 0x0574, /* Monocases to self */ - 0x0575, /* Monocases to self */ - 0x0576, /* Monocases to self */ - 0x0577, /* Monocases to self */ - 0x0578, /* Monocases to self */ - 0x0579, /* Monocases to self */ - 0x057A, /* Monocases to self */ - 0x057B, /* Monocases to self */ - 0x057C, /* Monocases to self */ - 0x057D, /* Monocases to self */ - 0x057E, /* Monocases to self */ - 0x057F, /* Monocases to self */ - 0x0580, /* Monocases to self */ - 0x0581, /* Monocases to self */ - 0x0582, /* Monocases to self */ - 0x0583, /* Monocases to self */ - 0x0584, /* Monocases to self */ - 0x0585, /* Monocases to self */ - 0x0586, /* Monocases to self */ - 0x0587, /* Monocases to self */ - 0x0588, /* Monocases to self */ - 0x0589, /* Monocases to self */ - 0x058A, /* Monocases to self */ - 0x058B, /* Monocases to self */ - 0x058C, /* Monocases to self */ - 0x058D, /* Monocases to self */ - 0x058E, /* Monocases to self */ - 0x058F, /* Monocases to self */ - 0x0590, /* Monocases to self */ - 0x0591, /* Monocases to self */ - 0x0592, /* Monocases to self */ - 0x0593, /* Monocases to self */ - 0x0594, /* Monocases to self */ - 0x0595, /* Monocases to self */ - 0x0596, /* Monocases to self */ - 0x0597, /* Monocases to self */ - 0x0598, /* Monocases to self */ - 0x0599, /* Monocases to self */ - 0x059A, /* Monocases to self */ - 0x059B, /* Monocases to self */ - 0x059C, /* Monocases to self */ - 0x059D, /* Monocases to self */ - 0x059E, /* Monocases to self */ - 0x059F, /* Monocases to self */ - 0x05A0, /* Monocases to self */ - 0x05A1, /* Monocases to self */ - 0x05A2, /* Monocases to self */ - 0x05A3, /* Monocases to self */ - 0x05A4, /* Monocases to self */ - 0x05A5, /* Monocases to self */ - 0x05A6, /* Monocases to self */ - 0x05A7, /* Monocases to self */ - 0x05A8, /* Monocases to self */ - 0x05A9, /* Monocases to self */ - 0x05AA, /* Monocases to self */ - 0x05AB, /* Monocases to self */ - 0x05AC, /* Monocases to self */ - 0x05AD, /* Monocases to self */ - 0x05AE, /* Monocases to self */ - 0x05AF, /* Monocases to self */ - 0x05B0, /* Monocases to self */ - 0x05B1, /* Monocases to self */ - 0x05B2, /* Monocases to self */ - 0x05B3, /* Monocases to self */ - 0x05B4, /* Monocases to self */ - 0x05B5, /* Monocases to self */ - 0x05B6, /* Monocases to self */ - 0x05B7, /* Monocases to self */ - 0x05B8, /* Monocases to self */ - 0x05B9, /* Monocases to self */ - 0x05BA, /* Monocases to self */ - 0x05BB, /* Monocases to self */ - 0x05BC, /* Monocases to self */ - 0x05BD, /* Monocases to self */ - 0x05BE, /* Monocases to self */ - 0x05BF, /* Monocases to self */ - 0x05C0, /* Monocases to self */ - 0x05C1, /* Monocases to self */ - 0x05C2, /* Monocases to self */ - 0x05C3, /* Monocases to self */ - 0x05C4, /* Monocases to self */ - 0x05C5, /* Monocases to self */ - 0x05C6, /* Monocases to self */ - 0x05C7, /* Monocases to self */ - 0x05C8, /* Monocases to self */ - 0x05C9, /* Monocases to self */ - 0x05CA, /* Monocases to self */ - 0x05CB, /* Monocases to self */ - 0x05CC, /* Monocases to self */ - 0x05CD, /* Monocases to self */ - 0x05CE, /* Monocases to self */ - 0x05CF, /* Monocases to self */ - 0x05D0, /* Monocases to self */ - 0x05D1, /* Monocases to self */ - 0x05D2, /* Monocases to self */ - 0x05D3, /* Monocases to self */ - 0x05D4, /* Monocases to self */ - 0x05D5, /* Monocases to self */ - 0x05D6, /* Monocases to self */ - 0x05D7, /* Monocases to self */ - 0x05D8, /* Monocases to self */ - 0x05D9, /* Monocases to self */ - 0x05DA, /* Monocases to self */ - 0x05DB, /* Monocases to self */ - 0x05DC, /* Monocases to self */ - 0x05DD, /* Monocases to self */ - 0x05DE, /* Monocases to self */ - 0x05DF, /* Monocases to self */ - 0x05E0, /* Monocases to self */ - 0x05E1, /* Monocases to self */ - 0x05E2, /* Monocases to self */ - 0x05E3, /* Monocases to self */ - 0x05E4, /* Monocases to self */ - 0x05E5, /* Monocases to self */ - 0x05E6, /* Monocases to self */ - 0x05E7, /* Monocases to self */ - 0x05E8, /* Monocases to self */ - 0x05E9, /* Monocases to self */ - 0x05EA, /* Monocases to self */ - 0x05EB, /* Monocases to self */ - 0x05EC, /* Monocases to self */ - 0x05ED, /* Monocases to self */ - 0x05EE, /* Monocases to self */ - 0x05EF, /* Monocases to self */ - 0x05F0, /* Monocases to self */ - 0x05F1, /* Monocases to self */ - 0x05F2, /* Monocases to self */ - 0x05F3, /* Monocases to self */ - 0x05F4, /* Monocases to self */ - 0x05F5, /* Monocases to self */ - 0x05F6, /* Monocases to self */ - 0x05F7, /* Monocases to self */ - 0x05F8, /* Monocases to self */ - 0x05F9, /* Monocases to self */ - 0x05FA, /* Monocases to self */ - 0x05FB, /* Monocases to self */ - 0x05FC, /* Monocases to self */ - 0x05FD, /* Monocases to self */ - 0x05FE, /* Monocases to self */ - 0x05FF, /* Monocases to self */ - }; - - static const FLMUNICODE georgian[ 40] = - { - 0x10D0, /* GEORGIAN LETTER AN */ - 0x10D1, /* GEORGIAN LETTER BAN */ - 0x10D2, /* GEORGIAN LETTER GAN */ - 0x10D3, /* GEORGIAN LETTER DON */ - 0x10D4, /* GEORGIAN LETTER EN */ - 0x10D5, /* GEORGIAN LETTER VIN */ - 0x10D6, /* GEORGIAN LETTER ZEN */ - 0x10D7, /* GEORGIAN LETTER TAN */ - 0x10D8, /* GEORGIAN LETTER IN */ - 0x10D9, /* GEORGIAN LETTER KAN */ - 0x10DA, /* GEORGIAN LETTER LAS */ - 0x10DB, /* GEORGIAN LETTER MAN */ - 0x10DC, /* GEORGIAN LETTER NAR */ - 0x10DD, /* GEORGIAN LETTER ON */ - 0x10DE, /* GEORGIAN LETTER PAR */ - 0x10DF, /* GEORGIAN LETTER ZHAR */ - 0x10E0, /* GEORGIAN LETTER RAE */ - 0x10E1, /* GEORGIAN LETTER SAN */ - 0x10E2, /* GEORGIAN LETTER TAR */ - 0x10E3, /* GEORGIAN LETTER UN */ - 0x10E4, /* GEORGIAN LETTER PHAR */ - 0x10E5, /* GEORGIAN LETTER KHAR */ - 0x10E6, /* GEORGIAN LETTER GHAN */ - 0x10E7, /* GEORGIAN LETTER QAR */ - 0x10E8, /* GEORGIAN LETTER SHIN */ - 0x10E9, /* GEORGIAN LETTER CHIN */ - 0x10EA, /* GEORGIAN LETTER CAN */ - 0x10EB, /* GEORGIAN LETTER JIL */ - 0x10EC, /* GEORGIAN LETTER CIL */ - 0x10ED, /* GEORGIAN LETTER CHAR */ - 0x10EE, /* GEORGIAN LETTER XAN */ - 0x10EF, /* GEORGIAN LETTER JHAN */ - 0x10F0, /* GEORGIAN LETTER HAE */ - 0x10F1, /* GEORGIAN LETTER HE */ - 0x10F2, /* GEORGIAN LETTER HIE */ - 0x10F3, /* GEORGIAN LETTER WE */ - 0x10F4, /* GEORGIAN LETTER HAR */ - 0x10F5, /* GEORGIAN LETTER HOE */ - }; - - static const FLMUNICODE circledLatin[26] = - { - 0x24D0, /* CIRCLED LATIN LETTER A */ - 0x24D1, /* CIRCLED LATIN LETTER B */ - 0x24D2, /* CIRCLED LATIN LETTER C */ - 0x24D3, /* CIRCLED LATIN LETTER D */ - 0x24D4, /* CIRCLED LATIN LETTER E */ - 0x24D5, /* CIRCLED LATIN LETTER F */ - 0x24D6, /* CIRCLED LATIN LETTER G */ - 0x24D7, /* CIRCLED LATIN LETTER H */ - 0x24D8, /* CIRCLED LATIN LETTER I */ - 0x24D9, /* CIRCLED LATIN LETTER J */ - 0x24DA, /* CIRCLED LATIN LETTER K */ - 0x24DB, /* CIRCLED LATIN LETTER L */ - 0x24DC, /* CIRCLED LATIN LETTER M */ - 0x24DD, /* CIRCLED LATIN LETTER N */ - 0x24DE, /* CIRCLED LATIN LETTER O */ - 0x24DF, /* CIRCLED LATIN LETTER P */ - 0x24E0, /* CIRCLED LATIN LETTER Q */ - 0x24E1, /* CIRCLED LATIN LETTER R */ - 0x24E2, /* CIRCLED LATIN LETTER S */ - 0x24E3, /* CIRCLED LATIN LETTER T */ - 0x24E4, /* CIRCLED LATIN LETTER U */ - 0x24E5, /* CIRCLED LATIN LETTER V */ - 0x24E6, /* CIRCLED LATIN LETTER W */ - 0x24E7, /* CIRCLED LATIN LETTER X */ - 0x24E8, /* CIRCLED LATIN LETTER Y */ - 0x24E9, /* CIRCLED LATIN LETTER Z */ - }; - - static const FLMUNICODE compat[] = - { - 0x2025, - 0x2014, - 0x2013, - 0x005F, - 0x005F, - 0x0028, - 0x0029, - 0x007B, - 0x007D, - 0x3014, - 0x3015, - 0x3010, - 0x3011, - 0x300A, - 0x300B, - 0x3008, - 0x3009, - 0x300C, - 0x300D, - 0x300E, - 0x300F, - 0xFE45, - 0xFE46, - 0xFE47, - 0xFE48, - 0x203E, - 0x203E, - 0x203E, - 0x203E, - 0x005F, - 0x005F, - 0x005F, - 0x002C, - 0x3001, - 0x002E, - 0xFE53, - 0x003B, - 0x003A, - 0x003F, - 0x0021, - 0x2014, - 0x0028, - 0x0029, - 0x007B, - 0x007D, - 0x3014, - 0x3015, - 0x0023, - 0x0026, - 0x002A, - 0x002B, - 0x002D, - 0x003C, - 0x003E, - 0x003D, - 0xFE67, - 0x005C, - 0x0024, - 0x0025, - 0x0040, - 0xFE6C, - 0xFE6D, - 0xFE6E, - 0xFE6F, - 0x064B, - 0x064B, - 0x064C, - 0xFE73, - 0x064D, - 0xFE75, - 0x064E, - 0x064E, - 0x064F, - 0x064F, - 0x0650, - 0x0650, - 0x0651, - 0x0651, - 0x0652, - 0x0652, - 0x0621, - 0x0622, - 0x0622, - 0x0623, - 0x0623, - 0x0624, - 0x0624, - 0x0625, - 0x0625, - 0x0626, - 0x0626, - 0x0626, - 0x0626, - 0x0627, - 0x0627, - 0x0628, - 0x0628, - 0x0628, - 0x0628, - 0x0629, - 0x0629, - 0x062A, - 0x062A, - 0x062A, - 0x062A, - 0x062B, - 0x062B, - 0x062B, - 0x062B, - 0x062C, - 0x062C, - 0x062C, - 0x062C, - 0x062D, - 0x062D, - 0x062D, - 0x062D, - 0x062E, - 0x062E, - 0x062E, - 0x062E, - 0x062F, - 0x062F, - 0x0630, - 0x0630, - 0x0631, - 0x0631, - 0x0632, - 0x0632, - 0x0633, - 0x0633, - 0x0633, - 0x0633, - 0x0634, - 0x0634, - 0x0634, - 0x0634, - 0x0635, - 0x0635, - 0x0635, - 0x0635, - 0x0636, - 0x0636, - 0x0636, - 0x0636, - 0x0637, - 0x0637, - 0x0637, - 0x0637, - 0x0638, - 0x0638, - 0x0638, - 0x0638, - 0x0639, - 0x0639, - 0x0639, - 0x0639, - 0x063A, - 0x063A, - 0x063A, - 0x063A, - 0x0641, - 0x0641, - 0x0641, - 0x0641, - 0x0642, - 0x0642, - 0x0642, - 0x0642, - 0x0643, - 0x0643, - 0x0643, - 0x0643, - 0x0644, - 0x0644, - 0x0644, - 0x0644, - 0x0645, - 0x0645, - 0x0645, - 0x0645, - 0x0646, - 0x0646, - 0x0646, - 0x0646, - 0x0647, - 0x0647, - 0x0647, - 0x0647, - 0x0648, - 0x0648, - 0x0649, - 0x0649, - 0x064A, - 0x064A, - 0x064A, - 0x064A, - 0xFEF5, - 0xFEF6, - 0xFEF7, - 0xFEF8, - 0xFEF9, - 0xFEFA, - 0xFEFB, - 0xFEFC, - 0xFEFD, - 0xFEFE, - 0xFEFE, - 0xFE00, - 0x0021, - 0x0022, - 0x0023, - 0x0024, - 0x0025, - 0x0026, - 0x0027, - 0x0028, - 0x0029, - 0x002A, - 0x002B, - 0x002C, - 0x002D, - 0x002E, - 0x002F, - 0x0030, - 0x0031, - 0x0032, - 0x0033, - 0x0034, - 0x0035, - 0x0036, - 0x0037, - 0x0038, - 0x0039, - 0x003A, - 0x003B, - 0x003C, - 0x003D, - 0x003E, - 0x003F, - 0x0040, - 0x0061, - 0x0062, - 0x0063, - 0x0064, - 0x0065, - 0x0066, - 0x0067, - 0x0068, - 0x0069, - 0x006A, - 0x006B, - 0x006C, - 0x006D, - 0x006E, - 0x006F, - 0x0070, - 0x0071, - 0x0072, - 0x0073, - 0x0074, - 0x0075, - 0x0076, - 0x0077, - 0x0078, - 0x0079, - 0x007A, - 0x005B, - 0x005C, - 0x005D, - 0x005E, - 0x005F, - 0x0060, - 0x0061, - 0x0062, - 0x0063, - 0x0064, - 0x0065, - 0x0066, - 0x0067, - 0x0068, - 0x0069, - 0x006A, - 0x006B, - 0x006C, - 0x006D, - 0x006E, - 0x006F, - 0x0070, - 0x0071, - 0x0072, - 0x0073, - 0x0074, - 0x0075, - 0x0076, - 0x0077, - 0x0078, - 0x0079, - 0x007A, - 0x007B, - 0x007C, - 0x007D, - 0x007E, - 0xFF5F, - 0xFF60, - 0x3002, - 0x300C, - 0x300D, - 0x3001, - 0x30FB, - 0x30F2, - 0x30A1, - 0x30A3, - 0x30A5, - 0x30A7, - 0x30A9, - 0x30E3, - 0x30E5, - 0x30E7, - 0x30C3, - 0x30FC, - 0x30A2, - 0x30A4, - 0x30A6, - 0x30A8, - 0x30AA, - 0x30AB, - 0x30AD, - 0x30AF, - 0x30B1, - 0x30B3, - 0x30B5, - 0x30B7, - 0x30B9, - 0x30BB, - 0x30BD, - 0x30BF, - 0x30C1, - 0x30C4, - 0x30C6, - 0x30C8, - 0x30CA, - 0x30CB, - 0x30CC, - 0x30CD, - 0x30CE, - 0x30CF, - 0x30D2, - 0x30D5, - 0x30D8, - 0x30DB, - 0x30DE, - 0x30DF, - 0x30E0, - 0x30E1, - 0x30E2, - 0x30E4, - 0x30E6, - 0x30E8, - 0x30E9, - 0x30EA, - 0x30EB, - 0x30EC, - 0x30ED, - 0x30EF, - 0x30F3, - 0x309B, - 0x309C, - 0x3164, - 0x3131, - 0x3132, - 0x3133, - 0x3134, - 0x3135, - 0x3136, - 0x3137, - 0x3138, - 0x3139, - 0x313A, - 0x313B, - 0x313C, - 0x313D, - 0x313E, - 0x313F, - 0x3140, - 0x3141, - 0x3142, - 0x3143, - 0x3144, - 0x3145, - 0x3146, - 0x3147, - 0x3148, - 0x3149, - 0x314A, - 0x314B, - 0x314C, - 0x314D, - 0x314E, - 0xFFBF, - 0xFFC0, - 0xFFC1, - 0x314F, - 0x3150, - 0x3151, - 0x3152, - 0x3153, - 0x3154, - 0xFFC8, - 0xFFC9, - 0x3155, - 0x3156, - 0x3157, - 0x3158, - 0x3159, - 0x315A, - 0xFFD0, - 0xFFD1, - 0x315B, - 0x315C, - 0x315D, - 0x315E, - 0x315F, - 0x3160, - 0xFFD8, - 0xFFD9, - 0x3161, - 0x3162, - 0x3163, - 0xFFDD, - 0xFFDE, - 0xFFDF, - 0x00A2, - 0x00A3, - 0x00AC, - 0x00AF, - 0x00A6, - 0x00A5, - 0x20A9 - }; - - if( uChar < 0x600) - { - uChar = basicAlpha[ uChar]; - } - else if( uChar < 0x10A0) - { - ; - } - else if( uChar >= 0x10A0 && uChar <= 0x10C5) - { - uChar = georgian[ uChar - 0x10A0]; - } - else if( uChar >= 0x24B6 && uChar <= 0x24CF) - { - uChar = circledLatin[ uChar - 0x24B6]; - } - else if( uChar >= 0xFE30 && uChar <= 0xFFE6) - { - uChar = compat[ uChar - 0xFE30]; - } - - return( uChar); -} - -/**************************************************************************** -Desc: Compares two Unicode strings -****************************************************************************/ -FLMINT f_unicmp( - const FLMUNICODE * puzStr1, - const FLMUNICODE * puzStr2) -{ - while( *puzStr1 == *puzStr2 && *puzStr1) - { - puzStr1++; - puzStr2++; - } - - return( (FLMINT)*puzStr1 - (FLMINT)*puzStr2); -} - -/**************************************************************************** -Desc: Performs a case-insensitive comparision of two Unicode strings -****************************************************************************/ -FLMINT f_uniicmp( - const FLMUNICODE * puzStr1, - const FLMUNICODE * puzStr2) -{ - while( f_unitolower( *puzStr1) == f_unitolower( *puzStr2) && *puzStr1) - { - puzStr1++; - puzStr2++; - } - - return( (FLMINT)f_unitolower( *puzStr1) - (FLMINT)f_unitolower( *puzStr2)); -} - -/**************************************************************************** -Desc: Compares two strings, one Unicode and one native -****************************************************************************/ -FLMINT f_uninativecmp( - const FLMUNICODE * puzStr1, - const char * pszStr2) -{ - while( *puzStr1 == ((FLMUNICODE)f_toascii( *pszStr2)) && *puzStr1) - { - puzStr1++; - pszStr2++; - } - - return( (FLMINT)*puzStr1 - (FLMINT)*pszStr2); -} - -/**************************************************************************** -Desc: Compares two strings, one Unicode and one native -****************************************************************************/ -FLMINT f_uninativencmp( - const FLMUNICODE * puzStr1, - const char * pszStr2, - FLMUINT uiCount) -{ - if( !uiCount) - { - return( 0); - } - - while( uiCount && - *puzStr1 == ((FLMUNICODE)f_toascii( *pszStr2)) && *puzStr1) - { - puzStr1++; - pszStr2++; - uiCount--; - } - - return( uiCount ? ((FLMINT)*puzStr1 - (FLMINT)*pszStr2) : 0); -} - -/*************************************************************************** -Desc: Sort an array of items -****************************************************************************/ -void f_qsort( - void * pvBuffer, - FLMUINT uiLowerBounds, - FLMUINT uiUpperBounds, - F_SORT_COMPARE_FUNC fnCompare, - F_SORT_SWAP_FUNC fnSwap) -{ - FLMUINT uiLBPos; - FLMUINT uiUBPos; - FLMUINT uiMIDPos; - FLMUINT uiCurrentPos; - FLMUINT uiLeftItems; - FLMUINT uiRightItems; - FLMINT iCompare; - -Iterate_Larger_Half: - - uiUBPos = uiUpperBounds; - uiLBPos = uiLowerBounds; - uiMIDPos = (uiUpperBounds + uiLowerBounds + 1) / 2; - uiCurrentPos = uiMIDPos; - - for (;;) - { - while (uiLBPos == uiMIDPos || - ((iCompare = - fnCompare( pvBuffer, uiLBPos, uiCurrentPos)) < 0)) - { - if( uiLBPos >= uiUpperBounds) - { - break; - } - uiLBPos++; - } - - while( uiUBPos == uiMIDPos || - (((iCompare = - fnCompare( pvBuffer, uiCurrentPos, uiUBPos)) < 0))) - { - if (!uiUBPos) - { - break; - } - uiUBPos--; - } - - if( uiLBPos < uiUBPos) - { - // Exchange [uiLBPos] with [uiUBPos]. - - fnSwap( pvBuffer, uiLBPos, uiUBPos); - uiLBPos++; - uiUBPos--; - } - else - { - break; - } - } - - // Check for swap( LB, MID ) - cases 3 and 4 - - if( uiLBPos < uiMIDPos ) - { - - // Exchange [uiLBPos] with [uiMIDPos] - - fnSwap( pvBuffer, uiMIDPos, uiLBPos); - uiMIDPos = uiLBPos; - } - else if( uiMIDPos < uiUBPos ) - { - // Exchange [uUBPos] with [uiMIDPos] - - fnSwap( pvBuffer, uiMIDPos, uiUBPos); - uiMIDPos = uiUBPos; - } - - // Check the left piece. - - uiLeftItems = (uiLowerBounds + 1 < uiMIDPos) - ? uiMIDPos - uiLowerBounds - : 0; - - uiRightItems = (uiMIDPos + 1 < uiUpperBounds) - ? uiUpperBounds - uiMIDPos - : 0; - - if( uiLeftItems < uiRightItems) - { - // Recurse on the LEFT side and goto the top on the RIGHT side. - - if( uiLeftItems) - { - f_qsort( pvBuffer, uiLowerBounds, uiMIDPos - 1, fnCompare, fnSwap); - } - - uiLowerBounds = uiMIDPos + 1; - goto Iterate_Larger_Half; - } - else if( uiLeftItems) - { - // Recurse on the RIGHT side and goto the top for the LEFT side. - - if (uiRightItems ) - { - f_qsort( pvBuffer, uiMIDPos + 1, uiUpperBounds, fnCompare, fnSwap); - } - - uiUpperBounds = uiMIDPos - 1; - goto Iterate_Larger_Half; - } -} - -/*************************************************************************** -Desc: -****************************************************************************/ -FLMINT flmQSortUINTCompare( - void * pvBuffer, - FLMUINT uiPos1, - FLMUINT uiPos2) -{ - FLMUINT uiLeft = *(((FLMUINT *)pvBuffer) + uiPos1); - FLMUINT uiRight = *(((FLMUINT *)pvBuffer) + uiPos2); - - if( uiLeft < uiRight) - { - return( -1); - } - else if( uiLeft > uiRight) - { - return( 1); - } - - return( 0); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -void flmQSortUINTSwap( - void * pvBuffer, - FLMUINT uiPos1, - FLMUINT uiPos2) -{ - FLMUINT * puiArray = (FLMUINT *)pvBuffer; - FLMUINT uiTmp = puiArray[ uiPos1]; - - puiArray[ uiPos1] = puiArray[ uiPos2]; - puiArray[ uiPos2] = uiTmp; -} - -/*************************************************************************** -Desc: -****************************************************************************/ -FLMBOOL XFLMAPI F_DbSystem::uniIsUpper( - FLMUNICODE uzChar) -{ - FLMBOOL bRV; - - // Which nibble do we need to look at? - if (uzChar & 0x1) - { - // Low nibble - bRV = (UnicodeProperties[uzChar/2] & UNICODE_UPPERCASE_MASK) ? TRUE : FALSE; - } - else - { - // High nibble - bRV = ((UnicodeProperties[uzChar/2] >> 4) & UNICODE_UPPERCASE_MASK) ? TRUE : FALSE; - } - return bRV; -} - -/*************************************************************************** -Desc: -****************************************************************************/ -FLMBOOL XFLMAPI F_DbSystem::uniIsLower( - FLMUNICODE uzChar) -{ - FLMBOOL bRV; - - // Which nibble do we need to look at? - if (uzChar & 0x1) - { - // Low nibble - bRV = (UnicodeProperties[uzChar/2] & UNICODE_LOWERCASE_MASK) ? TRUE : FALSE; - } - else - { - // High nibble - bRV = ((UnicodeProperties[uzChar/2] >> 4) & UNICODE_LOWERCASE_MASK) ? TRUE : FALSE; - } - return bRV; -} - -/*************************************************************************** -Desc: -****************************************************************************/ -FLMBOOL XFLMAPI F_DbSystem::uniIsAlpha( - FLMUNICODE uzChar) -{ - FLMBOOL bRV; - - // Which nibble do we need to look at? - if (uzChar & 0x1) - { - // Low nibble - bRV = (UnicodeProperties[uzChar/2] & UNICODE_ALPHABETIC_MASK) ? TRUE : FALSE; - } - else - { - // High nibble - bRV = ((UnicodeProperties[uzChar/2] >> 4) & UNICODE_ALPHABETIC_MASK) ? TRUE : FALSE; - } - return bRV; -} - -/*************************************************************************** -Desc: -****************************************************************************/ -FLMBOOL XFLMAPI F_DbSystem::uniIsDecimalDigit( - FLMUNICODE uzChar) -{ - FLMBOOL bRV; - - // Which nibble do we need to look at? - if (uzChar & 0x1) - { - // Low nibble - bRV = (UnicodeProperties[uzChar/2] & UNICODE_DECIMAL_DIGIT_MASK) ? TRUE : FALSE; - } - else - { - // High nibble - bRV = ((UnicodeProperties[uzChar/2] >> 4) & UNICODE_DECIMAL_DIGIT_MASK) ? TRUE : FALSE; - } - return bRV; -} - -/*************************************************************************** -Desc: -****************************************************************************/ -FLMUNICODE XFLMAPI F_DbSystem::uniToLower( - FLMUNICODE uzChar) -{ - return f_unitolower( uzChar); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE XFLMAPI F_DbSystem::nextUCS2Char( - const FLMBYTE ** ppszUTF8, - const FLMBYTE * pszEndOfUTF8String, - FLMUNICODE * puzChar) -{ - return flmGetCharFromUTF8Buf( ppszUTF8, pszEndOfUTF8String, puzChar); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE XFLMAPI F_DbSystem::numUCS2Chars( - const FLMBYTE * pszUTF8, - FLMUINT * puiNumChars) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiTemp = 0; - FLMUNICODE uzChar; - - for (;;) - { - if (RC_BAD( rc = flmGetCharFromUTF8Buf( &pszUTF8, NULL, &uzChar))) - { - goto Exit; - } - if (!uzChar) - { - break; - } - uiTemp++; - } - -Exit: - - *puiNumChars = uiTemp; - return rc; -} diff --git a/xflaim/src/flverify.cpp b/xflaim/src/flverify.cpp index ed6171c..a7cd317 100644 --- a/xflaim/src/flverify.cpp +++ b/xflaim/src/flverify.cpp @@ -1199,12 +1199,11 @@ RCODE F_DbCheck::verifyBTrees( if (RC_BAD( rc = dbSystem.getTempDir( szTmpIoPath))) { - if (rc == NE_XFLM_IO_PATH_NOT_FOUND || - rc == NE_XFLM_IO_INVALID_FILENAME) + if (rc == NE_FLM_IO_PATH_NOT_FOUND || + rc == NE_FLM_IO_INVALID_FILENAME) { - if (RC_BAD( rc = gv_pFileSystem->pathReduce( m_pDb->m_pDatabase->m_pszDbPath, - szTmpIoPath, - szBaseName))) + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathReduce( + m_pDb->m_pDatabase->m_pszDbPath, szTmpIoPath, szBaseName))) { goto Exit; } @@ -4084,7 +4083,7 @@ FSTATIC FLMBYTE * getEntryEnd( Desc: Compare two cache blocks during a sort to determine which one has lower address. *****************************************************************************/ -FINLINE FLMINT blkSortCompare( +FINLINE FLMINT FLMAPI blkSortCompare( void * pvBuffer, FLMUINT uiPos1, FLMUINT uiPos2) @@ -4109,7 +4108,7 @@ FINLINE FLMINT blkSortCompare( /*************************************************************************** Desc: Swap two entries in cache table during sort. *****************************************************************************/ -FINLINE void blkSortSwap( +FINLINE void FLMAPI blkSortSwap( void * pvBuffer, FLMUINT uiPos1, FLMUINT uiPos2) @@ -4408,12 +4407,12 @@ RCODE F_NodeVerifier::finalize( FLMBOOL bSkipDOMLinkCheck, FLMINT * piElmErrCodeRV) { - RCODE rc = NE_XFLM_OK; - NODE_RS_ENTRY * pRSEntry = NULL; - FLMUINT uiRSBufIndex; - FLMUINT uiStorageFlags; - F_NameTable * pNameTable = pDict->getNameTable(); - F_BufferIStream bufferStream; + RCODE rc = NE_XFLM_OK; + NODE_RS_ENTRY * pRSEntry = NULL; + FLMUINT uiRSBufIndex; + FLMUINT uiStorageFlags; + F_NameTable * pNameTable = pDict->getNameTable(); + IF_BufferIStream * pBufferStream = NULL; *piElmErrCodeRV = 0; @@ -4425,13 +4424,19 @@ RCODE F_NodeVerifier::finalize( f_memset( &m_nodeInfo, 0, sizeof( F_NODE_INFO)); - if( RC_BAD( rc = bufferStream.open( m_pucBuf, m_uiBytesInBuf))) + if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferStream))) + { + goto Exit; + } + + if( RC_BAD( rc = pBufferStream->open( + (const char *)m_pucBuf, m_uiBytesInBuf))) { goto Exit; } if( RC_BAD( rc = flmReadNodeInfo( uiCollection, ui64NodeId, - &bufferStream, m_uiOverallLength, FALSE, &m_nodeInfo, &uiStorageFlags))) + pBufferStream, m_uiOverallLength, FALSE, &m_nodeInfo, &uiStorageFlags))) { goto Exit; } @@ -4564,6 +4569,11 @@ RCODE F_NodeVerifier::finalize( Exit: + if( pBufferStream) + { + pBufferStream->Release(); + } + if( pRSEntry) { f_free( &pRSEntry); diff --git a/xflaim/src/fntable.cpp b/xflaim/src/fntable.cpp index a3b0cae..d631c28 100644 --- a/xflaim/src/fntable.cpp +++ b/xflaim/src/fntable.cpp @@ -149,7 +149,7 @@ Desc: Constructor ****************************************************************************/ F_NameTable::F_NameTable() { - m_pool.poolInit( 1024); + m_pPool = NULL; m_uiMemoryAllocated = 0; m_ppSortedByTagTypeAndName = NULL; m_ppSortedByTagTypeAndNum = NULL; @@ -176,6 +176,11 @@ Desc: Destructor F_NameTable::~F_NameTable() { clearTable( 0); + + if( m_pPool) + { + m_pPool->Release(); + } } /**************************************************************************** @@ -184,20 +189,36 @@ Desc: Setup name table. This routine should be called immediately after ****************************************************************************/ RCODE F_NameTable::setupNameTable( void) { - return( NE_XFLM_OK); + RCODE rc = NE_XFLM_OK; + + if( RC_BAD( rc = FlmAllocPool( &m_pPool))) + { + goto Exit; + } + + m_pPool->poolInit( 1024); + +Exit: + + return( rc); } /**************************************************************************** Desc: Free everything in the table ****************************************************************************/ void F_NameTable::clearTable( - FLMUINT uiPoolBlkSize) + FLMUINT uiPoolBlkSize) { - m_pool.poolFree(); + if( m_pPool) + { + m_pPool->poolFree(); + } + if (uiPoolBlkSize) { - m_pool.poolInit( uiPoolBlkSize); + m_pPool->poolInit( uiPoolBlkSize); } + m_uiMemoryAllocated = 0; // NOTE: Only one allocation is used for m_ppSortedByTagTypeAndName and @@ -280,8 +301,8 @@ FSTATIC FLMINT tagNameCompare( else if (uzChar1 != uzChar2) { Test_Case: - uzLowerChar1 = f_unitolower( uzChar1); - uzLowerChar2 = f_unitolower( uzChar2); + uzLowerChar1 = f_uniToLower( uzChar1); + uzLowerChar2 = f_uniToLower( uzChar2); if (uzLowerChar1 < uzLowerChar2) { @@ -1101,9 +1122,9 @@ RCODE F_NameTable::allocTag( // Create a new tag info structure. - pvMark = m_pool.poolMark(); + pvMark = m_pPool->poolMark(); uiSaveMemoryAllocated = m_uiMemoryAllocated; - if (RC_BAD( rc = m_pool.poolCalloc( sizeof( FLM_TAG_INFO), + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( FLM_TAG_INFO), (void **)&pTagInfo))) { goto Exit; @@ -1115,7 +1136,7 @@ RCODE F_NameTable::allocTag( if (puzTagName) { uiNameSize = (f_unilen( puzTagName) + 1) * sizeof( FLMUNICODE); - if (RC_BAD( rc = m_pool.poolAlloc( uiNameSize, + if (RC_BAD( rc = m_pPool->poolAlloc( uiNameSize, (void **)&pTagInfo->puzTagName))) { goto Exit; @@ -1126,7 +1147,7 @@ RCODE F_NameTable::allocTag( else { uiNameSize = (f_strlen( pszTagName) + 1) * sizeof( FLMUNICODE); - if (RC_BAD( rc = m_pool.poolAlloc( uiNameSize, + if (RC_BAD( rc = m_pPool->poolAlloc( uiNameSize, (void **)&pTagInfo->puzTagName))) { goto Exit; @@ -1160,7 +1181,7 @@ RCODE F_NameTable::allocTag( &uiNamespaceInsertPos)) == NULL) { uiNameSize = (f_unilen( puzNamespace) + 1) * sizeof( FLMUNICODE); - if (RC_BAD( rc = m_pool.poolAlloc( uiNameSize, + if (RC_BAD( rc = m_pPool->poolAlloc( uiNameSize, (void **)&puzTblNamespace))) { goto Exit; @@ -1178,7 +1199,7 @@ RCODE F_NameTable::allocTag( // allocated if the pool is reset at Exit due to a later // error. - pvMark = m_pool.poolMark(); + pvMark = m_pPool->poolMark(); uiSaveMemoryAllocated = m_uiMemoryAllocated; } pTagInfo->puzNamespace = puzTblNamespace; @@ -1189,7 +1210,7 @@ Exit: if (RC_BAD( rc)) { - m_pool.poolReset( pvMark); + m_pPool->poolReset( pvMark); m_uiMemoryAllocated = uiSaveMemoryAllocated; pTagInfo = NULL; } @@ -2391,19 +2412,19 @@ Exit: /**************************************************************************** Desc: Increment use count on this object. ****************************************************************************/ -FLMINT XFLMAPI F_NameTable::AddRef( void) +FLMINT FLMAPI F_NameTable::AddRef( void) { - return( flmAtomicInc( &m_refCnt)); + return( f_atomicInc( &m_refCnt)); } /**************************************************************************** Desc: Decrement the use count and delete if use count goes to zero. ****************************************************************************/ -FLMINT XFLMAPI F_NameTable::Release( void) +FLMINT FLMAPI F_NameTable::Release( void) { FLMINT iRefCnt; - if ((iRefCnt = flmAtomicDec( &m_refCnt)) == 0) + if ((iRefCnt = f_atomicDec( &m_refCnt)) == 0) { delete this; } @@ -2469,7 +2490,7 @@ Exit: /**************************************************************************** Desc: Get the name for a dictionary item. ****************************************************************************/ -RCODE XFLMAPI F_Db::getDictionaryName( +RCODE FLMAPI F_Db::getDictionaryName( FLMUINT uiDictType, FLMUINT uiDictNumber, char * pszName, @@ -2520,7 +2541,7 @@ Exit: /**************************************************************************** Desc: Get the name for a dictionary item. ****************************************************************************/ -RCODE XFLMAPI F_Db::getDictionaryName( +RCODE FLMAPI F_Db::getDictionaryName( FLMUINT uiDictType, FLMUINT uiDictNumber, FLMUNICODE * puzName, diff --git a/xflaim/src/fposix.cpp b/xflaim/src/fposix.cpp deleted file mode 100644 index 9e6989d..0000000 --- a/xflaim/src/fposix.cpp +++ /dev/null @@ -1,1654 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Contains the methods for the F_FileHdl class for UNIX. -// -// Tabs: 3 -// -// Copyright (c) 1999-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: fposix.cpp 3123 2006-01-24 17:19:50 -0700 (Tue, 24 Jan 2006) ahodgkinson $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -#if defined( FLM_UNIX) - -#ifdef FLM_AIX - #ifndef _LARGE_FILES - #define _LARGE_FILES - #endif - #include -#endif - -#include -#ifndef FLM_OSX - #include -#endif - -#include - -#if defined( FLM_SOLARIS) - #include -#elif defined( FLM_LINUX) - #include -#elif defined( FLM_OSF) - - // Tru64 4.0 does not have this declaration. Tru64 5.0 renames statfs - // in vague ways, so we put these declarations before including - // - - // DSS NOTE: statfs declaration below conflicts with one found in - // sys/mount.h header file, so I commented it out. This was when I - // compiled using the GNU compiler. - - struct statfs; - #include -#endif - -pthread_mutex_t gv_atomicMutex = PTHREAD_MUTEX_INITIALIZER; - -/****************************************************************************** -Desc: -*******************************************************************************/ -F_FileHdl::F_FileHdl() -{ - m_pNext = NULL; - m_pPrev = NULL; - m_bInList = FALSE; - m_uiAvailTime = 0; - m_bFileOpened = FALSE; - m_bDeleteOnRelease = FALSE; - m_bOpenedReadOnly = FALSE; - m_pszFileName = NULL; - - m_fd = -1; - m_bDoDirectIO = FALSE; - m_uiExtendSize = 0; - m_uiMaxAutoExtendSize = gv_XFlmSysData.uiMaxFileSize; - m_uiBytesPerSector = 0; - m_ui64NotOnSectorBoundMask = 0; - m_ui64GetSectorBoundMask = 0; - m_uiExtendSize = 0; - m_ui64CurrentPos = 0; - m_bDoDirectIO = FALSE; - m_bCanDoAsync = FALSE; - m_pucAlignedBuff = NULL; - m_uiAlignedBuffSize = 0; -} - -/****************************************************************************** -Desc: -******************************************************************************/ -F_FileHdl::~F_FileHdl() -{ - if( m_bFileOpened) - { - (void)Close(); - } - - if( m_pucAlignedBuff) - { - free( m_pucAlignedBuff); - } - - if (m_pszFileName) - { - f_free( &m_pszFileName); - } -} - -/*************************************************************************** -Desc: Open or create a file. -***************************************************************************/ -RCODE F_FileHdl::OpenOrCreate( - const char * pszFileName, - FLMUINT uiAccess, - FLMBOOL bCreateFlag) -{ - RCODE rc = NE_XFLM_OK; - FLMBOOL bDoDirectIO = FALSE; - char szSaveFileName[ F_PATH_MAX_SIZE]; - int openFlags = O_RDONLY; - -#if !defined( FLM_UNIX) || defined( FLM_LINUX) || defined( FLM_SOLARIS) - bDoDirectIO = (uiAccess & XFLM_IO_DIRECT) ? TRUE : FALSE; -#endif - -// HPUX needs this defined to access files larger than 2 GB. The Linux -// man pages *say* it's needed although as of Suse 9.1 it actually -// isn't. Including this flag on Linux anyway just it case... -#if defined( FLM_HPUX) || defined( FLM_LINUX) - openFlags |= O_LARGEFILE; -#endif - - // Save the file name in case we have to create the directory - - if( bCreateFlag && (uiAccess & XFLM_IO_CREATE_DIR)) - { - f_strcpy( &szSaveFileName, pszFileName); - } - - if( bCreateFlag) - { - openFlags |= O_CREAT; - if( uiAccess & XFLM_IO_EXCL) - { - openFlags |= O_EXCL; - } - else - { - openFlags |= O_TRUNC; - } - } - - if( !(uiAccess & XFLM_IO_RDONLY)) - { - openFlags |= O_RDWR; - } - - if( !(uiAccess & XFLM_IO_RDONLY)) - { - openFlags |= O_RDWR; - } - - // If doing direct IO, need to get the sector size. - - if( bDoDirectIO) - { - if( !m_uiBlockSize) - { - bDoDirectIO = FALSE; - } - else - { - if( RC_BAD( rc = gv_pFileSystem->GetSectorSize( - pszFileName, &m_uiBytesPerSector))) - { - goto Exit; - } - - m_ui64NotOnSectorBoundMask = m_uiBytesPerSector - 1; - m_ui64GetSectorBoundMask = ~m_ui64NotOnSectorBoundMask; - - // Can't do direct IO if the block size isn't a multiple of - // the sector size. - - if( m_uiBlockSize < m_uiBytesPerSector || - m_uiBlockSize % m_uiBytesPerSector != 0) - { - bDoDirectIO = FALSE; - } - else - { -#if defined( FLM_LINUX) - FLMUINT uiMajor = gv_XFlmSysData.uiLinuxMajorVer; - FLMUINT uiMinor = gv_XFlmSysData.uiLinuxMinorVer; - FLMUINT uiRevision = gv_XFlmSysData.uiLinuxRevision; - - if( uiMajor > 2 || (uiMajor == 2 && uiMinor > 6) || - (uiMajor == 2 && uiMinor == 6 && uiRevision >= 5)) - { - openFlags |= O_DIRECT; - - if( gv_XFlmSysData.bOkToDoAsyncWrites) - { - m_bCanDoAsync = TRUE; - } - } - else - { - bDoDirectIO = FALSE; - } -#elif defined( FLM_SOLARIS) - if( gv_XFlmSysData.bOkToDoAsyncWrites) - { - m_bCanDoAsync = TRUE; - } -#endif - } - } - } - -Retry_Create: - - // Try to create or open the file - - if ((m_fd = open( pszFileName, openFlags, 0600)) == -1) - { - if ((errno == ENOENT) && (uiAccess & XFLM_IO_CREATE_DIR)) - { - char szTemp[ F_PATH_MAX_SIZE]; - char szIoDirPath[ F_PATH_MAX_SIZE]; - - uiAccess &= ~XFLM_IO_CREATE_DIR; - - // Remove the file name for which we are creating the directory - - if( RC_OK( gv_pFileSystem->pathReduce( szSaveFileName, - szIoDirPath, szTemp))) - { - if( RC_OK( rc = gv_pFileSystem->CreateDir( szIoDirPath))) - { - goto Retry_Create; - } - else - { - goto Exit; - } - } - } -#ifdef FLM_LINUX - else if( errno == EINVAL && bDoDirectIO) - { - openFlags &= ~O_DIRECT; - bDoDirectIO = FALSE; - m_bCanDoAsync = FALSE; - goto Retry_Create; - } -#endif - - rc = MapErrnoToFlaimErr( errno, NE_XFLM_OPENING_FILE); - goto Exit; - } - -#if defined( FLM_SOLARIS) - if( bDoDirectIO) - { - directio( m_fd, DIRECTIO_ON); - } -#endif - - m_bDoDirectIO = bDoDirectIO; - -Exit: - - if( RC_BAD( rc)) - { - m_fd = -1; - m_bDoDirectIO = FALSE; - m_bCanDoAsync = FALSE; - } - - return( rc); -} - -/****************************************************************************** -Desc: Create a file -******************************************************************************/ -RCODE XFLMAPI F_FileHdl::Create( - const char * pszFileName, - FLMUINT uiIoFlags) -{ - RCODE rc = NE_XFLM_OK; - - flmAssert( m_bFileOpened == FALSE); - - if( m_bDeleteOnRelease) - { - // This file handle had better not been used for another file - // before. Otherwise, we will get a memory leak. - - flmAssert( m_pszFileName == NULL); - - // Note: 'OpenOrCreate' will set m_pszFileName - - if( RC_BAD( rc = f_alloc( F_PATH_MAX_SIZE, &m_pszFileName))) - { - goto Exit; - } - - f_strcpy( m_pszFileName, pszFileName); - } - - if( RC_BAD( rc = OpenOrCreate( pszFileName, uiIoFlags, TRUE))) - { - goto Exit; - } - - m_bFileOpened = TRUE; - m_ui64CurrentPos = 0; - m_bOpenedExclusive = (uiIoFlags & XFLM_IO_SH_DENYRW) ? TRUE : FALSE; - -Exit: - - if( RC_BAD( rc) && m_bDeleteOnRelease && m_pszFileName) - { - f_free( &m_pszFileName); - } - - return( rc); -} - -/****************************************************************************** -Desc: -******************************************************************************/ -RCODE XFLMAPI F_FileHdl::CreateUnique( - const char * pszDirName, - const char * pszFileExtension, - FLMUINT uiIoFlags) -{ - RCODE rc = NE_XFLM_OK; - char * pszTmp; - FLMBOOL bModext = TRUE; - FLMUINT uiBaseTime = 0; - FLMBYTE ucHighByte = 0; - char szFileName[ F_FILENAME_SIZE]; - char * pszDirPath; - char szDirPath[ F_PATH_MAX_SIZE]; - char szTmpPath[ F_PATH_MAX_SIZE]; - FLMUINT uiCount; - - flmAssert( !m_bFileOpened); - f_memset( szFileName, 0, sizeof( szFileName)); - - if( m_bDeleteOnRelease) - { - // This file handle had better not been used for another file - // before. Otherwise, we will get a memory leak. - - flmAssert( !m_pszFileName); - } - - if( !pszDirName || pszDirName[ 0] == '\0') - { - f_strcpy( szDirPath, "./"); - } - else - { - f_strcpy( szDirPath, pszDirName); - } - pszDirPath = &szDirPath [0]; - - // Search backwards replacing trailing spaces with NULLs. - - pszTmp = pszDirPath; - pszTmp += (f_strlen( pszTmp) - 1); - while (*pszTmp == ' ' && pszTmp >= pszDirPath) - { - *pszTmp = 0; - pszTmp--; - } - - // Append a slash if one isn't already there - - if (pszTmp >= pszDirPath && *pszTmp != '/') - { - pszTmp++; - *pszTmp++ = '/'; - } - else - { - pszTmp++; - } - *pszTmp = 0; - - if( pszFileExtension && f_strlen( pszFileExtension) >= 3) - { - bModext = FALSE; - } - - uiCount = 0; - do - { - gv_pFileSystem->pathCreateUniqueName( &uiBaseTime, szFileName, - pszFileExtension, - &ucHighByte, bModext); - - f_strcpy( szTmpPath, pszDirPath); - gv_pFileSystem->pathAppend( szTmpPath, szFileName); - if( m_pszFileName) - { - f_free( &m_pszFileName); - } - - rc = Create( szTmpPath, uiIoFlags | XFLM_IO_EXCL); - - if (rc == NE_XFLM_IO_DISK_FULL) - { - gv_pFileSystem->Delete( pszDirPath); - goto Exit; - } - - if( rc == NE_XFLM_IO_PATH_NOT_FOUND || rc == NE_XFLM_IO_INVALID_PASSWORD) - { - goto Exit; - } - } while ((rc != NE_XFLM_OK) && (uiCount++ < 10)); - - // Check if the path was created - - if( uiCount >= 10 && rc != NE_XFLM_OK) - { - rc = RC_SET( NE_XFLM_IO_PATH_CREATE_FAILURE); - goto Exit; - } - - m_bFileOpened = TRUE; - m_bOpenedExclusive = (uiIoFlags & XFLM_IO_SH_DENYRW) ? TRUE : FALSE; - - // Created file name needs to be returned. - - f_strcpy( pszDirName, szTmpPath); - -Exit: - - if( RC_BAD( rc) && m_pszFileName) - { - f_free( &m_pszFileName); - m_pszFileName = NULL; - } - - return( rc); -} - -/****************************************************************************** -Desc: Open a file -******************************************************************************/ -RCODE XFLMAPI F_FileHdl::Open( - const char * pszFileName, - FLMUINT uiIoFlags) -{ - RCODE rc = NE_XFLM_OK; - - flmAssert( !m_bFileOpened); - - if( m_bDeleteOnRelease) - { - // This file handle had better not been used for another file - // before. Otherwise, we will get a memory leak. - - flmAssert( !m_pszFileName); - - if( RC_BAD( rc = f_alloc( F_PATH_MAX_SIZE, &m_pszFileName))) - { - goto Exit; - } - } - - // Loop on error open conditions. - - for( ;;) - { - if( RC_OK( rc = OpenOrCreate( pszFileName, uiIoFlags, FALSE))) - { - break; - } - - if( rc != NE_XFLM_IO_TOO_MANY_OPEN_FILES) - { - goto Exit; - } - - // If for some reason we cannot open the file, then - // try to close some other file handle in the list. - - gv_XFlmSysData.pFileHdlMgr->releaseOneAvail( FALSE); - } - - m_bFileOpened = TRUE; - m_ui64CurrentPos = 0; - m_bOpenedReadOnly = (uiIoFlags & XFLM_IO_RDONLY) ? TRUE : FALSE; - m_bOpenedExclusive = (uiIoFlags & XFLM_IO_SH_DENYRW) ? TRUE : FALSE; - -Exit: - - if( RC_BAD( rc) && m_bDeleteOnRelease && m_pszFileName) - { - f_free( &m_pszFileName); - m_pszFileName = NULL; - } - - return( rc); -} - -/****************************************************************************** -Desc: Close a file -******************************************************************************/ -RCODE XFLMAPI F_FileHdl::Close( void) -{ - FLMBOOL bDeleteAllowed = TRUE; - RCODE rc = NE_XFLM_OK; - - if( !m_bFileOpened) - { - goto Exit; - } - - close( m_fd); - - m_fd = -1; - m_bFileOpened = FALSE; - m_bOpenedReadOnly = FALSE; - m_bOpenedExclusive = FALSE; - - if( m_bDeleteOnRelease) - { - flmAssert( m_pszFileName); - - if( bDeleteAllowed) - { - gv_pFileSystem->Delete( m_pszFileName); - } - m_bDeleteOnRelease = FALSE; - - f_free( &m_pszFileName); - m_pszFileName = NULL; - } - -Exit: - - return( rc); -} - -/****************************************************************************** -Desc: Make sure all file data is safely on disk -******************************************************************************/ -RCODE XFLMAPI F_FileHdl::Flush() -{ -#ifdef FLM_SOLARIS - // Direct I/O on Solaris is ADVISORY, meaning that the - // operating system may or may not actually honor the - // option for some or all operations on a given file. - // Thus, the only way to guarantee that writes are on disk - // is to call fdatasync. - // - // If a process is killed (with SIGKILL or SIGTERM), the - // dirty cache buffers associated with open files will be discarded unless - // the process intercepts the signal and properly closes the files. - // - // NOTES FROM THE UNIX MAN PAGES ON SIGNALS - // - // When killing a process or series of processes, it is common sense - // to start trying with the least dangerous signal, SIGTERM. That way, - // programs that care about an orderly shutdown get the chance to follow - // the procedures that they have been designed to execute when getting - // the SIGTERM signal, such as cleaning up and closing open files. If you - // send a SIGKILL to a process, you remove any chance for the process - // to do a tidy cleanup and shutdown, which might have unfortunate - // consequences. - - if( fdatasync( m_fd) != 0) - { - return( MapErrnoToFlaimErr( errno, NE_XFLM_FLUSHING_FILE)); - } -#else - if( !m_bDoDirectIO) - { - #ifdef FLM_OSX - if( fsync( m_fd) != 0) - #else - if( fdatasync( m_fd) != 0) - #endif - { - return( MapErrnoToFlaimErr( errno, NE_XFLM_FLUSHING_FILE)); - } - } -#endif - - return( NE_XFLM_OK); -} - -/****************************************************************************** -Desc: Read from a file -******************************************************************************/ -RCODE F_FileHdl::DirectRead( - FLMUINT64 ui64ReadOffset, - FLMUINT uiBytesToRead, - void * pvBuffer, - FLMBOOL bBuffHasFullSectors, - FLMUINT * puiBytesRead) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiBytesRead; - FLMBYTE * pucReadBuffer; - FLMBYTE * pucDestBuffer; - FLMUINT uiMaxBytesToRead; - FLMINT iTmp; - FLMBOOL bHitEOF; - - flmAssert( m_bFileOpened); - flmAssert( m_bDoDirectIO); - - if( puiBytesRead) - { - *puiBytesRead = 0; - } - - if( ui64ReadOffset == XFLM_IO_CURRENT_POS) - { - ui64ReadOffset = m_ui64CurrentPos; - } - - // This loop does multiple reads (if necessary) to get all of the - // data. It uses aligned buffers and reads at sector offsets. - - pucDestBuffer = (FLMBYTE *)pvBuffer; - for (;;) - { - // See if we are using an aligned buffer. If not, allocate - // one (if not already allocated), and use it. - - if( (ui64ReadOffset & m_ui64NotOnSectorBoundMask) || - (((FLMUINT64)(FLMUINT)pucDestBuffer) & m_ui64NotOnSectorBoundMask) || - ((uiBytesToRead & m_ui64NotOnSectorBoundMask) && - !bBuffHasFullSectors)) - { - if( !m_pucAlignedBuff) - { - if( RC_BAD( rc = AllocAlignBuffer())) - { - goto Exit; - } - } - pucReadBuffer = m_pucAlignedBuff; - - // Must read enough bytes to cover all of the sectors that - // contain the data we are trying to read. The value of - // (ui64ReadOffset & m_ui64NotOnSectorBoundMask) will give us the - // number of additional bytes that are in the sector prior to - // the read offset. We then round that up to the next sector - // to get the total number of bytes we are going to read. - - uiMaxBytesToRead = (FLMUINT)RoundUpToSectorMultiple( - uiBytesToRead + (ui64ReadOffset & m_ui64NotOnSectorBoundMask)); - - // Can't read more than the aligned buffer will hold. - - if( uiMaxBytesToRead > m_uiAlignedBuffSize) - { - uiMaxBytesToRead = m_uiAlignedBuffSize; - } - } - else - { - uiMaxBytesToRead = (FLMUINT)RoundUpToSectorMultiple( uiBytesToRead); - flmAssert( uiMaxBytesToRead >= uiBytesToRead); - pucReadBuffer = pucDestBuffer; - } - - bHitEOF = FALSE; - - if( (iTmp = pread( m_fd, pucReadBuffer, - uiMaxBytesToRead, GetSectorStartOffset( ui64ReadOffset))) == -1) - { - rc = MapErrnoToFlaimErr( errno, NE_XFLM_READING_FILE); - goto Exit; - } - uiBytesRead = (FLMUINT)iTmp; - - if( uiBytesRead < uiMaxBytesToRead) - { - bHitEOF = TRUE; - } - - // If the offset we want to read from is not on a sector - // boundary, increment the read buffer pointer to the - // offset where the data we need starts and decrement the - // bytes read by the difference between the start of the - // sector and the actual read offset. - - if( ui64ReadOffset & m_ui64NotOnSectorBoundMask) - { - pucReadBuffer += (ui64ReadOffset & m_ui64NotOnSectorBoundMask); - flmAssert( uiBytesRead >= m_uiBytesPerSector); - uiBytesRead -= (FLMUINT)(ui64ReadOffset & m_ui64NotOnSectorBoundMask); - } - - // If bytes read is more than we actually need, truncate it back - // so that we only copy what we actually need. - - if( uiBytesRead > uiBytesToRead) - { - uiBytesRead = uiBytesToRead; - } - - uiBytesToRead -= uiBytesRead; - - if( puiBytesRead) - { - (*puiBytesRead) += uiBytesRead; - } - - m_ui64CurrentPos = ui64ReadOffset + uiBytesRead; - - // If using a different buffer for reading, copy the - // data read into the destination buffer. - - if( pucDestBuffer != pucReadBuffer) - { - f_memcpy( pucDestBuffer, pucReadBuffer, uiBytesRead); - } - - if( !uiBytesToRead) - { - break; - } - - // Still more to read - did we hit EOF above? - - if( bHitEOF) - { - rc = RC_SET( NE_XFLM_IO_END_OF_FILE); - break; - } - - pucDestBuffer += uiBytesRead; - ui64ReadOffset += uiBytesRead; - } - -Exit: - - return( rc); -} - -/****************************************************************************** -Desc: Read from a file -******************************************************************************/ -RCODE XFLMAPI F_FileHdl::Read( - FLMUINT64 ui64ReadOffset, - FLMUINT uiBytesToRead, - void * pvBuffer, - FLMUINT * puiBytesRead) -{ - RCODE rc = NE_XFLM_OK; - FLMINT iBytesRead; - - flmAssert( m_bFileOpened); - - if( m_bDoDirectIO) - { - rc = DirectRead( ui64ReadOffset, uiBytesToRead, - pvBuffer, FALSE, puiBytesRead); - goto Exit; - } - - if( ui64ReadOffset == XFLM_IO_CURRENT_POS) - { - ui64ReadOffset = m_ui64CurrentPos; - } - - if( (iBytesRead = pread( m_fd, pvBuffer, - uiBytesToRead, ui64ReadOffset)) == -1) - { - rc = MapErrnoToFlaimErr(errno, NE_XFLM_READING_FILE); - goto Exit; - } - - if( puiBytesRead) - { - *puiBytesRead = (FLMUINT)iBytesRead; - } - - m_ui64CurrentPos = ui64ReadOffset + (FLMUINT)iBytesRead; - - if( (FLMUINT)iBytesRead < uiBytesToRead) - { - rc = RC_SET( NE_XFLM_IO_END_OF_FILE); - goto Exit; - } - -Exit: - - return( rc); -} - -/****************************************************************************** -Note: This function assumes that the pvBuffer that is passed in is - a multiple of a the sector size. -******************************************************************************/ -RCODE XFLMAPI F_FileHdl::SectorRead( - FLMUINT64 ui64ReadOffset, - FLMUINT uiBytesToRead, - void * pvBuffer, - FLMUINT * puiBytesRead) -{ - if( m_bDoDirectIO) - { - return( DirectRead( ui64ReadOffset, uiBytesToRead, - pvBuffer, TRUE, puiBytesRead)); - } - else - { - return( Read( ui64ReadOffset, uiBytesToRead, pvBuffer, puiBytesRead)); - } -} - -/****************************************************************************** -Desc: Sets current position of file. -******************************************************************************/ -RCODE XFLMAPI F_FileHdl::Seek( - FLMUINT64 ui64Offset, - FLMINT iWhence, - FLMUINT64 * pui64NewOffset) -{ - RCODE rc = NE_XFLM_OK; - - switch( iWhence) - { - case XFLM_IO_SEEK_CUR: - { - m_ui64CurrentPos += ui64Offset; - break; - } - - case XFLM_IO_SEEK_SET: - { - m_ui64CurrentPos = ui64Offset; - break; - } - - case XFLM_IO_SEEK_END: - { - if( RC_BAD( rc = Size( &m_ui64CurrentPos))) - { - goto Exit; - } - - break; - } - - default: - { - rc = RC_SET_AND_ASSERT( NE_XFLM_NOT_IMPLEMENTED); - goto Exit; - } - } - - if( pui64NewOffset) - { - *pui64NewOffset = m_ui64CurrentPos; - } - -Exit: - - return( rc); -} - -/****************************************************************************** -Desc: Return the size of the file -******************************************************************************/ -RCODE XFLMAPI F_FileHdl::Size( - FLMUINT64 * pui64Size) -{ - RCODE rc = NE_XFLM_OK; - struct stat statBuf; - - if( fstat( m_fd, &statBuf) == -1) - { - rc = MapErrnoToFlaimErr( errno, NE_XFLM_GETTING_FILE_SIZE); - goto Exit; - } - - *pui64Size = statBuf.st_size; - -Exit: - - return( rc); -} - -/****************************************************************************** -Desc: -******************************************************************************/ -RCODE XFLMAPI F_FileHdl::Tell( - FLMUINT64 * pui64Offset) -{ - *pui64Offset = m_ui64CurrentPos; - return( NE_XFLM_OK); -} - -/****************************************************************************** -Desc: Truncate the file to the indicated size -******************************************************************************/ -RCODE XFLMAPI F_FileHdl::Truncate( - FLMUINT64 ui64Size) -{ - RCODE rc = NE_XFLM_OK; - - flmAssert( m_bFileOpened); - - if( ftruncate( m_fd, ui64Size) == -1) - { - rc = MapErrnoToFlaimErr( errno, NE_XFLM_TRUNCATING_FILE); - goto Exit; - } - -Exit: - - return( rc); -} - -/****************************************************************************** -Desc: Write to a file -******************************************************************************/ -RCODE XFLMAPI F_FileHdl::Write( - FLMUINT64 ui64WriteOffset, - FLMUINT uiBytesToWrite, - const void * pvBuffer, - FLMUINT * puiBytesWrittenRV) -{ - RCODE rc = NE_XFLM_OK; - FLMINT iBytesWritten = 0; - - flmAssert( m_bFileOpened); - - if( m_bDoDirectIO) - { - rc = DirectWrite( ui64WriteOffset, uiBytesToWrite, pvBuffer, - uiBytesToWrite, NULL, puiBytesWrittenRV, FALSE, TRUE); - goto Exit; - } - - if( ui64WriteOffset == XFLM_IO_CURRENT_POS) - { - ui64WriteOffset = m_ui64CurrentPos; - } - - if( (iBytesWritten = pwrite( m_fd, pvBuffer, - uiBytesToWrite, ui64WriteOffset)) == -1) - { - rc = MapErrnoToFlaimErr(errno, NE_XFLM_WRITING_FILE); - goto Exit; - } - - if( puiBytesWrittenRV) - { - *puiBytesWrittenRV = (FLMUINT)iBytesWritten; - } - - m_ui64CurrentPos = ui64WriteOffset + (FLMUINT)iBytesWritten; - - if( (FLMUINT)iBytesWritten < uiBytesToWrite) - { - rc = RC_SET( NE_XFLM_IO_DISK_FULL); - goto Exit; - } - -Exit: - - return( rc); -} - -/****************************************************************************** -Desc: Allocate an aligned buffer. -******************************************************************************/ -RCODE F_FileHdl::AllocAlignBuffer( void) -{ - RCODE rc = NE_XFLM_OK; - - if( m_pucAlignedBuff) - { - goto Exit; - } - - // Allocate at least 64K - this will handle most read and write - // operations and will also be a multiple of the sector size most of - // the time. The calculation below rounds it up to the next sector - // boundary if it is not already on one. - - m_uiAlignedBuffSize = (FLMUINT)RoundUpToSectorMultiple( 64 * 1024); - -#if defined( FLM_SOLARIS) - if( (m_pucAlignedBuff = (FLMBYTE *)memalign( - sysconf( _SC_PAGESIZE), m_uiAlignedBuffSize)) == NULL) -#elif defined( FLM_OSX) - if( (m_pucAlignedBuff = (FLMBYTE *)malloc( m_uiAlignedBuffSize)) == NULL) -#else - if( posix_memalign( (void **)&m_pucAlignedBuff, - sysconf( _SC_PAGESIZE), m_uiAlignedBuffSize) == -1) -#endif - { - m_uiAlignedBuffSize = 0; - rc = MapErrnoToFlaimErr( errno, NE_XFLM_MEM); - goto Exit; - } - -Exit: - - return( rc); -} - -/****************************************************************************** -Note: This routine assumes that the size of pvBuffer is a multiple of - sector size and can be used to write out full sectors. Even if - uiBytesToWrite does not account for full sectors, data from the - buffer will still be written out - a partial sector on disk will - not be preserved. -******************************************************************************/ -RCODE F_FileHdl::DirectWrite( - FLMUINT64 ui64WriteOffset, - FLMUINT uiBytesToWrite, - const void * pvBuffer, - FLMUINT, - F_IOBuffer * pBufferObj, - FLMUINT * puiBytesWrittenRV, - FLMBOOL bBuffHasFullSectors, - FLMBOOL bZeroFill) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiBytesRead; - FLMUINT uiMaxBytesToWrite; - FLMUINT uiBytesBeingOutput; - FLMBYTE * pucWriteBuffer; - FLMBYTE * pucSrcBuffer; -#ifdef FLM_DEBUG - FLMBOOL bDoAsync = (pBufferObj != NULL) - ? TRUE - : FALSE; -#endif - FLMBOOL bDidAsync = FALSE; - FLMUINT uiLastWriteOffset; - FLMUINT uiLastWriteSize; - - flmAssert( m_bFileOpened); - -#ifdef FLM_DEBUG - if( bDoAsync) - { - flmAssert( m_bCanDoAsync); - } -#endif - - if( puiBytesWrittenRV) - { - *puiBytesWrittenRV = 0; - } - - if( ui64WriteOffset == XFLM_IO_CURRENT_POS) - { - ui64WriteOffset = m_ui64CurrentPos; - } - - // This loop is for direct IO - must make sure we use - // aligned buffers. - - pucSrcBuffer = (FLMBYTE *)pvBuffer; - for (;;) - { - // See if we are using an aligned buffer. If not, allocate - // one (if not already allocated), and use it. - - if( (ui64WriteOffset & m_ui64NotOnSectorBoundMask) || - (((FLMUINT64)(FLMUINT)pucSrcBuffer) & m_ui64NotOnSectorBoundMask) || - ((uiBytesToWrite & m_ui64NotOnSectorBoundMask) && !bBuffHasFullSectors)) - { - // Cannot be using a temporary write buffer if we are doing - // asynchronous writes! - - flmAssert( !bDoAsync || !m_bCanDoAsync); - - if( !m_pucAlignedBuff) - { - if( RC_BAD( rc = AllocAlignBuffer())) - { - goto Exit; - } - } - pucWriteBuffer = m_pucAlignedBuff; - - // Must write enough bytes to cover all of the sectors that - // contain the data we are trying to write out. The value of - // (ui64WriteOffset & m_ui64NotOnSectorBoundMask) will give us the - // number of additional bytes that are in the sector prior to - // the read offset. We then round to the next sector to get the - // total number of bytes we are going to write. - - uiMaxBytesToWrite = (FLMUINT)RoundUpToSectorMultiple( - uiBytesToWrite + (ui64WriteOffset & m_ui64NotOnSectorBoundMask)); - - // Can't write more than the aligned buffer will hold. - - if( uiMaxBytesToWrite > m_uiAlignedBuffSize) - { - uiMaxBytesToWrite = m_uiAlignedBuffSize; - uiBytesBeingOutput = uiMaxBytesToWrite - - (FLMUINT)(ui64WriteOffset & m_ui64NotOnSectorBoundMask); - } - else - { - uiBytesBeingOutput = uiBytesToWrite; - } - - // If the write offset is not on a sector boundary, or if - // we are writing a partial sector, we must read the - // sector into the buffer. - - if( (ui64WriteOffset & m_ui64NotOnSectorBoundMask) || - (uiBytesBeingOutput < m_uiBytesPerSector && !bBuffHasFullSectors)) - { - // Read the first sector that is to be written out. - // Read one sector's worth of data - so that we will - // preserve what is already in the sector before - // writing it back out again. - - if( RC_BAD( rc = Read( GetSectorStartOffset( ui64WriteOffset), - m_uiBytesPerSector, pucWriteBuffer, &uiBytesRead))) - { - if( rc != NE_XFLM_IO_END_OF_FILE) - { - goto Exit; - } - - rc = NE_XFLM_OK; - f_memset( &pucWriteBuffer[ uiBytesRead], 0, - m_uiBytesPerSector - uiBytesRead); - } - } - - // Finally, copy the data from the source buffer into the - // write buffer. - - f_memcpy( &pucWriteBuffer[ ui64WriteOffset & m_ui64NotOnSectorBoundMask], - pucSrcBuffer, uiBytesBeingOutput); - } - else - { - uiMaxBytesToWrite = (FLMUINT)RoundUpToSectorMultiple( uiBytesToWrite); - uiBytesBeingOutput = uiBytesToWrite; - pucWriteBuffer = pucSrcBuffer; - - if( bZeroFill && uiMaxBytesToWrite > uiBytesToWrite) - { - f_memset( &pucWriteBuffer[ uiBytesToWrite], 0, - uiMaxBytesToWrite - uiBytesToWrite); - } - } - - // Position the file to the nearest sector below the write offset. - - uiLastWriteOffset = (FLMUINT)GetSectorStartOffset( ui64WriteOffset); - uiLastWriteSize = uiMaxBytesToWrite; - - if( !m_bCanDoAsync || !pBufferObj) - { - FLMINT iBytesWritten; - - if( (iBytesWritten = pwrite( m_fd, - pucWriteBuffer, uiMaxBytesToWrite, uiLastWriteOffset)) == -1) - { - rc = MapErrnoToFlaimErr( errno, NE_XFLM_WRITING_FILE); - goto Exit; - } - - if( (FLMUINT)iBytesWritten < uiMaxBytesToWrite) - { - rc = RC_SET( NE_XFLM_IO_DISK_FULL); - goto Exit; - } - } - else - { - struct aiocb * pAio = pBufferObj->getAIOStruct(); - - f_memset( pAio, 0, sizeof( struct aiocb)); - pAio->aio_lio_opcode = LIO_WRITE; - pAio->aio_sigevent.sigev_notify = SIGEV_NONE; - pAio->aio_fildes = m_fd; - pAio->aio_offset = uiLastWriteOffset; - pAio->aio_nbytes = uiMaxBytesToWrite; - pAio->aio_buf = pucWriteBuffer; - - if( aio_write( pAio) == -1) - { - rc = MapErrnoToFlaimErr( errno, NE_XFLM_WRITING_FILE); - goto Exit; - } - - pBufferObj->makePending(); - bDidAsync = TRUE; - } - - uiBytesToWrite -= uiBytesBeingOutput; - if( puiBytesWrittenRV) - { - (*puiBytesWrittenRV) += uiBytesBeingOutput; - } - - m_ui64CurrentPos = ui64WriteOffset + uiBytesBeingOutput; - - if( !uiBytesToWrite) - { - break; - } - - flmAssert( !pBufferObj); - - pucSrcBuffer += uiBytesBeingOutput; - ui64WriteOffset += uiBytesBeingOutput; - } - -Exit: - - if( !bDidAsync && pBufferObj) - { - pBufferObj->notifyComplete( rc); - } - - return( rc); -} - -/****************************************************************************** -Desc: Returns flag indicating whether or not we can do async writes. -******************************************************************************/ -FLMBOOL XFLMAPI F_FileHdl::CanDoAsync() -{ - return( m_bCanDoAsync); -} - -/****************************************************************************** -Desc: Attempts to lock byte 0 of the file. This method is used to - lock byte 0 of the .lck file to ensure that only one process - has access to a database. -******************************************************************************/ -RCODE XFLMAPI F_FileHdl::Lock( void) -{ - RCODE rc = NE_XFLM_OK; - struct flock LockStruct; - - // Lock first byte in file - - f_memset( &LockStruct, 0, sizeof( LockStruct)); - LockStruct.l_type = F_WRLCK; - LockStruct.l_whence = SEEK_SET; - LockStruct.l_start = 0; - LockStruct.l_len = 1; - - if( fcntl( m_fd, F_SETLK, &LockStruct) == -1) - { - rc = RC_SET( NE_XFLM_IO_FILE_LOCK_ERR); - goto Exit; - } - -Exit: - - return( rc); -} - -/****************************************************************************** -Desc: Attempts to unlock byte 0 of the file. -******************************************************************************/ -RCODE XFLMAPI F_FileHdl::Unlock( void) -{ - RCODE rc = NE_XFLM_OK; - struct flock LockStruct; - - // Lock first byte in file - - f_memset( &LockStruct, 0, sizeof( LockStruct)); - LockStruct.l_type = F_UNLCK; - LockStruct.l_whence = SEEK_SET; - LockStruct.l_start = 0; - LockStruct.l_len = 1; - - if( fcntl( m_fd, F_SETLK, &LockStruct) == -1) - { - rc = RC_SET( NE_XFLM_IO_FILE_UNLOCK_ERR); - goto Exit; - } - -Exit: - - return( rc); -} - -/*************************************************************************** -Desc: Determines the kernel version of the linux system we are running on -***************************************************************************/ -#ifdef FLM_LINUX -void flmGetLinuxKernelVersion( - FLMUINT * puiMajor, - FLMUINT * puiMinor, - FLMUINT * puiRevision) -{ - int fd = -1; - int iBytesRead; - char szBuffer [80]; - char * pszVer; - FLMUINT uiMajorVer = 0; - FLMUINT uiMinorVer = 0; - FLMUINT uiRevision = 0; - - if( (fd = open( "/proc/version", O_RDONLY, 0600)) == -1) - { - goto Exit; - } - - if( (iBytesRead = read( fd, szBuffer, sizeof( szBuffer))) == -1) - { - goto Exit; - } - if( (pszVer = (char *)f_strstr( - (FLMBYTE *)szBuffer, (FLMBYTE *)"version ")) == NULL) - { - goto Exit; - } - pszVer += 8; - - while( *pszVer >= '0' && *pszVer <= '9') - { - uiMajorVer *= 10; - uiMajorVer += (FLMUINT)(*pszVer - '0'); - pszVer++; - } - - if( *pszVer == '.') - { - pszVer++; - while (*pszVer >= '0' && *pszVer <= '9') - { - uiMinorVer *= 10; - uiMinorVer += (FLMUINT)(*pszVer - '0'); - pszVer++; - } - } - - if( *pszVer == '.') - { - pszVer++; - while (*pszVer >= '0' && *pszVer <= '9') - { - uiRevision *= 10; - uiRevision += (FLMUINT)(*pszVer - '0'); - pszVer++; - } - } - -Exit: - - if( fd != -1) - { - close( fd); - } - - if( puiMajor) - { - *puiMajor = uiMajorVer; - } - - if( puiMinor) - { - *puiMinor = uiMinorVer; - } - - if( puiRevision) - { - *puiRevision = uiRevision; - } -} -#endif - -/*************************************************************************** -Desc: Determines if the linux system we are running on is 2.4 or greater. -***************************************************************************/ -#ifdef FLM_LINUX -FLMUINT flmGetLinuxMaxFileSize( void) -{ -#ifdef FLM_32BIT - return( XFLM_MAXIMUM_FILE_SIZE); -#else - FLMUINT uiMaxFileSize = 0x7FF00000; - - flmAssert( gv_XFlmSysData.uiLinuxMajorVer); - - // Is version 2.4 or greater? - - if( gv_XFlmSysData.uiLinuxMajorVer > 2 || - (gv_XFlmSysData.uiLinuxMajorVer == 2 && - gv_XFlmSysData.uiLinuxMinorVer >= 4)) - { - uiMaxFileSize = XFLM_MAXIMUM_FILE_SIZE; - } - - return( uiMaxFileSize); -#endif -} -#endif - -/*************************************************************************** -Desc: -***************************************************************************/ -#ifdef FLM_LINUX -FINLINE FLMUINT64 flmGetLinuxMemInfoValue( - char * pszMemInfoBuffer, - char * pszTag) -{ - char * pszTmp; - FLMUINT64 ui64Bytes = 0; - - if( (pszTmp = (char *)f_strstr( - (FLMBYTE *)pszMemInfoBuffer, (FLMBYTE *)pszTag)) == NULL) - { - return( 0); - } - - pszTmp += f_strlen( pszTag); - - while( *pszTmp == ASCII_SPACE) - { - pszTmp++; - } - - while( *pszTmp >= '0' && *pszTmp <= '9') - { - ui64Bytes *= 10; - ui64Bytes += (FLMUINT)(*pszTmp - '0'); - pszTmp++; - } - - return( ui64Bytes * 1024); -} -#endif - -/*************************************************************************** -Desc: -***************************************************************************/ -#ifdef FLM_LINUX -void flmGetLinuxMemInfo( - FLMUINT64 * pui64TotalMem, - FLMUINT64 * pui64AvailMem) -{ - int fd = -1; - int iBytesRead; - int iMemInfoBufSize = 4096; - char * pszMemInfoBuf = NULL; - FLMUINT64 ui64TotalMem = 0; - FLMUINT64 ui64AvailMem = 0; - - if( (pszMemInfoBuf = (char *)malloc( iMemInfoBufSize)) == NULL) - { - goto Exit; - } - - if( (fd = open( "/proc/meminfo", O_RDONLY, 0600)) == -1) - { - goto Exit; - } - - if( (iBytesRead = read( fd, pszMemInfoBuf, iMemInfoBufSize - 1)) == -1) - { - goto Exit; - } - - pszMemInfoBuf[ iBytesRead] = 0; - - if( (ui64TotalMem = - flmGetLinuxMemInfoValue( pszMemInfoBuf, "MemTotal:")) != 0) - { - ui64AvailMem = - flmGetLinuxMemInfoValue( pszMemInfoBuf, "MemFree:") + - flmGetLinuxMemInfoValue( pszMemInfoBuf, "Buffers:") + - flmGetLinuxMemInfoValue( pszMemInfoBuf, "Cached:"); - } - -Exit: - - if( pui64TotalMem) - { - *pui64TotalMem = ui64TotalMem; - } - - if( pui64AvailMem) - { - *pui64AvailMem = ui64AvailMem; - } - - if( pszMemInfoBuf) - { - free( pszMemInfoBuf); - } - - if( fd != -1) - { - close( fd); - } -} -#endif - -/**************************************************************************** -Desc: This routine gets the block size for the file system a file belongs to. -****************************************************************************/ -FLMUINT flmGetFSBlockSize( - FLMBYTE * pszFileName) -{ - FLMUINT uiFSBlkSize = 4096; - FLMBYTE * pszTmp = pszFileName + f_strlen( pszFileName) - 1; - FLMBYTE * pszDir; - FLMBYTE ucRestoreByte = 0; - - while( pszTmp != pszFileName && *pszTmp != '/') - { - pszTmp--; - } - - if( *pszTmp == '/') - { - if (pszTmp == pszFileName) - { - pszTmp++; - } - ucRestoreByte = *pszTmp; - *pszTmp = 0; - pszDir = pszFileName; - } - else - { - pszDir = (FLMBYTE *)"."; - } - -#if defined( FLM_SOLARIS) - struct statvfs statfsbuf; - if (statvfs( (char *)pszDir, &statfsbuf) == 0) - { - uiFSBlkSize = (FLMUINT)statfsbuf.f_bsize; - } -#elif defined( FLM_LINUX) || defined( FLM_OSF) - struct statfs statfsbuf; - if (statfs( (char *)pszDir, &statfsbuf) == 0) - { - uiFSBlkSize = (FLMUINT)statfsbuf.f_bsize; - } -#endif - - if( ucRestoreByte) - { - *pszTmp = ucRestoreByte; - } - - return( uiFSBlkSize); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -#if defined( FLM_SOLARIS) && defined( FLM_SPARC) && !defined( FLM_GNUC) -static void sparc_asm_code( void) -{ - asm( ".align 8"); - asm( ".global sparc_atomic_add_32"); - asm( ".type sparc_atomic_add_32, #function"); - asm( "sparc_atomic_add_32:"); - asm( " membar #LoadLoad | #LoadStore | #StoreStore | #StoreLoad"); - asm( " ld [%o0], %l0"); - asm( " add %l0, %o1, %l2"); - asm( " cas [%o0], %l0, %l2"); - asm( " cmp %l0, %l2"); - asm( " bne sparc_atomic_add_32"); - asm( " nop"); - asm( " add %l2, %o1, %o0"); - asm( " membar #LoadLoad | #LoadStore | #StoreStore | #StoreLoad"); - asm( "retl"); - asm( "nop"); - - asm( ".align 8"); - asm( ".global sparc_atomic_xchg_32"); - asm( ".type sparc_atomic_xchg_32, #function"); - asm( "sparc_atomic_xchg_32:"); - asm( " membar #LoadLoad | #LoadStore | #StoreStore | #StoreLoad"); - asm( " ld [%o0], %l0"); - asm( " mov %o1, %l1"); - asm( " cas [%o0], %l0, %l1"); - asm( " cmp %l0, %l1"); - asm( " bne sparc_atomic_xchg_32"); - asm( " nop"); - asm( " mov %l0, %o0"); - asm( " membar #LoadLoad | #LoadStore | #StoreStore | #StoreLoad"); - asm( "retl"); - asm( "nop"); -} -#endif - -/********************************************************************** -Desc: -**********************************************************************/ -extern "C" FLMINT32 posix_atomic_add_32( - volatile FLMINT32 * piTarget, - FLMINT32 iDelta) -{ - FLMINT32 iNewVal; - - pthread_mutex_lock( &gv_atomicMutex); - (*piTarget) += iDelta; - iNewVal = *piTarget; - pthread_mutex_unlock( &gv_atomicMutex); - - return( iNewVal); -} - -/********************************************************************** -Desc: -**********************************************************************/ -extern "C" FLMINT32 posix_atomic_xchg_32( - volatile FLMINT32 * piTarget, - FLMINT32 iNewValue) -{ - FLMINT32 iOldVal; - - pthread_mutex_lock( &gv_atomicMutex); - iOldVal = *piTarget; - *piTarget = iNewValue; - pthread_mutex_unlock( &gv_atomicMutex); - - return( iOldVal); -} - -#endif // FLM_UNIX - -#if defined( FLM_WATCOM_NLM) - int fposixDummy(void) - { - return( 0); - } -#endif diff --git a/xflaim/src/fposix.h b/xflaim/src/fposix.h deleted file mode 100644 index 2d3e23a..0000000 --- a/xflaim/src/fposix.h +++ /dev/null @@ -1,270 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: This include file contains the class definitions for FLAIM's POSIX -// FileHdl classes. -// -// Tabs: 3 -// -// Copyright (c) 2000-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: fposix.h 3109 2006-01-19 13:07:07 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#ifndef FPOSIX_H -#define FPOSIX_H - -#ifdef FLM_UNIX - -class F_FileHdl : public IF_FileHdl, public XF_Base -{ -public: - - F_FileHdl(); - - ~F_FileHdl(); - - RCODE XFLMAPI Setup( - FLMUINT uiFileId); - - RCODE XFLMAPI Close( void); - - RCODE XFLMAPI Create( - const char * pszFileName, - FLMUINT uiIoFlags); - - RCODE XFLMAPI CreateUnique( - const char * pszDirName, - const char * pszFileExtension, - FLMUINT uiIoFlags); - - RCODE XFLMAPI Open( - const char * pszFileName, - FLMUINT uiIoFlags); - - RCODE XFLMAPI Flush( void); - - RCODE XFLMAPI Read( - FLMUINT64 ui64Offset, - FLMUINT uiLength, - void * pvBuffer, - FLMUINT * puiBytesRead); - - RCODE XFLMAPI Seek( - FLMUINT64 ui64Offset, - FLMINT iWhence, - FLMUINT64 * pui64NewOffset); - - RCODE XFLMAPI Size( - FLMUINT64 * pui64Size); - - RCODE XFLMAPI Tell( - FLMUINT64 * pui64Offset); - - RCODE XFLMAPI Truncate( - FLMUINT64 ui64Size); - - RCODE XFLMAPI Write( - FLMUINT64 ui64Offset, - FLMUINT uiLength, - const void * pvBuffer, - FLMUINT * puiBytesWritten); - - // Some I/O subsystems (such as direct IO) can only read and - // write sectors. If uiOffset is not on a sector boundary or - // uiLength is not an exact multiple of a sector size, the I/O system - // would have to try to read or write a partial sector - something that - // requires extra overhead, particularly for write operations - because - // in order to write a partial sector, the I/O subsystem first has to - // read the sector in to memory before writing it out in order to - // preserve the part of the sector that was not being written to. - - // The SectorRead and SectorWrite routines are provided to allow - // the caller to tell the I/O subsystem that it is OK to do full - // sector reads or writes if it needs to, because pvBuffer is - // guaranteed to be a multiple of 512 bytes big. If the I/O - // subsystem can only do sector reads and writes, it can use the - // extra buffer space in pvBuffer. When a program calls SectorWrite - // it is also telling the I/O subsystem that it does not need to - // read a partially written sector from disk before writing it out. - // It will be OK to write whatever data is in the pvBuffer to fill out - // the sector. - - RCODE XFLMAPI SectorRead( - FLMUINT64 ui64ReadOffset, - FLMUINT uiBytesToRead, - void * pvBuffer, - FLMUINT * puiBytesReadRV); - - RCODE XFLMAPI SectorWrite( - FLMUINT64 ui64WriteOffset, - FLMUINT uiBytesToWrite, - const void * pvBuffer, - FLMUINT uiBufferSize, - void * pvBufferObj, - FLMUINT * puiBytesWrittenRV, - FLMBOOL bZeroFill = TRUE) - { - if( m_bDoDirectIO) - { - return( DirectWrite( ui64WriteOffset, uiBytesToWrite, - pvBuffer, uiBufferSize, (F_IOBuffer *)pvBufferObj, - puiBytesWrittenRV, TRUE, bZeroFill)); - } - else - { - return( Write( ui64WriteOffset, uiBytesToWrite, - pvBuffer, puiBytesWrittenRV)); - } - } - - FLMBOOL XFLMAPI CanDoAsync( void); - - FINLINE FLMBOOL XFLMAPI UsingDirectIo( void) - { - return( m_bDoDirectIO); - } - - FINLINE void XFLMAPI setExtendSize( - FLMUINT uiExtendSize) - { - m_uiExtendSize = uiExtendSize; - } - - FINLINE void XFLMAPI setMaxAutoExtendSize( - FLMUINT uiMaxAutoExtendSize) - { - m_uiMaxAutoExtendSize = uiMaxAutoExtendSize; - } - - RCODE XFLMAPI Lock( void); - - RCODE XFLMAPI Unlock( void); - - FINLINE void XFLMAPI SetBlockSize( - FLMUINT uiBlockSize) - { - m_uiBlockSize = uiBlockSize; - } - - FINLINE FLMUINT XFLMAPI GetSectorSize( void) - { - return( m_uiBytesPerSector); - } - - FINLINE void setupFileHdl( - FLMUINT uiFileId, - FLMBOOL bDeleteOnRelease) - { - m_uiFileId = uiFileId; - m_bDeleteOnRelease = bDeleteOnRelease; - } - - FINLINE FLMUINT getFileId( void) - { - return m_uiFileId; - } - -private: - - RCODE OpenOrCreate( - const char * pszFileName, - FLMUINT uiAccess, - FLMBOOL bCreateFlag); - - FINLINE FLMUINT64 RoundUpToSectorMultiple( - FLMUINT64 ui64Bytes) - { - return( (ui64Bytes + m_ui64NotOnSectorBoundMask) & - m_ui64GetSectorBoundMask); - } - - FINLINE FLMUINT64 GetSectorStartOffset( - FLMUINT64 ui64Offset) - { - return( ui64Offset & m_ui64GetSectorBoundMask); - } - - RCODE DirectRead( - FLMUINT64 ui64ReadOffset, - FLMUINT uiBytesToRead, - void * pvBuffer, - FLMBOOL bBuffHasFullSectors, - FLMUINT * puiBytesRead); - - RCODE DirectWrite( - FLMUINT64 ui64WriteOffset, - FLMUINT uiBytesToWrite, - const void * pvBuffer, - FLMUINT uiBufferSize, - F_IOBuffer * pBufferObj, - FLMUINT * puiBytesWrittenRV, - FLMBOOL bBuffHasFullSectors, - FLMBOOL bZeroFill); - - RCODE AllocAlignBuffer( void); - - // The following are for every platform. - - F_FileHdl * m_pNext; // Next file handle in list - F_FileHdl * m_pPrev; // Prev file handle in list - FLMBOOL m_bInList; // Is this file handle in a list? - FLMBOOL m_bFileOpened; // Is the file currently opened/closed. - FLMUINT m_uiAvailTime; // Time when placed in avail list. - FLMUINT m_uiFileId; // FFILE Unique File Id - FLMBOOL m_bDeleteOnRelease; // Delete this file when it is released. - FLMBOOL m_bOpenedReadOnly; // Opened the file read only - FLMBOOL m_bOpenedExclusive; // Opened the file in exclusive mode - char * m_pszFileName; // File name for this FileHdl - - // Specific to this platform - - int m_fd; - FLMUINT m_uiBlockSize; - FLMUINT m_uiBytesPerSector; - FLMUINT64 m_ui64NotOnSectorBoundMask; - FLMUINT64 m_ui64GetSectorBoundMask; - FLMUINT64 m_ui64CurrentPos; - FLMUINT m_uiExtendSize; - FLMUINT m_uiMaxAutoExtendSize; - FLMBOOL m_bCanDoAsync; - FLMBOOL m_bDoDirectIO; - FLMBYTE * m_pucAlignedBuff; - FLMUINT m_uiAlignedBuffSize; - - friend class F_FileHdlPage; - friend class F_FileHdlMgr; -}; - -FLMUINT flmGetFSBlockSize( - FLMBYTE * pszFileName); - -#if defined( FLM_LINUX) - void flmGetLinuxKernelVersion( - FLMUINT * puiMajor, - FLMUINT * puiMinor, - FLMUINT * puiRevision); - - FLMUINT flmGetLinuxMaxFileSize( void); - - void flmGetLinuxMemInfo( - FLMUINT64 * pui64TotalMem, - FLMUINT64 * pui64AvailMem); -#endif - -#endif // FLM_UNIX - -#endif // FPOSIX_H diff --git a/xflaim/src/fqeval.cpp b/xflaim/src/fqeval.cpp index 945d3ef..9433ea2 100644 --- a/xflaim/src/fqeval.cpp +++ b/xflaim/src/fqeval.cpp @@ -1037,289 +1037,23 @@ FSTATIC void fqOpSUMinus( } } -/*************************************************************************** -Desc: Compare two entire strings. -****************************************************************************/ -RCODE fqCompareCollStreams( - F_CollIStream * pLStream, - F_CollIStream * pRStream, - FLMBOOL bOpIsMatch, - FLMUINT uiLanguage, - FLMINT * piResult) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT16 ui16RCol; - FLMUINT16 ui16LCol; - FLMUINT16 ui16RSubCol; - FLMUINT16 ui16LSubCol; - FLMBYTE ucRCase; - FLMBYTE ucLCase; - F_CollStreamPos savedRPos; - F_CollStreamPos savedLPos; - F_CollStreamPos startLPos; - FLMUNICODE uLChar = 0; - FLMBOOL bLCharIsWild = FALSE; - FLMUNICODE uRChar = 0; - FLMBOOL bRCharIsWild = FALSE; - FLMBOOL bPrevLWasWild = FALSE; - FLMBOOL bPrevRWasWild = FALSE; - FLMBOOL bAllowTwoIntoOne; - - // If we are doing a "match" operation, we don't want two - // character sequences like Ch, ae, etc. turned into a single - // a single collation, because then matches that involve wildcards - // like "aetna == a*" would not match properly. - // When not doing a match operation, we WANT two character sequences - // turned into a single collation value so that we can know if - // something is > or <. When doing match operations, all we care - // about is if they are equal or not, so there is no need to look - // at double character collation properties. - - bAllowTwoIntoOne = bOpIsMatch ? FALSE : TRUE; - - for( ;;) - { -GetNextLChar: - - if( bLCharIsWild) - { - bPrevLWasWild = TRUE; - } - - pLStream->getCurrPosition( &startLPos); - if( RC_BAD( rc = pLStream->read( - bAllowTwoIntoOne, - &uLChar, &bLCharIsWild, &ui16LCol, &ui16LSubCol, &ucLCase))) - { - if( rc == NE_XFLM_EOF_HIT) - { - rc = NE_XFLM_OK; - - // If the last character was a wildcard, we have a match! - - if( bPrevLWasWild) - { - *piResult = 0; - goto Exit; - } - - for( ;;) - { - if( RC_BAD( rc = pRStream->read( - bAllowTwoIntoOne, - &uRChar, &bRCharIsWild, &ui16RCol, &ui16RSubCol, &ucRCase))) - { - if( rc == NE_XFLM_EOF_HIT) - { - rc = NE_XFLM_OK; - *piResult = 0; - } - - goto Exit; - } - - // Break out when we hit a non-wild character - - if( !bRCharIsWild) - { - break; - } - } - - *piResult = -1; - } - - goto Exit; - } - - if( bLCharIsWild) - { - // Consume multiple wildcards - - if( bPrevLWasWild) - { - goto GetNextLChar; - } - - // See if we match anywhere on the remaining right string - - for( ;;) - { - pRStream->getCurrPosition( &savedRPos); - pLStream->getCurrPosition( &savedLPos); - - if( RC_BAD( rc = fqCompareCollStreams( pLStream, pRStream, - bOpIsMatch, uiLanguage, piResult))) - { - goto Exit; - } - - if( !(*piResult)) - { - goto Exit; - } - - if( RC_BAD( rc = pRStream->positionTo( &savedRPos))) - { - goto Exit; - } - - if( RC_BAD( rc = pRStream->read( - bAllowTwoIntoOne, - NULL, NULL, NULL, NULL, NULL))) - { - if( rc == NE_XFLM_EOF_HIT) - { - rc = NE_XFLM_OK; - break; - } - goto Exit; - } - - if( RC_BAD( rc = pLStream->positionTo( &savedLPos))) - { - goto Exit; - } - } - - *piResult = 1; - goto Exit; - } - -GetNextRChar: - - if( bRCharIsWild) - { - bPrevRWasWild = TRUE; - } - - if( RC_BAD( rc = pRStream->read( - bAllowTwoIntoOne, - &uRChar, &bRCharIsWild, &ui16RCol, &ui16RSubCol, &ucRCase))) - { - if( rc == NE_XFLM_EOF_HIT) - { - rc = NE_XFLM_OK; - - // If the last character was a wildcard, we have a match! - - if( bPrevRWasWild) - { - *piResult = 0; - } - else - { - *piResult = 1; - } - } - - goto Exit; - } - - if( bRCharIsWild) - { - if( bPrevRWasWild) - { - goto GetNextRChar; - } - - // See if we match anywhere on the remaining left string - - if( RC_BAD( rc = pLStream->positionTo( &startLPos))) - { - goto Exit; - } - - for( ;;) - { - pLStream->getCurrPosition( &savedLPos); - pRStream->getCurrPosition( &savedRPos); - - if( RC_BAD( rc = fqCompareCollStreams( pLStream, pRStream, - bOpIsMatch, uiLanguage, piResult))) - { - goto Exit; - } - - if( !(*piResult)) - { - goto Exit; - } - - if( RC_BAD( rc = pRStream->positionTo( &savedRPos))) - { - goto Exit; - } - - if( RC_BAD( rc = pLStream->positionTo( &savedLPos))) - { - goto Exit; - } - - // Skip the character we just processed - - if( RC_BAD( rc = pLStream->read( - bAllowTwoIntoOne, - NULL, NULL, NULL, NULL, NULL))) - { - if( rc == NE_XFLM_EOF_HIT) - { - rc = NE_XFLM_OK; - break; - } - goto Exit; - } - } - - *piResult = -1; - goto Exit; - } - - if( ui16LCol != ui16RCol) - { - *piResult = ui16LCol < ui16RCol ? -1 : 1; - goto Exit; - } - else if( ui16LSubCol != ui16RSubCol) - { - *piResult = ui16LSubCol < ui16RSubCol ? -1 : 1; - goto Exit; - } - else if( ucLCase != ucRCase) - { - // NOTE: If we are doing a case insensitive comparison, - // ucLCase and ucRCase should be equal (both will have been - // set to zero - - *piResult = ucLCase < ucRCase ? -1 : 1; - goto Exit; - } - } - -Exit: - - return( rc); -} - /*************************************************************************** Desc: Compare two entire strings. ****************************************************************************/ FSTATIC RCODE fqCompareText( - IF_OperandComparer * pOpComparer, - FQVALUE * pLValue, - FQVALUE * pRValue, - FLMUINT uiCompareRules, - FLMBOOL bOpIsMatch, - FLMUINT uiLanguage, - FLMINT * piResult) + IF_OperandComparer * pOpComparer, + FQVALUE * pLValue, + FQVALUE * pRValue, + FLMUINT uiCompareRules, + FLMBOOL bOpIsMatch, + FLMUINT uiLanguage, + FLMINT * piResult) { - RCODE rc = NE_XFLM_OK; - F_BufferIStream bufferLStream; - IF_PosIStream * pLStream; - F_BufferIStream bufferRStream; - IF_PosIStream * pRStream; - F_CollIStream lStream; - F_CollIStream rStream; + RCODE rc = NE_XFLM_OK; + IF_BufferIStream * pBufferLStream = NULL; + IF_PosIStream * pLStream; + IF_BufferIStream * pBufferRStream = NULL; + IF_PosIStream * pRStream; // Types must be text @@ -1334,13 +1068,18 @@ FSTATIC RCODE fqCompareText( if( !(pLValue->uiFlags & VAL_IS_STREAM)) { - if (RC_BAD( rc = bufferLStream.open( pLValue->val.pucBuf, - pLValue->uiDataLen))) + if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferLStream))) + { + goto Exit; + } + + if (RC_BAD( rc = pBufferLStream->open( + (const char *)pLValue->val.pucBuf, pLValue->uiDataLen))) { goto Exit; } - pLStream = &bufferLStream; + pLStream = pBufferLStream; } else { @@ -1349,12 +1088,17 @@ FSTATIC RCODE fqCompareText( if( !(pRValue->uiFlags & VAL_IS_STREAM)) { - if( RC_BAD( rc = bufferRStream.open( pRValue->val.pucBuf, - pRValue->uiDataLen))) + if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferRStream))) { goto Exit; } - pRStream = &bufferRStream; + + if( RC_BAD( rc = pBufferRStream->open( + (const char *)pRValue->val.pucBuf, pRValue->uiDataLen))) + { + goto Exit; + } + pRStream = pBufferRStream; } else { @@ -1366,29 +1110,29 @@ FSTATIC RCODE fqCompareText( rc = pOpComparer->compare( pLStream, pRStream, piResult); goto Exit; } - - // Open up the collated streams - - if (RC_BAD( rc = lStream.open( pLStream, FALSE, uiLanguage, uiCompareRules, - (bOpIsMatch && (pLValue->uiFlags & VAL_IS_CONSTANT)) ? TRUE : FALSE))) - { - goto Exit; - } - - if (RC_BAD( rc = rStream.open( pRStream, FALSE, uiLanguage, uiCompareRules, - (bOpIsMatch && (pRValue->uiFlags & VAL_IS_CONSTANT)) ? TRUE : FALSE))) - { - goto Exit; - } - - if (RC_BAD( rc = fqCompareCollStreams( &lStream, &rStream, - bOpIsMatch, uiLanguage, piResult))) + + if( RC_BAD( rc = f_compareUTF8Streams( + pLStream, + (bOpIsMatch && (pLValue->uiFlags & VAL_IS_CONSTANT)) ? TRUE : FALSE, + pRStream, + (bOpIsMatch && (pRValue->uiFlags & VAL_IS_CONSTANT)) ? TRUE : FALSE, + uiCompareRules, uiLanguage, piResult))) { goto Exit; } Exit: + if( pBufferLStream) + { + pBufferLStream->Release(); + } + + if( pBufferRStream) + { + pBufferRStream->Release(); + } + return( rc); } @@ -1396,18 +1140,18 @@ Exit: Desc: Approximate compare - only works for strings right now. ****************************************************************************/ FSTATIC RCODE fqApproxCompare( - FQVALUE * pLValue, - FQVALUE * pRValue, - FLMINT * piResult) + FQVALUE * pLValue, + FQVALUE * pRValue, + FLMINT * piResult) { - RCODE rc = NE_XFLM_OK; - FLMUINT uiLMeta; - FLMUINT uiRMeta; - FLMUINT64 ui64StartPos; - F_BufferIStream bufferLStream; - IF_PosIStream * pLStream; - F_BufferIStream bufferRStream; - IF_PosIStream * pRStream; + RCODE rc = NE_XFLM_OK; + FLMUINT uiLMeta; + FLMUINT uiRMeta; + FLMUINT64 ui64StartPos; + IF_BufferIStream * pBufferLStream = NULL; + IF_PosIStream * pLStream; + IF_BufferIStream * pBufferRStream = NULL; + IF_PosIStream * pRStream; // Types must be text @@ -1422,13 +1166,18 @@ FSTATIC RCODE fqApproxCompare( if (!(pLValue->uiFlags & VAL_IS_STREAM)) { - if (RC_BAD( rc = bufferLStream.open( pLValue->val.pucBuf, - pLValue->uiDataLen))) + if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferLStream))) + { + goto Exit; + } + + if (RC_BAD( rc = pBufferLStream->open( + (const char *)pLValue->val.pucBuf, pLValue->uiDataLen))) { goto Exit; } - pLStream = &bufferLStream; + pLStream = pBufferLStream; } else { @@ -1437,12 +1186,18 @@ FSTATIC RCODE fqApproxCompare( if (!(pRValue->uiFlags & VAL_IS_STREAM)) { - if( RC_BAD( rc = bufferRStream.open( pRValue->val.pucBuf, - pRValue->uiDataLen))) + if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferRStream))) { goto Exit; } - pRStream = &bufferRStream; + + if( RC_BAD( rc = pBufferRStream->open( + (const char *)pRValue->val.pucBuf, pRValue->uiDataLen))) + { + goto Exit; + } + + pRStream = pBufferRStream; } else { @@ -1454,7 +1209,7 @@ FSTATIC RCODE fqApproxCompare( { for( ;;) { - if( RC_BAD( rc = flmGetNextMetaphone( pLStream, &uiLMeta))) + if( RC_BAD( rc = f_getNextMetaphone( pLStream, &uiLMeta))) { if( rc == NE_XFLM_EOF_HIT) { @@ -1468,7 +1223,7 @@ FSTATIC RCODE fqApproxCompare( for( ;;) { - if( RC_BAD( rc = flmGetNextMetaphone( pRStream, &uiRMeta))) + if( RC_BAD( rc = f_getNextMetaphone( pRStream, &uiRMeta))) { if( rc == NE_XFLM_EOF_HIT) { @@ -1496,7 +1251,7 @@ FSTATIC RCODE fqApproxCompare( { for( ;;) { - if( RC_BAD( rc = flmGetNextMetaphone( pRStream, &uiRMeta))) + if( RC_BAD( rc = f_getNextMetaphone( pRStream, &uiRMeta))) { if( rc == NE_XFLM_EOF_HIT) { @@ -1510,7 +1265,7 @@ FSTATIC RCODE fqApproxCompare( for( ;;) { - if( RC_BAD( rc = flmGetNextMetaphone( pLStream, &uiLMeta))) + if( RC_BAD( rc = f_getNextMetaphone( pLStream, &uiLMeta))) { if( rc == NE_XFLM_EOF_HIT) { @@ -1537,6 +1292,16 @@ FSTATIC RCODE fqApproxCompare( Exit: + if( pBufferLStream) + { + pBufferLStream->Release(); + } + + if( pBufferRStream) + { + pBufferRStream->Release(); + } + return( rc); } @@ -1550,15 +1315,15 @@ FSTATIC RCODE fqCompareBinary( FQVALUE * pRValue, FLMINT * piResult) { - RCODE rc = NE_XFLM_OK; - F_BufferIStream bufferLStream; - IF_PosIStream * pLStream; - F_BufferIStream bufferRStream; - IF_PosIStream * pRStream; - FLMBYTE ucLByte; - FLMBYTE ucRByte; - FLMUINT uiOffset = 0; - FLMBOOL bLEmpty = FALSE; + RCODE rc = NE_XFLM_OK; + IF_BufferIStream * pBufferLStream = NULL; + IF_PosIStream * pLStream; + IF_BufferIStream * pBufferRStream = NULL; + IF_PosIStream * pRStream; + FLMBYTE ucLByte; + FLMBYTE ucRByte; + FLMUINT uiOffset = 0; + FLMBOOL bLEmpty = FALSE; *piResult = 0; @@ -1575,13 +1340,18 @@ FSTATIC RCODE fqCompareBinary( if( !(pLValue->uiFlags & VAL_IS_STREAM)) { - if (RC_BAD( rc = bufferLStream.open( pLValue->val.pucBuf, - pLValue->uiDataLen))) + if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferLStream))) + { + goto Exit; + } + + if (RC_BAD( rc = pBufferLStream->open( + (const char *)pLValue->val.pucBuf, pLValue->uiDataLen))) { goto Exit; } - pLStream = &bufferLStream; + pLStream = pBufferLStream; } else { @@ -1590,12 +1360,12 @@ FSTATIC RCODE fqCompareBinary( if( !(pRValue->uiFlags & VAL_IS_STREAM)) { - if( RC_BAD( rc = bufferRStream.open( pRValue->val.pucBuf, - pRValue->uiDataLen))) + if( RC_BAD( rc = pBufferRStream->open( + (const char *)pRValue->val.pucBuf, pRValue->uiDataLen))) { goto Exit; } - pRStream = &bufferRStream; + pRStream = pBufferRStream; } else { @@ -1658,6 +1428,16 @@ FSTATIC RCODE fqCompareBinary( Exit: + if( pBufferLStream) + { + pBufferLStream->Release(); + } + + if( pBufferRStream) + { + pBufferRStream->Release(); + } + return( rc); } @@ -2050,517 +1830,3 @@ Exit: return( rc); } - -/***************************************************************************** -Desc: -******************************************************************************/ -RCODE F_CollIStream::read( - FLMBOOL bAllowTwoIntoOne, - FLMUNICODE * puChar, - FLMBOOL * pbCharIsWild, - FLMUINT16 * pui16Col, - FLMUINT16 * pui16SubCol, - FLMBYTE * pucCase) -{ - RCODE rc = NE_XFLM_OK; - FLMUNICODE uChar; - FLMUINT16 ui16WpChar; - FLMUINT16 ui16NextWpChar; - FLMUINT16 ui16Col; - FLMUINT16 ui16SubCol; - FLMBOOL bTwoIntoOne; - FLMBYTE ucCase; - FLMBOOL bAsian; - FLMBOOL bLastCharWasSpace = FALSE; - FLMUINT64 ui64AfterLastSpacePos = 0; - FLMUINT64 ui64CurrCharPos = 0; - - if (pbCharIsWild) - { - *pbCharIsWild = FALSE; - } - - // Is this a double-byte (Asian) character set? - - bAsian = (m_uiLanguage >= FIRST_DBCS_LANG && m_uiLanguage <= LAST_DBCS_LANG) - ? TRUE - : FALSE; - - // Get the next character from the stream - -GetNextChar: - - ui16WpChar = 0; - ui16NextWpChar = 0; - ui16Col = 0; - ui16SubCol = 0; - bTwoIntoOne = FALSE; - ucCase = 0; - - if (m_uNextChar) - { - uChar = m_uNextChar; - m_uNextChar = 0; - } - else - { - ui64CurrCharPos = m_pIStream->getCurrPosition(); - if( RC_BAD( rc = readCharFromStream( &uChar))) - { - if (rc != NE_XFLM_EOF_HIT) - { - goto Exit; - } - - // If we were skipping spaces, we need to - // process a single space character, unless we are - // ignoring trailing white space. - - if (bLastCharWasSpace && - !(m_uiCompareRules & XFLM_COMP_IGNORE_TRAILING_SPACE)) - { - // bLastCharWasSpace flag can only be TRUE if either - // XFLM_COMP_IGNORE_TRAILING_SPACE is set or - // XFLM_COMP_COMPRESS_WHITESPACE is set. - - flmAssert( m_uiCompareRules & XFLM_COMP_COMPRESS_WHITESPACE); - uChar = ASCII_SPACE; - rc = NE_XFLM_OK; - goto Process_Char; - } - goto Exit; - } - } - - if ((uChar = flmConvertChar( uChar, m_uiCompareRules)) == 0) - { - goto GetNextChar; - } - - // Deal with spaces - - if (uChar == ASCII_SPACE) - { - if (m_uiCompareRules & XFLM_COMP_COMPRESS_WHITESPACE) - { - bLastCharWasSpace = TRUE; - ui64AfterLastSpacePos = m_pIStream->getCurrPosition(); - goto GetNextChar; - } - else if (m_uiCompareRules & XFLM_COMP_IGNORE_TRAILING_SPACE) - { - if (!bLastCharWasSpace) - { - bLastCharWasSpace = TRUE; - - // Save where we are at so that if this doesn't turn out - // to be trailing spaces, we can restore this position. - - ui64AfterLastSpacePos = m_pIStream->getCurrPosition(); - } - goto GetNextChar; - } - } - else - { - if (m_uiCompareRules & XFLM_COMP_IGNORE_LEADING_SPACE) - { - m_ui64EndOfLeadingSpacesPos = ui64CurrCharPos; - m_uiCompareRules &= (~(XFLM_COMP_IGNORE_LEADING_SPACE)); - } - - // If the last character was a space, we need to process it. - - if (bLastCharWasSpace) - { - - // Position back to after the last space, and process a space - // character. - - if (RC_BAD( rc = m_pIStream->positionTo( ui64AfterLastSpacePos))) - { - goto Exit; - } - - uChar = ASCII_SPACE; - bLastCharWasSpace = FALSE; - } - else if (uChar == ASCII_BACKSLASH) - { - // If wildcards are allowed, the backslash should be treated - // as an escape character, and the next character is the one - // we want. Otherwise, it should be treated as - // the actual character we want returned. - - if (m_bMayHaveWildCards) - { - - // Got a backslash. Means the next character is to be taken - // no matter what because it is escaped. - - if (RC_BAD( rc = readCharFromStream( &uChar))) - { - if (rc != NE_XFLM_EOF_HIT) - { - goto Exit; - } - rc = NE_XFLM_OK; - uChar = ASCII_BACKSLASH; - } - } - } - else if (uChar == ASCII_WILDCARD) - { - if (m_bMayHaveWildCards && pbCharIsWild) - { - *pbCharIsWild = TRUE; - } - } - } - -Process_Char: - - if (!bAsian) - { - - // Must check for double characters if non-US and non-Asian - // character set - - if (m_uiLanguage != XFLM_US_LANG) - { - if (RC_BAD( rc = flmWPCheckDoubleCollation( - m_pIStream, m_bUnicodeStream, bAllowTwoIntoOne, - &uChar, &m_uNextChar, &bTwoIntoOne, m_uiLanguage))) - { - goto Exit; - } - } - } - else - { - if (RC_BAD( rc = readCharFromStream( &m_uNextChar))) - { - if (rc == NE_XFLM_EOF_HIT) - { - rc = NE_XFLM_OK; - m_uNextChar = 0; - } - else - { - RC_UNEXPECTED_ASSERT( rc); - goto Exit; - } - } - } - - // Convert each character to its WP equivalent - - if (!flmUnicodeToWP( uChar, &ui16WpChar)) - { - ui16WpChar = 0; - } - - if (!flmUnicodeToWP( m_uNextChar, &ui16NextWpChar)) - { - ui16NextWpChar = 0; - } - - // If we have an unconvertible UNICODE character, the collation - // value for it will be COLS0 - - if (!ui16WpChar) - { - if (!bAsian) - { - ui16Col = COLS0; - } - else - { - if (uChar < 0x20) - { - ui16Col = 0xFFFF; - ui16SubCol = uChar; - } - else - { - ui16Col = uChar; - ui16SubCol = 0; - } - } - } - else - { - if (!bAsian) - { - ui16Col = flmWPGetCollation( ui16WpChar, m_uiLanguage); - if (bTwoIntoOne) - { - // Since two characters were merged into one, increment - // the collation value by one. In the case of something - // like 'ch', there is a collation value between 'c' and - // 'd'. flmWPGetCollation would have returned the - // collation value for 'c' ... incrementing by one gives - // us the proper collation value for 'ch' (i.e., the - // collation value between 'c' and 'd'). - - ui16Col++; - } - } - else - { - if (flmWPAsiaGetCollation( ui16WpChar, ui16NextWpChar, ui16Col, - &ui16Col, &ui16SubCol, &ucCase, !m_bCaseSensitive) == 2) - { - - // Next character was consumed by collation - - m_uNextChar = 0; - } - } - } - - if (pui16Col) - { - *pui16Col = ui16Col; - } - - // Consume m_uNextChar if two characters merged into one - - if (bTwoIntoOne) - { - m_uNextChar = 0; - } - - // Subcollation - - if( pui16SubCol) - { - if( uChar > 127 && !bAsian) - { - ui16SubCol = ui16WpChar - ? flmWPGetSubCol( ui16WpChar, ui16Col, m_uiLanguage) - : uChar; - - if( !m_bCaseSensitive) - { - // If the sub-collation value is the original - // character, it means that the collation could not - // distinguish the characters and sub-collation is being - // used to do it. However, this creates a problem when the - // characters are the same character except for case. In that - // scenario, we incorrectly return a not-equal when we are - // doing a case-insensitive comparison. So, at this point, - // we need to use the sub-collation for the upper-case of the - // character instead of the sub-collation for the character - // itself. - - if( ui16WpChar && ui16SubCol == ui16WpChar) - { - ui16SubCol = flmWPGetSubCol( - flmWPUpper( ui16WpChar), - ui16Col, m_uiLanguage); - } - } - } - - *pui16SubCol = ui16SubCol; - } - - // Case - - if( pucCase) - { - if (!m_bCaseSensitive) - { - *pucCase = 0; - } - else - { - if (!bAsian && ui16WpChar) - { - // flmWPIsUpper() returns FALSE if the character is lower or - // TRUE if the character is not lower case. - - if( flmWPIsUpper( ui16WpChar)) - { - if( bTwoIntoOne) - { - if( flmWPIsUpper( ui16NextWpChar)) - { - ucCase = 0x03; - } - else - { - ucCase = 0x10; - } - } - else - { - ucCase = 0x01; - } - } - } - *pucCase = ucCase; - } - } - - if (puChar) - { - *puChar = uChar; - } - -Exit: - - return( rc); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_DbSystem::compareUTF8Strings( - const FLMBYTE * pucLString, - FLMUINT uiLStrBytes, - FLMBOOL bLeftWild, - const FLMBYTE * pucRString, - FLMUINT uiRStrBytes, - FLMBOOL bRightWild, - FLMUINT uiCompareRules, - FLMUINT uiLanguage, - FLMINT * piResult) -{ - RCODE rc = NE_XFLM_OK; - F_BufferIStream bufferLStream; - F_BufferIStream bufferRStream; - F_CollIStream lStream; - F_CollIStream rStream; - - if (RC_BAD( rc = bufferLStream.open( pucLString, uiLStrBytes))) - { - goto Exit; - } - - if( RC_BAD( rc = bufferRStream.open( pucRString, uiRStrBytes))) - { - goto Exit; - } - - if( RC_BAD( rc = lStream.open( &bufferLStream, FALSE, uiLanguage, - uiCompareRules, bLeftWild))) - { - goto Exit; - } - - if( RC_BAD( rc = rStream.open( &bufferRStream, FALSE, uiLanguage, - uiCompareRules, bRightWild))) - { - goto Exit; - } - - if( RC_BAD( rc = fqCompareCollStreams( &lStream, &rStream, - (bLeftWild || bRightWild) ? TRUE : FALSE, - uiLanguage, piResult))) - { - goto Exit; - } - -Exit: - - return( rc); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_DbSystem::compareUnicodeStrings( - const FLMUNICODE * puzLString, - FLMUINT uiLStrBytes, - FLMBOOL bLeftWild, - const FLMUNICODE * puzRString, - FLMUINT uiRStrBytes, - FLMBOOL bRightWild, - FLMUINT uiCompareRules, - FLMUINT uiLanguage, - FLMINT * piResult) -{ - RCODE rc = NE_XFLM_OK; - F_BufferIStream bufferLStream; - F_BufferIStream bufferRStream; - F_CollIStream lStream; - F_CollIStream rStream; - - if( RC_BAD( rc = bufferLStream.open( (FLMBYTE *)puzLString, uiLStrBytes))) - { - goto Exit; - } - - if( RC_BAD( rc = bufferRStream.open( (FLMBYTE *)puzRString, uiRStrBytes))) - { - goto Exit; - } - - if( RC_BAD( rc = lStream.open( &bufferLStream, TRUE, uiLanguage, - uiCompareRules, bLeftWild))) - { - goto Exit; - } - - if( RC_BAD( rc = rStream.open( &bufferRStream, TRUE, uiLanguage, - uiCompareRules, bRightWild))) - { - goto Exit; - } - - if( RC_BAD( rc = fqCompareCollStreams( &lStream, &rStream, - (bLeftWild || bRightWild) ? TRUE : FALSE, uiLanguage, piResult))) - { - goto Exit; - } - -Exit: - - return( rc); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE XFLMAPI F_DbSystem::utf8IsSubStr( - const FLMBYTE * pszString, - const FLMBYTE * pszSubString, - FLMUINT uiCompareRules, - FLMUINT uiLanguage, - FLMBOOL * pbExists) -{ - RCODE rc = NE_XFLM_OK; - FLMINT iResult = 0; - FLMBYTE * pszSearch = NULL; - FLMUINT uiSubStringLen = f_strlen( pszSubString); - - if( RC_BAD( rc = f_alloc( uiSubStringLen + 3, &pszSearch))) - { - goto Exit; - } - - pszSearch[0] = '*'; - f_memcpy( &pszSearch[ 1], pszSubString, uiSubStringLen); - pszSearch[ uiSubStringLen + 1] = '*'; - pszSearch[ uiSubStringLen + 2] = '\0'; - - if( RC_BAD( rc = compareUTF8Strings( - pszString, f_strlen( pszString), FALSE, pszSearch, - uiSubStringLen + 2, TRUE, uiCompareRules, uiLanguage, &iResult))) - { - goto Exit; - } - - *pbExists = (iResult)?FALSE:TRUE; - -Exit: - - if( pszSearch) - { - f_free( &pszSearch); - } - - return( rc); -} diff --git a/xflaim/src/fqsort.cpp b/xflaim/src/fqsort.cpp index 7ff7940..c50aac7 100644 --- a/xflaim/src/fqsort.cpp +++ b/xflaim/src/fqsort.cpp @@ -35,7 +35,7 @@ FSTATIC RCODE fqGetDocId( /*************************************************************************** Desc: Add a sort key to the query. ***************************************************************************/ -RCODE XFLMAPI F_Query::addSortKey( +RCODE FLMAPI F_Query::addSortKey( void * pvSortKeyContext, FLMBOOL bChildToContext, FLMBOOL bElement, @@ -77,7 +77,7 @@ RCODE XFLMAPI F_Query::addSortKey( if (!m_pSortIxd) { - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( IXD), (void **)&m_pSortIxd))) + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( IXD), (void **)&m_pSortIxd))) { goto Exit; } @@ -90,7 +90,7 @@ RCODE XFLMAPI F_Query::addSortKey( // Allocate an ICD structure. - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( ICD), + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( ICD), (void **)&pSortIcd))) { goto Exit; @@ -400,7 +400,7 @@ RCODE F_Query::addToResultSet( void) goto Exit; } pucTmp = &ucKey [uiKeyLen]; - uiIDLen = flmEncodeSEN( ui64DocId, &pucTmp); + uiIDLen = f_encodeSEN( ui64DocId, &pucTmp); // Output a zero SEN (which is one byte) for all of the other node IDs. @@ -432,13 +432,13 @@ RCODE F_Query::addToResultSet( void) flmAssert( m_bPositioningEnabled); ui32Count++; - longToByte( ui32Count, ucKey); + f_UINT32ToByte( ui32Count, ucKey); pucTmp = &ucKey [4]; if (RC_BAD( rc = m_pCurrDoc->getDocumentId( (IF_Db *)m_pDb, &ui64DocId))) { goto Exit; } - uiIDLen = flmEncodeSEN( ui64DocId, &pucTmp); + uiIDLen = f_encodeSEN( ui64DocId, &pucTmp); if (RC_BAD( rc = m_pSortResultSet->addEntry( ucKey, uiIDLen + 4, TRUE))) { @@ -514,7 +514,7 @@ RCODE F_QueryResultSet::initResultSet( { break; } - if (rc == NE_XFLM_FILE_EXISTS || rc == NE_XFLM_IO_ACCESS_DENIED) + if (rc == NE_XFLM_FILE_EXISTS || rc == NE_FLM_IO_ACCESS_DENIED) { // Try again with a slightly altered number. @@ -1072,7 +1072,7 @@ FINLINE RCODE getRemainingTimeMilli( else { uiRemainingTimeTU = uiTimeLimitTU - uiElapsedTimeTU; - FLM_TIMER_UNITS_TO_MILLI( uiRemainingTimeTU, *puiRemainingTimeMilli); + *puiRemainingTimeMilli = FLM_TIMER_UNITS_TO_MILLI( uiRemainingTimeTU); } Exit: return( rc); @@ -1134,7 +1134,7 @@ RCODE F_Query::buildResultSet( if (uiTimeLimit) { - FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit, uiTimeLimitTU); + uiTimeLimitTU = FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit); uiStartTimeTU = FLM_GET_TIMER(); uiRemainingTimeMilli = uiTimeLimit; } @@ -1318,7 +1318,7 @@ Exit: /*************************************************************************** Desc: Stop building the result set. ***************************************************************************/ -void XFLMAPI F_Query::stopBuildingResultSet( void) +void FLMAPI F_Query::stopBuildingResultSet( void) { if (m_pSortResultSet) { @@ -1351,7 +1351,7 @@ void XFLMAPI F_Query::stopBuildingResultSet( void) Desc: Build the query result set. This is the method that applications can call. It implies enabling of positioning. ***************************************************************************/ -RCODE XFLMAPI F_Query::buildResultSet( +RCODE FLMAPI F_Query::buildResultSet( IF_Db * pDb, FLMUINT uiTimeLimit) { @@ -1475,7 +1475,7 @@ FSTATIC RCODE fqGetDocId( // Should be positioned on document ID - if (RC_BAD( rc = flmDecodeSEN64( &pucKey, pucKeyEnd, pui64DocId))) + if (RC_BAD( rc = f_decodeSEN64( &pucKey, pucKeyEnd, pui64DocId))) { goto Exit; } @@ -1493,7 +1493,7 @@ FSTATIC RCODE fqGetDocId( rc = RC_SET( NE_XFLM_BAD_COLLATED_KEY); goto Exit; } - if (RC_BAD( rc = flmDecodeSEN64( &pucKey, pucKeyEnd, pui64DocId))) + if (RC_BAD( rc = f_decodeSEN64( &pucKey, pucKeyEnd, pui64DocId))) { goto Exit; } @@ -1615,7 +1615,7 @@ RCODE F_Query::waitResultSetBuild( if (uiTimeLimit) { waiter.uiWaitStartTime = FLM_GET_TIMER(); - FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit, waiter.uiTimeLimit); + waiter.uiTimeLimit = FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit); } else { @@ -1685,7 +1685,7 @@ RCODE F_Query::getFirstFromResultSet( if (uiTimeLimit) { - FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit, uiTimeLimitTU); + uiTimeLimitTU = FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit); uiStartTimeTU = FLM_GET_TIMER(); uiRemainingTimeMilli = uiTimeLimit; } @@ -1803,7 +1803,7 @@ RCODE F_Query::getLastFromResultSet( if (uiTimeLimit) { - FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit, uiTimeLimitTU); + uiTimeLimitTU = FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit); uiStartTimeTU = FLM_GET_TIMER(); uiRemainingTimeMilli = uiTimeLimit; } @@ -1903,7 +1903,7 @@ RCODE F_Query::getNextFromResultSet( if (uiTimeLimit) { - FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit, uiTimeLimitTU); + uiTimeLimitTU = FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit); uiStartTimeTU = FLM_GET_TIMER(); uiRemainingTimeMilli = uiTimeLimit; } @@ -2061,7 +2061,7 @@ RCODE F_Query::getPrevFromResultSet( if (uiTimeLimit) { - FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit, uiTimeLimitTU); + uiTimeLimitTU = FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit); uiStartTimeTU = FLM_GET_TIMER(); uiRemainingTimeMilli = uiTimeLimit; } @@ -2256,7 +2256,7 @@ Exit: /*************************************************************************** Desc: Get previous node/document that passes query expression. ***************************************************************************/ -RCODE XFLMAPI F_Query::positionTo( +RCODE FLMAPI F_Query::positionTo( IF_Db * ifpDb, IF_DOMNode ** ppNode, FLMUINT uiTimeLimit, @@ -2283,7 +2283,7 @@ RCODE XFLMAPI F_Query::positionTo( if (uiTimeLimit) { - FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit, uiTimeLimitTU); + uiTimeLimitTU = FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit); uiStartTimeTU = FLM_GET_TIMER(); uiRemainingTimeMilli = uiTimeLimit; } @@ -2420,7 +2420,7 @@ Exit: /*************************************************************************** Desc: Get previous node/document that passes query expression. ***************************************************************************/ -RCODE XFLMAPI F_Query::positionTo( +RCODE FLMAPI F_Query::positionTo( IF_Db * ifpDb, IF_DOMNode ** ppNode, FLMUINT uiTimeLimit, @@ -2448,7 +2448,7 @@ RCODE XFLMAPI F_Query::positionTo( if (uiTimeLimit) { - FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit, uiTimeLimitTU); + uiTimeLimitTU = FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit); uiStartTimeTU = FLM_GET_TIMER(); uiRemainingTimeMilli = uiTimeLimit; } @@ -2569,7 +2569,7 @@ Exit: /*************************************************************************** Desc: Get current position. ***************************************************************************/ -RCODE XFLMAPI F_Query::getPosition( +RCODE FLMAPI F_Query::getPosition( IF_Db * ifpDb, FLMUINT * puiPosition ) @@ -2648,7 +2648,7 @@ Exit: /*************************************************************************** Desc: Get count. Only works for queries that are building result sets. ***************************************************************************/ -RCODE XFLMAPI F_Query::getCounts( +RCODE FLMAPI F_Query::getCounts( IF_Db * ifpDb, FLMUINT uiTimeLimit, FLMBOOL bPartialCountOk, diff --git a/xflaim/src/fquery.cpp b/xflaim/src/fquery.cpp index f2af386..379e18e 100644 --- a/xflaim/src/fquery.cpp +++ b/xflaim/src/fquery.cpp @@ -61,10 +61,6 @@ FINLINE FLMUINT getPrecedence( return( uiPrecedenceTable [eOperator - XFLM_AND_OP]); } -F_Pool::POOL_STATS gv_QueryPoolStats = {0,0}; - -// Local Function Prototypes - FSTATIC void fqUnlinkFromParent( FQNODE * pQNode); @@ -196,8 +192,8 @@ Desc: Constructor ***************************************************************************/ F_Query::F_Query() { - m_Pool.smartPoolInit( &gv_QueryPoolStats); - m_uiLanguage = XFLM_US_LANG; + m_pPool = NULL; + m_uiLanguage = FLM_US_LANG; m_uiCollection = XFLM_DATA_COLLECTION; initVars(); } @@ -208,7 +204,30 @@ Desc: Destructor F_Query::~F_Query() { clearQuery(); - m_Pool.poolFree(); + + if( m_pPool) + { + m_pPool->Release(); + } +} + +/*************************************************************************** +Desc: +***************************************************************************/ +RCODE F_Query::setup( void) +{ + RCODE rc = NE_XFLM_OK; + + if( RC_BAD( rc = FlmAllocPool( &m_pPool))) + { + goto Exit; + } + + m_pPool->poolInit( 1024); + +Exit: + + return( rc); } /*************************************************************************** @@ -414,13 +433,17 @@ void F_Query::initVars( void) m_ppObjectList = NULL; m_uiObjectListSize = 0; m_uiObjectCount = 0; - m_Pool.poolReset( NULL); m_bRemoveDups = FALSE; m_pDocIdSet = NULL; m_uiIndex = 0; m_bIndexSet = FALSE; m_uiTimeLimit = 0; m_uiStartTime = 0; + + if( m_pPool) + { + m_pPool->poolReset( NULL); + } } /*************************************************************************** @@ -433,7 +456,7 @@ RCODE F_Query::allocExprState( void) if (!m_pCurExprState || !m_pCurExprState->pNext) { - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( EXPR_STATE), + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( EXPR_STATE), (void **)&pExprState))) { goto Exit; @@ -471,8 +494,7 @@ Desc: Unlinks a node from its parent and siblings. This routine assumes that the test has already been made that the node has a parent. ***************************************************************************/ FSTATIC void fqUnlinkFromParent( - FQNODE * pQNode - ) + FQNODE * pQNode) { flmAssert( pQNode->pParent); if (pQNode->pPrevSib) @@ -629,7 +651,7 @@ RCODE F_Query::allocValueNode( goto Exit; } - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( FQNODE), + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( FQNODE), (void **)ppQNode))) { goto Exit; @@ -645,7 +667,7 @@ RCODE F_Query::allocValueNode( if (uiValLen && (eValType == XFLM_UTF8_VAL || eValType == XFLM_BINARY_VAL)) { - if (RC_BAD( rc = m_Pool.poolAlloc( uiValLen, + if (RC_BAD( rc = m_pPool->poolAlloc( uiValLen, (void **)&pQNode->currVal.val.pucBuf))) { goto Exit; @@ -672,7 +694,7 @@ Exit: /*************************************************************************** Desc: Adds a unicode value to the query criteria. ***************************************************************************/ -RCODE XFLMAPI F_Query::addUnicodeValue( +RCODE FLMAPI F_Query::addUnicodeValue( const FLMUNICODE * puzVal) { RCODE rc = NE_XFLM_OK; @@ -763,7 +785,7 @@ Exit: /*************************************************************************** Desc: Adds a UTF8 value to the query criteria. ***************************************************************************/ -RCODE XFLMAPI F_Query::addUTF8Value( +RCODE FLMAPI F_Query::addUTF8Value( const char * pszVal, FLMUINT uiUTF8Len) { @@ -807,7 +829,7 @@ RCODE XFLMAPI F_Query::addUTF8Value( bHaveWildCards = FALSE; for (;;) { - if (RC_BAD( rc = flmGetCharFromUTF8Buf( &pszTmp, pucEnd, &uzChar))) + if (RC_BAD( rc = f_getCharFromUTF8Buf( &pszTmp, pucEnd, &uzChar))) { goto Exit; } @@ -818,7 +840,7 @@ RCODE XFLMAPI F_Query::addUTF8Value( // Skip over the next character no matter what // because it is escaped. - if (RC_BAD( rc = flmGetCharFromUTF8Buf( &pszTmp, pucEnd, &uzChar))) + if (RC_BAD( rc = f_getCharFromUTF8Buf( &pszTmp, pucEnd, &uzChar))) { goto Exit; } @@ -872,7 +894,7 @@ Exit: /*************************************************************************** Desc: Adds a binary value to the query criteria. ***************************************************************************/ -RCODE XFLMAPI F_Query::addBinaryValue( +RCODE FLMAPI F_Query::addBinaryValue( const void * pvVal, FLMUINT uiValLen) { @@ -899,7 +921,7 @@ Exit: /*************************************************************************** Desc: Adds a UINT value to the query criteria. ***************************************************************************/ -RCODE XFLMAPI F_Query::addUINTValue( +RCODE FLMAPI F_Query::addUINTValue( FLMUINT uiVal ) { @@ -922,7 +944,7 @@ Exit: /*************************************************************************** Desc: Adds an INT value to the query criteria. ***************************************************************************/ -RCODE XFLMAPI F_Query::addINTValue( +RCODE FLMAPI F_Query::addINTValue( FLMINT iVal ) { @@ -945,7 +967,7 @@ Exit: /*************************************************************************** Desc: Adds a UINT64 value to the query criteria. ***************************************************************************/ -RCODE XFLMAPI F_Query::addUINT64Value( +RCODE FLMAPI F_Query::addUINT64Value( FLMUINT64 ui64Val ) { @@ -968,7 +990,7 @@ Exit: /*************************************************************************** Desc: Adds an INT64 value to the query criteria. ***************************************************************************/ -RCODE XFLMAPI F_Query::addINT64Value( +RCODE FLMAPI F_Query::addINT64Value( FLMINT64 i64Val ) { @@ -991,7 +1013,7 @@ Exit: /*************************************************************************** Desc: Adds a BOOL value to the query criteria. ***************************************************************************/ -RCODE XFLMAPI F_Query::addBoolean( +RCODE FLMAPI F_Query::addBoolean( FLMBOOL bVal, FLMBOOL bUnknown ) @@ -1019,7 +1041,7 @@ Exit: /*************************************************************************** Desc: Add an XPATH component ***************************************************************************/ -RCODE XFLMAPI F_Query::addXPathComponent( +RCODE FLMAPI F_Query::addXPathComponent( eXPathAxisTypes eXPathAxis, eDomNodeType eNodeType, FLMUINT uiDictNum, @@ -1080,7 +1102,7 @@ RCODE XFLMAPI F_Query::addXPathComponent( // Allocate an XPATH component - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( XPATH_COMPONENT), + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( XPATH_COMPONENT), (void **)&pXPathComponent))) { goto Exit; @@ -1111,12 +1133,12 @@ RCODE XFLMAPI F_Query::addXPathComponent( // Need to allocate a node and an XPATH - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( FQNODE), + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( FQNODE), (void **)&pQNode))) { goto Exit; } - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( FXPATH), + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( FXPATH), (void **)&pXPath))) { goto Exit; @@ -1173,16 +1195,15 @@ Desc: Keep track of objects supplied by the application that we use for callbacks, etc. ***************************************************************************/ RCODE F_Query::objectAddRef( - XF_RefCount * pObject - ) + F_Object * pObject) { - RCODE rc = NE_XFLM_OK; + RCODE rc = NE_XFLM_OK; // If object list is full, make room for 20 more if (m_uiObjectCount == m_uiObjectListSize) { - if (RC_BAD( rc = f_realloc( sizeof( XFLMIUnknown *) * + if (RC_BAD( rc = f_realloc( sizeof( F_Object *) * (m_uiObjectListSize + 20), &m_ppObjectList))) { @@ -1190,6 +1211,7 @@ RCODE F_Query::objectAddRef( } m_uiObjectListSize += 20; } + m_ppObjectList [m_uiObjectCount++] = pObject; pObject->AddRef(); @@ -1271,7 +1293,7 @@ FINLINE FLMBOOL hasContextPosTest( /*************************************************************************** Desc: Add an operator to the query expression ***************************************************************************/ -RCODE XFLMAPI F_Query::addOperator( +RCODE FLMAPI F_Query::addOperator( eQueryOperators eOperator, FLMUINT uiCompareRules, IF_OperandComparer * pOpComparer) @@ -1357,7 +1379,7 @@ RCODE XFLMAPI F_Query::addOperator( // Allocate an expression node and link it to the // function. - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( FQEXPR), + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( FQEXPR), (void **)&pQExpr))) { goto Exit; @@ -1447,7 +1469,7 @@ RCODE XFLMAPI F_Query::addOperator( // Allocate an expression node and link it to the - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( FQEXPR), + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( FQEXPR), (void **)&pQExpr))) { goto Exit; @@ -1594,7 +1616,7 @@ RCODE XFLMAPI F_Query::addOperator( // Create an AND node and link the existing expression with // this new expression as children of this new AND node. - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( FQNODE), + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( FQNODE), (void **)&pQNode))) { goto Exit; @@ -1686,7 +1708,7 @@ RCODE XFLMAPI F_Query::addOperator( // Make a QNODE and find a place for it in the query tree - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( FQNODE), + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( FQNODE), (void **)&pQNode))) { goto Exit; @@ -1813,7 +1835,7 @@ Exit: /*************************************************************************** Desc: Add a function to the query expression ***************************************************************************/ -RCODE XFLMAPI F_Query::addFunction( +RCODE FLMAPI F_Query::addFunction( eQueryFunctions eFunction, IF_QueryValFunc * pFuncObj, FLMBOOL bHaveXPathExpr) @@ -1849,12 +1871,12 @@ RCODE XFLMAPI F_Query::addFunction( // Allocate a function node - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( FQNODE), + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( FQNODE), (void **)&pQNode))) { goto Exit; } - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( FQFUNCTION), + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( FQFUNCTION), (void **)&pQFunction))) { goto Exit; @@ -2332,7 +2354,7 @@ RCODE F_Query::intersectPredicates( // Add a new predicate to the context path - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( PATH_PRED), + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( PATH_PRED), (void **)&pPred))) { goto Exit; @@ -2419,7 +2441,7 @@ Exit: { PATH_PRED_NODE * pPathPredNode; - if (RC_OK( rc = m_Pool.poolCalloc( sizeof( PATH_PRED_NODE), + if (RC_OK( rc = m_pPool->poolCalloc( sizeof( PATH_PRED_NODE), (void **)&pPathPredNode))) { pPathPredNode->pXPathNode = pXPathNode; @@ -2821,7 +2843,7 @@ RCODE F_Query::unionPredicates( // Add a new predicate to the context path - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( PATH_PRED), + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( PATH_PRED), (void **)&pPred))) { goto Exit; @@ -2908,7 +2930,7 @@ Exit: { PATH_PRED_NODE * pPathPredNode; - if (RC_OK( rc = m_Pool.poolCalloc( sizeof( PATH_PRED_NODE), + if (RC_OK( rc = m_pPool->poolCalloc( sizeof( PATH_PRED_NODE), (void **)&pPathPredNode))) { pPathPredNode->pXPathNode = pXPathNode; @@ -3061,7 +3083,7 @@ RCODE F_Query::addPredicateToContext( if (!pContextPath) { - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( CONTEXT_PATH), + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( CONTEXT_PATH), (void **)&pContextPath))) { goto Exit; @@ -3288,7 +3310,7 @@ RCODE F_Query::createOpContext( // Allocate a new context and link it in as a child // to the current context. - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( OP_CONTEXT), + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( OP_CONTEXT), (void **)&pContext))) { goto Exit; @@ -4549,6 +4571,7 @@ RCODE F_Query::optimizePredicate( FLMUINT uiTotalRefs; FLMBOOL bTotalsEstimated; FLMUINT uiCost; + IF_BufferIStream * pBufferIStream = NULL; F_AttrElmInfo defInfo; // Special handling for app. defined source nodes @@ -4948,16 +4971,20 @@ RCODE F_Query::optimizePredicate( pIcd->uiFlags & ICD_METAPHONE && pPred->pFromValue->eValType == XFLM_UTF8_VAL) { - F_BufferIStream bufferIStream; FLMUINT uiMeta; FLMUINT uiAltMeta; FQVALUE metaValue; FQVALUE * pSaveValue = pPred->pFromValue; FLMUINT uiMetaCost; + + if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferIStream))) + { + goto Exit; + } uiCost = 0; - if (RC_BAD( rc = bufferIStream.open( - pPred->pFromValue->val.pucBuf, + if (RC_BAD( rc = pBufferIStream->open( + (const char *)pPred->pFromValue->val.pucBuf, pPred->pFromValue->uiDataLen))) { goto Exit; @@ -4972,8 +4999,8 @@ RCODE F_Query::optimizePredicate( metaValue.eValType = XFLM_UTF8_VAL; for (;;) { - if( RC_BAD( rc = flmGetNextMetaphone( - &bufferIStream, &uiMeta, &uiAltMeta))) + if( RC_BAD( rc = f_getNextMetaphone( + pBufferIStream, &uiMeta, &uiAltMeta))) { if (rc != NE_XFLM_EOF_HIT) { @@ -5046,6 +5073,13 @@ RCODE F_Query::optimizePredicate( } } } + + if( pBufferIStream) + { + pBufferIStream->Release(); + pBufferIStream = NULL; + } + bTmpCanCompareOnKey = FALSE; bDoNodeMatch = TRUE; } @@ -5149,6 +5183,12 @@ RCODE F_Query::optimizePredicate( Exit: + if( pBufferIStream) + { + pBufferIStream->Release(); + pBufferIStream = NULL; + } + if (pFSIndexCursor) { pFSIndexCursor->Release(); @@ -6552,7 +6592,7 @@ RCODE F_Query::getNodeSourceNode( } else { - FLM_TIMER_UNITS_TO_MILLI( (m_uiTimeLimit - uiElapsedTime), uiTimeLimit); + uiTimeLimit = FLM_TIMER_UNITS_TO_MILLI( (m_uiTimeLimit - uiElapsedTime)); // Always give at least one milli-second. @@ -9163,8 +9203,7 @@ RCODE F_Query::getNextFunctionValue( IF_DOMNode * pContextNode, FLMBOOL bForward, FQNODE * pCurrNode, - F_DynaBuf * pDynaBuf - ) + IF_DynaBuf * pDynaBuf) { RCODE rc = NE_XFLM_OK; ValIterator eIterator; @@ -9208,7 +9247,7 @@ RCODE F_Query::getNextFunctionValue( pDynaBuf->truncateData( 0); if (RC_BAD( rc = pCurrNode->nd.pQFunction->pFuncObj->getValue( (IF_Db *)m_pDb, pNode, eIterator, &pCurrNode->currVal.eValType, - &pCurrNode->bLastValue, &ucValBuf, (IF_DynaBuf *)pDynaBuf))) + &pCurrNode->bLastValue, ucValBuf, (IF_DynaBuf *)pDynaBuf))) { goto Exit; } @@ -9554,11 +9593,10 @@ RCODE F_Query::getFuncValue( FLMBOOL bForward, FQNODE ** ppCurrNode, FLMBOOL * pbGetNodeValue, - F_DynaBuf * pDynaBuf - ) + IF_DynaBuf * pDynaBuf) { - RCODE rc = NE_XFLM_OK; - FQNODE * pCurrNode = *ppCurrNode; + RCODE rc = NE_XFLM_OK; + FQNODE * pCurrNode = *ppCurrNode; // We currently only support user-defined functions. @@ -10089,7 +10127,7 @@ FSTATIC void fqReleaseQueryExpr( /*************************************************************************** Desc: Release the resources of a query ***************************************************************************/ -void XFLMAPI F_Query::resetQuery( void) +void FLMAPI F_Query::resetQuery( void) { if (m_pQuery) { @@ -10451,7 +10489,7 @@ RCODE F_Query::getAppNode( } else { - FLM_TIMER_UNITS_TO_MILLI( (m_uiTimeLimit - uiElapsedTime), uiTimeLimit); + uiTimeLimit = FLM_TIMER_UNITS_TO_MILLI( (m_uiTimeLimit - uiElapsedTime)); // Always give at least one milli-second. @@ -10791,8 +10829,7 @@ RCODE F_Query::testKey( F_DataVector * pKey, PATH_PRED * pPred, FLMBOOL * pbPasses, - IF_DOMNode ** ppPassedNode - ) + IF_DOMNode ** ppPassedNode) { RCODE rc = NE_XFLM_OK; FLMUINT64 ui64NodeId; @@ -12594,7 +12631,7 @@ Exit: /*************************************************************************** Desc: Get first node/document that passes query expression. ***************************************************************************/ -RCODE XFLMAPI F_Query::getFirst( +RCODE FLMAPI F_Query::getFirst( IF_Db * ifpDb, IF_DOMNode ** ppNode, FLMUINT uiTimeLimit @@ -12691,7 +12728,7 @@ RCODE XFLMAPI F_Query::getFirst( if ((m_uiTimeLimit = uiTimeLimit) != 0) { - FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit, m_uiTimeLimit); + m_uiTimeLimit = FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit); m_uiStartTime = FLM_GET_TIMER(); } if (m_bScan) @@ -12782,7 +12819,7 @@ Exit: /*************************************************************************** Desc: Get last node/document that passes query expression. ***************************************************************************/ -RCODE XFLMAPI F_Query::getLast( +RCODE FLMAPI F_Query::getLast( IF_Db * ifpDb, IF_DOMNode ** ppNode, FLMUINT uiTimeLimit @@ -12877,7 +12914,7 @@ RCODE XFLMAPI F_Query::getLast( if ((m_uiTimeLimit = uiTimeLimit) != 0) { - FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit, m_uiTimeLimit); + m_uiTimeLimit = FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit); m_uiStartTime = FLM_GET_TIMER(); } if (m_bScan) @@ -12968,7 +13005,7 @@ Exit: /*************************************************************************** Desc: Get next node/document that passes query expression. ***************************************************************************/ -RCODE XFLMAPI F_Query::getNext( +RCODE FLMAPI F_Query::getNext( IF_Db * ifpDb, IF_DOMNode ** ppNode, FLMUINT uiTimeLimit, @@ -13088,7 +13125,7 @@ RCODE XFLMAPI F_Query::getNext( if ((m_uiTimeLimit = uiTimeLimit) != 0) { - FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit, m_uiTimeLimit); + m_uiTimeLimit = FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit); m_uiStartTime = FLM_GET_TIMER(); } if (m_bScan || m_bScanIndex) @@ -13141,7 +13178,7 @@ Exit: /*************************************************************************** Desc: Get previous node/document that passes query expression. ***************************************************************************/ -RCODE XFLMAPI F_Query::getPrev( +RCODE FLMAPI F_Query::getPrev( IF_Db * ifpDb, IF_DOMNode ** ppNode, FLMUINT uiTimeLimit, @@ -13261,7 +13298,7 @@ RCODE XFLMAPI F_Query::getPrev( if ((m_uiTimeLimit = uiTimeLimit) != 0) { - FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit, m_uiTimeLimit); + m_uiTimeLimit = FLM_MILLI_TO_TIMER_UNITS( uiTimeLimit); m_uiStartTime = FLM_GET_TIMER(); } if (m_bScan || m_bScanIndex) @@ -13314,7 +13351,7 @@ Exit: /*************************************************************************** Desc: Get current document that passes query expression. ***************************************************************************/ -RCODE XFLMAPI F_Query::getCurrent( +RCODE FLMAPI F_Query::getCurrent( IF_Db * ifpDb, IF_DOMNode ** ppNode) { @@ -13429,7 +13466,7 @@ Exit: /*************************************************************************** Desc: Get statistics and optimization information. ***************************************************************************/ -RCODE XFLMAPI F_Query::getStatsAndOptInfo( +RCODE FLMAPI F_Query::getStatsAndOptInfo( FLMUINT * puiNumOptInfos, XFLM_OPT_INFO ** ppOptInfo) { @@ -13533,7 +13570,7 @@ Exit: /*************************************************************************** Desc: Free the optimization info structure. ***************************************************************************/ -void XFLMAPI F_Query::freeStatsAndOptInfo( +void FLMAPI F_Query::freeStatsAndOptInfo( XFLM_OPT_INFO ** ppOptInfo) { if (*ppOptInfo) @@ -13546,19 +13583,33 @@ void XFLMAPI F_Query::freeStatsAndOptInfo( /**************************************************************************** Desc: Create an empty query object and return it's interface... ****************************************************************************/ -RCODE XFLMAPI F_DbSystem::createIFQuery( - IF_Query ** ppQuery) +RCODE FLMAPI F_DbSystem::createIFQuery( + IF_Query ** ppQuery) { - RCODE rc = NE_XFLM_OK; + RCODE rc = NE_XFLM_OK; + F_Query * pQuery = NULL; - if ((*ppQuery = f_new F_Query) == NULL) + if ((pQuery = f_new F_Query) == NULL) { rc = RC_SET( NE_XFLM_MEM); goto Exit; } + if( RC_BAD( rc = pQuery->setup())) + { + goto Exit; + } + + *ppQuery = pQuery; + pQuery = NULL; + Exit: + if( pQuery) + { + pQuery->Release(); + } + return( rc); } @@ -13647,7 +13698,7 @@ RCODE F_Query::allocDupCheckSet( void) } if (RC_BAD( rc = dbSystem.getTempDir( szTmpDir))) { - if (rc == NE_XFLM_IO_PATH_NOT_FOUND) + if (rc == NE_FLM_IO_PATH_NOT_FOUND) { rc = NE_XFLM_OK; } @@ -13659,7 +13710,7 @@ RCODE F_Query::allocDupCheckSet( void) if (!szTmpDir [0]) { - if (RC_BAD( rc = gv_pFileSystem->pathReduce( + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathReduce( m_pDb->m_pDatabase->m_pszDbPath, szTmpDir, NULL))) { goto Exit; @@ -13743,7 +13794,7 @@ Exit: /**************************************************************************** Desc: Setup duplicate handling for a query. ****************************************************************************/ -void XFLMAPI F_Query::setDupHandling( +void FLMAPI F_Query::setDupHandling( FLMBOOL bRemoveDups ) { @@ -13761,7 +13812,7 @@ void XFLMAPI F_Query::setDupHandling( /**************************************************************************** Desc: Set an index for the query. ****************************************************************************/ -RCODE XFLMAPI F_Query::setIndex( +RCODE FLMAPI F_Query::setIndex( FLMUINT uiIndex ) { @@ -13785,7 +13836,7 @@ Exit: /**************************************************************************** Desc: Set an index for the query. ****************************************************************************/ -RCODE XFLMAPI F_Query::getIndex( +RCODE FLMAPI F_Query::getIndex( IF_Db * ifpDb, FLMUINT * puiIndex, FLMBOOL * pbHaveMultiple @@ -13955,7 +14006,7 @@ RCODE F_Query::copyValue( case XFLM_UTF8_VAL: if (pDestValue->uiDataLen) { - if (RC_BAD( rc = m_Pool.poolAlloc( pDestValue->uiDataLen, + if (RC_BAD( rc = m_pPool->poolAlloc( pDestValue->uiDataLen, (void **)&pDestValue->val.pucBuf))) { goto Exit; @@ -13988,7 +14039,7 @@ RCODE F_Query::copyXPath( XPATH_COMPONENT * pXPathComponent; XPATH_COMPONENT * pTmpXPathComponent; - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( FXPATH), + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( FXPATH), (void **)&pDestXPath))) { goto Exit; @@ -13997,7 +14048,7 @@ RCODE F_Query::copyXPath( pXPathComponent = pSrcXPath->pFirstComponent; while (pXPathComponent) { - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( XPATH_COMPONENT), + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( XPATH_COMPONENT), (void **)&pTmpXPathComponent))) { goto Exit; @@ -14076,7 +14127,7 @@ RCODE F_Query::copyFunction( FQEXPR * pExpr; FQEXPR * pTmpExpr; - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( FQFUNCTION), + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( FQFUNCTION), (void **)&pDestFunc))) { goto Exit; @@ -14107,7 +14158,7 @@ RCODE F_Query::copyFunction( pExpr = pSrcFunc->pFirstArg; while (pExpr) { - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( FQEXPR), + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( FQEXPR), (void **)&pTmpExpr))) { goto Exit; @@ -14146,7 +14197,7 @@ RCODE F_Query::copyNode( RCODE rc = NE_XFLM_OK; FQNODE * pDestNode; - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( FQNODE), (void **)&pDestNode))) + if (RC_BAD( rc = m_pPool->poolCalloc( sizeof( FQNODE), (void **)&pDestNode))) { goto Exit; } @@ -14281,7 +14332,7 @@ Exit: /**************************************************************************** Desc: Copy criteria from another query object. ****************************************************************************/ -RCODE XFLMAPI F_Query::copyCriteria( +RCODE FLMAPI F_Query::copyCriteria( IF_Query * pSrcQuery ) { diff --git a/xflaim/src/frecread.cpp b/xflaim/src/frecread.cpp deleted file mode 100644 index b239a5d..0000000 --- a/xflaim/src/frecread.cpp +++ /dev/null @@ -1,5718 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Routines for reading records from FLXIM 4.x databases -// -// Tabs: 3 -// -// Copyright (c) 2003-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: frecread.cpp 3114 2006-01-19 13:22:45 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -static FLMBYTE gv_ucMaxBcdINT32[] = {0x21, 0x47, 0x48, 0x36, 0x47}; -static FLMBYTE gv_ucMinBcdINT32[] = {0xB2, 0x14, 0x74, 0x83, 0x64, 0x8F}; -static FLMBYTE gv_ucMaxBcdUINT32[] = {0x42, 0x94, 0x96, 0x72, 0x95}; - -typedef struct -{ - const char * pszTagName; - FLMUINT uiTagNum; - FLMUINT uiFieldType; -} FLM_4x_DICT_TAG_INFO; - -FLM_4x_DICT_TAG_INFO Flm4xDictTagInfo[] = -{ - {FLM_4x_FIELD_TAG_NAME, FLM_4x_FIELD_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_INDEX_TAG_NAME, FLM_4x_INDEX_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_TYPE_TAG_NAME, FLM_4x_TYPE_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_CONTAINER_TAG_NAME, FLM_4x_CONTAINER_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_LANGUAGE_TAG_NAME, FLM_4x_LANGUAGE_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_OPTIONAL_TAG_NAME, FLM_4x_OPTIONAL_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_UNIQUE_TAG_NAME, FLM_4x_UNIQUE_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_KEY_TAG_NAME, FLM_4x_KEY_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_REFS_TAG_NAME, FLM_4x_REFS_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_AREA_TAG_NAME, FLM_4x_AREA_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_STATE_TAG_NAME, FLM_4x_STATE_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_BLOB_TAG_NAME, FLM_4x_BLOB_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_THRESHOLD_TAG_NAME, FLM_4x_THRESHOLD_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_SUFFIX_TAG_NAME, FLM_4x_SUFFIX_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_SUBDIRECTORY_TAG_NAME, FLM_4x_SUBDIRECTORY_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_RESERVED_TAG_NAME, FLM_4x_RESERVED_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_SUBNAME_TAG_NAME, FLM_4x_SUBNAME_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_NAME_TAG_NAME, FLM_4x_NAME_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_BASE_TAG_NAME, FLM_4x_BASE_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_CASE_TAG_NAME, FLM_4x_CASE_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_COMBINATIONS_TAG_NAME, FLM_4x_COMBINATIONS_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_COUNT_TAG_NAME, FLM_4x_COUNT_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_POSITIONING_TAG_NAME, FLM_4x_POSITIONING_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_PAIRED_TAG_NAME, FLM_4x_PAIRED_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_PARENT_TAG_NAME, FLM_4x_PARENT_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_POST_TAG_NAME, FLM_4x_POST_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_REQUIRED_TAG_NAME, FLM_4x_REQUIRED_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_USE_TAG_NAME, FLM_4x_USE_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_FILTER_TAG_NAME, FLM_4x_FILTER_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_LIMIT_TAG_NAME, FLM_4x_LIMIT_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_DICT_TAG_NAME, FLM_4x_DICT_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_RECINFO_TAG_NAME, FLM_4x_RECINFO_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_DRN_TAG_NAME, FLM_4x_DRN_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_DICT_SEQ_TAG_NAME, FLM_4x_DICT_SEQ_TAG, FLM_4x_TEXT_TYPE}, - {FLM_4x_LAST_CONTAINER_INDEXED_TAG_NAME, FLM_4x_LAST_CONTAINER_INDEXED_TAG, FLM_4x_NUMBER_TYPE}, - {FLM_4x_LAST_DRN_INDEXED_TAG_NAME, FLM_4x_LAST_DRN_INDEXED_TAG, FLM_4x_NUMBER_TYPE}, - {FLM_4x_ONLINE_TRANS_ID_TAG_NAME, FLM_4x_ONLINE_TRANS_ID_TAG, FLM_4x_NUMBER_TYPE}, - {NULL, 0} -}; - -/*************************************************************************** -Desc: -****************************************************************************/ -F_4xReader::F_4xReader() -{ - m_tmpPool.poolInit( 32 * 1024); - m_pSuperHdl = NULL; - m_pLckFile = NULL; - m_uiMaxFileSize = 0; - m_pLFileTbl = NULL; - m_uiLFileCnt = 0; - m_uiFieldTblSize = 0; - m_puiFieldTbl = NULL; - m_ppBlockTbl = NULL; - m_uiBlockTblSize = 0; - m_uiDefaultContainer = 0; - m_pNameTable = NULL; - f_memset( &m_fileHdr, 0, sizeof( F_4x_FILE_HDR)); - f_memset( &m_logHdr, 0, sizeof( F_4x_LOG_HDR)); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -F_4xReader::~F_4xReader() -{ - closeDatabase(); - m_tmpPool.poolFree(); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_4xReader::openDatabase( - char * pszPath) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE * pucReadBuf = NULL; - FLMBYTE * pucPrefix; - FLMBYTE * pucFileHdr; - FLMBYTE * pucLogHdr; - FLMUINT uiBytesRead; - FLMUINT uiTmp; - F_FileHdl * pFileHdl = NULL; - - flmAssert( !m_pSuperHdl); - - if( (m_pSuperHdl = f_new F_SuperFileHdl) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = m_pSuperHdl->Setup( NULL, pszPath, NULL))) - { - goto Exit; - } - - // We must have exclusive access. - - if( RC_BAD( rc = createLckFile( pszPath))) - { - goto Exit; - } - - // Read and verify the file and log headers. - - if( RC_BAD( rc = m_pSuperHdl->GetFileHdl( 0, FALSE, - (IF_FileHdl **)&pFileHdl))) - { - goto Exit; - } - - if( RC_BAD( rc = f_alloc( 2048, &pucReadBuf))) - { - goto Exit; - } - - // Read the fixed information area - - if( RC_BAD( rc = pFileHdl->Read( 0, 2048, pucReadBuf, &uiBytesRead))) - { - goto Exit; - } - - *pucReadBuf = 0xFF; - pucPrefix = pucReadBuf; - pucFileHdr = &pucReadBuf[ FLM_4x_FLAIM_HEADER_START]; - - // Make sure we have a valid prefix - - if( pucPrefix[ 1] != f_toascii('W') || - pucPrefix[ 2] != f_toascii('P') || - pucPrefix[ 3] != f_toascii('C')) - { - rc = RC_SET( NE_XFLM_NOT_FLAIM); - goto Exit; - } - - // Extract the file header info - - m_fileHdr.uiBlockSize = (FLMUINT)FB2UW( &pucFileHdr[ FLM_4x_DB_BLOCK_SIZE]); - m_fileHdr.uiAppMajorVer = pucPrefix[ 10]; - m_fileHdr.uiAppMinorVer = pucPrefix[ 11]; - m_fileHdr.uiDefaultLanguage = pucFileHdr[ FLM_4x_DB_DEFAULT_LANGUAGE]; - m_fileHdr.uiVersionNum = - ((FLMUINT16)(pucFileHdr[ FLM_4x_VER_POS] - ASCII_ZERO) * 100 + - (FLMUINT16)(pucFileHdr[ FLM_4x_MINOR_VER_POS] - ASCII_ZERO) * 10 + - (FLMUINT16)(pucFileHdr[ FLM_4x_SMINOR_VER_POS] - ASCII_ZERO)); - - // Is the block size valid? - - if( m_fileHdr.uiBlockSize != 4096 && - m_fileHdr.uiBlockSize != 8192) - { - rc = RC_SET( NE_XFLM_DATA_ERROR); - goto Exit; - } - - // Supported version? - - switch( m_fileHdr.uiVersionNum) - { - case FLM_VER_4_0: - case FLM_VER_4_3: - case FLM_VER_4_31: - case FLM_VER_4_50: - case FLM_VER_4_51: - break; - default: - rc = RC_SET( NE_XFLM_UNSUPPORTED_VERSION); - goto Exit; - } - - // Get other log header elements. - - m_fileHdr.uiFirstLFHBlkAddr = - (FLMUINT)FB2UD( &pucFileHdr[ FLM_4x_DB_1ST_LFH_ADDR]); - - if( pucFileHdr[ FLM_4x_FLAIM_NAME_POS ] != f_toascii( 'F') || - pucFileHdr[ FLM_4x_FLAIM_NAME_POS + 1 ] != f_toascii( 'L') || - pucFileHdr[ FLM_4x_FLAIM_NAME_POS + 2 ] != f_toascii( 'A') || - pucFileHdr[ FLM_4x_FLAIM_NAME_POS + 3 ] != f_toascii( 'I') || - pucFileHdr[ FLM_4x_FLAIM_NAME_POS + 4 ] != f_toascii( 'M')) - { - rc = RC_SET( NE_XFLM_NOT_FLAIM); - goto Exit; - } - - // Set up the uiSigBitsInBlkSize member of the file - // header - - m_fileHdr.uiSigBitsInBlkSize = 0; - uiTmp = m_fileHdr.uiBlockSize; - while( !(uiTmp & 0x0001)) - { - m_fileHdr.uiSigBitsInBlkSize++; - uiTmp >>= 1; - } - - // Get the log file header information - - pucLogHdr = &pucReadBuf[ FLM_4x_DB_LOG_HEADER_START]; - - // Verify the checksums in the log header - - if( lgHdrCheckSum( pucLogHdr, TRUE) != 0) - { - rc = RC_SET( NE_XFLM_BLOCK_CRC); - goto Exit; - } - - m_logHdr.uiCurrTransID = - (FLMUINT)FB2UD( &pucLogHdr[ FLM_4x_LOG_CURR_TRANS_ID]); - - m_logHdr.uiLogicalEOF = - (FLMUINT)FB2UD( &pucLogHdr[ FLM_4x_LOG_LOGICAL_EOF]); - - m_logHdr.uiFirstAvailBlkAddr = - (FLMUINT)FB2UD( &pucLogHdr[ FLM_4x_LOG_PF_AVAIL_BLKS]); - - m_logHdr.uiAvailBlkCount = - (FLMUINT)FB2UD( &pucLogHdr[ FLM_4x_LOG_PF_NUM_AVAIL_BLKS]); - - // Get the maximum file size - - if( m_fileHdr.uiVersionNum >= FLM_VER_4_3) - { - m_uiMaxFileSize = (FLMUINT)(FB2UW(&((pucLogHdr)[ - FLM_4x_LOG_MAX_FILE_SIZE]))) << 16; - } - else - { - m_uiMaxFileSize = 0x7FF00000; - } - - // Make sure that no recovery needs to be done. - - if( (FLMUINT)FB2UD( &pucLogHdr[ FLM_4x_LOG_ROLLBACK_EOF]) != - m_fileHdr.uiBlockSize || - (FLMUINT)FB2UD( &pucLogHdr[ FLM_4x_LOG_PL_FIRST_CP_BLOCK_ADDR])) - { - rc = RC_SET( NE_XFLM_ILLEGAL_OP); - goto Exit; - } - - // Set the block size - - m_pSuperHdl->ReleaseFile( (FLMUINT)0, TRUE); - m_pSuperHdl->SetBlockSize( m_fileHdr.uiBlockSize); - - // Set up the block table - - m_uiBlockTblSize = 1024; - if( RC_BAD( rc = f_calloc( - sizeof( F_Block *) * m_uiBlockTblSize, &m_ppBlockTbl))) - { - m_uiBlockTblSize = 0; - goto Exit; - } - - // Set the default container - - m_uiDefaultContainer = FLM_4x_DATA_CONTAINER;; - - // Read the LFile table - - if( RC_BAD( rc = readLFiles())) - { - goto Exit; - } - - // Read the dictionary - - if( RC_BAD( rc = readDictionary())) - { - goto Exit; - } - -Exit: - - if( pFileHdl) - { - m_pSuperHdl->ReleaseFile( (FLMUINT)0, TRUE); - } - - if( pucReadBuf) - { - f_free( &pucReadBuf); - } - - if( RC_BAD( rc)) - { - closeDatabase(); - } - - return( rc); -} - -/******************************************************************** -Desc: -*********************************************************************/ -FLMUINT F_4xReader::lgHdrCheckSum( - FLMBYTE * pucLogHdr, - FLMBOOL bCompare) -{ - FLMUINT uiCnt; - FLMUINT uiTempSum; - FLMUINT uiCurrCheckSum; - FLMUINT uiTempSum2; - FLMUINT uiBytesToChecksum; - - uiBytesToChecksum = (FB2UW( &pucLogHdr[ - FLM_4x_LOG_FLAIM_VERSION]) < FLM_VER_4_3) - ? 88 - : 156; - - if( (uiCurrCheckSum = (FLMUINT)FB2UW( - &pucLogHdr[ FLM_4x_LOG_HDR_CHECKSUM])) == 0xFFFF) - { - uiCurrCheckSum = 0; - } - - if( bCompare && !uiCurrCheckSum) - { - return( 0); - } - - for( uiTempSum = 0 - (FLMUINT)FB2UW( &pucLogHdr[ FLM_4x_LOG_HDR_CHECKSUM]), - uiCnt = 1 + uiBytesToChecksum / sizeof( FLMUINT16); --uiCnt != 0;) - { - uiTempSum += (FLMUINT)FB2UW( pucLogHdr); - pucLogHdr += sizeof( FLMUINT16); - } - - if( (0 == (uiTempSum2 = (uiTempSum & 0xFFFF))) || (uiTempSum2 == 0xFFFF)) - { - uiTempSum2 = 1; - } - - return( (FLMUINT)(((bCompare) && (uiTempSum2 == uiCurrCheckSum)) - ? (FLMUINT)0 - : uiTempSum2) ); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_4xReader::createLckFile( - char * pszFilePath) -{ - RCODE rc = NE_XFLM_OK; - char szLockPath[ F_PATH_MAX_SIZE]; - char szDbBaseName[ F_FILENAME_SIZE]; - char * pszFileExt; - F_FileHdl * pLockFileHdl = NULL; - - // Extract the 8.3 name and put a .lck extension on it to create - // the full path for the .lck file. - - if( RC_BAD( rc = gv_pFileSystem->pathReduce( - pszFilePath, szLockPath, szDbBaseName))) - { - goto Exit; - } - - pszFileExt = &szDbBaseName[ 0]; - - while( (*pszFileExt) && (*pszFileExt != '.')) - { - pszFileExt++; - } - - f_strcpy( pszFileExt, ".lck"); - - if (RC_BAD( rc = gv_pFileSystem->pathAppend( szLockPath, szDbBaseName))) - { - goto Exit; - } - - if( (pLockFileHdl = f_new F_FileHdl) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - -#ifndef FLM_UNIX - pLockFileHdl->setupFileHdl( 0, TRUE); -#else - - // On Unix, we do not want to delete the file because it - // will succeed even if someone else has the file open. - - pLockFileHdl->setupFileHdl( 0, FALSE); -#endif - - if( RC_BAD( pLockFileHdl->Create( szLockPath, - XFLM_IO_RDWR | XFLM_IO_EXCL | XFLM_IO_SH_DENYRW))) - { -#ifndef FLM_UNIX - if (RC_BAD( gv_pFileSystem->Delete( szLockPath))) - { - rc = RC_SET( NE_XFLM_IO_ACCESS_DENIED); - goto Exit; - } - else if (RC_BAD( pLockFileHdl->Create( szLockPath, - XFLM_IO_RDWR | XFLM_IO_EXCL | XFLM_IO_SH_DENYRW))) - { - rc = RC_SET( NE_XFLM_IO_ACCESS_DENIED); - goto Exit; - } -#else - - if( RC_BAD( pLockFileHdl->Open( szLockPath, - XFLM_IO_RDWR | XFLM_IO_SH_DENYRW))) - { - rc = RC_SET( NE_XFLM_IO_ACCESS_DENIED); - goto Exit; - } -#endif - } - -#ifdef FLM_UNIX - if( RC_BAD( pLockFileHdl->Lock())) - { - rc = RC_SET( NE_XFLM_IO_ACCESS_DENIED); - goto Exit; - } -#endif - - m_pLckFile = pLockFileHdl; - pLockFileHdl = NULL; - -Exit: - - if (pLockFileHdl) - { - pLockFileHdl->Close(); - pLockFileHdl->Release(); - } - - return( rc); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -void F_4xReader::closeDatabase( void) -{ - FLMUINT uiLoop; - - m_tmpPool.poolReset( NULL); - - if( m_pLckFile) - { - m_pLckFile->Release(); - m_pLckFile = NULL; - } - - if( m_pSuperHdl) - { - m_pSuperHdl->Release(); - } - - if( m_pLFileTbl) - { - f_free( &m_pLFileTbl); - m_pLFileTbl = NULL; - } - m_uiLFileCnt = 0; - - if( m_puiFieldTbl) - { - f_free( &m_puiFieldTbl); - m_puiFieldTbl = NULL; - } - m_uiFieldTblSize = 0; - - if( m_ppBlockTbl) - { - for( uiLoop = 0; uiLoop < m_uiBlockTblSize; uiLoop++) - { - if( m_ppBlockTbl[ uiLoop]) - { - m_ppBlockTbl[ uiLoop]->Release(); - } - } - - f_free( &m_ppBlockTbl); - } - m_uiBlockTblSize = 0; - - if( m_pNameTable) - { - m_pNameTable->Release(); - m_pNameTable = NULL; - } - - m_uiMaxFileSize = 0; - f_memset( &m_fileHdr, 0, sizeof( F_4x_FILE_HDR)); - f_memset( &m_logHdr, 0, sizeof( F_4x_LOG_HDR)); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_4xReader::readLFiles( void) -{ - RCODE rc = NE_XFLM_OK; - F_Block * pBlock = NULL; - FLMBYTE * pucBlk; - FLMUINT uiBlkAddress; - FLMUINT uiPos; - FLMUINT uiEndPos; - FLMUINT uiEstCount; - FLMUINT uiLFileCnt; - FLMUINT uiLFHCnt; - FLMUINT uiBlkSize = m_fileHdr.uiBlockSize; - F_4x_LFILE TmpLFile; - F_4x_LFILE * pLFile; - F_4x_LFILE * pLFiles = NULL; - - f_memset( &TmpLFile, 0, sizeof( F_4x_LFILE)); - - for( uiEstCount = 0, uiLFileCnt = 4, - uiBlkAddress = m_fileHdr.uiFirstLFHBlkAddr; - uiBlkAddress != FLM_4x_BT_END;) - { - if( RC_BAD( rc = readBlock( uiBlkAddress, &pBlock))) - { - goto Exit; - } - - pucBlk = pBlock->m_pucBlk; - uiPos = FLM_4x_BH_OVHD; - - if( (uiEndPos = (FLMUINT)FB2UW( - &pucBlk[ FLM_4x_BH_ELM_END])) <= FLM_4x_BH_OVHD) - { - uiEndPos = FLM_4x_BH_OVHD; - uiLFHCnt = 0; - } - else - { - if( uiEndPos > uiBlkSize) - { - uiEndPos = uiBlkSize; - } - - uiLFHCnt = (FLMUINT)((uiEndPos - FLM_4x_BH_OVHD) / FLM_4x_LFH_SIZE); - uiEndPos = (FLMUINT)(FLM_4x_BH_OVHD + uiLFHCnt * FLM_4x_LFH_SIZE); - } - - // May allocate too many like the inactive ones but OK for now. - // Allocate an additional 2 for the default data and dict containers. - - if( !uiEstCount) - { - uiEstCount = uiLFHCnt + uiLFileCnt; - if( uiEstCount) - { - if( RC_BAD( rc = f_calloc( - uiEstCount * sizeof( F_4x_LFILE), &pLFiles))) - { - goto Exit; - } - } - } - else if( uiLFHCnt) - { - uiEstCount += uiLFHCnt; - - if( RC_BAD(rc = f_recalloc( uiEstCount * sizeof( F_4x_LFILE), - &pLFiles))) - { - goto Exit; - } - } - - // Read through all of the logical file definitions in the block - - for( ; uiPos < uiEndPos; uiPos += FLM_4x_LFH_SIZE) - { - FLMUINT uiLfNum; - - // Have to fix up the offsets later when they are read in - - TmpLFile.uiBlkAddress = uiBlkAddress; - TmpLFile.uiOffsetInBlk = uiPos; - - if( (TmpLFile.uiLfType = - (FLMUINT)pucBlk[ uiPos + FLM_4x_LFH_TYPE_OFFSET]) == FLM_4x_LF_INVALID) - { - TmpLFile.uiLfType = FLM_4x_LF_INVALID; - continue; - } - - TmpLFile.uiLfNum = - (FLMUINT)FB2UW( &pucBlk[ uiPos + FLM_4x_LFH_LF_NUMBER_OFFSET]); - - TmpLFile.uiRootBlk = - (FLMUINT)FB2UD( &pucBlk[ uiPos + FLM_4x_LFH_ROOT_BLK_OFFSET]); - - TmpLFile.uiNextDrn = - (FLMUINT) FB2UD( &pucBlk[ uiPos + FLM_4x_LFH_NEXT_DRN_OFFSET]); - - uiLfNum = TmpLFile.uiLfNum; - - if( uiLfNum == FLM_4x_DATA_CONTAINER) - { - pLFile = pLFiles + FLM_4x_LFILE_DATA_CONTAINER_OFFSET; - } - else if( uiLfNum == FLM_4x_DICT_CONTAINER) - { - pLFile = pLFiles + FLM_4x_LFILE_DICT_CONTAINER_OFFSET; - } - else if( uiLfNum == FLM_4x_DICT_INDEX) - { - pLFile = pLFiles + FLM_4x_LFILE_DICT_INDEX_OFFSET; - } - else if( uiLfNum == FLM_4x_TRACKER_CONTAINER) - { - pLFile = pLFiles + FLM_4x_LFILE_TRACKER_CONTAINER_OFFSET; - } - else - { - pLFile = pLFiles + uiLFileCnt++; - } - f_memcpy( pLFile, &TmpLFile, sizeof( F_4x_LFILE)); - } - - // Get the next block in the chain - - uiBlkAddress = (FLMUINT)FB2UD( &pucBlk[ FLM_4x_BH_NEXT_BLK]); - } - - m_pLFileTbl = pLFiles; - m_uiLFileCnt = uiLFileCnt; - pLFiles = NULL; - -Exit: - - if( pBlock) - { - pBlock->Release(); - } - - if( pLFiles) - { - f_free( &pLFiles); - } - - return( rc ); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_4xReader::getLFile( - FLMUINT uiLFile, - F_4x_LFILE ** ppLFile) -{ - RCODE rc = NE_XFLM_OK; - F_4x_LFILE * pLFile = NULL; - FLMUINT uiLoop; - - if( uiLFile == FLM_4x_DATA_CONTAINER) - { - pLFile = &m_pLFileTbl[ FLM_4x_LFILE_DATA_CONTAINER_OFFSET]; - } - else if( uiLFile == FLM_4x_DICT_CONTAINER) - { - pLFile = &m_pLFileTbl[ FLM_4x_LFILE_DICT_CONTAINER_OFFSET]; - } - else if( uiLFile == FLM_4x_TRACKER_CONTAINER) - { - pLFile = &m_pLFileTbl[ FLM_4x_LFILE_TRACKER_CONTAINER_OFFSET]; - } - else - { - for( uiLoop = 0; uiLoop < m_uiLFileCnt; uiLoop++) - { - if( m_pLFileTbl[ uiLoop].uiLfNum == uiLFile) - { - pLFile = &m_pLFileTbl[ uiLoop]; - break; - } - } - } - - if( !pLFile) - { - rc = RC_SET( NE_XFLM_BAD_COLLECTION); - goto Exit; - } - - *ppLFile = pLFile; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE F_4xReader::getNextDrn( - FLMUINT uiContainer, - FLMUINT * puiDrn) -{ - RCODE rc = NE_XFLM_OK; - BTSK stackBuf[ FLM_4x_BH_MAX_LEVELS ]; - BTSK * pStack = stackBuf; - FLMBYTE * pucElm; - FLMBOOL bUsedStack = FALSE; - F_4x_LFILE * pLFile; - - if( RC_BAD( rc = getLFile( uiContainer, &pLFile))) - { - goto Exit; - } - - bUsedStack = TRUE; - initStack( &stackBuf[ 0]); - - if( RC_BAD( rc = btSearchEnd( pLFile, - FLM_4x_DRN_LAST_MARKER, &pStack))) - { - goto Exit; - } - - if( pLFile->uiRootBlk == FLM_4x_BT_END) - { - *puiDrn = pLFile->uiNextDrn; - } - else - { - if( pLFile->uiLfNum != - FB2UW( &pStack->pBlk->m_pucBlk[ FLM_4x_BH_LOG_FILE_NUM])) - { - rc = RC_SET( NE_XFLM_DATA_ERROR); - goto Exit; - } - - pucElm = FLM_4x_CURRENT_ELM( pStack); - pucElm += FLM_4x_BBE_GETR_KL( pucElm) + FLM_4x_BBE_KEY; - *puiDrn = FB2UD( pucElm); - } - -Exit: - - if( bUsedStack) - { - releaseStack( stackBuf); - } - - return( rc); -} - -/*************************************************************************** -Desc: Search the right-most end of the b-tree. -****************************************************************************/ -RCODE F_4xReader::btSearchEnd( - F_4x_LFILE * pLFile, - FLMUINT uiDrn, - BTSK ** ppStack) -{ - RCODE rc = NE_XFLM_OK; - BTSK * pStack = *ppStack; - FLMBYTE ucKey[ FLM_4x_DIN_KEY_SIZ]; - FLMUINT uiBlkAddr; - - if( RC_BAD( rc = getRootBlock( pLFile, pStack))) - { - goto Exit; - } - - longToByte( uiDrn, ucKey); - for(;;) - { - if( pStack->uiLevel) - { - pStack->uiCurElm = pStack->uiBlkEnd; - btPrevElm( pStack, pLFile); - } - else - { - if( pStack->uiBlkType != FLM_4x_BHT_NON_LEAF_DATA) - { - if( RC_BAD( rc = btScan( pStack, ucKey))) - { - goto Exit; - } - } - else - { - if( RC_BAD( rc = btScanNonLeafData( pStack, uiDrn))) - { - goto Exit; - } - } - } - - if( !pStack->uiLevel) - { - break; - } - - uiBlkAddr = childBlkAddr( pStack); - pStack++; - - if( RC_BAD( rc = getBlock( pLFile, uiBlkAddr, pStack))) - { - goto Exit; - } - } - - *ppStack = pStack; - -Exit: - - return( rc); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_4xReader::readBlock( - FLMUINT uiBlkAddr, - F_Block ** ppBlock) -{ - RCODE rc = NE_XFLM_OK; - F_Block * pBlock = NULL; - F_Block * pReuseBlock = NULL; - F_Block ** ppTblSlot = NULL; - - if( *ppBlock) - { - (*ppBlock)->Release(); - *ppBlock = NULL; - } - - if( m_ppBlockTbl) - { - ppTblSlot = getHashBucket( uiBlkAddr); - pBlock = *ppTblSlot; - - if( pBlock) - { - if( FLM_4x_GET_BH_ADDR( pBlock->m_pucBlk) != uiBlkAddr) - { - if( pBlock->getRefCount() == 1) - { - pReuseBlock = *ppTblSlot; - } - else - { - (*ppTblSlot)->Release(); - } - - pBlock = NULL; - *ppTblSlot = NULL; - } - else - { - pBlock->AddRef(); - } - } - } - - if( !pBlock) - { - if( pReuseBlock) - { - pBlock = pReuseBlock; - pReuseBlock = NULL; - } - else - { - if( (pBlock = f_new F_Block) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - } - - if( RC_BAD( rc = pBlock->allocBlockBuf( m_fileHdr.uiBlockSize))) - { - goto Exit; - } - - if( RC_BAD( rc = m_pSuperHdl->ReadBlock( uiBlkAddr, - m_fileHdr.uiBlockSize, pBlock->m_pucBlk, NULL))) - { - if( rc == NE_XFLM_IO_END_OF_FILE) - { - rc = RC_SET( NE_XFLM_DATA_ERROR); - } - goto Exit; - } - - // Verify the block checksum - - if( RC_BAD( rc = blkCheckSum( - pBlock->m_pucBlk, uiBlkAddr, m_fileHdr.uiBlockSize))) - { - goto Exit; - } - - // See if we even got the block we thought we wanted - - if( FLM_4x_GET_BH_ADDR( pBlock->m_pucBlk) != uiBlkAddr) - { - rc = RC_SET( NE_XFLM_DATA_ERROR); - goto Exit; - } - - flmAssert( *ppTblSlot == NULL); - *ppTblSlot = pBlock; - pBlock->AddRef(); - } - - flmAssert( *ppTblSlot == pBlock); - *ppBlock = pBlock; - pBlock = NULL; - -Exit: - - if( pBlock) - { - pBlock->Release(); - } - - if( pReuseBlock) - { - pReuseBlock->Release(); - } - - return( rc); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_4xReader::blkCheckSum( - FLMBYTE * pucBlkPtr, - FLMUINT uiBlkAddress, - FLMUINT uiBlkSize) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiCnt; - FLMUINT uiAdds; - FLMUINT uiXORs; - FLMUINT uiCurrCheckSum; - FLMUINT uiNewCheckSum; - FLMUINT uiEncryptSize; - FLMBYTE * pucSaveBlkPtr = pucBlkPtr; - - // Check the block length against the max. block size - - uiEncryptSize = (FLMUINT)getEncryptSize( pucBlkPtr); - if( uiEncryptSize > uiBlkSize || uiEncryptSize < FLM_4x_BH_OVHD) - { - rc = RC_SET( NE_XFLM_BLOCK_CRC); - goto Exit; - } - - uiCurrCheckSum = (FLMUINT)(((FLMUINT)pucBlkPtr[ - FLM_4x_BH_CHECKSUM_HIGH] << 8) + - (FLMUINT)pucBlkPtr[ FLM_4x_BH_CHECKSUM_LOW]); - - uiAdds = 0 - (pucBlkPtr[ FLM_4x_BH_CHECKSUM_LOW] + - pucBlkPtr[ FLM_4x_BH_CHECKSUM_HIGH]); - - uiXORs = pucBlkPtr[ FLM_4x_BH_CHECKSUM_LOW] ^ - pucBlkPtr[ FLM_4x_BH_CHECKSUM_HIGH]; - - if( uiBlkAddress != FLM_4x_BT_END) - { - uiAdds += (FLMBYTE)uiBlkAddress; - uiXORs ^= (FLMBYTE)uiBlkAddress; - } - - for( uiCnt = uiEncryptSize; uiCnt--;) - { - uiAdds += *pucBlkPtr; - uiXORs ^= *(pucBlkPtr++); - } - - uiNewCheckSum = (((uiAdds << 8) + uiXORs) & 0xFFFF); - - if( uiBlkAddress == FLM_4x_BT_END ) - { - FLMBYTE byXor; - FLMBYTE byAdd; - FLMBYTE byDelta; - - // If there is a one byte value that will satisfy both - // sides of the checksum, the checksum is OK and that value - // is the first byte value. - - byXor = (FLMBYTE) uiNewCheckSum; - byAdd = (FLMBYTE) (uiNewCheckSum >> 8); - byDelta = byXor ^ pucSaveBlkPtr[ FLM_4x_BH_CHECKSUM_LOW]; - - // This is the big check, if byDelta is also what is - // off with the add portion of the checksum, we have - // a good value. - - if( ((FLMBYTE) (byAdd + byDelta)) == - pucSaveBlkPtr[ FLM_4x_BH_CHECKSUM_HIGH]) - { - // Set the low checksum value with the computed value. - - pucSaveBlkPtr[ FLM_4x_BH_CHECKSUM_LOW] = byDelta; - goto Exit; - } - } - else - { - // This has the side effect of setting the low block address byte - // in the block thus getting rid of the low checksum byte. - // - // NOTE: We are allowing the case where the calculated checksum is - // zero and the stored checksum is one because we used to change - // a calculated zero to a one in old databases and store the one. - // This is probably a somewhat rare case (1 out of 65536 checksums - // will be zero), so forgiving it will be OK most of the time. - // So that those don't cause us to report block checksum errors, - // we just allow it - checksumming isn't a perfect check anyway. - - if( uiNewCheckSum == uiCurrCheckSum || - ((!uiNewCheckSum) && (uiCurrCheckSum == 1))) - { - pucSaveBlkPtr[ FLM_4x_BH_CHECKSUM_LOW] = (FLMBYTE)uiBlkAddress; - goto Exit; - } - } - - // Otherwise, we have a checksum error. - - rc = RC_SET( NE_XFLM_BLOCK_CRC); - -Exit: - - return( rc); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_4xReader::retrieveRec( - FLMUINT uiContainer, - FLMUINT uiDrn, - FLMUINT uiFlags, - F_Record ** ppRecord) -{ - RCODE rc = NE_XFLM_OK; - BTSK stackBuf[ FLM_4x_BH_MAX_LEVELS]; - BTSK * pStack = NULL; - F_4x_LFILE * pLFile; - - initStack( &stackBuf[ 0]); - pStack = stackBuf; - - if( uiDrn >= (FLM_4x_DRN_LAST_MARKER - 1)) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_ILLEGAL_OP); - goto Exit; - } - - if( RC_BAD( rc = getLFile( uiContainer, &pLFile))) - { - goto Exit; - } - - if( uiFlags & XFLM_INCL) - { - // Search the for the record - - if( RC_BAD( rc = btSearch( pLFile, uiDrn, &pStack))) - { - goto Exit; - } - - if( byteToLong( pStack->ucKeyBuf) == FLM_4x_DRN_LAST_MARKER) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - - flmAssert( byteToLong( pStack->ucKeyBuf) >= uiDrn); - } - else if( uiFlags & XFLM_EXCL) - { - // Search the for the record - - if( RC_BAD( rc = btSearch( pLFile, uiDrn + 1, &pStack))) - { - goto Exit; - } - - if( byteToLong( pStack->ucKeyBuf) == FLM_4x_DRN_LAST_MARKER) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - - flmAssert( byteToLong( pStack->ucKeyBuf) > uiDrn); - } - else - { - // Search the for the record - - if( RC_BAD( rc = btSearch( pLFile, uiDrn, &pStack))) - { - if( rc == NE_XFLM_EOF_HIT) - { - rc = RC_SET( NE_XFLM_NOT_FOUND); - } - - goto Exit; - } - - if( !pStack->uiKeyLen || - byteToLong( pStack->ucKeyBuf) != uiDrn) - { - rc = RC_SET( NE_XFLM_NOT_FOUND); - goto Exit; - } - } - - // Read the record - - if( RC_BAD( rc = readRecElements( pStack, pLFile, ppRecord))) - { - goto Exit; - } - -Exit: - - releaseStack( stackBuf); - return( rc); -} - -/*************************************************************************** -Desc: -*****************************************************************************/ -RCODE F_4xReader::retrieveNextRec( - F_Record ** ppRecord) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiDrn = 0; - FLMUINT uiContainer = m_uiDefaultContainer; - - if( *ppRecord) - { - uiDrn = (*ppRecord)->getID(); - uiContainer = (*ppRecord)->getContainerID(); - } - - if( RC_BAD( rc = retrieveRec( uiContainer, uiDrn, XFLM_EXCL, ppRecord))) - { - goto Exit; - } - -Exit: - - return( rc); -} - -/************************************************************************** -Desc: -**************************************************************************/ -void F_4xReader::releaseStack( - BTSK * pStack) -{ - FLMUINT uiNumLevels = FLM_4x_BH_MAX_LEVELS; - - while( uiNumLevels) - { - if( pStack->pBlk) - { - pStack->pBlk->Release(); - pStack->pBlk = NULL; - } - uiNumLevels--; - pStack++; - } -} - -/************************************************************************** -Desc: -**************************************************************************/ -RCODE F_4xReader::readRecElements( - BTSK * pStack, - F_4x_LFILE * pLFile, - F_Record ** ppRecord) -{ - RCODE rc = NE_XFLM_OK; - F_Record * pRecord = NULL; - FLMBYTE * pucCurElm; - void * pvMark = m_tmpPool.poolMark(); - FLMUINT uiElmRecLen; - FLMUINT uiFieldLen; - FLMUINT uiFieldCount; - FLMUINT uiTrueDataSpace; - FLMUINT uiFieldPos; - TFIELD * pField; - FLDGROUP * pFldGroup = NULL; - FLDGROUP * pFirstFldGroup = NULL; - DATAPIECE * pDataPiece; - LOCKED_BLOCK * pLockedBlock = NULL; - FSTATE state; - - // Initialize variables - - state.uiLevel = 0; - uiFieldCount = 0; - uiTrueDataSpace = 0; - uiFieldPos = NUM_FIELDS_IN_ARRAY; - - // Check to make sure we are positioned at the first element. - - pucCurElm = FLM_4x_CURRENT_ELM( pStack); - - if( !FLM_4x_BBE_IS_FIRST( pucCurElm)) - { - rc = RC_SET( NE_XFLM_DATA_ERROR); - goto Exit; - } - - // Loop on each element in the record - - for( ;;) - { - // Setup all variables to process the current element - - uiElmRecLen = FLM_4x_BBE_GET_RL( pucCurElm); - - if( !uiElmRecLen) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - break; - } - - pucCurElm += FLM_4x_BBE_REC_OFS( pucCurElm); - state.uiPosInElm = 0; - - // Loop on each field within this element. - - while( state.uiPosInElm < uiElmRecLen) - { - state.pElement = pucCurElm; - if( RC_BAD( rc = getFldOverhead( &state))) - { - goto Exit; - } - - uiFieldLen = state.uiFieldLen; - - // Old record info data - skip past for now - - if( !state.uiTagNum) - { - state.uiPosInElm += uiFieldLen; - continue; - } - - if( !pRecord) - { - // Create a new data record or use the existing data record. - - if( *ppRecord) - { - // Reuse the existing F_Record object. - - pRecord = *ppRecord; - *ppRecord = NULL; - pRecord->clear(); - } - else - { - if( (pRecord = f_new F_Record) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - } - - pRecord->setContainerID( - FB2UW( &pStack->pBlk->m_pucBlk[ FLM_4x_BH_LOG_FILE_NUM])); - pRecord->setID( byteToLong( pStack->ucKeyBuf)); - } - - // Check if out of fields in the tempoary field group - - if( uiFieldPos >= NUM_FIELDS_IN_ARRAY) - { - FLDGROUP * pTempFldGroup; - - uiFieldPos = 0; - - // Allocate the first field group from the pool. - - if( RC_BAD( rc = m_tmpPool.poolAlloc( - sizeof( FLDGROUP), (void **)&pTempFldGroup))) - { - goto Exit; - } - - pTempFldGroup->pNext = NULL; - if( pFldGroup) - { - pFldGroup->pNext = pTempFldGroup; - } - else - { - pFirstFldGroup = pTempFldGroup; - } - pFldGroup = pTempFldGroup; - } - - flmAssert( state.uiFieldType != FLM_4x_UNKNOWN_TYPE); - uiFieldCount++; - pField = &pFldGroup->pFields[ uiFieldPos++]; - pField->uiLevel = state.uiLevel; - pField->uiFieldID = state.uiTagNum; - pField->uiFieldType = state.uiFieldType; - pField->uiFieldLen = state.uiFieldLen; - pDataPiece = &pField->DataPiece; - - if( uiFieldLen) - { - FLMUINT uiDataPos = 0; - - if( state.uiFieldLen > 4) - { - // Binary data needs to account for alignment issues. - - if( state.uiFieldType == FLM_4x_BINARY_TYPE) - { - if( state.uiFieldLen >= 255) - { - // Align so that the data is aligned - not the length - - uiTrueDataSpace += 2; - uiTrueDataSpace = ((uiTrueDataSpace + FLM_ALLOC_ALIGN) & - (~(FLM_ALLOC_ALIGN) & 0x7FFFFFFF)); - uiTrueDataSpace -= 2; - } - else - { - uiTrueDataSpace = ((uiTrueDataSpace + FLM_ALLOC_ALIGN) & - (~(FLM_ALLOC_ALIGN) & 0x7FFFFFFF)); - } - } - - uiTrueDataSpace += state.uiFieldLen; - - // For read only records, greater than 255 bytes are - // stored length preceded. - - if( state.uiFieldLen >= 255) - { - uiTrueDataSpace += 2; - } - } - - // Value may start in the next element. - - while( uiDataPos < uiFieldLen) - { - // Need to read next element for the value portion? - - if( state.uiPosInElm >= uiElmRecLen) - { - if( FLM_4x_BBE_IS_LAST( FLM_4x_CURRENT_ELM( pStack))) - { - rc = RC_SET( NE_XFLM_DATA_ERROR); - goto Exit; - } - - // If we are going to the next block, lock down this block - // beacause data pointers are pointing to it. - - if( RC_BAD( blkNextElm( pStack))) - { - LOCKED_BLOCK * pLastLockedBlock = pLockedBlock; - - if( RC_BAD( rc = m_tmpPool.poolAlloc( - sizeof( LOCKED_BLOCK), (void **)&pLockedBlock))) - { - goto Exit; - } - - pLockedBlock->pBlock = pStack->pBlk; - pLockedBlock->pBlock->AddRef(); - pLockedBlock->pNext = pLastLockedBlock; - - if( RC_BAD( rc = btNextElm( pStack, pLFile))) - { - goto Exit; - } - } - - pucCurElm = FLM_4x_CURRENT_ELM( pStack); - uiElmRecLen = FLM_4x_BBE_GET_RL( pucCurElm); - pucCurElm += FLM_4x_BBE_REC_OFS( pucCurElm); - state.uiPosInElm = 0; - } - - // Compare number of bytes left if value <= # bytes left in element - - if( (uiFieldLen - uiDataPos) <= - (uiElmRecLen - state.uiPosInElm)) - { - FLMUINT uiDelta = uiFieldLen - uiDataPos; - - pDataPiece->pData = &pucCurElm[ state.uiPosInElm]; - pDataPiece->uiLength = uiDelta; - state.uiPosInElm += uiDelta; - pDataPiece->pNext = NULL; - break; - } - else - { - // Take what is there and get next element to grab some more. - - FLMUINT uiBytesToMove = uiElmRecLen - state.uiPosInElm; - DATAPIECE * pNextDataPiece; - - pDataPiece->pData = &pucCurElm[ state.uiPosInElm]; - pDataPiece->uiLength = uiBytesToMove; - state.uiPosInElm += uiBytesToMove; - uiDataPos += uiBytesToMove; - - if( RC_BAD( rc = m_tmpPool.poolAlloc( - sizeof( DATAPIECE), (void **)&pNextDataPiece))) - { - goto Exit; - } - pDataPiece->pNext = pNextDataPiece; - pDataPiece = pNextDataPiece; - } - } - } - } - - // Done? - - if( FLM_4x_BBE_IS_LAST( FLM_4x_CURRENT_ELM( pStack))) - { - break; - } - - // Position to next element - - if( RC_BAD( blkNextElm( pStack))) - { - LOCKED_BLOCK * pLastLockedBlock = pLockedBlock; - - if( RC_BAD( rc = m_tmpPool.poolAlloc( - sizeof( LOCKED_BLOCK), (void **)&pLockedBlock))) - { - goto Exit; - } - - pLockedBlock->pBlock = pStack->pBlk; - pLockedBlock->pBlock->AddRef(); - pLockedBlock->pNext = pLastLockedBlock; - - if( RC_BAD( rc = btNextElm( pStack, pLFile))) - { - goto Exit; - } - } - - // Corruption Check. - - pucCurElm = FLM_4x_CURRENT_ELM( pStack); - if( FLM_4x_BBE_IS_FIRST( pucCurElm)) - { - rc = RC_SET( NE_XFLM_DATA_ERROR); - goto Exit; - } - } - - if( pRecord) - { - void * pvField; - - if( RC_BAD( rc = pRecord->preallocSpace( uiTrueDataSpace))) - { - goto Exit; - } - pFldGroup = pFirstFldGroup; - - for( uiFieldPos = 0; uiFieldCount--; uiFieldPos++) - { - - if( uiFieldPos >= NUM_FIELDS_IN_ARRAY) - { - uiFieldPos = 0; - if( (pFldGroup = pFldGroup->pNext) == NULL) - { - break; - } - } - pField = &pFldGroup->pFields[ uiFieldPos]; - - if( RC_BAD( rc = pRecord->insertLast( pField->uiLevel, pField->uiFieldID, - pField->uiFieldType, &pvField))) - { - goto Exit; - } - - if( pField->uiFieldLen) - { - FLMBYTE * pDataPtr; // Points to where the data will go. - - pDataPiece = &pField->DataPiece; - pDataPtr = pRecord->getImportDataPtr( pvField, - pField->uiFieldType, pField->uiFieldLen); - - if( !pDataPtr) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - do - { - f_memcpy( pDataPtr, pDataPiece->pData, pDataPiece->uiLength); - pDataPtr += pDataPiece->uiLength; - pDataPiece = pDataPiece->pNext; - } - while( pDataPiece); - } - } - } - - if( *ppRecord) - { - flmAssert( 0); - (*ppRecord)->Release(); - } - - *ppRecord = pRecord; - pRecord = NULL; - -Exit: - - // Release all locked down blocks except the current block. - - while( pLockedBlock) - { - pLockedBlock->pBlock->Release(); - pLockedBlock = pLockedBlock->pNext; - } - - m_tmpPool.poolReset( pvMark); - - if( pRecord) - { - pRecord->Release(); - } - - return( rc); -} - -/************************************************************************** -Desc: -**************************************************************************/ -RCODE F_4xReader::getFldOverhead( - FSTATE * pState) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE * pFieldOvhd = &pState->pElement[ pState->uiPosInElm]; - FLMBYTE * pElement = pState->pElement; - FLMBOOL bDoesntHaveFieldDef = TRUE; - FLMUINT uiFieldLen; - FLMUINT uiFieldType = 0; - FLMUINT uiTagNum; - FLMBYTE ucTemp; - - if( FLM_4x_FOP_IS_STANDARD( pFieldOvhd)) - { - if( FLM_4x_FSTA_LEVEL( pFieldOvhd)) - { - pState->uiLevel++; - } - - uiFieldLen = FLM_4x_FSTA_FLD_LEN( pFieldOvhd); - uiTagNum = FLM_4x_FSTA_FLD_NUM( pFieldOvhd); - pFieldOvhd += FLM_4x_FSTA_OVHD; - } - else if( FLM_4x_FOP_IS_OPEN( pFieldOvhd)) - { - if( FLM_4x_FOPE_LEVEL( pFieldOvhd)) - { - pState->uiLevel++; - } - - ucTemp = (FLMBYTE)(FLM_4x_FOP_GET_FLD_FLAGS( pFieldOvhd++)); - uiTagNum = (FLMUINT)*pFieldOvhd++; - - if( FLM_4x_FOP_2BYTE_FLDNUM( ucTemp)) - { - uiTagNum += ((FLMUINT) *pFieldOvhd++) << 8; - } - - uiFieldLen = (FLMUINT) *pFieldOvhd++; - if( FLM_4x_FOP_2BYTE_FLDLEN( ucTemp)) - { - uiFieldLen += ((FLMUINT) *pFieldOvhd++) << 8; - } - } - else if( FLM_4x_FOP_IS_NO_VALUE( pFieldOvhd)) - { - if( FLM_4x_FNOV_LEVEL( pFieldOvhd)) - { - pState->uiLevel++; - } - - ucTemp = (FLMBYTE)(FLM_4x_FOP_GET_FLD_FLAGS( pFieldOvhd++)); - uiTagNum = (FLMUINT)*pFieldOvhd++; - - if( FLM_4x_FOP_2BYTE_FLDNUM( ucTemp)) - { - uiTagNum += ((FLMUINT) *pFieldOvhd++) << 8; - } - uiFieldLen = uiFieldType = 0; - } - else if( FLM_4x_FOP_IS_SET_LEVEL( pFieldOvhd)) - { - pState->uiLevel -= FLM_4x_FSLEV_GET( pFieldOvhd++); - pState->uiPosInElm = (FLMUINT)( pFieldOvhd - pElement); - rc = getFldOverhead( pState); - goto Exit; - } - else if( FLM_4x_FOP_IS_TAGGED( pFieldOvhd)) - { - bDoesntHaveFieldDef = FALSE; - - if( FLM_4x_FTAG_LEVEL( pFieldOvhd)) - { - pState->uiLevel++; - } - - ucTemp = (FLMBYTE)(FLM_4x_FOP_GET_FLD_FLAGS( pFieldOvhd)); - uiFieldType = (FLMUINT)(FLM_4x_FTAG_FLD_TYPE( pFieldOvhd)); - pFieldOvhd += FLM_4x_FTAG_OVHD; - uiTagNum = (FLMUINT) *pFieldOvhd++; - - if( FLM_4x_FOP_2BYTE_FLDNUM( ucTemp)) - { - uiTagNum += ((FLMUINT) *pFieldOvhd++) << 8; - } - - uiTagNum ^= 0x8000; - uiFieldLen = (FLMUINT)*pFieldOvhd++; - if( FLM_4x_FOP_2BYTE_FLDLEN( ucTemp)) - { - uiFieldLen += ((FLMUINT) *pFieldOvhd++) << 8; - } - } - else if( FLM_4x_FOP_IS_RECORD_INFO( pFieldOvhd)) - { - bDoesntHaveFieldDef = FALSE; - ucTemp = *pFieldOvhd++; - uiFieldLen = *pFieldOvhd++; - - if( FLM_4x_FOP_2BYTE_FLDLEN( ucTemp)) - { - uiFieldLen += ((FLMUINT) *pFieldOvhd++) << 8; - } - uiTagNum = 0; - } - else - { - rc = RC_SET( NE_XFLM_DATA_ERROR); - goto Exit; - } - - if( bDoesntHaveFieldDef) - { - if( RC_BAD( rc = getFieldType( uiTagNum, &uiFieldType))) - { - goto Exit; - } - } - - pState->uiFieldType = uiFieldType; - pState->uiFieldLen = uiFieldLen; - pState->uiPosInElm = (FLMUINT)(pFieldOvhd - pElement); - pState->uiTagNum = uiTagNum; - -Exit: - - return( rc); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -FLMUINT F_4xReader::childBlkAddr( - BTSK * pStack) -{ - FLMBYTE * pucChildBlkPtr; - FLMUINT uiElmOvhd = pStack->uiElmOvhd; - - if( uiElmOvhd == FLM_4x_BNE_DATA_OVHD) - { - pucChildBlkPtr = FLM_4x_BLK_ELM_ADDR( - pStack, pStack->uiCurElm + FLM_4x_BNE_DATA_CHILD_BLOCK); - return( FB2UD( pucChildBlkPtr)); - } - else - { - // Corruption - - flmAssert( 0); - return( 0); - } -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_4xReader::btSearch( - F_4x_LFILE * pLFile, - FLMUINT uiDrn, - BTSK ** ppStack) -{ - RCODE rc = NE_XFLM_OK; - BTSK * pStack = *ppStack; - FLMBYTE ucKey[ FLM_4x_DIN_KEY_SIZ]; - FLMUINT uiBlkAddr; - - // Get the root block - - if( RC_BAD( rc = getRootBlock( pLFile, pStack))) - { - goto Exit; - } - - longToByte( uiDrn, ucKey); - - // Read each block going down the b-tree. - // Save state information in the stack. - - for(;;) - { - if( pStack->uiBlkType != FLM_4x_BHT_NON_LEAF_DATA) - { - if( RC_BAD( rc = btScan( pStack, ucKey))) - { - goto Exit; - } - } - else - { - if( RC_BAD( rc = btScanNonLeafData( pStack, uiDrn))) - { - goto Exit; - } - } - - if( !pStack->uiLevel) - { - break; - } - - uiBlkAddr = childBlkAddr( pStack); - pStack++; - - if( RC_BAD( rc = getBlock( pLFile, uiBlkAddr, pStack))) - { - goto Exit; - } - } - - *ppStack = pStack; - -Exit: - - return( rc); -} - -/*************************************************************************** -Desc: Scan a b-tree block for a matching key at any b-tree block level. -****************************************************************************/ -RCODE F_4xReader::btScan( - BTSK * pStack, - FLMBYTE * pucSearchKey) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE * pucCurElm; - FLMBYTE * pBlk; - FLMBYTE * pucKeyBuf; - FLMBYTE * pElmKey; - FLMUINT uiRecLen = 0; - FLMUINT uiPrevKeyCnt; - FLMUINT uiElmKeyLen; - FLMUINT uiBlkType; - FLMUINT uiElmOvhd; - FLMUINT uiBytesMatched; - - uiBlkType = pStack->uiBlkType; - flmAssert( uiBlkType != FLM_4x_BHT_NON_LEAF_DATA); - - pucKeyBuf = pStack->ucKeyBuf; - pBlk = pStack->pBlk->m_pucBlk; - uiElmOvhd = pStack->uiElmOvhd; - pStack->uiCurElm = FLM_4x_BH_OVHD; - pStack->uiKeyLen = 0; - pStack->uiPKC = 0; - pStack->uiPrevElmPKC = 0; - uiBytesMatched = 0; - - for( ;;) - { - pucCurElm = &pBlk[ pStack->uiCurElm]; - uiElmKeyLen = FLM_4x_BBE_GETR_KL( pucCurElm); - - // Read in RAW mode - doesn't do all bit checking - - if( (uiPrevKeyCnt = (FLM_4x_BBE_GETR_PKC( pucCurElm))) > - FLM_4x_BBE_PKC_MAX) - { - uiElmKeyLen += (uiPrevKeyCnt & FLM_4x_BBE_KL_HBITS) << - FLM_4x_BBE_KL_SHIFT_BITS; - uiPrevKeyCnt &= FLM_4x_BBE_PKC_MAX; - } - - // Should not have a non-zero PKC if we are on the first element - // of a block - - if( uiPrevKeyCnt && pStack->uiCurElm == FLM_4x_BH_OVHD) - { - rc = RC_SET( NE_XFLM_DATA_ERROR); - goto Exit; - } - - // Get the record portion length when on the leaf blocks. - - if( uiBlkType == FLM_4x_BHT_LEAF) - { - uiRecLen = FLM_4x_BBE_GET_RL( pucCurElm); - } - - pStack->uiPrevElmPKC = pStack->uiPKC; - - // The zero length key is the terminating - // element in a right-most block. - - if( (pStack->uiKeyLen = uiPrevKeyCnt + uiElmKeyLen) == 0) - { - pStack->uiPrevElmPKC = f_min( uiBytesMatched, FLM_4x_BBE_PKC_MAX); - pStack->uiPKC = 0; - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - - // Handle special case of left-end compression maxing out. - - if( uiPrevKeyCnt == FLM_4x_BBE_PKC_MAX && - FLM_4x_BBE_PKC_MAX < uiBytesMatched) - { - uiBytesMatched = FLM_4x_BBE_PKC_MAX; - } - - // Check out this element to see if the key matches. - - if( uiPrevKeyCnt == uiBytesMatched) - { - pElmKey = &pucCurElm[ uiElmOvhd]; - - for(;;) - { - // All bytes of the search key are matched? - - if( uiBytesMatched == FLM_4x_DIN_KEY_SIZ) - { - pStack->uiPKC = f_min( uiBytesMatched, FLM_4x_BBE_PKC_MAX); - - if( pStack->uiKeyLen != FLM_4x_DIN_KEY_SIZ) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_DATA_ERROR); - goto Exit; - } - - // Current key is equal to the search key. - - f_memcpy( pucKeyBuf, pucSearchKey, FLM_4x_DIN_KEY_SIZ); - goto Exit; - } - - if( uiBytesMatched == pStack->uiKeyLen) - { - pStack->uiPKC = f_min( uiBytesMatched, FLM_4x_BBE_PKC_MAX); - goto Next_Element; - } - - // Compare the next byte in the search key and element - - if( pucSearchKey[ uiBytesMatched] != *pElmKey) - { - break; - } - - uiBytesMatched++; - pElmKey++; - } - - pStack->uiPKC = f_min( uiBytesMatched, FLM_4x_BBE_PKC_MAX); - - // Check if we are done comparing - - if( pucSearchKey[ uiBytesMatched] < *pElmKey) - { - if( uiBytesMatched) - { - flmAssert( uiBytesMatched <= FLM_4x_DIN_KEY_SIZ); - f_memcpy( pucKeyBuf, pucSearchKey, uiBytesMatched); - } - - flmAssert( pStack->uiKeyLen <= FLM_4x_DIN_KEY_SIZ); - f_memcpy( &pucKeyBuf[ uiBytesMatched], pElmKey, - pStack->uiKeyLen - uiBytesMatched); - goto Exit; - } - } - else if( uiPrevKeyCnt < uiBytesMatched) - { - // Current key > search key. Set pucKeyBuf and break out. - - pStack->uiPKC = uiPrevKeyCnt; - if( uiPrevKeyCnt) - { - flmAssert( uiPrevKeyCnt <= FLM_4x_DIN_KEY_SIZ); - f_memcpy( pucKeyBuf, pucSearchKey, uiPrevKeyCnt); - } - - flmAssert( uiPrevKeyCnt + uiElmKeyLen <= FLM_4x_DIN_KEY_SIZ); - f_memcpy( &pucKeyBuf[ uiPrevKeyCnt], - &pucCurElm[ uiElmOvhd], uiElmKeyLen); - - if( byteToLong( pucKeyBuf) == FLM_4x_BT_END) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - } - - goto Exit; - } - -Next_Element: - - // Position to the next element - - pStack->uiCurElm += uiElmKeyLen + ((uiBlkType == FLM_4x_BHT_LEAF ) - ? (FLM_4x_BBE_KEY + uiRecLen) - : (FLM_4x_BNE_IS_DOMAIN( pucCurElm) - ? (FLM_4x_BNE_DOMAIN_LEN + uiElmOvhd) - : uiElmOvhd)); - - // Most common check first. - - if( pStack->uiCurElm < pStack->uiBlkEnd) - { - continue; - } - - if( pStack->uiCurElm == pStack->uiBlkEnd) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - - // Marched off the end of the block - - rc = RC_SET( NE_XFLM_DATA_ERROR); - goto Exit; - } - -Exit: - - return( rc); -} - -/*************************************************************************** -Desc: Binary search into a non-leaf data record block. -****************************************************************************/ -RCODE F_4xReader::btScanNonLeafData( - BTSK * pStack, - FLMUINT uiDrn) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE * pucBlk = pStack->pBlk->m_pucBlk; - FLMUINT uiLow = 0; - FLMUINT uiMid; - FLMUINT uiHigh = ((pStack->uiBlkEnd - FLM_4x_BH_OVHD) >> 3) - 1; - FLMUINT uiTblSize = uiHigh; - FLMUINT uiCurDrn; - - for(;;) - { - uiMid = (uiLow + uiHigh) >> 1; - - uiCurDrn = byteToLong( &pucBlk[ FLM_4x_BH_OVHD + (uiMid << 3)]); - if( !uiCurDrn) - { - // Special case - at the end of a rightmost block. - break; - } - - if( uiDrn == uiCurDrn) - { - // Remember a data record can span multiple blocks (same DRN). - - while( uiMid) - { - uiCurDrn = byteToLong( - &pucBlk[ FLM_4x_BH_OVHD + ((uiMid - 1) << 3)]); - if( uiDrn != uiCurDrn) - { - break; - } - uiMid--; - } - break; - } - - // Down to one item if too high then position to next item. - - if( uiLow >= uiHigh) - { - if( (uiDrn > uiCurDrn) && uiMid < uiTblSize) - { - uiMid++; - } - - break; - } - - // If too high then try lower section - - if( uiDrn < uiCurDrn) - { - // First item too high? - - if( !uiMid) - { - break; - } - - uiHigh = uiMid - 1; - } - else - { - if( uiMid == uiTblSize) - { - uiMid++; - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - - uiLow = uiMid + 1; - } - } - - // Set curElm and the key buffer. - - pStack->uiCurElm = FLM_4x_BH_OVHD + (uiMid << 3); - longToByte( uiCurDrn, pStack->ucKeyBuf); - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Goto the next element within the block -****************************************************************************/ -RCODE F_4xReader::blkNextElm( - BTSK * pStack) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE * pucElm; - FLMUINT uiElmSize; - - pucElm = &pStack->pBlk->m_pucBlk[ pStack->uiCurElm]; - - if( pStack->uiBlkType == FLM_4x_BHT_LEAF) - { - uiElmSize = FLM_4x_BBE_LEN( pucElm); - if( pStack->uiCurElm + FLM_4x_BBE_LEM_LEN < pStack->uiBlkEnd) - { - if( ((pStack->uiCurElm += uiElmSize) + - FLM_4x_BBE_LEM_LEN < pStack->uiBlkEnd) == 0) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - - } - else - { - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - } - else - { - if( pStack->uiBlkType != FLM_4x_BHT_NON_LEAF_DATA) - { - rc = RC_SET( NE_XFLM_DATA_ERROR); - goto Exit; - } - - uiElmSize = FLM_4x_BNE_DATA_OVHD; - - if( pStack->uiCurElm < pStack->uiBlkEnd) - { - // Check if this is not the last element within the block - - if( (pStack->uiCurElm += uiElmSize) >= pStack->uiBlkEnd) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - } - else - { - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - } - -Exit: - - return( rc); -} - -/*************************************************************************** -Desc: Go to the next element in the logical b-tree -****************************************************************************/ -RCODE F_4xReader::btNextElm( - BTSK * pStack, - F_4x_LFILE * pLFile) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE * pucCurElm; - FLMUINT uiLFile; - - uiLFile = FB2UW( &pStack->pBlk->m_pucBlk[ FLM_4x_BH_LOG_FILE_NUM]); - - if( pStack->uiCurElm < FLM_4x_BH_OVHD) - { - pStack->uiCurElm = FLM_4x_BH_OVHD; - } - else - { - if( RC_BAD( rc = blkNextElm( pStack))) - { - if( rc == NE_XFLM_EOF_HIT) - { - FLMBYTE * pucBlk = FLM_4x_BLK_ELM_ADDR( pStack, FLM_4x_BH_NEXT_BLK); - FLMUINT uiBlkNum = FB2UD( pucBlk); - - if( uiBlkNum != FLM_4x_BT_END) - { - // Current element was last element in the block - goto next block */ - - if( RC_BAD( rc = getBlock( pLFile, uiBlkNum, pStack))) - { - goto Exit; - } - - pucBlk = pStack->pBlk->m_pucBlk; - pStack->uiBlkEnd = (FLMUINT)FB2UW( &pucBlk[ FLM_4x_BH_ELM_END ]); - pStack->uiCurElm = FLM_4x_BH_OVHD; - btAdjustStack( pStack, pLFile, TRUE); - } - } - } - } - - pucCurElm = FLM_4x_CURRENT_ELM( pStack); - - // Copy the key - - f_memcpy( pStack->ucKeyBuf, pucCurElm, FLM_4x_DIN_KEY_SIZ); - -Exit: - - return(rc ); -} - -/*************************************************************************** -Desc: Go to the previous element in the logical b-tree -****************************************************************************/ -RCODE F_4xReader::btPrevElm( - BTSK * pStack, - F_4x_LFILE * pLFile) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiBlkAddr; - FLMUINT uiTargetElm; - FLMUINT uiPrevElm = 0; - FLMUINT uiPrevKeyCnt = 0; - FLMUINT uiElmKeyLen = 0; - FLMUINT uiElmOvhd = pStack->uiElmOvhd; - FLMBYTE * pucCurElm; - FLMBYTE * pucBlk; - - // Check if we are at or before the first element in the block - - if( pStack->uiCurElm <= FLM_4x_BH_OVHD) - { - pucBlk = pStack->pBlk->m_pucBlk; - - // We're at or before the first element, so read in the previous - // block and go to the last element - - if( (uiBlkAddr = (FLMUINT)FB2UD( &pucBlk[ - FLM_4x_BH_PREV_BLK])) == FLM_4x_BT_END) - { - // We are at the end - - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - else - { - if( RC_BAD( rc = getBlock( pLFile, uiBlkAddr, pStack))) - { - // Set uiBlkEnd and uiCurElm. - // Adjust the parent block to the previous element - - pucBlk = pStack->pBlk->m_pucBlk; - pStack->uiCurElm = pStack->uiBlkEnd; - btAdjustStack( pStack, pLFile, FALSE); - goto Exit; - } - } - } - - // Move down 1 before the current element - - if( pStack->uiBlkType == FLM_4x_BHT_NON_LEAF_DATA) - { - pStack->uiCurElm -= FLM_4x_BNE_DATA_OVHD; - pucBlk = pStack->pBlk->m_pucBlk; - pucCurElm = &pucBlk[ pStack->uiCurElm]; - f_memcpy( pStack->ucKeyBuf, pucCurElm, FLM_4x_DIN_KEY_SIZ); - goto Exit; - } - - // Set up to point to first element in the block - - uiTargetElm = pStack->uiCurElm; - pStack->uiCurElm = FLM_4x_BH_OVHD; - pucBlk = pStack->pBlk->m_pucBlk; - - while( pStack->uiCurElm < uiTargetElm) - { - pucCurElm = &pucBlk[ pStack->uiCurElm]; - uiPrevKeyCnt = (FLMUINT)(FLM_4x_BBE_GET_PKC( pucCurElm)); - uiElmKeyLen = (FLMUINT)(FLM_4x_BBE_GET_KL( pucCurElm)); - - if( uiElmKeyLen + uiPrevKeyCnt > FLM_4x_DIN_KEY_SIZ) - { - rc = RC_SET( NE_XFLM_DATA_ERROR); - goto Exit; - } - - if( uiElmKeyLen) - { - flmAssert( uiPrevKeyCnt + uiElmKeyLen <= FLM_4x_DIN_KEY_SIZ); - f_memcpy( &pStack->ucKeyBuf[ uiPrevKeyCnt], - &pucCurElm[ uiElmOvhd], uiElmKeyLen); - } - - uiPrevElm = pStack->uiCurElm; - if( RC_BAD( rc = blkNextElm( pStack))) - { - if( rc != NE_XFLM_EOF_HIT) - { - goto Exit; - } - rc = NE_XFLM_OK; - break; - } - } - - pStack->uiKeyLen = uiPrevKeyCnt + uiElmKeyLen; - pStack->uiCurElm = uiPrevElm; - flmAssert( pStack->uiKeyLen == FLM_4x_DIN_KEY_SIZ); - -Exit: - - return( rc); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_4xReader::btAdjustStack( - BTSK * pStack, - F_4x_LFILE * pLFile, - FLMBOOL bMovedNext) -{ - RCODE rc = NE_XFLM_OK; - - pStack--; - if( RC_BAD( rc = getBlock( pLFile, pStack->uiBlkAddr, pStack))) - { - goto Exit; - } - - if( bMovedNext) - { - if( RC_BAD( rc = btNextElm( pStack, pLFile))) - { - goto Exit; - } - } - else - { - if( RC_BAD( rc = btPrevElm( pStack, pLFile))) - { - goto Exit; - } - } - -Exit: - - pStack++; - return( rc); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_4xReader::getNameTable( - F_4xNameTable ** ppNameTable) -{ - RCODE rc = NE_XFLM_OK; - FLMBOOL bAllocated = FALSE; - - if( !m_pNameTable) - { - if( (m_pNameTable = f_new F_4xNameTable) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - bAllocated = TRUE; - - if( RC_BAD( rc = m_pNameTable->setupNameTable( this))) - { - goto Exit; - } - } - - flmAssert( *ppNameTable == NULL); - m_pNameTable->AddRef(); - *ppNameTable = m_pNameTable; - -Exit: - - if( RC_BAD( rc) && bAllocated) - { - m_pNameTable->Release(); - m_pNameTable = NULL; - } - - return( rc); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -F_Record::F_Record() -{ - m_uiContainerID = 0; - m_uiRecordID = 0; - m_pool.poolInit( sizeof( m_fieldList)); - m_pFirstFld = m_pLastFld = NULL; - resetFieldList(); - m_pDataBuf = NULL; - m_uiDataBufOffset = 0; - m_uiDataBufLength = 0; -} - -/*************************************************************************** -Desc: -****************************************************************************/ -F_Record::~F_Record() -{ - m_pool.poolFree(); - if( m_pDataBuf) - { - f_free( &m_pDataBuf); - } -} - -/*************************************************************************** -Desc: -****************************************************************************/ -void F_Record::resetFieldList( void) -{ - FLMUINT uiLoop; - FIELD * pCurField; - FIELD * pPrevField = NULL; - - for( uiLoop = 0; uiLoop < FLM_4x_FIELD_LIST_SIZE; uiLoop++) - { - pCurField = &m_fieldList[ uiLoop]; - pCurField->ui16FieldID = 0xFFFF; - - pCurField->pPrev = pPrevField; - pCurField->pNext = &m_fieldList[ uiLoop + 1]; - pPrevField = pCurField; - } - - pCurField->pNext = NULL; - - m_pAvailFld = &m_fieldList[ 0]; -} - -/*************************************************************************** -Desc: -****************************************************************************/ -void F_Record::clear() -{ - m_uiDataBufOffset = 0; - resetFieldList(); - - m_pool.poolReset( NULL); - m_pFirstFld = NULL; - m_pLastFld = NULL; - - m_uiContainerID = 0; - m_uiRecordID = 0; -} - -/*************************************************************************** -Desc: -****************************************************************************/ -FIELD * F_Record::lastSubTreeField( - FIELD * pField) -{ - FIELD * pTempField = (FIELD *)lastChild( pField); - FIELD * pLastChild = NULL; - FLMUINT uiStartLevel = pField->ui8Level; - - // Step down through the tree - - for( ; pTempField && pTempField->ui8Level > uiStartLevel; - pTempField = nextField( pTempField)) - { - pLastChild = pTempField; - } - - return( pLastChild); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_Record::insertLast( - FLMUINT uiLevel, - FLMUINT uiFieldID, - FLMUINT uiDataType, - void ** ppvField) -{ - RCODE rc = NE_XFLM_OK; - FIELD * pField = NULL; - - // Insert new field following current last field - - if( RC_BAD( rc = createField( m_pLastFld, &pField))) - { - goto Exit; - } - - // Set up the new field and set as the current field - - pField->ui16FieldID = (FLMUINT16) uiFieldID; - pField->ui8Level = (FLMUINT8) uiLevel; - pField->ui8Type = (FLMUINT8) uiDataType; - - if( ppvField) - { - *ppvField = pField; - } - -Exit: - -#ifdef FLM_DEBUG - if ( pField) - { - flmAssert( pField->pNext != pField); - flmAssert( pField->pPrev != pField); - flmAssert( pField->ui16FieldID != 0xFFFF); - } -#endif - - return( rc); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -FIELD * F_Record::nextSiblingField( - FIELD * pField) -{ - FLMUINT8 ui8Level = pField->ui8Level; - - while( (pField = nextField( pField)) != NULL && - pField->ui8Level > ui8Level) - { - ; - } - - return( (pField && pField->ui8Level == ui8Level) - ? pField - : NULL); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -void * F_Record::prevSibling( - void * pvField) -{ - if( !pvField) - { - return( NULL); - } - - FIELD * pField = (FIELD *)pvField; - FLMUINT8 ui8Level = pField->ui8Level; - - while( (pField = prevField( pField)) != NULL && - pField->ui8Level > ui8Level) - { - ; - } - - return( (pField && pField->ui8Level == ui8Level) - ? pField - : NULL); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -void * F_Record::lastChild( - void * pvField) -{ - FIELD * pField = (FIELD *)pvField; - FIELD * pLastField = NULL; - - if( !pField) - { - return( NULL); - } - - for( pField = firstChildField( pField); - pField; - pField = nextSiblingField( pField)) - { - pLastField = pField; - } - - return( pLastField); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -void * F_Record::parent( - void * pvField) -{ - FIELD * pField = (FIELD *) pvField; - FLMUINT8 ui8Level; - - if( !pField) - { - return( NULL); - } - - ui8Level = pField->ui8Level; - - while( (pField = prevField( pField)) != NULL && - pField->ui8Level >= ui8Level) - { - ; - } - - return( pField); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -FLMBYTE * F_Record::getImportDataPtr( - void * pvField, - FLMUINT uiDataType, - FLMUINT uiLength) -{ - FLMBYTE * pucData = NULL; - - getNewDataPtr( (FIELD *)pvField, uiDataType, uiLength, &pucData); - ((FIELD *)pvField)->ui8Type = (FLMUINT8) uiDataType; - - return( pucData); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_Record::preallocSpace( - FLMUINT uiDataSize) -{ - RCODE rc = NE_XFLM_OK; - - m_uiDataBufOffset = 0; - if( m_uiDataBufLength >= uiDataSize) - { - goto Exit; - } - - if( !m_pDataBuf) - { - m_uiDataBufLength = 0; - if( RC_BAD( rc = f_alloc( uiDataSize, &m_pDataBuf))) - { - goto Exit; - } - m_uiDataBufLength = uiDataSize; - } - else - { - if( RC_BAD( rc = f_realloc( uiDataSize, &m_pDataBuf))) - { - goto Exit; - } - m_uiDataBufLength = uiDataSize; - } - -Exit: - - return( rc); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -void * F_Record::find( - void * pvField, - FLMUINT uiFieldID, - FLMUINT uiOccur, - FLMBOOL bSearchForest) -{ - if( uiOccur == 0) - { - uiOccur = 1; - } - - if( pvField) - { - FLMUINT uiStartLevel = ((FIELD *)pvField)->ui8Level; - do - { - if( (uiFieldID == - ((FIELD *)pvField)->ui16FieldID) && (--uiOccur < 1)) - { - return( pvField); - } - } - while( (pvField = (FIELD *)(pvField - ? ((FIELD *)pvField)->pNext - : NULL)) != NULL && - ((((FIELD *)pvField)->ui8Level > uiStartLevel) || - (bSearchForest && ((FIELD *)pvField)->ui8Level == - uiStartLevel))); - } - - return( NULL); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -void * F_Record::find( - void * pvField, - FLMUINT * puiPathArray, - FLMUINT uiOccur, - FLMBOOL bSearchForest) -{ - void * pvSaveField; - FLMUINT * puiPath; - FLMUINT uiLevel; - - // Handle empty record - - if( !pvField) - { - return( NULL); - } - - if( !uiOccur) - { - uiOccur = 1; - } - - uiLevel = ((FIELD *)pvField)->ui8Level; - for(;;) - { - puiPath = puiPathArray + ( ((FIELD *)pvField)->ui8Level - uiLevel); - pvSaveField = pvField; - - if( *puiPath == ((FIELD *)pvField)->ui16FieldID) - { - if( *(puiPath + 1) == 0 && (--uiOccur < 1)) - { - return( pvField); - } - - // Go down level for rest of path - - if( ( pvField = firstChild( pvField)) != NULL) - { - continue; - } - pvField = pvSaveField; - } - - // Find next sibling/uncle/end - - do - { - pvField = (FIELD *)(pvField ? ((FIELD *)pvField)->pNext : NULL); - } - while( pvField != NULL - && ((FIELD *)pvField)->ui8Level > ((FIELD *)pvSaveField)->ui8Level); - - // Are we at the end? - - if( !pvField || - ((FIELD *)pvField)->ui8Level < uiLevel || - (bSearchForest && ((FIELD *)pvField)->ui8Level == uiLevel)) - { - break; - } - } - - return( NULL); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_Record::createField( - FIELD * pCurField, - FIELD ** ppNewField) -{ - RCODE rc = NE_XFLM_OK; - FIELD * pNewField; - - if( m_pAvailFld) - { - pNewField = m_pAvailFld; - m_pAvailFld = m_pAvailFld->pNext; - if( m_pAvailFld) - m_pAvailFld->pPrev = NULL; - pNewField->pPrev = NULL; - pNewField->pNext = NULL; - } - else - { - if( RC_BAD( rc = m_pool.poolAlloc( sizeof( FIELD), (void **)&pNewField))) - { - goto Exit; - } - } - - if( !pCurField && m_pLastFld) - { - pCurField = m_pLastFld; - } - - if( pCurField) - { - pNewField->pNext = pCurField->pNext; - pNewField->pPrev = pCurField; - - if( pCurField->pNext) - { - pCurField->pNext->pPrev = pNewField; - } - pCurField->pNext = pNewField; - } - - if( !m_pFirstFld) - { - m_pFirstFld = pNewField; - } - - if( !m_pLastFld || pCurField == m_pLastFld) - { - m_pLastFld = pNewField; - } - - pNewField->uiDataLength = 0; - pNewField->uiDataOffset = 0; - *ppNewField = pNewField; - -Exit: - - return( rc); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_Record::getNewDataPtr( - FIELD * pField, - FLMUINT uiDataType, - FLMUINT uiNewLength, - FLMBYTE ** ppDataPtr) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE * pDataPtr; - FLMUINT uiTemp; - - if( pField->uiDataLength) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_NOT_IMPLEMENTED); - goto Exit; - } - - if( uiNewLength <= sizeof( FLMUINT)) - { - pDataPtr = (FLMBYTE *) &(pField->uiDataOffset); - } - else - { - // If this is a binary field it must start on an aligned byte. - - if( uiDataType == FLM_4x_BINARY_TYPE && - (m_uiDataBufOffset & FLM_ALLOC_ALIGN) != 0) - { - uiTemp = (FLM_ALLOC_ALIGN + 1) - (m_uiDataBufOffset & FLM_ALLOC_ALIGN); - m_uiDataBufOffset += uiTemp; - } - - if( uiNewLength + m_uiDataBufOffset > m_uiDataBufLength) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_FAILURE); - goto Exit; - } - - pDataPtr = m_pDataBuf + m_uiDataBufOffset; - pField->uiDataOffset = m_uiDataBufOffset; - m_uiDataBufOffset += uiNewLength; - } - - pField->uiDataLength = uiNewLength; - *ppDataPtr = pDataPtr; - -Exit: - - return( rc); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_Record::getINT( - void * pvField, - FLMINT * piNumber) -{ - return( pvField - ? storage2INT( getDataType( pvField), getDataLength( pvField), - getDataPtr( (FIELD *)pvField), piNumber) - : RC_SET( NE_XFLM_NOT_FOUND)); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_Record::getUINT( - void * pvField, - FLMUINT * puiNumber) -{ - return( pvField - ? storage2UINT( getDataType( pvField), getDataLength( pvField), - getDataPtr( (FIELD *)pvField), puiNumber) - : RC_SET( NE_XFLM_NOT_FOUND)); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_Record::getUINT32( - void * pvField, - FLMUINT32 * pui32Number) -{ - return( pvField - ? storage2UINT32( getDataType( pvField), getDataLength( pvField), - getDataPtr( (FIELD *)pvField), pui32Number) - : RC_SET( NE_XFLM_NOT_FOUND)); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_Record::getUnicode( - void * pvField, - FLMUNICODE * pUnicode, - FLMUINT * puiBufLen) -{ - return( pvField - ? getUnicode( getDataType( pvField), getDataLength( pvField), - getDataPtr( (FIELD *) pvField), puiBufLen, pUnicode) - : RC_SET( NE_XFLM_NOT_FOUND)); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_Record::getNative( - void * pvField, - char * pszString, - FLMUINT * puiBufLen) -{ - return( pvField - ? storage2Native( getDataType( pvField), getDataLength( pvField), - getDataPtr( (FIELD *) pvField), puiBufLen, pszString) - : RC_SET( NE_XFLM_NOT_FOUND)); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_Record::getBinary( - void * pvField, - void * pvBuf, - FLMUINT * puiBufLen) -{ - if( pvField) - { - *puiBufLen = f_min( *puiBufLen, getDataLength( pvField)); - f_memcpy( pvBuf, getDataPtr( (FIELD *)pvField), *puiBufLen); - return( NE_XFLM_OK); - } - - return( RC_SET( NE_XFLM_NOT_FOUND)); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -FLMBYTE * F_Record::getDataPtr( - FIELD * pField) -{ - if( !pField->uiDataLength) - { - return( NULL); - } - else if( pField->uiDataLength <= sizeof( FLMUINT)) - { - return (FLMBYTE *) &(pField->uiDataOffset); - } - - return( m_pDataBuf + pField->uiDataOffset); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_Record::storage2INT( - FLMUINT uiType, - FLMUINT uiBufLength, - FLMBYTE * pBuf, - FLMINT * piNum) -{ - RCODE rc = NE_XFLM_OK; - BCD_TYPE bcd; - - if( RC_BAD( rc = bcd2Num( uiType, uiBufLength, pBuf, &bcd))) - { - goto Exit; - } - - if( bcd.bNegFlag) - { - *piNum = -((FLMINT)bcd.uiNum); - if( !((bcd.uiNibCnt < 11) || - (bcd.uiNibCnt == 11 && - (!bcd.pucPtr || (f_memcmp( bcd.pucPtr, - gv_ucMinBcdINT32, 6) <= 0))))) - { - rc = RC_SET( NE_XFLM_CONV_NUM_UNDERFLOW); - goto Exit; - } - } - else - { - *piNum = (FLMINT)bcd.uiNum; - - if( !((bcd.uiNibCnt < 10) || - (bcd.uiNibCnt == 10 && - (!bcd.pucPtr || (f_memcmp( bcd.pucPtr, - gv_ucMaxBcdINT32, 5) <= 0))))) - { - rc = RC_SET( NE_XFLM_CONV_NUM_OVERFLOW); - goto Exit; - } - } - -Exit: - - return( rc); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_Record::storage2UINT( - FLMUINT uiType, - FLMUINT uiBufLength, - FLMBYTE * pBuf, - FLMUINT * puiNum) -{ - RCODE rc = NE_XFLM_OK; - BCD_TYPE bcd; - - if( RC_BAD( rc = bcd2Num( uiType, uiBufLength, pBuf, &bcd))) - { - goto Exit; - } - - *puiNum = bcd.uiNum; - - if( bcd.bNegFlag) - { - rc = RC_SET( NE_XFLM_CONV_NUM_UNDERFLOW); - goto Exit; - } - else if( bcd.uiNibCnt == 10) - { - if( !(!bcd.pucPtr || - (f_memcmp( bcd.pucPtr, gv_ucMaxBcdUINT32, 5) <= 0))) - { - rc = RC_SET( NE_XFLM_CONV_NUM_OVERFLOW); - goto Exit; - } - } - else if( bcd.uiNibCnt > 10) - { - rc = RC_SET( NE_XFLM_CONV_NUM_OVERFLOW); - goto Exit; - } - -Exit: - - return( rc); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_Record::storage2UINT32( - FLMUINT uiType, - FLMUINT uiBufLength, - FLMBYTE * pBuf, - FLMUINT32 * pui32Num) -{ - RCODE rc = NE_XFLM_OK; - BCD_TYPE bcd; - - if( RC_BAD( rc = bcd2Num( uiType, uiBufLength, pBuf, &bcd))) - { - goto Exit; - } - - *pui32Num = (FLMUINT32)bcd.uiNum; - - if( bcd.bNegFlag) - { - rc = RC_SET( NE_XFLM_CONV_NUM_UNDERFLOW); - goto Exit; - } - else if( bcd.uiNibCnt == 10) - { - if( !(!bcd.pucPtr || - (f_memcmp( bcd.pucPtr, gv_ucMaxBcdUINT32, 5) <= 0))) - { - rc = RC_SET( NE_XFLM_CONV_NUM_OVERFLOW); - goto Exit; - } - } - else if( bcd.uiNibCnt > 10) - { - rc = RC_SET( NE_XFLM_CONV_NUM_OVERFLOW); - goto Exit; - } - -Exit: - - return( rc); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_Record::bcd2Num( - FLMUINT uiType, - FLMUINT uiBufLength, - FLMBYTE * pBuf, - BCD_TYPE * bcd) -{ - RCODE rc = NE_XFLM_OK; - - if( !pBuf) - { - rc = RC_SET( NE_XFLM_CONV_NULL_SRC); - goto Exit; - } - - switch( uiType) - { - case FLM_4x_NUMBER_TYPE: - { - FLMUINT uiTotalNum = 0; - FLMUINT uiByte; - FLMUINT uiNibCnt; - - bcd->pucPtr = pBuf; - - // Get each nibble and use to create the number - -#define FLM_MAX_NIB_CNT 11 - - for( bcd->bNegFlag = - (FLMBOOL)(uiNibCnt = ((*pBuf & 0xF0) == 0xB0) ? 1 : 0); - uiNibCnt <= FLM_MAX_NIB_CNT; - uiNibCnt++ ) - { - uiByte = (uiNibCnt & 0x01) - ? (FLMUINT)(0x0F & *pBuf++) - : (FLMUINT)(*pBuf >> 4); - - if( uiByte == 0x0F) - { - break; - } - - // Multiply by 10 and add n - // NOTE: 10y = 8y + 2y = (y << 3) + (y << 1) - // faster than using the long multiply (10 * y) - - uiTotalNum = (uiTotalNum << 3) + (uiTotalNum << 1) + uiByte; - } - - bcd->uiNibCnt = uiNibCnt; - bcd->uiNum = uiTotalNum; - break; - } - - case FLM_4x_TEXT_TYPE: - { - FLMUINT uiNumber = 0; - - // If it is a TEXT Value, convert to a numeric value - // WARNING: The text is not null terminated - - while( uiBufLength--) - { - if( *pBuf < ASCII_ZERO || *pBuf > ASCII_NINE) - { - break; - } - - uiNumber = (uiNumber * 10) + (*pBuf - ASCII_ZERO); - pBuf++; - } - - bcd->uiNum = uiNumber; - bcd->uiNibCnt = 0; - bcd->bNegFlag = FALSE; - break; - } - - case FLM_4x_CONTEXT_TYPE : - { - if( uiBufLength == sizeof( FLMUINT32)) - { - bcd->uiNum = (FLMUINT)( FB2UD( pBuf)); - bcd->bNegFlag = 0; - - // Now set the uiNibCnt, the uiNibCnt will not be totally - // accurate, but it's close enough to get the value out... - - if( bcd->uiNum < FLM_MAX_UINT8) - { - bcd->uiNibCnt = 3; - } - else if( bcd->uiNum < FLM_MAX_UINT16) - { - bcd->uiNibCnt = 5; - } - else - { - bcd->uiNibCnt = 9; - } - } - - break; - } - - default : - { - rc = RC_SET_AND_ASSERT( NE_XFLM_CONV_ILLEGAL); - goto Exit; - } - } - -Exit: - - return( rc); -} - -/*************************************************************************** -Desc: -****************************************************************************/ -RCODE F_Record::getUnicode( - FLMUINT uiType, - FLMUINT uiBufLength, - FLMBYTE * pBuffer, - FLMUINT * puiStrBufLen, - FLMUNICODE * puzStrBuf) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE ucChar; - FLMUINT uiBytesProcessed = 0; - FLMUINT uiBytesOutput = 0; - FLMBOOL bOutputData = FALSE; - FLMUINT uiMaxOutLen; - FLMBYTE ucObjType; - FLMUINT uiObjLength = 0; - FLMBYTE tempBuf[ 80]; - FLMBYTE chrSet, chrVal; - FLMUNICODE newChrVal; - - // If the value is a number, convert to text first - - if( uiType != FLM_4x_TEXT_TYPE) - { - if( !pBuffer) - { - uiBufLength = 0; - } - else - { - if( uiType == FLM_4x_NUMBER_TYPE) - { - uiBufLength = sizeof( tempBuf); - if( RC_BAD( rc = numToText( pBuffer, tempBuf, &uiBufLength))) - { - goto Exit; - } - } - else if( uiType == FLM_4x_TEXT_TYPE) - { - uiBufLength = sizeof( tempBuf); - if( RC_BAD( rc = contextToText( pBuffer, tempBuf, &uiBufLength))) - { - goto Exit; - } - } - else - { - rc = RC_SET( NE_XFLM_CONV_ILLEGAL); - goto Exit; - } - - pBuffer = &tempBuf[ 0]; - } - } - - uiMaxOutLen = *puiStrBufLen; - if( puzStrBuf != NULL && uiMaxOutLen > 1) - { - bOutputData = TRUE; - uiMaxOutLen -= 2; - } - - // Parse through the string outputting data to the buffer as we go - - while( uiBytesProcessed < uiBufLength) - { - // Determine what we are pointing at - - ucChar = *pBuffer; - ucObjType = (FLMBYTE)textObjType( ucChar); - - switch( ucObjType) - { - case FLM_4x_ASCII_CHAR_CODE: - { - uiObjLength = 1; - if( bOutputData) - { - if( (uiMaxOutLen < 2) || (uiBytesOutput > uiMaxOutLen - 2)) - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto GetUNICODE_Output; - } - *puzStrBuf++ = ucChar; - } - uiBytesOutput += 2; - break; - } - - case FLM_4x_CHAR_SET_CODE: - { - uiObjLength = 2; - if( bOutputData) - { - if( (uiMaxOutLen < 2) || (uiBytesOutput > uiMaxOutLen - 2)) - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto GetUNICODE_Output; - } - - // Convert WP to UNICODE - - chrSet = ucChar & 0x3F; - chrVal = *(pBuffer + 1); - - if( RC_BAD( rc = flmWPToUnicode( - (((FLMUINT16)chrSet) << 8) | chrVal, &newChrVal))) - { - RC_UNEXPECTED_ASSERT( rc); - goto Exit; - } - - if( bOutputData) - { - if( (uiMaxOutLen < 2) || (uiBytesOutput > uiMaxOutLen - 2)) - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto GetUNICODE_Output; - } - *puzStrBuf++ = newChrVal; - } - } - - uiBytesOutput += 2; - break; - } - - case FLM_4x_WHITE_SPACE_CODE: - { - uiObjLength = 1; - - if( bOutputData) - { - if( (uiMaxOutLen < 2) || (uiBytesOutput > uiMaxOutLen - 2)) - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto GetUNICODE_Output; - } - - if( ucChar == (FLM_4x_WHITE_SPACE_CODE | 0x0C)) - { - *puzStrBuf = 9; - } - else if( ucChar == (FLM_4x_WHITE_SPACE_CODE | 0x0D)) - { - *puzStrBuf = 10; - } - else if( ucChar == (FLM_4x_WHITE_SPACE_CODE | 0x07)) - { - *puzStrBuf = 13; - } - else - { - *puzStrBuf = 0x20; - } - puzStrBuf++; - } - uiBytesOutput += 2; - break; - } - - case FLM_4x_EXT_CHAR_CODE: - { - uiObjLength = 3; - if( bOutputData) - { - if( (uiMaxOutLen < 2) || (uiBytesOutput > uiMaxOutLen - 2)) - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto GetUNICODE_Output; - } - - // Convert back from WP to UNICODE - - chrSet = *(pBuffer + 1); - chrVal = *(pBuffer + 2); - - if( RC_BAD( rc = flmWPToUnicode( - (((FLMUINT16)chrSet) << 8) | chrVal, &newChrVal))) - { - RC_UNEXPECTED_ASSERT( rc); - goto Exit; - } - - if( bOutputData) - { - if( (uiMaxOutLen < 2) || (uiBytesOutput > uiMaxOutLen - 2)) - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto GetUNICODE_Output; - } - *puzStrBuf++ = newChrVal; - } - } - uiBytesOutput += 2; - - break; - } - - case FLM_4x_OEM_CODE: - { - uiObjLength = 2; - break; - } - - case FLM_4x_UNICODE_CODE: - { - uiObjLength = 3; - if( bOutputData) - { - if( (uiMaxOutLen < 2) || (uiBytesOutput > uiMaxOutLen - 2)) - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto GetUNICODE_Output; - } - *puzStrBuf++ = (*(pBuffer + 1) << 8) + *(pBuffer + 2); - } - uiBytesOutput += 2; - break; - } - - case FLM_4x_UNK_EQ_1_CODE: - { - uiObjLength = 2; - if( bOutputData) - { - if( (uiMaxOutLen < 2) || (uiBytesOutput > uiMaxOutLen - 2)) - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto GetUNICODE_Output; - } - *puzStrBuf++ = *(pBuffer+1); - } - uiBytesOutput += 2; - break; - } - - default: - { - flmAssert( 0); - uiBytesProcessed = uiBufLength; - break; - } - } - - pBuffer += uiObjLength; - uiBytesProcessed += uiObjLength; - } - -GetUNICODE_Output: - - if( bOutputData) - { - *puzStrBuf = 0; - } - - *puiStrBufLen = uiBytesOutput; - -Exit: - - return( rc); -} - -/*************************************************************************** -Desc: Convert a storage text string into a native string -***************************************************************************/ -RCODE F_Record::storage2Native( - FLMUINT uiType, - FLMUINT uiBufLength, - FLMBYTE * pBuffer, - FLMUINT * puiOutBufLenRV, - char * pOutBuffer) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE * ptr = pBuffer; - FLMBYTE * pucOut; - FLMBYTE ucChar; - FLMUINT uiBytesProcessed; - FLMUINT uiBytesOutput; - FLMUINT uiValLength = uiBufLength; - FLMBOOL bOutputData = FALSE; - FLMUINT uiMaxOutLen = 0; - FLMBYTE ucObjType; - FLMUINT uiObjLength = 0; - FLMBYTE TempBuf[ 80]; - - // If needed, try and convert the data to text - - if( uiType != FLM_4x_TEXT_TYPE) - { - if( !ptr) - { - uiValLength = 0; - } - else if( uiType == FLM_4x_NUMBER_TYPE) - { - uiValLength = sizeof( TempBuf); - if( RC_BAD( rc = numToText( ptr, TempBuf, &uiValLength))) - { - goto Exit; - } - ptr = &TempBuf[ 0]; - } - else if( uiType == FLM_4x_CONTEXT_TYPE) - { - uiValLength = sizeof( TempBuf); - if( RC_BAD( rc = contextToText( ptr, TempBuf, &uiValLength))) - { - goto Exit; - } - ptr = &TempBuf[ 0]; - } - else - { - rc = RC_SET( NE_XFLM_CONV_ILLEGAL); - goto Exit; - } - } - - if( pOutBuffer != NULL && *puiOutBufLenRV) - { - bOutputData = TRUE; - uiMaxOutLen = *puiOutBufLenRV - 1; - } - - uiBytesProcessed = 0; - uiBytesOutput = 0; - pucOut = (FLMBYTE *)pOutBuffer; - - // Parse through the string outputting data to the buffer - // as we go - - while( uiBytesProcessed < uiValLength) - { - // Determine what we are pointing at - - ucChar = *ptr; - ucObjType = (FLMBYTE)textObjType( ucChar); - switch( ucObjType) - { - case FLM_4x_ASCII_CHAR_CODE: - { - uiObjLength = 1; - if( bOutputData) - { - if( uiBytesOutput < uiMaxOutLen) - *pucOut++ = f_tonative( ucChar); - else - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto Native_Output; - } - } - uiBytesOutput++; - break; - } - - case FLM_4x_CHAR_SET_CODE: - { - uiObjLength = 2; - if( bOutputData) - { - if( uiBytesOutput < uiMaxOutLen) - { - if( (ucChar & (~ucObjType)) == 0) - { - *pucOut++ = f_tonative( *(ptr + 1)); - } - else - { - *pucOut++ = 0xFF; - } - } - else - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto Native_Output; - } - } - uiBytesOutput++; - break; - } - - case FLM_4x_WHITE_SPACE_CODE: - { - uiObjLength = 1; - - if( bOutputData) - { - if( uiBytesOutput < uiMaxOutLen) - { - ucChar &= (~FLM_4x_WHITE_SPACE_MASK); - if( (ucChar == 0x03) || - (ucChar == 0x04) || - (ucChar == 0x05)) - { - ucChar = ASCII_DASH; - } - else if( ucChar == 0x0C) - { - ucChar = ASCII_TAB; - } - else if( ucChar == 0x0D) - { - ucChar = 0x0A; - } - else if( ucChar == 0x07) - { - ucChar = 0x0D; - } - else - { - ucChar = 0x20; - } - - *pucOut++ = f_tonative( ucChar); - } - else - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto Native_Output; - } - } - uiBytesOutput++; - break; - } - - case FLM_4x_UNK_EQ_1_CODE: - { - uiObjLength = 2; - - // Skip it if it is not a NATIVE code - - if( (ucChar & (~ucObjType)) == 0x02) - { - if( bOutputData) - { - if( uiBytesOutput < uiMaxOutLen) - { - *pucOut++ = f_tonative( *(ptr + 1)); - } - else - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto Native_Output; - } - } - uiBytesOutput++; - } - break; - } - - case FLM_4x_EXT_CHAR_CODE: - { - uiObjLength = 3; - if( bOutputData) - { - if( uiBytesOutput < uiMaxOutLen) - { - *pucOut += 0xFF; - } - else - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto Native_Output; - } - } - uiBytesOutput++; - break; - } - - case FLM_4x_OEM_CODE: - { - uiObjLength = 2; - if( bOutputData) - { - if( uiBytesOutput < uiMaxOutLen) - { - *pucOut++ = f_tonative( *(ptr + 1)); - } - else - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto Native_Output; - } - } - uiBytesOutput++; - break; - } - - case FLM_4x_UNICODE_CODE: - { - uiObjLength = 3; - if( bOutputData) - { - if( uiBytesOutput < uiMaxOutLen ) - { - *pucOut++ = 0xFF; - } - else - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto Native_Output; - } - } - uiBytesOutput++; - break; - } - - default: - { - flmAssert( 0); - break; - } - } - - ptr += uiObjLength; - uiBytesProcessed += uiObjLength; - } - - // Add a terminating NULL character, but DO NOT increment the - // uiBytesOutput counter - -Native_Output: - - if( bOutputData) - { - *pucOut = 0; - } - - *puiOutBufLenRV = uiBytesOutput; - -Exit: - - return( rc); -} - -/*************************************************************************** -Desc: Convert a storage number into a storage text string -***************************************************************************/ -RCODE F_Record::numToText( - FLMBYTE * pucNum, - FLMBYTE * pucOutBuffer, - FLMUINT * puiBufLen) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE * pucOutput; - FLMBYTE ucChar; - FLMBYTE ucOutChar; - FLMUINT uiBytesOutput; - FLMBOOL bOutputData; - FLMUINT uiMaxOutLen; - FLMBOOL bFirstNibble; - - uiMaxOutLen = *puiBufLen; - bOutputData = ((pucOutBuffer != NULL) && uiMaxOutLen) ? TRUE : FALSE; - uiBytesOutput = 0; - pucOutput = pucOutBuffer; - - // Parse through the string outputting data to the buffer - // as we go - - if( !pucNum) - { - goto Exit; - } - - bFirstNibble = TRUE; - for( ;;) - { - if( bFirstNibble) - { - ucChar = (FLMBYTE)(*pucNum >> 4); - } - else - { - ucChar = (FLMBYTE)(*pucNum++ & 0x0F); - } - - bFirstNibble = !bFirstNibble; - - if( ucChar <= 9) - { - ucOutChar = (FLMBYTE)( ASCII_ZERO + ucChar); - } - else if( ucChar == 0x0F) - { - break; - } - else - { - rc = RC_SET( NE_XFLM_DATA_ERROR); - goto Exit; - } - - if( bOutputData) - { - if( uiBytesOutput < uiMaxOutLen) - { - *pucOutput++ = ucOutChar; - } - else - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto Exit; - } - } - - uiBytesOutput++; - } - -Exit: - - *puiBufLen = uiBytesOutput; - return( rc); -} - -/*************************************************************************** -Desc: Convert a context value into a storage text string -***************************************************************************/ -RCODE F_Record::contextToText( - FLMBYTE * pucValue, - FLMBYTE * pucOutBuffer, - FLMUINT * puiBufLen) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiMaxOutLen; - FLMUINT uiStrLen; - FLMUINT uiBytesOutput = 0; - FLMBOOL bOutputData; - FLMBYTE ucTmpBuf[ 32]; - - uiMaxOutLen = *puiBufLen; - bOutputData = ((pucOutBuffer != NULL) && uiMaxOutLen) ? TRUE : FALSE; - - if( !pucValue) - { - goto Exit; - } - - f_sprintf( (char *)ucTmpBuf, "%u", FB2UD( pucValue)); - uiStrLen = f_strlen( ucTmpBuf) + 1; - uiBytesOutput = f_min( uiStrLen, uiMaxOutLen); - - if( bOutputData) - { - f_memcpy( pucOutBuffer, ucTmpBuf, uiBytesOutput); - pucOutBuffer[ uiBytesOutput - 1] = 0; - } - - if( uiMaxOutLen < uiBytesOutput) - { - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); - goto Exit; - } - -Exit: - - *puiBufLen = uiBytesOutput; - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE F_4xReader::getRootBlock( - F_4x_LFILE * pLFile, - BTSK * pStack) -{ - RCODE rc = NE_XFLM_OK; - F_Block * pBlock = NULL; - - if( RC_BAD( rc = readBlock( pLFile->uiRootBlk, &pBlock))) - { - goto Exit; - } - - if( !(FLM_4x_BH_IS_ROOT_BLK( pBlock->m_pucBlk)) || - (pLFile->uiLfNum != FB2UW( &pBlock->m_pucBlk[ - FLM_4x_BH_LOG_FILE_NUM]))) - { - rc = RC_SET( NE_XFLM_DATA_ERROR); - goto Exit; - } - - // Set up the stack - - blkToStack( &pBlock, pStack); - -Exit: - - if( pBlock) - { - pBlock->Release(); - } - - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE F_4xReader::getBlock( - F_4x_LFILE * pLFile, - FLMUINT uiBlkAddr, - BTSK * pStack) -{ - RCODE rc = NE_XFLM_OK; - F_Block * pBlock = NULL; - - if( RC_BAD( rc = readBlock( uiBlkAddr, &pBlock))) - { - goto Exit; - } - - if( pLFile->uiLfNum != FB2UW( &pBlock->m_pucBlk[ - FLM_4x_BH_LOG_FILE_NUM])) - { - rc = RC_SET( NE_XFLM_DATA_ERROR); - goto Exit; - } - - // Set up the stack - - blkToStack( &pBlock, pStack); - -Exit: - - if( pBlock) - { - pBlock->Release(); - } - - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void F_4xReader::blkToStack( - F_Block ** ppBlock, - BTSK * pStack) -{ - FLMBYTE * pucBlk = (*ppBlock)->m_pucBlk; - FLMUINT uiBlkType; - - uiBlkType = (FLMUINT)(FLM_4x_BH_GET_TYPE( pucBlk)); - pStack->uiBlkType = uiBlkType; - - if( uiBlkType == FLM_4x_BHT_LEAF) - { - pStack->uiElmOvhd = FLM_4x_BBE_KEY; - } - else if( uiBlkType == FLM_4x_BHT_NON_LEAF_DATA) - { - pStack->uiElmOvhd = FLM_4x_BNE_DATA_OVHD; - } - else if( uiBlkType == FLM_4x_BHT_NON_LEAF) - { - pStack->uiElmOvhd = FLM_4x_BNE_KEY_START; - } - else if( uiBlkType == FLM_4x_BHT_NON_LEAF_COUNTS) - { - pStack->uiElmOvhd = FLM_4x_BNE_KEY_COUNTS_START; - } - else - { - flmAssert( 0); - pStack->uiElmOvhd = FLM_4x_BNE_KEY_START; - } - - pStack->uiKeyLen = 0; - pStack->uiPKC = 0; - pStack->uiPrevElmPKC = 0; - pStack->uiCurElm = FLM_4x_BH_OVHD; - pStack->uiBlkEnd = (FLMUINT)FB2UW( &pucBlk[ FLM_4x_BH_ELM_END]); - pStack->uiLevel = (FLMUINT)pucBlk[ FLM_4x_BH_LEVEL ]; - - if( pStack->pBlk) - { - pStack->pBlk->Release(); - } - - pStack->pBlk = *ppBlock; - *ppBlock = NULL; -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE F_4xReader::getFieldType( - FLMUINT uiFieldNum, - FLMUINT * puiType) -{ - RCODE rc = NE_XFLM_OK; - - if( uiFieldNum < m_uiFieldTblSize) - { - if( (*puiType = m_puiFieldTbl[ uiFieldNum - 1]) == - FLM_4x_UNKNOWN_TYPE) - { - rc = RC_SET( NE_XFLM_BAD_ELEMENT_NUM); - goto Exit; - } - } - else - { - // Check if the field is a FLAIM dictionary field. - // Most of these fields are TEXT fields. - - if( (uiFieldNum >= FLM_4x_DICT_FIELD_NUMS) && - (uiFieldNum <= FLM_4x_LAST_DICT_FIELD_NUM)) - { - *puiType = FLM_4x_TEXT_TYPE; - } - else if( uiFieldNum >= FLM_4x_UNREGISTERED_TAGS) - { - *puiType = FLM_4x_TEXT_TYPE; - } - else - { - rc = RC_SET( NE_XFLM_BAD_ELEMENT_NUM); - goto Exit; - } - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE F_4xReader::readDictionary( void) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiType; - FLMUINT uiFieldNum; - F_Record * pRec = NULL; - void * pvField; - - if( m_puiFieldTbl) - { - f_free( &m_puiFieldTbl); - } - m_uiFieldTblSize = 0; - - if( RC_BAD( rc = f_alloc( FLM_4x_RESERVED_TAG_NUMS, - &m_puiFieldTbl))) - { - goto Exit; - } - - m_uiFieldTblSize = FLM_4x_RESERVED_TAG_NUMS; - f_memset( m_puiFieldTbl, FLM_4x_UNKNOWN_TYPE, m_uiFieldTblSize); - setDefaultContainer( FLM_4x_DICT_CONTAINER); - - for( ;;) - { - if( RC_BAD( rc = retrieveNextRec( &pRec))) - { - if( rc != NE_XFLM_EOF_HIT) - { - goto Exit; - } - - rc = NE_XFLM_OK; - break; - } - - if( pRec->getFieldID( pRec->root()) == FLM_4x_FIELD_TAG) - { - pvField = pRec->firstChild( pRec->root()); - if( RC_BAD( rc = getTypeTag( pRec, pvField, &uiType))) - { - goto Exit; - } - - uiFieldNum = pRec->getID(); - flmAssert( uiFieldNum < FLM_4x_RESERVED_TAG_NUMS); - m_puiFieldTbl[ uiFieldNum - 1] = uiType; - } - } - -Exit: - - if( pRec) - { - pRec->Release(); - } - - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE F_4xReader::getTypeTag( - F_Record * pRec, - void * pvField, - FLMUINT * puiType) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiType; - FLMUINT uiBufLen; - char szTmpBuf[ 64]; - - uiBufLen = sizeof( szTmpBuf); - if( RC_BAD( rc = pRec->getNative( pvField, szTmpBuf, &uiBufLen))) - { - goto Exit; - } - - if( f_strnicmp( szTmpBuf, "text", 4) == 0) - { - uiType = FLM_4x_TEXT_TYPE; - } - else if( f_strnicmp( szTmpBuf, "numb", 4) == 0) - { - uiType = FLM_4x_NUMBER_TYPE; - } - else if( f_strnicmp( szTmpBuf, "bina", 4) == 0) - { - uiType = FLM_4x_BINARY_TYPE; - } - else if( f_strnicmp( szTmpBuf, "cont", 4) == 0) - { - uiType = FLM_4x_CONTEXT_TYPE; - } - else if( f_strnicmp( szTmpBuf, "blob", 4) == 0) - { - uiType = FLM_4x_BLOB_TYPE; - } - else - { - rc = RC_SET( NE_XFLM_SYNTAX); - goto Exit; - } - - *puiType = uiType; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Constructor -****************************************************************************/ -F_4xNameTable::F_4xNameTable() -{ - m_pool.poolInit( 1024); - m_ppSortedByTagName = NULL; - m_ppSortedByTagNum = NULL; - m_ppSortedByTagTypeAndName = NULL; - m_uiTblSize = 0; - m_uiNumTags = 0; - m_bTablesSorted = FALSE; -} - -/**************************************************************************** -Desc: Destructor -****************************************************************************/ -F_4xNameTable::~F_4xNameTable() -{ - clearTable(); - m_pool.poolFree(); -} - -/**************************************************************************** -Desc: Free everything in the table -****************************************************************************/ -void F_4xNameTable::clearTable( void) -{ - m_pool.poolFree(); - m_pool.poolInit( 1024); - - // NOTE: Only one allocation is used for m_ppSortedByTagName, - // m_ppSortedByTagNum, and m_ppSortedByTagTypeAndName - there is no - // need to free m_ppSortedByTagNum and m_ppSortedByTagTypeAndName. - - if (m_ppSortedByTagName) - { - f_free( &m_ppSortedByTagName); - m_ppSortedByTagNum = NULL; - m_ppSortedByTagTypeAndName = NULL; - m_uiTblSize = 0; - m_uiNumTags = 0; - } -} - -/**************************************************************************** -Desc: Compare two tag names. Name1 can be NATIVE or UNICODE. If a - non-NULL UNICODE string is passed, it will be used. Otherwise, - the NATIVE string will be used. -Note: Comparison is case insensitive for the ASCII characters A-Z. -****************************************************************************/ -FLMINT F_4xNameTable::tagNameCompare( - const FLMUNICODE * puzName1, // If NULL, use pszName1 for comparison - const char * pszName1, - const FLMUNICODE * puzName2) -{ - FLMUNICODE uzChar1; - FLMUNICODE uzChar2; - - if (puzName1) - { - for (;;) - { - uzChar1 = *puzName1; - uzChar2 = *puzName2; - - // Convert to lower case for comparison. - - if (uzChar1 >= 'A' && uzChar1 <= 'Z') - { - uzChar1 = uzChar1 - 'A' + 'a'; - } - if (uzChar2 >= 'A' && uzChar2 <= 'Z') - { - uzChar2 = uzChar2 - 'A' + 'a'; - } - - if (!uzChar1 || !uzChar2 || uzChar1 != uzChar2) - { - break; - } - - puzName1++; - puzName2++; - } - } - else - { - for (;;) - { - uzChar1 = (FLMUNICODE)*pszName1; - uzChar2 = *puzName2; - - // Convert to lower case for comparison. - - if (uzChar1 >= 'A' && uzChar1 <= 'Z') - { - uzChar1 = uzChar1 - 'A' + 'a'; - } - if (uzChar2 >= 'A' && uzChar2 <= 'Z') - { - uzChar2 = uzChar2 - 'A' + 'a'; - } - - if (!uzChar1 || !uzChar2 || uzChar1 != uzChar2) - { - break; - } - - pszName1++; - puzName2++; - } - } - - if (uzChar1) - { - return( (FLMINT)((uzChar2 && uzChar1 < uzChar2) - ? (FLMINT)-1 - : (FLMINT)1)); - } - else if (uzChar2) - { - return( -1); - } - else - { - return( 0); - } -} - -/**************************************************************************** -Desc: Lookup a tag by tag name. Tag name is passed in as a UNICODE - string or a NATIVE string. If a non-NULL UNICODE string is - passed in, it will be used. Otherwise, the NATIVE string will - be used. -****************************************************************************/ -FLM_4x_TAG_INFO * F_4xNameTable::findTagByName( - const FLMUNICODE * puzTagName, - const char * pszTagName, - FLMUINT * puiInsertPos) -{ - FLM_4x_TAG_INFO * pTagInfo = NULL; - FLMUINT uiTblSize; - FLMUINT uiLow; - FLMUINT uiMid; - FLMUINT uiHigh; - FLMINT iCmp; - - // Do binary search in the table - - if ((uiTblSize = m_uiNumTags) == 0) - { - if (puiInsertPos) - { - *puiInsertPos = 0; - } - goto Exit; - } - uiHigh = --uiTblSize; - uiLow = 0; - for (;;) - { - uiMid = (uiLow + uiHigh) / 2; - iCmp = tagNameCompare( puzTagName, pszTagName, - m_ppSortedByTagName [uiMid]->puzTagName); - if (iCmp == 0) - { - - // Found Match - - pTagInfo = m_ppSortedByTagName [uiMid]; - if (puiInsertPos) - { - *puiInsertPos = uiMid; - } - goto Exit; - } - - // Check if we are done - - if (uiLow >= uiHigh) - { - - // Done, item not found - - if (puiInsertPos) - { - *puiInsertPos = (iCmp < 0) - ? uiMid - : uiMid + 1; - } - goto Exit; - } - - if (iCmp < 0) - { - if (uiMid == 0) - { - if (puiInsertPos) - { - *puiInsertPos = 0; - } - goto Exit; - } - uiHigh = uiMid - 1; - } - else - { - if (uiMid == uiTblSize) - { - if (puiInsertPos) - { - *puiInsertPos = uiMid + 1; - } - goto Exit; - } - uiLow = uiMid + 1; - } - } - -Exit: - - return( pTagInfo); -} - -/**************************************************************************** -Desc: Lookup a tag by tag number. -****************************************************************************/ -FLM_4x_TAG_INFO * F_4xNameTable::findTagByNum( - FLMUINT uiTagNum, - FLMUINT * puiInsertPos) -{ - FLM_4x_TAG_INFO * pTagInfo = NULL; - FLMUINT uiTblSize; - FLMUINT uiLow; - FLMUINT uiMid; - FLMUINT uiHigh; - FLMUINT uiTblTagNum; - - // Do binary search in the table - - if ((uiTblSize = m_uiNumTags) == 0) - { - if (puiInsertPos) - { - *puiInsertPos = 0; - } - goto Exit; - } - - uiHigh = --uiTblSize; - uiLow = 0; - for (;;) - { - uiMid = (uiLow + uiHigh) / 2; - uiTblTagNum = m_ppSortedByTagNum [uiMid]->uiTagNum; - if (uiTagNum == uiTblTagNum) - { - - // Found Match - - pTagInfo = m_ppSortedByTagNum [uiMid]; - if (puiInsertPos) - { - *puiInsertPos = uiMid; - } - goto Exit; - } - - // Check if we are done - - if (uiLow >= uiHigh) - { - - // Done, item not found - - if (puiInsertPos) - { - *puiInsertPos = (uiTagNum < uiTblTagNum) - ? uiMid - : uiMid + 1; - } - goto Exit; - } - - if (uiTagNum < uiTblTagNum) - { - if (uiMid == 0) - { - if (puiInsertPos) - { - *puiInsertPos = 0; - } - goto Exit; - } - uiHigh = uiMid - 1; - } - else - { - if (uiMid == uiTblSize) - { - if (puiInsertPos) - { - *puiInsertPos = uiMid + 1; - } - goto Exit; - } - uiLow = uiMid + 1; - } - } - -Exit: - - return( pTagInfo); -} - -/**************************************************************************** -Desc: Lookup a tag by tag type and tag name. Tag name is passed - in as a UNICODE string or a NATIVE string. If a non-NULL - UNICODE string is passed in, it will be used. Otherwise, the - NATIVE string will be used. -****************************************************************************/ -FLM_4x_TAG_INFO * F_4xNameTable::findTagByTypeAndName( - const FLMUNICODE * puzTagName, - const char * pszTagName, - FLMUINT uiType, - FLMUINT * puiInsertPos) -{ - FLM_4x_TAG_INFO * pTagInfo = NULL; - FLMUINT uiTblType; - FLMUINT uiTblSize; - FLMUINT uiLow; - FLMUINT uiMid; - FLMUINT uiHigh; - FLMINT iCmp; - - // Do binary search in the table - - if ((uiTblSize = m_uiNumTags) == 0) - { - if (puiInsertPos) - { - *puiInsertPos = 0; - } - goto Exit; - } - uiHigh = --uiTblSize; - uiLow = 0; - for (;;) - { - uiMid = (uiLow + uiHigh) / 2; - uiTblType = m_ppSortedByTagTypeAndName [uiMid]->uiType; - if (uiType < uiTblType) - { - iCmp = -1; - } - else if (uiType > uiTblType) - { - iCmp = 1; - } - else if ((iCmp = tagNameCompare( puzTagName, pszTagName, - m_ppSortedByTagTypeAndName [uiMid]->puzTagName)) == 0) - { - - // Found Match - - pTagInfo = m_ppSortedByTagTypeAndName [uiMid]; - if (puiInsertPos) - { - *puiInsertPos = uiMid; - } - goto Exit; - } - - // Check if we are done - - if (uiLow >= uiHigh) - { - - // Done, item not found - - if (puiInsertPos) - { - *puiInsertPos = (iCmp < 0) - ? uiMid - : uiMid + 1; - } - goto Exit; - } - - if (iCmp < 0) - { - if (uiMid == 0) - { - if (puiInsertPos) - { - *puiInsertPos = 0; - } - goto Exit; - } - uiHigh = uiMid - 1; - } - else - { - if (uiMid == uiTblSize) - { - if (puiInsertPos) - { - *puiInsertPos = uiMid + 1; - } - goto Exit; - } - uiLow = uiMid + 1; - } - } - -Exit: - - return( pTagInfo); -} - -/**************************************************************************** -Desc: Copy a tag name to a UNICODE or NATIVE buffer. Truncate if - necessary. If a non-NULL UNICODE string is passed in, it will - be populated. Otherwise, the NATIVE string will be populated. -****************************************************************************/ -void F_4xNameTable::copyTagName( - FLMUNICODE * puzDestTagName, - char * pszDestTagName, - FLMUINT uiDestBufSize, // Bytes, must be enough for null terminator - FLMUNICODE * puzSrcTagName) -{ - if (puzDestTagName) - { - - // Decrement name buffer size by sizeof( FLMUNICODE) to allow for a - // terminating NULL character. uiDestBufSize better be at list big - // enough for a null terminating character. - - flmAssert( uiDestBufSize >= sizeof( FLMUNICODE)); - uiDestBufSize -= sizeof( FLMUNICODE); - - // Copy the name to the NATIVE buffer. Non-Ascii UNICODE characters - // will be returned as question marks (?). - - while (uiDestBufSize >= sizeof( FLMUNICODE) && *puzSrcTagName) - { - *puzDestTagName++ = *puzSrcTagName; - uiDestBufSize -= sizeof( FLMUNICODE); - puzSrcTagName++; - } - *puzDestTagName = 0; - } - else - { - // Decrement name buffer size by one to allow for a terminating - // NULL character. uiDestBufSize better be at list big - // enough for a null terminating character. - - flmAssert( uiDestBufSize); - uiDestBufSize--; - - // Copy the name to the NATIVE buffer. Non-Ascii UNICODE characters - // will be returned as question marks (?). - - while (uiDestBufSize && *puzSrcTagName) - { - if (*puzSrcTagName <= 127) - { - *pszDestTagName++ = (char)*puzSrcTagName; - } - else - { - *pszDestTagName++ = '?'; - } - uiDestBufSize--; - puzSrcTagName++; - } - *pszDestTagName = 0; - } -} - -/*************************************************************************** -Desc: Sort an array of SCACHE pointers by their block address. -****************************************************************************/ -void F_4xNameTable::sortTagTbl( - FLM_4x_TAG_INFO ** ppTagInfoTbl, - FLMUINT uiLowerBounds, - FLMUINT uiUpperBounds, - FLM_4x_TAG_COMPARE_FUNC fnTagCompare) -{ - FLMUINT uiLBPos; - FLMUINT uiUBPos; - FLMUINT uiMIDPos; - FLMUINT uiLeftItems; - FLMUINT uiRightItems; - FLM_4x_TAG_INFO * pCurTagInfo; - FLMINT iCompare; - -Iterate_Larger_Half: - - uiUBPos = uiUpperBounds; - uiLBPos = uiLowerBounds; - uiMIDPos = (uiUpperBounds + uiLowerBounds + 1) / 2; - pCurTagInfo = ppTagInfoTbl [uiMIDPos ]; - for (;;) - { - while (uiLBPos == uiMIDPos || // Don't compare with target - ((iCompare = - fnTagCompare( ppTagInfoTbl [uiLBPos], pCurTagInfo)) < 0)) - { - if (uiLBPos >= uiUpperBounds) - { - break; - } - uiLBPos++; - } - - while (uiUBPos == uiMIDPos || // Don't compare with target - (((iCompare = - fnTagCompare( pCurTagInfo, ppTagInfoTbl [uiUBPos])) < 0))) - { - if (!uiUBPos) - { - break; - } - uiUBPos--; - } - - if (uiLBPos < uiUBPos ) // Interchange and continue loop. - { - - // Exchange [uiLBPos] with [uiUBPos]. - - tagInfoSwap( ppTagInfoTbl, uiLBPos, uiUBPos); - uiLBPos++; // Scan from left to right. - uiUBPos--; // Scan from right to left. - } - else // Past each other - done - { - break; - } - } - - // Check for swap( LB, MID ) - cases 3 and 4 - - if( uiLBPos < uiMIDPos ) - { - - // Exchange [uiLBPos] with [uiMIDPos] - - tagInfoSwap( ppTagInfoTbl, uiMIDPos, uiLBPos); - uiMIDPos = uiLBPos; - } - else if( uiMIDPos < uiUBPos ) - { - - // Exchange [uUBPos] with [uiMIDPos] - - tagInfoSwap( ppTagInfoTbl, uiMIDPos, uiUBPos); - uiMIDPos = uiUBPos; - } - - // Check the left piece. - - uiLeftItems = (uiLowerBounds + 1 < uiMIDPos ) - ? uiMIDPos - uiLowerBounds // 2 or more - : 0; - uiRightItems = (uiMIDPos + 1 < uiUpperBounds ) - ? uiUpperBounds - uiMIDPos // 2 or more - : 0; - - if( uiLeftItems < uiRightItems ) - { - - // Recurse on the LEFT side and goto the top on the RIGHT side. - - if (uiLeftItems ) - { - sortTagTbl( ppTagInfoTbl, uiLowerBounds, uiMIDPos - 1, fnTagCompare); - } - uiLowerBounds = uiMIDPos + 1; - goto Iterate_Larger_Half; - } - else if (uiLeftItems ) // Compute a truth table to figure out this check. - { - - // Recurse on the RIGHT side and goto the top for the LEFT side. - - if (uiRightItems ) - { - sortTagTbl( ppTagInfoTbl, uiMIDPos + 1, uiUpperBounds, fnTagCompare); - } - uiUpperBounds = uiMIDPos - 1; - goto Iterate_Larger_Half; - } -} - -/**************************************************************************** -Desc: Allocate a new tag info structure and set it up. -****************************************************************************/ -RCODE F_4xNameTable::allocTag( - const FLMUNICODE * puzTagName, - const char * pszTagName, - FLMUINT uiTagNum, - FLMUINT uiType, - FLMUINT uiSubType, - FLM_4x_TAG_INFO ** ppTagInfo) -{ - RCODE rc = NE_XFLM_OK; - void * pvMark; - FLM_4x_TAG_INFO * pTagInfo; - FLMUINT uiNameSize; - FLMUNICODE * puzTmp; - - // Create a new tag info structure. - - pvMark = m_pool.poolMark(); - if( RC_BAD( rc = m_pool.poolAlloc( sizeof( FLM_4x_TAG_INFO), - (void **)&pTagInfo))) - { - goto Exit; - } - - // Allocate the space for the tag name. - - if (puzTagName) - { - uiNameSize = (f_unilen( puzTagName) + 1) * sizeof( FLMUNICODE); - if( RC_BAD( rc = m_pool.poolAlloc( uiNameSize, - (void **)&pTagInfo->puzTagName))) - { - goto Exit; - } - f_memcpy( pTagInfo->puzTagName, puzTagName, uiNameSize); - } - else - { - uiNameSize = (f_strlen( pszTagName) + 1) * sizeof( FLMUNICODE); - if( RC_BAD( rc = m_pool.poolAlloc( uiNameSize, - (void **)&pTagInfo->puzTagName))) - { - goto Exit; - } - puzTmp = pTagInfo->puzTagName; - while (*pszTagName) - { - *puzTmp++ = (FLMUNICODE)*pszTagName; - pszTagName++; - } - *puzTmp = 0; - } - pTagInfo->uiTagNum = uiTagNum; - pTagInfo->uiType = uiType; - pTagInfo->uiSubType = uiSubType; - -Exit: - - if (RC_BAD( rc)) - { - m_pool.poolReset( pvMark); - pTagInfo = NULL; - } - *ppTagInfo = pTagInfo; - - return( rc); -} - -/**************************************************************************** -Desc: Allocate the sort tables. -****************************************************************************/ -RCODE F_4xNameTable::reallocSortTables( - FLMUINT uiNewTblSize) -{ - RCODE rc = NE_XFLM_OK; - FLM_4x_TAG_INFO ** ppNewTbl; - - if( RC_BAD( rc = f_alloc( - sizeof( FLM_4x_TAG_INFO *) * uiNewTblSize * 3, &ppNewTbl))) - { - goto Exit; - } - - // Copy the old tables into the new. - - if (m_uiNumTags) - { - f_memcpy( ppNewTbl, m_ppSortedByTagName, - sizeof( FLM_4x_TAG_INFO *) * m_uiNumTags); - f_memcpy( &ppNewTbl [uiNewTblSize], m_ppSortedByTagNum, - sizeof( FLM_4x_TAG_INFO *) * m_uiNumTags); - f_memcpy( &ppNewTbl [uiNewTblSize + uiNewTblSize], - m_ppSortedByTagTypeAndName, - sizeof( FLM_4x_TAG_INFO *) * m_uiNumTags); - f_free( &m_ppSortedByTagName); - } - m_ppSortedByTagName = ppNewTbl; - m_ppSortedByTagNum = &ppNewTbl [uiNewTblSize]; - m_ppSortedByTagTypeAndName = &ppNewTbl [uiNewTblSize + uiNewTblSize]; - m_uiTblSize = uiNewTblSize; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Get a tag name, number, etc. using tag number ordering. - Tag name is returned as a UNICODE string or NATIVE string. If a - non-NULL UNICODE string is passed in, it will be used. - Otherwise, the NATIVE string will be used. -****************************************************************************/ -FLMBOOL F_4xNameTable::getNextTagNumOrder( - FLMUINT * puiNextPos, - FLMUNICODE * puzTagName, - char * pszTagName, - FLMUINT uiNameBufSize, - FLMUINT * puiTagNum, // May be NULL - FLMUINT * puiType, // May be NULL - FLMUINT * puiSubType) // May be NULL -{ - FLM_4x_TAG_INFO * pTagInfo = NULL; - - if (!m_bTablesSorted) - { - sortTags(); - } - - if (*puiNextPos < m_uiNumTags) - { - pTagInfo = m_ppSortedByTagNum [*puiNextPos]; - if (puiTagNum) - { - *puiTagNum = pTagInfo->uiTagNum; - } - if (puiType) - { - *puiType = pTagInfo->uiType; - } - if (puiSubType) - { - *puiSubType = pTagInfo->uiSubType; - } - - if( puzTagName || pszTagName) - { - copyTagName( puzTagName, pszTagName, uiNameBufSize, - pTagInfo->puzTagName); - } - - // Returned *puiNextPos should be the next one to retrieve. - - (*puiNextPos)++; - } - else - { - // Nothing more in list, but initialize return variables anyway. - - if (puzTagName) - { - *puzTagName = 0; - } - - if (pszTagName) - { - *pszTagName = 0; - } - - if (puiTagNum) - { - *puiTagNum = 0; - } - - if (puiType) - { - *puiType = 0; - } - - if (puiSubType) - { - *puiSubType = 0; - } - } - - return( (FLMBOOL)(pTagInfo ? (FLMBOOL)TRUE : (FLMBOOL)FALSE)); -} - -/**************************************************************************** -Desc: Get a tag name, number, etc. using tag name ordering. - Tag name is returned as a UNICODE string or NATIVE string. If a - non-NULL UNICODE string is passed in, it will be used. - Otherwise, the NATIVE string will be used. -****************************************************************************/ -FLMBOOL F_4xNameTable::getNextTagNameOrder( - FLMUINT * puiNextPos, - FLMUNICODE * puzTagName, - char * pszTagName, - FLMUINT uiNameBufSize, - FLMUINT * puiTagNum, // May be NULL - FLMUINT * puiType, // May be NULL - FLMUINT * puiSubType) // May be NULL -{ - FLM_4x_TAG_INFO * pTagInfo = NULL; - - if (!m_bTablesSorted) - { - sortTags(); - } - - if (*puiNextPos < m_uiNumTags) - { - pTagInfo = m_ppSortedByTagName [*puiNextPos]; - if (puiTagNum) - { - *puiTagNum = pTagInfo->uiTagNum; - } - if (puiType) - { - *puiType = pTagInfo->uiType; - } - if (puiSubType) - { - *puiSubType = pTagInfo->uiSubType; - } - - if( puzTagName || pszTagName) - { - copyTagName( puzTagName, pszTagName, uiNameBufSize, - pTagInfo->puzTagName); - } - - // Returned *puiNextPos should be the next one to retrieve. - - (*puiNextPos)++; - } - else - { - // Nothing more in list, but initialize return variables anyway. - - if (puzTagName) - { - *puzTagName = 0; - } - - if (pszTagName) - { - *pszTagName = 0; - } - - if (puiTagNum) - { - *puiTagNum = 0; - } - - if (puiType) - { - *puiType = 0; - } - - if (puiSubType) - { - *puiSubType = 0; - } - } - - return( (FLMBOOL)(pTagInfo ? (FLMBOOL)TRUE : (FLMBOOL)FALSE)); -} - -/**************************************************************************** -Desc: Get a tag name and number from type. Tag name is returned as a - UNICODE string or NATIVE string. If a non-NULL UNICODE string is - passed in, it will be used. Otherwise, the NATIVE string - will be used. -****************************************************************************/ -FLMBOOL F_4xNameTable::getFromTagType( - FLMUINT uiType, - FLMUINT * puiNextPos, // To get first, initialize to zero. - FLMUNICODE * puzTagName, - char * pszTagName, - FLMUINT uiNameBufSize, // In bytes - must be at least sizeof( FLMUNICODE) - FLMUINT * puiTagNum, // May be NULL - FLMUINT * puiSubType) // May be NULL -{ - FLM_4x_TAG_INFO * pTagInfo = NULL; - - if (!m_bTablesSorted) - { - sortTags(); - } - if (*puiNextPos == 0) - { - - // A value of zero indicates we should try to find the first - // one. - - (void)findTagByTypeAndName( NULL, "", uiType, puiNextPos); - if (*puiNextPos < m_uiNumTags && - m_ppSortedByTagTypeAndName [*puiNextPos]->uiType != uiType) - { - (*puiNextPos)++; - } - } - - if (*puiNextPos < m_uiNumTags && - m_ppSortedByTagTypeAndName [*puiNextPos]->uiType == uiType) - { - pTagInfo = m_ppSortedByTagTypeAndName [*puiNextPos]; - - if (puiTagNum) - { - *puiTagNum = pTagInfo->uiTagNum; - } - if (puiSubType) - { - *puiSubType = pTagInfo->uiSubType; - } - - if( puzTagName || pszTagName) - { - copyTagName( puzTagName, pszTagName, uiNameBufSize, - pTagInfo->puzTagName); - } - - // Returned *puiNextPos should be the next one to retrieve, so that - // it is not zero. - - (*puiNextPos)++; - } - else - { - // Type was not found, but initialize return variables anyway. - - if (puzTagName) - { - *puzTagName = 0; - } - if (pszTagName) - { - *pszTagName = 0; - } - if (puiTagNum) - { - *puiTagNum = 0; - } - if (puiSubType) - { - *puiSubType = 0; - } - } - - return( (FLMBOOL)(pTagInfo ? (FLMBOOL)TRUE : (FLMBOOL)FALSE)); -} - -/**************************************************************************** -Desc: Get a tag name from its tag number. Tag name is returned as a - UNICODE string or NATIVE string. If a non-NULL UNICODE string - is passed in, it will be used. Otherwise, the NATIVE string - will be used. -****************************************************************************/ -FLMBOOL F_4xNameTable::getFromTagNum( - FLMUINT uiTagNum, - FLMUNICODE * puzTagName, - char * pszTagName, - FLMUINT uiNameBufSize, // In bytes, at least enough for null char. - FLMUINT * puiType, // May be NULL - FLMUINT * puiSubType) // May be NULL -{ - FLM_4x_TAG_INFO * pTagInfo; - - if (!m_bTablesSorted) - { - sortTags(); - } - - if ((pTagInfo = findTagByNum( uiTagNum)) != NULL) - { - if (puiType) - { - *puiType = pTagInfo->uiType; - } - - if (puiSubType) - { - *puiSubType = pTagInfo->uiSubType; - } - - if( puzTagName || pszTagName) - { - copyTagName( puzTagName, pszTagName, uiNameBufSize, - pTagInfo->puzTagName); - } - } - else - { - // Tag number was not found, but initialize return variables anyway. - - if (puzTagName) - { - *puzTagName = 0; - } - - if (pszTagName) - { - *pszTagName = 0; - } - - if (puiType) - { - *puiType = 0; - } - - if (puiSubType) - { - *puiSubType = 0; - } - } - - return( (FLMBOOL)(pTagInfo ? (FLMBOOL)TRUE : (FLMBOOL)FALSE)); -} - -/**************************************************************************** -Desc: Get a tag number and type from its tag name. Tag name is passed - in as a UNICODE string or NATIVE string. If a non-NULL UNICODE - string is passed in, it will be used. Otherwise, the NATIVE - string will be used. -****************************************************************************/ -FLMBOOL F_4xNameTable::getFromTagName( - const FLMUNICODE * puzTagName, - const char * pszTagName, - FLMUINT * puiTagNum, // Cannot be NULL - FLMUINT * puiType, // May be NULL - FLMUINT * puiSubType) // May be NULL -{ - FLM_4x_TAG_INFO * pTagInfo; - - if (!m_bTablesSorted) - { - sortTags(); - } - - if ((pTagInfo = findTagByName( puzTagName, pszTagName)) != NULL) - { - flmAssert( puiTagNum); - *puiTagNum = pTagInfo->uiTagNum; - if (puiType) - { - *puiType = pTagInfo->uiType; - } - - if (puiSubType) - { - *puiSubType = pTagInfo->uiSubType; - } - } - else - { - // Tag name was not found, but initialize return variables anyway. - - *puiTagNum = 0; - if (puiType) - { - *puiType = 0; - } - if (puiSubType) - { - *puiSubType = 0; - } - } - - return( (FLMBOOL)(pTagInfo ? (FLMBOOL)TRUE : (FLMBOOL)FALSE)); -} - -/**************************************************************************** -Desc: Get a tag number from its tag name and type. Tag name is passed - in as a UNICODE or NATIVE string. If a non-NULL UNICODE string is - passed in, it will be used. Otherwise, the NATIVE string will - be used. -****************************************************************************/ -FLMBOOL F_4xNameTable::getFromTagTypeAndName( - const FLMUNICODE * puzTagName, - const char * pszTagName, - FLMUINT uiType, - FLMUINT * puiTagNum, // Cannot be NULL - FLMUINT * puiSubType) // May be NULL -{ - FLM_4x_TAG_INFO * pTagInfo; - - if (!m_bTablesSorted) - { - sortTags(); - } - - if ((pTagInfo = findTagByTypeAndName( puzTagName, pszTagName, - uiType)) != NULL) - { - flmAssert( puiTagNum); - *puiTagNum = pTagInfo->uiTagNum; - if (puiSubType) - { - *puiSubType = pTagInfo->uiSubType; - } - } - else - { - - // Tag name was not found, but initialize return variables anyway. - - *puiTagNum = 0; - if (puiSubType) - { - *puiSubType = 0; - } - } - - return( (FLMBOOL)(pTagInfo ? (FLMBOOL)TRUE : (FLMBOOL)FALSE)); -} - -/**************************************************************************** -Desc: Insert a tag info structure into the sorted tables at the - specified positions. -****************************************************************************/ -RCODE F_4xNameTable::insertTagInTables( - FLM_4x_TAG_INFO * pTagInfo, - FLMUINT uiTagNameTblInsertPos, - FLMUINT uiTagTypeAndNameTblInsertPos, - FLMUINT uiTagNumTblInsertPos) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiLoop; - - // See if we need to resize the tables. Start at 256. Double each - // time up to 2048. Then just add 2048 at a time. - - if (m_uiNumTags == m_uiTblSize) - { - FLMUINT uiNewSize; - - if (!m_uiTblSize) - { - uiNewSize = 256; - } - else if (m_uiTblSize < 2048) - { - uiNewSize = m_uiTblSize * 2; - } - else - { - uiNewSize = m_uiTblSize + 2048; - } - - if (RC_BAD( rc = reallocSortTables( uiNewSize))) - { - goto Exit; - } - } - - // Insert into the sorted-by-name table - - uiLoop = m_uiNumTags; - while (uiLoop > uiTagNameTblInsertPos) - { - m_ppSortedByTagName [uiLoop] = m_ppSortedByTagName [uiLoop - 1]; - uiLoop--; - } - m_ppSortedByTagName [uiTagNameTblInsertPos] = pTagInfo; - - // Insert into the sorted-by-number table - - uiLoop = m_uiNumTags; - while (uiLoop > uiTagNumTblInsertPos) - { - m_ppSortedByTagNum [uiLoop] = m_ppSortedByTagNum [uiLoop - 1]; - uiLoop--; - } - m_ppSortedByTagNum [uiTagNumTblInsertPos] = pTagInfo; - - // Insert into the sorted-by-tag-name-and-type table - - uiLoop = m_uiNumTags; - while (uiLoop > uiTagTypeAndNameTblInsertPos) - { - m_ppSortedByTagTypeAndName [uiLoop] = - m_ppSortedByTagTypeAndName [uiLoop - 1]; - uiLoop--; - } - m_ppSortedByTagTypeAndName [uiTagTypeAndNameTblInsertPos] = pTagInfo; - - // Increment the total number of tags - - m_uiNumTags++; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Add a tag to the table. Tag name is passed in as a UNICODE - string or NATIVE string. If a non-NULL UNICODE string is passed - in, it will be used. Otherwise, the NATIVE string will be used. -****************************************************************************/ -RCODE F_4xNameTable::addTag( - const FLMUNICODE * puzTagName, - const char * pszTagName, - FLMUINT uiTagNum, - FLMUINT uiType, - FLMUINT uiSubType, - FLMBOOL bCheckDuplicates) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiTagNameTblInsertPos; - FLMUINT uiTagTypeAndNameTblInsertPos; - FLMUINT uiTagNumTblInsertPos; - FLM_4x_TAG_INFO * pTagInfo; - - // Must have a non-NULL tag name. Use UNICODE string if it is - // non-NULL. Otherwise, use NATIVE string. - - if (puzTagName && *puzTagName) - { - pszTagName = NULL; - } - else if (pszTagName && *pszTagName) - { - puzTagName = NULL; - } - else - { - rc = RC_SET_AND_ASSERT( NE_XFLM_INVALID_PARM); - goto Exit; - } - - // Tag number of zero not allowed. - - if (!uiTagNum) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_INVALID_PARM); - goto Exit; - } - - // Tables must be sorted in order for this to work - - if (bCheckDuplicates) - { - if (!m_bTablesSorted) - { - sortTags(); - } - - // Make sure that the tag name is not already used. - - if (findTagByName( puzTagName, pszTagName, &uiTagNameTblInsertPos)) - { - rc = RC_SET( NE_XFLM_EXISTS); - goto Exit; - } - - // Make sure that the tag name + type is not already used. - - if (findTagByTypeAndName( puzTagName, pszTagName, - uiType, &uiTagTypeAndNameTblInsertPos)) - { - rc = RC_SET( NE_XFLM_EXISTS); - goto Exit; - } - - // Make sure that the tag number is not already used. - - if (findTagByNum( uiTagNum, &uiTagNumTblInsertPos)) - { - rc = RC_SET( NE_XFLM_EXISTS); - goto Exit; - } - } - else - { - uiTagNameTblInsertPos = - uiTagTypeAndNameTblInsertPos = - uiTagNumTblInsertPos = m_uiNumTags; - m_bTablesSorted = FALSE; - } - - // Create a new tag info structure. - - if (RC_BAD( rc = allocTag( puzTagName, pszTagName, uiTagNum, uiType, - uiSubType, &pTagInfo))) - { - goto Exit; - } - - // Insert the tag structure into the appropriate places in the - // sorted tables. - - if (RC_BAD( rc = insertTagInTables( pTagInfo, uiTagNameTblInsertPos, - uiTagTypeAndNameTblInsertPos, - uiTagNumTblInsertPos))) - { - goto Exit; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Sort the tag tables according to their respective criteria. -****************************************************************************/ -void F_4xNameTable::sortTags( void) -{ - if (!m_bTablesSorted && m_uiNumTags > 1) - { - sortTagTbl( m_ppSortedByTagName, 0, m_uiNumTags - 1, - compareTagNameOnly); - sortTagTbl( m_ppSortedByTagNum, 0, m_uiNumTags - 1, - compareTagNumOnly); - sortTagTbl( m_ppSortedByTagTypeAndName, 0, m_uiNumTags - 1, - compareTagTypeAndName); - } - m_bTablesSorted = TRUE; -} - -/**************************************************************************** -Desc: Initialize a name table from a database. -****************************************************************************/ -RCODE F_4xNameTable::setupNameTable( - F_4xReader * pDb) -{ - RCODE rc = NE_XFLM_OK; - F_Record * pRec = NULL; - FLMUINT uiDrn; - FLMUINT uiLoop; - void * pvField; - FLMUNICODE uzName[ 60]; - FLMUNICODE * puzName = &uzName[ 0]; - FLMUINT uiNameLen = sizeof( uzName); - FLMUINT uiLen; - FLMUINT uiSubType; - - // Clean out all existing tags, if any. - - clearTable(); - - // Find the next DRN in the dictionary container - - if( RC_BAD( rc = pDb->getNextDrn( FLM_4x_DICT_CONTAINER, &uiDrn))) - { - goto Exit; - } - - // Count the reserved tags - - for (uiLoop = 0; Flm4xDictTagInfo[ uiLoop].pszTagName; uiLoop++) - { - ; - } - - // Preallocate space so we don't have to do it over and over. - - if( RC_BAD( rc = reallocSortTables( uiLoop + uiDrn))) - { - goto Exit; - } - - // Add in all of the reserved dictionary tags. - - for( uiLoop = 0; Flm4xDictTagInfo[ uiLoop].pszTagName; uiLoop++) - { - if( RC_BAD( rc = addTag( NULL, - Flm4xDictTagInfo[ uiLoop].pszTagName, - Flm4xDictTagInfo[ uiLoop].uiTagNum, - FLM_4x_FIELD_TAG, - Flm4xDictTagInfo[ uiLoop].uiFieldType, FALSE))) - { - goto Exit; - } - } - - // Read through all of the dictionary records - - pDb->setDefaultContainer( FLM_4x_DICT_CONTAINER); - for( ;;) - { - if( RC_BAD( rc = pDb->retrieveNextRec( &pRec))) - { - if( rc != NE_XFLM_EOF_HIT) - { - goto Exit; - } - - rc = NE_XFLM_OK; - break; - } - - pvField = pRec->root(); - uiDrn = pRec->getID(); - - // Get the unicode name length (does not include NULL terminator) - - if( RC_BAD( rc = pRec->getUnicode( pvField, NULL, &uiLen))) - { - goto Exit; - } - - // Account for NULL character. - - uiLen += sizeof( FLMUNICODE); - - // See if we need a larger buffer to get the name. - - if (uiLen > uiNameLen) - { - FLMUNICODE * puzTmp; - - // Add enough for 60 more unicode characters. - - uiLen += (60 * sizeof( FLMUNICODE)); - - if( RC_BAD( rc = f_alloc( uiLen, &puzTmp))) - { - goto Exit; - } - - if (puzName != &uzName [0]) - { - f_free( &puzName); - } - - puzName = puzTmp; - uiNameLen = uiLen; - } - - // Get the tag name. - - uiLen = uiNameLen; - if (RC_BAD( rc = pRec->getUnicode( pvField, puzName, &uiLen))) - { - goto Exit; - } - - // Get the sub-type. - - if (pRec->getFieldID( pvField) == FLM_4x_FIELD_TAG) - { - void * pvFld = pRec->find( pvField, FLM_4x_TYPE_TAG, 1, FALSE); - - if (!pvFld || - RC_BAD( pDb->getTypeTag( pRec, pvFld, &uiSubType))) - { - uiSubType = FLM_4x_TEXT_TYPE; - } - } - else - { - uiSubType = 0; - } - - // Add tag to table, without sorting yet. - - if (RC_BAD( rc = addTag( puzName, NULL, uiDrn, - pRec->getFieldID( pvField), uiSubType, FALSE))) - { - goto Exit; - } - } - - sortTags(); - -Exit: - - if( RC_BAD( rc)) - { - clearTable(); - } - - if( pRec) - { - pRec->Release(); - } - - if( puzName != &uzName [0]) - { - f_free( &puzName); - } - - return( rc); -} diff --git a/xflaim/src/frecread.h b/xflaim/src/frecread.h deleted file mode 100644 index 1ac931b..0000000 --- a/xflaim/src/frecread.h +++ /dev/null @@ -1,1184 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Contains interfaces for reading FLAIM 4.x databases. -// -// Tabs: 3 -// -// Copyright (c) 2003-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: frecread.h 3109 2006-01-19 13:07:07 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#ifndef FRECREAD_H -#define FRECREAD_H - -class F_Block; -class F_4xNameTable; - -#define FLM_4x_RESERVED_TAG_NUMS 32100 -#define FLM_4x_UNREGISTERED_TAGS 32769 -#define FLM_4x_DICT_CONTAINER 32000 -#define FLM_4x_DATA_CONTAINER 32001 -#define FLM_4x_TRACKER_CONTAINER 32002 -#define FLM_4x_DICT_INDEX 32003 -#define FLM_4x_DICT_FIELD_NUMS 32100 -#define FLM_4x_LAST_DICT_FIELD_NUM 32175 - -#define FLM_4x_BH_MAX_LEVELS 8 -#define FLM_4x_BH_CHECKSUM_LOW 0 -#define FLM_4x_BH_ADDR 0 -#define FLM_4x_BH_PREV_BLK 4 -#define FLM_4x_BH_NEXT_BLK 8 -#define FLM_4x_BH_TYPE 12 -#define FLM_4x_BH_LEVEL 13 -#define FLM_4x_BH_ELM_END 14 -#define FLM_4x_BH_TRANS_ID 16 -#define FLM_4x_BH_PREV_TRANS_ID 20 -#define FLM_4x_BH_PREV_BLK_ADDR 24 -#define FLM_4x_BH_LOG_FILE_NUM 28 -#define FLM_4x_BH_CHECKSUM_HIGH 31 -#define FLM_4x_BH_OVHD 32 - -#define FLM_4x_BT_END 0xFFFFFFFF - -#define FLM_4x_BHT_FREE 0 // Free block - avail list -#define FLM_4x_BHT_LEAF 1 // Leaf block -#define FLM_4x_BHT_LFH_BLK 4 // LFH Header block -#define FLM_4x_BHT_NON_LEAF 6 // Non-leaf block - variable key size -#define FLM_4x_BHT_NON_LEAF_DATA 7 // Non-leaf block data block - fixed key size -#define FLM_4x_BHT_NON_LEAF_COUNTS 8 // Non-leaf index with counts - -#define FLM_4x_BH_GET_TYPE(blk) (((blk)[ FLM_4x_BH_TYPE]) & 0x0F) -#define FLM_4x_BH_IS_ROOT_BLK(blk) (((blk)[ FLM_4x_BH_TYPE]) & 0x80) - -#define FLM_4x_FOP_RECORD_INFO 0xB0 -#define FLM_4x_FOP_IS_RECORD_INFO(p) ((*(p) & 0xFE) == FLM_4x_FOP_RECORD_INFO) - -#define FLM_4x_TEXT_TYPE 0 -#define FLM_4x_NUMBER_TYPE 1 -#define FLM_4x_BINARY_TYPE 2 -#define FLM_4x_CONTEXT_TYPE 3 -#define FLM_4x_BLOB_TYPE 8 -#define FLM_4x_UNKNOWN_TYPE 0xFFFFFFFF - -#define FLM_4x_FIELD_TAG (FLM_4x_RESERVED_TAG_NUMS + 0) -#define FLM_4x_INDEX_TAG (FLM_4x_RESERVED_TAG_NUMS + 1) -#define FLM_4x_TYPE_TAG (FLM_4x_RESERVED_TAG_NUMS + 2) -#define FLM_4x_CONTAINER_TAG (FLM_4x_RESERVED_TAG_NUMS + 4) -#define FLM_4x_LANGUAGE_TAG (FLM_4x_RESERVED_TAG_NUMS + 5) -#define FLM_4x_OPTIONAL_TAG (FLM_4x_RESERVED_TAG_NUMS + 6) -#define FLM_4x_UNIQUE_TAG (FLM_4x_RESERVED_TAG_NUMS + 7) -#define FLM_4x_KEY_TAG (FLM_4x_RESERVED_TAG_NUMS + 8) -#define FLM_4x_REFS_TAG (FLM_4x_RESERVED_TAG_NUMS + 9) -#define FLM_4x_AREA_TAG (FLM_4x_RESERVED_TAG_NUMS + 17) -#define FLM_4x_STATE_TAG (FLM_4x_RESERVED_TAG_NUMS + 25) -#define FLM_4x_BLOB_TAG (FLM_4x_RESERVED_TAG_NUMS + 26) -#define FLM_4x_THRESHOLD_TAG (FLM_4x_RESERVED_TAG_NUMS + 27) -#define FLM_4x_SUFFIX_TAG (FLM_4x_RESERVED_TAG_NUMS + 29) -#define FLM_4x_SUBDIRECTORY_TAG (FLM_4x_RESERVED_TAG_NUMS + 30) -#define FLM_4x_RESERVED_TAG (FLM_4x_RESERVED_TAG_NUMS + 31) -#define FLM_4x_SUBNAME_TAG (FLM_4x_RESERVED_TAG_NUMS + 32) -#define FLM_4x_NAME_TAG (FLM_4x_RESERVED_TAG_NUMS + 33) -#define FLM_4x_BASE_TAG (FLM_4x_RESERVED_TAG_NUMS + 36) -#define FLM_4x_CASE_TAG (FLM_4x_RESERVED_TAG_NUMS + 38) -#define FLM_4x_COMBINATIONS_TAG (FLM_4x_RESERVED_TAG_NUMS + 40) -#define FLM_4x_COUNT_TAG (FLM_4x_RESERVED_TAG_NUMS + 41) -#define FLM_4x_POSITIONING_TAG (FLM_4x_RESERVED_TAG_NUMS + 42) -#define FLM_4x_PAIRED_TAG (FLM_4x_RESERVED_TAG_NUMS + 44) -#define FLM_4x_PARENT_TAG (FLM_4x_RESERVED_TAG_NUMS + 45) -#define FLM_4x_POST_TAG (FLM_4x_RESERVED_TAG_NUMS + 46) -#define FLM_4x_REQUIRED_TAG (FLM_4x_RESERVED_TAG_NUMS + 47) -#define FLM_4x_USE_TAG (FLM_4x_RESERVED_TAG_NUMS + 48) -#define FLM_4x_FILTER_TAG (FLM_4x_RESERVED_TAG_NUMS + 49) -#define FLM_4x_LIMIT_TAG (FLM_4x_RESERVED_TAG_NUMS + 50) -#define FLM_4x_DICT_TAG (FLM_4x_RESERVED_TAG_NUMS + 54) -#define FLM_4x_RECINFO_TAG (FLM_4x_RESERVED_TAG_NUMS + 70) -#define FLM_4x_DRN_TAG (FLM_4x_RESERVED_TAG_NUMS + 71) -#define FLM_4x_DICT_SEQ_TAG (FLM_4x_RESERVED_TAG_NUMS + 72) -#define FLM_4x_LAST_CONTAINER_INDEXED_TAG (FLM_4x_RESERVED_TAG_NUMS + 73) -#define FLM_4x_LAST_DRN_INDEXED_TAG (FLM_4x_RESERVED_TAG_NUMS + 74) -#define FLM_4x_ONLINE_TRANS_ID_TAG (FLM_4x_RESERVED_TAG_NUMS + 75) - -#define FLM_4x_FIELD_TAG_NAME "Field" -#define FLM_4x_INDEX_TAG_NAME "Index" -#define FLM_4x_TYPE_TAG_NAME "Type" -#define FLM_4x_CONTAINER_TAG_NAME "Container" -#define FLM_4x_LANGUAGE_TAG_NAME "Language" -#define FLM_4x_OPTIONAL_TAG_NAME "Optional" -#define FLM_4x_UNIQUE_TAG_NAME "Unique" -#define FLM_4x_KEY_TAG_NAME "Key" -#define FLM_4x_REFS_TAG_NAME "Refs" -#define FLM_4x_AREA_TAG_NAME "Area" -#define FLM_4x_STATE_TAG_NAME "State" -#define FLM_4x_BLOB_TAG_NAME "Blob" -#define FLM_4x_THRESHOLD_TAG_NAME "Threshold" -#define FLM_4x_SUFFIX_TAG_NAME "Suffix" -#define FLM_4x_SUBDIRECTORY_TAG_NAME "Subdirectory" -#define FLM_4x_RESERVED_TAG_NAME "Reserved" -#define FLM_4x_SUBNAME_TAG_NAME "Subname" -#define FLM_4x_NAME_TAG_NAME "Name" -#define FLM_4x_BASE_TAG_NAME "Base" -#define FLM_4x_CASE_TAG_NAME "Case" -#define FLM_4x_COMBINATIONS_TAG_NAME "Combinations" -#define FLM_4x_COUNT_TAG_NAME "Count" -#define FLM_4x_POSITIONING_TAG_NAME "Positioning" -#define FLM_4x_PAIRED_TAG_NAME "Paired" -#define FLM_4x_PARENT_TAG_NAME "Parent" -#define FLM_4x_POST_TAG_NAME "Post" -#define FLM_4x_REQUIRED_TAG_NAME "Required" -#define FLM_4x_USE_TAG_NAME "Use" -#define FLM_4x_FILTER_TAG_NAME "Filter" -#define FLM_4x_LIMIT_TAG_NAME "Limit" -#define FLM_4x_DICT_TAG_NAME "Dict" -#define FLM_4x_RECINFO_TAG_NAME "RecInfo" -#define FLM_4x_DRN_TAG_NAME "Drn" -#define FLM_4x_DICT_SEQ_TAG_NAME "DictSeq" -#define FLM_4x_LAST_CONTAINER_INDEXED_TAG_NAME "LastContainerIndexed" -#define FLM_4x_LAST_DRN_INDEXED_TAG_NAME "LastDrnIndexed" -#define FLM_4x_ONLINE_TRANS_ID_TAG_NAME "OnlineTransId" - -#define FLM_4x_ASCII_CHAR_CODE 0x00 -#define FLM_4x_ASCII_CHAR_MASK 0x80 -#define FLM_4x_CHAR_SET_CODE 0x80 -#define FLM_4x_CHAR_SET_MASK 0xC0 -#define FLM_4x_WHITE_SPACE_CODE 0xC0 -#define FLM_4x_WHITE_SPACE_MASK 0xE0 -#define FLM_4x_UNK_GT_255_CODE 0xE0 -#define FLM_4x_UNK_GT_255_MASK 0xF8 -#define FLM_4x_UNK_EQ_1_CODE 0xF0 -#define FLM_4x_UNK_EQ_1_MASK 0xF8 -#define FLM_4x_UNK_LE_255_CODE 0xF8 -#define FLM_4x_UNK_LE_255_MASK 0xF8 -#define FLM_4x_EXT_CHAR_CODE 0xE8 -#define FLM_4x_OEM_CODE 0xE9 -#define FLM_4x_UNICODE_CODE 0xEA - -#define FLM_4x_FOP_IS_STANDARD(p) (!(*(p) & 0x80) ) -#define FLM_4x_FOP_OPEN 0x90 -#define FLM_4x_FOP_IS_OPEN(p) ((*(p) & 0xF0) == FLM_4x_FOP_OPEN) -#define FLM_4x_FOP_GET_FLD_FLAGS(p) ((*p) & 0x07) -#define FLM_4x_FOP_2BYTE_FLDNUM(bv) ((bv) & 0x02) -#define FLM_4x_FOP_2BYTE_FLDLEN(bv) ((bv) & 0x01) -#define FLM_4x_FOP_TAGGED 0x80 -#define FLM_4x_FOP_IS_TAGGED(p) ((*(p) & 0xF0) == FLM_4x_FOP_TAGGED) -#define FLM_4x_FOP_NO_VALUE 0xA8 -#define FLM_4x_FOP_IS_NO_VALUE(p) ((*(p) & 0xF8) == FLM_4x_FOP_NO_VALUE) -#define FLM_4x_FOP_SET_LEVEL 0xA0 -#define FLM_4x_FOP_IS_SET_LEVEL(p) ((*(p) & 0xF8) == FLM_4x_FOP_SET_LEVEL) -#define FLM_4x_FOP_LEVEL_MAX 0x07 -#define FLM_4x_FSLEV_GET(p) (*(p) & FLM_4x_FOP_LEVEL_MAX) -#define FLM_4x_FTAG_LEVEL(p) ((*p) & 0x08) -#define FLM_4x_FTAG_FLD_TYPE(p) ((*(p+1)) & 0x0F) -#define FLM_4x_FOPE_LEVEL(p) ((*p) & 0x08) -#define FLM_4x_FSTA_FLD_LEN(p) ((*p) & 0x3F) -#define FLM_4x_FSTA_LEVEL(p) ((*p) & 0x40) -#define FLM_4x_FSTA_FLD_NUM(p) (*(p+1)) -#define FLM_4x_FSTA_OVHD 2 -#define FLM_4x_FTAG_OVHD 2 -#define FLM_4x_FNOV_LEVEL(p) ((*p) & 0x04) - -#define FLM_4x_BBE_FIRST_FLAG 0x80 -#define FLM_4x_BBE_LAST_FLAG 0x40 -#define FLM_4x_BBE_IS_FIRST(elm) ((*(elm)) & FLM_4x_BBE_FIRST_FLAG ) -#define FLM_4x_BBE_IS_LAST(elm) ((*(elm)) & FLM_4x_BBE_LAST_FLAG ) -#define FLM_4x_BBE_KL_HBITS 0x30 -#define FLM_4x_BBE_PKC 0 -#define FLM_4x_BBE_PKC_MAX 0x0F -#define FLM_4x_BBE_GET_PKC(elm) ((*(elm)) & FLM_4x_BBE_PKC_MAX) -#define FLM_4x_BBE_KL 1 -#define FLM_4x_BBE_KL_SHIFT_BITS 4 -#define FLM_4x_BBE_GET_KL(elm) (((*(elm) & FLM_4x_BBE_KL_HBITS) << FLM_4x_BBE_KL_SHIFT_BITS) + \ - (elm)[ FLM_4x_BBE_KL]) -#define FLM_4x_BBE_GETR_PKC(elm) (*(elm) & 0x3F) -#define FLM_4x_BBE_GETR_KL(elm) ((elm)[FLM_4x_BBE_KL]) -#define FLM_4x_BBE_RL 2 -#define FLM_4x_BBE_GET_RL(elm) ((elm)[ FLM_4x_BBE_RL]) -#define FLM_4x_BBE_KEY 3 -#define FLM_4x_BBE_LEN(elm) (FLM_4x_BBE_GET_RL(elm) + FLM_4x_BBE_GET_KL(elm) + FLM_4x_BBE_KEY) -#define FLM_4x_BBE_LEM_LEN 3 -#define FLM_4x_BBE_REC_OFS(elm) (FLM_4x_BBE_GET_KL(elm) + FLM_4x_BBE_KEY) -#define FLM_4x_BBE_REC_PTR(elm) (&(elm)[ FLM_4x_BBE_REC_OFS(elm)]) - -#define FLM_4x_BNE_DATA_CHILD_BLOCK 4 -#define FLM_4x_BNE_DATA_OVHD 8 -#define FLM_4x_BNE_DOMAIN 0x80 -#define FLM_4x_BNE_IS_DOMAIN(elm) ((*(elm)) & FLM_4x_BNE_DOMAIN) -#define FLM_4x_BNE_DOMAIN_LEN 3 -#define FLM_4x_BNE_KEY_START 6 -#define FLM_4x_BNE_KEY_COUNTS_START 10 - -#define FLM_4x_DIN_KEY_SIZ 4 -#define FLM_4x_MAX_KEY_SIZ 640 -#define FLM_4x_IXD_UNIQUE 0x00001 - -#define FLM_4x_DRN_LAST_MARKER ((FLMUINT) 0xFFFFFFFF) - -#define FLM_4x_GET_BH_ADDR( pBlk) (FB2UD(&(pBlk)[ FLM_4x_BH_ADDR])) -#define FLM_4x_BLK_ELM( stack,elm) ((stack)->pBlk[ (elm)]) -#define FLM_4x_BLK_ELM_ADDR(stack,elm) (&((stack)->pBlk->m_pucBlk[ (elm)])) -#define FLM_4x_CURRENT_ELM(stack) (&((stack)->pBlk->m_pucBlk[ stack->uiCurElm])) -#define FLM_4x_FOP_IS_OPEN(p) ((*(p) & 0xF0) == FLM_4x_FOP_OPEN) - -#define FLM_4x_ASCII_CHAR_CODE 0x00 // 0nnnnnnn -#define FLM_4x_CHAR_SET_CODE 0x80 // 10nnnnnn -#define FLM_4x_WHITE_SPACE_CODE 0xC0 // 110nnnnn -#define FLM_4x_WHITE_SPACE_MASK 0xE0 // 11100000 -#define FLM_4x_UNK_EQ_1_CODE 0xF0 // 11110nnn -#define FLM_4x_EXT_CHAR_CODE 0xE8 // 11101000 -#define FLM_4x_OEM_CODE 0xE9 // 11101001 -#define FLM_4x_UNICODE_CODE 0xEA // 11101010 - -#define FLM_4x_FLM_FILE_HEADER_SIZE 172 -#define FLM_4x_FLAIM_HEADER_START (2048 - FLM_4x_FLM_FILE_HEADER_SIZE) -#define FLM_4x_DB_LOG_HEADER_START 16 -#define FLM_4x_FLAIM_NAME_POS 0 -#define FLM_4x_VER_POS 5 -#define FLM_4x_MINOR_VER_POS (FLM_4x_VER_POS + 2) -#define FLM_4x_SMINOR_VER_POS (FLM_4x_VER_POS + 3) -#define FLM_4x_DB_DEFAULT_LANGUAGE 13 -#define FLM_4x_DB_BLOCK_SIZE 14 -#define FLM_4x_DB_1ST_LFH_ADDR 32 - -#define FLM_4x_LOG_RFL_FILE_NUM 0 -#define FLM_4x_LOG_RFL_LAST_TRANS_OFFSET 4 -#define FLM_4x_LOG_RFL_LAST_CP_FILE_NUM 8 -#define FLM_4x_LOG_RFL_LAST_CP_OFFSET 12 -#define FLM_4x_LOG_ROLLBACK_EOF 16 -#define FLM_4x_LOG_INC_BACKUP_SEQ_NUM 20 -#define FLM_4x_LOG_CURR_TRANS_ID 24 -#define FLM_4x_LOG_COMMIT_COUNT 28 -#define FLM_4x_LOG_PL_FIRST_CP_BLOCK_ADDR 32 -#define FLM_4x_LOG_LAST_RFL_FILE_DELETED 36 -#define FLM_4x_LOG_RFL_MIN_FILE_SIZE 40 -#define FLM_4x_LOG_HDR_CHECKSUM 44 -#define FLM_4x_LOG_FLAIM_VERSION 46 -#define FLM_4x_LOG_LAST_BACKUP_TRANS_ID 48 -#define FLM_4x_LOG_BLK_CHG_SINCE_BACKUP 52 -#define FLM_4x_LOG_LAST_CP_TRANS_ID 56 -#define FLM_4x_LOG_PF_FIRST_BACKCHAIN 60 -#define FLM_4x_LOG_PF_AVAIL_BLKS 64 -#define FLM_4x_LOG_LOGICAL_EOF 68 -#define FLM_4x_LOG_LAST_RFL_COMMIT_ID 72 -#define FLM_4x_LOG_KEEP_ABORTED_TRANS_IN_RFL 76 -#define FLM_4x_LOG_PF_FIRST_BC_CNT 77 -#define FLM_4x_LOG_KEEP_RFL_FILES 78 -#define FLM_4x_LOG_AUTO_TURN_OFF_KEEP_RFL 79 -#define FLM_4x_LOG_PF_NUM_AVAIL_BLKS 80 -#define FLM_4x_LOG_RFL_MAX_FILE_SIZE 84 -#define FLM_4x_LOG_DB_SERIAL_NUM 88 -#define FLM_4x_LOG_LAST_TRANS_RFL_SERIAL_NUM 104 -#define FLM_4x_LOG_RFL_NEXT_SERIAL_NUM 120 -#define FLM_4x_LOG_INC_BACKUP_SERIAL_NUM 136 -#define FLM_4x_LOG_NU_152_153 152 -#define FLM_4x_LOG_MAX_FILE_SIZE 154 - -#define FLM_4x_LFH_LF_NUMBER_OFFSET 0 -#define FLM_4x_LFH_TYPE_OFFSET 2 -#define FLM_4x_LFH_STATUS_OFFSET 3 -#define FLM_4x_LFH_ROOT_BLK_OFFSET 4 -#define FLM_4x_LFH_NEXT_DRN_OFFSET 12 -#define FLM_4x_LFH_MAX_FILL_OFFSET 16 -#define FLM_4x_LFH_MIN_FILL_OFFSET 17 -#define FLM_4x_LFH_SIZE 32 - -#define FLM_4x_LFILE_DATA_CONTAINER_OFFSET 0 -#define FLM_4x_LFILE_DICT_CONTAINER_OFFSET 1 -#define FLM_4x_LFILE_DICT_INDEX_OFFSET 2 -#define FLM_4x_LFILE_TRACKER_CONTAINER_OFFSET 3 - -#define FLM_VER_4_0 400 -#define FLM_VER_4_3 430 -#define FLM_VER_4_31 431 -#define FLM_VER_4_50 450 -#define FLM_VER_4_51 451 - -/**************************************************************************** -Desc: -****************************************************************************/ -typedef struct -{ - F_Block * pBlk; - FLMBYTE ucKeyBuf[ FLM_4x_DIN_KEY_SIZ]; - FLMUINT uiKeyLen; - FLMUINT uiPKC; - FLMUINT uiPrevElmPKC; - FLMUINT uiBlkAddr; - FLMUINT uiCurElm; - FLMUINT uiBlkEnd; - FLMUINT uiElmOvhd; - FLMUINT uiBlkType; - FLMUINT uiLevel; -} BTSK; - -typedef struct -{ - FLMBYTE * pElement; - FLMUINT uiFieldType; - FLMUINT uiFieldLen; - FLMUINT uiPosInElm; - FLMUINT uiTagNum; - FLMUINT uiLevel; -} FSTATE; - -typedef struct Data_Piece -{ - FLMBYTE * pData; - FLMUINT uiLength; - struct Data_Piece * pNext; -} DATAPIECE; - -typedef struct -{ - FLMUINT uiLevel; - FLMUINT uiFieldID; - FLMUINT uiFieldType; - FLMUINT uiFieldLen; - DATAPIECE DataPiece; -} TFIELD; - -typedef struct Field_Group -{ -#define NUM_FIELDS_IN_ARRAY 16 - TFIELD pFields[ NUM_FIELDS_IN_ARRAY]; // Allocated array of fields - struct Field_Group * pNext; // Next temporary field group -} FLDGROUP; - -typedef struct Locked_Block -{ - F_Block * pBlock; - struct Locked_Block * pNext; -} LOCKED_BLOCK; - -typedef struct FlmField -{ - FLMUINT16 ui16FieldID; - FLMUINT8 ui8Level; - FLMUINT8 ui8Type; - FLMUINT uiDataLength; - FLMUINT uiDataOffset; - FlmField * pNext; - FlmField * pPrev; -} FIELD; - -typedef struct -{ - FLMUNICODE * puzTagName; - FLMUINT uiTagNum; - FLMUINT uiType; - FLMUINT uiSubType; -} FLM_4x_TAG_INFO; - -typedef struct -{ - FLMBYTE * pucPtr; - FLMUINT uiNibCnt; - FLMUINT uiNum; - FLMBOOL bNegFlag; - FLMBYTE ucNumBuf[ 12]; -} BCD_TYPE; - -typedef struct -{ - FLMUINT uiFirstLFHBlkAddr; // Address of first LFH block. - FLMUINT uiVersionNum; // Database version - FLMUINT uiBlockSize; // Block size - FLMUINT uiDefaultLanguage; // Default language - FLMUINT uiAppMajorVer; // Application major version number - FLMUINT uiAppMinorVer; // Application minor version number - FLMUINT uiSigBitsInBlkSize; // Number of significant bits in block - // size. 1K = 10, 2K = 11, 4K = 12 ... -} F_4x_FILE_HDR; - -typedef struct -{ - FLMUINT uiCurrTransID; // Current transaction ID. - FLMUINT uiFirstAvailBlkAddr; // Address of first block in avail list - FLMUINT uiAvailBlkCount; // Avail block count - FLMUINT uiLogicalEOF; // Current logical end of file. New - // blocks are allocated at this address. -} F_4x_LOG_HDR; - -typedef FLMINT (* FLM_4x_TAG_COMPARE_FUNC)( - FLM_4x_TAG_INFO * pTagInfo1, - FLM_4x_TAG_INFO * pTagInfo2); - -/**************************************************************************** -Struct: LFILE (Logical File) -Desc: This keeps track of the logical file information for an index or - a container. -****************************************************************************/ -typedef struct -{ - FLMUINT uiRootBlk; // Address of root block. - FLMUINT uiNextDrn; // Next DRN - only use when root is null - FLMUINT uiBlkAddress; // Block address of LFile entry. - FLMUINT uiOffsetInBlk; // Offset within block of entry. - FLMUINT uiLfNum; // Index number or container number. - FLMUINT uiLfType; // Type of logical file -#define FLM_4x_LF_CONTAINER 1 -#define FLM_4x_LF_INDEX 3 -#define FLM_4x_LF_INVALID 15 -} F_4x_LFILE; - -/************************************************************************** -Desc: -**************************************************************************/ -class F_Record : public XF_RefCount, public XF_Base -{ -public: - - F_Record(); - ~F_Record(); - - FINLINE FLMUINT getID( void) - { - return( m_uiRecordID); - } - - FINLINE void setID( - FLMUINT uiRecordID) - { - m_uiRecordID = uiRecordID; - } - - FINLINE FLMUINT getContainerID( void) - { - return( m_uiContainerID); - } - - FINLINE void setContainerID( - FLMUINT uiContainerID) - { - m_uiContainerID = uiContainerID; - } - - F_Record * copy( void); - - void clear(); - - RCODE getINT( - void * pvField, - FLMINT * piNumber); - - RCODE getUINT( - void * pvField, - FLMUINT * puiNumber); - - RCODE getUINT32( - void * pvField, - FLMUINT32 * pui32Number); - - RCODE getUnicode( - void * pvField, - FLMUNICODE * pUnicode, - FLMUINT * puiBufLen); - - RCODE getNative( - void * pvField, - char * pszString, - FLMUINT * puiBufLen); - - RCODE getBinary( - void * pvField, - void * pvBuf, - FLMUINT * puiBufLen); - - FINLINE FLMUINT getLevel( - void * pvField) - { - return( ((FIELD *)pvField)->ui8Level); - } - - FINLINE FLMUINT getFieldID( - void * pvField) - { - return( ((FIELD *)pvField)->ui16FieldID); - } - - FINLINE FLMUINT getDataType( - void * pvField) - { - return( ((FIELD *)pvField)->ui8Type & 0x0F); - } - - FINLINE FLMUINT getDataLength( - void * pvField) - { - return( ((FIELD *)pvField)->uiDataLength); - } - - FINLINE FLMBYTE * getExportDataPtr( - void * pvField) - { - return( getDataPtr( (FIELD *)pvField)); - } - - FINLINE FLMBOOL hasChild( - void * pvField) - { - return( (firstChildField( (FIELD *)pvField) != NULL) ? TRUE : FALSE); - } - - FINLINE FLMBOOL isLast( - void * pvField) - { - return( (nextField( (FIELD *)pvField) == NULL) ? TRUE : FALSE); - } - - FINLINE void * root( void) - { - return( m_pFirstFld); - } - - FINLINE void * nextSibling( - void * pvField) - { - return( pvField ? nextSiblingField( (FIELD *)pvField) : NULL); - } - - FINLINE void * firstChild( - void * pvField) - { - return( pvField ? firstChildField( (FIELD *)pvField) : NULL); - } - - FINLINE void * next( - void * pvField) - { - return( pvField ? nextField( (FIELD * )pvField) : NULL); - } - - FINLINE void * prev( - void * pvField) - { - return( pvField ? prevField( (FIELD *)pvField) : NULL); - } - - void * prevSibling( - void * pvField); - - void * lastChild( - void * pvField); - - void * parent( - void * pvField); - - void * find( - void * pvStartField, - FLMUINT uiFieldID, - FLMUINT uiOccur = 1, - FLMBOOL bSearchForest = FALSE); - - void * find( - void * pvStartField, - FLMUINT * puiFieldPath, - FLMUINT uiOccur = 1, - FLMBOOL bSearchForest = FALSE); - - RCODE preallocSpace( - FLMUINT uiDataSize); - - FLMBYTE * getImportDataPtr( - void * pvField, - FLMUINT uiDataType, - FLMUINT uiLength); - - RCODE insertLast( - FLMUINT uiLevel, - FLMUINT uiFieldID, - FLMUINT uiDataType, - void ** ppvField); - -private: - - void resetFieldList( void); - - FINLINE FIELD * getFirstField( void) - { - return( m_pFirstFld); - } - - FINLINE FIELD * prevField( - FIELD * pField) - { - return( (FIELD *)(pField ? pField->pPrev : NULL)); - } - - FINLINE FIELD * nextField( - FIELD * pField) - { - return( (FIELD *)(pField ? pField->pNext : NULL)); - } - - FIELD * nextSiblingField( - FIELD * pField); - - FINLINE FIELD * firstChildField( - FIELD * pField) - { - FLMUINT8 ui8Level = pField->ui8Level; - - return( ((pField = nextField( pField)) != NULL && - pField->ui8Level > ui8Level) - ? pField - : NULL); - } - - FIELD * lastSubTreeField( - FIELD * pField); - - RCODE createField( - FIELD * pCurField, - FIELD ** ppNewField); - - FLMBYTE * getDataPtr( - FIELD * pField); - - RCODE getNewDataPtr( - FIELD * pField, - FLMUINT uiDataType, - FLMUINT uiNewLength, - FLMBYTE ** ppDataPtr); - - RCODE storage2INT( - FLMUINT uiType, - FLMUINT uiBufLength, - FLMBYTE * pBuf, - FLMINT * piNum); - - RCODE storage2UINT( - FLMUINT uiType, - FLMUINT uiBufLength, - FLMBYTE * pBuf, - FLMUINT * puiNum); - - RCODE storage2UINT32( - FLMUINT uiType, - FLMUINT uiBufLength, - FLMBYTE * pBuf, - FLMUINT32 * pui32Num); - - RCODE bcd2Num( - FLMUINT uiType, - FLMUINT uiBufLength, - FLMBYTE * pBuf, - BCD_TYPE * bcd); - - RCODE getUnicode( - FLMUINT uiType, - FLMUINT uiBufLength, - FLMBYTE * pBuffer, - FLMUINT * puiStrBufLen, - FLMUNICODE * puzStrBuf); - - RCODE storage2Native( - FLMUINT uiType, - FLMUINT uiBufLength, - FLMBYTE * pBuffer, - FLMUINT * puiOutBufLenRV, - char * pszOutBuffer); - - RCODE numToText( - FLMBYTE * pucNum, - FLMBYTE * pucOutBuffer, - FLMUINT * puiBufLen); - - RCODE contextToText( - FLMBYTE * pucValue, - FLMBYTE * pucOutBuffer, - FLMUINT * puiBufLen); - - FLMUINT textObjType( - FLMBYTE ucObj) - { - if( (ucObj & FLM_4x_ASCII_CHAR_MASK) == - FLM_4x_ASCII_CHAR_CODE) - { - return( FLM_4x_ASCII_CHAR_CODE); - } - else if( (ucObj & FLM_4x_WHITE_SPACE_MASK) == - FLM_4x_WHITE_SPACE_CODE) - { - return( FLM_4x_WHITE_SPACE_CODE); - } - else if( (ucObj & FLM_4x_UNK_EQ_1_MASK) == - FLM_4x_UNK_EQ_1_CODE) - { - return( FLM_4x_UNK_EQ_1_CODE); - } - else if( (ucObj & FLM_4x_CHAR_SET_MASK) == - FLM_4x_CHAR_SET_CODE) - { - return( FLM_4x_CHAR_SET_CODE); - } - - return( ucObj); - } - - FLMUINT m_uiContainerID; - FLMUINT m_uiRecordID; - F_Pool m_pool; -#define FLM_4x_FIELD_LIST_SIZE 100 - FIELD m_fieldList[ FLM_4x_FIELD_LIST_SIZE]; - FIELD * m_pFirstFld; - FIELD * m_pLastFld; - FIELD * m_pAvailFld; - FLMBYTE * m_pDataBuf; - FLMUINT m_uiDataBufOffset; - FLMUINT m_uiDataBufLength; - -friend class F_4xReader; -}; - -/************************************************************************** -Desc: -**************************************************************************/ -class F_4xReader : public XF_RefCount, public XF_Base -{ -public: - - F_4xReader(); - - ~F_4xReader(); - - RCODE openDatabase( - char * pszPath); - - void closeDatabase( void); - - RCODE retrieveRec( - FLMUINT uiContainer, - FLMUINT uiDrn, - FLMUINT uiFlags, - F_Record ** ppRecord); - - RCODE retrieveNextRec( - F_Record ** ppRecord); - - RCODE getNextDrn( - FLMUINT uiContainer, - FLMUINT * puiDrn); - - RCODE getNameTable( - F_4xNameTable ** ppNameTable); - - FINLINE void setDefaultContainer( - FLMUINT uiContainer) - { - m_uiDefaultContainer = uiContainer; - } - -private: - - FINLINE void initStack( - BTSK * pStack) - { - FLMUINT uiNumLevels = FLM_4x_BH_MAX_LEVELS; - - while( uiNumLevels--) - { - pStack->pBlk = NULL; - pStack->uiBlkAddr = 0; - pStack++; - } - } - - void releaseStack( - BTSK * pStack); - - RCODE readRecElements( - BTSK * pStack, - F_4x_LFILE * pLFile, - F_Record ** ppRecord); - - RCODE getFldOverhead( - FSTATE * pState); - - RCODE btSearch( - F_4x_LFILE * pLFile, - FLMUINT uiDrn, - BTSK ** ppStack); - - RCODE blkNextElm( - BTSK * pStack); - - RCODE btNextElm( - BTSK * pStack, - F_4x_LFILE * pLFile); - - RCODE btPrevElm( - BTSK * pStack, - F_4x_LFILE * pLFile); - - RCODE btScan( - BTSK * pStack, - FLMBYTE * pucSearchKey); - - RCODE btScanNonLeafData( - BTSK * pStack, - FLMUINT uiDrn); - - RCODE btSearchEnd( - F_4x_LFILE * pLFile, - FLMUINT uiDrn, - BTSK ** ppStack); - - RCODE btAdjustStack( - BTSK * pStack, - F_4x_LFILE * pLFile, - FLMBOOL bMovedNext); - - FLMUINT childBlkAddr( - BTSK * pStack); - - FLMUINT lgHdrCheckSum( - FLMBYTE * pucLogHdr, - FLMBOOL bCompare); - - RCODE createLckFile( - char * pszFilePath); - - RCODE readBlock( - FLMUINT uiBlkAddr, - F_Block ** ppBlock); - - FINLINE FLMUINT getEncryptSize( - FLMBYTE * pucBlk) - { - FLMUINT uiLen = (FLMUINT)FB2UW( &pucBlk[ FLM_4x_BH_ELM_END]); - - if (uiLen % sizeof( FLMUINT32) != 0) - { - uiLen += (FLMUINT)(sizeof( FLMUINT32) - - (uiLen % sizeof( FLMUINT32))); - } - return( uiLen); - } - - RCODE blkCheckSum( - FLMBYTE * pucBlkPtr, - FLMUINT uiBlkAddress, - FLMUINT uiBlkSize); - - RCODE readLFiles( void); - - RCODE getLFile( - FLMUINT uiLFile, - F_4x_LFILE ** ppLFile); - - RCODE getRootBlock( - F_4x_LFILE * pLFile, - BTSK * pStack); - - RCODE getBlock( - F_4x_LFILE * pLFile, - FLMUINT uiBlkAddr, - BTSK * pStack); - - void blkToStack( - F_Block ** ppBlock, - BTSK * pStack); - - RCODE getFieldType( - FLMUINT uiFieldNum, - FLMUINT * puiType); - - RCODE readDictionary( void); - - RCODE getTypeTag( - F_Record * pRec, - void * pvField, - FLMUINT * puiType); - - FINLINE F_Block ** getHashBucket( - FLMUINT uiBlkAddress) - { - return( &m_ppBlockTbl[ - (((uiBlkAddress) >> m_fileHdr.uiSigBitsInBlkSize) & - (m_uiBlockTblSize - 1))]); - } - - // Data - - F_Pool m_tmpPool; - F_SuperFileHdl * m_pSuperHdl; - F_4x_FILE_HDR m_fileHdr; - F_4x_LOG_HDR m_logHdr; - F_4x_LFILE * m_pLFileTbl; - FLMUINT m_uiLFileCnt; - FLMUINT * m_puiFieldTbl; - FLMUINT m_uiFieldTblSize; - FLMUINT m_uiDefaultContainer; - F_FileHdl * m_pLckFile; - FLMUINT m_uiMaxFileSize; - F_Block ** m_ppBlockTbl; - FLMUINT m_uiBlockTblSize; - F_4xNameTable * m_pNameTable; - -friend class F_4xNameTable; -}; - -/************************************************************************** -Desc: -**************************************************************************/ -class F_Block : public XF_RefCount, public XF_Base -{ -public: - - F_Block() - { - m_pucBlk = NULL; - m_uiBlockSize = 0; - } - - ~F_Block() - { - if( m_pucBlk) - { - f_free( &m_pucBlk); - } - } - - FINLINE RCODE allocBlockBuf( - FLMUINT uiBlockSize) - { - RCODE rc = NE_XFLM_OK; - - flmAssert( getRefCount() == 1); - - if( !m_uiBlockSize) - { - if( RC_BAD( rc = f_alloc( uiBlockSize, &m_pucBlk))) - { - goto Exit; - } - } - else if( m_uiBlockSize != uiBlockSize) - { - if( RC_BAD( rc = f_realloc( uiBlockSize, &m_pucBlk))) - { - goto Exit; - } - } - - m_uiBlockSize = uiBlockSize; - - Exit: - - return( rc); - } - -private: - - FLMUINT m_uiBlockSize; - FLMBYTE * m_pucBlk; - -friend class F_4xReader; -}; - -/************************************************************************** -Desc: -**************************************************************************/ -class F_4xNameTable : public XF_RefCount, public XF_Base -{ -public: - - F_4xNameTable(); - - ~F_4xNameTable(); - - void clearTable( void); - - FLMBOOL getNextTagNumOrder( - FLMUINT * puiNextPos, - FLMUNICODE * puzTagName, - char * pszTagName, - FLMUINT uiNameBufSize, - FLMUINT * puiTagNum = NULL, - FLMUINT * puiType = NULL, - FLMUINT * puiSubType = NULL); - - FLMBOOL getNextTagNameOrder( - FLMUINT * puiNextPos, - FLMUNICODE * puzTagName, - char * pszTagName, - FLMUINT uiNameBufSize, - FLMUINT * puiTagNum = NULL, - FLMUINT * puiType = NULL, - FLMUINT * puiSubType = NULL); - - FLMBOOL getFromTagType( - FLMUINT uiType, - FLMUINT * puiNextPos, - FLMUNICODE * puzTagName, - char * pszTagName, - FLMUINT uiNameBufSize, - FLMUINT * puiTagNum = NULL, - FLMUINT * puiSubType = NULL); - - FLMBOOL getFromTagNum( - FLMUINT uiTagNum, - FLMUNICODE * puzTagName, - char * pszTagName, - FLMUINT uiNameBufSize, - FLMUINT * puiType = NULL, - FLMUINT * puiSubType = NULL); - - FLMBOOL getFromTagName( - const FLMUNICODE * puzTagName, - const char * pszTagName, - FLMUINT * puiTagNum, - FLMUINT * puiType = NULL, - FLMUINT * puiSubType = NULL); - - FLMBOOL getFromTagTypeAndName( - const FLMUNICODE * puzTagName, - const char * pszTagName, - FLMUINT uiType, - FLMUINT * puiTagNum, - FLMUINT * puiSubType = NULL); - - RCODE addTag( - const FLMUNICODE * puzTagName, - const char * pszTagName, - FLMUINT uiTagNum, - FLMUINT uiType, - FLMUINT uiSubType, - FLMBOOL bCheckDuplicates = TRUE); - - RCODE setupNameTable( - F_4xReader * pDb); - - void sortTags( void); - -private: - - RCODE allocTag( - const FLMUNICODE * puzTagName, - const char * pszTagName, - FLMUINT uiTagNum, - FLMUINT uiType, - FLMUINT uiSubType, - FLM_4x_TAG_INFO ** ppTagInfo); - - RCODE reallocSortTables( - FLMUINT uiNewTblSize); - - void copyTagName( - FLMUNICODE * puzDestTagName, - char * pszDestTagName, - FLMUINT uiDestBufSize, - FLMUNICODE * puzSrcTagName); - - FLM_4x_TAG_INFO * findTagByName( - const FLMUNICODE * puzTagName, - const char * pszTagName, - FLMUINT * puiInsertPos = NULL); - - FLM_4x_TAG_INFO * findTagByNum( - FLMUINT uiTagNum, - FLMUINT * puiInsertPos = NULL); - - FLM_4x_TAG_INFO * findTagByTypeAndName( - const FLMUNICODE * puzTagName, - const char * pszTagName, - FLMUINT uiType, - FLMUINT * puiInsertPos = NULL); - - RCODE insertTagInTables( - FLM_4x_TAG_INFO * pTagInfo, - FLMUINT uiTagNameTblInsertPos, - FLMUINT uiTagTypeAndNameTblInsertPos, - FLMUINT uiTagNumTblInsertPos); - - FINLINE void tagInfoSwap( - FLM_4x_TAG_INFO ** ppTagInfoTbl, - FLMUINT uiPos1, - FLMUINT uiPos2) - { - FLM_4x_TAG_INFO * pTmpTagInfo = ppTagInfoTbl [uiPos1]; - - ppTagInfoTbl [uiPos1] = ppTagInfoTbl [uiPos2]; - ppTagInfoTbl [uiPos2] = pTmpTagInfo; - } - - static FLMINT tagNameCompare( - const FLMUNICODE * puzName1, - const char * pszName1, - const FLMUNICODE * puzName2); - - static FINLINE FLMINT compareTagNumOnly( - FLM_4x_TAG_INFO * pTagInfo1, - FLM_4x_TAG_INFO * pTagInfo2) - { - if (pTagInfo1->uiTagNum < pTagInfo2->uiTagNum) - { - return( -1); - } - else if (pTagInfo1->uiTagNum > pTagInfo2->uiTagNum) - { - return( 1); - } - else - { - return( 0); - } - } - - static FINLINE FLMINT compareTagNameOnly( - FLM_4x_TAG_INFO * pTagInfo1, - FLM_4x_TAG_INFO * pTagInfo2) - { - return (tagNameCompare( pTagInfo1->puzTagName, NULL, - pTagInfo2->puzTagName)); - } - - static FINLINE FLMINT compareTagTypeAndName( - FLM_4x_TAG_INFO * pTagInfo1, - FLM_4x_TAG_INFO * pTagInfo2) - { - if (pTagInfo1->uiType < pTagInfo2->uiType) - { - return( -1); - } - else if (pTagInfo1->uiType > pTagInfo2->uiType) - { - return( 1); - } - else - { - return (tagNameCompare( pTagInfo1->puzTagName, NULL, - pTagInfo2->puzTagName)); - } - } - - void sortTagTbl( - FLM_4x_TAG_INFO ** ppTagInfoTbl, - FLMUINT uiLowerBounds, - FLMUINT uiUpperBounds, - FLM_4x_TAG_COMPARE_FUNC fnTagCompare); - - F_Pool m_pool; - FLM_4x_TAG_INFO ** m_ppSortedByTagName; - FLM_4x_TAG_INFO ** m_ppSortedByTagNum; - FLM_4x_TAG_INFO ** m_ppSortedByTagTypeAndName; - FLMUINT m_uiTblSize; - FLMUINT m_uiNumTags; - FLMBOOL m_bTablesSorted; -}; - -#endif diff --git a/xflaim/src/frestore.cpp b/xflaim/src/frestore.cpp index 5faf99e..72c330f 100644 --- a/xflaim/src/frestore.cpp +++ b/xflaim/src/frestore.cpp @@ -31,7 +31,7 @@ Desc: Constructor F_FSRestore::F_FSRestore() { m_pFileHdl = NULL; - m_pFileHdl64 = NULL; + m_pMultiFileHdl = NULL; m_ui64Offset = 0; m_bSetupCalled = FALSE; m_szDbPath[ 0] = 0; @@ -86,18 +86,17 @@ RCODE F_FSRestore::openBackupSet( void) RCODE rc = NE_XFLM_OK; flmAssert( m_bSetupCalled); - flmAssert( !m_pFileHdl64); - - if( (m_pFileHdl64 = f_new F_64BitFileHandle) == NULL) + flmAssert( !m_pMultiFileHdl); + + if( RC_BAD( rc = FlmAllocMultiFileHdl( &m_pMultiFileHdl))) { - rc = RC_SET( NE_XFLM_MEM); goto Exit; } - if( RC_BAD( rc = m_pFileHdl64->Open( m_szBackupSetPath))) + if( RC_BAD( rc = m_pMultiFileHdl->open( m_szBackupSetPath))) { - m_pFileHdl64->Release(); - m_pFileHdl64 = NULL; + m_pMultiFileHdl->Release(); + m_pMultiFileHdl = NULL; goto Exit; } @@ -131,8 +130,8 @@ RCODE F_FSRestore::openRflFile( if( !m_uiDbVersion) { - if( RC_BAD( rc = gv_pFileSystem->Open( m_szDbPath, - XFLM_IO_RDWR | XFLM_IO_SH_DENYNONE | XFLM_IO_DIRECT, &pFileHdl))) + if( RC_BAD( rc = gv_XFlmSysData.pFileSystem->openFile( m_szDbPath, + FLM_IO_RDWR | FLM_IO_SH_DENYNONE | FLM_IO_DIRECT, &pFileHdl))) { goto Exit; } @@ -142,7 +141,7 @@ RCODE F_FSRestore::openRflFile( goto Exit; } - pFileHdl->Close(); + pFileHdl->close(); pFileHdl->Release(); pFileHdl = NULL; @@ -158,12 +157,12 @@ RCODE F_FSRestore::openRflFile( uiBaseNameSize = sizeof( szBaseName); rflGetBaseFileName( uiFileNum, szBaseName, &uiBaseNameSize, NULL); - gv_pFileSystem->pathAppend( szRflPath, szBaseName); + gv_XFlmSysData.pFileSystem->pathAppend( szRflPath, szBaseName); // Open the file. - if( RC_BAD( rc = gv_pFileSystem->OpenBlockFile( szRflPath, - XFLM_IO_RDWR | XFLM_IO_SH_DENYNONE | XFLM_IO_DIRECT, 512, &m_pFileHdl))) + if( RC_BAD( rc = gv_XFlmSysData.pFileSystem->openBlockFile( szRflPath, + FLM_IO_RDWR | FLM_IO_SH_DENYNONE | FLM_IO_DIRECT, 512, &m_pFileHdl))) { goto Exit; } @@ -192,35 +191,32 @@ RCODE F_FSRestore::openIncFile( RCODE rc = NE_XFLM_OK; flmAssert( m_bSetupCalled); - flmAssert( !m_pFileHdl64); + flmAssert( !m_pMultiFileHdl); - /* - Since this is a non-interactive restore, we will "guess" - that incremental backups are located in the same parent - directory as the main backup set. We will further assume - that the incremental backup sets have been named XXXXXXXX.INC, - where X is a hex digit. - */ + // Since this is a non-interactive restore, we will "guess" + // that incremental backups are located in the same parent + // directory as the main backup set. We will further assume + // that the incremental backup sets have been named XXXXXXXX.INC, + // where X is a hex digit. - if( RC_BAD( rc = gv_pFileSystem->pathReduce( m_szBackupSetPath, + if( RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathReduce( m_szBackupSetPath, szIncPath, NULL))) { goto Exit; } f_sprintf( szIncFile, "%08X.INC", (unsigned)uiFileNum); - gv_pFileSystem->pathAppend( szIncPath, szIncFile); - - if( (m_pFileHdl64 = f_new F_64BitFileHandle) == NULL) + gv_XFlmSysData.pFileSystem->pathAppend( szIncPath, szIncFile); + + if( RC_BAD( rc = FlmAllocMultiFileHdl( &m_pMultiFileHdl))) { - rc = RC_SET( NE_XFLM_MEM); goto Exit; } - if( RC_BAD( rc = m_pFileHdl64->Open( szIncPath))) + if( RC_BAD( rc = m_pMultiFileHdl->open( szIncPath))) { - m_pFileHdl64->Release(); - m_pFileHdl64 = NULL; + m_pMultiFileHdl->Release(); + m_pMultiFileHdl = NULL; goto Exit; } @@ -244,11 +240,11 @@ RCODE F_FSRestore::read( RCODE rc = NE_XFLM_OK; flmAssert( m_bSetupCalled); - flmAssert( m_pFileHdl || m_pFileHdl64); + flmAssert( m_pFileHdl || m_pMultiFileHdl); - if( m_pFileHdl64) + if( m_pMultiFileHdl) { - if( RC_BAD( rc = m_pFileHdl64->Read( m_ui64Offset, + if( RC_BAD( rc = m_pMultiFileHdl->read( m_ui64Offset, uiLength, pvBuffer, &uiBytesRead))) { goto Exit; @@ -256,7 +252,7 @@ RCODE F_FSRestore::read( } else { - if( RC_BAD( rc = m_pFileHdl->Read( (FLMUINT)m_ui64Offset, + if( RC_BAD( rc = m_pFileHdl->read( (FLMUINT)m_ui64Offset, uiLength, pvBuffer, &uiBytesRead))) { goto Exit; @@ -282,10 +278,10 @@ RCODE F_FSRestore::close( void) { flmAssert( m_bSetupCalled); - if( m_pFileHdl64) + if( m_pMultiFileHdl) { - m_pFileHdl64->Release(); - m_pFileHdl64 = NULL; + m_pMultiFileHdl->Release(); + m_pMultiFileHdl = NULL; } if( m_pFileHdl) diff --git a/xflaim/src/frset.cpp b/xflaim/src/frset.cpp deleted file mode 100644 index 96aab67..0000000 --- a/xflaim/src/frset.cpp +++ /dev/null @@ -1,1960 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Result set routines -// -// Tabs: 3 -// -// Copyright (c) 1996-1998, 2003-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: frset.cpp 3114 2006-01-19 13:22:45 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -// Make sure that the extension is in lower case characters. - -#define FRSET_FILENAME_EXTENSION "frs" - -/* -** Sorting Result Sets: -** - New algorithm 7/2/97. This is a good one! - Below are refinements to the existing result set code. - - 1) We now have two files that are used in the merge-sort process. - The first file is used to hold all of the blocks created when - adding entries into the result set. The second file is used for - the first and thereafter odd merge steps. The first file is then - truncated and used for each even merge step. At the end of the - merge one of the files will be deleted. Three buffers are used - during merge and only one will remain after the merge is done. - This is safer than the previous method and uses a little less - disk space. There are many small improvements that can be made. - - 2) The result set code now takes a buffer and a length and has no - knowledge of the data in the result set. In fact, the data may - be fixed length or variable length. We removed the record cache - from the result set and made a record cache manager. - - Future enhancements to consider: - 1) Do a 3, 4 or N-Way merge. - This will greatly increase memory allocations but save a lot of time - reading and writing when the number of entries is large. - 2) Use 3 buffers on the initial load. This is really doing the first - phase of the merge when adding entries. The algorithm would add - entries to two buffers, and when full merge to the third buffer and - write out two sorted buffer. - 3) Don't write out the last block - use it as the first block of the - merge when not complete. This will save a write and read on each - pass. In addition, the I/O cache may be helped out. - In addition, the last block of each phase should be used first - on the next phase. - - Old Notes: - Duplicate Entries: - Duplicate entries are very difficult for a general purpose sorter - to find. In some cases the user would want to compare only these - fields and not these to determine a duplicate. This result set - code lets the user pass in a callback routine to determine if - two entries are the same and if one should be dropped. The user - could pass in NULL to cause all duplicates to be retained. - Quick Sort Algorithm: - This algorithm, in FRSETBLK.CPP is a great algorithm that Scott - came up with. It will recurse only Log(base2)N times (number of - bits needed to represent N). This is a breakthrough because - all sorting algorithms I have seen will recurse N-1 times if - the data is in order or in reverse order. This will crash the - stack for a production quality sort. - Variable Length - This sorting engine (result set) supports variable length and - fixed length data. There is very low overhead for variable - length support. This sorting engine can be used for a variety - of tasks. - - Example: - - All numbers are logical block numbers. - - Adding Pass 1 Pass2 Pass3 Pass4 - Phase File 2 File 1 File 2 File 1 - File 1 (created) (truncated) (truncated) (truncated) - ========= ========= ========= =========== ==================== - 1 10 (1+2) 14 (10+11) 16 (14+15) 17 Final file (16+9) - 2 - 3 11 (3+4) 15 (12+13) 9 - 4 - 5 12 (5+6) 9 - 6 - 7 13 (7+8) - 8 - 9 9 -*/ - -/***************************************************************************** -Desc: -*****************************************************************************/ -FResultSet::FResultSet() -{ - m_pCompare = NULL; - m_pSortStatus = NULL; - m_ui64EstTotalUnits = 0; - m_ui64UnitsDone = 0; - - m_uiEntrySize = 0; - m_ui64TotalEntries = 0; - m_pCurRSBlk = NULL; - m_pFirstRSBlk = NULL; - m_pLastRSBlk = NULL; - - f_memset( &m_szIoDefaultPath[0], 0, F_PATH_MAX_SIZE); - - m_pucBlockBuf1 = NULL; - m_pucBlockBuf2 = NULL; - m_pucBlockBuf3 = NULL; - m_uiBlockBuf1Len = 0; - m_bFile1Opened = FALSE; - m_bFile2Opened = FALSE; - m_pFileHdl641 = NULL; - m_pFileHdl642 = NULL; - m_bOutput2ndFile = FALSE; - m_bInitialAdding = TRUE; - m_bFinalizeCalled = FALSE; - m_bSetupCalled = FALSE; - m_uiBlkSize = RSBLK_BLOCK_SIZE; -} - -/***************************************************************************** -Desc: -*****************************************************************************/ -FResultSet::FResultSet( - FLMUINT uiBlkSize) -{ - m_pCompare = NULL; - m_pSortStatus = NULL; - m_ui64EstTotalUnits = 0; - m_ui64UnitsDone = 0; - - m_uiEntrySize = 0; - m_ui64TotalEntries = 0; - m_pCurRSBlk = NULL; - m_pFirstRSBlk = NULL; - m_pLastRSBlk = NULL; - - f_memset( &m_szIoDefaultPath[0], 0, F_PATH_MAX_SIZE); - - m_pucBlockBuf1 = NULL; - m_pucBlockBuf2 = NULL; - m_pucBlockBuf3 = NULL; - m_uiBlockBuf1Len = 0; - m_bFile1Opened = FALSE; - m_bFile2Opened = FALSE; - m_pFileHdl641 = NULL; - m_pFileHdl642 = NULL; - m_bOutput2ndFile = FALSE; - m_bInitialAdding = TRUE; - m_bFinalizeCalled = FALSE; - m_bSetupCalled = FALSE; - m_uiBlkSize = uiBlkSize; -} - -/***************************************************************************** -Desc: -*****************************************************************************/ -FResultSet::~FResultSet() -{ - FResultSetBlk *pCurRSBlk; - FResultSetBlk *pNextRSBlk; - - // Free up the result set block chain. - - for( pCurRSBlk = m_pFirstRSBlk; pCurRSBlk; pCurRSBlk = pNextRSBlk) - { - FLMUINT uiCount; - - pNextRSBlk = pCurRSBlk->m_pNext; - uiCount = pCurRSBlk->Release(); - flmAssert( !uiCount); - } - - // Set list to NULL for debugging in memory. - - m_pFirstRSBlk = NULL; - m_pLastRSBlk = NULL; - m_pCurRSBlk = NULL; - - // Free up all of the block buffers in the list. - - f_free( &m_pucBlockBuf1); - f_free( &m_pucBlockBuf2); - f_free( &m_pucBlockBuf3); - - // Close all opened files - - CloseFile( &m_pFileHdl641 ); - CloseFile( &m_pFileHdl642 ); - - if( m_pCompare) - { - m_pCompare->Release(); - } - - if( m_pSortStatus) - { - m_pSortStatus->Release(); - } -} - -/***************************************************************************** -Desc: Reset the result set so it can be reused. -*****************************************************************************/ -RCODE XFLMAPI FResultSet::resetResultSet( - FLMBOOL bDelete) -{ - RCODE rc = NE_XFLM_OK; - FResultSetBlk * pCurRSBlk; - FResultSetBlk * pNextRSBlk; - - // Free up the result set block chain - except for the first one. - - for( pCurRSBlk = m_pFirstRSBlk; pCurRSBlk; pCurRSBlk = pNextRSBlk) - { - FLMUINT uiCount; - - pNextRSBlk = pCurRSBlk->m_pNext; - if( pCurRSBlk != m_pFirstRSBlk) - { - uiCount = pCurRSBlk->Release(); - flmAssert( !uiCount); - } - } - - // Free up all of the block buffers in the list, except for the first one. - - f_free( &m_pucBlockBuf2); - f_free( &m_pucBlockBuf3); - - if( !m_pucBlockBuf1 || m_uiBlockBuf1Len != m_uiBlkSize) - { - if( m_pucBlockBuf1) - { - f_free( &m_pucBlockBuf1); - } - - if( RC_BAD( rc = f_alloc( m_uiBlkSize, &m_pucBlockBuf1))) - { - goto Exit; - } - - m_uiBlockBuf1Len = m_uiBlkSize; - } - - // Close all opened files - - CloseFile( &m_pFileHdl641, bDelete ); - CloseFile( &m_pFileHdl642 ); - m_bFile1Opened = m_bFile2Opened = FALSE; - m_pFileHdl641 = m_pFileHdl642 = NULL; - - // Reset some other variables - - if( m_pSortStatus) - { - m_pSortStatus->Release(); - m_pSortStatus = NULL; - } - - m_ui64EstTotalUnits = 0; - m_ui64UnitsDone = 0; - m_ui64TotalEntries = 0; - m_bOutput2ndFile = FALSE; - m_bInitialAdding = TRUE; - m_bEntriesInOrder = m_bAppAddsInOrder; - m_bFinalizeCalled = FALSE; - - // If we don't have a block, allocate it. Otherwise - // reset the one we have left. - - if( !m_pFirstRSBlk) - { - if( (m_pFirstRSBlk = f_new FResultSetBlk) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - } - else - { - m_pFirstRSBlk->reset(); - } - - m_pLastRSBlk = m_pCurRSBlk = m_pFirstRSBlk; - (void)m_pFirstRSBlk->Setup( &m_pFileHdl641, m_pCompare, - m_uiEntrySize, TRUE, m_bDropDuplicates, - m_bEntriesInOrder); - (void) m_pFirstRSBlk->SetBuffer( m_pucBlockBuf1, m_uiBlockBuf1Len); - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Setup the result set with all of the needed input values. - This method must only be called once. -*****************************************************************************/ -RCODE XFLMAPI FResultSet::setupResultSet( - const char * pszDirPath, - IF_ResultSetCompare * pCompare, - FLMUINT uiEntrySize, - FLMBOOL bDropDuplicates, - FLMBOOL bEntriesInOrder, - const char * pszInputFileName) -{ - RCODE rc = NE_XFLM_OK; - FLMBOOL bNewBlock = FALSE; - FLMBOOL bNewBuffer = FALSE; - - flmAssert( !m_bSetupCalled ); - flmAssert( uiEntrySize <= MAX_FIXED_ENTRY_SIZE); - - // Perform all of the allocations first. - - m_pFirstRSBlk = m_pLastRSBlk = m_pCurRSBlk = f_new FResultSetBlk; - - // Allocation Error? - - if( !m_pCurRSBlk) - { - rc = RC_SET( NE_XFLM_MEM ); - goto Exit; - } - - bNewBlock = TRUE; - m_pCurRSBlk->Setup( &m_pFileHdl641, pCompare, - uiEntrySize, TRUE, bDropDuplicates, bEntriesInOrder); - - // Allocate only the first buffer - other buffers only used in merge. - - if( RC_BAD( rc = f_alloc( m_uiBlkSize, &m_pucBlockBuf1))) - { - goto Exit; - } - - m_uiBlockBuf1Len = m_uiBlkSize; - bNewBuffer = TRUE; - (void) m_pCurRSBlk->SetBuffer( m_pucBlockBuf1, m_uiBlockBuf1Len); - - // Set the input variables. - - if( pszDirPath) - { - f_strcpy( m_szIoDefaultPath, pszDirPath); - } - - if( m_pCompare) - { - m_pCompare->Release(); - } - - if( (m_pCompare = pCompare) != NULL) - { - m_pCompare->AddRef(); - } - - m_uiEntrySize = uiEntrySize; - m_bDropDuplicates = bDropDuplicates; - m_bEntriesInOrder = m_bAppAddsInOrder = bEntriesInOrder; - - // If a filename was passed in, then we will try to open it and read whatever - // data it holds into the result set. If the file does not exist, it will not - // be created at this time. - - if( pszInputFileName) - { - f_strcpy( m_szIoFilePath1, m_szIoDefaultPath); - - if( RC_BAD( rc = gv_pFileSystem->pathAppend( - m_szIoFilePath1, pszInputFileName))) - { - goto Exit; - } - - f_strcat( m_szIoFilePath1, "." FRSET_FILENAME_EXTENSION); - - if( RC_BAD( rc = setupFromFile())) - { - goto Exit; - } - } - -Exit: - - // Free allocations on any error - - if( RC_BAD(rc)) - { - if( bNewBlock) - { - if( m_pCurRSBlk) - { - m_pCurRSBlk->Release(); - m_pFirstRSBlk = m_pLastRSBlk = m_pCurRSBlk = NULL; - } - } - - if( bNewBuffer) - { - f_free( &m_pucBlockBuf1); - m_uiBlockBuf1Len = 0; - } - } - else - { - m_bSetupCalled = TRUE; - } - - return( rc); -} - -/***************************************************************************** -Desc: Attempt to establish the result set from an existing file. -*****************************************************************************/ -RCODE XFLMAPI FResultSet::setupFromFile( void) -{ - RCODE rc = NE_XFLM_OK; - FResultSetBlk * pNextRSBlk; - FLMUINT uiOffset; - FLMUINT uiBytesRead; - F_BLOCK_HEADER BlkHdr; - - flmAssert( !m_bSetupCalled); - - if( (m_pFileHdl641 = f_new F_64BitFileHandle) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = m_pFileHdl641->Open( m_szIoFilePath1))) - { - if( rc == NE_XFLM_IO_PATH_NOT_FOUND) - { - if( RC_BAD( rc = m_pFileHdl641->Create( m_szIoFilePath1))) - { - rc = NE_XFLM_OK; - m_pFileHdl641->Release(); - m_pFileHdl641 = NULL; - goto Exit; - } - } - else - { - rc = NE_XFLM_OK; - m_pFileHdl641->Release(); - m_pFileHdl641 = NULL; - goto Exit; - } - } - - m_bFile1Opened = TRUE; - - // Release the current set of blocks. - - while( m_pFirstRSBlk) - { - m_pCurRSBlk = m_pFirstRSBlk; - m_pFirstRSBlk = m_pFirstRSBlk->m_pNext; - m_pCurRSBlk->Release(); - } - - m_pFirstRSBlk = m_pLastRSBlk = m_pCurRSBlk = NULL; - - // Allocate the buffer that we will use to read the data in. - - if( !m_pucBlockBuf1) - { - if( RC_BAD( rc = f_calloc( m_uiBlkSize, &m_pucBlockBuf1))) - { - goto Exit; - } - m_uiBlockBuf1Len = m_uiBlkSize; - } - else - { - f_memset( m_pucBlockBuf1, 0, m_uiBlkSize); - } - - // Now read every block in the file and create a FResultSetBlk chain. - - f_memset( (void *)&BlkHdr, 0, sizeof( F_BLOCK_HEADER)); - - for( uiOffset = 0;;) - { - // Read the block header - - if( RC_BAD( rc = m_pFileHdl641->Read( - BlkHdr.ui64FilePos + BlkHdr.uiBlockSize + uiOffset, - sizeof( F_BLOCK_HEADER), &BlkHdr, &uiBytesRead))) - { - if( rc == NE_XFLM_EOF_HIT || rc == NE_XFLM_IO_END_OF_FILE) - { - rc = NE_XFLM_OK; - break; - } - - goto Exit; - } - - // Put the previous block out of fous. - - if( m_pCurRSBlk) - { - if( RC_BAD( rc = m_pCurRSBlk->SetBuffer( NULL, m_uiBlkSize))) - { - goto Exit; - } - } - - // Allocate a new RSBlk and link into the result block list. - - if( (pNextRSBlk = f_new FResultSetBlk) == NULL) - { - rc = RC_SET( NE_XFLM_MEM ); - goto Exit; - } - - if( !m_pFirstRSBlk) - { - m_pFirstRSBlk = m_pLastRSBlk = m_pCurRSBlk = pNextRSBlk; - } - else - { - m_pCurRSBlk->m_pNext = pNextRSBlk; - pNextRSBlk->m_pPrev = m_pCurRSBlk; - m_pLastRSBlk = m_pCurRSBlk = pNextRSBlk; - } - - m_pCurRSBlk->Setup( &m_pFileHdl641, m_pCompare, m_uiEntrySize, - BlkHdr.bFirstBlock, m_bDropDuplicates, !m_bInitialAdding); - - f_memcpy( (void *)&m_pCurRSBlk->m_BlockHeader, - (void *)&BlkHdr, sizeof(F_BLOCK_HEADER)); - - // Process the block... - - if( RC_BAD( rc = m_pCurRSBlk->SetBuffer( m_pucBlockBuf1, m_uiBlkSize))) - { - goto Exit; - } - - m_pCurRSBlk->adjustState( m_uiBlkSize); - uiOffset = sizeof(F_BLOCK_HEADER); - } - - // If the file is empty or just created, we won't have a RS Block yet. - - if( !m_pCurRSBlk) - { - // Allocate a new RSBlk - - if( (pNextRSBlk = f_new FResultSetBlk) == NULL) - { - rc = RC_SET( NE_XFLM_MEM ); - goto Exit; - } - - if( !m_pFirstRSBlk) - { - m_pFirstRSBlk = m_pLastRSBlk = m_pCurRSBlk = pNextRSBlk; - } - else - { - m_pCurRSBlk->m_pNext = pNextRSBlk; - pNextRSBlk->m_pPrev = m_pCurRSBlk; - m_pLastRSBlk = m_pCurRSBlk = pNextRSBlk; - } - - m_pCurRSBlk->Setup( &m_pFileHdl641, m_pCompare, - m_uiEntrySize, m_bInitialAdding, m_bDropDuplicates, - !m_bInitialAdding ); - - if( RC_BAD( rc = m_pCurRSBlk->SetBuffer( m_pucBlockBuf1, m_uiBlkSize))) - { - goto Exit; - } - } - else - { - // Resize the file. - - if( RC_BAD(rc = m_pCurRSBlk->Truncate( (FLMBYTE *)m_szIoFilePath1))) - { - goto Exit; - } - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Write the current block and close the file. Call this function befor - calling resetResultSet so that it can be reused. -*****************************************************************************/ -RCODE XFLMAPI FResultSet::flushToFile() -{ - RCODE rc = NE_XFLM_OK; - - flmAssert( m_bFile1Opened); - - // Flush to disk what ever we have. - - if( RC_BAD( rc = m_pCurRSBlk->Flush( m_bInitialAdding, TRUE))) - { - goto Exit; - } - - if( RC_BAD( rc = m_pCurRSBlk->SetBuffer( NULL, m_uiBlkSize))) - { - goto Exit; - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Interface to add a variable length entry to the result set. -Notes: Public method used by application and by the internal sort - and merge steps during finalize. The user must never add an - entry that is larger than the block size. -*****************************************************************************/ -RCODE XFLMAPI FResultSet::addEntry( - const void * pvEntry, - FLMUINT uiEntryLength) // If zero then entry is fixed length -{ - RCODE rc = NE_XFLM_OK; - - flmAssert( m_bSetupCalled); - flmAssert( !m_bFinalizeCalled); - - rc = m_pCurRSBlk->AddEntry( (FLMBYTE *)pvEntry, uiEntryLength); - - // See if current block is full - - if( rc == NE_XFLM_EOF_HIT) - { - FResultSetBlk * pNextRSBlk; - F_64BitFileHandle ** ppFileHdl64; - - if( m_bInitialAdding && !m_bFile1Opened) - { - // Need to create and open the output file? - // In a merge we may be working on the 2nd file and NOT the 1st. - // There just isn't a better place to open the 1st file. - - if( RC_BAD(rc = OpenFile( &m_pFileHdl641))) - { - goto Exit; - } - } - - ppFileHdl64 = (m_bOutput2ndFile) ? &m_pFileHdl642 : &m_pFileHdl641; - - // Always flush to disk (TRUE) from here. - - if( RC_BAD( rc = m_pCurRSBlk->Flush( m_bInitialAdding, TRUE))) - { - goto Exit; - } - - (void) m_pCurRSBlk->SetBuffer( NULL, m_uiBlkSize); - - // Adding the current block is complete so allocate a new - // block object and link it into the list. - // We must continue to use this same block buffer. - - // Allocate a new RSBlk and link into the result block list. - - if( (pNextRSBlk = f_new FResultSetBlk) == NULL) - { - rc = RC_SET( NE_XFLM_MEM ); - goto Exit; - } - - m_pCurRSBlk->m_pNext = pNextRSBlk; - pNextRSBlk->m_pPrev = m_pCurRSBlk; - m_pLastRSBlk = m_pCurRSBlk = pNextRSBlk; - m_pCurRSBlk->Setup( ppFileHdl64, m_pCompare, - m_uiEntrySize, m_bInitialAdding, m_bDropDuplicates, - !m_bInitialAdding ); - - // Reset all of the buffer pointers and values. - - (void)m_pCurRSBlk->SetBuffer( m_pucBlockBuf1, m_uiBlockBuf1Len); - - // Make the callback only during the merge phase. - - if( !m_bInitialAdding && m_pSortStatus) - { - if( m_ui64EstTotalUnits <= ++m_ui64UnitsDone ) - { - m_ui64EstTotalUnits = m_ui64UnitsDone; - } - - if( RC_BAD( rc = m_pSortStatus->reportSortStatus( m_ui64EstTotalUnits, - m_ui64UnitsDone))) - { - goto Exit; - } - } - - // Add the entry again. This call should never fail because of space. - // If it does fail then the entry is larger than the buffer size. - - if( RC_BAD( rc = m_pCurRSBlk->AddEntry( - (FLMBYTE *)pvEntry, uiEntryLength))) - { - if( rc == NE_XFLM_EOF_HIT) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_FAILURE); - } - - goto Exit; - } - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Done adding entries. Sort all of the entries and perform a merge. -*****************************************************************************/ -RCODE XFLMAPI FResultSet::finalizeResultSet( - FLMUINT64 * pui64TotalEntries) -{ - RCODE rc = NE_XFLM_OK; - FLMBOOL bMergeSort; - - // Avoid being called more than once. - - flmAssert( !m_bFinalizeCalled); - flmAssert( m_bSetupCalled ); - - // Not a bug - but for future possibilities just check - // if there is more than one block and if so then - // the while() loop merge sort needs to be called. - - bMergeSort = (m_pFirstRSBlk != m_pLastRSBlk) ? TRUE : FALSE; - - // Force the write to disk if bMergeSort is TRUE. - - if( RC_BAD(rc = m_pCurRSBlk->Finalize( bMergeSort))) - { - goto Exit; - } - - m_bInitialAdding = FALSE; - - // If the entries are in order fixup the block chain and we are done. - - if( m_bEntriesInOrder) - { - FResultSetBlk * pBlk; - - if( NumberOfBlockChains() > 1) - { - // Entries already in order - need to fixup the blocks. - - for( pBlk = m_pFirstRSBlk; pBlk; pBlk = pBlk->m_pNext) - { - pBlk->m_BlockHeader.bFirstBlock = FALSE; - pBlk->m_BlockHeader.bLastBlock = FALSE; - } - - m_pFirstRSBlk->m_BlockHeader.bFirstBlock = TRUE; - m_pLastRSBlk->m_BlockHeader.bLastBlock = TRUE; - m_pCurRSBlk = NULL; - } - - goto Exit; - } - - // Compute total number of blocks. - - if( m_pSortStatus) - { - // Estimate total number of unit blocks to be written. - - FLMUINT64 ui64Units = NumberOfBlockChains(); - FLMUINT64 ui64Loops; - - m_ui64EstTotalUnits = 0; - for( ui64Loops = ui64Units; ui64Loops > 1; - ui64Loops = (ui64Loops + 1) / 2 ) - { - m_ui64EstTotalUnits += ui64Units; - } - } - - // Do the merge sort. - // Keep looping until we have only one block in the result set list. - - while( NumberOfBlockChains() > 1) - { - // Allocate two more buffers. Merge will open the 2nd file. - // Exit will free these allocations and close one of the files. - - // Are the 2nd and 3rd buffers allocated? - - if( !m_pucBlockBuf2) - { - if( RC_BAD( rc = f_alloc( m_uiBlkSize, &m_pucBlockBuf2))) - { - goto Exit; - } - } - - if( !m_pucBlockBuf3) - { - if( RC_BAD( rc = f_alloc( m_uiBlkSize, &m_pucBlockBuf3))) - { - goto Exit; - } - } - - // Swap which file is selected as the output file. - - m_bOutput2ndFile = m_bOutput2ndFile ? FALSE : TRUE; - - // Here is the magical call that does all of the work! - - if( RC_BAD( rc = MergeSort())) - { - goto Exit; - } - } - -Exit: - - // If we did a merge sort of multiple blocks then - // free the first and second buffers and close one of the files. - - if( RC_BAD(rc)) - { - f_free( &m_pucBlockBuf1); - m_uiBlockBuf1Len = 0; - } - - f_free( &m_pucBlockBuf2); - f_free( &m_pucBlockBuf3); - - // Close the non-output opened file. Close both on error. - // If m_bFile2Opened then we did a merge - close one file - - if( m_bFile2Opened || RC_BAD( rc)) - { - if( m_bOutput2ndFile || RC_BAD( rc)) - { - if( m_bFile1Opened) - { - m_pFileHdl641->Close( TRUE); - m_bFile1Opened = FALSE; - } - - if( m_pFileHdl641) - { - m_pFileHdl641->Release(); - m_pFileHdl641 = NULL; - } - } - - if( !m_bOutput2ndFile || RC_BAD( rc)) - { - if( m_bFile2Opened) - { - m_pFileHdl642->Close( TRUE); - m_bFile2Opened = FALSE; - } - - if( m_pFileHdl642) - { - m_pFileHdl642->Release(); - m_pFileHdl642 = NULL; - } - } - } - - if( RC_OK(rc)) - { - FLMUINT64 ui64Pos; - FResultSetBlk * pRSBlk; - - m_bFinalizeCalled = TRUE; - m_bEntriesInOrder = TRUE; - - m_ui64TotalEntries = getTotalEntries(); - - // Set the return value for total entries. - - if( pui64TotalEntries) - { - *pui64TotalEntries = m_ui64TotalEntries; - } - - if( !m_ui64TotalEntries) - { - if( m_pCurRSBlk) - { - m_pCurRSBlk->Release(); - } - - m_pCurRSBlk = NULL; - m_pFirstRSBlk = NULL; - m_pLastRSBlk = NULL; - f_free( &m_pucBlockBuf1); - m_uiBlockBuf1Len = 0; - } - - // Set the ui64BlkEntryPosition values in each block. - - for( ui64Pos = 0, pRSBlk = m_pFirstRSBlk; - pRSBlk; - pRSBlk = pRSBlk->m_pNext) - { - pRSBlk->m_ui64BlkEntryPosition = ui64Pos; - ui64Pos += pRSBlk->m_BlockHeader.uiEntryCount; - } - - // Resize the buffer to save space if only one block & in memory. - - if( m_pFirstRSBlk == m_pLastRSBlk && m_pCurRSBlk) - { - FLMBYTE * pucNewBlk; - FLMUINT uiLen = m_pCurRSBlk->BytesUsedInBuffer(); - - if( uiLen != m_uiBlockBuf1Len) - { - if( RC_OK( rc = f_alloc( uiLen, &pucNewBlk))) - { - f_memcpy( pucNewBlk, m_pucBlockBuf1, uiLen); - f_free( &m_pucBlockBuf1); - m_pucBlockBuf1 = pucNewBlk; - m_uiBlockBuf1Len = uiLen; - } - } - - // Need to always do the SetBuffer, because it causes the - // result set to get positioned. - - if( RC_OK( rc)) - { - rc = m_pCurRSBlk->SetBuffer( m_pucBlockBuf1, uiLen); - } - } - } - - // else on error finalize leaves the block list in an awful state. - - return( rc); -} - -/***************************************************************************** -Desc: Perform a Merge Sort on a list of result set blocks. This new - algorithm uses two files for the sort. The end result may - be one of the two files. At the end of the sort all old result set - block objects will be freed and only one result set block object - will be left. This RSBlk object will be used for reading the - entries. At this point there are at least 'N' result set block - objects that will be merged into ('N'/2) block objects. -*****************************************************************************/ -RCODE FResultSet::MergeSort( void) -{ - RCODE rc = NE_XFLM_OK; - FResultSetBlk * pBlkList = NULL; - FResultSetBlk * pTempBlk; - FResultSetBlk * pLeftBlk; - FResultSetBlk * pRightBlk; - F_64BitFileHandle ** ppFileHdl64; - - // Set output file and truncate it. - - // OpenFilex() Closes and creats a new file. - // This is prefered over truncating the file because - // if a database gets truncated we will be blamed. - - rc = (m_bOutput2ndFile) - ? OpenFile( &m_pFileHdl642) - : OpenFile( &m_pFileHdl641); - - if( RC_BAD( rc)) - { - RC_UNEXPECTED_ASSERT( rc); - goto Exit; - } - - ppFileHdl64 = ( m_bOutput2ndFile ) ? &m_pFileHdl642 : &m_pFileHdl641; - - // Get the list to the RS blocks - - pBlkList = m_pFirstRSBlk; - - // Form an empty list to build. - - m_pFirstRSBlk = m_pLastRSBlk = m_pCurRSBlk = NULL; - - // Read and UNION one or two blocks at a time getting rid of duplicates. - // Reading the entries when performing a union of only one block - // is a lot of work for nothing - but it simplifies the code. - - pTempBlk = pBlkList; - while (pTempBlk) - { - pLeftBlk = pTempBlk; - pRightBlk = pTempBlk->m_pNext; - - while( pRightBlk && !pRightBlk->m_BlockHeader.bFirstBlock) - { - pRightBlk = pRightBlk->m_pNext; - } - - // Allocate a new result set block list and link into the new list. - - if( (m_pCurRSBlk = f_new FResultSetBlk) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( !m_pLastRSBlk) - { - // First time - - m_pFirstRSBlk = m_pLastRSBlk = m_pCurRSBlk; - } - else - { - m_pLastRSBlk->m_pNext = m_pCurRSBlk; - m_pCurRSBlk->m_pPrev = m_pLastRSBlk; - m_pLastRSBlk = m_pCurRSBlk; - } - - m_pCurRSBlk->Setup( ppFileHdl64, m_pCompare, - m_uiEntrySize, TRUE, m_bDropDuplicates, TRUE); - - // Output to block buffer 1 - - (void)m_pCurRSBlk->SetBuffer( m_pucBlockBuf1, m_uiBlkSize ); - if( RC_BAD( rc = pLeftBlk->SetBuffer( m_pucBlockBuf2, m_uiBlkSize))) - { - goto Exit; - } - - if( pRightBlk) - { - if( RC_BAD( rc = pRightBlk->SetBuffer( m_pucBlockBuf3, m_uiBlkSize))) - { - goto Exit; - } - } - - // pRightBlk may be NULL - will move left block to output. - // Output leftBlk and rightBlk to the output block (m_pCurRSBlk) - - if( RC_BAD(rc = UnionBlkLists( pLeftBlk, pRightBlk))) - { - goto Exit; - } - - // Setup for the next loop. - - pTempBlk = pRightBlk ? pRightBlk->m_pNext : NULL; - while( pTempBlk && !pTempBlk->m_BlockHeader.bFirstBlock) - { - pTempBlk = pTempBlk->m_pNext; - } - } - -Exit: - - // Free the working block list. - - pTempBlk = pBlkList; - while( pTempBlk) - { - FLMUINT uiTemp; - - pRightBlk = pTempBlk->m_pNext; - uiTemp = pTempBlk->Release(); - flmAssert( uiTemp == 0); - pTempBlk = pRightBlk; - } - - return( rc); -} - -/***************************************************************************** -Desc: Return the Current entry reference in the result set. -*****************************************************************************/ -RCODE XFLMAPI FResultSet::getCurrent( - void * pvBuffer, - FLMUINT uiBufferLength, - FLMUINT * puiReturnLength) -{ - RCODE rc = NE_XFLM_OK; - - flmAssert( m_bFinalizeCalled); - - if( !m_pCurRSBlk) - { - rc = RC_SET( NE_XFLM_NOT_FOUND); - } - else - { - rc = m_pCurRSBlk->GetCurrent( (FLMBYTE *)pvBuffer, uiBufferLength, - puiReturnLength ); - } - - return( rc); -} - -/***************************************************************************** -Desc: Return the next reference in the result set. If the result set - is not positioned then the first entry will be returned. -*****************************************************************************/ -RCODE XFLMAPI FResultSet::getNext( - void * pvBuffer, - FLMUINT uiBufferLength, - FLMUINT * puiReturnLength) -{ - RCODE rc = NE_XFLM_OK; - - flmAssert( m_bFinalizeCalled); - - // Make sure we are positioned to a block. - - if( !m_pCurRSBlk) - { - m_pCurRSBlk = m_pFirstRSBlk; - if( !m_pCurRSBlk) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - - if( RC_BAD( rc = m_pCurRSBlk->SetBuffer( m_pucBlockBuf1, m_uiBlkSize))) - { - goto Exit; - } - } - - rc = m_pCurRSBlk->GetNext( (FLMBYTE *)pvBuffer, uiBufferLength, - puiReturnLength ); - - // Position to the next block? - - if( rc == NE_XFLM_EOF_HIT) - { - if( m_pCurRSBlk->m_pNext) - { - m_pCurRSBlk->SetBuffer( NULL); - m_pCurRSBlk = m_pCurRSBlk->m_pNext; - - if( RC_BAD( rc = m_pCurRSBlk->SetBuffer( m_pucBlockBuf1, m_uiBlkSize))) - { - goto Exit; - } - - if( RC_BAD( rc = m_pCurRSBlk->GetNext( - (FLMBYTE *)pvBuffer, uiBufferLength, puiReturnLength))) - { - goto Exit; - } - } - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Return the previous reference in the result set. If the result set - is not positioned then the last entry will be returned. -*****************************************************************************/ -RCODE XFLMAPI FResultSet::getPrev( - void * pvBuffer, - FLMUINT uiBufferLength, - FLMUINT * puiReturnLength) -{ - RCODE rc; - - flmAssert( m_bFinalizeCalled); - - // Make sure we are positioned to a block. - - if( !m_pCurRSBlk) - { - if( (m_pCurRSBlk = m_pLastRSBlk) == NULL) - { - rc = RC_SET( NE_XFLM_BOF_HIT); - goto Exit; - } - - if( RC_BAD( rc = m_pCurRSBlk->SetBuffer( m_pucBlockBuf1, m_uiBlkSize))) - { - goto Exit; - } - } - - rc = m_pCurRSBlk->GetPrev( (FLMBYTE *)pvBuffer, uiBufferLength, - puiReturnLength ); - - // Position to the previous block? - - if( rc == NE_XFLM_BOF_HIT) - { - if( m_pCurRSBlk->m_pPrev) - { - m_pCurRSBlk->SetBuffer( NULL); - m_pCurRSBlk = m_pCurRSBlk->m_pPrev; - if( RC_BAD( rc = m_pCurRSBlk->SetBuffer( m_pucBlockBuf1, m_uiBlkSize))) - { - goto Exit; - } - - if( RC_BAD( rc = m_pCurRSBlk->GetPrev( (FLMBYTE *)pvBuffer, - uiBufferLength, - puiReturnLength))) - { - goto Exit; - } - } - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Return the first reference in the result set. -*****************************************************************************/ -RCODE XFLMAPI FResultSet::getFirst( - void * pvBuffer, - FLMUINT uiBufferLength, - FLMUINT * puiReturnLength) -{ - RCODE rc; - - flmAssert( m_bFinalizeCalled); - - if( m_pCurRSBlk != m_pFirstRSBlk) - { - if( m_pCurRSBlk) - { - m_pCurRSBlk->SetBuffer( NULL); - } - - m_pCurRSBlk = m_pFirstRSBlk; - - if( RC_BAD( rc = m_pCurRSBlk->SetBuffer( m_pucBlockBuf1, m_uiBlkSize))) - { - goto Exit; - } - } - else if( !m_pCurRSBlk) - { - rc = RC_SET( NE_XFLM_NOT_FOUND); - goto Exit; - } - - if( RC_BAD( rc = m_pCurRSBlk->GetNext( (FLMBYTE *)pvBuffer, - uiBufferLength, puiReturnLength))) - { - goto Exit; - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Return the last reference in the result set. -*****************************************************************************/ -RCODE XFLMAPI FResultSet::getLast( - void * pvBuffer, - FLMUINT uiBufferLength, - FLMUINT * puiReturnLength) -{ - RCODE rc = NE_XFLM_OK; - - flmAssert( m_bFinalizeCalled); - - if( m_pCurRSBlk != m_pLastRSBlk) - { - if( m_pCurRSBlk) - { - m_pCurRSBlk->SetBuffer( NULL); - } - - m_pCurRSBlk = m_pLastRSBlk; - - if( RC_BAD( rc = m_pCurRSBlk->SetBuffer( m_pucBlockBuf1, m_uiBlkSize))) - { - goto Exit; - } - } - else if( !m_pCurRSBlk) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - - if( RC_BAD( rc = m_pCurRSBlk->GetPrev( (FLMBYTE *) pvBuffer, - uiBufferLength, puiReturnLength))) - { - goto Exit; - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Find the matching entry in the result set using the compare routine. - This does a binary search on the list of blocks. -*****************************************************************************/ -RCODE XFLMAPI FResultSet::findMatch( - const void * pvMatchEntry, // Entry to match - FLMUINT uiMatchEntryLength, // Variable length of above entry - void * pvFoundEntry, // (out) Entry to return - FLMUINT * puiFoundEntryLength) // (out) Length of entry returned -{ - RCODE rc = NE_XFLM_OK; - FLMINT iBlkCompare; // 0 if key is/would be in block. - FResultSetBlk * pLowBlk; // Used for locating block. - FResultSetBlk * pHighBlk; // Low and High are exclusive. - - flmAssert( m_bFinalizeCalled); - - // If not positioned anywhere, position to the midpoint. - // Otherwise, start on the current block we are on. - - if( !m_pCurRSBlk) - { - // m_pFirstRSBlk will be NULL if no entries. - - if( !m_pFirstRSBlk) - { - rc = RC_SET( NE_XFLM_NOT_FOUND); - goto Exit; - } - - if( m_pFirstRSBlk == m_pLastRSBlk) - { - m_pCurRSBlk = m_pFirstRSBlk; - } - else - { - m_pCurRSBlk = SelectMidpoint( m_pFirstRSBlk, m_pLastRSBlk, FALSE); - } - - if( RC_BAD( rc = m_pCurRSBlk->SetBuffer( m_pucBlockBuf1, m_uiBlkSize))) - { - goto Exit; - } - } - - // Set the exclusive low block and high block. - - pLowBlk = m_pFirstRSBlk; - pHighBlk = m_pLastRSBlk; - - // Loop until the correct block is found. - - for( ;;) - { - // Two return value returned: rc and iBlkCompare. - // FindMatch returns NE_XFLM_OK if the entry if found in the block. - // It returns NE_XFLM_NOT_FOUND if not found in the block. - // uiCompare returns 0 if entry would be within the block. - // otherwise < 0 if previous blocks should be checked - // and > 0 if next blocks should be checked. - - rc = m_pCurRSBlk->FindMatch( - (FLMBYTE *) pvMatchEntry, uiMatchEntryLength, - (FLMBYTE *) pvFoundEntry, puiFoundEntryLength, - &iBlkCompare ); - - // Found match or should key be within the block. - - if( RC_OK(rc) || iBlkCompare == 0) - { - goto Exit; - } - - if( iBlkCompare < 0) - { - // Done if the low block - // Keep NE_XFLM_NOT_FOUND return code - - if( m_pCurRSBlk == pLowBlk) - { - goto Exit; - } - - // Set the new high block - - pHighBlk = m_pCurRSBlk->m_pPrev; - } - else - { - // Done if we are at the high block - // Keep the NE_XFLM_NOT_FOUND return code - - if( m_pCurRSBlk == pHighBlk) - { - goto Exit; - } - - pLowBlk = m_pCurRSBlk->m_pNext; - } - - if( RC_BAD( rc = m_pCurRSBlk->SetBuffer( NULL))) - { - goto Exit; - } - - m_pCurRSBlk = SelectMidpoint( pLowBlk, pHighBlk, FALSE); - - // Need to set the working buffer. - - if( RC_BAD( rc = m_pCurRSBlk->SetBuffer( m_pucBlockBuf1, m_uiBlkSize))) - { - goto Exit; - } - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Select the midpoint between two different blocks in a list. - Entries should not be the same value. -*****************************************************************************/ -FResultSetBlk * FResultSet::SelectMidpoint( - FResultSetBlk * pLowBlk, - FResultSetBlk * pHighBlk, - FLMBOOL bPickHighIfNeighbors) -{ - FLMUINT uiCount; - FResultSetBlk * pTempBlk; - - // If the same then return. - - if( pLowBlk == pHighBlk) - { - pTempBlk = pLowBlk; - goto Exit; - } - - // Check if neighbors and use the boolean flag. - - if( pLowBlk->m_pNext == pHighBlk) - { - pTempBlk = (FResultSetBlk *)(bPickHighIfNeighbors - ? pHighBlk - : pLowBlk); - goto Exit; - } - - // Count the total blocks exclusive between low and high and add one. - // Check pTempBlk against null to not crash. - - for( pTempBlk = pLowBlk, uiCount = 1; - pTempBlk && (pTempBlk != pHighBlk); - uiCount++) - { - pTempBlk = pTempBlk->m_pNext; - } - - // Check for implementation error - pTempBlk is NULL and handle. - - if( !pTempBlk) - { - flmAssert( 0); - pTempBlk = pLowBlk; - goto Exit; - } - - // Loop to the middle item - // Divide count by 2 - - uiCount >>= 1; - for( pTempBlk = pLowBlk; uiCount > 0; uiCount--) - { - pTempBlk = pTempBlk->m_pNext; - } - -Exit: - - return( pTempBlk); -} - -/***************************************************************************** -Desc: Set the current entry position. -*****************************************************************************/ -RCODE XFLMAPI FResultSet::setPosition( - FLMUINT64 ui64Position) -{ - RCODE rc = NE_XFLM_OK; - FResultSetBlk * pInitialBlk = m_pCurRSBlk; - - flmAssert( m_bFinalizeCalled); - - if( ui64Position == RS_POSITION_NOT_SET) - { - // Set out of focus - - if( m_pCurRSBlk) - { - if( RC_BAD( rc = m_pCurRSBlk->SetBuffer( NULL))) - { - goto Exit; - } - } - - m_pCurRSBlk = NULL; - goto Exit; - } - - if( !m_pCurRSBlk) - { - m_pCurRSBlk = m_pFirstRSBlk; - } - - // Check for empty result set. - - if( !m_pCurRSBlk) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - - if( ui64Position < m_pCurRSBlk->m_ui64BlkEntryPosition) - { - // Go backwards looking for the correct block. - - do - { - m_pCurRSBlk = m_pCurRSBlk->m_pPrev; - flmAssert( m_pCurRSBlk); - } - while( ui64Position < m_pCurRSBlk->m_ui64BlkEntryPosition); - } - else if( ui64Position >= m_pCurRSBlk->m_ui64BlkEntryPosition + - m_pCurRSBlk->m_BlockHeader.uiEntryCount) - { - // Go forward looking for the correct block. - - do - { - if( !m_pCurRSBlk->m_pNext) - { - // Will set rc to EOF in SetPosition below. - - break; - } - - m_pCurRSBlk = m_pCurRSBlk->m_pNext; - } - while( ui64Position >= m_pCurRSBlk->m_ui64BlkEntryPosition + - m_pCurRSBlk->m_BlockHeader.uiEntryCount); - } - - // Need working buffer out of focus. - - if( pInitialBlk != m_pCurRSBlk) - { - if( pInitialBlk) - { - if( RC_BAD( rc = pInitialBlk->SetBuffer( NULL))) - { - goto Exit; - } - } - - // Need working buffer into focus. - - if( RC_BAD( rc = m_pCurRSBlk->SetBuffer( m_pucBlockBuf1, m_uiBlkSize))) - { - goto Exit; - } - } - - // Now we are positioned to the correct block. - - if( RC_BAD( rc = m_pCurRSBlk->SetPosition( ui64Position))) - { - goto Exit; - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Return a pointer to the next entry in the list. -*****************************************************************************/ -RCODE FResultSet::GetNextPtr( - FResultSetBlk ** ppCurBlk, - FLMBYTE ** ppucBuffer, - FLMUINT * puiReturnLength) -{ - RCODE rc = NE_XFLM_OK; - FResultSetBlk * pCurBlk = *ppCurBlk; - FResultSetBlk * pNextBlk; - FLMBYTE * pucBuffer; - - flmAssert( pCurBlk); - - while( RC_BAD( rc = pCurBlk->GetNextPtr( ppucBuffer, puiReturnLength))) - { - if( rc == NE_XFLM_EOF_HIT) - { - if( pCurBlk->m_pNext) - { - pNextBlk = pCurBlk->m_pNext; - if( !pNextBlk->m_BlockHeader.bFirstBlock) - { - pucBuffer = pCurBlk->m_pucBlockBuf; - pCurBlk->SetBuffer( NULL ); - pCurBlk = pNextBlk; - if( RC_BAD( rc = pCurBlk->SetBuffer( pucBuffer, m_uiBlkSize))) - { - goto Exit; - } - *ppCurBlk = pCurBlk; - continue; - } - } - } - - goto Exit; - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Union two block lists into a result output list. This may be - called to union two result sets or to perform the initial merge-sort - on a create result set. - - Performing an N-way merge would be fast when we have over 10K - of entries. However, the code is more complex. -*****************************************************************************/ -RCODE FResultSet::UnionBlkLists( - FResultSetBlk * pLeftBlk, - FResultSetBlk * pRightBlk) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE * pucLeftEntry; - FLMBYTE * pucRightEntry; - FLMUINT uiLeftLength; - FLMUINT uiRightLength; - - // If no right block then copy all of the items from the left block - // to the output block. We could optimize this in the future. - - if( !pRightBlk) - { - rc = CopyRemainingItems( pLeftBlk); - goto Exit; - } - - // Now the fun begins. Read entries from both lists and union - // while checking the order of the entries. - - if( RC_BAD( rc = GetNextPtr( &pLeftBlk, &pucLeftEntry, &uiLeftLength))) - { - if( rc == NE_XFLM_EOF_HIT) - { - rc = CopyRemainingItems( pRightBlk); - } - - goto Exit; - } - - if( RC_BAD( rc = GetNextPtr( &pRightBlk, &pucRightEntry, &uiRightLength))) - { - if( rc == NE_XFLM_EOF_HIT) - { - rc = CopyRemainingItems( pLeftBlk); - } - - goto Exit; - } - - for (;;) - { - FLMINT iCompare; - - if( RC_BAD(rc = m_pCompare->compare( pucLeftEntry, uiLeftLength, - pucRightEntry, uiRightLength, &iCompare ))) - { - goto Exit; - } - - if( iCompare < 0) - { - // Take the left item. - - if( RC_BAD(rc = addEntry( pucLeftEntry, uiLeftLength))) - { - goto Exit; - } - - if( RC_BAD( rc = GetNextPtr( &pLeftBlk, - &pucLeftEntry, &uiLeftLength))) - { - if( rc != NE_XFLM_EOF_HIT) - { - goto Exit; - } - - if( RC_BAD( rc = addEntry( pucRightEntry, uiRightLength))) - { - goto Exit; - } - - // Left entries are done - read all of the right entries. - - rc = CopyRemainingItems( pRightBlk); - goto Exit; - } - } - else - { - // If equals then drop the right item and continue comparing left. - // WARNING: Don't try to optimize for equals because when one - // list runs out the remaining duplicate entries must be dropped. - // Continuing to compare the duplicate item is the correct way. - - if( iCompare > 0 || !m_bDropDuplicates) - { - // Take the right item. - - if( RC_BAD(rc = addEntry( pucRightEntry, uiRightLength))) - { - goto Exit; - } - } - - if( RC_BAD(rc = GetNextPtr( &pRightBlk, - &pucRightEntry, &uiRightLength))) - { - if( rc != NE_XFLM_EOF_HIT) - { - goto Exit; - } - - if( RC_BAD(rc = addEntry( pucLeftEntry, uiLeftLength))) - { - goto Exit; - } - - // Right entries are done - read all of the left entries. - - rc = CopyRemainingItems( pLeftBlk); - goto Exit; - } - } - } - -Exit: - - if( RC_OK( rc)) - { - // Flush out the output entries. - - rc = m_pCurRSBlk->Finalize( TRUE ); - m_pCurRSBlk->SetBuffer( NULL); - m_pCurRSBlk = NULL; - - if( m_pSortStatus) - { - RCODE rc2; - - ++m_ui64UnitsDone; - if( RC_BAD( rc2 = m_pSortStatus->reportSortStatus( m_ui64EstTotalUnits, - m_ui64UnitsDone))) - { - if( RC_OK( rc)) - { - rc = rc2; - } - } - } - } - - return( rc); -} - -/***************************************************************************** -Desc: Copy the remaining items from a block list to the output. -*****************************************************************************/ -RCODE FResultSet::CopyRemainingItems( - FResultSetBlk * pCurBlk) -{ - RCODE rc; - FLMBYTE * pucEntry; - FLMUINT uiLength; - - while( RC_OK( rc = GetNextPtr( &pCurBlk, &pucEntry, &uiLength))) - { - if( RC_BAD( rc = addEntry( pucEntry, uiLength))) - { - goto Exit; - } - } - - if( rc == NE_XFLM_EOF_HIT) - { - rc = NE_XFLM_OK; - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Closes and deletes one of two files. -*****************************************************************************/ -void FResultSet::CloseFile( - F_64BitFileHandle ** ppFileHdl64, - FLMBOOL bDelete) -{ - if( ppFileHdl64 == &m_pFileHdl641) - { - if( m_bFile1Opened) - { - m_pFileHdl641->Close( bDelete); - m_bFile1Opened = FALSE; - } - - if( m_pFileHdl641) - { - m_pFileHdl641->Release(); - m_pFileHdl641 = NULL; - } - } - else - { - if( m_bFile2Opened) - { - m_pFileHdl642->Close( TRUE); - m_bFile2Opened = FALSE; - } - - if( m_pFileHdl642) - { - m_pFileHdl642->Release(); - m_pFileHdl642 = NULL; - } - } -} - -/***************************************************************************** -Desc: Close the file if previously opened and creates the file. -*****************************************************************************/ -RCODE FResultSet::OpenFile( - F_64BitFileHandle ** ppFileHdl64) -{ - RCODE rc = NE_XFLM_OK; - FLMBOOL * pbFileOpened; - char * pszDirPath; - - // Will close and delete if opened, else will do nothing. - - CloseFile( ppFileHdl64); - - if( ppFileHdl64 == &m_pFileHdl641) - { - pbFileOpened = &m_bFile1Opened; - pszDirPath = &m_szIoFilePath1 [0]; - } - else - { - pbFileOpened = &m_bFile2Opened; - pszDirPath = &m_szIoFilePath2 [0]; - } - - f_strcpy( pszDirPath, m_szIoDefaultPath); - - if( (*ppFileHdl64 = f_new F_64BitFileHandle) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = (*ppFileHdl64)->CreateUnique( pszDirPath, - FRSET_FILENAME_EXTENSION))) - { - (*ppFileHdl64)->Release(); - *ppFileHdl64 = NULL; - goto Exit; - } - - *pbFileOpened = TRUE; - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Create and empty data vector and return it's interface... -*****************************************************************************/ -RCODE XFLMAPI F_DbSystem::createIFResultSet( - IF_ResultSet ** ppResultSet) -{ - RCODE rc = NE_XFLM_OK; - - if( (*ppResultSet = f_new FResultSet) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - -Exit: - - return( rc); -} diff --git a/xflaim/src/frset.h b/xflaim/src/frset.h deleted file mode 100644 index 5bb88a1..0000000 --- a/xflaim/src/frset.h +++ /dev/null @@ -1,567 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Result sets -// -// Tabs: 3 -// -// Copyright (c) 1996-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: frset.h 3109 2006-01-19 13:07:07 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#ifndef FRSET_H -#define FRSET_H - -// Forward declarations - -class FResultSet; -class FResultSetBlk; - -/***************************************************************************** -***** -** Definitions -***** -*****************************************************************************/ - -#define RSBLK_BLOCK_SIZE (1024 * 512) - -// Need to allocate on the stack the maximum fixed entry size -// in the recursive quicksort routine. - -#define MAX_FIXED_ENTRY_SIZE 64 - -#define RS_POSITION_NOT_SET FLM_MAX_UINT64 - -/***************************************************************************** -***** -** Result Set Block Definitions -***** -*****************************************************************************/ - -// Block Size Limits: -// 1) 4 GB (whatever we can represent in 32 bits) -// 2) Three blocks are allocated as a maximum during the merge phase. -// Two of these blocks are freed after the merge phase. -// -// Block Layout: -// Block Header Structure -// Variable Length Entries -// An array of [Offset][Length] entry items (F_VAR_HEADER) -// The variable length entries are stored from the end back to front. -// The length of a variable length entry must be less than the block size. -// Fixed Length Entries -// Each entry is stored from the first of the buffer to the last. - -typedef struct FVarHeaderTag -{ - FLMUINT32 ui32Offset; - FLMUINT32 ui32Length; -} F_VAR_HEADER; - -/*=========================================================================== - - Block Header Definition - - Desc: Actually stored as the first section of each block. - We can write this structure because the same process will - read the block header i.e. portability is not a problem. -===========================================================================*/ - -typedef struct FBlockHeaderTag -{ - FLMUINT64 ui64FilePos; // ~0 or file position - FLMUINT uiEntryCount; // Number of entries in block - FLMUINT uiBlockSize; // Total Block size in memory or on disk - FLMBOOL bFirstBlock; // TRUE=first block in chain - FLMBOOL bLastBlock; // TRUE=last block in chain -} F_BLOCK_HEADER; - -#define RSBLK_UNSET_FILE_POS (~((FLMUINT64)0)) - -/*=========================================================================== - - Result Set Block Class Definition - Move to another file if FResultSet is more public. - Source: FRSETBLK.CPP - -Note: Anything member variable in comments is for the future. -===========================================================================*/ -class FResultSetBlk : public XF_RefCount, public XF_Base -{ -public: - - // Constructor - - FResultSetBlk(); - - // Destructor - - FINLINE ~FResultSetBlk() - { - if (m_pNext) - { - m_pNext->m_pPrev = m_pPrev; - } - - if( m_pPrev) - { - m_pPrev->m_pNext = m_pNext; - } - - if (m_pCompare) - { - m_pCompare->Release(); - } - } - - // Setup and termination methods - - void reset( void); - - void Setup( - F_64BitFileHandle ** ppFileHdl64, // file handle to use for temp file. - IF_ResultSetCompare * pCompare, - FLMUINT uiEntrySize, // Entry size if fixed. - FLMBOOL bFirstInList, // Use RSBLK_IS_FIRST_IN_LIST or - // RSBLK_NOT_FIRST_IN_LIST - FLMBOOL bDropDuplicates, // If TRUE drop duplicates - FLMBOOL bEntriesInOrder); // TRUE when entries are in order. - - RCODE SetBuffer( // Set the current working buffer - FLMBYTE * pBuffer, - FLMUINT uiBufferSize = RSBLK_BLOCK_SIZE); - - FINLINE FLMUINT BytesUsedInBuffer( void) - { - if (m_bEntriesInOrder) - { - return( m_BlockHeader.uiBlockSize); - } - else - { - return( m_BlockHeader.uiBlockSize - m_uiLengthRemaining); - } - } - - // Entry Add and Sort Methods - - RCODE AddEntry( // Variable or fixed length entry coming in - FLMBYTE * pEntry, // Entry cannot be all zero values. - FLMUINT uiEntryLength ); // If length is zero then ignore entry. - - RCODE ModifyEntry( // Modify current entry. - FLMBYTE * pEntry, // Points to entry buffer - FLMUINT uiEntryLength = 0); // Zero value means fixed length. - // Existing entry must be the same length - // and sort in the same place. - - - FINLINE RCODE Finalize( - FLMBOOL bForceWrite) - { - return Flush( TRUE, bForceWrite); - } - - RCODE Flush( // Sort and flush block to disk if more data - FLMBOOL bLastBlockInList, - FLMBOOL bForceWrite); - - // Methods to read entries. - - RCODE GetCurrent( // Return current entry - FLMBYTE * pBuffer, - FLMUINT uiBufferLength, - FLMUINT * puiReturnLength); - - FINLINE RCODE GetNext( - FLMBYTE * pucBuffer, - FLMUINT uiBufferLength, - FLMUINT * puiReturnLength) - { - // Are we on the last entry or past the last entry? - - if (m_iEntryPos + 1 >= (FLMINT)m_BlockHeader.uiEntryCount) - { - m_iEntryPos = (FLMINT) m_BlockHeader.uiEntryCount; - return RC_SET( NE_XFLM_EOF_HIT); - } - - m_iEntryPos++; // Else position to next entry - - return CopyCurrentEntry( pucBuffer, uiBufferLength, puiReturnLength); - } - - RCODE GetNextPtr( // Get a pointer to the next entry. - // Internal call not to be exposed. - FLMBYTE * * ppBuffer, - FLMUINT * puiReturnLength); - - RCODE GetPrev( // Position to previous entry and return - FLMBYTE * pBuffer, - FLMUINT uiBufferLength, - FLMUINT * puiReturnLength); - - FINLINE FLMUINT64 GetPosition( void) - { - return( (!m_bPositioned || - m_iEntryPos == -1 || - m_iEntryPos == (FLMINT)m_BlockHeader.uiEntryCount - ? RS_POSITION_NOT_SET - : m_ui64BlkEntryPosition + (FLMUINT64)m_iEntryPos)); - } - - - RCODE SetPosition( // Set the input position. Returns - // SUCCESS or NE_XFLM_NOT_FOUND if position bad. - FLMUINT64 ui64Position ); // (in) Position or RS_POSITION_NOT_SET - - RCODE FindMatch( // Find and return an etnry that - // matches in this block. - FLMBYTE * pMatchEntry, // Entry to match - FLMUINT uiMatchEntryLength, // Variable length of above entry - FLMBYTE * pFoundEntry, // (out) Entry to return - FLMUINT * puiFoundEntryLength, // (out) Length of entry returned - FLMINT * piCompare); // See comments above. - - void adjustState( - FLMUINT uiBlkBufferSize); - - RCODE Truncate( - FLMBYTE * pszPath); - -private: - - RCODE AddEntry( // Fixed length entry coming in. - FLMBYTE * pucEntry); // Entry cannot be all zero values. - - void SqueezeSpace( void); // Squeeze out space if variable length. - - RCODE SortAndRemoveDups( void); // Sort entries in a block and remove dups. - - void RemoveEntry( // Remove an entry. - FLMBYTE * pucEntry); - - RCODE QuickSort( // The great quick sort algorithm. - FLMUINT uiLowerBounds, - FLMUINT uiUpperBounds); - - FINLINE RCODE EntryCompare( - FLMBYTE * pucLeftEntry, - FLMBYTE * pucRightEntry, - FLMINT * piCompare) - { - RCODE rc; - - if( m_bFixedEntrySize) - { - rc = m_pCompare->compare( pucLeftEntry, m_uiEntrySize, - pucRightEntry, m_uiEntrySize, piCompare); - } - else - { - rc = m_pCompare->compare( - m_pucBlockBuf + ((F_VAR_HEADER *)pucLeftEntry)->ui32Offset, - ((F_VAR_HEADER *)pucLeftEntry)->ui32Length, - m_pucBlockBuf + ((F_VAR_HEADER *)pucRightEntry)->ui32Offset, - ((F_VAR_HEADER *)pucRightEntry)->ui32Length, - piCompare); - } - if (*piCompare == 0) - { - m_bDuplicateFound = TRUE; - } - return rc; - } - - RCODE CopyCurrentEntry( // Copy current entry to pBuffer. - FLMBYTE * pBuffer, - FLMUINT uiBufferLength, - FLMUINT * puiReturnLength); - - RCODE CompareEntry( // Compares match entry with entry - // identified by uiEntryPos. - FLMBYTE * pMatchEntry, // Entry to match - FLMUINT uiMatchEntryLength,// Variable length of pMatchEntry. - FLMUINT uiEntryPos, // Position of entry in block. - FLMINT * piCompare); // Return from compare. - - // I/O Methods - - RCODE Write(); // Write a block to disk - RCODE Read(); // Read a block of data from disk - - // Member Variables - - F_BLOCK_HEADER m_BlockHeader; // Block Header - written to disk. - - IF_ResultSetCompare * m_pCompare; - - // Variables to track data in the block. - - FLMBYTE * m_pucBlockBuf; // Block buffer. Allocated by owner - FLMBYTE * m_pucEndPoint; // Entry data runs from rear to front - - FResultSetBlk * m_pNext; // Next RSBLK in a chain. - FResultSetBlk * m_pPrev; // Previous RSBlk in a chain. - - F_64BitFileHandle ** - m_ppFileHdl64; // Points to a 64-bit file handle - - FLMUINT64 m_ui64BlkEntryPosition;// Position of first entry in block. - FLMUINT m_uiLengthRemaining; // Bytes left between entry pointers - // and pEndPoint (start of entry data.) - - // Flags and counters - - FLMINT m_iEntryPos; // Entry position when reading. - FLMUINT m_uiEntrySize; // Entry size used in the block (non-0). - - FLMBOOL m_bEntriesInOrder; // TRUE = entries are in order. - FLMBOOL m_bFixedEntrySize; // TRUE = process fixed length entries. - FLMBOOL m_bPositioned; // TRUE = we are positioned through - // ResultSetFirst() or ResultSetLast(). - FLMBOOL m_bModifiedEntry; // 1+ entries in blk modifed or deleted. - FLMBOOL m_bDuplicateFound; // TRUE = duplicate found when sorting. - FLMBOOL m_bDropDuplicates; // TRUE drop duplicate entries. -friend class FResultSet; -}; - -/***************************************************************************** -Desc: Result set class -*****************************************************************************/ -class FResultSet : public IF_ResultSet, public XF_Base -{ -public: - - FResultSet(); - FResultSet( - FLMUINT uiBlkSize); - - virtual ~FResultSet(); // No errors returned when closing files - // or freeing memory. - - RCODE XFLMAPI setupResultSet( - const char * pszPath, // Default I/O path to use for the result - // set files. There may be 2 files when - // a lot of data is to be merged. - IF_ResultSetCompare * pCompare, // Compare callback object - FLMUINT uiEntrySize, // Size of entry if fixed length or zero - // if variable length. Assert will be - // called if entry size changed when setup - // is called multiple times. - FLMBOOL bDropDuplicates = TRUE, - FLMBOOL bEntriesInOrder = FALSE, - // TRUE if entries are in order. - const char * pszInputFileName = NULL); - // Use this file if needed. If specified - // AND it exists, the file will be opened and read. - // If you don't want to use an existing file, you - // should call resetResultSet immediately after this call. - // That will delete the existing file. - - FINLINE void XFLMAPI setSortStatus( - IF_ResultSetSortStatus * pSortStatus) - { - if (m_pSortStatus) - { - m_pSortStatus->Release(); - m_pSortStatus = NULL; - } - if ((m_pSortStatus = pSortStatus) != NULL) - { - m_pSortStatus->AddRef(); - } - } - - FINLINE FLMUINT64 XFLMAPI getTotalEntries( void) - { - FResultSetBlk * pBlk = m_pFirstRSBlk; - FLMUINT64 ui64TotalEntries = 0; - - for( pBlk = m_pFirstRSBlk; pBlk; pBlk = pBlk->m_pNext) - { - ui64TotalEntries += pBlk->m_BlockHeader.uiEntryCount; - } - return ui64TotalEntries; - } - - // Methods for building a result set. - - RCODE XFLMAPI addEntry( // Add fixed or variable length entry. - const void * pvEntry, // Points to entry buffer - FLMUINT uiEntryLength = 0); // zero value means fixed length - - RCODE XFLMAPI finalizeResultSet( // Commit all entries added. - FLMUINT64 * pui64TotalEntries = NULL);// (out) returns total entries. - - // Reading Entries from a Result Set - - RCODE XFLMAPI getFirst( // Returns first entry - void * pvEntryBuffer, - FLMUINT uiBufferLength = 0, - FLMUINT * puiEntryLength = NULL); - - RCODE XFLMAPI getNext( // Returns next entry - void * pvEntryBuffer, - FLMUINT uiBufferLength = 0, - FLMUINT * puiEntryLength = NULL); - - RCODE XFLMAPI getLast( // Returns last entry - void * pvEntryBuffer, - FLMUINT uiBufferLength = 0, - FLMUINT * puiEntryLength = NULL); - - RCODE XFLMAPI getPrev( // Returns previous entry - void * pvEntryBuffer, - FLMUINT uiBufferLength = 0, - FLMUINT * puiEntryLength = NULL); - - RCODE XFLMAPI getCurrent( // Returns current entry - void * pvEntryBuffer, // Buffer to hold entry - FLMUINT uiBufferLength = 0, // Length of buffer to hold entry - FLMUINT * puiEntryLength = NULL); // (out) Length of returned entry - - FINLINE RCODE XFLMAPI modifyCurrent( - const void * pvEntry, - FLMUINT uiEntryLength = 0) // If zero entry is fixed length. - { - return( m_pCurRSBlk->ModifyEntry( (FLMBYTE *)pvEntry, uiEntryLength)); - } - - FINLINE RCODE XFLMAPI findMatch( - const void * pvMatchEntry, // Fixed length entry to match. - void * pvFoundEntry) // (out) Buffer to return full entry to. - { - return( findMatch( pvMatchEntry, m_uiEntrySize, - pvFoundEntry, NULL)); - } - - RCODE XFLMAPI findMatch( // Find and return an etnry that - // matches in the result set (variable). - const void * pvMatchEntry, // Entry to match - FLMUINT uiMatchEntryLength, // Variable length of above entry - void * pvFoundEntry, // (out) Entry to return - FLMUINT * puiFoundEntryLength); // (out) Length of entry returned - - FINLINE FLMUINT64 XFLMAPI getPosition( void) - { - return( (!m_pCurRSBlk - ? RS_POSITION_NOT_SET - : m_pCurRSBlk->GetPosition())); - } - - RCODE XFLMAPI setPosition( - FLMUINT64 ui64Position); - - RCODE XFLMAPI resetResultSet( - FLMBOOL bDelete = TRUE); - - RCODE XFLMAPI flushToFile( void); - -private: - - // Private Methods - - FINLINE FLMUINT64 NumberOfBlockChains( void) - { - FLMUINT64 ui64Count = 0; - FResultSetBlk * pBlk = m_pFirstRSBlk; - - for (; pBlk ; pBlk = pBlk->m_pNext) - { - if (pBlk->m_BlockHeader.bFirstBlock) - { - ui64Count++; - } - } - return ui64Count; - } - - RCODE MergeSort(); // Sort/Merge all blks into single list. - - RCODE GetNextPtr( // Return ptr to next entry. - FResultSetBlk **ppCurBlk, - FLMBYTE * * ppBuffer, - FLMUINT * puiReturnLength); - - RCODE UnionBlkLists( - FResultSetBlk *pLeftBlk, // (IN) Left block - FResultSetBlk *pRightBlk = NULL);// (IN) May be NULL - - RCODE CopyRemainingItems( // Copy remaining items from a block list. - FResultSetBlk *pCurBlk); // (IN) Inputblock - - void CloseFile( // Close the input file. - F_64BitFileHandle ** ppFileHdl64, - FLMBOOL bDelete = TRUE); - - RCODE OpenFile( // Open the input file - F_64BitFileHandle ** ppFileHdl64); - - FResultSetBlk *SelectMidpoint( // Select the midpoint between blocks. - FResultSetBlk *pLowBlk, - FResultSetBlk *pHighBlk, - FLMBOOL bPickHighIfNeighbors); - - RCODE XFLMAPI setupFromFile( void); - - - // Callback objects - - IF_ResultSetCompare * m_pCompare; - - IF_ResultSetSortStatus * m_pSortStatus; - FLMUINT64 m_ui64EstTotalUnits; // Estimated total number of units to do. - FLMUINT64 m_ui64UnitsDone; // Units completed - - FLMUINT m_uiEntrySize; // Fixed length entry size or 0 for var. - - FLMUINT64 m_ui64TotalEntries; // Total number of entries. - - FResultSetBlk *m_pCurRSBlk, // Current result set block. - *m_pFirstRSBlk, // Points to first of merge list - *m_pLastRSBlk; // Points to last of merge list - - char m_szIoDefaultPath[ F_PATH_MAX_SIZE],// Copy of default path from setup(). - m_szIoFilePath1[ F_PATH_MAX_SIZE], // File created for result set. - m_szIoFilePath2[ F_PATH_MAX_SIZE]; // File create for result set merge. - - F_64BitFileHandle * - m_pFileHdl641; // File handles. - F_64BitFileHandle * - m_pFileHdl642; - - FLMBYTE * m_pucBlockBuf1; // Buffer for initial loading of entries - FLMBYTE * m_pucBlockBuf2; // Buffer for merge step. - FLMBYTE * m_pucBlockBuf3; // Buffer for merge step. - FLMUINT m_uiBlockBuf1Len; - - FLMBOOL m_bFile1Opened; // TRUE when m_IoFile1 is opened. - FLMBOOL m_bFile2Opened; // TRUE when m_IoFile2 is opened. - FLMBOOL m_bOutput2ndFile; // TRUE if output is 2nd file - FLMBOOL m_bInitialAdding; // TRUE when user adding entries. - FLMBOOL m_bFinalizeCalled; // TRUE after finalize step. - FLMBOOL m_bSetupCalled; // TRUE after setup has been called. - FLMBOOL m_bDropDuplicates; // TRUE drop duplicate entries. - FLMBOOL m_bAppAddsInOrder; // TRUE entries are added in order. - FLMBOOL m_bEntriesInOrder; // TRUE entries are in order - FLMUINT m_uiBlkSize; // Default is RSBLK_BLOCK_SIZE - -friend class FResultSetBlk; -}; - -#endif // ifndef FRSET_H diff --git a/xflaim/src/frsetblk.cpp b/xflaim/src/frsetblk.cpp deleted file mode 100644 index 1bae58b..0000000 --- a/xflaim/src/frsetblk.cpp +++ /dev/null @@ -1,1403 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Result set block routines -// -// Tabs: 3 -// -// Copyright (c) 1996-2000, 2003-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: frsetblk.cpp 3114 2006-01-19 13:22:45 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" -#include "frset.h" - -/***************************************************************************** -Desc: -******************************************************************************/ -FResultSetBlk::FResultSetBlk() -{ - m_pNext = m_pPrev = NULL; - m_pCompare = NULL; - reset(); -} - -/***************************************************************************** -Desc: Reset a block so it can be reused. -******************************************************************************/ -void FResultSetBlk::reset( void) -{ - flmAssert( !m_pNext && !m_pPrev); - - // Initialize all of the member variables - // between this constructor, SetBuffer() and Setup(). - - m_BlockHeader.ui64FilePos = RSBLK_UNSET_FILE_POS; - m_BlockHeader.uiEntryCount = 0; - m_ppFileHdl64 = NULL; - m_ui64BlkEntryPosition = RS_POSITION_NOT_SET; - m_iEntryPos = 0; - m_bDuplicateFound = FALSE; - m_bPositioned = FALSE; - m_bModifiedEntry = FALSE; - m_pucBlockBuf = NULL; -} - -/***************************************************************************** -Desc: -******************************************************************************/ -void FResultSetBlk::Setup( - F_64BitFileHandle ** ppFileHdl64, // file handle to use for temp file. - IF_ResultSetCompare * pCompare, - FLMUINT uiEntrySize, - FLMBOOL bFirstInList, - FLMBOOL bDropDuplicates, // If TRUE drop duplicates - FLMBOOL bEntriesInOrder) // TRUE when entries are in order. -{ - flmAssert( ppFileHdl64); - m_ppFileHdl64 = ppFileHdl64; - - if( m_pCompare) - { - m_pCompare->Release(); - } - - if( (m_pCompare = pCompare) != NULL) - { - m_pCompare->AddRef(); - } - - m_uiEntrySize = uiEntrySize; - m_BlockHeader.bFirstBlock = bFirstInList; - m_BlockHeader.bLastBlock = FALSE; - m_bFixedEntrySize = m_uiEntrySize ? TRUE : FALSE; - - if( !m_uiEntrySize) - { - m_uiEntrySize = sizeof( F_VAR_HEADER); - } - - m_bDropDuplicates = bDropDuplicates; - m_bEntriesInOrder = bEntriesInOrder; -} - -/***************************************************************************** -Desc: The buffer is NOT allocated the by the result set block object. - Setup the pucBuffer and associated variables. Read in the data - for this block if necessary. If NULL is passed in as pucBuffer - then this block is not the active block anymore. -Notes: Must be called before other methods below are called. -*****************************************************************************/ -RCODE FResultSetBlk::SetBuffer( - FLMBYTE * pucBuffer, // Working buffer or NULL - FLMUINT uiBufferLength) // Default value is RSBLK_BLOCK_SIZE. -{ - RCODE rc = NE_XFLM_OK; - - // If a buffer is defined then read in the data from disk. - - if( pucBuffer) - { - m_pucBlockBuf = pucBuffer; - if( !m_BlockHeader.uiEntryCount) - { - // uiBlockSize is the final block size after squeeze. - // uiLengthRemaining is working value of bytes available. - - m_BlockHeader.uiBlockSize = uiBufferLength; - m_uiLengthRemaining = uiBufferLength; - - if( m_bFixedEntrySize) - { - m_pucEndPoint = m_pucBlockBuf; - } - else - { - m_pucEndPoint = m_pucBlockBuf + uiBufferLength; - } - } - else - { - // Read in the data if necessary. - - if( RC_BAD( rc = Read())) - { - goto Exit; - } - } - - // The block is now in focus - - m_bPositioned = TRUE; - } - else - { - // Deactivating block so the buffer can be reused. - // Check if the block has been modified - - if( m_bModifiedEntry) - { - // Is this a lone block? - - if( !m_BlockHeader.bLastBlock || !m_BlockHeader.bFirstBlock) - { - if( RC_BAD( rc = Write())) - { - goto Exit; - } - } - m_bModifiedEntry = FALSE; - } - - // The block is now out of focus - - m_bPositioned = FALSE; - m_pucEndPoint = m_pucBlockBuf = NULL; - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Add a variable length entry to the result set. If fixed length - entry then call AddEntry for fixed length entries. -*****************************************************************************/ -RCODE FResultSetBlk::AddEntry( - FLMBYTE * pucEntry, - FLMUINT uiEntryLength) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiAlignLength; - F_VAR_HEADER * pEntry; - - flmAssert( m_pucBlockBuf); - - // Was setup called for fixed length entries? - - if( m_bFixedEntrySize ) - { - rc = AddEntry( pucEntry ); - goto Exit; - } - - uiAlignLength = (uiEntryLength + FLM_ALLOC_ALIGN) & (~FLM_ALLOC_ALIGN); - - // Check to see if the current buffer will overflow. - - if( m_uiLengthRemaining < uiAlignLength + sizeof( F_VAR_HEADER)) - { - // Caller should call Flush and setup correctly what to do next. - - rc = RC_SET( NE_XFLM_EOF_HIT ); - goto Exit; - } - - // Copy entry and compute the offset value for pNextEntryPtr. - - m_pucEndPoint -= uiAlignLength; - f_memcpy( m_pucEndPoint, pucEntry, uiEntryLength ); - - pEntry = ((F_VAR_HEADER *)m_pucBlockBuf) + m_BlockHeader.uiEntryCount; - pEntry->ui32Offset = (FLMUINT32)(m_pucEndPoint - m_pucBlockBuf); - pEntry->ui32Length = (FLMUINT32)uiEntryLength; - - m_uiLengthRemaining -= (uiAlignLength + sizeof( F_VAR_HEADER)); - m_BlockHeader.uiEntryCount++; - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Add a fixed length entry to the result set. -*****************************************************************************/ -RCODE FResultSetBlk::AddEntry( - FLMBYTE * pucEntry) -{ - RCODE rc = NE_XFLM_OK; - - // Check that setup was called for fixed length entries. - - flmAssert( m_bFixedEntrySize); - - // Check to see if the current buffer is full. - - if( m_uiLengthRemaining < m_uiEntrySize) - { - // Caller should call Flush and setup correctly what to do next. - - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - - f_memcpy( m_pucBlockBuf + (m_uiEntrySize * m_BlockHeader.uiEntryCount), - pucEntry, m_uiEntrySize); - m_BlockHeader.uiEntryCount++; - m_pucEndPoint += m_uiEntrySize; - m_uiLengthRemaining -= m_uiEntrySize; - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Modify the current entry being references. -Notes: The size of each block cannot be modified. This is to allow - writing to the same location on disk and not waste disk memory. -*****************************************************************************/ -RCODE FResultSetBlk::ModifyEntry( - FLMBYTE * pucEntry, - FLMUINT uiEntryLength) -{ - RCODE rc = NE_XFLM_OK; - - F_UNREFERENCED_PARM( uiEntryLength); - - flmAssert( m_pucBlockBuf); - - // The incoming entry MUST be the same size. - - if( m_bFixedEntrySize ) - { - // Assert that the entry length must be zero. - // If not - still use m_uiEntrySize; - - flmAssert( !uiEntryLength); - - // Copy over the current item. - - f_memcpy( &m_pucBlockBuf [m_iEntryPos * m_uiEntrySize], - pucEntry, m_uiEntrySize ); - } - else - { - // Variable Length - - F_VAR_HEADER * pCurEntry; - - pCurEntry = ((F_VAR_HEADER *)m_pucBlockBuf) + m_iEntryPos; - - // We cannot support changing the entry size at this time. - - flmAssert( uiEntryLength == (FLMUINT)pCurEntry->ui32Length); - - f_memcpy( m_pucBlockBuf + pCurEntry->ui32Offset, - pucEntry, uiEntryLength); - } - - m_bModifiedEntry = TRUE; - return( rc); -} - -/***************************************************************************** -Desc: The block is full and need to flush the block to disk. If - bForceWrite is FALSE then will not write block to disk. -*****************************************************************************/ -RCODE FResultSetBlk::Flush( - FLMBOOL bLastBlockInList, // Last block in a block list. - FLMBOOL bForceWrite) // if TRUE write out to disk. -{ - RCODE rc = NE_XFLM_OK; - - // Make sure SetBuffer was called - - flmAssert( m_pucBlockBuf); - SqueezeSpace(); - - if( !m_bEntriesInOrder) - { - // Remove duplicate entries. - - if( RC_BAD( rc = SortAndRemoveDups())) - { - goto Exit; - } - } - - m_bEntriesInOrder = TRUE; - m_BlockHeader.bLastBlock = bLastBlockInList; - - if( bForceWrite) - { - if( RC_BAD( rc = Write())) - { - goto Exit; - } - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: If there is length remaining, squeeze out additional space. -*****************************************************************************/ -void FResultSetBlk::SqueezeSpace( void) -{ - FLMUINT uiPos; - - // Fixed Entry Size? - - if( m_bFixedEntrySize) - { - // Yes, no need to squeeze out any space. - - goto Exit; - } - - // Is there room to shift things down? - // Don't do if no entries or if less than 64 bytes. - - if( m_uiLengthRemaining >= 64 && m_BlockHeader.uiEntryCount) - { - FLMUINT uiBytesToMoveUp; - F_VAR_HEADER * pEntry; - - uiBytesToMoveUp = m_uiLengthRemaining; - m_uiLengthRemaining = 0; - - // Overlapping memory move call. - - flmAssert( (m_pucBlockBuf + m_BlockHeader.uiBlockSize) > m_pucEndPoint ); - flmAssert( uiBytesToMoveUp < m_BlockHeader.uiBlockSize ); - - f_memmove( m_pucEndPoint - uiBytesToMoveUp, m_pucEndPoint, - (FLMUINT) ((m_pucBlockBuf + m_BlockHeader.uiBlockSize ) - m_pucEndPoint )); - - m_BlockHeader.uiBlockSize -= uiBytesToMoveUp; - m_pucEndPoint -= uiBytesToMoveUp; - - // Change all of the offsets for every entry. This is expensive. - - for( uiPos = 0, pEntry = (F_VAR_HEADER *)m_pucBlockBuf; - uiPos < m_BlockHeader.uiEntryCount; - pEntry++, uiPos++) - { - pEntry->ui32Offset -= (FLMUINT32)uiBytesToMoveUp; - } - } - -Exit: - - return; -} - -/***************************************************************************** -Desc: Sort the current block and remove all duplicates. -*****************************************************************************/ -RCODE FResultSetBlk::SortAndRemoveDups( void) -{ - RCODE rc = NE_XFLM_OK; - - // Nothing to do if one or zero entries in the block. - - if( m_BlockHeader.uiEntryCount <= 1 || !m_pCompare) - { - goto Exit; - } - - m_bDuplicateFound = FALSE; - if( RC_BAD( rc = QuickSort( 0, m_BlockHeader.uiEntryCount - 1))) - { - goto Exit; - } - - // Some users of result sets may not have any duplicates to remove - // or may want the side effect of having duplicates to further - // process the entries like for sorting tracker records. It is up - // to the compare routine to never return 0 in this case. - - // This algorithm is tuned for the case where there are zero or few - // duplicate records. Removing duplicates is expensive in this design. - - if( m_bDropDuplicates && m_bDuplicateFound) - { - FLMUINT uiEntriesRemaining; - FLMINT iCompare; - - if( m_bFixedEntrySize) - { - FLMBYTE * pucEntry; - FLMBYTE * pucNextEntry; - - pucEntry = m_pucBlockBuf; - for( uiEntriesRemaining = m_BlockHeader.uiEntryCount - 1 - ; uiEntriesRemaining > 0 - ; uiEntriesRemaining-- ) - { - pucNextEntry = pucEntry + m_uiEntrySize; - - if( RC_BAD( rc = m_pCompare->compare( pucEntry, m_uiEntrySize, - pucNextEntry, m_uiEntrySize, - &iCompare))) - { - goto Exit; - } - - if( iCompare == 0) - { - RemoveEntry( pucEntry); - - // Leave pucEntry alone - everyone will scoot down - } - else - { - pucEntry += m_uiEntrySize; - } - } - } - else - { - F_VAR_HEADER * pEntry = (F_VAR_HEADER *)m_pucBlockBuf; - F_VAR_HEADER * pNextEntry; - - for( uiEntriesRemaining = m_BlockHeader.uiEntryCount - 1 - ; uiEntriesRemaining > 0 - ; uiEntriesRemaining-- ) - { - pNextEntry = pEntry + 1; - - if( RC_BAD( rc = m_pCompare->compare( m_pucBlockBuf + pEntry->ui32Offset, - (FLMUINT)pEntry->ui32Length, - m_pucBlockBuf + pNextEntry->ui32Offset, - (FLMUINT)pNextEntry->ui32Length, - &iCompare))) - { - goto Exit; - } - - if( iCompare == 0) - { - RemoveEntry( (FLMBYTE *)pEntry); - - // Leave pEntry alone - everyone will scoot down - } - else - { - pEntry++; - } - } - } - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Remove the current entry from the block. -*****************************************************************************/ -void FResultSetBlk::RemoveEntry( - FLMBYTE * pucEntry) -{ - if( m_bFixedEntrySize) - { - // Don't like moving zero bytes - check first. - - if( pucEntry + m_uiEntrySize < m_pucEndPoint) - { - // This is really easy - just memmove everyone down. - - f_memmove( pucEntry, pucEntry + m_uiEntrySize, - (FLMUINT)(m_pucEndPoint - pucEntry) - m_uiEntrySize); - } - - m_BlockHeader.uiEntryCount--; - m_BlockHeader.uiBlockSize -= m_uiEntrySize; - m_pucEndPoint -= m_uiEntrySize; - } - else - { - // Variable length entries - much harder - - // Example - remove entry 3 below... - - // [entryOfs1:len][entryOfs2:len][entryOfs3:len][entryOfs4:len] - // [entryData1][entryData2][entryData3][entryData4] - - // Need to reduce EntryOfs1 and entryOfs2 by m_uiEntrySize+entryLen3. - // because these entries are stored AFTER entry 3 - entries are first - // stored going from the back of the block to the front of the block. - // Need to reduce Ofs4 by OFFSET_SIZE. - - F_VAR_HEADER * pEntry = (F_VAR_HEADER *)pucEntry; - FLMUINT uiDeletedOffset = (FLMUINT)pEntry->ui32Offset; - FLMUINT uiTempOffset; - FLMUINT uiDeletedLength = (FLMUINT)pEntry->ui32Length; - F_VAR_HEADER * pCurEntry; - FLMUINT uiPos; - FLMUINT uiMoveBytes; - - flmAssert( m_BlockHeader.uiBlockSize >= - (uiDeletedOffset + uiDeletedLength )); - - uiMoveBytes = (FLMUINT) - (m_BlockHeader.uiBlockSize - (uiDeletedOffset + uiDeletedLength)); - - if( uiMoveBytes) - { - - // First move down the variable length entry data. - - f_memmove( m_pucBlockBuf + uiDeletedOffset, - m_pucBlockBuf + uiDeletedOffset + uiDeletedLength, - uiMoveBytes ); - } - - flmAssert( m_BlockHeader.uiBlockSize >= - (FLMUINT)((FLMBYTE *)(&pEntry[1]) - m_pucBlockBuf) ); - - uiMoveBytes = m_BlockHeader.uiBlockSize - - (FLMUINT)((FLMBYTE *)(&pEntry [1]) - m_pucBlockBuf); - - if( uiMoveBytes) - { - f_memmove( pEntry, &pEntry[1], uiMoveBytes ); - } - - m_BlockHeader.uiBlockSize -= (uiDeletedLength + sizeof( F_VAR_HEADER)); - - // Adjust the offset values. - - m_BlockHeader.uiEntryCount--; - - for( uiPos = 0, pCurEntry = (F_VAR_HEADER *)m_pucBlockBuf - ; uiPos < m_BlockHeader.uiEntryCount - ; uiPos++, pCurEntry++) - { - // Assume that the offsets are NOT in descending order. - // This will help in the future additional adding and deleting - // to an existing result set. - - uiTempOffset = (FLMUINT)pCurEntry->ui32Offset; - if (uiTempOffset > uiDeletedOffset) - { - uiTempOffset -= uiDeletedLength; - } - uiTempOffset -= sizeof( F_VAR_HEADER); - pCurEntry->ui32Offset = (FLMUINT32)uiTempOffset; - } - } -} - -/***************************************************************************** -Desc: Quick sort an array of values. -Notes: Optimized the above quicksort algorithm. On page 559 the book - suggests that "The worst case can sometimes be avioded by choosing - more carefully the record for final placement at each state." - This algorithm picks a mid point for the compare value. Doing - this helps the worst case where the entries are in order. In Order - tests went from 101 seconds down to 6 seconds! - This helps the 'in order' sorts from worst case Order(N^^2)/2 with - the normal quickSort to Order(NLog2 N) for the worst case. - Also optimized the number of recursions to Log2 N from (N-2). - Will recurse the SMALLER side and will iterate to the top of - the routine for the LARGER side. Follow comments below. -*****************************************************************************/ -RCODE FResultSetBlk::QuickSort( - FLMUINT uiLowerBounds, - FLMUINT uiUpperBounds) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE * pucEntryTbl = m_pucBlockBuf; - FLMBYTE * pucCurEntry; - FLMUINT uiLBPos; - FLMUINT uiUBPos; - FLMUINT uiMIDPos; - FLMUINT uiLeftItems; - FLMUINT uiRightItems; - FLMINT iCompare; - FLMUINT uiEntrySize = m_uiEntrySize; - FLMBYTE ucaSwapBuffer[MAX_FIXED_ENTRY_SIZE]; - -#define RS_SWAP(pTbl,pos1,pos2) { \ - f_memcpy( ucaSwapBuffer, &pTbl[pos2*uiEntrySize], uiEntrySize); \ - f_memcpy( &pTbl[ pos2 * uiEntrySize ], &pTbl[ pos1 * uiEntrySize ], uiEntrySize ); \ - f_memcpy( &pTbl[ pos1 * uiEntrySize ], ucaSwapBuffer, uiEntrySize ); } - -Iterate_Larger_Half: - - uiUBPos = uiUpperBounds; - uiLBPos = uiLowerBounds; - uiMIDPos = (uiUpperBounds + uiLowerBounds + 1) / 2; - pucCurEntry = &pucEntryTbl[ uiMIDPos * uiEntrySize ]; - - for (;;) - { - // Don't compare with target - - while( uiLBPos == uiMIDPos || - (RC_OK( rc = EntryCompare( &pucEntryTbl[ uiLBPos * uiEntrySize], - pucCurEntry, - &iCompare)) && - iCompare < 0)) - { - if( uiLBPos >= uiUpperBounds) - { - break; - } - uiLBPos++; - } - - if( RC_BAD( rc)) - { - goto Exit; - } - - // Don't compare with target - - while( uiUBPos == uiMIDPos || - (RC_OK( rc = EntryCompare( pucCurEntry, - &pucEntryTbl[uiUBPos * uiEntrySize], - &iCompare)) && - iCompare < 0)) - { - // Check for underflow - - if( !uiUBPos) - { - break; - } - - uiUBPos--; - } - - if (RC_BAD( rc)) - { - goto Exit; - } - - // Interchange and continue loop - - if( uiLBPos < uiUBPos) - { - // Interchange [uiLBPos] with [uiUBPos]. - - RS_SWAP( pucEntryTbl, uiLBPos, uiUBPos ); - uiLBPos++; // Scan from left to right. - uiUBPos--; // Scan from right to left. - } - else - { - // Past each other - done - - break; - } - } - - // 5 cases to check. - // 1) UB < MID < LB - Don't need to do anything. - // 2) MID < UB < LB - swap( UB, MID ) - // 3) UB < LB < MID - swap( LB, MID ) - // 4) UB = LB < MID - swap( LB, MID ) - At first position - // 5) MID < UB = LB - swap( UB, MID ) - At last position - - // Check for swap( LB, MID ) - cases 3 and 4 - - if( uiLBPos < uiMIDPos) - { - // Interchange [uiLBPos] with [uiMIDPos] - - RS_SWAP( pucEntryTbl, uiMIDPos, uiLBPos ); - uiMIDPos = uiLBPos; - } - else if (uiMIDPos < uiUBPos) - { - // Cases 2 and 5 - // Interchange [uUBPos] with [uiMIDPos] - - RS_SWAP( pucEntryTbl, uiMIDPos, uiUBPos ); - uiMIDPos = uiUBPos; - } - - // To save stack space - recurse the SMALLER Piece. For the larger - // piece goto the top of the routine. Worst case will be - // (Log2 N) levels of recursion. - - // Don't recurse in the following cases: - // 1) We are at an end. Just loop to the top. - // 2) There are two on one side. Compare and swap. Loop to the top. - // Don't swap if the values are equal. There are many recursions - // with one or two entries. This doesn't speed up any so it is - // commented out. - - // Check the left piece. - - uiLeftItems = (uiLowerBounds + 1 < uiMIDPos ) - ? uiMIDPos - uiLowerBounds // 2 or more - : 0; - uiRightItems = (uiMIDPos + 1 < uiUpperBounds ) - ? uiUpperBounds - uiMIDPos // 2 or more - : 0; - - if( uiLeftItems < uiRightItems) - { - // Recurse on the LEFT side and goto the top on the RIGHT side. - - if( uiLeftItems) - { - // Recursive call. - - if( RC_BAD( rc = QuickSort( uiLowerBounds, uiMIDPos - 1))) - { - goto Exit; - } - } - - uiLowerBounds = uiMIDPos + 1; - goto Iterate_Larger_Half; - } - else if( uiLeftItems) - { - // Recurse on the RIGHT side and goto the top for the LEFT side. - - if( uiRightItems) - { - // Recursive call. - - if( RC_BAD( rc = QuickSort( uiMIDPos + 1, uiUpperBounds))) - { - goto Exit; - } - } - - uiUpperBounds = uiMIDPos - 1; - goto Iterate_Larger_Half; - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Write this block to disk. -*****************************************************************************/ -RCODE FResultSetBlk::Write() -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiBytesWritten; - - // By this time there better be something to write... - // The file should be opened by default. - - if( m_BlockHeader.ui64FilePos == RSBLK_UNSET_FILE_POS) - { - if( RC_BAD(rc = (*m_ppFileHdl64)->Size( &m_BlockHeader.ui64FilePos))) - { - goto Exit; - } - } - - // Write out the block header definition. - - if( RC_BAD( rc = (*m_ppFileHdl64)->Write( - m_BlockHeader.ui64FilePos, - sizeof( F_BLOCK_HEADER), &m_BlockHeader, - &uiBytesWritten))) - { - goto Exit; - } - - // Write out the data buffer - - if( RC_BAD( rc = (*m_ppFileHdl64)->Write( - m_BlockHeader.ui64FilePos + sizeof( F_BLOCK_HEADER), - m_BlockHeader.uiBlockSize, - m_pucBlockBuf, - &uiBytesWritten))) - { - goto Exit; - } - -Exit: - - return rc; -} - -/***************************************************************************** -Desc: Read in the specified block into memory. -*****************************************************************************/ -RCODE FResultSetBlk::Read() -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiBytesRead; - F_BLOCK_HEADER BlockHeader; - - // Nothing to do? - - if (m_BlockHeader.ui64FilePos == RSBLK_UNSET_FILE_POS) - { - goto Exit; - } - - // First read the block header in. - - if (RC_BAD( rc = (*m_ppFileHdl64)->Read( m_BlockHeader.ui64FilePos, - sizeof( F_BLOCK_HEADER ), - (void *)&BlockHeader, &uiBytesRead))) - { - goto Exit; - } - - // Verify that the block header data is the same. - // This is the best we can do to verify that the file handle - // is not junky. - - if (BlockHeader.ui64FilePos != m_BlockHeader.ui64FilePos || - BlockHeader.uiEntryCount != m_BlockHeader.uiEntryCount) - { - rc = RC_SET( NE_XFLM_FAILURE); - goto Exit; - } - - // Read in the data buffer - - if (RC_BAD( rc = (*m_ppFileHdl64)->Read( - m_BlockHeader.ui64FilePos + sizeof( F_BLOCK_HEADER), - m_BlockHeader.uiBlockSize, - m_pucBlockBuf, &uiBytesRead))) - { - goto Exit; - } - -Exit: - - if (RC_OK(rc)) - { - m_bPositioned = TRUE; - m_iEntryPos = -1; - } - - return( rc); -} - -/***************************************************************************** -Desc: Copies the current entry into the user buffer. Checks for overflow. -*****************************************************************************/ -RCODE FResultSetBlk::CopyCurrentEntry( - FLMBYTE * pucBuffer, - FLMUINT uiBufferLength, - FLMUINT * puiReturnLength) -{ - RCODE rc = NE_XFLM_OK; // Must be initailized - FLMUINT uiEntrySize; - F_VAR_HEADER * pEntry; - FLMBYTE * pucEntry; - - flmAssert( pucBuffer); - - // Copy the current entry. This is a shared routine - // because the code to copy an entry is a little complicated. - - if( !m_bFixedEntrySize) - { - pEntry = ((F_VAR_HEADER *)m_pucBlockBuf) + m_iEntryPos; - uiEntrySize = pEntry->ui32Length; - pucEntry = m_pucBlockBuf + pEntry->ui32Offset; - } - else - { - uiEntrySize = m_uiEntrySize; - pucEntry = &m_pucBlockBuf[ m_iEntryPos * uiEntrySize ]; - } - - if( uiBufferLength && (uiEntrySize > uiBufferLength)) - { - uiEntrySize = uiBufferLength; - rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW ); - // Fall through into memcpy. - } - - f_memcpy( pucBuffer, pucEntry, uiEntrySize); - - if( puiReturnLength) - { - *puiReturnLength = uiEntrySize; - } - - return( rc); -} - -/***************************************************************************** -Desc: Return the Current entry reference in the result set. -*****************************************************************************/ -RCODE FResultSetBlk::GetCurrent( - FLMBYTE * pBuffer, - FLMUINT uiBufferLength, - FLMUINT * puiReturnLength) -{ - RCODE rc; - - flmAssert( m_pucBlockBuf); - if( !m_bPositioned ) - { - rc = RC_SET( NE_XFLM_NOT_FOUND ); - goto Exit; - } - - // Check for EOF and BOF conditions - otherwise return current. - - if (m_iEntryPos >= (FLMINT) m_BlockHeader.uiEntryCount) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - - if( m_iEntryPos == -1) - { - rc = RC_SET( NE_XFLM_BOF_HIT ); - goto Exit; - } - - rc = CopyCurrentEntry( pBuffer, uiBufferLength, puiReturnLength ); - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Return a pointer to the next reference in the result set. - If the result set is not positioned then the first entry will - be returned. -*****************************************************************************/ -RCODE FResultSetBlk::GetNextPtr( - FLMBYTE ** ppucBuffer, - FLMUINT * puiReturnLength) -{ - RCODE rc = NE_XFLM_OK; - - flmAssert( ppucBuffer); - flmAssert( puiReturnLength); - flmAssert( m_bPositioned); - - // Are we on the last entry or past the last entry? - - if (m_iEntryPos + 1 >= (FLMINT) m_BlockHeader.uiEntryCount) - { - m_iEntryPos = (FLMINT)m_BlockHeader.uiEntryCount; - rc = RC_SET( NE_XFLM_EOF_HIT ); - goto Exit; - } - - // Position to the next entry - - m_iEntryPos++; - - if (!m_bFixedEntrySize) - { - F_VAR_HEADER * pEntry; - - pEntry = ((F_VAR_HEADER *)m_pucBlockBuf) + m_iEntryPos; - *puiReturnLength = (FLMUINT)pEntry->ui32Length; - *ppucBuffer = m_pucBlockBuf + pEntry->ui32Offset; - } - else - { - *puiReturnLength = m_uiEntrySize; - *ppucBuffer = &m_pucBlockBuf[ m_iEntryPos * m_uiEntrySize]; - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Return the previous reference in the result set. If the result set - is not positioned then the last entry will be returned. -*****************************************************************************/ -RCODE FResultSetBlk::GetPrev( - FLMBYTE * pucBuffer, - FLMUINT uiBufferLength, - FLMUINT * puiReturnLength) -{ - RCODE rc = NE_XFLM_OK; - - flmAssert( m_bPositioned); - - // If not positioned then position past last entry. - - if (m_iEntryPos == -1) - { - m_iEntryPos = (FLMINT) m_BlockHeader.uiEntryCount; - } - - // Are we on the first entry or before the first entry? - - if (m_iEntryPos == 0) - { - m_iEntryPos = -1; - rc = RC_SET( NE_XFLM_BOF_HIT); - goto Exit; - } - - m_iEntryPos--; // position to previous entry. - - if (RC_BAD( rc = CopyCurrentEntry( pucBuffer, uiBufferLength, - puiReturnLength))) - { - goto Exit; - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Set the current entry position for this block. -*****************************************************************************/ -RCODE FResultSetBlk::SetPosition( - FLMUINT64 ui64Position) -{ - RCODE rc= NE_XFLM_OK; - - // Buffer must be set or SetBuffer() will set iEntryPos back to -1. - - flmAssert( m_bPositioned); - - if( ui64Position == RS_POSITION_NOT_SET) - { - m_iEntryPos = -1; - goto Exit; - } - - flmAssert( ui64Position >= m_ui64BlkEntryPosition); - - // Convert to a zero based number relative to this block. - - if (ui64Position >= m_ui64BlkEntryPosition) - { - ui64Position -= m_ui64BlkEntryPosition; - } - else - { - ui64Position = 0; - } - - if (ui64Position >= m_BlockHeader.uiEntryCount) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - m_iEntryPos = m_BlockHeader.uiEntryCount; - } - else - { - m_iEntryPos = (FLMINT)ui64Position; - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Find the matching entry within the block using the compare routine. - This does a binary search on entries. Watch the (out) variable. -Out: *piCompare = 0 - match found OR entry would compare between - the low and high entries in the block. - > 0 - match entry is greater than - the highest entry in the block. - < 0 - match entry is less than the - lowest entry in the block. -Notes: One side effect is that m_iEntryPos is set to the matched - entry or some random entry if not found is returned. -*****************************************************************************/ -RCODE FResultSetBlk::FindMatch( // Find and return an etnry that - // matches in this block. - FLMBYTE * pucMatchEntry, // Entry to match - FLMUINT uiMatchEntryLength, // Variable length of above entry - FLMBYTE * pucFoundEntry, // (out) Entry to return - FLMUINT * puiFoundEntryLength, // (out) Length of entry returned - FLMINT * piCompare) // See comments above. -{ - RCODE rc = NE_XFLM_OK; - FLMINT iCompare; // Return from CompareEntry - FLMUINT uiLow; - FLMUINT uiHigh; - FLMUINT uiMid; - FLMUINT uiLimit; - - uiLow = 0; - uiHigh = uiLimit = m_BlockHeader.uiEntryCount - 1; - - // Set the match entry length - - if (!uiMatchEntryLength) - { - uiMatchEntryLength = m_uiEntrySize; - } - - // Check the first and last entries in the block. - // Copy the current entry if found. - - if( RC_BAD( rc = CompareEntry( pucMatchEntry, uiMatchEntryLength, uiLow, - &iCompare))) - { - goto Exit; - } - - if( iCompare <= 0) - { - if( iCompare < 0) - { - rc = RC_SET( NE_XFLM_NOT_FOUND); - } - else - { - if( pucFoundEntry) - { - rc = CopyCurrentEntry( pucFoundEntry, 0, puiFoundEntryLength); - } - } - - *piCompare = iCompare; - goto Exit; - } - - if( RC_BAD( rc = CompareEntry( pucMatchEntry, uiMatchEntryLength, uiHigh, - &iCompare ))) - { - goto Exit; - } - - if (iCompare >= 0) - { - if (iCompare > 0) - { - rc = RC_SET( NE_XFLM_NOT_FOUND); - } - else - { - rc = CopyCurrentEntry( pucFoundEntry, 0, puiFoundEntryLength); - } - *piCompare = iCompare; - goto Exit; - } - - // Set the iCompare to equals because - // the match entry sorts within the block somewhere. - // Binary search the entries in the block. May still - // not find the matching entry. - - *piCompare = 0; - for( ;;) - { - uiMid = (uiLow + uiHigh) >> 1; // (uiLow + uiHigh) / 2 - - if( RC_BAD( rc = CompareEntry( pucMatchEntry, uiMatchEntryLength, uiMid, - &iCompare))) - { - goto Exit; - } - - if( iCompare == 0) - { - // Found Match! All set up to return. - - if( pucFoundEntry) - { - rc = CopyCurrentEntry( pucFoundEntry, 0, puiFoundEntryLength); - } - - goto Exit; - } - - // Check if we are done - where uiLow >= uiHigh. - - if( uiLow >= uiHigh) - { - // Done - item not found - - break; - } - - if( iCompare < 0) - { - // Way too high? - - if( !uiMid) - { - break; - } - - // Too high - - uiHigh = uiMid - 1; - } - else - { - if( uiMid == uiLimit) - { - // Done - hit the top - break; - } - - // Too low - - uiLow = uiMid + 1; - } - } - - // On break set we did not find the matching entry. - - rc = RC_SET( NE_XFLM_NOT_FOUND); - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Compare the buffer entry with entry identifies by - uiEntryPos. -Out: *piCompare = 0 - match found OR entry value would compare - between the low and high entries. - > 0 - match entry is greater than - the highest entry in the block. - < 0 - match entry is less than the - lowest entry in the block. -*****************************************************************************/ -RCODE FResultSetBlk::CompareEntry( // Compares match entry with entry - // identified by uiEntryPos. - FLMBYTE * pucMatchEntry, // Entry to match - FLMUINT uiMatchEntryLength, // Variable length of pMatchEntry. - FLMUINT uiEntryPos, // Position of entry in block. - FLMINT * piCompare) // Return from compare. -{ - FLMBYTE * pucEntry; - FLMUINT uiEntrySize; - - // Position to the entry. - - m_iEntryPos = (FLMINT) uiEntryPos; - - if (!m_bFixedEntrySize) - { - F_VAR_HEADER * pEntry; - - pEntry = ((F_VAR_HEADER *)m_pucBlockBuf) + m_iEntryPos; - uiEntrySize = (FLMUINT)pEntry->ui32Length; - pucEntry = m_pucBlockBuf + pEntry->ui32Offset; - } - else - { - uiEntrySize = m_uiEntrySize; - pucEntry = &m_pucBlockBuf[ m_iEntryPos * uiEntrySize ]; - } - - return( m_pCompare->compare( pucMatchEntry, uiMatchEntryLength, - pucEntry, uiEntrySize, - piCompare)); -} - -/***************************************************************************** -Desc: Make sure the state reflects what we have in the blocks. -*****************************************************************************/ -void FResultSetBlk::adjustState( - FLMUINT uiBlkBufferSize) -{ - F_VAR_HEADER * pVarHdr; - FLMUINT uiTotalSize = 0; - FLMBYTE * pucFromPos; - FLMBYTE * pucToPos; - FLMUINT uiBytesMoved; - FLMUINT uiPos; - - // Are the entries in the block fixed length or variable length? - - if( m_bFixedEntrySize) - { - // Fixed Length. - - m_uiLengthRemaining = uiBlkBufferSize - - (m_BlockHeader.uiEntryCount * m_uiEntrySize); - m_ui64BlkEntryPosition = 0; - m_pucEndPoint = m_pucBlockBuf + (m_BlockHeader.uiEntryCount * m_uiEntrySize); - } - else - { - // Variable length Entries. - // We may need to move the entries around. First, determine if the block is full. - - if( m_BlockHeader.uiBlockSize < uiBlkBufferSize) - { - uiTotalSize = m_BlockHeader.uiBlockSize - - (sizeof(F_VAR_HEADER) * m_BlockHeader.uiEntryCount); - - pucFromPos = m_pucBlockBuf + (sizeof(F_VAR_HEADER) * m_BlockHeader.uiEntryCount); - - pucToPos = (m_pucBlockBuf + uiBlkBufferSize) - uiTotalSize; - - f_memmove( pucToPos, pucFromPos, uiTotalSize); - - for( uiBytesMoved = (pucToPos - pucFromPos), - uiPos = 0, - pVarHdr = (F_VAR_HEADER *)m_pucBlockBuf; - uiPos < m_BlockHeader.uiEntryCount; - pVarHdr++, uiPos++) - { - pVarHdr->ui32Offset += (FLMUINT32)uiBytesMoved; - } - - m_pucEndPoint = pucToPos; - m_uiLengthRemaining = uiBlkBufferSize - m_BlockHeader.uiBlockSize; - m_ui64BlkEntryPosition = pucToPos - m_pucBlockBuf; - } - else - { - m_uiLengthRemaining = 0; - } - } - - m_BlockHeader.uiBlockSize = uiBlkBufferSize; -} - -/***************************************************************************** -Desc: truncate the file to the current file position. -*****************************************************************************/ -RCODE FResultSetBlk::Truncate( - FLMBYTE * pszPath) -{ - RCODE rc = NE_XFLM_OK; - - if( RC_BAD( rc = (*m_ppFileHdl64)->Truncate( - m_BlockHeader.ui64FilePos))) - { - goto Exit; - } - - (*m_ppFileHdl64)->Close( FALSE); - - if( RC_BAD( rc = (*m_ppFileHdl64)->Open( ( char *)pszPath))) - { - goto Exit; - } - - m_BlockHeader.ui64FilePos = RSBLK_UNSET_FILE_POS; - -Exit: - - return( rc); -} diff --git a/xflaim/src/fscursor.cpp b/xflaim/src/fscursor.cpp index c9c742c..2d79094 100644 --- a/xflaim/src/fscursor.cpp +++ b/xflaim/src/fscursor.cpp @@ -145,7 +145,7 @@ RCODE FSIndexCursor::allocDupCheckSet( void) } if (RC_BAD( rc = dbSystem.getTempDir( szTmpDir))) { - if (rc == NE_XFLM_IO_PATH_NOT_FOUND) + if (rc == NE_FLM_IO_PATH_NOT_FOUND) { rc = NE_XFLM_OK; } @@ -157,7 +157,7 @@ RCODE FSIndexCursor::allocDupCheckSet( void) if (!szTmpDir [0] && m_pDb) { - if (RC_BAD( rc = gv_pFileSystem->pathReduce( + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathReduce( m_pDb->m_pDatabase->m_pszDbPath, szTmpDir, NULL))) { goto Exit; @@ -544,12 +544,11 @@ RCODE FSIndexCursor::setKeyPosition( FLMUINT * puiDataLen, F_Btree * pBTree, // BTree to use. NULL means use our // internal one. - FLMUINT * puiAbsolutePos - ) + FLMUINT * puiAbsolutePos) { - RCODE rc = NE_XFLM_OK; - FLMUINT uiDataLen; - FLMINT iCompare; + RCODE rc = NE_XFLM_OK; + FLMUINT uiDataLen; + FLMINT iCompare = 0; // if pBTree is NULL, we are to use m_pbTree. Otherwise, we // need to open the pBTree and use it. @@ -902,15 +901,16 @@ RCODE FSIndexCursor::nextKey( F_DataVector * pKey, FLMBOOL bSkipCurrKey) { - RCODE rc = NE_XFLM_OK; - KEYPOS saveCurrentKey; - FLMUINT uiDataLen; - FLMINT iCompare; + RCODE rc = NE_XFLM_OK; + KEYPOS saveCurrentKey; + FLMUINT uiDataLen; + FLMINT iCompare; if (RC_BAD( rc = checkTransaction( pDb))) { goto Exit; } + flmAssert( m_bSetup); if (m_bAtEOF) { @@ -1140,21 +1140,24 @@ RCODE FSIndexCursor::prevKey( F_DataVector * pKey, FLMBOOL bSkipCurrKey) { - RCODE rc = NE_XFLM_OK; - KEYPOS saveCurrentKey; - FLMUINT uiDataLen; - FLMINT iCompare; + RCODE rc = NE_XFLM_OK; + KEYPOS saveCurrentKey; + FLMUINT uiDataLen; + FLMINT iCompare; if (RC_BAD( rc = checkTransaction( pDb))) { goto Exit; } + flmAssert( m_bSetup); + if (m_bAtBOF) { rc = RC_SET( NE_XFLM_BOF_HIT); goto Exit; } + if (m_bAtEOF || !m_curKey.uiKeyLen) { rc = lastKey( pDb, pKey); diff --git a/xflaim/src/fscursor.h b/xflaim/src/fscursor.h index 6b304ea..b165ef3 100644 --- a/xflaim/src/fscursor.h +++ b/xflaim/src/fscursor.h @@ -37,7 +37,7 @@ typedef struct KeyPosition /*============================================================================ Desc: File system implementation of a cursor for an index. ============================================================================*/ -class FSIndexCursor : public XF_RefCount, public XF_Base +class FSIndexCursor : public F_Object { public: @@ -198,7 +198,7 @@ private: /*============================================================================ Desc: File system implementation of a cursor for a collection. ============================================================================*/ -class FSCollectionCursor : public XF_RefCount, public XF_Base +class FSCollectionCursor : public F_Object { public: diff --git a/xflaim/src/fslfile.cpp b/xflaim/src/fslfile.cpp index 0a22085..9415f5f 100644 --- a/xflaim/src/fslfile.cpp +++ b/xflaim/src/fslfile.cpp @@ -223,13 +223,13 @@ RCODE F_Database::lFileCreate( FLMUINT uiEncId) { RCODE rc = NE_XFLM_OK; - F_CachedBlock * pNewSCache; + F_CachedBlock * pNewSCache = NULL; F_CachedBlock * pSCache = NULL; - F_BLK_HDR * pBlkHdr; - FLMUINT uiBlkAddress; + F_BLK_HDR * pBlkHdr = NULL; + FLMUINT uiBlkAddress = 0; FLMUINT uiNextBlkAddress; - FLMUINT uiEndPos; - FLMUINT uiPos; + FLMUINT uiEndPos = 0; + FLMUINT uiPos = 0; FLMBOOL bReleaseCache2 = FALSE; FLMBOOL bReleaseCache = FALSE; F_Btree * pbTree = NULL; diff --git a/xflaim/src/fslfileu.cpp b/xflaim/src/fslfileu.cpp index 6bba570..e85962c 100644 --- a/xflaim/src/fslfileu.cpp +++ b/xflaim/src/fslfileu.cpp @@ -818,6 +818,11 @@ RCODE F_Db::dictClone( void) rc = RC_SET( NE_XFLM_MEM); goto Exit; } + + if( RC_BAD( rc = pNewDict->setup())) + { + goto Exit; + } // Nothing to do is not a legal state. @@ -949,7 +954,7 @@ void flmLogIndexingProgress( if( (pLogMsg = flmBeginLogMessage( XFLM_GENERAL_MESSAGE)) != NULL) { - pLogMsg->changeColor( XFLM_YELLOW, XFLM_BLACK); + pLogMsg->changeColor( FLM_YELLOW, FLM_BLACK); if (ui64LastDocumentId) { f_sprintf( (char *)szMsg, @@ -1134,7 +1139,7 @@ RCODE F_Db::indexDocument( IX_CONTEXT * pIxContext; F_DOMNode * pTmpNode = NULL; F_TRAV * pTrav = NULL; - void * pvMark = m_TempPool.poolMark(); + void * pvMark = m_pTempPool->poolMark(); CDL_HDR * pCdlHdr; FLMUINT64 ui64DocId; @@ -1190,7 +1195,7 @@ RCODE F_Db::indexDocument( // Do an in-order traversal of the document. - if (RC_BAD( rc = m_TempPool.poolCalloc( sizeof( F_TRAV), (void **)&pTrav))) + if (RC_BAD( rc = m_pTempPool->poolCalloc( sizeof( F_TRAV), (void **)&pTrav))) { goto Exit; } @@ -1322,12 +1327,12 @@ RCODE F_Db::indexDocument( pIxContextList->pPrev = pIxContext; } pIxContextList = pIxContext; - - if ((pIxContext->pPool = f_new F_Pool) == NULL) + + if( RC_BAD( rc = FlmAllocPool( &pIxContext->pPool))) { - rc = RC_SET( NE_XFLM_MEM); goto Exit; } + pIxContext->pPool->poolInit( 512); if (RC_BAD( rc = pIxContext->pPool->poolCalloc( @@ -1500,7 +1505,7 @@ Setup_Child: { F_TRAV * pNewTrav; - if (RC_BAD( rc = m_TempPool.poolCalloc( sizeof( F_TRAV), + if (RC_BAD( rc = m_pTempPool->poolCalloc( sizeof( F_TRAV), (void **)&pNewTrav))) { goto Exit; @@ -1725,7 +1730,7 @@ Exit: kyFreeIxContext( pIxd, pIxContextList, &pIxContextList); } - m_TempPool.poolReset( pvMark); + m_pTempPool->poolReset( pvMark); return( rc); } @@ -1740,7 +1745,7 @@ RCODE F_Db::indexSetOfDocuments( IF_IxClient * ifpIxClient, XFLM_INDEX_STATUS * pIndexStatus, FLMBOOL * pbHitEnd, - F_Thread * pThread) + IF_Thread * pThread) { RCODE rc = NE_XFLM_OK; FLMUINT64 ui64DocumentId; @@ -1760,14 +1765,14 @@ RCODE F_Db::indexSetOfDocuments( FLMBOOL bRelinquish = FALSE; FLMBYTE ucKey[ FLM_MAX_NUM_BUF_SIZE]; FLMUINT uiKeyLen; - void * pvTmpPoolMark = m_TempPool.poolMark(); + void * pvTmpPoolMark = m_pTempPool->poolMark(); F_Btree * pbtree = NULL; FLMBOOL bNeg; FLMUINT uiBytesProcessed; F_DOMNode * pNode = NULL; - FLM_MILLI_TO_TIMER_UNITS( 500, uiMinTU); // 1/2 second - FLM_SECS_TO_TIMER_UNITS( 10, uiStatusIntervalTU); // 10 seconds + uiMinTU = FLM_MILLI_TO_TIMER_UNITS( 500); + uiStatusIntervalTU = FLM_SECS_TO_TIMER_UNITS( 10); uiStartTime = FLM_GET_TIMER(); if (RC_BAD( rc = krefCntrlCheck())) @@ -2071,7 +2076,7 @@ Exit: } krefCntrlFree(); - m_TempPool.poolReset( pvTmpPoolMark); + m_pTempPool->poolReset( pvTmpPoolMark); if (pbtree) { @@ -2472,7 +2477,7 @@ RCODE F_Database::startMaintThread( void) // Generate the thread name - if( RC_BAD( rc = gv_pFileSystem->pathReduce( + if( RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathReduce( m_pszDbPath, szThreadName, szBaseName))) { goto Exit; @@ -2489,9 +2494,9 @@ RCODE F_Database::startMaintThread( void) // Start the thread. - if( RC_BAD( rc = f_threadCreate( &m_pMaintThrd, + if( RC_BAD( rc = gv_XFlmSysData.pThreadMgr->createThread( &m_pMaintThrd, F_Database::maintenanceThread, szThreadName, - FLM_DEFAULT_THREAD_GROUP, 0, this, NULL, 32000))) + 0, 0, this, NULL, 32000))) { goto Exit; } @@ -2517,7 +2522,7 @@ Exit: Desc: ****************************************************************************/ RCODE F_Db::beginBackgroundTrans( - F_Thread * pThread) + IF_Thread * pThread) { RCODE rc = NE_XFLM_OK; @@ -2609,7 +2614,7 @@ Desc: Thread that will build an index in the background. freed at the conclusion of the routine. ****************************************************************************/ RCODE F_Database::maintenanceThread( - F_Thread * pThread) + IF_Thread * pThread) { RCODE rc = NE_XFLM_OK; F_Database * pDatabase = (F_Database *)pThread->getParm1(); diff --git a/xflaim/src/fsrvlock.cpp b/xflaim/src/fsrvlock.cpp index d7ba0fd..c753294 100644 --- a/xflaim/src/fsrvlock.cpp +++ b/xflaim/src/fsrvlock.cpp @@ -456,7 +456,8 @@ void FFileItemId::GetFileName( // _ExtractFileName( m_pFile, pszFileNameRV); char szTmpPath[ F_PATH_MAX_SIZE]; - (void)gv_pFileSystem->pathReduce( m_pDatabase->m_pszDbPath, szTmpPath, pszFileNameRV); + (void)gv_XFlmSysData.pFileSystem->pathReduce( + m_pDatabase->m_pszDbPath, szTmpPath, pszFileNameRV); // Convert to upper case for consistency when hashing. @@ -745,8 +746,7 @@ RCODE ServerLockObject::Lock( } else { - FLM_SECS_TO_TIMER_UNITS( uiMaxWaitSecs, - LockWait.uiWaitTime); + LockWait.uiWaitTime = FLM_SECS_TO_TIMER_UNITS( uiMaxWaitSecs); } // Link to list of global waiters - ordered by end time. @@ -773,11 +773,7 @@ RCODE ServerLockObject::Lock( if (RC_BAD( TempRc = f_semWait( LockWait.hESem, F_SEM_WAITFOREVER))) { -#ifdef FLM_NLM - EnterDebugger(); -#else RC_UNEXPECTED_ASSERT( TempRc); -#endif rc = TempRc; } else @@ -787,11 +783,7 @@ RCODE ServerLockObject::Lock( if (rc == NE_XFLM_FAILURE) { -#ifdef FLM_NLM - EnterDebugger(); -#else RC_UNEXPECTED_ASSERT( rc); -#endif } } @@ -1153,7 +1145,7 @@ RCODE ServerLockObject::GetLockInfo( // Output the lock holder first. uiElapTime = FLM_ELAPSED_TIME( uiCurrTime, m_uiLockTime); - FLM_TIMER_UNITS_TO_MILLI( uiElapTime, uiMilli); + uiMilli = FLM_TIMER_UNITS_TO_MILLI( uiElapTime); if( pLockInfo->addLockInfo( 0, m_uiLockThreadId, uiMilli) == FALSE) { goto Exit; @@ -1166,7 +1158,7 @@ RCODE ServerLockObject::GetLockInfo( while( pLockWaiter && uiCnt) { uiElapTime = FLM_ELAPSED_TIME( uiCurrTime, pLockWaiter->uiWaitStartTime); - FLM_TIMER_UNITS_TO_MILLI( uiElapTime, uiMilli); + uiMilli = FLM_TIMER_UNITS_TO_MILLI( uiElapTime); if( pLockInfo->addLockInfo( (m_uiNumWaiters - uiCnt) + 1, pLockWaiter->uiThreadId, uiMilli) == FALSE) { diff --git a/xflaim/src/fsrvlock.h b/xflaim/src/fsrvlock.h index d47a7eb..936d4a1 100644 --- a/xflaim/src/fsrvlock.h +++ b/xflaim/src/fsrvlock.h @@ -86,7 +86,7 @@ Class: ServerLockManager Desc: The ServerLockManager class manages ServerLockObject objects. ===========================================================================*/ -class ServerLockManager : public XF_RefCount, public XF_Base +class ServerLockManager : public F_Object { public: @@ -183,7 +183,7 @@ friend class ServerLockObject; Class: F_ItemId Desc: The item id that identifies a particular object. ===========================================================================*/ -class F_ItemId : public XF_RefCount, public XF_Base +class F_ItemId : public F_Object { public: F_ItemId(); // F_ItemId Constructor @@ -316,7 +316,7 @@ private: Desc: The ServerLockObject is used to lock and unlock a particular object. ===========================================================================*/ -class ServerLockObject : public XF_RefCount, public XF_Base +class ServerLockObject : public F_Object { public: ServerLockObject(); // ServerLockObject Constructor @@ -356,7 +356,7 @@ public: // Decrement ref count, when it gets // down to 1, put it in the avail list. - FLMINT XFLMAPI Release( void) + FLMINT FLMAPI Release( void) { return( Release( FALSE)); } diff --git a/xflaim/src/fstream.cpp b/xflaim/src/fstream.cpp deleted file mode 100644 index ce3b749..0000000 --- a/xflaim/src/fstream.cpp +++ /dev/null @@ -1,3345 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Streaming interface -// -// Tabs: 3 -// -// Copyright (c) 2004-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: fstream.cpp 3123 2006-01-24 17:19:50 -0700 (Tue, 24 Jan 2006) ahodgkinson $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -#define LZW_MAGIC_NUMBER 0x3482 -#define LZW_END_OF_DATA 256 -#define LZW_NEW_DICT 257 -#define LZW_STOP_COMPRESSION 258 -#define LZW_START_CODE 259 -#define LZW_MAX_CODE 0xFFFF - -#define MULTI_FILE_OUT_STREAM_MIN_FILE_SIZE 1048510 -#define MULTI_FILE_OUT_STREAM_MAX_FILE_SIZE 2147483647 - -FLMBYTE F_Base64EncoderIStream::m_ucEncodeTable[ 64] = -{ - ASCII_UPPER_A, ASCII_UPPER_B, ASCII_UPPER_C, ASCII_UPPER_D, - ASCII_UPPER_E, ASCII_UPPER_F, ASCII_UPPER_G, ASCII_UPPER_H, - ASCII_UPPER_I, ASCII_UPPER_J, ASCII_UPPER_K, ASCII_UPPER_L, - ASCII_UPPER_M, ASCII_UPPER_N, ASCII_UPPER_O, ASCII_UPPER_P, - ASCII_UPPER_Q, ASCII_UPPER_R, ASCII_UPPER_S, ASCII_UPPER_T, - ASCII_UPPER_U, ASCII_UPPER_V, ASCII_UPPER_W, ASCII_UPPER_X, - ASCII_UPPER_Y, ASCII_UPPER_Z, ASCII_LOWER_A, ASCII_LOWER_B, - ASCII_LOWER_C, ASCII_LOWER_D, ASCII_LOWER_E, ASCII_LOWER_F, - ASCII_LOWER_G, ASCII_LOWER_H, ASCII_LOWER_I, ASCII_LOWER_J, - ASCII_LOWER_K, ASCII_LOWER_L, ASCII_LOWER_M, ASCII_LOWER_N, - ASCII_LOWER_O, ASCII_LOWER_P, ASCII_LOWER_Q, ASCII_LOWER_R, - ASCII_LOWER_S, ASCII_LOWER_T, ASCII_LOWER_U, ASCII_LOWER_V, - ASCII_LOWER_W, ASCII_LOWER_X, ASCII_LOWER_Y, ASCII_LOWER_Z, - ASCII_ZERO, ASCII_ONE, ASCII_TWO, ASCII_THREE, - ASCII_FOUR, ASCII_FIVE, ASCII_SIX, ASCII_SEVEN, - ASCII_EIGHT, ASCII_NINE, ASCII_PLUS, ASCII_SLASH -}; - -FLMBYTE F_Base64DecoderIStream::m_ucDecodeTable[ 256] = -{ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0 .. 7 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 8 .. 15 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 16 .. 23 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 24 .. 31 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 32 .. 39 - 0xFF, 0xFF, 0xFF, 0x3E, 0xFF, 0xFF, 0xFF, 0x3F, // 40 .. 47 - 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, // 48 .. 55 - 0x3C, 0x3D, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, // 56 .. 63 - 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // 64 .. 71 - 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, // 72 .. 79 - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, // 80 .. 87 - 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 88 .. 95 - 0xFF, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, // 96 .. 103 - 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, // 104 .. 111 - 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, // 112 .. 119 - 0x31, 0x32, 0x33, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 120 .. 127 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 128 .. 135 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 136 .. 143 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 144 .. 151 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 152 .. 159 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 160 .. 167 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 168 .. 175 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 176 .. 183 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 184 .. 191 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 192 .. 199 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 200 .. 207 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 208 .. 215 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 216 .. 223 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 224 .. 231 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 232 .. 239 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 240 .. 247 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF // 248 .. 255 -}; - -/**************************************************************************** -Desc: -****************************************************************************/ -F_IStream::F_IStream() -{ - m_bLockedModule = FALSE; -} - -/**************************************************************************** -Desc: -****************************************************************************/ -F_IStream::~F_IStream() -{ - if( m_bLockedModule) - { - UnlockModule(); - } -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void F_IStream::lockModule( void) -{ - if( !m_bLockedModule) - { - LockModule(); - m_bLockedModule = TRUE; - } -} - -/**************************************************************************** -Desc: -****************************************************************************/ -F_PosIStream::F_PosIStream() -{ - m_bLockedModule = FALSE; -} - -/**************************************************************************** -Desc: -****************************************************************************/ -F_PosIStream::~F_PosIStream() -{ - if( m_bLockedModule) - { - UnlockModule(); - } -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void F_PosIStream::lockModule( void) -{ - if( !m_bLockedModule) - { - LockModule(); - m_bLockedModule = TRUE; - } -} - -/**************************************************************************** -Desc: -****************************************************************************/ -F_OStream::F_OStream() -{ - m_bLockedModule = FALSE; -} - -/**************************************************************************** -Desc: -****************************************************************************/ -F_OStream::~F_OStream() -{ - if( m_bLockedModule) - { - UnlockModule(); - } -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void F_OStream::lockModule( void) -{ - if( !m_bLockedModule) - { - LockModule(); - m_bLockedModule = TRUE; - } -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -RCODE XFLMAPI F_FileIStream::open( - const char * pszFilePath) -{ - RCODE rc = NE_XFLM_OK; - - close(); - - if( RC_BAD( rc = gv_pFileSystem->Open( (char *)pszFilePath, - XFLM_IO_RDONLY | XFLM_IO_SH_DENYNONE, &m_pFileHdl))) - { - goto Exit; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Closes the input stream and frees any resources -*****************************************************************************/ -RCODE F_FileIStream::close( void) -{ - RCODE rc = NE_XFLM_OK; - - if( m_pFileHdl) - { - rc = m_pFileHdl->Close(); - m_pFileHdl->Release(); - m_pFileHdl = NULL; - } - - m_ui64FileOffset = 0; - return( rc); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -FLMUINT64 XFLMAPI F_FileIStream::totalSize( void) -{ - FLMUINT64 ui64FileSize = 0; - - (void)m_pFileHdl->Size( &ui64FileSize); - return( ui64FileSize); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -FLMUINT64 XFLMAPI F_FileIStream::remainingSize( void) -{ - FLMUINT64 ui64TotalSize = totalSize(); - FLMUINT64 ui64Offset = getCurrPosition(); - - if( ui64TotalSize >= ui64Offset) - { - return( ui64TotalSize - ui64Offset); - } - - return( 0); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -FLMUINT64 XFLMAPI F_FileIStream::getCurrPosition( void) -{ - return( m_ui64FileOffset); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -RCODE XFLMAPI F_FileIStream::positionTo( - FLMUINT64 ui64Offset) -{ - m_ui64FileOffset = ui64Offset; - return( NE_XFLM_OK); -} - -/**************************************************************************** -Desc: Reads the requested amount of data from the stream. -*****************************************************************************/ -RCODE F_FileIStream::read( - void * pvBuffer, - FLMUINT uiBytesToRead, - FLMUINT * puiBytesRead) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiBytesRead = 0; - - if( !m_pFileHdl) - { - rc = RC_SET( NE_XFLM_READING_FILE); - goto Exit; - } - - rc = m_pFileHdl->Read( m_ui64FileOffset, uiBytesToRead, - pvBuffer, &uiBytesRead); - m_ui64FileOffset += uiBytesRead; - - if( RC_BAD( rc)) - { - if( rc == NE_XFLM_IO_END_OF_FILE) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - } - goto Exit; - } - -Exit: - - if( puiBytesRead) - { - *puiBytesRead = uiBytesRead; - } - - return( rc); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -RCODE XFLMAPI F_BufferedIStream::open( - IF_IStream * pIStream, - FLMUINT uiBufferSize) -{ - RCODE rc = NE_XFLM_OK; - - if( m_pIStream || !pIStream) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_ILLEGAL_OP); - goto Exit; - } - - m_pIStream = pIStream; - m_pIStream->AddRef(); - - m_uiBufferSize = uiBufferSize; - m_uiBufferOffset = 0; - m_uiBytesAvail = 0; - - if( RC_BAD( rc = f_alloc( m_uiBufferSize, &m_pucBuffer))) - { - goto Exit; - } - -Exit: - - if (RC_BAD( rc)) - { - close(); - } - - return( rc); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -RCODE XFLMAPI F_BufferedIStream::read( - void * pvBuffer, - FLMUINT uiBytesToRead, - FLMUINT * puiBytesRead) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE * pucBuffer = (FLMBYTE *)pvBuffer; - FLMUINT uiBytesRead = 0; - FLMUINT uiMaxSize; - - if (!m_pIStream) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_ILLEGAL_OP); - goto Exit; - } - - while( uiBytesToRead) - { - if( (uiMaxSize = m_uiBytesAvail - m_uiBufferOffset) == 0) - { - if (RC_BAD( rc = m_pIStream->read( - m_pucBuffer, m_uiBufferSize, &m_uiBytesAvail))) - { - if (rc != NE_XFLM_EOF_HIT || !m_uiBytesAvail) - { - m_uiBufferOffset = 0; - goto Exit; - } - } - - flmAssert( m_uiBytesAvail <= m_uiBufferSize); - m_uiBufferOffset = 0; - } - else if( uiBytesToRead < uiMaxSize) - { - f_memcpy( pucBuffer, &m_pucBuffer[ m_uiBufferOffset], uiBytesToRead); - m_uiBufferOffset += uiBytesToRead; - uiBytesRead += uiBytesToRead; - uiBytesToRead = 0; - break; - } - else - { - f_memcpy( pucBuffer, &m_pucBuffer[ m_uiBufferOffset], uiMaxSize); - m_uiBufferOffset += uiMaxSize; - pucBuffer += uiMaxSize; - uiBytesToRead -= uiMaxSize; - uiBytesRead += uiMaxSize; - } - } - -Exit: - - if (puiBytesRead) - { - *puiBytesRead = uiBytesRead; - } - - return( rc); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -RCODE XFLMAPI F_BufferedIStream::close( void) -{ - RCODE rc = NE_XFLM_OK; - - if( m_pIStream) - { - if( m_pIStream->getRefCount() == 1) - { - rc = m_pIStream->close(); - } - - m_pIStream->Release(); - m_pIStream = NULL; - } - - if( m_pucBuffer) - { - f_free( &m_pucBuffer); - } - - m_uiBufferSize = 0; - m_uiBufferOffset = 0; - m_uiBytesAvail = 0; - - return( rc); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -RCODE XFLMAPI F_FileOStream::open( - const char * pszFilePath, - FLMBOOL bTruncateIfExists) -{ - RCODE rc = NE_XFLM_OK; - - if( m_pFileHdl) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_ILLEGAL_OP); - goto Exit; - } - - if( bTruncateIfExists) - { - if( RC_BAD( rc = gv_pFileSystem->Delete( (char *)pszFilePath))) - { - if( rc != NE_XFLM_IO_PATH_NOT_FOUND) - { - goto Exit; - } - } - - if( RC_BAD( rc = gv_pFileSystem->Create( - (char *)pszFilePath, XFLM_IO_RDWR, &m_pFileHdl))) - { - goto Exit; - } - } - else - { - if( RC_BAD( rc = gv_pFileSystem->Open( - (char *)pszFilePath, XFLM_IO_RDWR, &m_pFileHdl))) - { - if( rc != NE_XFLM_IO_PATH_NOT_FOUND) - { - goto Exit; - } - - if( RC_BAD( rc = gv_pFileSystem->Create( - (char *)pszFilePath, XFLM_IO_RDWR, &m_pFileHdl))) - { - goto Exit; - } - } - } - - if( RC_BAD( rc = m_pFileHdl->Size( &m_ui64FileOffset))) - { - goto Exit; - } - -Exit: - - if (RC_BAD( rc)) - { - close(); - } - - return( rc); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -RCODE XFLMAPI F_FileOStream::write( - const void * pvBuffer, - FLMUINT uiBytesToWrite, - FLMUINT * puiBytesWritten) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiBytesWritten = 0; - - if (!m_pFileHdl) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_ILLEGAL_OP); - goto Exit; - } - - if( RC_BAD( rc = m_pFileHdl->Write( - (FLMUINT)m_ui64FileOffset, uiBytesToWrite, (void *)pvBuffer, &uiBytesWritten))) - { - goto Exit; - } - -Exit: - - m_ui64FileOffset += uiBytesWritten; - - if( puiBytesWritten) - { - *puiBytesWritten = uiBytesWritten; - } - - return( rc); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -RCODE XFLMAPI F_FileOStream::close( void) -{ - RCODE rc = NE_XFLM_OK; - - if( m_pFileHdl) - { - m_pFileHdl->Release(); - m_pFileHdl = NULL; - } - - m_ui64FileOffset = 0; - return( rc); -} - -/****************************************************************************** -Desc: -******************************************************************************/ -RCODE XFLMAPI F_MultiFileIStream::open( - const char * pszDirectory, - const char * pszBaseName) -{ - RCODE rc = NE_XFLM_OK; - - if( m_bOpen) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_ILLEGAL_OP); - goto Exit; - } - - f_strcpy( m_szDirectory, pszDirectory); - f_strcpy( m_szBaseName, pszBaseName); - - m_uiFileNum = 0xFFFFFFFF; - m_ui64FileOffset = 0; - m_bEndOfStream = FALSE; - m_bOpen = TRUE; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -RCODE F_MultiFileIStream::rollToNextFile( void) -{ - RCODE rc = NE_XFLM_OK; - F_FileIStream * pFileIStream = NULL; - F_BufferedIStream * pBufferedIStream = NULL; - FLMUINT uiNewFileNum = 0; - FLMBYTE szFilePath[ F_PATH_MAX_SIZE + 1]; - FLMBYTE szFileName[ F_PATH_MAX_SIZE + 1]; - - if( m_pIStream) - { - m_pIStream->Release(); - m_pIStream = NULL; - m_ui64FileOffset = 0; - } - - if( m_uiFileNum == 0xFFFFFFFE) - { - rc = RC_SET( NE_XFLM_STREAM_TOO_MANY_FILES); - goto Exit; - } - else if( m_uiFileNum == 0xFFFFFFFF) - { - f_strcpy( szFileName, m_szBaseName); - uiNewFileNum = 0; - } - else - { - uiNewFileNum = m_uiFileNum + 1; - f_sprintf( (char *)szFileName, "%s.%08X", m_szBaseName, uiNewFileNum); - } - - f_strcpy( szFilePath, m_szDirectory); - if( RC_BAD( rc = gv_pFileSystem->pathAppend( - (char *)szFilePath, (char *)szFileName))) - { - goto Exit; - } - - if( (pFileIStream = f_new F_FileIStream) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = pFileIStream->open( (const char *)szFilePath))) - { - if (rc == NE_XFLM_IO_PATH_NOT_FOUND) - { - m_bEndOfStream = TRUE; - rc = RC_SET( NE_XFLM_EOF_HIT); - } - goto Exit; - } - - if( (pBufferedIStream = f_new F_BufferedIStream) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = pBufferedIStream->open( pFileIStream, 16384))) - { - goto Exit; - } - - m_uiFileNum = uiNewFileNum; - m_pIStream = pBufferedIStream; - pBufferedIStream = NULL; - -Exit: - - if( pFileIStream) - { - pFileIStream->Release(); - } - - if( pBufferedIStream) - { - pBufferedIStream->Release(); - } - - return( rc); -} - -/****************************************************************************** -Desc: -******************************************************************************/ -RCODE XFLMAPI F_MultiFileIStream::read( - void * pvBuffer, - FLMUINT uiBytesToRead, - FLMUINT * puiBytesRead) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiTmpRead; - FLMUINT uiTotalRead = 0; - FLMBOOL bRollToNextFile = FALSE; - FLMBYTE * pucBuffer = (FLMBYTE *)pvBuffer; - - if( !m_bOpen) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_ILLEGAL_OP); - goto Exit; - } - - if (m_bEndOfStream) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - - if (!m_pIStream) - { - bRollToNextFile = TRUE; - } - - while (uiBytesToRead) - { - if (bRollToNextFile) - { - if (RC_BAD( rc = rollToNextFile())) - { - goto Exit; - } - } - - if (RC_BAD( rc = m_pIStream->read( - pucBuffer, uiBytesToRead, &uiTmpRead))) - { - if (rc != NE_XFLM_EOF_HIT) - { - goto Exit; - } - - rc = NE_XFLM_OK; - bRollToNextFile = TRUE; - if (!uiTmpRead) - { - continue; - } - } - - pucBuffer += uiTmpRead; - uiBytesToRead -= uiTmpRead; - uiTotalRead += uiTmpRead; - m_ui64FileOffset += uiTmpRead; - } - -Exit: - - if (puiBytesRead) - { - *puiBytesRead = uiTotalRead; - } - - return( rc); -} - -/****************************************************************************** -Desc: -******************************************************************************/ -RCODE XFLMAPI F_MultiFileIStream::close( void) -{ - if( m_pIStream) - { - m_pIStream->Release(); - m_pIStream = NULL; - } - - m_uiFileNum = 0; - m_ui64FileOffset = 0; - m_szDirectory[ 0] = 0; - m_szBaseName[ 0] = 0; - m_bEndOfStream = FALSE; - m_bOpen = FALSE; - - return( NE_XFLM_OK); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -RCODE F_MultiFileOStream::create( - const char * pszDirectory, - const char * pszBaseName, - FLMUINT uiMaxFileSize, - FLMBOOL bOkToOverwrite) -{ - RCODE rc = NE_XFLM_OK; - - if( m_bOpen) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_ILLEGAL_OP); - goto Exit; - } - - if( RC_BAD( rc = processDirectory( - pszDirectory, pszBaseName, bOkToOverwrite))) - { - goto Exit; - } - - f_strcpy( m_szDirectory, pszDirectory); - f_strcpy( m_szBaseName, pszBaseName); - - if( !uiMaxFileSize) - { - uiMaxFileSize = MULTI_FILE_OUT_STREAM_MAX_FILE_SIZE; - } - else if( uiMaxFileSize < MULTI_FILE_OUT_STREAM_MIN_FILE_SIZE) - { - uiMaxFileSize = MULTI_FILE_OUT_STREAM_MIN_FILE_SIZE; - } - else if( uiMaxFileSize > MULTI_FILE_OUT_STREAM_MAX_FILE_SIZE) - { - uiMaxFileSize = MULTI_FILE_OUT_STREAM_MAX_FILE_SIZE; - } - - m_uiFileNum = 0xFFFFFFFF; - m_ui64FileOffset = 0; - m_ui64MaxFileSize = uiMaxFileSize; - m_bOpen = TRUE; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -RCODE F_MultiFileOStream::processDirectory( - const char * pszDirectory, - const char * pszBaseName, - FLMBOOL bOkToDelete) -{ - RCODE rc = NE_XFLM_OK; - IF_DirHdl * pDirHandle = NULL; - FLMUINT uiBaseNameLen = f_strlen( pszBaseName); - const char * pszName = NULL; - char szSearchPattern[ F_PATH_MAX_SIZE + 1]; - char szFilePath[ F_PATH_MAX_SIZE + 1]; - - f_sprintf( szSearchPattern, "%s*", pszBaseName); - - if (!pszDirectory || *pszDirectory == 0) - { - pszDirectory = "."; - } - - if( RC_BAD( rc = gv_pFileSystem->OpenDir( - (char *)pszDirectory, szSearchPattern, &pDirHandle))) - { - goto Exit; - } - - for( ;;) - { - if( RC_BAD( rc = pDirHandle->Next())) - { - if( rc != NE_XFLM_IO_NO_MORE_FILES) - { - goto Exit; - } - - rc = NE_XFLM_OK; - break; - } - - // Verify that the file belongs to the stream - - pszName = pDirHandle->CurrentItemName(); - if( f_strcmp( pszName, pszBaseName) == 0 || - (f_strncmp( pszName, pszBaseName, uiBaseNameLen) == 0 && - pszName[ uiBaseNameLen] == '.' && - f_isValidHexNum( (FLMBYTE *)&pszName[ uiBaseNameLen + 1]))) - { - if (!bOkToDelete) - { - rc = RC_SET( NE_XFLM_STREAM_EXISTS); - goto Exit; - } - - // Delete the file - - f_strcpy( szFilePath, pszDirectory); - - if( RC_BAD( rc = gv_pFileSystem->pathAppend( - szFilePath, pszName))) - { - goto Exit; - } - - if( RC_BAD( gv_pFileSystem->Delete( szFilePath))) - { - if (rc != NE_XFLM_IO_PATH_NOT_FOUND) - { - goto Exit; - } - - rc = NE_XFLM_OK; - } - } - } - -Exit: - - if( pDirHandle) - { - pDirHandle->Release(); - pDirHandle = NULL; - } - - return( rc); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -RCODE XFLMAPI F_DbSystem::removeMultiFileStream( - const char * pszDirectory, - const char * pszBaseName) -{ - RCODE rc = NE_XFLM_OK; - F_MultiFileOStream * pMultiStream = NULL; - - if( (pMultiStream = f_new F_MultiFileOStream) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = pMultiStream->processDirectory( - pszDirectory, pszBaseName, TRUE))) - { - goto Exit; - } - -Exit: - - if( pMultiStream) - { - pMultiStream->Release(); - } - - return( rc); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -RCODE F_MultiFileOStream::rollToNextFile( void) -{ - RCODE rc = NE_XFLM_OK; - F_FileOStream * pFileOStream = NULL; - F_BufferedOStream * pBufferedOStream = NULL; - FLMUINT uiNewFileNum = 0; - FLMBYTE szFilePath[ F_PATH_MAX_SIZE + 1]; - FLMBYTE szFileName[ F_PATH_MAX_SIZE + 1]; - - if( m_pOStream) - { - if( RC_BAD( rc = m_pOStream->close())) - { - goto Exit; - } - - m_pOStream->Release(); - m_pOStream = NULL; - m_ui64FileOffset = 0; - } - - if( m_uiFileNum == 0xFFFFFFFE) - { - rc = RC_SET( NE_XFLM_STREAM_TOO_MANY_FILES); - goto Exit; - } - else if( m_uiFileNum == 0xFFFFFFFF) - { - f_strcpy( szFileName, m_szBaseName); - uiNewFileNum = 0; - } - else - { - uiNewFileNum = m_uiFileNum + 1; - f_sprintf( (char *)szFileName, "%s.%08X", m_szBaseName, uiNewFileNum); - } - - f_strcpy( szFilePath, m_szDirectory); - - if( RC_BAD( rc = gv_pFileSystem->pathAppend( - (char *)szFilePath, (char *)szFileName))) - { - goto Exit; - } - - if( (pFileOStream = f_new F_FileOStream) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = pFileOStream->open( (const char *)szFilePath, TRUE))) - { - goto Exit; - } - - if( (pBufferedOStream = f_new F_BufferedOStream) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = pBufferedOStream->open( pFileOStream, 16384))) - { - goto Exit; - } - - m_uiFileNum = uiNewFileNum; - m_pOStream = pBufferedOStream; - pBufferedOStream = NULL; - -Exit: - - if( pFileOStream) - { - pFileOStream->Release(); - } - - if( pBufferedOStream) - { - pBufferedOStream->Release(); - } - - return( rc); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -RCODE XFLMAPI F_MultiFileOStream::write( - const void * pvBuffer, - FLMUINT uiBytesToWrite, - FLMUINT * puiBytesWritten) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiMaxToWrite; - FLMUINT uiBytesWritten = 0; - FLMBYTE * pucBuffer = (FLMBYTE *)pvBuffer; - - if (!m_bOpen) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_ILLEGAL_OP); - goto Exit; - } - - if (!m_pOStream) - { - if (RC_BAD( rc = rollToNextFile())) - { - goto Exit; - } - } - - while (uiBytesToWrite) - { - if ((uiMaxToWrite = (FLMUINT)(m_ui64MaxFileSize - m_ui64FileOffset)) < - uiBytesToWrite) - { - if (RC_BAD( rc = m_pOStream->write( pucBuffer, uiMaxToWrite))) - { - goto Exit; - } - - pucBuffer += uiMaxToWrite; - uiBytesWritten += uiMaxToWrite; - - if (RC_BAD( rc = rollToNextFile())) - { - goto Exit; - } - } - else - { - uiMaxToWrite = uiBytesToWrite; - - if (RC_BAD( rc = m_pOStream->write( pucBuffer, uiBytesToWrite))) - { - goto Exit; - } - } - - uiBytesWritten += uiBytesToWrite; - uiBytesToWrite -= uiMaxToWrite; - m_ui64FileOffset += uiMaxToWrite; - } - -Exit: - - if( puiBytesWritten) - { - *puiBytesWritten = uiBytesWritten; - } - - return( rc); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -RCODE XFLMAPI F_MultiFileOStream::close( void) -{ - RCODE rc = NE_XFLM_OK; - - if( m_pOStream) - { - rc = m_pOStream->close(); - m_pOStream->Release(); - m_pOStream = NULL; - } - - m_uiFileNum = 0; - m_ui64MaxFileSize = 0; - m_ui64FileOffset = 0; - m_szDirectory[ 0] = 0; - m_szBaseName[ 0] = 0; - m_bOpen = FALSE; - - return( rc); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -RCODE XFLMAPI F_BufferedOStream::open( - IF_OStream * pOStream, - FLMUINT uiBufferSize) -{ - RCODE rc = NE_XFLM_OK; - - if( !pOStream || m_pOStream || !uiBufferSize) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_ILLEGAL_OP); - goto Exit; - } - - if( RC_BAD( rc = f_alloc( uiBufferSize, &m_pucBuffer))) - { - goto Exit; - } - - m_pOStream = pOStream; - m_pOStream->AddRef(); - - m_uiBufferSize = uiBufferSize; - m_uiBufferOffset = 0; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -RCODE XFLMAPI F_BufferedOStream::flush( void) -{ - RCODE rc = NE_XFLM_OK; - - if( m_uiBufferOffset) - { - if( RC_BAD( rc = m_pOStream->write( m_pucBuffer, m_uiBufferOffset))) - { - goto Exit; - } - - m_uiBufferOffset = 0; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -RCODE XFLMAPI F_BufferedOStream::write( - const void * pvBuffer, - FLMUINT uiBytesToWrite, - FLMUINT * puiBytesWritten) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiMaxToWrite; - FLMUINT uiBytesWritten = 0; - FLMBYTE * pucBuffer = (FLMBYTE *)pvBuffer; - - while( uiBytesToWrite) - { - uiMaxToWrite = (FLMUINT)(m_uiBufferSize - m_uiBufferOffset); - uiMaxToWrite = uiMaxToWrite > uiBytesToWrite - ? uiBytesToWrite - : uiMaxToWrite; - - f_memcpy( &m_pucBuffer[ m_uiBufferOffset], pucBuffer, uiMaxToWrite); - pucBuffer += uiMaxToWrite; - m_uiBufferOffset += uiMaxToWrite; - uiBytesToWrite -= uiMaxToWrite; - uiBytesWritten += uiMaxToWrite; - - if (m_uiBufferOffset == m_uiBufferSize) - { - if (RC_BAD( rc = flush())) - { - goto Exit; - } - } - } - -Exit: - - if( puiBytesWritten) - { - *puiBytesWritten = uiBytesWritten; - } - - return( rc); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -RCODE XFLMAPI F_BufferedOStream::close( void) -{ - RCODE rc = NE_XFLM_OK; - - if( m_pOStream) - { - if( RC_OK( rc = flush())) - { - if( m_pOStream->getRefCount() == 1) - { - rc = m_pOStream->close(); - } - } - - m_pOStream->Release(); - m_pOStream = NULL; - } - - if( m_pucBuffer) - { - f_free( &m_pucBuffer); - } - - m_uiBufferSize = 0; - m_uiBufferOffset = 0; - - return( rc); -} - -/***************************************************************************** -Desc: -******************************************************************************/ -F_BufferIStream::~F_BufferIStream() -{ - close(); -} - -/***************************************************************************** -Desc: -******************************************************************************/ -RCODE XFLMAPI F_BufferIStream::open( - const FLMBYTE * pucBuffer, - FLMUINT uiLength, - FLMBYTE ** ppucAllocatedBuffer) -{ - RCODE rc = NE_XFLM_OK; - - flmAssert( !m_pucBuffer); - - if( !pucBuffer && uiLength) - { - if( RC_BAD( rc = f_alloc( uiLength, &m_pucBuffer))) - { - goto Exit; - } - - if( ppucAllocatedBuffer) - { - *ppucAllocatedBuffer = (FLMBYTE *)m_pucBuffer; - } - - m_bAllocatedBuffer = TRUE; - } - else - { - m_pucBuffer = pucBuffer; - } - - m_uiBufferLen = uiLength; - m_uiOffset = 0; - m_bIsOpen = TRUE; - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: -******************************************************************************/ -RCODE XFLMAPI F_BufferIStream::close( void) -{ - if( m_bIsOpen) - { - if( m_bAllocatedBuffer) - { - if( m_pucBuffer) - { - f_free( &m_pucBuffer); - } - - m_bAllocatedBuffer = FALSE; - } - else - { - m_pucBuffer = NULL; - } - - m_bIsOpen = FALSE; - } - - return( NE_XFLM_OK); -} - -/***************************************************************************** -Desc: -******************************************************************************/ -RCODE XFLMAPI F_BufferIStream::read( - void * pvBuffer, - FLMUINT uiBytesToRead, - FLMUINT * puiBytesRead) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE * pucBuffer = (FLMBYTE *)pvBuffer; - FLMUINT uiBytesRead; - - flmAssert( m_bIsOpen); - - uiBytesRead = uiBytesToRead < m_uiBufferLen - m_uiOffset - ? uiBytesToRead - : m_uiBufferLen - m_uiOffset; - - if (uiBytesRead) - { - if (pucBuffer) - { - f_memcpy( pucBuffer, &m_pucBuffer[ m_uiOffset], uiBytesRead); - } - - m_uiOffset += uiBytesRead; - } - - if (puiBytesRead) - { - *puiBytesRead = uiBytesRead; - } - - if (uiBytesRead < uiBytesToRead) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: -*****************************************************************************/ -RCODE XFLMAPI F_Base64DecoderIStream::open( - IF_IStream * pIStream) -{ - RCODE rc = NE_XFLM_OK; - - if( m_pIStream || !pIStream) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_ILLEGAL_OP); - goto Exit; - } - - m_uiBufOffset = 0; - m_uiAvailBytes = 0; - m_pIStream = pIStream; - pIStream->AddRef(); - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Reads decoded binary from the base64 ASCII source stream. -*****************************************************************************/ -RCODE XFLMAPI F_Base64DecoderIStream::read( - void * pvBuffer, - FLMUINT uiBytesToRead, - FLMUINT * puiBytesRead) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE * pucOutBuf = (FLMBYTE *)pvBuffer; - FLMBYTE ucQuadBuffer[ 4]; - FLMUINT uiOffset; - FLMUINT uiBytesToCopy; - - if( puiBytesRead) - { - *puiBytesRead = 0; - } - - if( !m_pIStream) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - - while( uiBytesToRead) - { - if( !m_uiAvailBytes) - { - m_uiBufOffset = 0; - - for( uiOffset = 0; uiOffset < 4;) - { - if( RC_BAD( rc = m_pIStream->read( - &ucQuadBuffer[ uiOffset], 1, NULL))) - { - if( rc != NE_XFLM_EOF_HIT) - { - goto Exit; - } - - if( uiOffset) - { - rc = RC_SET( NE_XFLM_BAD_BASE64_ENCODING); - } - - goto Exit; - } - - if( m_ucDecodeTable[ ucQuadBuffer[ uiOffset]] == 0xFF) - { - FLMBYTE ucTmp = ucQuadBuffer[ uiOffset]; - - if( ucTmp == ASCII_TAB || ucTmp == ASCII_SPACE || - ucTmp == ASCII_NEWLINE || ucTmp == ASCII_CR) - { - continue; - } - - rc = RC_SET( NE_XFLM_BAD_BASE64_ENCODING); - goto Exit; - } - - uiOffset++; - } - - m_ucBuffer[ 0] = - (m_ucDecodeTable[ ucQuadBuffer[ 0]] << 2) | - (m_ucDecodeTable[ ucQuadBuffer[ 1]] >> 4); - m_uiAvailBytes++; - - if( ucQuadBuffer[ 2] != '=') - { - m_ucBuffer[ 1] = - (m_ucDecodeTable[ ucQuadBuffer[ 1]] << 4) | - (m_ucDecodeTable[ ucQuadBuffer[ 2]] >> 2); - m_uiAvailBytes++; - } - - if( ucQuadBuffer[ 3] != '=') - { - m_ucBuffer[ 2] = - (m_ucDecodeTable[ ucQuadBuffer[ 2]] << 6) | - m_ucDecodeTable[ ucQuadBuffer[ 3]]; - m_uiAvailBytes++; - } - } - - uiBytesToCopy = f_min( m_uiAvailBytes, uiBytesToRead); - - if( pucOutBuf) - { - f_memcpy( pucOutBuf, &m_ucBuffer[ m_uiBufOffset], uiBytesToCopy); - } - - uiBytesToRead -= uiBytesToCopy; - m_uiAvailBytes -= uiBytesToCopy; - m_uiBufOffset += uiBytesToCopy; - pucOutBuf += uiBytesToCopy; - - if( puiBytesRead) - { - *puiBytesRead += uiBytesToCopy; - } - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: -*****************************************************************************/ -RCODE XFLMAPI F_Base64EncoderIStream::open( - IF_IStream * pIStream, - FLMBOOL bLineBreaks) -{ - RCODE rc = NE_XFLM_OK; - - if( m_pIStream || !pIStream) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_ILLEGAL_OP); - goto Exit; - } - - m_uiBase64Count = 0; - m_uiBufOffset = 0; - m_uiAvailBytes = 0; - m_bLineBreaks = bLineBreaks; - m_bInputExhausted = FALSE; - m_bPriorLineEnd = FALSE; - m_pIStream = pIStream; - pIStream->AddRef(); - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Reads ASCII base64 encoded binary from the source stream. -*****************************************************************************/ -RCODE XFLMAPI F_Base64EncoderIStream::read( - void * pvBuffer, - FLMUINT uiBytesToRead, - FLMUINT * puiBytesRead) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE * pucOutBuf = (FLMBYTE *)pvBuffer; - FLMUINT uiBytesToCopy; - FLMUINT uiBytesToEncode; - FLMBYTE ucTriBuffer[ 3]; - - if( *puiBytesRead) - { - *puiBytesRead = 0; - } - - if( !m_pIStream) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - - while( uiBytesToRead) - { - if( !m_uiAvailBytes) - { - m_uiBufOffset = 0; - - if( m_bInputExhausted) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - - if( RC_BAD( rc = m_pIStream->read( ucTriBuffer, - 3, &uiBytesToEncode))) - { - if( rc != NE_XFLM_EOF_HIT) - { - goto Exit; - } - - rc = NE_XFLM_OK; - m_bInputExhausted = TRUE; - } - - if( uiBytesToEncode) - { - m_ucBuffer[ m_uiAvailBytes++] = - m_ucEncodeTable[ ucTriBuffer[ 0] >> 2]; - - m_ucBuffer[ m_uiAvailBytes++] = - m_ucEncodeTable[ ((ucTriBuffer[ 0] & 0x03) << 4) | - (ucTriBuffer[ 1] >> 4)]; - - if( uiBytesToEncode >= 2) - { - m_ucBuffer[ m_uiAvailBytes++] = - m_ucEncodeTable[ ((ucTriBuffer[ 1] & 0x0F) << 2) | - (ucTriBuffer[ 2] >> 6)]; - } - else - { - m_ucBuffer[ m_uiAvailBytes++] = ASCII_EQUAL; - } - - if( uiBytesToEncode == 3) - { - m_ucBuffer[ m_uiAvailBytes++] = - m_ucEncodeTable[ ucTriBuffer[ 2] & 0x3F]; - } - else - { - m_ucBuffer[ m_uiAvailBytes++] = ASCII_EQUAL; - } - - m_uiBase64Count += 4; - } - - if( m_bLineBreaks) - { - if( (m_uiBase64Count % 72) == 0 || - (m_bInputExhausted && !m_bPriorLineEnd)) - { -#ifdef FLM_UNIX - m_ucBuffer[ m_uiAvailBytes++] = ASCII_NEWLINE; -#elif FLM_OSX - m_ucBuffer[ m_uiAvailBytes++] = ASCII_CR; -#else - m_ucBuffer[ m_uiAvailBytes++] = ASCII_CR; - m_ucBuffer[ m_uiAvailBytes++] = ASCII_NEWLINE; -#endif - m_bPriorLineEnd = TRUE; - } - else - { - m_bPriorLineEnd = FALSE; - } - } - - if( !m_uiAvailBytes) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - } - - uiBytesToCopy = f_min( m_uiAvailBytes, uiBytesToRead); - - if( pucOutBuf) - { - f_memcpy( pucOutBuf, &m_ucBuffer[ m_uiBufOffset], uiBytesToCopy); - } - - pucOutBuf += uiBytesToCopy; - uiBytesToRead -= uiBytesToCopy; - m_uiAvailBytes -= uiBytesToCopy; - m_uiBufOffset += uiBytesToCopy; - - if( puiBytesRead) - { - *puiBytesRead += uiBytesToCopy; - } - } - -Exit: - - return( rc); -} - -/****************************************************************************** -Desc: -******************************************************************************/ -RCODE XFLMAPI F_CompressingOStream::open( - IF_OStream * pOStream) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE ucOutBuf[ 2]; - - // Setup the hash table - - m_uiHashTblSize = ((2 * 1024 * 1024) / sizeof( LZWODictItem *)); - if( RC_BAD( rc = f_alloc( - sizeof( LZWODictItem *) * m_uiHashTblSize, &m_ppHashTbl))) - { - goto Exit; - } - - f_memset( m_ppHashTbl, 0, sizeof( LZWODictItem *) * m_uiHashTblSize); - - // Output a magic number so the stream can be identified - - UW2FBA( LZW_MAGIC_NUMBER, ucOutBuf); - if( RC_BAD( rc = pOStream->write( ucOutBuf, 2))) - { - goto Exit; - } - - // Setup misc. member variables - - m_pOStream = pOStream; - m_pOStream->AddRef(); - - m_ui16CurrentCode = LZW_END_OF_DATA; - m_ui16FreeCode = LZW_START_CODE; - m_uiLastRatio = 100; - m_uiBestRatio = 100; - m_uiCurrentBytesIn = 0; - m_uiTotalBytesIn = 0; - m_uiCurrentBytesOut = 0; - m_uiTotalBytesOut = 0; - m_bStopCompression = FALSE; - -Exit: - - if( RC_BAD( rc)) - { - close(); - } - - return( rc); -} - -/****************************************************************************** -Desc: -******************************************************************************/ -LZWODictItem * F_CompressingOStream::findDictEntry( - FLMUINT16 ui16CurrentCode, - FLMBYTE ucChar) -{ - FLMUINT uiHashBucket; - LZWODictItem * pDictItem; - FLMUINT uiLooks = 0; - - uiHashBucket = getHashBucket( ui16CurrentCode, ucChar); - pDictItem = m_ppHashTbl[ uiHashBucket]; - - while( pDictItem) - { - if( pDictItem->ui16ParentCode == ui16CurrentCode && - pDictItem->ucChar == ucChar) - { - break; - } - - pDictItem = pDictItem->pNext; - uiLooks++; - } - - return( pDictItem); -} - -/****************************************************************************** -Desc: -******************************************************************************/ -RCODE XFLMAPI F_CompressingOStream::write( - const void * pvBuffer, - FLMUINT uiBytesToWrite, - FLMUINT * puiBytesWritten) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiBucket; - FLMUINT uiBytesWritten = 0; - FLMUINT uiTmp; - LZWODictItem * pDictItem; - const FLMBYTE * pucBuffer = (const FLMBYTE *)pvBuffer; - FLMBYTE ucOut[ 2]; - - if( !uiBytesToWrite) - { - goto Exit; - } - - if( m_bStopCompression) - { - rc = m_pOStream->write( pucBuffer, uiBytesToWrite, &uiTmp); - uiBytesWritten += uiTmp; - goto Exit; - } - - if( !m_uiTotalBytesIn) - { - m_ui16CurrentCode = *pucBuffer++; - m_uiCurrentBytesIn++; - m_uiTotalBytesIn++; - uiBytesToWrite--; - } - - while( uiBytesToWrite) - { - if( (pDictItem = findDictEntry( - m_ui16CurrentCode, *pucBuffer)) == NULL) - { - // No match. Output the code. - - UW2FBA( m_ui16CurrentCode, ucOut); - if( RC_BAD( rc = m_pOStream->write( ucOut, 2))) - { - goto Exit; - } - m_uiCurrentBytesOut += 2; - m_uiTotalBytesOut += 2; - uiBytesWritten += 2; - - // Add the new code to the dictionary - - if( m_ui16FreeCode < LZW_MAX_CODE) - { - uiBucket = getHashBucket( m_ui16CurrentCode, *pucBuffer); - if( RC_BAD( rc = m_pool.poolAlloc( - sizeof( LZWODictItem), (void **)&pDictItem))) - { - goto Exit; - } - - pDictItem->pNext = m_ppHashTbl[ uiBucket]; - m_ppHashTbl[ uiBucket] = pDictItem; - - pDictItem->ucChar = *pucBuffer; - pDictItem->ui16Code = m_ui16FreeCode++; - pDictItem->ui16ParentCode = m_ui16CurrentCode; - } - - m_ui16CurrentCode = *pucBuffer; - - // May need to reset the dictionary to improve compression. - // If compression is causing the stream to grow, we - // need to disable it. - - if( m_uiTotalBytesIn > (10 * 1024 * 1024) && - m_uiTotalBytesOut > m_uiTotalBytesIn) - { - // Compression isn't buying us anything. From this - // point forward in the stream, just store the bytes - // without compression. - - UW2FBA( LZW_STOP_COMPRESSION, ucOut); - if (RC_BAD( rc = m_pOStream->write( ucOut, 2))) - { - goto Exit; - } - - uiBytesWritten += 2; - m_bStopCompression = TRUE; - m_ui16CurrentCode = LZW_END_OF_DATA; - - // Finish writing out the rest of the current buffer - - if( RC_BAD( rc = m_pOStream->write( pucBuffer, uiBytesToWrite))) - { - goto Exit; - } - - m_uiCurrentBytesIn = 0; - m_uiTotalBytesIn += uiBytesToWrite; - uiBytesWritten += uiBytesToWrite; - uiBytesToWrite = 0; - break; - } - else if( m_uiCurrentBytesIn >= 8192) - { - FLMUINT uiRatio; - - uiRatio = (m_uiCurrentBytesOut * 100) / m_uiCurrentBytesIn; - m_uiCurrentBytesIn = 0; - m_uiCurrentBytesOut = 0; - - if( uiRatio > m_uiBestRatio) - { - if( uiRatio > 50 && - (uiRatio > 90 || uiRatio > m_uiLastRatio + 10)) - { - // Output the dictionary reset token - - UW2FBA( LZW_NEW_DICT, ucOut); - if (RC_BAD( rc = m_pOStream->write( ucOut, 2))) - { - goto Exit; - } - - uiBytesWritten += 2; - - // Reset the dictionary - - m_pool.poolReset( NULL); - f_memset( m_ppHashTbl, 0, sizeof( LZWODictItem *) * m_uiHashTblSize); - m_ui16FreeCode = LZW_START_CODE; - } - else - { - m_uiBestRatio = uiRatio; - } - - m_uiLastRatio = uiRatio; - } - - // Good time to release the CPU - - f_yieldCPU(); - } - } - else - { - m_ui16CurrentCode = pDictItem->ui16Code; - } - - pucBuffer++; - m_uiCurrentBytesIn++; - m_uiTotalBytesIn++; - uiBytesToWrite--; - } - -Exit: - - if( puiBytesWritten) - { - *puiBytesWritten = uiBytesWritten; - } - - return( rc); -} - -/****************************************************************************** -Desc: -******************************************************************************/ -RCODE XFLMAPI F_CompressingOStream::close( void) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE ucOut[ 2]; - - if (m_pOStream) - { - if (RC_OK( rc) && m_ui16CurrentCode != LZW_END_OF_DATA) - { - UW2FBA( m_ui16CurrentCode, ucOut); - rc = m_pOStream->write( ucOut, 2); - m_uiCurrentBytesOut += 2; - m_uiTotalBytesOut += 2; - } - - // Write the end-of-data marker - - if (RC_OK( rc)) - { - UW2FBA( LZW_END_OF_DATA, ucOut); - rc = m_pOStream->write( ucOut, 2); - m_uiCurrentBytesOut += 2; - m_uiTotalBytesOut += 2; - } - - if (m_pOStream->getRefCount() == 1) - { - if (RC_OK( rc)) - { - rc = m_pOStream->close(); - } - else - { - m_pOStream->close(); - } - } - - m_pOStream->Release(); - m_pOStream = NULL; - } - - if( m_ppHashTbl) - { - f_free( &m_ppHashTbl); - m_uiHashTblSize = 0; - } - - m_pool.poolReset( NULL); - return( rc); -} - -/****************************************************************************** -Desc: -******************************************************************************/ -RCODE XFLMAPI F_UncompressingIStream::open( - IF_IStream * pIStream) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE ucInBuf[ 2]; - FLMUINT16 ui16Magic; - - // Allocate the dictonary table - - if( RC_BAD( rc = f_alloc( - sizeof( LZWIDictItem) * LZW_MAX_CODE, &m_pDict))) - { - goto Exit; - } - - f_memset( m_pDict, 0, sizeof( LZWIDictItem) * LZW_MAX_CODE); - - // Allocate the decode buffer - - m_uiDecodeBufferSize = 4096; - if( RC_BAD( rc = f_alloc( m_uiDecodeBufferSize, &m_pucDecodeBuffer))) - { - goto Exit; - } - - // Read the magic number from the stream to ensure that this - // is really an LZW compressed stream - - if( RC_BAD( rc = pIStream->read( ucInBuf, 2, NULL))) - { - goto Exit; - } - ui16Magic = FB2UW( ucInBuf); - - if( ui16Magic != LZW_MAGIC_NUMBER) - { - rc = RC_SET( NE_XFLM_STREAM_NOT_COMPRESSED); - goto Exit; - } - - // Add a reference to the passed-in stream object - - m_pIStream = pIStream; - m_pIStream->AddRef(); - - // Setup misc. member variables - - m_ui16FreeCode = LZW_START_CODE; - m_ui16LastCode = LZW_END_OF_DATA; - m_uiDecodeBufferOffset = 0; - m_bStopCompression = FALSE; - m_bEndOfStream = FALSE; - -Exit: - - if( RC_BAD( rc)) - { - close(); - } - - return( rc); -} - -/****************************************************************************** -Desc: -******************************************************************************/ -RCODE F_UncompressingIStream::readCode( - FLMUINT16 * pui16Code) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE ucInBuf[ 2]; - - if( m_bEndOfStream) - { - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - - if( RC_BAD( rc = m_pIStream->read( ucInBuf, 2, NULL))) - { - goto Exit; - } - *pui16Code = FB2UW( ucInBuf); - - if( *pui16Code == LZW_END_OF_DATA) - { - m_bEndOfStream = TRUE; - rc = RC_SET( NE_XFLM_EOF_HIT); - goto Exit; - } - -Exit: - - return( rc); -} - -/****************************************************************************** -Desc: -******************************************************************************/ -RCODE F_UncompressingIStream::decodeToBuffer( - FLMUINT16 ui16Code) -{ - RCODE rc = NE_XFLM_OK; - - if( ui16Code >= m_ui16FreeCode || m_ui16LastCode == LZW_END_OF_DATA) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_STREAM_DECOMPRESS_ERROR); - goto Exit; - } - - while( ui16Code > 0x00FF) - { - flmAssert( m_uiDecodeBufferOffset < m_uiDecodeBufferSize); - flmAssert( ui16Code < m_ui16FreeCode); - - m_pucDecodeBuffer[ m_uiDecodeBufferOffset++] = m_pDict[ ui16Code].ucChar; - ui16Code = m_pDict[ ui16Code].ui16ParentCode; - } - m_pucDecodeBuffer[ m_uiDecodeBufferOffset++] = (FLMBYTE)ui16Code; - -Exit: - - return( rc); -} - -/****************************************************************************** -Desc: -******************************************************************************/ -RCODE XFLMAPI F_UncompressingIStream::read( - void * pvBuffer, - FLMUINT uiBytesToRead, - FLMUINT * puiBytesRead) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE * pucBuffer = (FLMBYTE *)pvBuffer; - FLMUINT uiTmp; - FLMUINT uiBytesRead = 0; - FLMUINT uiSavePos; - FLMUINT16 ui16Code; - - while( uiBytesToRead) - { - if( m_uiDecodeBufferOffset) - { - // Consume a byte from the decode buffer - - *pucBuffer++ = m_pucDecodeBuffer[ --m_uiDecodeBufferOffset]; - uiBytesToRead--; - continue; - } - - if( m_bStopCompression) - { - if (RC_BAD( rc = m_pIStream->read( pvBuffer, uiBytesToRead, &uiTmp))) - { - if (rc != NE_XFLM_EOF_HIT) - { - goto Exit; - } - - uiBytesRead += uiTmp; - } - - break; - } - - if( RC_BAD( rc = readCode( &ui16Code))) - { - goto Exit; - } - - if( ui16Code == LZW_NEW_DICT) - { - m_ui16FreeCode = LZW_START_CODE; - m_ui16LastCode = LZW_END_OF_DATA; - continue; - } - else if( ui16Code == LZW_STOP_COMPRESSION) - { - flmAssert( !m_bStopCompression); - m_bStopCompression = TRUE; - continue; - } - else - { - if( ui16Code >= m_ui16FreeCode) - { - // The code isn't in our dictionary. There is only - // one type of sequence that can result in this - // condition. The code below builds the correct - // sequence of bytes. - - flmAssert( m_ui16LastCode != LZW_END_OF_DATA); - - uiSavePos = m_uiDecodeBufferOffset++; - if( RC_BAD( rc = decodeToBuffer( m_ui16LastCode))) - { - goto Exit; - } - - m_pucDecodeBuffer[ uiSavePos] = - m_pucDecodeBuffer[ m_uiDecodeBufferOffset - 1]; - } - else if( m_ui16LastCode == LZW_END_OF_DATA) - { - flmAssert( ui16Code <= 0x00FF); - *pucBuffer++ = (FLMBYTE)ui16Code; - uiBytesToRead--; - m_ui16LastCode = ui16Code; - continue; - } - else - { - if( RC_BAD( rc = decodeToBuffer( ui16Code))) - { - goto Exit; - } - } - - if( m_ui16FreeCode < LZW_MAX_CODE) - { - flmAssert( m_uiDecodeBufferOffset); - - m_pDict[ m_ui16FreeCode].ui16ParentCode = m_ui16LastCode; - m_pDict[ m_ui16FreeCode].ucChar = - m_pucDecodeBuffer[ m_uiDecodeBufferOffset - 1]; - m_ui16FreeCode++; - } - - m_ui16LastCode = ui16Code; - } - } - -Exit: - - if( puiBytesRead) - { - *puiBytesRead = uiBytesRead; - } - - return( rc); -} - -/****************************************************************************** -Desc: -******************************************************************************/ -RCODE XFLMAPI F_UncompressingIStream::close( void) -{ - if( m_pIStream) - { - m_pIStream->Release(); - m_pIStream = NULL; - } - - if( m_pDict) - { - f_free( &m_pDict); - } - - if( m_pucDecodeBuffer) - { - f_free( &m_pucDecodeBuffer); - } - - return( NE_XFLM_OK); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -RCODE XFLMAPI F_DbSystem::openBufferIStream( - const char * pucBuffer, - FLMUINT uiLength, - IF_PosIStream ** ppIStream) -{ - RCODE rc = NE_XFLM_OK; - F_BufferIStream * pNewIStream = NULL; - - if( (pNewIStream = f_new F_BufferIStream) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = pNewIStream->open( (FLMBYTE *)pucBuffer, uiLength))) - { - goto Exit; - } - - if( *ppIStream) - { - (*ppIStream)->Release(); - } - - pNewIStream->lockModule(); - *ppIStream = pNewIStream; - pNewIStream = NULL; - -Exit: - - if( pNewIStream) - { - pNewIStream->Release(); - } - - return( rc); -} - -/****************************************************************************** -Desc: Return an input stream that reads from multiple files. -******************************************************************************/ -RCODE XFLMAPI F_DbSystem::openMultiFileIStream( - const char * pszDirectory, - const char * pszBaseName, - IF_IStream ** ppIStream) -{ - RCODE rc = NE_XFLM_OK; - F_MultiFileIStream * pNewIStream = NULL; - - if( (pNewIStream = f_new F_MultiFileIStream) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = pNewIStream->open( pszDirectory, pszBaseName))) - { - goto Exit; - } - - pNewIStream->lockModule(); - *ppIStream = pNewIStream; - pNewIStream = NULL; - -Exit: - - if( pNewIStream) - { - pNewIStream->Release(); - } - - return( rc); -} - -/****************************************************************************** -Desc: Return a buffered input stream from pIStream. -******************************************************************************/ -RCODE XFLMAPI F_DbSystem::openBufferedIStream( - IF_IStream * pIStream, - FLMUINT uiBufferSize, - IF_IStream ** ppIStream) -{ - RCODE rc = NE_XFLM_OK; - F_BufferedIStream * pNewIStream = NULL; - - if( (pNewIStream = f_new F_BufferedIStream) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = pNewIStream->open( pIStream, uiBufferSize))) - { - goto Exit; - } - - pNewIStream->lockModule(); - *ppIStream = pNewIStream; - pNewIStream = NULL; - -Exit: - - if( pNewIStream) - { - pNewIStream->Release(); - } - - return( rc); -} - -/****************************************************************************** -Desc: -******************************************************************************/ -RCODE XFLMAPI F_DbSystem::openUncompressingIStream( - IF_IStream * pIStream, - IF_IStream ** ppIStream) -{ - RCODE rc = NE_XFLM_OK; - F_UncompressingIStream * pNewIStream = NULL; - - if( (pNewIStream = f_new F_UncompressingIStream) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = pNewIStream->open( pIStream))) - { - goto Exit; - } - - pNewIStream->lockModule(); - *ppIStream = pNewIStream; - pNewIStream = NULL; - -Exit: - - if( pNewIStream) - { - pNewIStream->Release(); - } - - return( rc); -} - -/****************************************************************************** -Desc: Return a compressing output stream. -******************************************************************************/ -RCODE XFLMAPI F_DbSystem::openCompressingOStream( - IF_OStream * pOStream, - IF_OStream ** ppOStream) -{ - RCODE rc = NE_XFLM_OK; - F_CompressingOStream * pNewOStream = NULL; - - if( (pNewOStream = f_new F_CompressingOStream) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = pNewOStream->open( pOStream))) - { - goto Exit; - } - - pNewOStream->lockModule(); - *ppOStream = pNewOStream; - pNewOStream = NULL; - -Exit: - - if( pNewOStream) - { - pNewOStream->Release(); - } - - return( rc); -} - -/****************************************************************************** -Desc: Return a file output stream. -******************************************************************************/ -RCODE XFLMAPI F_DbSystem::openFileOStream( - const char * pszFileName, - FLMBOOL bTruncateIfExists, - IF_OStream ** ppOStream) -{ - RCODE rc = NE_XFLM_OK; - F_FileOStream * pNewOStream = NULL; - - if( (pNewOStream = f_new F_FileOStream) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = pNewOStream->open( pszFileName, bTruncateIfExists))) - { - goto Exit; - } - - pNewOStream->lockModule(); - *ppOStream = pNewOStream; - pNewOStream = NULL; - -Exit: - - if( pNewOStream) - { - pNewOStream->Release(); - } - - return( rc); -} - -/****************************************************************************** -Desc: Return a multi-file output stream. -******************************************************************************/ -RCODE XFLMAPI F_DbSystem::openMultiFileOStream( - const char * pszDirectory, - const char * pszBaseName, - FLMUINT uiMaxFileSize, - FLMBOOL bOverwrite, - IF_OStream ** ppOStream) -{ - RCODE rc = NE_XFLM_OK; - F_MultiFileOStream * pNewOStream = NULL; - - if( (pNewOStream = f_new F_MultiFileOStream) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = pNewOStream->create( pszDirectory, pszBaseName, - uiMaxFileSize, bOverwrite))) - { - goto Exit; - } - - pNewOStream->lockModule(); - *ppOStream = pNewOStream; - pNewOStream = NULL; - -Exit: - - if( pNewOStream) - { - pNewOStream->Release(); - } - - return( rc); -} - -/****************************************************************************** -Desc: Return a buffered output stream. -******************************************************************************/ -RCODE XFLMAPI F_DbSystem::openBufferedOStream( - IF_OStream * pOStream, - FLMUINT uiBufferSize, - IF_OStream ** ppOStream) -{ - RCODE rc = NE_XFLM_OK; - F_BufferedOStream * pNewOStream = NULL; - - if( (pNewOStream = f_new F_BufferedOStream) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = pNewOStream->open( pOStream, uiBufferSize))) - { - goto Exit; - } - - pNewOStream->lockModule(); - *ppOStream = pNewOStream; - pNewOStream = NULL; - -Exit: - - if( pNewOStream) - { - pNewOStream->Release(); - } - - return( rc); -} - -/****************************************************************************** -Desc: Read all data from input stream and write to the output stream. -******************************************************************************/ -RCODE XFLMAPI F_DbSystem::writeToOStream( - IF_IStream * pIStream, - IF_OStream * pOStream) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE ucBuffer[ 512]; - FLMUINT uiBufferSize = sizeof( ucBuffer); - FLMUINT uiBytesToWrite; - FLMUINT uiBytesRead; - - for (;;) - { - if( RC_BAD( rc = pIStream->read( - ucBuffer, uiBufferSize, &uiBytesRead))) - { - if( rc != NE_XFLM_EOF_HIT) - { - goto Exit; - } - - rc = NE_XFLM_OK; - - if (!uiBytesRead) - { - goto Exit; - } - } - - uiBytesToWrite = uiBytesRead; - if( RC_BAD( rc = pOStream->write( ucBuffer, uiBytesToWrite))) - { - goto Exit; - } - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: -*****************************************************************************/ -RCODE XFLMAPI F_DbSystem::openFileIStream( - const char * pszPath, - IF_PosIStream ** ppIStream) -{ - RCODE rc = NE_XFLM_OK; - F_FileIStream * pNewIStream = NULL; - - if( (pNewIStream = f_new F_FileIStream) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = pNewIStream->open( pszPath))) - { - goto Exit; - } - - if( *ppIStream) - { - (*ppIStream)->Release(); - } - - pNewIStream->lockModule(); - *ppIStream = pNewIStream; - pNewIStream = NULL; - -Exit: - - if( pNewIStream) - { - pNewIStream->Release(); - } - - return( rc); -} - -/***************************************************************************** -Desc: -******************************************************************************/ -RCODE XFLMAPI F_DbSystem::openBase64Encoder( - IF_IStream * pInputStream, - FLMBOOL bInsertLineBreaks, - IF_IStream ** ppEncodedStream) -{ - RCODE rc = NE_XFLM_OK; - F_Base64EncoderIStream * pNewIStream = NULL; - - if( (pNewIStream = f_new F_Base64EncoderIStream) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = pNewIStream->open( pInputStream, bInsertLineBreaks))) - { - goto Exit; - } - - if( *ppEncodedStream) - { - (*ppEncodedStream)->Release(); - } - - pNewIStream->lockModule(); - *ppEncodedStream = pNewIStream; - pNewIStream = NULL; - -Exit: - - if( pNewIStream) - { - pNewIStream->Release(); - } - - return( rc); -} - -/***************************************************************************** -Desc: -******************************************************************************/ -RCODE XFLMAPI F_DbSystem::openBase64Decoder( - IF_IStream * pInputStream, - IF_IStream ** ppDecodedStream) -{ - RCODE rc = NE_XFLM_OK; - F_Base64DecoderIStream * pNewIStream = NULL; - - if( (pNewIStream = f_new F_Base64DecoderIStream) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = pNewIStream->open( pInputStream))) - { - goto Exit; - } - - if( *ppDecodedStream) - { - (*ppDecodedStream)->Release(); - } - - pNewIStream->lockModule(); - *ppDecodedStream = pNewIStream; - pNewIStream = NULL; - -Exit: - - if( pNewIStream) - { - pNewIStream->Release(); - } - - return( rc); -} - -/******************************************************************** -Desc: -*********************************************************************/ -F_TCPStream::F_TCPStream( void) -{ - m_pszIp[ 0] = 0; - m_pszName[ 0] = 0; - m_pszPeerIp[ 0] = 0; - m_pszPeerName[ 0] = 0; - m_uiIOTimeout = 10; - m_iSocket = INVALID_SOCKET; - m_ulRemoteAddr = 0; - m_bInitialized = FALSE; - m_bConnected = FALSE; - -#ifndef FLM_UNIX - if( !WSAStartup( MAKEWORD( 2, 0), &m_wsaData)) - { - m_bInitialized = TRUE; - } -#endif -} - -/******************************************************************** -Desc: -*********************************************************************/ -F_TCPStream::~F_TCPStream( void) -{ - if( m_bConnected) - { - close(); - } - -#ifndef FLM_UNIX - if( m_bInitialized) - { - WSACleanup(); - } -#endif -} - -/******************************************************************** -Desc: Opens a new connection -*********************************************************************/ -RCODE F_TCPStream::openConnection( - const char * pucHostName, - FLMUINT uiPort, - FLMUINT uiConnectTimeout, - FLMUINT uiDataTimeout) -{ - RCODE rc = NE_XFLM_OK; - FLMINT iSockErr; - FLMINT iTries; - FLMINT iMaxTries = 5; - struct sockaddr_in address; - struct hostent * pHostEntry; - unsigned long ulIPAddr; - int iTmp; - - flmAssert( !m_bConnected); - m_iSocket = INVALID_SOCKET; - - if( pucHostName && pucHostName[ 0] != '\0') - { - ulIPAddr = inet_addr( (char *)pucHostName); - if( ulIPAddr == (unsigned long)(-1)) - { - pHostEntry = gethostbyname( (char *)pucHostName); - - if( !pHostEntry) - { - rc = RC_SET( NE_XFLM_NOIP_ADDR); - goto Exit; - } - else - { - ulIPAddr = *((unsigned long *)pHostEntry->h_addr); - } - - } - } - else - { - ulIPAddr = inet_addr( (char *)"127.0.0.1"); - } - - // Fill in the Socket structure with family type - - f_memset( (char *)&address, 0, sizeof( struct sockaddr_in)); - address.sin_family = AF_INET; - address.sin_addr.s_addr = (unsigned)ulIPAddr; - address.sin_port = htons( (unsigned short)uiPort); - - // Allocate a socket, then attempt to connect to it! - - if( (m_iSocket = socket( AF_INET, - SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) - { - rc = RC_SET( NE_XFLM_SOCKET_FAIL); - goto Exit; - } - - // Now attempt to connect with the specified partner host, - // time-out if connection doesn't complete within alloted time - -#ifdef FLM_WIN - - if( uiConnectTimeout) - { - if ( uiConnectTimeout < 5 ) - { - iMaxTries = (iMaxTries * uiConnectTimeout) / 5; - uiConnectTimeout = 5; - } - } - else - { - iMaxTries = 1; - } -#endif - - for( iTries = 0; iTries < iMaxTries; iTries++ ) - { - iSockErr = 0; - if( connect( m_iSocket, (struct sockaddr *)&address, - (unsigned)sizeof(struct sockaddr)) >= 0) - { - break; - } - - #ifndef FLM_UNIX - iSockErr = WSAGetLastError(); - #else - iSockErr = errno; - #endif - - #ifdef FLM_WIN - - // In WIN, we sometimes get WSAEINVAL when, if we keep - // trying, we will eventually connect. Therefore, - // here we'll treat WSAEINVAL as EINPROGRESS. - - if( iSockErr == WSAEINVAL) - { - #ifndef FLM_UNIX - closesocket( m_iSocket); - #else - ::close( m_iSocket); - #endif - if( (m_iSocket = socket( AF_INET, - SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) - { - rc = RC_SET( NE_XFLM_SOCKET_FAIL); - goto Exit; - } - #if defined( FLM_WIN) || defined( FLM_NLM) - iSockErr = WSAEINPROGRESS; - #else - iSockErr = EINPROGRESS; - #endif - continue; - } - #endif - - #if defined( FLM_WIN) || defined( FLM_NLM) - if( iSockErr == WSAEISCONN ) - #else - if( iSockErr == EISCONN ) - #endif - { - break; - } - #if defined( FLM_WIN) || defined( FLM_NLM) - else if( iSockErr == WSAEWOULDBLOCK) - #else - else if( iSockErr == EWOULDBLOCK) - #endif - { - // Let's wait a split second to give the connection - // request a chance. - - f_sleep( 100 ); - continue; - } - #if defined( FLM_WIN) || defined( FLM_NLM) - else if( iSockErr == WSAEINPROGRESS) - #else - else if( iSockErr == EINPROGRESS) - #endif - { - if( RC_OK( rc = socketPeek( uiConnectTimeout, FALSE))) - { - // Let's wait a split second to give the connection - // request a chance. - - f_sleep( 100 ); - continue; - } - } - - rc = RC_SET( NE_XFLM_CONNECT_FAIL); - goto Exit; - } - - // Disable Nagel's algorithm - - iTmp = 1; - if( (setsockopt( m_iSocket, IPPROTO_TCP, TCP_NODELAY, (char *)&iTmp, - (unsigned)sizeof( iTmp) )) < 0) - { - rc = RC_SET( NE_XFLM_SOCKET_SET_OPT_FAIL); - goto Exit; - } - - m_uiIOTimeout = uiDataTimeout; - m_bConnected = TRUE; - -Exit: - - if( RC_BAD( rc)) - { - if( m_iSocket != INVALID_SOCKET) - { - #ifndef FLM_UNIX - closesocket( m_iSocket); - #else - ::close( m_iSocket); - #endif - m_iSocket = INVALID_SOCKET; - } - } - - return( rc); -} - -/******************************************************************** -Desc: Gets information about the local host machine. -*********************************************************************/ -RCODE F_TCPStream::getLocalInfo( void) -{ - RCODE rc = NE_XFLM_OK; - struct hostent * pHostEnt; - FLMUINT32 ui32IPAddr; - - m_pszIp[ 0] = 0; - m_pszName[ 0] = 0; - - if( !m_pszName[ 0]) - { - if( gethostname( m_pszName, (unsigned)sizeof( m_pszName))) - { - rc = RC_SET( NE_XFLM_SOCKET_FAIL); - goto Exit; - } - } - - if( !m_pszIp[ 0] && (pHostEnt = gethostbyname( m_pszName)) != NULL) - { - ui32IPAddr = (FLMUINT32)(*((unsigned long *)pHostEnt->h_addr)); - if( ui32IPAddr != (FLMUINT32)-1) - { - struct in_addr InAddr; - - InAddr.s_addr = ui32IPAddr; - f_strcpy( m_pszIp, inet_ntoa( InAddr)); - } - } - -Exit: - - return( rc); -} - -/******************************************************************** -Desc: Gets information about the remote machine. -*********************************************************************/ -RCODE F_TCPStream::getRemoteInfo( void) -{ - RCODE rc = NE_XFLM_OK; - struct sockaddr_in SockAddrIn; - char * InetAddr = NULL; - struct hostent * HostsName; - - m_pszPeerIp[ 0] = 0; - m_pszPeerName[ 0] = 0; - - SockAddrIn.sin_addr.s_addr = (unsigned)m_ulRemoteAddr; - - InetAddr = inet_ntoa( SockAddrIn.sin_addr); - f_strcpy( m_pszPeerIp, InetAddr); - - // Try to get the peer's host name by looking up his IP - // address. - - HostsName = gethostbyaddr( (char *)&SockAddrIn.sin_addr.s_addr, - (unsigned)sizeof( unsigned long), AF_INET ); - - if( HostsName != NULL) - { - f_strcpy( m_pszPeerName, (char*) HostsName->h_name ); - } - else - { - if (!InetAddr) - { - InetAddr = inet_ntoa( SockAddrIn.sin_addr); - } - - f_strcpy( m_pszPeerName, InetAddr); - } - - return( rc); -} - -/******************************************************************** -Desc: Tests for socket data readiness -*********************************************************************/ -RCODE F_TCPStream::socketPeek( - FLMINT iTimeoutVal, - FLMBOOL bPeekRead) -{ - RCODE rc = NE_XFLM_OK; - struct timeval TimeOut; - int iMaxDescs; - fd_set GenDescriptors; - fd_set * DescrRead; - fd_set * DescrWrt; - - if( m_iSocket != INVALID_SOCKET) - { - FD_ZERO( &GenDescriptors); -#ifdef FLM_WIN - #pragma warning( push) - #pragma warning( disable : 4127) -#endif - FD_SET( m_iSocket, &GenDescriptors); -#ifdef FLM_WIN - #pragma warning( pop) -#endif - - iMaxDescs = (int)(m_iSocket + 1); - DescrRead = bPeekRead ? &GenDescriptors : NULL; - DescrWrt = bPeekRead ? NULL : &GenDescriptors; - - TimeOut.tv_sec = (long)iTimeoutVal; - TimeOut.tv_usec = (long)0; - - if( select( iMaxDescs, DescrRead, DescrWrt, NULL, &TimeOut) < 0 ) - { - rc = RC_SET( NE_XFLM_SELECT_ERR); - goto Exit; - } - else - { - if( !FD_ISSET( m_iSocket, &GenDescriptors)) - { - rc = bPeekRead - ? RC_SET( NE_XFLM_SOCKET_READ_TIMEOUT) - : RC_SET( NE_XFLM_SOCKET_WRITE_TIMEOUT); - } - } - } - else - { - rc = RC_SET( NE_XFLM_CONNECT_FAIL); - } - -Exit: - - return( rc); -} - -/******************************************************************** -Desc: -*********************************************************************/ -RCODE XFLMAPI F_TCPStream::write( - const void * pucBuffer, - FLMUINT uiBytesToWrite, - FLMUINT * puiBytesWritten) -{ - RCODE rc = NE_XFLM_OK; - FLMINT iRetryCount = 0; - FLMINT iBytesWritten = 0; - - if( m_iSocket == INVALID_SOCKET) - { - rc = RC_SET( NE_XFLM_CONNECT_FAIL); - goto Exit; - } - - flmAssert( pucBuffer && uiBytesToWrite); - -Retry: - - *puiBytesWritten = 0; - if( RC_OK( rc = socketPeek( m_uiIOTimeout, FALSE))) - { - iBytesWritten = send( m_iSocket, - (char *)pucBuffer, (int)uiBytesToWrite, 0); - - switch ( iBytesWritten) - { - case -1: - { - *puiBytesWritten = 0; - rc = RC_SET( NE_XFLM_SOCKET_WRITE_FAIL); - break; - } - - case 0: - { - rc = RC_SET( NE_XFLM_SOCKET_DISCONNECT); - break; - } - - default: - { - *puiBytesWritten = (FLMUINT)iBytesWritten; - break; - } - } - } - - if( RC_BAD( rc) && rc != NE_XFLM_SOCKET_WRITE_TIMEOUT) - { -#ifndef FLM_UNIX - FLMINT iSockErr = WSAGetLastError(); -#else - FLMINT iSockErr = errno; -#endif - -#if defined( FLM_WIN) || defined( FLM_NLM) - if( iSockErr == WSAECONNABORTED) -#else - if( iSockErr == ECONNABORTED) -#endif - { - rc = RC_SET( NE_XFLM_SOCKET_DISCONNECT); - } -#if defined( FLM_WIN) || defined( FLM_NLM) - else if( iSockErr == WSAEWOULDBLOCK && iRetryCount < 5) -#else - else if( iSockErr == EWOULDBLOCK && iRetryCount < 5) -#endif - { - iRetryCount++; - f_sleep( (FLMUINT)(100 * iRetryCount)); - goto Retry; - } - } - -Exit: - - return( rc); -} - -/******************************************************************** -Desc: -*********************************************************************/ -RCODE XFLMAPI F_TCPStream::read( - void * pucBuffer, - FLMUINT uiBytesToWrite, - FLMUINT * puiBytesRead) -{ - RCODE rc = NE_XFLM_OK; - FLMINT iReadCnt = 0; - - flmAssert( m_bConnected && pucBuffer && uiBytesToWrite); - - if( RC_OK( rc = socketPeek( m_uiIOTimeout, TRUE))) - { - iReadCnt = (FLMINT)recv( m_iSocket, - (char *)pucBuffer, (int)uiBytesToWrite, 0); - - switch ( iReadCnt) - { - case -1: - { - iReadCnt = 0; -#if defined( FLM_WIN) || defined( FLM_NLM) - if ( WSAGetLastError() == WSAECONNRESET) -#else - if( errno == ECONNRESET) -#endif - { - rc = RC_SET( NE_XFLM_SOCKET_DISCONNECT); - } - else - { - rc = RC_SET( NE_XFLM_SOCKET_READ_FAIL); - } - break; - } - - case 0: - { - rc = RC_SET( NE_XFLM_SOCKET_DISCONNECT); - break; - } - - default: - { - break; - } - } - } - - if( puiBytesRead) - { - *puiBytesRead = (FLMUINT)iReadCnt; - } - - return( rc); -} - -/******************************************************************** -Desc: Reads data from the connection - Timeout valkue is zero, no error - is generated if timeout occurs. -*********************************************************************/ -RCODE F_TCPStream::readNoWait( - FLMBYTE * pucBuffer, - FLMUINT uiBytesToRead, - FLMUINT * puiBytesRead) -{ - RCODE rc = NE_XFLM_OK; - FLMINT iReadCnt = 0; - - flmAssert( m_bConnected && pucBuffer && uiBytesToRead); - - if( puiBytesRead) - { - *puiBytesRead = 0; - } - - if( RC_OK( rc = socketPeek( (FLMUINT)0, TRUE))) - { - iReadCnt = recv( m_iSocket, (char *)pucBuffer, (int)uiBytesToRead, 0); - switch ( iReadCnt) - { - case -1: - { - *puiBytesRead = 0; -#if defined( FLM_WIN) || defined( FLM_NLM) - if ( WSAGetLastError() == WSAECONNRESET) -#else - if( errno == ECONNRESET) -#endif - { - rc = RC_SET( NE_XFLM_SOCKET_DISCONNECT); - } - else - { - rc = RC_SET( NE_XFLM_SOCKET_READ_FAIL); - } - goto Exit; - } - - case 0: - { - rc = RC_SET( NE_XFLM_SOCKET_DISCONNECT); - goto Exit; - } - - default: - { - break; - } - } - } - else if (rc == NE_XFLM_SOCKET_READ_TIMEOUT) - { - rc = NE_XFLM_OK; - } - - if( puiBytesRead) - { - *puiBytesRead = (FLMUINT)iReadCnt; - } - -Exit: - - return( rc); -} - -/******************************************************************** -Desc: Reads data and does not return until all requested data has - been read or a timeout error has been encountered. -*********************************************************************/ -RCODE F_TCPStream::readAll( - FLMBYTE * pucBuffer, - FLMUINT uiBytesToRead, - FLMUINT * puiBytesRead) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiToRead = 0; - FLMUINT uiHaveRead = 0; - FLMUINT uiPartialCnt; - - flmAssert( m_bConnected && pucBuffer && uiBytesToRead); - - uiToRead = uiBytesToRead; - while( uiToRead) - { - if( RC_BAD( rc = read( pucBuffer, uiToRead, &uiPartialCnt))) - { - goto Exit; - } - - pucBuffer += uiPartialCnt; - uiHaveRead += uiPartialCnt; - uiToRead = (FLMUINT)(uiBytesToRead - uiHaveRead); - - if( puiBytesRead) - { - *puiBytesRead = uiHaveRead; - } - } - -Exit: - - return( rc); -} - -/******************************************************************** -Desc: Closes any open connections -*********************************************************************/ -RCODE XFLMAPI F_TCPStream::close( void) -{ - if( m_iSocket == INVALID_SOCKET) - { - goto Exit; - } - -#ifndef FLM_UNIX - closesocket( m_iSocket); -#else - ::close( m_iSocket); -#endif - -Exit: - - m_iSocket = INVALID_SOCKET; - m_bConnected = FALSE; - - return( NE_XFLM_OK); -} diff --git a/xflaim/src/fstructs.h b/xflaim/src/fstructs.h index afe6be7..6495582 100644 --- a/xflaim/src/fstructs.h +++ b/xflaim/src/fstructs.h @@ -36,17 +36,13 @@ class HRequest; class F_BtPool; class F_XMLImport; class F_XMLExport; -class F_FileIdList; class F_Rfl; class F_SuperFileHdl; class F_Btree; class F_DbRebuild; class F_DbCheck; -class F_XML; class ServerLockManager; class ServerLockObject; -class F_FileHdlMgr; -class F_ThreadMgr; class F_Cursor; class F_MultiAlloc; class F_CachedNode; @@ -62,92 +58,6 @@ class F_NodeListRelocator; class F_AttrItemRelocator; class F_AttrBufferRelocator; -#if defined( FLM_NLM) - - extern "C" - { - void ConvertTicksToSeconds( - LONG ticks, - LONG * seconds, - LONG * tenthsOfSeconds); - - void ConvertSecondsToTicks( - LONG seconds, - LONG tenthsOfSeconds, - LONG * ticks); - } - - #define FLM_GET_TIMER() (FLMUINT)GetCurrentTime() - - #define FLM_SECS_TO_TIMER_UNITS( uiSeconds, uiTU) \ - ConvertSecondsToTicks( (LONG)(uiSeconds), 0, (LONG *)(&(uiTU))) - - #define FLM_TIMER_UNITS_TO_SECS( uiTU, uiSeconds) \ - { \ - LONG udDummy; \ - ConvertTicksToSeconds( (LONG)(uiTU), (LONG *)(&(uiSeconds)), &udDummy); \ - } - - #define FLM_TIMER_UNITS_TO_MILLI( uiTU, uiMilli) \ - { \ - LONG udTenths; \ - LONG udSeconds; \ - ConvertTicksToSeconds( (LONG)(uiTU), (LONG *)(&(udSeconds)), &udTenths); \ - uiMilli = (FLMUINT)(udSeconds) * 1000 + (FLMUINT)udTenths * 100; \ - } - #define FLM_MILLI_TO_TIMER_UNITS( uiMilliSeconds, uiTU) \ - { \ - LONG udTenths, udSeconds; \ - udSeconds = ((LONG) uiMilliSeconds) / 1000; \ - udTenths = (((LONG) uiMilliSeconds) % 1000) / 100; \ - ConvertSecondsToTicks( udSeconds, udTenths, (LONG *)(&(uiTU))); \ - } - -#elif defined( FLM_UNIX) - - // gettimeofday() is actually 4 times faster than time() on - // Solaris. gethrtime() is even faster. On Linux time() is the - // fastest; gettimeofday() is 50% slower. clock() is the - // slowest on both Solaris and Linux. We use a new function for - // millisec resolution. The implementation is OS dependent. - - #define FLM_GET_TIMER() (FLMUINT) f_timeGetMilliTime() - #define FLM_SECS_TO_TIMER_UNITS( uiSeconds, uiTU) \ - ((uiTU) = ((uiSeconds) * 1000)) - #define FLM_TIMER_UNITS_TO_SECS( uiTU, uiSeconds) \ - ((uiSeconds) = ((uiTU) / 1000)) - #define FLM_TIMER_UNITS_TO_MILLI( uiTU, uiMilli) \ - ((uiMilli) = (uiTU)) - #define FLM_MILLI_TO_TIMER_UNITS( uiMilli, uiTU) \ - ((uiTU) = (uiMilli)) -#else /* FLM_WIN */ - - #define FLM_GET_TIMER() \ - (FLMUINT)GetTickCount() - - #define FLM_SECS_TO_TIMER_UNITS( uiSeconds, uiTU) \ - ((uiTU) = (uiSeconds) * 1000) - - #define FLM_TIMER_UNITS_TO_SECS( uiTU, uiSeconds) \ - ((uiSeconds) = (uiTU) / 1000) - - #define FLM_TIMER_UNITS_TO_MILLI( uiTU, uiMilli) \ - (uiMilli = (uiTU)) - - #define FLM_MILLI_TO_TIMER_UNITS( uiMilliSeconds, uiTU) \ - (uiTU = (uiMilliSeconds)) - -#endif - -// This macro for calculating elapsed time accounts for the -// possibility of the time wrapping - which it will for some -// of our counters (FLM_WIN is milliseconds and wraps in 49.7 days). - -#define FLM_ELAPSED_TIME(uiLaterTime,uiEarlierTime) \ - (FLMUINT)(((uiLaterTime) >= (uiEarlierTime)) \ - ? (FLMUINT)((uiLaterTime) - (uiEarlierTime)) \ - : (FLMUINT)((0xFFFFFFFF - (uiEarlierTime)) + (uiLaterTime))) - /**************************************************************************** Desc: Tests to see if database is NOT in native platform format. ****************************************************************************/ @@ -522,7 +432,7 @@ typedef struct /**************************************************************************** Desc: Node list ****************************************************************************/ -class F_NodeList : public XF_RefCount, public XF_Base +class F_NodeList : public F_Object { public: @@ -721,7 +631,7 @@ Desc: This is a temporary structure that is used when building compound ****************************************************************************/ typedef struct IxContextTag { - F_Pool * pPool; + IF_Pool * pPool; CDL_HDR * pCdlTbl; CDL * pCdlList; IxContextTag * pNext; @@ -798,7 +708,7 @@ typedef struct Tmp_Read_Stats /***************************************************************************** Desc: Shared database object - only to be used internally *****************************************************************************/ -class F_Database : public XF_RefCount, public XF_Base +class F_Database : public F_Object { public: @@ -857,7 +767,7 @@ public: RCODE startCPThread( void); FLMBOOL tryCheckpoint( - F_Thread * pThread, + IF_Thread * pThread, CP_INFO * pCPInfo); void newDatabaseFinish( @@ -1118,7 +1028,7 @@ private: RCODE writeContiguousBlocks( XFLM_DB_STATS * pDbStats, F_SuperFileHdl * pSFileHdl, - F_IOBuffer * pIOBuffer, + IF_IOBuffer * pIOBuffer, FLMUINT uiBlkAddress, FLMBOOL bDoAsync); @@ -1216,7 +1126,7 @@ private: FLMBOOL bHaveData); static RCODE maintenanceThread( - F_Thread * pThread); + IF_Thread * pThread); F_Database * m_pNext; // Next F_Database structure in in name hash // bucket, dependent store hash @@ -1297,7 +1207,7 @@ private: // because of a critical error. RCODE m_rcMustClose; // Return code that caused bMustClose to // be set. - F_Pool m_krefPool; // Kref pool to be used during update + IF_Pool * m_pKrefPool; // Kref pool to be used during update // transactions. FLMUINT m_uiSigBitsInBlkSize;// Significant bits in the database's // block size. @@ -1311,12 +1221,9 @@ private: XFLM_DB_HDR m_uncommittedDbHdr; // This is the uncommitted DB header. // It is used by the current update // transaction. - F_FileIdList * m_pFileIdList; // List of unique IDs that have been - // assigned to the physical files that - // are mananaged by the FFILE. - F_IOBufferMgr * m_pBufferMgr; + IF_IOBufferMgr * m_pBufferMgr; - F_IOBuffer * m_pCurrLogBuffer; + IF_IOBuffer * m_pCurrLogBuffer; FLMUINT m_uiCurrLogWriteOffset; // Offset in current write buffer FLMUINT m_uiCurrLogBlkAddr; // Address of first block in the current @@ -1374,7 +1281,7 @@ private: FLMUINT m_uiLastCheckpointTime; // Last time we successfully completed a // checkpoint. - F_Thread * m_pCPThrd; // Checkpoint thread. + IF_Thread * m_pCPThrd; // Checkpoint thread. CP_INFO * m_pCPInfo; // Pointer to checkpoint thread's // information buffer - used for // communicating information to the @@ -1388,7 +1295,7 @@ private: FLMBOOL m_bBackupActive; // Backup is currently being run against the // database. F_NodeList m_DocumentList; // List of documents modified in a transaction - F_Thread * m_pMaintThrd; // Background maintenance thread + IF_Thread * m_pMaintThrd; // Background maintenance thread F_SEM m_hMaintSem; // Maintenance thread "work-to-do" semaphore FLMBYTE * m_pszDbPasswd; // The database encryption password F_CCS * m_pWrappingKey; // The database wrapping key @@ -1481,7 +1388,7 @@ typedef enum /*=========================================================================== Desc: FLAIM object base class ===========================================================================*/ -class F_HashObject : public XF_RefCount, public XF_Base +class F_HashObject : public F_Object { public: @@ -1557,7 +1464,7 @@ friend class F_HashTable; /*=========================================================================== Desc: FLAIM hash table ===========================================================================*/ -class F_HashTable : public XF_RefCount, public XF_Base +class F_HashTable : public F_Object { public: @@ -1567,8 +1474,7 @@ public: RCODE setupHashTable( FLMBOOL bMultithreaded, - FLMUINT uiNumBuckets, - FLMUINT32 * pCRCTable); + FLMUINT uiNumBuckets); RCODE addObject( F_HashObject * pObject); @@ -1616,8 +1522,6 @@ private: F_HashObject * m_pGlobalList; F_HashObject ** m_ppHashTable; FLMUINT m_uiBuckets; - FLMUINT32 * m_pCRCTable; - FLMBOOL m_bOwnCRCTable; }; typedef struct node_loc @@ -1648,8 +1552,6 @@ typedef struct FlmSystemData F_MUTEX hBlockCacheMutex; // Mutex for controlling access to // block cache. - F_FileHdlMgr * pFileHdlMgr; // Used to Manage all FileHdl objects - FLMBOOL bTempDirSet; // TRUE if temporary directory has been set FLMBOOL bOkToDoAsyncWrites; @@ -1669,8 +1571,8 @@ typedef struct FlmSystemData // to reallocate a cache manager's hash // table before trying again. F_NodePool * pNodePool; // Pool of nodes that can be re-used - F_Thread * pMonitorThrd; // Monitor thread - F_Thread * pCacheCleanupThrd; + IF_Thread * pMonitorThrd; // Monitor thread + IF_Thread * pCacheCleanupThrd; XFLM_STATS Stats; // Statistics structure F_MUTEX hStatsMutex; // Mutex for statistics structure @@ -1699,7 +1601,7 @@ typedef struct FlmSystemData // unused structures in memory before // freeing them. FEVENT_HDR EventHdrs [XFLM_MAX_EVENT_CATEGORIES]; - F_Pool * pKRefPool; // Memory Pool that is only used by + IF_Pool * pKRefPool; // Memory Pool that is only used by // record updaters for key building FLMUINT uiMaxFileSize; @@ -1707,12 +1609,6 @@ typedef struct FlmSystemData FLMUINT uiPendingLogMessages; F_MUTEX hLoggerMutex; -#ifdef FLM_LINUX - FLMUINT uiLinuxMajorVer; - FLMUINT uiLinuxMinorVer; - FLMUINT uiLinuxRevision; -#endif - #ifdef FLM_DEBUG // Variables for memory allocation tracking. @@ -1727,71 +1623,26 @@ typedef struct FlmSystemData FLMUINT uiMemNumPtrs; FLMUINT uiMemNextPtrSlotToUse; FLMUINT uiAllocCnt; - #if defined( FLM_WIN) - HANDLE hMemProcess; - #endif - - #ifdef DEBUG_SIM_OUT_OF_MEM - FLMUINT uiOutOfMemSimEnabledFlag; - // We pick a random number for the flag so that it is hard to accidentally - // turn this flag on by writing memory out-of-bounds. - - #define OUT_OF_MEM_SIM_ENABLED_FLAG 2149614134UL - - F_RandomGenerator memSimRandomGen; - FLMUINT uiSimOutOfMemFailTotal; - FLMUINT uiSimOutOfMemFailSequence; - #endif #endif - F_MUTEX hIniMutex; - F_ThreadMgr * pThreadMgr; - F_MUTEX hHttpSessionMutex; - F_BtPool * pBtPool; - F_XML * pXml; -#ifdef FLM_NLM - FLMBOOL bUseNSSFileHdls; -#endif + F_MUTEX hIniMutex; + F_MUTEX hHttpSessionMutex; + F_BtPool * pBtPool; + IF_XML * pXml; + IF_FileSystem * pFileSystem; + IF_ThreadMgr * pThreadMgr; + FLMUINT uiIndexingThreadGroup; + FLMUINT uiDbThreadGroup; + FLMUINT uiCheckpointThreadGroup; + } FLMSYSDATA; #ifndef ALLOCATE_SYS_DATA - extern FLMSYSDATA gv_XFlmSysData; + extern FLMSYSDATA gv_XFlmSysData; #else - FLMSYSDATA gv_XFlmSysData; + FLMSYSDATA gv_XFlmSysData; #endif -FINLINE FLMBOOL f_isWhiteSpace( - FLMBYTE ucChar) -{ - return( ucChar == ASCII_SPACE || ucChar == ASCII_TAB ? TRUE : FALSE); -} - -FINLINE FLMUNICODE flmConvertChar( - FLMUNICODE uzChar, - FLMUINT uiCompareRules) -{ - if (uzChar == ASCII_SPACE || - (uzChar == ASCII_UNDERSCORE && - (uiCompareRules & XFLM_COMP_NO_UNDERSCORES)) || - (gv_XFlmSysData.pXml->isWhitespace( uzChar) && - (uiCompareRules & XFLM_COMP_WHITESPACE_AS_SPACE))) - { - return( (FLMUNICODE)((uiCompareRules & - (XFLM_COMP_NO_WHITESPACE | - XFLM_COMP_IGNORE_LEADING_SPACE)) - ? (FLMUNICODE)0 - : (FLMUNICODE)ASCII_SPACE)); - } - else if (uzChar == ASCII_DASH && (uiCompareRules & XFLM_COMP_NO_DASHES)) - { - return( (FLMUNICODE)0); - } - else - { - return( uzChar); - } -} - #if defined( FLM_WIN) || defined( FLM_NLM) || defined( FLM_LINUX) #pragma pack(pop) #else diff --git a/xflaim/src/fsuperfl.cpp b/xflaim/src/fsuperfl.cpp index 0f65c9a..40058eb 100644 --- a/xflaim/src/fsuperfl.cpp +++ b/xflaim/src/fsuperfl.cpp @@ -29,113 +29,11 @@ FSTATIC char base24ToDigit( FLMUINT uiBaseValue); -/**************************************************************************** -Desc: -****************************************************************************/ -F_FileIdList::F_FileIdList() -{ - m_hMutex = F_MUTEX_NULL; - m_uiFileIdTblSize = 0; - m_puiFileIdTbl = NULL; -} - -/**************************************************************************** -Desc: -****************************************************************************/ -F_FileIdList::~F_FileIdList() -{ - if( m_hMutex != F_MUTEX_NULL) - { - f_mutexDestroy( &m_hMutex); - } - - if( m_puiFileIdTbl) - { - for( FLMUINT uiLoop = 0; uiLoop < m_uiFileIdTblSize; uiLoop++) - { - if( m_puiFileIdTbl[ uiLoop]) - { - (void)gv_XFlmSysData.pFileHdlMgr->removeFileHdls( - m_puiFileIdTbl[ uiLoop]); - } - } - - f_free( &m_puiFileIdTbl); - } -} - -/**************************************************************************** -Desc: Allocates the mutex used by the file ID list object -****************************************************************************/ -RCODE F_FileIdList::setup( void) -{ - RCODE rc = NE_XFLM_OK; - - flmAssert( m_hMutex == F_MUTEX_NULL); - - if( RC_BAD( rc = f_mutexCreate( &m_hMutex))) - { - goto Exit; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Translates a database file number into a file ID. -****************************************************************************/ -RCODE F_FileIdList::getFileId( - FLMUINT uiFileNumber, - FLMUINT * puiFileId) -{ - RCODE rc = NE_XFLM_OK; - FLMBOOL bMutexLocked = TRUE; - FLMUINT uiLoop = 0; - - f_mutexLock( m_hMutex); - bMutexLocked = TRUE; - - if( uiFileNumber >= m_uiFileIdTblSize) - { - FLMUINT uiOldTableSize = m_uiFileIdTblSize; - - /* - Re-size the table - */ - - if( RC_BAD( rc = f_recalloc( (uiFileNumber + 1) * sizeof( FLMUINT), - &m_puiFileIdTbl))) - { - goto Exit; - } - m_uiFileIdTblSize = uiFileNumber + 1; - - for( uiLoop = uiOldTableSize; uiLoop < m_uiFileIdTblSize; uiLoop++) - { - m_puiFileIdTbl[ uiLoop] = gv_XFlmSysData.pFileHdlMgr->getUniqueId(); - } - } - - *puiFileId = m_puiFileIdTbl[ uiFileNumber]; - -Exit: - - if( bMutexLocked) - { - f_mutexUnlock( m_hMutex); - } - - return( rc); -} - /**************************************************************************** Desc: ****************************************************************************/ F_SuperFileHdl::F_SuperFileHdl( void) { - m_pFileIdList = NULL; m_pszDbFileName = NULL; m_pszDataFileNameBase = NULL; f_memset( &m_CheckedOutFileHdls[ 0], 0, sizeof( m_CheckedOutFileHdls)); @@ -157,22 +55,9 @@ Desc: ****************************************************************************/ F_SuperFileHdl::~F_SuperFileHdl() { - /* - Release any file handles still being held and close the files. - */ - if( m_bSetupCalled) { - (void)ReleaseFiles( TRUE); - } - - /* - Release the ID list - */ - - if( m_pFileIdList) - { - m_pFileIdList->Release(); + (void)releaseFiles( TRUE); } if (m_pszDbFileName) @@ -184,8 +69,7 @@ F_SuperFileHdl::~F_SuperFileHdl() /**************************************************************************** Desc: Configures the super file object ****************************************************************************/ -RCODE F_SuperFileHdl::Setup( - F_FileIdList * pFileIdList, +RCODE F_SuperFileHdl::setup( const char * pszDbFileName, const char * pszDataDir) { @@ -199,44 +83,20 @@ RCODE F_SuperFileHdl::Setup( if( !pszDbFileName && *pszDbFileName == 0) { - rc = RC_SET( NE_XFLM_IO_INVALID_FILENAME); + rc = RC_SET( NE_FLM_IO_INVALID_FILENAME); goto Exit; } - if( !pFileIdList) - { - if( (m_pFileIdList = f_new F_FileIdList) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = m_pFileIdList->setup())) - { - FLMUINT uiRefCnt; - - uiRefCnt = m_pFileIdList->Release(); - flmAssert( !uiRefCnt); - m_pFileIdList = NULL; - goto Exit; - } - } - else - { - pFileIdList->AddRef(); - m_pFileIdList = pFileIdList; - } - uiNameLen = f_strlen( pszDbFileName); if (pszDataDir && *pszDataDir) { - if (RC_BAD( rc = gv_pFileSystem->pathReduce( + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathReduce( pszDbFileName, szDir, szBaseName))) { goto Exit; } f_strcpy( szDir, pszDataDir); - if (RC_BAD( rc = gv_pFileSystem->pathAppend( + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathAppend( szDir, szBaseName))) { goto Exit; @@ -278,74 +138,48 @@ Exit: /**************************************************************************** Desc: Creates a file ****************************************************************************/ -RCODE F_SuperFileHdl::CreateFile( +RCODE F_SuperFileHdl::createFile( FLMUINT uiFileNumber) { - char szFilePath[ F_PATH_MAX_SIZE]; - F_FileHdl * pFileHdl = NULL; - FLMUINT uiFileId; RCODE rc = NE_XFLM_OK; + char szFilePath[ F_PATH_MAX_SIZE]; + IF_FileHdl * pFileHdl = NULL; +// FLMUINT uiFileId; - /* - Sanity checks - */ + // Sanity checks flmAssert( m_bSetupCalled && m_uiBlockSize); flmAssert( uiFileNumber <= MAX_LOG_BLOCK_FILE_NUMBER); - /* - See if we already have an open file handle (or if we can open the file). - If so, truncate the file and use it. - */ + // See if we already have an open file handle (or if we can open the file). + // If so, truncate the file and use it. - if( RC_OK( rc = GetFileHdl( uiFileNumber, TRUE, (IF_FileHdl **)&pFileHdl))) + if( RC_OK( rc = getFileHdl( uiFileNumber, TRUE, &pFileHdl))) { - rc = pFileHdl->Truncate( 0); - pFileHdl = NULL; // Don't want to release the file handle at exit + rc = pFileHdl->truncate( 0); + pFileHdl = NULL; goto Exit; } - else if( rc != NE_XFLM_IO_PATH_NOT_FOUND) + else if( rc != NE_FLM_IO_PATH_NOT_FOUND) { goto Exit; } - // The file was not found above. Allocate a new file handle. - - if ((pFileHdl = f_new F_FileHdl) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - pFileHdl->SetBlockSize( m_uiBlockSize); - - // Configure the file handle. - - if( RC_BAD( rc = m_pFileIdList->getFileId( uiFileNumber, &uiFileId))) - { - goto Exit; - } - - flmAssert( uiFileId); // File ID should always be non-zero - - pFileHdl->setupFileHdl( uiFileId, FALSE); - // Build the file path - if( RC_BAD( rc = GetFilePath( uiFileNumber, szFilePath))) + if( RC_BAD( rc = getFilePath( uiFileNumber, szFilePath))) { goto Exit; } - if( RC_BAD( rc = pFileHdl->Create( szFilePath, - XFLM_IO_RDWR | XFLM_IO_EXCL | XFLM_IO_DIRECT | XFLM_IO_SH_DENYNONE))) + if( RC_BAD( rc = gv_XFlmSysData.pFileSystem->createFile( szFilePath, + FLM_IO_RDWR | FLM_IO_EXCL | FLM_IO_DIRECT | FLM_IO_SH_DENYNONE, + &pFileHdl))) { goto Exit; } - - // Insert into the file handle manager - - gv_XFlmSysData.pFileHdlMgr->insertInUsedList( FALSE, pFileHdl, TRUE); + + pFileHdl->setBlockSize( m_uiBlockSize); Exit: @@ -360,7 +194,7 @@ Exit: /**************************************************************************** Desc: Reads a database block into a buffer ****************************************************************************/ -RCODE F_SuperFileHdl::ReadBlock( +RCODE F_SuperFileHdl::readBlock( FLMUINT uiBlkAddress, FLMUINT uiBytesToRead, void * pvBuffer, @@ -371,19 +205,19 @@ RCODE F_SuperFileHdl::ReadBlock( flmAssert( m_bSetupCalled && m_uiBlockSize); - if( RC_BAD( rc = GetFileHdl( + if( RC_BAD( rc = getFileHdl( FSGetFileNumber( uiBlkAddress), FALSE, &pFileHdl))) { goto Exit; } - if( RC_BAD( rc = pFileHdl->SectorRead( + if( RC_BAD( rc = pFileHdl->sectorRead( FSGetFileOffset( uiBlkAddress), uiBytesToRead, pvBuffer, puiBytesRead))) { - if (rc != NE_XFLM_IO_END_OF_FILE && rc != NE_XFLM_MEM) + if (rc != NE_FLM_IO_END_OF_FILE && rc != NE_XFLM_MEM) { - ReleaseFile( FSGetFileNumber( uiBlkAddress), TRUE); + releaseFile( FSGetFileNumber( uiBlkAddress), TRUE); } goto Exit; } @@ -396,12 +230,12 @@ Exit: /**************************************************************************** Desc: Writes a block to the database ****************************************************************************/ -RCODE F_SuperFileHdl::WriteBlock( +RCODE F_SuperFileHdl::writeBlock( FLMUINT uiBlkAddress, FLMUINT uiBytesToWrite, const void * pvBuffer, FLMUINT uiBufferSize, - F_IOBuffer * pIOBuffer, + IF_IOBuffer * pIOBuffer, FLMUINT * puiBytesWritten) { IF_FileHdl * pFileHdl = NULL; @@ -410,12 +244,12 @@ RCODE F_SuperFileHdl::WriteBlock( flmAssert( m_bSetupCalled && m_uiBlockSize); Get_Handle: - if( RC_BAD( rc = GetFileHdl( + if( RC_BAD( rc = getFileHdl( FSGetFileNumber( uiBlkAddress), TRUE, &pFileHdl))) { - if (rc == NE_XFLM_IO_PATH_NOT_FOUND) + if (rc == NE_FLM_IO_PATH_NOT_FOUND) { - if (RC_BAD( rc = CreateFile( FSGetFileNumber( uiBlkAddress)))) + if (RC_BAD( rc = createFile( FSGetFileNumber( uiBlkAddress)))) { goto Exit; } @@ -429,13 +263,13 @@ Get_Handle: pFileHdl->setExtendSize( m_uiExtendSize); pFileHdl->setMaxAutoExtendSize( m_uiMaxAutoExtendSize); - if( RC_BAD( rc = pFileHdl->SectorWrite( + if( RC_BAD( rc = pFileHdl->sectorWrite( FSGetFileOffset( uiBlkAddress), uiBytesToWrite, pvBuffer, uiBufferSize, pIOBuffer, puiBytesWritten))) { - if (rc != NE_XFLM_IO_DISK_FULL && rc != NE_XFLM_MEM) + if (rc != NE_FLM_IO_DISK_FULL && rc != NE_XFLM_MEM) { - ReleaseFile( FSGetFileNumber( uiBlkAddress), TRUE); + releaseFile( FSGetFileNumber( uiBlkAddress), TRUE); } goto Exit; } @@ -448,7 +282,7 @@ Exit: /**************************************************************************** Desc: Reads data from the database header ****************************************************************************/ -RCODE F_SuperFileHdl::ReadHeader( +RCODE F_SuperFileHdl::readHeader( FLMUINT uiOffset, FLMUINT uiBytesToRead, void * pvBuffer, @@ -460,27 +294,25 @@ RCODE F_SuperFileHdl::ReadHeader( #ifdef FLM_DEBUG if( m_uiBlockSize) { - /* - Note: Block size may not be set because we are in the process of - opening the file for the first time and we don't know the block - size until after the header has been read. - */ + // Note: Block size may not be set because we are in the process of + // opening the file for the first time and we don't know the block + // size until after the header has been read. flmAssert( (FLMUINT)(uiOffset + uiBytesToRead) <= m_uiBlockSize); } #endif - if( RC_BAD( rc = GetFileHdl( 0, TRUE, &pFileHdl))) + if( RC_BAD( rc = getFileHdl( 0, TRUE, &pFileHdl))) { goto Exit; } - if( RC_BAD( rc = pFileHdl->Read( uiOffset, + if( RC_BAD( rc = pFileHdl->read( uiOffset, uiBytesToRead, pvBuffer, puiBytesRead))) { - if (rc != NE_XFLM_IO_END_OF_FILE && rc != NE_XFLM_MEM) + if (rc != NE_FLM_IO_END_OF_FILE && rc != NE_XFLM_MEM) { - ReleaseFile( (FLMUINT)0, TRUE); + releaseFile( (FLMUINT)0, TRUE); } goto Exit; } @@ -493,7 +325,7 @@ Exit: /**************************************************************************** Desc: Writes data to the database header ****************************************************************************/ -RCODE F_SuperFileHdl::WriteHeader( +RCODE F_SuperFileHdl::writeHeader( FLMUINT uiOffset, FLMUINT uiBytesToWrite, const void * pvBuffer, @@ -509,17 +341,17 @@ RCODE F_SuperFileHdl::WriteHeader( } #endif - if( RC_BAD( rc = GetFileHdl( 0, TRUE, &pFileHdl))) + if( RC_BAD( rc = getFileHdl( 0, TRUE, &pFileHdl))) { goto Exit; } - if( RC_BAD( rc = pFileHdl->Write( uiOffset, + if( RC_BAD( rc = pFileHdl->write( uiOffset, uiBytesToWrite, pvBuffer, puiBytesWritten))) { - if (rc != NE_XFLM_IO_DISK_FULL && rc != NE_XFLM_MEM) + if (rc != NE_FLM_IO_DISK_FULL && rc != NE_XFLM_MEM) { - ReleaseFile( (FLMUINT)0, TRUE); + releaseFile( (FLMUINT)0, TRUE); } goto Exit; } @@ -532,7 +364,7 @@ Exit: /**************************************************************************** Desc: Releases all file handle objects and optionally closes the files ****************************************************************************/ -RCODE F_SuperFileHdl::ReleaseFile( +RCODE F_SuperFileHdl::releaseFile( FLMUINT uiFileNum, FLMBOOL bCloseFile) { @@ -543,7 +375,7 @@ RCODE F_SuperFileHdl::ReleaseFile( pCkoFileHdl = getCkoFileHdlPtr( uiFileNum, &uiSlot); if( pCkoFileHdl->uiFileNumber == uiFileNum) { - if( RC_BAD( rc = ReleaseFile( pCkoFileHdl, bCloseFile))) + if( RC_BAD( rc = releaseFile( pCkoFileHdl, bCloseFile))) { goto Exit; } @@ -557,7 +389,7 @@ Exit: /**************************************************************************** Desc: Releases all file handle objects and optionally closes the files ****************************************************************************/ -RCODE F_SuperFileHdl::ReleaseFiles( +RCODE F_SuperFileHdl::releaseFiles( FLMBOOL bCloseFiles) { RCODE rc = NE_XFLM_OK; @@ -567,7 +399,7 @@ RCODE F_SuperFileHdl::ReleaseFiles( for( uiLoop = 0; uiLoop <= m_uiHighestUsedSlot; uiLoop++) { - if( RC_BAD( rc = ReleaseFile( + if( RC_BAD( rc = releaseFile( &m_CheckedOutFileHdls[ uiLoop], bCloseFiles))) { goto Exit; @@ -582,44 +414,28 @@ Exit: /**************************************************************************** Desc: Releases a file handle object ****************************************************************************/ -RCODE F_SuperFileHdl::ReleaseFile( +RCODE F_SuperFileHdl::releaseFile( CHECKED_OUT_FILE_HDL * pCkoFileHdl, FLMBOOL bCloseFile) { RCODE rc = NE_XFLM_OK; - F_FileHdl * pFileHdl = (F_FileHdl *)pCkoFileHdl->pFileHdl; + IF_FileHdl * pFileHdl = pCkoFileHdl->pFileHdl; if( pFileHdl) { - flmAssert( pFileHdl->getFileId()); +// flmAssert( pFileHdl->getFileId()); if( pCkoFileHdl->bDirty) { - (void)pFileHdl->Flush(); + (void)pFileHdl->flush(); } if( bCloseFile) { FLMUINT uiRefCnt; - /* - We must remove this handle from all lists and release - the file handle. - */ - - gv_XFlmSysData.pFileHdlMgr->removeFileHdls( pFileHdl->getFileId()); uiRefCnt = pFileHdl->Release(); - flmAssert( uiRefCnt == 0); // pFileHdl should have been freed. - } - else - { - - // Link out of the used list and move to the available list. - - gv_XFlmSysData.pFileHdlMgr->makeAvailAndRelease( FALSE, pFileHdl); - - // NOTE: makeAvailAndRelease will perform a release on the - // file handle object for the caller. + flmAssert( uiRefCnt == 0); } clearCkoFileHdl( pCkoFileHdl); @@ -669,7 +485,7 @@ void F_SuperFileHdl::copyCkoFileHdls( { if (m_pCheckedOutFileHdls [uiNewSlot].uiFileNumber) { - ReleaseFile( &m_pCheckedOutFileHdls [uiNewSlot], FALSE); + releaseFile( &m_pCheckedOutFileHdls [uiNewSlot], FALSE); } f_memcpy( &m_pCheckedOutFileHdls [uiNewSlot], pSrcCkoArray, sizeof( CHECKED_OUT_FILE_HDL)); @@ -701,7 +517,7 @@ void F_SuperFileHdl::copyCkoFileHdls( } else { - ReleaseFile( pSrcCkoArray, FALSE); + releaseFile( pSrcCkoArray, FALSE); } } } @@ -733,7 +549,7 @@ void F_SuperFileHdl::disableFlushMinimize( void) /**************************************************************************** Desc: Flush dirty files to disk. ****************************************************************************/ -RCODE F_SuperFileHdl::Flush( void) +RCODE F_SuperFileHdl::flush( void) { RCODE rc = NE_XFLM_OK; FLMUINT uiLoop; @@ -749,10 +565,10 @@ RCODE F_SuperFileHdl::Flush( void) RCODE tmpRc; if (RC_BAD( tmpRc = - m_pCheckedOutFileHdls[ uiLoop].pFileHdl->Flush())) + m_pCheckedOutFileHdls[ uiLoop].pFileHdl->flush())) { rc = tmpRc; - ReleaseFile( &m_pCheckedOutFileHdls [uiLoop], TRUE); + releaseFile( &m_pCheckedOutFileHdls [uiLoop], TRUE); } m_pCheckedOutFileHdls[ uiLoop].bDirty = FALSE; } @@ -767,7 +583,7 @@ Desc: Truncates back to an end of file block address. This may only be called from reduce() because there cannot be any other cases to reduce a 3x block file. ****************************************************************************/ -RCODE F_SuperFileHdl::TruncateFile( +RCODE F_SuperFileHdl::truncateFile( FLMUINT uiEOFBlkAddress) { RCODE rc = NE_XFLM_OK; @@ -775,39 +591,35 @@ RCODE F_SuperFileHdl::TruncateFile( FLMUINT uiBlockOffset = (FLMUINT)FSGetFileOffset( uiEOFBlkAddress); IF_FileHdl * pFileHdl; - /* - Truncate the current block file. - */ + // Truncate the current block file. - if( RC_BAD( rc = GetFileHdl( uiFileNumber, TRUE, &pFileHdl))) + if( RC_BAD( rc = getFileHdl( uiFileNumber, TRUE, &pFileHdl))) { goto Exit; } - if( RC_BAD( rc = pFileHdl->Truncate( uiBlockOffset))) + if( RC_BAD( rc = pFileHdl->truncate( uiBlockOffset))) { - ReleaseFile( uiFileNumber, TRUE); + releaseFile( uiFileNumber, TRUE); goto Exit; } - /* - Visit the rest of the high block files until a NULL file hdl is hit. - */ + // Visit the rest of the high block files until a NULL file hdl is hit. for( ;;) { - if( RC_BAD( GetFileHdl( ++uiFileNumber, TRUE, &pFileHdl))) + if( RC_BAD( getFileHdl( ++uiFileNumber, TRUE, &pFileHdl))) { break; } - if( RC_BAD( rc = pFileHdl->Truncate( (FLMUINT)0 ))) + if( RC_BAD( rc = pFileHdl->truncate( (FLMUINT)0 ))) { - ReleaseFile( uiFileNumber, TRUE); + releaseFile( uiFileNumber, TRUE); goto Exit; } - if( RC_BAD( rc = ReleaseFile( uiFileNumber, TRUE))) + if( RC_BAD( rc = releaseFile( uiFileNumber, TRUE))) { goto Exit; } @@ -822,7 +634,7 @@ Exit: Desc: Truncate to zero length any files between the specified start and end files. ****************************************************************************/ -void F_SuperFileHdl::TruncateFiles( +void F_SuperFileHdl::truncateFiles( FLMUINT uiStartFileNum, FLMUINT uiEndFileNum) { @@ -833,10 +645,10 @@ void F_SuperFileHdl::TruncateFiles( uiFileNumber <= uiEndFileNum; uiFileNumber++ ) { - if( RC_OK( GetFileHdl( uiFileNumber, TRUE, &pFileHdl ))) + if( RC_OK( getFileHdl( uiFileNumber, TRUE, &pFileHdl ))) { - (void)pFileHdl->Truncate( (FLMUINT)0 ); - (void)ReleaseFile( uiFileNumber, TRUE); + (void)pFileHdl->truncate( (FLMUINT)0 ); + (void)releaseFile( uiFileNumber, TRUE); } } } @@ -844,7 +656,7 @@ void F_SuperFileHdl::TruncateFiles( /**************************************************************************** Desc: Returns the physical size of a file ****************************************************************************/ -RCODE F_SuperFileHdl::GetFileSize( +RCODE F_SuperFileHdl::getFileSize( FLMUINT uiFileNumber, FLMUINT64 * pui64FileSize) { @@ -858,14 +670,14 @@ RCODE F_SuperFileHdl::GetFileSize( // Get the file handle. - if( RC_BAD( rc = GetFileHdl( uiFileNumber, FALSE, &pFileHdl))) + if( RC_BAD( rc = getFileHdl( uiFileNumber, FALSE, &pFileHdl))) { goto Exit; } - if( RC_BAD( rc = pFileHdl->Size( pui64FileSize))) + if( RC_BAD( rc = pFileHdl->size( pui64FileSize))) { - ReleaseFile( uiFileNumber, TRUE); + releaseFile( uiFileNumber, TRUE); goto Exit; } @@ -877,7 +689,7 @@ Exit: /**************************************************************************** Desc: Returns the path of a file given its file number ****************************************************************************/ -RCODE F_SuperFileHdl::GetFilePath( +RCODE F_SuperFileHdl::getFilePath( FLMUINT uiFileNumber, char * pszIoPath) { @@ -975,21 +787,16 @@ Exit: /**************************************************************************** Desc: Returns a file handle given the file's number ****************************************************************************/ -RCODE F_SuperFileHdl::GetFileHdl( +RCODE F_SuperFileHdl::getFileHdl( FLMUINT uiFileNum, FLMBOOL bGetForUpdate, IF_FileHdl ** ppFileHdl) { - F_FileHdl * pFileHdl = NULL; - FLMUINT uiFileId; + RCODE rc = NE_XFLM_OK; + IF_FileHdl * pFileHdl = NULL; CHECKED_OUT_FILE_HDL * pCkoFileHdl; char szFilePath[ F_PATH_MAX_SIZE]; FLMUINT uiSlot; - RCODE rc = NE_XFLM_OK; - - /* - Get the file handle - */ pCkoFileHdl = getCkoFileHdlPtr( uiFileNum, &uiSlot); if( pCkoFileHdl->uiFileNumber != uiFileNum && @@ -1012,7 +819,7 @@ RCODE F_SuperFileHdl::GetFileHdl( } else { - if( RC_BAD( rc = ReleaseFile( pCkoFileHdl, FALSE))) + if( RC_BAD( rc = releaseFile( pCkoFileHdl, FALSE))) { goto Exit; } @@ -1021,67 +828,28 @@ RCODE F_SuperFileHdl::GetFileHdl( if( !pCkoFileHdl->pFileHdl) { - /* - Get the file ID - */ - - if( RC_BAD( rc = m_pFileIdList->getFileId( uiFileNum, &uiFileId))) - { - goto Exit; - } - - /* - Look for an available file handle if not opening exclusive. - NOTE: AddRef() performed for caller by findAvail if a file - handle is found. - */ - - gv_XFlmSysData.pFileHdlMgr->findAvail( uiFileId, FALSE, &pFileHdl); - if (!pFileHdl) { - /* - Allocate a new file handle, open the file and - link into the used directory. - */ - - if ((pFileHdl = f_new F_FileHdl) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - /* - If m_uiBlockSize is 0, direct I/O will not be used - */ - - pFileHdl->SetBlockSize( m_uiBlockSize); - - flmAssert( uiFileId); // File ID must be non-zero - - pFileHdl->setupFileHdl( uiFileId, FALSE); - // Build the file path - if( RC_BAD( rc = GetFilePath( uiFileNum, szFilePath))) + if( RC_BAD( rc = getFilePath( uiFileNum, szFilePath))) { goto Exit; } // Open the file - if( RC_BAD( rc = pFileHdl->Open( szFilePath, - XFLM_IO_RDWR | XFLM_IO_SH_DENYNONE | XFLM_IO_DIRECT))) + if( RC_BAD( rc = gv_XFlmSysData.pFileSystem->openFile( szFilePath, + FLM_IO_RDWR | FLM_IO_SH_DENYNONE | FLM_IO_DIRECT, + &pFileHdl))) { goto Exit; } - // Insert into the manager - - gv_XFlmSysData.pFileHdlMgr->insertInUsedList( FALSE, pFileHdl, TRUE); + pFileHdl->setBlockSize( m_uiBlockSize); } - pCkoFileHdl->pFileHdl = (IF_FileHdl *)pFileHdl; + pCkoFileHdl->pFileHdl = pFileHdl; pFileHdl = NULL; pCkoFileHdl->uiFileNumber = uiFileNum; pCkoFileHdl->bDirty = FALSE; diff --git a/xflaim/src/fsuperfl.h b/xflaim/src/fsuperfl.h index 2d8cae3..afac08a 100644 --- a/xflaim/src/fsuperfl.h +++ b/xflaim/src/fsuperfl.h @@ -29,173 +29,93 @@ #include "fsrvlock.h" -/* -Constants -*/ - #define MAX_CHECKED_OUT_FILE_HDLS 8 -/* -Forward references -*/ +void bldSuperFileExtension( + FLMUINT uiFileNum, + char * pszFileExtension); -class F_SuperFileHdl; -typedef F_SuperFileHdl * F_SuperFileHdl_p; - -class F_FileIdList; -typedef F_FileIdList * F_FileIdList_p; - -/* -Typedefs -*/ - -typedef struct CheckedOutFileHdlTag +typedef struct { IF_FileHdl * pFileHdl; FLMUINT uiFileNumber; FLMBOOL bDirty; } CHECKED_OUT_FILE_HDL; -// Misc. prototypes - -void bldSuperFileExtension( - FLMUINT uiFileNum, - char * pszFileExtension); - -/*=========================================================================== -Desc: This class keeps a list of file IDs for file numbers in a database. - It does not know the use of the file IDs, and it is not limited in - the number of file IDs it can keep track of, but it will generally - be as follows: - - FileNumber - 0 This is the database file (xxx.db) - 1-4095 These are the data files (xxx_data.nnn) - 4096-8192 These are the rollback files (xxx_rb.nnn). In this - case, the caller will map the file number in and - out of this range. -===========================================================================*/ -class F_FileIdList : public XF_RefCount, public XF_Base -{ -public: - F_FileIdList(); - - ~F_FileIdList(); - - RCODE setup( void); - - RCODE getFileId( - FLMUINT uiFileNumber, - FLMUINT * puiFileId); - - FINLINE FLMINT XFLMAPI AddRef( void) - { - return( flmAtomicInc( &m_refCnt)); - } - - FINLINE FLMINT XFLMAPI Release( void) - { - FLMINT iRefCnt = flmAtomicDec( &m_refCnt); - - if( !iRefCnt) - { - delete this; - } - - return( iRefCnt); - } - -private: - - F_MUTEX m_hMutex; - FLMUINT m_uiFileIdTblSize; - FLMUINT * m_puiFileIdTbl; -}; - -/*=========================================================================== +/**************************************************************************** Desc: The F_SuperFileHdl object manages the control and block files associated with a FLAIM Super File. This class also provides backward compatibility with prior file formats. Note: -===========================================================================*/ -class F_SuperFileHdl : public XF_RefCount, public XF_Base +****************************************************************************/ +class F_SuperFileHdl : public F_Object { public: - F_SuperFileHdl(); // F_SuperFileHdl Constructor + F_SuperFileHdl(); - ~F_SuperFileHdl(); // F_SuperFileHdl Destructor + ~F_SuperFileHdl(); - RCODE Setup( // Configures the object. Should - // be called exactly once. - F_FileIdList * pFileIdList, + RCODE setup( const char * pszDbFileName, const char * pszDataDir); - RCODE CreateFile( // Create a block file (>= 3.0 only) - FLMUINT uiFileNumber); // File number to create + RCODE createFile( + FLMUINT uiFileNumber); - RCODE ReadBlock( // Reads a block from a block file or - // the log - FLMUINT uiBlkAddress, // Block address - FLMUINT uiBytesToRead, // Number of bytes to read from block - void * pvBuffer, // Buffer to place read bytes into - FLMUINT * puiBytesRead); // [out] number of bytes read + RCODE readBlock( + FLMUINT uiBlkAddress, + FLMUINT uiBytesToRead, + void * pvBuffer, + FLMUINT * puiBytesRead); - RCODE WriteBlock( // Writes a block to a block file or - // the log - FLMUINT uiBlkAddress, // Block address - FLMUINT uiBytesToWrite, // Number of bytes to write - const void * pvBuffer, // Buffer to write bytes from - FLMUINT uiBufferSize, // Actual size of buffer - F_IOBuffer * pIOBuffer, // If non-NULL, contains info for - // doing an async write. - FLMUINT * puiBytesWritten); // [out] number of bytes written + RCODE writeBlock( + FLMUINT uiBlkAddress, + FLMUINT uiBytesToWrite, + const void * pvBuffer, + FLMUINT uiBufferSize, + IF_IOBuffer * pIOBuffer, + FLMUINT * puiBytesWritten); - RCODE ReadHeader( // Reads data from the DB header - FLMUINT uiOffset, - FLMUINT uiBytesToRead, - void * pvBuffer, - FLMUINT * puiBytesRead); + RCODE readHeader( + FLMUINT uiOffset, + FLMUINT uiBytesToRead, + void * pvBuffer, + FLMUINT * puiBytesRead); - RCODE WriteHeader( // Writes data to the DB header - FLMUINT uiOffset, - FLMUINT uiBytesToWrite, - const void * pvBuffer, - FLMUINT * puiBytesWritten); + RCODE writeHeader( + FLMUINT uiOffset, + FLMUINT uiBytesToWrite, + const void * pvBuffer, + FLMUINT * puiBytesWritten); - RCODE GetFilePath( // Generates a block file's path - FLMUINT uiFileNumber, // File number - char * pszPath); // Returned path + RCODE getFilePath( + FLMUINT uiFileNumber, + char * pszPath); - RCODE GetFileHdl( // Returns a file's handle given - // the file's number - FLMUINT uiFileNumber, - FLMBOOL bGetForUpdate, - IF_FileHdl ** ppFileHdlRV); + RCODE getFileHdl( + FLMUINT uiFileNumber, + FLMBOOL bGetForUpdate, + IF_FileHdl ** ppFileHdlRV); - RCODE GetFileSize( // Returns the physical size of - // a file - FLMUINT uiFileNumber, // File number - FLMUINT64 * pui64FileSize); // File size return value + RCODE getFileSize( + FLMUINT uiFileNumber, + FLMUINT64 * pui64FileSize); - RCODE ReleaseFile( // Release a single file - FLMUINT uiFileNum, - FLMBOOL bCloseFile); + RCODE releaseFile( + FLMUINT uiFileNum, + FLMBOOL bCloseFile); - RCODE ReleaseFiles( // Releases all file handles and - // returns them to the file handle - // manager. This is called at - // the end of a transaction. - FLMBOOL bCloseFiles); // Should files be closed? + RCODE releaseFiles( + FLMBOOL bCloseFiles); - RCODE TruncateFile( // Truncate the file(s) to given address. - FLMUINT uiEOFBlkAddress); // End of file block address. + RCODE truncateFile( + FLMUINT uiEOFBlkAddress); - void TruncateFiles( // Truncate the files specified by the - FLMUINT uiStartFileNum, // start and end file numbers. - FLMUINT uiEndFileNum); + void truncateFiles( + FLMUINT uiStartFileNum, + FLMUINT uiEndFileNum); - RCODE ReleaseFile( // Release a single file + RCODE releaseFile( CHECKED_OUT_FILE_HDL * pChkFileHdl, FLMBOOL bCloseFile); @@ -206,9 +126,9 @@ public: void disableFlushMinimize( void); - RCODE Flush( void); + RCODE flush( void); - FINLINE void SetBlockSize( + FINLINE void setBlockSize( FLMUINT uiBlockSize) { m_uiBlockSize = uiBlockSize; @@ -226,19 +146,19 @@ public: m_uiMaxAutoExtendSize = uiMaxAutoExtendSize; } - FINLINE FLMBOOL CanDoAsync( void) + FINLINE FLMBOOL canDoAsync( void) { if (m_pCheckedOutFileHdls[ 0].pFileHdl) { - return( m_pCheckedOutFileHdls[ 0].pFileHdl->CanDoAsync()); + return( m_pCheckedOutFileHdls[ 0].pFileHdl->canDoAsync()); } else { IF_FileHdl * pFileHdl; - if( RC_OK( GetFileHdl( 0, FALSE, &pFileHdl))) + if( RC_OK( getFileHdl( 0, FALSE, &pFileHdl))) { - return( pFileHdl->CanDoAsync()); + return( pFileHdl->canDoAsync()); } } @@ -277,7 +197,6 @@ private: char * m_pszDataFileNameBase; FLMUINT m_uiExtOffset; FLMUINT m_uiDataExtOffset; - F_FileIdList * m_pFileIdList; CHECKED_OUT_FILE_HDL m_CheckedOutFileHdls[ MAX_CHECKED_OUT_FILE_HDLS + 1]; CHECKED_OUT_FILE_HDL * m_pCheckedOutFileHdls; diff --git a/xflaim/src/fsysdata.cpp b/xflaim/src/fsysdata.cpp index b5725de..2f4e57d 100644 --- a/xflaim/src/fsysdata.cpp +++ b/xflaim/src/fsysdata.cpp @@ -27,9 +27,7 @@ #define ALLOCATE_SYS_DATA #define ALLOC_ERROR_TABLES -#include #include "flaimsys.h" -#include "inifile.h" #define HIGH_FLMUINT (~((FLMUINT)0)) #define FLM_MIN_FREE_BYTES (2 * 1024 * 1024) @@ -53,20 +51,14 @@ FLMATOMIC F_DbSystem::m_flmSysSpinLock = 0; FLMUINT F_DbSystem::m_uiFlmSysStartupCount = 0; -static FLMBYTE ucSENPrefixArray[] = - {0, 0, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF}; - -// Local Function Prototypes - -#ifdef FLM_CAN_GET_PHYS_MEM -FSTATIC FLMUINT flmGetCacheBytes( - FLMUINT uiPercent, - FLMUINT uiMin, - FLMUINT uiMax, - FLMUINT uiMinToLeave, - FLMBOOL bCalcOnAvailMem, - FLMUINT uiBytesCurrentlyInUse); -#endif +FSTATIC RCODE flmGetCacheBytes( + FLMUINT uiPercent, + FLMUINT uiMin, + FLMUINT uiMax, + FLMUINT uiMinToLeave, + FLMBOOL bCalcOnAvailMem, + FLMUINT uiBytesCurrentlyInUse, + FLMUINT * puiCacheBytes); FSTATIC RCODE flmVerifyDiskStructOffsets( void); @@ -78,7 +70,7 @@ FSTATIC void flmFreeEvent( FSTATIC void flmGetStringParam( const char * pszParamName, char ** ppszValue, - F_IniFile * pIniFile); + IF_IniFile * pIniFile); FSTATIC void flmGetNumParam( char ** ppszParam, @@ -88,402 +80,19 @@ FSTATIC void flmGetUintParam( const char * pszParamName, FLMUINT uiDefaultValue, FLMUINT * puiUint, - F_IniFile * pIniFile); + IF_IniFile * pIniFile); void flmGetBoolParam( const char * pszParamName, FLMBOOL uiDefaultValue, FLMBOOL * pbBool, - F_IniFile * pIniFile); + IF_IniFile * pIniFile); FSTATIC RCODE flmGetIniFileName( FLMBYTE * pszIniFileName, FLMUINT uiBufferSz); -/**************************************************************************** -Desc: Error code to string mapping tables -****************************************************************************/ -typedef struct -{ - RCODE rc; - const char * pszErrorStr; -} F_ERROR_CODE_MAP; - -#define flmErrorCodeEntry(c) { c, #c } - -#ifdef FLM_NLM - FLMBOOL gv_bNetWareStartupCalled = FALSE; -#endif - -F_ERROR_CODE_MAP gv_FlmCommonErrors[ - NE_XFLM_LAST_COMMON_ERROR - NE_XFLM_FIRST_COMMON_ERROR - 1] = -{ - flmErrorCodeEntry( NE_XFLM_NOT_IMPLEMENTED), - flmErrorCodeEntry( NE_XFLM_MEM), - { XFLM_ERROR_BASE( 0x0003), "NotUsed"}, - { XFLM_ERROR_BASE( 0x0004), "NotUsed"}, - flmErrorCodeEntry( NE_XFLM_INVALID_PARM), - { XFLM_ERROR_BASE( 0x0006), "NotUsed"}, - { XFLM_ERROR_BASE( 0x0007), "NotUsed"}, - { XFLM_ERROR_BASE( 0x0008), "NotUsed"}, - flmErrorCodeEntry( NE_XFLM_TIMEOUT), - flmErrorCodeEntry( NE_XFLM_NOT_FOUND), - { XFLM_ERROR_BASE( 0x000B), "NotUsed"}, - flmErrorCodeEntry( NE_XFLM_EXISTS), - { XFLM_ERROR_BASE( 0x000D), "NotUsed"}, - { XFLM_ERROR_BASE( 0x000E), "NotUsed"}, - { XFLM_ERROR_BASE( 0x000F), "NotUsed"}, - flmErrorCodeEntry( NE_XFLM_USER_ABORT), - flmErrorCodeEntry( NE_XFLM_FAILURE) -}; - -F_ERROR_CODE_MAP gv_FlmGeneralErrors[ - NE_XFLM_LAST_GENERAL_ERROR - NE_XFLM_FIRST_GENERAL_ERROR - 1] = -{ - flmErrorCodeEntry( NE_XFLM_BOF_HIT), - flmErrorCodeEntry( NE_XFLM_EOF_HIT), - flmErrorCodeEntry( NE_XFLM_END), - flmErrorCodeEntry( NE_XFLM_BAD_PREFIX), - flmErrorCodeEntry( NE_XFLM_ATTRIBUTE_PURGED), - flmErrorCodeEntry( NE_XFLM_BAD_COLLECTION), - flmErrorCodeEntry( NE_XFLM_DATABASE_LOCK_REQ_TIMEOUT), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_DATA_COMPONENT), - flmErrorCodeEntry( NE_XFLM_BAD_DATA_TYPE), - flmErrorCodeEntry( NE_XFLM_MUST_INDEX_ON_PRESENCE), - flmErrorCodeEntry( NE_XFLM_BAD_IX), - flmErrorCodeEntry( NE_XFLM_BACKUP_ACTIVE), - flmErrorCodeEntry( NE_XFLM_SERIAL_NUM_MISMATCH), - flmErrorCodeEntry( NE_XFLM_BAD_RFL_DB_SERIAL_NUM), - flmErrorCodeEntry( NE_XFLM_BTREE_ERROR), - flmErrorCodeEntry( NE_XFLM_BTREE_FULL), - flmErrorCodeEntry( NE_XFLM_BAD_RFL_FILE_NUMBER), - flmErrorCodeEntry( NE_XFLM_CANNOT_DEL_ELEMENT), - flmErrorCodeEntry( NE_XFLM_CANNOT_MOD_DATA_TYPE), - flmErrorCodeEntry( NE_XFLM_CANNOT_INDEX_DATA_TYPE), - flmErrorCodeEntry( NE_XFLM_CONV_BAD_DIGIT), - flmErrorCodeEntry( NE_XFLM_CONV_DEST_OVERFLOW), - flmErrorCodeEntry( NE_XFLM_CONV_ILLEGAL), - flmErrorCodeEntry( NE_XFLM_CONV_NULL_SRC), - flmErrorCodeEntry( NE_XFLM_CONV_NUM_OVERFLOW), - flmErrorCodeEntry( NE_XFLM_CONV_NUM_UNDERFLOW), - flmErrorCodeEntry( NE_XFLM_BAD_ELEMENT_NUM), - flmErrorCodeEntry( NE_XFLM_BAD_ATTRIBUTE_NUM), - flmErrorCodeEntry( NE_XFLM_BAD_ENCDEF_NUM), - flmErrorCodeEntry( NE_XFLM_DATA_ERROR), - flmErrorCodeEntry( NE_XFLM_INVALID_FILE_SEQUENCE), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_OP), - flmErrorCodeEntry( NE_XFLM_DUPLICATE_ELEMENT_NUM), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_TRANS_TYPE), - flmErrorCodeEntry( NE_XFLM_UNSUPPORTED_VERSION), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_TRANS_OP), - flmErrorCodeEntry( NE_XFLM_INCOMPLETE_LOG), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_INDEX_DEF), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_INDEX_ON), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_STATE_CHANGE), - flmErrorCodeEntry( NE_XFLM_BAD_RFL_SERIAL_NUM), - flmErrorCodeEntry( NE_XFLM_NEWER_FLAIM), - flmErrorCodeEntry( NE_XFLM_CANNOT_MOD_ELEMENT_STATE), - flmErrorCodeEntry( NE_XFLM_CANNOT_MOD_ATTRIBUTE_STATE), - flmErrorCodeEntry( NE_XFLM_NO_MORE_ELEMENT_NUMS), - flmErrorCodeEntry( NE_XFLM_NO_TRANS_ACTIVE), - flmErrorCodeEntry( NE_XFLM_NOT_UNIQUE), - flmErrorCodeEntry( NE_XFLM_NOT_FLAIM), - flmErrorCodeEntry( NE_XFLM_OLD_VIEW), - flmErrorCodeEntry( NE_XFLM_SHARED_LOCK), - flmErrorCodeEntry( NE_XFLM_SYNTAX), - flmErrorCodeEntry( NE_XFLM_TRANS_ACTIVE), - flmErrorCodeEntry( NE_XFLM_RFL_TRANS_GAP), - flmErrorCodeEntry( NE_XFLM_BAD_COLLATED_KEY), - flmErrorCodeEntry( NE_XFLM_UNSUPPORTED_FEATURE), - flmErrorCodeEntry( NE_XFLM_MUST_DELETE_INDEXES), - flmErrorCodeEntry( NE_XFLM_RFL_INCOMPLETE), - flmErrorCodeEntry( NE_XFLM_CANNOT_RESTORE_RFL_FILES), - flmErrorCodeEntry( NE_XFLM_INCONSISTENT_BACKUP), - flmErrorCodeEntry( NE_XFLM_BLOCK_CRC), - flmErrorCodeEntry( NE_XFLM_ABORT_TRANS), - flmErrorCodeEntry( NE_XFLM_NOT_RFL), - flmErrorCodeEntry( NE_XFLM_BAD_RFL_PACKET), - flmErrorCodeEntry( NE_XFLM_DATA_PATH_MISMATCH), - flmErrorCodeEntry( NE_XFLM_STREAM_EXISTS), - flmErrorCodeEntry( NE_XFLM_FILE_EXISTS), - flmErrorCodeEntry( NE_XFLM_COULD_NOT_CREATE_SEMAPHORE), - flmErrorCodeEntry( NE_XFLM_MUST_CLOSE_DATABASE), - flmErrorCodeEntry( NE_XFLM_INVALID_ENCKEY_CRC), - flmErrorCodeEntry( NE_XFLM_BAD_UTF8), - flmErrorCodeEntry( NE_XFLM_COULD_NOT_CREATE_MUTEX), - flmErrorCodeEntry( NE_XFLM_ERROR_WAITING_ON_SEMPAHORE), - flmErrorCodeEntry( NE_XFLM_BAD_PLATFORM_FORMAT), - flmErrorCodeEntry( NE_XFLM_HDR_CRC), - flmErrorCodeEntry( NE_XFLM_NO_NAME_TABLE), - flmErrorCodeEntry( NE_XFLM_MULTIPLE_MATCHES), - flmErrorCodeEntry( NE_XFLM_UNALLOWED_UPGRADE), - flmErrorCodeEntry( NE_XFLM_BTREE_BAD_STATE), - flmErrorCodeEntry( NE_XFLM_DUPLICATE_ATTRIBUTE_NUM), - flmErrorCodeEntry( NE_XFLM_DUPLICATE_INDEX_NUM), - flmErrorCodeEntry( NE_XFLM_DUPLICATE_COLLECTION_NUM), - flmErrorCodeEntry( NE_XFLM_DUPLICATE_ELEMENT_NAME), - flmErrorCodeEntry( NE_XFLM_DUPLICATE_ATTRIBUTE_NAME), - flmErrorCodeEntry( NE_XFLM_DUPLICATE_INDEX_NAME), - flmErrorCodeEntry( NE_XFLM_DUPLICATE_COLLECTION_NAME), - flmErrorCodeEntry( NE_XFLM_ELEMENT_PURGED), - flmErrorCodeEntry( NE_XFLM_TOO_MANY_OPEN_DATABASES), - flmErrorCodeEntry( NE_XFLM_DATABASE_OPEN), - flmErrorCodeEntry( NE_XFLM_CACHE_ERROR), - flmErrorCodeEntry( NE_XFLM_BTREE_KEY_SIZE), - flmErrorCodeEntry( NE_XFLM_DB_FULL), - flmErrorCodeEntry( NE_XFLM_QUERY_SYNTAX), - flmErrorCodeEntry( NE_XFLM_COULD_NOT_START_THREAD), - flmErrorCodeEntry( NE_XFLM_INDEX_OFFLINE), - flmErrorCodeEntry( NE_XFLM_RFL_DISK_FULL), - flmErrorCodeEntry( NE_XFLM_MUST_WAIT_CHECKPOINT), - flmErrorCodeEntry( NE_XFLM_MISSING_ENC_ALGORITHM), - flmErrorCodeEntry( NE_XFLM_INVALID_ENC_ALGORITHM), - flmErrorCodeEntry( NE_XFLM_INVALID_ENC_KEY_SIZE), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_DATA_TYPE), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_STATE), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_ELEMENT_NAME), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_ATTRIBUTE_NAME), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_COLLECTION_NAME), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_INDEX_NAME), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_ELEMENT_NUMBER), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_ATTRIBUTE_NUMBER), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_COLLECTION_NUMBER), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_INDEX_NUMBER), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_ENCDEF_NUMBER), - flmErrorCodeEntry( NE_XFLM_COLLECTION_NAME_MISMATCH), - flmErrorCodeEntry( NE_XFLM_ELEMENT_NAME_MISMATCH), - flmErrorCodeEntry( NE_XFLM_ATTRIBUTE_NAME_MISMATCH), - flmErrorCodeEntry( NE_XFLM_INVALID_COMPARE_RULE), - flmErrorCodeEntry( NE_XFLM_DUPLICATE_KEY_COMPONENT), - flmErrorCodeEntry( NE_XFLM_DUPLICATE_DATA_COMPONENT), - flmErrorCodeEntry( NE_XFLM_MISSING_KEY_COMPONENT), - flmErrorCodeEntry( NE_XFLM_MISSING_DATA_COMPONENT), - flmErrorCodeEntry( NE_XFLM_INVALID_INDEX_OPTION), - flmErrorCodeEntry( NE_XFLM_NO_MORE_ATTRIBUTE_NUMS), - flmErrorCodeEntry( NE_XFLM_MISSING_ELEMENT_NAME), - flmErrorCodeEntry( NE_XFLM_MISSING_ATTRIBUTE_NAME), - flmErrorCodeEntry( NE_XFLM_MISSING_ELEMENT_NUMBER), - flmErrorCodeEntry( NE_XFLM_MISSING_ATTRIBUTE_NUMBER), - flmErrorCodeEntry( NE_XFLM_MISSING_INDEX_NAME), - flmErrorCodeEntry( NE_XFLM_MISSING_INDEX_NUMBER), - flmErrorCodeEntry( NE_XFLM_MISSING_COLLECTION_NAME), - flmErrorCodeEntry( NE_XFLM_MISSING_COLLECTION_NUMBER), - flmErrorCodeEntry( NE_XFLM_BAD_SEN), - flmErrorCodeEntry( NE_XFLM_MISSING_ENCDEF_NAME), - flmErrorCodeEntry( NE_XFLM_MISSING_ENCDEF_NUMBER), - flmErrorCodeEntry( NE_XFLM_NO_MORE_INDEX_NUMS), - flmErrorCodeEntry( NE_XFLM_NO_MORE_COLLECTION_NUMS), - flmErrorCodeEntry( NE_XFLM_CANNOT_DEL_ATTRIBUTE), - flmErrorCodeEntry( NE_XFLM_TOO_MANY_PENDING_NODES), - flmErrorCodeEntry( NE_XFLM_UNSUPPORTED_INTERFACE), - flmErrorCodeEntry( NE_XFLM_BAD_USE_OF_ELM_ROOT_TAG), - flmErrorCodeEntry( NE_XFLM_DUP_SIBLING_IX_COMPONENTS), - flmErrorCodeEntry( NE_XFLM_RFL_FILE_NOT_FOUND), - flmErrorCodeEntry( NE_XFLM_BAD_RCODE_TABLE), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_KEY_COMPONENT_NUM), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_DATA_COMPONENT_NUM), - flmErrorCodeEntry( NE_XFLM_CLASS_NOT_AVAILABLE), - flmErrorCodeEntry( NE_XFLM_BUFFER_OVERFLOW), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_PREFIX_NUMBER), - flmErrorCodeEntry( NE_XFLM_MISSING_PREFIX_NAME), - flmErrorCodeEntry( NE_XFLM_MISSING_PREFIX_NUMBER), - flmErrorCodeEntry( NE_XFLM_UNDEFINED_ELEMENT_NAME), - flmErrorCodeEntry( NE_XFLM_UNDEFINED_ATTRIBUTE_NAME), - flmErrorCodeEntry( NE_XFLM_DUPLICATE_PREFIX_NAME), - flmErrorCodeEntry( NE_XFLM_KEY_OVERFLOW), - flmErrorCodeEntry( NE_XFLM_UNESCAPED_METACHAR), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_QUANTIFIER), - flmErrorCodeEntry( NE_XFLM_UNEXPECTED_END_OF_EXPR), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_MIN_COUNT), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_MAX_COUNT), - flmErrorCodeEntry( NE_XFLM_EMPTY_BRANCH_IN_EXPR), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_RPAREN_IN_EXPR), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_CLASS_SUBTRACTION), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_CHAR_RANGE_IN_EXPR), - flmErrorCodeEntry( NE_XFLM_BAD_BASE64_ENCODING), - flmErrorCodeEntry( NE_XFLM_NAMESPACE_NOT_ALLOWED), - flmErrorCodeEntry( NE_XFLM_INVALID_NAMESPACE_DECL), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_NAMESPACE_DECL_DATATYPE), - flmErrorCodeEntry( NE_XFLM_UNEXPECTED_END_OF_INPUT), - flmErrorCodeEntry( NE_XFLM_NO_MORE_PREFIX_NUMS), - flmErrorCodeEntry( NE_XFLM_NO_MORE_ENCDEF_NUMS), - flmErrorCodeEntry( NE_XFLM_COLLECTION_OFFLINE), - flmErrorCodeEntry( NE_XFLM_INVALID_XML), - flmErrorCodeEntry( NE_XFLM_READ_ONLY), - flmErrorCodeEntry( NE_XFLM_DELETE_NOT_ALLOWED), - flmErrorCodeEntry( NE_XFLM_RESET_NEEDED), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_REQUIRED_VALUE), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_INDEX_COMPONENT), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_UNIQUE_SUB_ELEMENT_VALUE), - flmErrorCodeEntry( NE_XFLM_DATA_TYPE_MUST_BE_NO_DATA), - flmErrorCodeEntry( NE_XFLM_ILLEGAL_FLAG), - flmErrorCodeEntry( NE_XFLM_CANNOT_SET_REQUIRED), - flmErrorCodeEntry( NE_XFLM_CANNOT_SET_LIMIT), - flmErrorCodeEntry( NE_XFLM_CANNOT_SET_INDEX_ON), - flmErrorCodeEntry( NE_XFLM_CANNOT_SET_COMPARE_RULES), - flmErrorCodeEntry( NE_XFLM_INPUT_PENDING), - flmErrorCodeEntry( NE_XFLM_INVALID_NODE_TYPE), - flmErrorCodeEntry( NE_XFLM_INVALID_CHILD_ELM_NODE_ID) -}; - -F_ERROR_CODE_MAP gv_FlmDomErrors[ - NE_XFLM_LAST_DOM_ERROR - NE_XFLM_FIRST_DOM_ERROR - 1] = -{ - flmErrorCodeEntry( NE_XFLM_DOM_HIERARCHY_REQUEST_ERR), - flmErrorCodeEntry( NE_XFLM_DOM_WRONG_DOCUMENT_ERR), - flmErrorCodeEntry( NE_XFLM_DOM_DATA_ERROR), - flmErrorCodeEntry( NE_XFLM_DOM_NODE_NOT_FOUND), - flmErrorCodeEntry( NE_XFLM_DOM_INVALID_CHILD_TYPE), - flmErrorCodeEntry( NE_XFLM_DOM_NODE_DELETED), - flmErrorCodeEntry( NE_XFLM_DOM_DUPLICATE_ELEMENT) -}; - -F_ERROR_CODE_MAP gv_FlmIoErrors[ - NE_XFLM_LAST_IO_ERROR - NE_XFLM_FIRST_IO_ERROR - 1] = -{ - flmErrorCodeEntry( NE_XFLM_IO_ACCESS_DENIED), - flmErrorCodeEntry( NE_XFLM_IO_BAD_FILE_HANDLE), - flmErrorCodeEntry( NE_XFLM_IO_COPY_ERR), - flmErrorCodeEntry( NE_XFLM_IO_DISK_FULL), - flmErrorCodeEntry( NE_XFLM_IO_END_OF_FILE), - flmErrorCodeEntry( NE_XFLM_IO_OPEN_ERR), - flmErrorCodeEntry( NE_XFLM_IO_SEEK_ERR), - flmErrorCodeEntry( NE_XFLM_IO_DIRECTORY_ERR), - flmErrorCodeEntry( NE_XFLM_IO_PATH_NOT_FOUND), - flmErrorCodeEntry( NE_XFLM_IO_TOO_MANY_OPEN_FILES), - flmErrorCodeEntry( NE_XFLM_IO_PATH_TOO_LONG), - flmErrorCodeEntry( NE_XFLM_IO_NO_MORE_FILES), - flmErrorCodeEntry( NE_XFLM_IO_DELETING_FILE), - flmErrorCodeEntry( NE_XFLM_IO_FILE_LOCK_ERR), - flmErrorCodeEntry( NE_XFLM_IO_FILE_UNLOCK_ERR), - flmErrorCodeEntry( NE_XFLM_IO_PATH_CREATE_FAILURE), - flmErrorCodeEntry( NE_XFLM_IO_RENAME_FAILURE), - flmErrorCodeEntry( NE_XFLM_IO_INVALID_PASSWORD), - flmErrorCodeEntry( NE_XFLM_SETTING_UP_FOR_READ), - flmErrorCodeEntry( NE_XFLM_SETTING_UP_FOR_WRITE), - flmErrorCodeEntry( NE_XFLM_IO_CANNOT_REDUCE_PATH), - flmErrorCodeEntry( NE_XFLM_INITIALIZING_IO_SYSTEM), - flmErrorCodeEntry( NE_XFLM_FLUSHING_FILE), - flmErrorCodeEntry( NE_XFLM_IO_INVALID_FILENAME), - flmErrorCodeEntry( NE_XFLM_IO_CONNECT_ERROR), - flmErrorCodeEntry( NE_XFLM_OPENING_FILE), - flmErrorCodeEntry( NE_XFLM_DIRECT_OPENING_FILE), - flmErrorCodeEntry( NE_XFLM_CREATING_FILE), - flmErrorCodeEntry( NE_XFLM_DIRECT_CREATING_FILE), - flmErrorCodeEntry( NE_XFLM_READING_FILE), - flmErrorCodeEntry( NE_XFLM_DIRECT_READING_FILE), - flmErrorCodeEntry( NE_XFLM_WRITING_FILE), - flmErrorCodeEntry( NE_XFLM_DIRECT_WRITING_FILE), - flmErrorCodeEntry( NE_XFLM_POSITIONING_IN_FILE), - flmErrorCodeEntry( NE_XFLM_GETTING_FILE_SIZE), - flmErrorCodeEntry( NE_XFLM_TRUNCATING_FILE), - flmErrorCodeEntry( NE_XFLM_PARSING_FILE_NAME), - flmErrorCodeEntry( NE_XFLM_CLOSING_FILE), - flmErrorCodeEntry( NE_XFLM_GETTING_FILE_INFO), - flmErrorCodeEntry( NE_XFLM_EXPANDING_FILE), - flmErrorCodeEntry( NE_XFLM_CHECKING_FILE_EXISTENCE), - flmErrorCodeEntry( NE_XFLM_RENAMING_FILE), - flmErrorCodeEntry( NE_XFLM_SETTING_FILE_INFO) -}; - -F_ERROR_CODE_MAP gv_FlmNetErrors[ - NE_XFLM_LAST_NET_ERROR - NE_XFLM_FIRST_NET_ERROR - 1] = -{ - flmErrorCodeEntry( NE_XFLM_NOIP_ADDR), - flmErrorCodeEntry( NE_XFLM_SOCKET_FAIL), - flmErrorCodeEntry( NE_XFLM_CONNECT_FAIL), - flmErrorCodeEntry( NE_XFLM_BIND_FAIL), - flmErrorCodeEntry( NE_XFLM_LISTEN_FAIL), - flmErrorCodeEntry( NE_XFLM_ACCEPT_FAIL), - flmErrorCodeEntry( NE_XFLM_SELECT_ERR), - flmErrorCodeEntry( NE_XFLM_SOCKET_SET_OPT_FAIL), - flmErrorCodeEntry( NE_XFLM_SOCKET_DISCONNECT), - flmErrorCodeEntry( NE_XFLM_SOCKET_READ_FAIL), - flmErrorCodeEntry( NE_XFLM_SOCKET_WRITE_FAIL), - flmErrorCodeEntry( NE_XFLM_SOCKET_READ_TIMEOUT), - flmErrorCodeEntry( NE_XFLM_SOCKET_WRITE_TIMEOUT), - flmErrorCodeEntry( NE_XFLM_SOCKET_ALREADY_CLOSED) -}; - -F_ERROR_CODE_MAP gv_FlmQueryErrors[ - NE_XFLM_LAST_QUERY_ERROR - NE_XFLM_FIRST_QUERY_ERROR - 1] = -{ - flmErrorCodeEntry( NE_XFLM_Q_UNMATCHED_RPAREN), - flmErrorCodeEntry( NE_XFLM_Q_UNEXPECTED_LPAREN), - flmErrorCodeEntry( NE_XFLM_Q_UNEXPECTED_RPAREN), - flmErrorCodeEntry( NE_XFLM_Q_EXPECTING_OPERAND), - flmErrorCodeEntry( NE_XFLM_Q_EXPECTING_OPERATOR), - flmErrorCodeEntry( NE_XFLM_Q_UNEXPECTED_COMMA), - flmErrorCodeEntry( NE_XFLM_Q_EXPECTING_LPAREN), - flmErrorCodeEntry( NE_XFLM_Q_UNEXPECTED_VALUE), - flmErrorCodeEntry( NE_XFLM_Q_INVALID_NUM_FUNC_ARGS), - flmErrorCodeEntry( NE_XFLM_Q_UNEXPECTED_XPATH_COMPONENT), - flmErrorCodeEntry( NE_XFLM_Q_ILLEGAL_LBRACKET), - flmErrorCodeEntry( NE_XFLM_Q_ILLEGAL_RBRACKET), - flmErrorCodeEntry( NE_XFLM_Q_ILLEGAL_OPERAND), - flmErrorCodeEntry( NE_XFLM_Q_ALREADY_OPTIMIZED), - flmErrorCodeEntry( NE_XFLM_Q_MISMATCHED_DB), - flmErrorCodeEntry( NE_XFLM_Q_ILLEGAL_OPERATOR), - flmErrorCodeEntry( NE_XFLM_Q_ILLEGAL_COMPARE_RULES), - flmErrorCodeEntry( NE_XFLM_Q_INCOMPLETE_QUERY_EXPR), - flmErrorCodeEntry( NE_XFLM_Q_NOT_POSITIONED), - flmErrorCodeEntry( NE_XFLM_Q_INVALID_NODE_ID_VALUE), - flmErrorCodeEntry( NE_XFLM_Q_INVALID_META_DATA_TYPE), - flmErrorCodeEntry( NE_XFLM_Q_NEW_EXPR_NOT_ALLOWED), - flmErrorCodeEntry( NE_XFLM_Q_INVALID_CONTEXT_POS), - flmErrorCodeEntry( NE_XFLM_Q_INVALID_FUNC_ARG), - flmErrorCodeEntry( NE_XFLM_Q_EXPECTING_RPAREN), - flmErrorCodeEntry( NE_XFLM_Q_TOO_LATE_TO_ADD_SORT_KEYS), - flmErrorCodeEntry( NE_XFLM_Q_INVALID_SORT_KEY_COMPONENT), - flmErrorCodeEntry( NE_XFLM_Q_DUPLICATE_SORT_KEY_COMPONENT), - flmErrorCodeEntry( NE_XFLM_Q_MISSING_SORT_KEY_COMPONENT), - flmErrorCodeEntry( NE_XFLM_Q_NO_SORT_KEY_COMPONENTS_SPECIFIED), - flmErrorCodeEntry( NE_XFLM_Q_SORT_KEY_CONTEXT_MUST_BE_ELEMENT), - flmErrorCodeEntry( NE_XFLM_Q_INVALID_ELEMENT_NUM_IN_SORT_KEYS), - flmErrorCodeEntry( NE_XFLM_Q_INVALID_ATTR_NUM_IN_SORT_KEYS), - flmErrorCodeEntry( NE_XFLM_Q_NON_POSITIONABLE_QUERY), - flmErrorCodeEntry( NE_XFLM_Q_INVALID_POSITION) -}; - -F_ERROR_CODE_MAP gv_FlmStreamErrors[ - NE_XFLM_LAST_STREAM_ERROR - NE_XFLM_FIRST_STREAM_ERROR - 1] = -{ - flmErrorCodeEntry( NE_XFLM_STREAM_DECOMPRESS_ERROR), - flmErrorCodeEntry( NE_XFLM_STREAM_NOT_COMPRESSED), - flmErrorCodeEntry( NE_XFLM_STREAM_TOO_MANY_FILES) -}; - -F_ERROR_CODE_MAP gv_FlmNiciErrors[ - NE_XFLM_LAST_NICI_ERROR - NE_XFLM_FIRST_NICI_ERROR - 1] = -{ - flmErrorCodeEntry( NE_XFLM_NICI_CONTEXT), - flmErrorCodeEntry( NE_XFLM_NICI_ATTRIBUTE_VALUE), - flmErrorCodeEntry( NE_XFLM_NICI_BAD_ATTRIBUTE), - flmErrorCodeEntry( NE_XFLM_NICI_WRAPKEY_FAILED), - flmErrorCodeEntry( NE_XFLM_NICI_UNWRAPKEY_FAILED), - flmErrorCodeEntry( NE_XFLM_NICI_INVALID_ALGORITHM), - flmErrorCodeEntry( NE_XFLM_NICI_GENKEY_FAILED), - flmErrorCodeEntry( NE_XFLM_NICI_BAD_RANDOM), - flmErrorCodeEntry( NE_XFLM_PBE_ENCRYPT_FAILED), - flmErrorCodeEntry( NE_XFLM_PBE_DECRYPT_FAILED), - flmErrorCodeEntry( NE_XFLM_DIGEST_INIT_FAILED), - flmErrorCodeEntry( NE_XFLM_DIGEST_FAILED), - flmErrorCodeEntry( NE_XFLM_INJECT_KEY_FAILED), - flmErrorCodeEntry( NE_XFLM_NICI_FIND_INIT), - flmErrorCodeEntry( NE_XFLM_NICI_FIND_OBJECT), - flmErrorCodeEntry( NE_XFLM_NICI_KEY_NOT_FOUND), - flmErrorCodeEntry( NE_XFLM_NICI_ENC_INIT_FAILED), - flmErrorCodeEntry( NE_XFLM_NICI_ENCRYPT_FAILED), - flmErrorCodeEntry( NE_XFLM_NICI_DECRYPT_INIT_FAILED), - flmErrorCodeEntry( NE_XFLM_NICI_DECRYPT_FAILED), - flmErrorCodeEntry( NE_XFLM_NICI_WRAPKEY_NOT_FOUND), - flmErrorCodeEntry( NE_XFLM_NOT_EXPECTING_PASSWORD), - flmErrorCodeEntry( NE_XFLM_EXPECTING_PASSWORD), - flmErrorCodeEntry( NE_XFLM_EXTRACT_KEY_FAILED), - flmErrorCodeEntry( NE_XFLM_NICI_INIT_FAILED), - flmErrorCodeEntry( NE_XFLM_BAD_ENCKEY_SIZE), - flmErrorCodeEntry( NE_XFLM_ENCRYPTION_UNAVAILABLE) -}; +FLMBOOL gv_bToolkitStarted = FALSE; /**************************************************************************** Desc: This routine allocates and initializes a hash table. @@ -492,13 +101,13 @@ RCODE flmAllocHashTbl( FLMUINT uiHashTblSize, FBUCKET ** ppHashTblRV) { - RCODE rc = NE_XFLM_OK; - FBUCKET * pHashTbl = NULL; - F_RandomGenerator RandGen; - FLMUINT uiCnt; - FLMUINT uiRandVal; - FLMUINT uiTempVal; - + RCODE rc = NE_XFLM_OK; + FBUCKET * pHashTbl = NULL; + IF_RandomGenerator * pRandGen = NULL; + FLMUINT uiCnt; + FLMUINT uiRandVal; + FLMUINT uiTempVal; + // Allocate memory for the hash table if (RC_BAD( rc = f_calloc( @@ -507,9 +116,14 @@ RCODE flmAllocHashTbl( goto Exit; } - // Initialize the hash table + // Set up the random number generator + + if( RC_BAD( rc = FlmAllocRandomGenerator( &pRandGen))) + { + goto Exit; + } - RandGen.randomSetSeed( 1); + pRandGen->setSeed( 1); for (uiCnt = 0; uiCnt < uiHashTblSize; uiCnt++) { @@ -521,7 +135,7 @@ RCODE flmAllocHashTbl( { for( uiCnt = 0; uiCnt < uiHashTblSize - 1; uiCnt++) { - uiRandVal = (FLMBYTE) RandGen.randomChoice( (FLMINT32)uiCnt, + uiRandVal = (FLMBYTE) pRandGen->getINT32( (FLMINT32)uiCnt, (FLMINT32)(uiHashTblSize - 1)); if( uiRandVal != uiCnt) { @@ -534,11 +148,15 @@ RCODE flmAllocHashTbl( Exit: + if( pRandGen) + { + pRandGen->Release(); + } + *ppHashTblRV = pHashTbl; return( rc); } -#ifdef FLM_CAN_GET_PHYS_MEM /**************************************************************************** Desc: This routine determines the number of cache bytes to use for caching based on a percentage of available physical memory or a percentage @@ -548,201 +166,39 @@ Desc: This routine determines the number of cache bytes to use for caching on the available memory. Lower limit is 1 megabyte. ****************************************************************************/ -FSTATIC FLMUINT flmGetCacheBytes( +FSTATIC RCODE flmGetCacheBytes( FLMUINT uiPercent, FLMUINT uiMin, FLMUINT uiMax, FLMUINT uiMinToLeave, FLMBOOL bCalcOnAvailMem, - FLMUINT uiBytesCurrentlyInUse - ) + FLMUINT uiBytesCurrentlyInUse, + FLMUINT * puiCacheBytes) { - FLMUINT uiMem; -#ifdef FLM_WIN - MEMORYSTATUS MemStatus; -#elif defined( FLM_UNIX) - FLMUINT uiProcMemLimit = HIGH_FLMUINT; - FLMUINT uiProcVMemLimit = HIGH_FLMUINT; -#endif - -#ifdef FLM_WIN - GlobalMemoryStatus( &MemStatus); + RCODE rc = NE_XFLM_OK; + FLMUINT uiMem = 0; + FLMUINT64 ui64TotalPhysMem; + FLMUINT64 ui64AvailPhysMem; + + if( RC_BAD( rc = f_getMemoryInfo( &ui64TotalPhysMem, &ui64AvailPhysMem))) + { + goto Exit; + } + + if( ui64TotalPhysMem > HIGH_FLMUINT) + { + ui64TotalPhysMem = HIGH_FLMUINT; + } + + if( ui64AvailPhysMem > ui64TotalPhysMem) + { + ui64AvailPhysMem = ui64TotalPhysMem; + } + uiMem = (FLMUINT)((bCalcOnAvailMem) - ? (FLMUINT)MemStatus.dwAvailPhys - : (FLMUINT)MemStatus.dwTotalPhys); -#elif defined( FLM_UNIX) - { - #if defined( RLIMIT_VMEM) - { - struct rlimit rlim; + ? (FLMUINT)ui64TotalPhysMem + : (FLMUINT)ui64AvailPhysMem); - // Bump the process soft virtual limit up to the hard limit - - if( getrlimit( RLIMIT_VMEM, &rlim) == 0) - { - if( rlim.rlim_cur < rlim.rlim_max) - { - rlim.rlim_cur = rlim.rlim_max; - (void)setrlimit( RLIMIT_VMEM, &rlim); - if( getrlimit( RLIMIT_VMEM, &rlim) != 0) - { - rlim.rlim_cur = RLIM_INFINITY; - rlim.rlim_max = RLIM_INFINITY; - } - } - - if( rlim.rlim_cur != RLIM_INFINITY) - { - uiProcVMemLimit = (FLMUINT)rlim.rlim_cur; - } - } - } - #endif - - #if defined( RLIMIT_DATA) - { - struct rlimit rlim; - - // Bump the process soft heap limit up to the hard limit - - if( getrlimit( RLIMIT_DATA, &rlim) == 0) - { - if( rlim.rlim_cur < rlim.rlim_max) - { - rlim.rlim_cur = rlim.rlim_max; - (void)setrlimit( RLIMIT_DATA, &rlim); - if( getrlimit( RLIMIT_DATA, &rlim) != 0) - { - rlim.rlim_cur = RLIM_INFINITY; - rlim.rlim_max = RLIM_INFINITY; - } - } - - if( rlim.rlim_cur != RLIM_INFINITY) - { - uiProcMemLimit = (FLMUINT)rlim.rlim_cur; - } - } - } - #endif - -#ifdef FLM_AIX - struct vminfo tmpvminfo; - #ifdef _SC_PAGESIZE - long iPageSize = sysconf(_SC_PAGESIZE); - #else - long iPageSize = 4096; - #endif - - if( iPageSize == -1) - { - // If sysconf returned an error, resort to using the default - // page size for the Power architecture. - - iPageSize = 4096; - } - - uiMem = HIGH_FLMUINT; - - if( vmgetinfo( &tmpvminfo, VMINFO, sizeof( tmpvminfo)) != -1) - { - if( bCalcOnAvailMem) - { - if( tmpvminfo.numfrb < HIGH_FLMUINT) - { - uiMem = (FLMUINT)tmpvminfo.numfrb; - } - } - else - { - if( tmpvminfo.memsizepgs < HIGH_FLMUINT) - { - uiMem = (FLMUINT)tmpvminfo.memsizepgs; - } - } - } - - if (HIGH_FLMUINT / (FLMUINT)iPageSize >= uiMem) - { - uiMem *= (FLMUINT)iPageSize; - } - else - { - uiMem = HIGH_FLMUINT; - } -#elif defined( FLM_LINUX) - - FLMUINT64 ui64TotalMem; - FLMUINT64 ui64AvailMem; - FLMUINT64 ui64Mem; - - flmGetLinuxMemInfo( &ui64TotalMem, &ui64AvailMem); - - ui64Mem = bCalcOnAvailMem - ? ui64AvailMem - : ui64TotalMem; - - if( HIGH_FLMUINT >= ui64Mem) - { - uiMem = (FLMUINT)ui64Mem; - } - else - { - uiMem = HIGH_FLMUINT; - } - -#else - - long iPageSize = sysconf( _SC_PAGESIZE); - - // Get the amount of memory available to the system - - uiMem = (FLMUINT)((bCalcOnAvailMem) - ? (FLMUINT)sysconf(_SC_AVPHYS_PAGES) - : (FLMUINT)sysconf(_SC_PHYS_PAGES)); - - if (HIGH_FLMUINT / (FLMUINT)iPageSize >= uiMem) - { - uiMem *= (FLMUINT)iPageSize; - } - else - { - uiMem = HIGH_FLMUINT; - } -#endif - } -#elif defined( FLM_NLM) - { - - #ifndef _SC_PHYS_PAGES - #define _SC_PHYS_PAGES 56 - #endif - #ifndef _SCAVPHYS_PAGES - #define _SC_AVPHYS_PAGES 57 - #endif - - long iPageSize = sysconf(_SC_PAGESIZE); - - // Get the amount of memory available to the system - - uiMem = (FLMUINT)((bCalcOnAvailMem) - ? (FLMUINT)sysconf(_SC_AVPHYS_PAGES) - : (FLMUINT)sysconf(_SC_PHYS_PAGES)); - - - if (HIGH_FLMUINT / (FLMUINT)iPageSize >= uiMem) - { - uiMem *= (FLMUINT)iPageSize; - } - else - { - uiMem = HIGH_FLMUINT; - } - } -#else - #error Getting physical memory is not supported by this platform. -#endif - // If we are basing the calculation on available physical memory, // take in to account what has already been allocated. @@ -758,38 +214,6 @@ FSTATIC FLMUINT flmGetCacheBytes( } } - // Determine if there are limits on the amount of memory the - // process can access and reset uiMem accordingly. There may - // be more available memory than the process is able to access. - -#ifdef FLM_WIN - - // There could be more physical memory in the system than we could - // actually allocate in our virtual address space. Thus, we need to - // make sure that we never exceed our total virtual address space. - - if (uiMem > (FLMUINT)MemStatus.dwTotalVirtual) - { - uiMem = (FLMUINT)MemStatus.dwTotalVirtual; - } - -#elif defined( FLM_UNIX) - - // The process might be limited in the amount of memory it - // can access. - - if ( uiMem > uiProcMemLimit) - { - uiMem = uiProcMemLimit; - } - - if( uiMem > uiProcVMemLimit) - { - uiMem = uiProcVMemLimit; - } - -#endif - // If uiMax is zero, use uiMinToLeave to calculate the maximum. if (!uiMax) @@ -827,9 +251,12 @@ FSTATIC FLMUINT flmGetCacheBytes( { uiMem = uiMin; } - return( uiMem); + +Exit: + + *puiCacheBytes = uiMem; + return( rc); } -#endif /*************************************************************************** Desc: Verify that the distance (in bytes) between pvStart and pvEnd is @@ -838,8 +265,7 @@ Desc: Verify that the distance (in bytes) between pvStart and pvEnd is FINLINE void flmVerifyOffset( FLMUINT uiCompilerOffset, FLMUINT uiOffset, - RCODE * pRc - ) + RCODE * pRc) { if (RC_OK( *pRc)) { @@ -862,79 +288,79 @@ FSTATIC RCODE flmVerifyDiskStructOffsets( void) // Verify the XFLM_DB_HDR offsets. - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, szSignature[0]), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, szSignature[0]), XFLM_DB_HDR_szSignature_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui8IsLittleEndian), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui8IsLittleEndian), XFLM_DB_HDR_ui8IsLittleEndian_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui8DefaultLanguage), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui8DefaultLanguage), XFLM_DB_HDR_ui8DefaultLanguage_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui16BlockSize), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui16BlockSize), XFLM_DB_HDR_ui16BlockSize_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui32DbVersion), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui32DbVersion), XFLM_DB_HDR_ui32DbVersion_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui8BlkChkSummingEnabled), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui8BlkChkSummingEnabled), XFLM_DB_HDR_ui8BlkChkSummingEnabled_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui8RflKeepFiles), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui8RflKeepFiles), XFLM_DB_HDR_ui8RflKeepFiles_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui8RflAutoTurnOffKeep), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui8RflAutoTurnOffKeep), XFLM_DB_HDR_ui8RflAutoTurnOffKeep_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui8RflKeepAbortedTrans), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui8RflKeepAbortedTrans), XFLM_DB_HDR_ui8RflKeepAbortedTrans_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui32RflCurrFileNum), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui32RflCurrFileNum), XFLM_DB_HDR_ui32RflCurrFileNum_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui64LastRflCommitID), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui64LastRflCommitID), XFLM_DB_HDR_ui64LastRflCommitID_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui32RflLastFileNumDeleted), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui32RflLastFileNumDeleted), XFLM_DB_HDR_ui32RflLastFileNumDeleted_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui32RflLastTransOffset), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui32RflLastTransOffset), XFLM_DB_HDR_ui32RflLastTransOffset_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui32RflLastCPFileNum), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui32RflLastCPFileNum), XFLM_DB_HDR_ui32RflLastCPFileNum_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui32RflLastCPOffset), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui32RflLastCPOffset), XFLM_DB_HDR_ui32RflLastCPOffset_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui64RflLastCPTransID), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui64RflLastCPTransID), XFLM_DB_HDR_ui64RflLastCPTransID_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui32RflMinFileSize), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui32RflMinFileSize), XFLM_DB_HDR_ui32RflMinFileSize_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui32RflMaxFileSize), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui32RflMaxFileSize), XFLM_DB_HDR_ui32RflMaxFileSize_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui64CurrTransID), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui64CurrTransID), XFLM_DB_HDR_ui64CurrTransID_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui64TransCommitCnt), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui64TransCommitCnt), XFLM_DB_HDR_ui64TransCommitCnt_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui32RblEOF), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui32RblEOF), XFLM_DB_HDR_ui32RblEOF_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui32RblFirstCPBlkAddr), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui32RblFirstCPBlkAddr), XFLM_DB_HDR_ui32RblFirstCPBlkAddr_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui32FirstAvailBlkAddr), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui32FirstAvailBlkAddr), XFLM_DB_HDR_ui32FirstAvailBlkAddr_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui32FirstLFBlkAddr), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui32FirstLFBlkAddr), XFLM_DB_HDR_ui32FirstLFBlkAddr_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui32LogicalEOF), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui32LogicalEOF), XFLM_DB_HDR_ui32LogicalEOF_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui32MaxFileSize), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui32MaxFileSize), XFLM_DB_HDR_ui32MaxFileSize_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui64LastBackupTransID), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui64LastBackupTransID), XFLM_DB_HDR_ui64LastBackupTransID_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui32IncBackupSeqNum), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui32IncBackupSeqNum), XFLM_DB_HDR_ui32IncBackupSeqNum_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui32BlksChangedSinceBackup), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui32BlksChangedSinceBackup), XFLM_DB_HDR_ui32BlksChangedSinceBackup_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ucDbSerialNum[0]), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ucDbSerialNum[0]), XFLM_DB_HDR_ucDbSerialNum_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ucLastTransRflSerialNum[0]), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ucLastTransRflSerialNum[0]), XFLM_DB_HDR_ucLastTransRflSerialNum_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ucNextRflSerialNum[0]), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ucNextRflSerialNum[0]), XFLM_DB_HDR_ucNextRflSerialNum_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ucIncBackupSerialNum[0]), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ucIncBackupSerialNum[0]), XFLM_DB_HDR_ucIncBackupSerialNum_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui32DbKeyLen), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui32DbKeyLen), XFLM_DB_HDR_ui32DbKeyLen, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ucReserved[0]), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ucReserved[0]), XFLM_DB_HDR_ucReserved_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, ui32HdrCRC), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, ui32HdrCRC), XFLM_DB_HDR_ui32HdrCRC_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(XFLM_DB_HDR, DbKey[0]), + flmVerifyOffset( (FLMUINT)f_offsetof(XFLM_DB_HDR, DbKey[0]), XFLM_DB_HDR_DbKey, &rc); // Have to use a variable for sizeof. If we don't, compiler barfs @@ -948,23 +374,23 @@ FSTATIC RCODE flmVerifyDiskStructOffsets( void) // Verify the offsets in the F_BLK_HDR structure. - flmVerifyOffset( (FLMUINT)offsetof(F_LARGEST_BLK_HDR, all.stdBlkHdr.ui32BlkAddr), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LARGEST_BLK_HDR, all.stdBlkHdr.ui32BlkAddr), F_BLK_HDR_ui32BlkAddr_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(F_LARGEST_BLK_HDR, all.stdBlkHdr.ui32PrevBlkInChain), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LARGEST_BLK_HDR, all.stdBlkHdr.ui32PrevBlkInChain), F_BLK_HDR_ui32PrevBlkInChain_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(F_LARGEST_BLK_HDR, all.stdBlkHdr.ui32NextBlkInChain), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LARGEST_BLK_HDR, all.stdBlkHdr.ui32NextBlkInChain), F_BLK_HDR_ui32NextBlkInChain_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(F_LARGEST_BLK_HDR, all.stdBlkHdr.ui32PriorBlkImgAddr), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LARGEST_BLK_HDR, all.stdBlkHdr.ui32PriorBlkImgAddr), F_BLK_HDR_ui32PriorBlkImgAddr_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(F_LARGEST_BLK_HDR, all.stdBlkHdr.ui64TransID), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LARGEST_BLK_HDR, all.stdBlkHdr.ui64TransID), F_BLK_HDR_ui64TransID_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(F_LARGEST_BLK_HDR, all.stdBlkHdr.ui32BlkCRC), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LARGEST_BLK_HDR, all.stdBlkHdr.ui32BlkCRC), F_BLK_HDR_ui32BlkCRC_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(F_LARGEST_BLK_HDR, all.stdBlkHdr.ui16BlkBytesAvail), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LARGEST_BLK_HDR, all.stdBlkHdr.ui16BlkBytesAvail), F_BLK_HDR_ui16BlkBytesAvail_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(F_LARGEST_BLK_HDR, all.stdBlkHdr.ui8BlkFlags), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LARGEST_BLK_HDR, all.stdBlkHdr.ui8BlkFlags), F_BLK_HDR_ui8BlkFlags_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(F_LARGEST_BLK_HDR, all.stdBlkHdr.ui8BlkType), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LARGEST_BLK_HDR, all.stdBlkHdr.ui8BlkType), F_BLK_HDR_ui8BlkType_OFFSET, &rc); // Have to use a variable for sizeof. If we don't, compiler barfs @@ -978,17 +404,17 @@ FSTATIC RCODE flmVerifyDiskStructOffsets( void) // Verify the offsets in the F_BTREE_BLK_HDR structure - flmVerifyOffset( (FLMUINT)offsetof(F_LARGEST_BLK_HDR, all.BTreeBlkHdr.stdBlkHdr), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LARGEST_BLK_HDR, all.BTreeBlkHdr.stdBlkHdr), F_BTREE_BLK_HDR_stdBlkHdr_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(F_LARGEST_BLK_HDR, all.BTreeBlkHdr.ui16LogicalFile), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LARGEST_BLK_HDR, all.BTreeBlkHdr.ui16LogicalFile), F_BTREE_BLK_HDR_ui16LogicalFile_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(F_LARGEST_BLK_HDR, all.BTreeBlkHdr.ui16NumKeys), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LARGEST_BLK_HDR, all.BTreeBlkHdr.ui16NumKeys), F_BTREE_BLK_HDR_ui16NumKeys_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(F_LARGEST_BLK_HDR, all.BTreeBlkHdr.ui8BlkLevel), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LARGEST_BLK_HDR, all.BTreeBlkHdr.ui8BlkLevel), F_BTREE_BLK_HDR_ui8BlkLevel_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(F_LARGEST_BLK_HDR, all.BTreeBlkHdr.ui8BTreeFlags), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LARGEST_BLK_HDR, all.BTreeBlkHdr.ui8BTreeFlags), F_BTREE_BLK_HDR_ui8BTreeFlags_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(F_LARGEST_BLK_HDR, all.BTreeBlkHdr.ui16HeapSize), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LARGEST_BLK_HDR, all.BTreeBlkHdr.ui16HeapSize), F_BTREE_BLK_HDR_ui16HeapSize_OFFSET, &rc); // Have to use a variable for sizeof. If we don't, compiler barfs @@ -1011,21 +437,21 @@ FSTATIC RCODE flmVerifyDiskStructOffsets( void) // Verify the offsets in the F_LF_HDR structure - flmVerifyOffset( (FLMUINT)offsetof(F_LF_HDR, ui32LfNumber), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LF_HDR, ui32LfNumber), F_LF_HDR_ui32LfNumber_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(F_LF_HDR, ui32LfType), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LF_HDR, ui32LfType), F_LF_HDR_ui32LfType_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(F_LF_HDR, ui32RootBlkAddr), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LF_HDR, ui32RootBlkAddr), F_LF_HDR_ui32RootBlkAddr_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(F_LF_HDR, ui32EncId), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LF_HDR, ui32EncId), F_LF_HDR_ui32EncId_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(F_LF_HDR, ui64NextNodeId), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LF_HDR, ui64NextNodeId), F_LF_HDR_ui64NextNodeId_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(F_LF_HDR, ui64FirstDocId), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LF_HDR, ui64FirstDocId), F_LF_HDR_ui64FirstDocId_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(F_LF_HDR, ui64LastDocId), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LF_HDR, ui64LastDocId), F_LF_HDR_ui64LastDocId_OFFSET, &rc); - flmVerifyOffset( (FLMUINT)offsetof(F_LF_HDR, ucZeroes[0]), + flmVerifyOffset( (FLMUINT)f_offsetof(F_LF_HDR, ucZeroes[0]), F_LF_HDR_ucZeroes_OFFSET, &rc); // Have to use a variable for sizeof. If we don't, compiler barfs @@ -1063,7 +489,7 @@ void F_Database::logMustCloseReason( (unsigned)m_rcMustClose, pszFileName, (int)iLineNumber); - pLogMsg->changeColor( XFLM_YELLOW, XFLM_BLACK); + pLogMsg->changeColor( FLM_YELLOW, FLM_BLACK); pLogMsg->appendString( pszMsgBuf); } flmEndLogMessage( &pLogMsg); @@ -1116,7 +542,7 @@ void F_Database::shutdownDatabaseThreads( void) RCODE rc = NE_XFLM_OK; F_BKGND_IX * pBackgroundIx; F_Db * pDb; - F_Thread * pThread; + IF_Thread * pThread; FLMUINT uiThreadId; FLMUINT uiThreadCount; FLMBOOL bMutexLocked = TRUE; @@ -1135,7 +561,7 @@ void F_Database::shutdownDatabaseThreads( void) for( ;;) { if( RC_BAD( rc = gv_XFlmSysData.pThreadMgr->getNextGroupThread( - &pThread, FLM_BACKGROUND_INDEXING_THREAD_GROUP, &uiThreadId))) + &pThread, gv_XFlmSysData.uiIndexingThreadGroup, &uiThreadId))) { if( rc == NE_XFLM_NOT_FOUND) { @@ -1169,7 +595,7 @@ void F_Database::shutdownDatabaseThreads( void) for( ;;) { if( RC_BAD( rc = gv_XFlmSysData.pThreadMgr->getNextGroupThread( - &pThread, FLM_DB_THREAD_GROUP, &uiThreadId))) + &pThread, gv_XFlmSysData.uiDbThreadGroup, &uiThreadId))) { if( rc == NE_XFLM_NOT_FOUND) { @@ -1372,14 +798,6 @@ Note: This routine assumes that the calling routine has locked the global ****************************************************************************/ void F_DbSystem::checkNotUsedObjects( void) { - - // Look for unused file handles - - if( gv_XFlmSysData.pFileHdlMgr) - { - gv_XFlmSysData.pFileHdlMgr->checkAgedFileHdls( - gv_XFlmSysData.pFileHdlMgr->getMaxAvailTime()); - } } /**************************************************************************** @@ -1423,7 +841,7 @@ RCODE F_Db::linkToDatabase( // Set up the super file - if( RC_BAD( rc = m_pSFileHdl->Setup( pDatabase->m_pFileIdList, + if( RC_BAD( rc = m_pSFileHdl->setup( pDatabase->m_pszDbPath, pDatabase->m_pszDataDir))) { goto Exit; @@ -1431,7 +849,7 @@ RCODE F_Db::linkToDatabase( if( pDatabase->m_lastCommittedDbHdr.ui32DbVersion) { - m_pSFileHdl->SetBlockSize( pDatabase->m_uiBlockSize); + m_pSFileHdl->setBlockSize( pDatabase->m_uiBlockSize); } } @@ -1487,11 +905,6 @@ RCODE F_GlobalCacheMgr::adjustCache( FLMUINT * puiCurrTime, FLMUINT * puiLastCacheAdjustTime) { -#ifndef FLM_CAN_GET_PHYS_MEM - F_UNREFERENCED_PARM( puiCurrTime); - F_UNREFERENCED_PARM( puiLastCacheAdjustTime); - return( RC_SET( NE_XFLM_NOT_IMPLEMENTED)); -#else RCODE rc = NE_XFLM_OK; FLMUINT uiCurrTime = *puiCurrTime; FLMUINT uiLastCacheAdjustTime = *puiLastCacheAdjustTime; @@ -1510,9 +923,13 @@ RCODE F_GlobalCacheMgr::adjustCache( FLM_ELAPSED_TIME( uiCurrTime, uiLastCacheAdjustTime) >= m_uiCacheAdjustInterval) { - uiCacheBytes = flmGetCacheBytes( m_uiCacheAdjustPercent, - m_uiCacheAdjustMin, m_uiCacheAdjustMax, - m_uiCacheAdjustMinToLeave, TRUE, totalBytes()); + if( RC_BAD( rc = flmGetCacheBytes( m_uiCacheAdjustPercent, + m_uiCacheAdjustMin, m_uiCacheAdjustMax, + m_uiCacheAdjustMinToLeave, TRUE, totalBytes(), &uiCacheBytes))) + { + goto Exit; + } + if (RC_BAD( rc = setCacheLimit( uiCacheBytes, FALSE))) { unlockMutex(); @@ -1526,7 +943,6 @@ RCODE F_GlobalCacheMgr::adjustCache( Exit: return( rc); -#endif } /**************************************************************************** @@ -1535,13 +951,11 @@ Desc: This routine functions as a thread. It monitors open files and close time. ****************************************************************************/ RCODE F_DbSystem::monitorThrd( - F_Thread * pThread) + IF_Thread * pThread) { FLMUINT uiLastUnusedCleanupTime = 0; FLMUINT uiCurrTime; -#ifdef FLM_CAN_GET_PHYS_MEM FLMUINT uiLastCacheAdjustTime = 0; -#endif for (;;) { @@ -1580,10 +994,8 @@ RCODE F_DbSystem::monitorThrd( // Check the adjusting cache limit -#ifdef FLM_CAN_GET_PHYS_MEM (void)gv_XFlmSysData.pGlobalCacheMgr->adjustCache( &uiCurrTime, &uiLastCacheAdjustTime); -#endif f_sleep( 1000); } @@ -1595,7 +1007,7 @@ RCODE F_DbSystem::monitorThrd( Desc: ****************************************************************************/ RCODE F_DbSystem::cacheCleanupThrd( - F_Thread * pThread) + IF_Thread * pThread) { FLMUINT uiCurrTime; FLMUINT uiLastDefragTime = 0; @@ -1604,7 +1016,7 @@ RCODE F_DbSystem::cacheCleanupThrd( FLMUINT uiCleanupInterval = gv_XFlmSysData.pGlobalCacheMgr->m_uiCacheCleanupInterval; FLMBOOL bDoNodeCacheFirst = TRUE; - FLM_SECS_TO_TIMER_UNITS( 120, uiDefragInterval); + uiDefragInterval = FLM_SECS_TO_TIMER_UNITS( 120); for (;;) { @@ -1736,8 +1148,6 @@ F_HashTable::F_HashTable() m_pGlobalList = NULL; m_ppHashTable = NULL; m_uiBuckets = 0; - m_pCRCTable = NULL; - m_bOwnCRCTable = FALSE; } /**************************************************************************** @@ -1766,11 +1176,6 @@ F_HashTable::~F_HashTable() { f_mutexDestroy( &m_hMutex); } - - if( m_pCRCTable && m_bOwnCRCTable) - { - f_freeCRCTable( &m_pCRCTable); - } } /**************************************************************************** @@ -1778,8 +1183,7 @@ Desc: Configures the hash table prior to first use ****************************************************************************/ RCODE F_HashTable::setupHashTable( FLMBOOL bMultithreaded, - FLMUINT uiNumBuckets, - FLMUINT32 * pCRCTable) + FLMUINT uiNumBuckets) { RCODE rc = NE_XFLM_OK; @@ -1806,21 +1210,6 @@ RCODE F_HashTable::setupHashTable( } } - if( !pCRCTable) - { - // Initialize the CRC table - - if( RC_BAD( rc = f_initCRCTable( &m_pCRCTable))) - { - goto Exit; - } - m_bOwnCRCTable = TRUE; - } - else - { - m_pCRCTable = pCRCTable; - } - Exit: return( rc); @@ -2088,7 +1477,7 @@ FLMUINT F_HashTable::getHashBucket( { FLMUINT32 ui32CRC = 0; - f_updateCRC( m_pCRCTable, (FLMBYTE *)pvKey, uiLen, &ui32CRC); + f_updateCRC( (FLMBYTE *)pvKey, uiLen, &ui32CRC); if( pui32KeyCRC) { *pui32KeyCRC = ui32CRC; @@ -2194,7 +1583,7 @@ void F_DbSystem::lockSysData( void) { // Obtain the spin lock - while( flmAtomicExchange( &m_flmSysSpinLock, 1) == 1) + while( f_atomicExchange( &m_flmSysSpinLock, 1) == 1) { f_sleep( 10); } @@ -2206,7 +1595,7 @@ Desc: Unlock the system data structure for access - called only by startup ***************************************************************************/ void F_DbSystem::unlockSysData( void) { - (void)flmAtomicExchange( &m_flmSysSpinLock, 0); + (void)f_atomicExchange( &m_flmSysSpinLock, 0); } /**************************************************************************** @@ -2217,31 +1606,19 @@ F_GlobalCacheMgr::F_GlobalCacheMgr() m_pSlabManager = NULL; m_bCachePreallocated = FALSE; -#ifdef FLM_CAN_GET_PHYS_MEM m_bDynamicCacheAdjust = TRUE; m_uiCacheAdjustPercent = XFLM_DEFAULT_CACHE_ADJUST_PERCENT; m_uiCacheAdjustMin = XFLM_DEFAULT_CACHE_ADJUST_MIN; m_uiCacheAdjustMax = XFLM_DEFAULT_CACHE_ADJUST_MAX; m_uiCacheAdjustMinToLeave = XFLM_DEFAULT_CACHE_ADJUST_MIN_TO_LEAVE; - FLM_SECS_TO_TIMER_UNITS( XFLM_DEFAULT_CACHE_ADJUST_INTERVAL, - m_uiCacheAdjustInterval); - m_uiMaxBytes = flmGetCacheBytes( m_uiCacheAdjustPercent, - m_uiCacheAdjustMin, - m_uiCacheAdjustMax, - m_uiCacheAdjustMinToLeave, TRUE, 0); -#else - m_bDynamicCacheAdjust = FALSE; - m_uiCacheAdjustPercent = 0; - m_uiCacheAdjustMin = 0; - m_uiCacheAdjustMax = 0; - m_uiCacheAdjustMinToLeave = 0; - m_uiCacheAdjustInterval = 0; - m_uiMaxBytes = XFLM_DEFAULT_CACHE_ADJUST_MIN; -#endif - FLM_SECS_TO_TIMER_UNITS( XFLM_DEFAULT_CACHE_CLEANUP_INTERVAL, - m_uiCacheCleanupInterval); - FLM_SECS_TO_TIMER_UNITS( XFLM_DEFAULT_UNUSED_CLEANUP_INTERVAL, - m_uiUnusedCleanupInterval); + m_uiCacheAdjustInterval = FLM_SECS_TO_TIMER_UNITS( + XFLM_DEFAULT_CACHE_ADJUST_INTERVAL); + flmGetCacheBytes( m_uiCacheAdjustPercent, m_uiCacheAdjustMin, + m_uiCacheAdjustMax, m_uiCacheAdjustMinToLeave, TRUE, 0, &m_uiMaxBytes); + m_uiCacheCleanupInterval = FLM_SECS_TO_TIMER_UNITS( + XFLM_DEFAULT_CACHE_CLEANUP_INTERVAL); + m_uiUnusedCleanupInterval = FLM_SECS_TO_TIMER_UNITS( + XFLM_DEFAULT_UNUSED_CLEANUP_INTERVAL); m_hMutex = F_MUTEX_NULL; m_uiMaxSlabs = 0; } @@ -2255,6 +1632,7 @@ F_GlobalCacheMgr::~F_GlobalCacheMgr() { m_pSlabManager->Release(); } + if (m_hMutex != F_MUTEX_NULL) { f_mutexDestroy( &m_hMutex); @@ -2276,9 +1654,8 @@ RCODE F_GlobalCacheMgr::setup( void) goto Exit; } - if( (m_pSlabManager = f_new F_SlabManager) == NULL) + if( RC_BAD( rc = FlmAllocSlabManager( &m_pSlabManager))) { - rc = RC_SET( NE_XFLM_MEM); goto Exit; } @@ -2429,55 +1806,53 @@ RCODE F_DbSystem::init( void) { goto Exit; } - -#ifdef FLM_NLM - gv_bNetWareStartupCalled = TRUE; - if( RC_BAD( rc = f_netwareStartup())) + + if( RC_BAD( rc = ftkStartup())) { goto Exit; } -#endif + gv_bToolkitStarted = TRUE; + // The memset needs to be first. + + f_memset( &gv_XFlmSysData, 0, sizeof( FLMSYSDATA)); + gv_XFlmSysData.uiMaxFileSize = f_getMaxFileSize(); + + // Get the thread manager + + if( RC_BAD( rc = FlmGetThreadMgr( &gv_XFlmSysData.pThreadMgr))) + { + goto Exit; + } + + // Get the file system manager + + if( RC_BAD( rc = FlmGetFileSystem( &gv_XFlmSysData.pFileSystem))) + { + goto Exit; + } + + gv_XFlmSysData.uiIndexingThreadGroup = + gv_XFlmSysData.pThreadMgr->allocGroupId(); + + gv_XFlmSysData.uiDbThreadGroup = + gv_XFlmSysData.pThreadMgr->allocGroupId(); + + gv_XFlmSysData.uiCheckpointThreadGroup = + gv_XFlmSysData.pThreadMgr->allocGroupId(); + // Sanity check -- make sure we are using the correct // byte-swap macros for this platform flmAssert( FB2UD( (FLMBYTE *)"\x0A\x0B\x0C\x0D") == 0x0D0C0B0A); flmAssert( FB2UW( (FLMBYTE *)"\x0A\x0B") == 0x0B0A); - // The memset needs to be first. - - f_memset( &gv_XFlmSysData, 0, sizeof( FLMSYSDATA)); - -#if defined( FLM_LINUX) - flmGetLinuxKernelVersion( &gv_XFlmSysData.uiLinuxMajorVer, - &gv_XFlmSysData.uiLinuxMinorVer, - &gv_XFlmSysData.uiLinuxRevision); - gv_XFlmSysData.uiMaxFileSize = flmGetLinuxMaxFileSize(); -#elif defined( FLM_AIX) - // Call set setrlimit to increase the max allowed file size. - // We don't have a good way to deal with any errors returned by - // setrlimit(), so we just hope that there aren't any... - struct rlimit rlim; - rlim.rlim_cur = RLIM_INFINITY; - rlim.rlim_max = RLIM_INFINITY; - setrlimit( RLIMIT_FSIZE, &rlim); - gv_XFlmSysData.uiMaxFileSize = XFLM_MAXIMUM_FILE_SIZE; -#else - gv_XFlmSysData.uiMaxFileSize = XFLM_MAXIMUM_FILE_SIZE; -#endif - - // Initialize memory tracking variables - should be done before - // call to f_memoryInit(). - #ifdef FLM_DEBUG // Variables for memory allocation tracking. gv_XFlmSysData.bTrackLeaks = TRUE; gv_XFlmSysData.hMemTrackingMutex = F_MUTEX_NULL; -#ifdef DEBUG_SIM_OUT_OF_MEM - gv_XFlmSysData.memSimRandomGen.randomSetSeed( 1); -#endif #endif gv_XFlmSysData.hNodeCacheMutex = F_MUTEX_NULL; @@ -2496,13 +1871,7 @@ RCODE F_DbSystem::init( void) gv_XFlmSysData.EventHdrs [iEventCategory].hMutex = F_MUTEX_NULL; } - // Memory initialization should be first. - - f_memoryInit(); - -#if defined( FLM_NLM) || (defined( FLM_WIN) && !defined( FLM_64BIT)) initFastBlockCheckSum(); -#endif if (RC_BAD( rc = flmVerifyDiskStructOffsets())) { @@ -2518,13 +1887,13 @@ RCODE F_DbSystem::init( void) // Initialize all of the fields - FLM_SECS_TO_TIMER_UNITS( XFLM_DEFAULT_MAX_UNUSED_TIME, - gv_XFlmSysData.uiMaxUnusedTime); - FLM_SECS_TO_TIMER_UNITS( XFLM_DEFAULT_MAX_CP_INTERVAL, - gv_XFlmSysData.uiMaxCPInterval); + gv_XFlmSysData.uiMaxUnusedTime = FLM_SECS_TO_TIMER_UNITS( + XFLM_DEFAULT_MAX_UNUSED_TIME); + gv_XFlmSysData.uiMaxCPInterval = FLM_SECS_TO_TIMER_UNITS( + XFLM_DEFAULT_MAX_CP_INTERVAL); - FLM_SECS_TO_TIMER_UNITS( XFLM_DEFAULT_REHASH_BACKOFF_INTERVAL, - gv_XFlmSysData.uiRehashAfterFailureBackoffTime); + gv_XFlmSysData.uiRehashAfterFailureBackoffTime = + FLM_SECS_TO_TIMER_UNITS( XFLM_DEFAULT_REHASH_BACKOFF_INTERVAL); if ((gv_XFlmSysData.pGlobalCacheMgr = f_new F_GlobalCacheMgr) == NULL) { @@ -2537,33 +1906,6 @@ RCODE F_DbSystem::init( void) goto Exit; } - // Initialize the thread manager - - if( (gv_XFlmSysData.pThreadMgr = f_new F_ThreadMgr) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = gv_XFlmSysData.pThreadMgr->setupThreadMgr())) - { - goto Exit; - } - - // Initialize the serial number generator - - if( RC_BAD( rc = f_initSerialNumberGenerator())) - { - goto Exit; - } - - // Initialize the Unicode<->WP mapping tables - - if( RC_BAD( rc = initCharMappingTables())) - { - goto Exit; - } - // Create the mutexes for controlling access to cache and global structures. if (RC_BAD( rc = f_mutexCreate( &gv_XFlmSysData.hNodeCacheMutex))) @@ -2632,55 +1974,11 @@ RCODE F_DbSystem::init( void) { goto Exit; } - - // Allocate and Initialize FLAIM Shared File Handle Manager - - if ((gv_XFlmSysData.pFileHdlMgr = f_new F_FileHdlMgr) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if (RC_BAD( rc = gv_XFlmSysData.pFileHdlMgr->setupFileHdlMgr( - XFLM_DEFAULT_OPEN_THRESHOLD, - XFLM_DEFAULT_MAX_UNUSED_TIME))) - { - goto Exit; - } - - // Allocate and Initialize FLAIM Shared File System object - - if ((gv_pFileSystem = f_new F_FileSystem) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - + #ifdef FLM_DBG_LOG flmDbgLogInit(); #endif -#if defined( FLM_WIN) - OSVERSIONINFO versionInfo; - - versionInfo.dwOSVersionInfoSize = sizeof( OSVERSIONINFO); - if( !GetVersionEx( &versionInfo)) - { - return( MapWinErrorToFlaim( GetLastError(), NE_XFLM_FAILURE)); - } - - // Async writes are not supported on Win32s (3.1) or - // Win95, 98, ME, etc. - - gv_XFlmSysData.bOkToDoAsyncWrites = - (versionInfo.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS && - versionInfo.dwPlatformId != VER_PLATFORM_WIN32s) - ? TRUE - : FALSE; -#else - gv_XFlmSysData.bOkToDoAsyncWrites = TRUE; -#endif - // Allocate and Initialize FLAIM Server Lock Manager. if ((gv_XFlmSysData.pServerLockMgr = f_new ServerLockManager) == NULL) @@ -2715,7 +2013,8 @@ RCODE F_DbSystem::init( void) // Start the monitor thread - if (RC_BAD( rc = f_threadCreate( &gv_XFlmSysData.pMonitorThrd, + if (RC_BAD( rc = gv_XFlmSysData.pThreadMgr->createThread( + &gv_XFlmSysData.pMonitorThrd, F_DbSystem::monitorThrd, "DB Monitor"))) { goto Exit; @@ -2723,7 +2022,8 @@ RCODE F_DbSystem::init( void) // Start the cache cleanup thread - if (RC_BAD( rc = f_threadCreate( &gv_XFlmSysData.pCacheCleanupThrd, + if (RC_BAD( rc = gv_XFlmSysData.pThreadMgr->createThread( + &gv_XFlmSysData.pCacheCleanupThrd, F_DbSystem::cacheCleanupThrd, "Cache Cleanup Thread"))) { goto Exit; @@ -2750,27 +2050,12 @@ RCODE F_DbSystem::init( void) { goto Exit; } - - if( (gv_XFlmSysData.pXml = f_new F_XML) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = gv_XFlmSysData.pXml->buildCharTable())) + + if( RC_BAD( rc = FlmGetXMLObject( &gv_XFlmSysData.pXml))) { goto Exit; } - // Check the metaphone routines - -#ifdef FLM_DEBUG - if( RC_BAD( rc = flmVerifyMetaphoneRoutines())) - { - goto Exit; - } -#endif - #ifdef FLM_USE_NICI iHandle = f_getpid(); @@ -2787,19 +2072,6 @@ RCODE F_DbSystem::init( void) readIniFile(); -#ifdef FLM_NLM - // Detect if we are running in RING0. If so, use NSS File Handles -#define MAX_ADDRSPACE_NAMELEN 63 - char szAddrSpaceName[ MAX_ADDRSPACE_NAMELEN + 1]; - if( getaddressspacename( getaddressspace(), szAddrSpaceName) != NULL) - { - if( f_strcmp( szAddrSpaceName, "OS") == 0) - { - gv_XFlmSysData.bUseNSSFileHdls = TRUE; - } - } -#endif - Exit: // If not successful, free up any resources that were allocated. @@ -2878,13 +2150,31 @@ void F_DbSystem::cleanup( void) } // Shut down the monitor thread, if there is one. - - f_threadDestroy( &gv_XFlmSysData.pMonitorThrd); + + if( gv_XFlmSysData.pMonitorThrd) + { + gv_XFlmSysData.pMonitorThrd->stopThread(); + gv_XFlmSysData.pMonitorThrd->Release(); + gv_XFlmSysData.pMonitorThrd = NULL; + } // Shut down the cache reduce thread - - f_threadDestroy( &gv_XFlmSysData.pCacheCleanupThrd); + if( gv_XFlmSysData.pCacheCleanupThrd) + { + gv_XFlmSysData.pCacheCleanupThrd->stopThread(); + gv_XFlmSysData.pCacheCleanupThrd->Release(); + gv_XFlmSysData.pCacheCleanupThrd = NULL; + } + + // Release the thread manager + + if( gv_XFlmSysData.pThreadMgr) + { + gv_XFlmSysData.pThreadMgr->Release(); + gv_XFlmSysData.pThreadMgr = NULL; + } + // Free all of the files and associated structures if (gv_XFlmSysData.pDatabaseHashTbl) @@ -2935,24 +2225,6 @@ void F_DbSystem::cleanup( void) f_mutexDestroy( &gv_XFlmSysData.hStatsMutex); } - // Free (release) FLAIM's File Shared File Handles. - - if (gv_XFlmSysData.pFileHdlMgr) - { - FLMUINT uiRefCnt = gv_XFlmSysData.pFileHdlMgr->Release(); - - // No one else should have a reference to the file handle manager - // after this point. - -#ifdef FLM_DEBUG - flmAssert( 0 == uiRefCnt); -#else - // Quiet the compiler about the unused variable - (void)uiRefCnt; -#endif - gv_XFlmSysData.pFileHdlMgr = NULL; - } - // Free (release) FLAIM's Server Lock Manager. if (gv_XFlmSysData.pServerLockMgr) @@ -3025,31 +2297,18 @@ void F_DbSystem::cleanup( void) } } - // Free (release) FLAIM's File Shared File System Object. + // Release the file system object - if (gv_pFileSystem) + if (gv_XFlmSysData.pFileSystem) { - FLMUINT uiRefCnt = gv_pFileSystem->Release(); - - // No one else should have a reference to the file system - // after this point. - -#ifdef FLM_DEBUG - flmAssert( 0 == uiRefCnt); -#else - // Quiet the compiler about the unused variable - (void)uiRefCnt; -#endif - gv_pFileSystem = NULL; + gv_XFlmSysData.pFileSystem->Release(); + gv_XFlmSysData.pFileSystem = NULL; } + #ifdef FLM_DBG_LOG flmDbgLogExit(); #endif - // Free the serial number generator - - f_freeSerialNumberGenerator(); - // Release the logger if( gv_XFlmSysData.pLogger) @@ -3064,14 +2323,6 @@ void F_DbSystem::cleanup( void) f_mutexDestroy( &gv_XFlmSysData.hLoggerMutex); } - // Release the thread manager - - if( gv_XFlmSysData.pThreadMgr) - { - gv_XFlmSysData.pThreadMgr->Release(); - gv_XFlmSysData.pThreadMgr = NULL; - } - // Free the btree pool if( gv_XFlmSysData.pBtPool) @@ -3106,10 +2357,6 @@ void F_DbSystem::cleanup( void) gv_XFlmSysData.pGlobalCacheMgr = NULL; } - // Free the Unicode<->WP tables - - freeCharMappingTables(); - #ifdef FLM_USE_NICI CCS_Shutdown(); #endif @@ -3138,20 +2385,12 @@ void F_DbSystem::cleanup( void) { f_mutexDestroy( &gv_XFlmSysData.hIniMutex); } - - // Memory cleanup - - f_memoryCleanup(); - - // Shutdown the NetWare interfaces - -#ifdef FLM_NLM - if( gv_bNetWareStartupCalled) + + if( gv_bToolkitStarted) { - f_netwareShutdown(); - gv_bNetWareStartupCalled = FALSE; + ftkShutdown(); + gv_bToolkitStarted = FALSE; } -#endif } /**************************************************************************** @@ -3163,31 +2402,35 @@ RCODE F_GlobalCacheMgr::setDynamicMemoryLimit( FLMUINT uiCacheAdjustMax, FLMUINT uiCacheAdjustMinToLeave) { -#ifndef FLM_CAN_GET_PHYS_MEM - F_UNREFERENCED_PARM( uiCacheAdjustPercent); - F_UNREFERENCED_PARM( uiCacheAdjustMin); - F_UNREFERENCED_PARM( uiCacheAdjustMax); - F_UNREFERENCED_PARM( uiCacheAdjustMinToLeave); - return( RC_SET( NE_XFLM_NOT_IMPLEMENTED)); -#else RCODE rc = NE_XFLM_OK; FLMUINT uiCacheBytes; lockMutex(); + m_bDynamicCacheAdjust = TRUE; flmAssert( uiCacheAdjustPercent > 0 && uiCacheAdjustPercent <= 100); m_uiCacheAdjustPercent = uiCacheAdjustPercent; m_uiCacheAdjustMin = uiCacheAdjustMin; m_uiCacheAdjustMax = uiCacheAdjustMax; m_uiCacheAdjustMinToLeave = uiCacheAdjustMinToLeave; - uiCacheBytes = flmGetCacheBytes( m_uiCacheAdjustPercent, + + if( RC_BAD( rc = flmGetCacheBytes( m_uiCacheAdjustPercent, m_uiCacheAdjustMin, m_uiCacheAdjustMax, - m_uiCacheAdjustMinToLeave, TRUE, totalBytes()); + m_uiCacheAdjustMinToLeave, TRUE, totalBytes(), + &uiCacheBytes))) + { + goto Exit; + } - rc = setCacheLimit( uiCacheBytes, FALSE); + if( RC_BAD( rc = setCacheLimit( uiCacheBytes, FALSE))) + { + goto Exit; + } + +Exit: + unlockMutex(); return( rc); -#endif } /**************************************************************************** @@ -3204,29 +2447,35 @@ RCODE F_GlobalCacheMgr::setHardMemoryLimit( RCODE rc = NE_XFLM_OK; lockMutex(); + m_bDynamicCacheAdjust = FALSE; if (uiPercent) { -#ifndef FLM_CAN_GET_PHYS_MEM - F_UNREFERENCED_PARM( bPercentOfAvail); - F_UNREFERENCED_PARM( uiMin); - F_UNREFERENCED_PARM( uiMinToLeave); - rc = RC_SET( NE_XFLM_NOT_IMPLEMENTED); -#else FLMUINT uiCacheBytes; - uiCacheBytes = flmGetCacheBytes( uiPercent, uiMin, uiMax, uiMinToLeave, - bPercentOfAvail, totalBytes()); - rc = setCacheLimit( uiCacheBytes, bPreallocate); -#endif + if( RC_BAD( rc = flmGetCacheBytes( uiPercent, uiMin, + uiMax, uiMinToLeave, bPercentOfAvail, + totalBytes(), &uiCacheBytes))) + { + goto Exit; + } + + if( RC_BAD( rc = setCacheLimit( uiCacheBytes, bPreallocate))) + { + goto Exit; + } } else { - rc = setCacheLimit( uiMax, bPreallocate); + if( RC_BAD( rc = setCacheLimit( uiMax, bPreallocate))) + { + goto Exit; + } } + +Exit: unlockMutex(); - return( rc); } @@ -3314,19 +2563,11 @@ void F_GlobalCacheMgr::getCacheInfo( f_mutexUnlock( gv_XFlmSysData.hShareMutex); } -/**************************************************************************** -Desc: Returns the number of open databases -****************************************************************************/ -FLMUINT XFLMAPI F_DbSystem::getOpenFileCount( void) -{ - return( gv_XFlmSysData.pFileHdlMgr->getOpenedFiles()); -} - /**************************************************************************** Desc: Close all files in the file handle manager that have not been used for the specified number of seconds. ****************************************************************************/ -RCODE XFLMAPI F_DbSystem::closeUnusedFiles( +RCODE FLMAPI F_DbSystem::closeUnusedFiles( FLMUINT uiSeconds) { RCODE rc = NE_XFLM_OK; @@ -3336,8 +2577,7 @@ RCODE XFLMAPI F_DbSystem::closeUnusedFiles( // Convert seconds to timer units - FLM_SECS_TO_TIMER_UNITS( uiSeconds, uiValue); - gv_XFlmSysData.pFileHdlMgr->checkAgedFileHdls( uiValue); + uiValue = FLM_SECS_TO_TIMER_UNITS( uiSeconds); // Free any other unused structures that have not been used for the // specified amount of time. @@ -3361,28 +2601,10 @@ RCODE XFLMAPI F_DbSystem::closeUnusedFiles( return( rc); } -/**************************************************************************** -Desc: Set threshold for number of file handles that are opened by - the file handle manager -****************************************************************************/ -void XFLMAPI F_DbSystem::setOpenThreshold( - FLMUINT uiThreshold) -{ - gv_XFlmSysData.pFileHdlMgr->setOpenThreshold( uiThreshold); -} - -/**************************************************************************** -Desc: Get the maximum number of file handles available. -****************************************************************************/ -FLMUINT XFLMAPI F_DbSystem::getOpenThreshold( void) -{ - return( gv_XFlmSysData.pFileHdlMgr->getOpenThreshold()); -} - /**************************************************************************** Desc: Enable/disable cache debugging mode ****************************************************************************/ -void XFLMAPI F_DbSystem::enableCacheDebug( +void FLMAPI F_DbSystem::enableCacheDebug( FLMBOOL bDebug) { #ifdef FLM_DEBUG @@ -3396,7 +2618,7 @@ void XFLMAPI F_DbSystem::enableCacheDebug( /**************************************************************************** Desc: Returns cache debugging mode ****************************************************************************/ -FLMBOOL XFLMAPI F_DbSystem::cacheDebugEnabled( void) +FLMBOOL FLMAPI F_DbSystem::cacheDebugEnabled( void) { #ifdef FLM_DEBUG return( gv_XFlmSysData.pBlockCacheMgr->m_bDebug || @@ -3409,7 +2631,7 @@ FLMBOOL XFLMAPI F_DbSystem::cacheDebugEnabled( void) /**************************************************************************** Desc: Start gathering statistics. ****************************************************************************/ -void XFLMAPI F_DbSystem::startStats( void) +void FLMAPI F_DbSystem::startStats( void) { f_mutexLock( gv_XFlmSysData.hStatsMutex); flmStatStart( &gv_XFlmSysData.Stats); @@ -3430,7 +2652,7 @@ void XFLMAPI F_DbSystem::startStats( void) /**************************************************************************** Desc: Stop gathering statistics. ****************************************************************************/ -void XFLMAPI F_DbSystem::stopStats( void) +void FLMAPI F_DbSystem::stopStats( void) { f_mutexLock( gv_XFlmSysData.hStatsMutex); flmStatStop( &gv_XFlmSysData.Stats); @@ -3455,7 +2677,7 @@ void XFLMAPI F_DbSystem::stopStats( void) /**************************************************************************** Desc: Reset statistics. ****************************************************************************/ -void XFLMAPI F_DbSystem::resetStats( void) +void FLMAPI F_DbSystem::resetStats( void) { FLMUINT uiSaveMax; @@ -3506,7 +2728,7 @@ void XFLMAPI F_DbSystem::resetStats( void) Desc: Returns statistics that have been collected for a share. Notes: The statistics returned will be the statistics for ALL databases ****************************************************************************/ -RCODE XFLMAPI F_DbSystem::getStats( +RCODE FLMAPI F_DbSystem::getStats( XFLM_STATS * pFlmStats) { RCODE rc = NE_XFLM_OK; @@ -3529,7 +2751,7 @@ Exit: /**************************************************************************** Desc: Frees memory allocated to a FLM_STATS structure ****************************************************************************/ -void XFLMAPI F_DbSystem::freeStats( +void FLMAPI F_DbSystem::freeStats( XFLM_STATS * pFlmStats) { flmStatFree( pFlmStats); @@ -3540,7 +2762,7 @@ Desc: Sets the path for all temporary files that come into use within a FLAIM share structure. The share mutex should be locked when settting when called from FlmConfig(). ****************************************************************************/ -RCODE XFLMAPI F_DbSystem::setTempDir( +RCODE FLMAPI F_DbSystem::setTempDir( const char * pszPath) { RCODE rc = NE_XFLM_OK; @@ -3549,7 +2771,7 @@ RCODE XFLMAPI F_DbSystem::setTempDir( // First, test the path - if( RC_BAD( rc = gv_pFileSystem->Exists( pszPath))) + if( RC_BAD( rc = gv_XFlmSysData.pFileSystem->doesFileExist( pszPath))) { goto Exit; } @@ -3566,7 +2788,7 @@ Exit: /**************************************************************************** Desc: Get the temporary directory. ****************************************************************************/ -RCODE XFLMAPI F_DbSystem::getTempDir( +RCODE FLMAPI F_DbSystem::getTempDir( char * pszPath) { RCODE rc = NE_XFLM_OK; @@ -3576,7 +2798,7 @@ RCODE XFLMAPI F_DbSystem::getTempDir( if( !gv_XFlmSysData.bTempDirSet ) { *pszPath = 0; - rc = RC_SET( NE_XFLM_IO_PATH_NOT_FOUND); + rc = RC_SET( NE_FLM_IO_PATH_NOT_FOUND); goto Exit; } else @@ -3593,146 +2815,101 @@ Exit: /**************************************************************************** Desc: Sets the maximum seconds between checkpoints ****************************************************************************/ -void XFLMAPI F_DbSystem::setCheckpointInterval( +void FLMAPI F_DbSystem::setCheckpointInterval( FLMUINT uiSeconds) { - FLM_SECS_TO_TIMER_UNITS( uiSeconds, gv_XFlmSysData.uiMaxCPInterval); + gv_XFlmSysData.uiMaxCPInterval = FLM_SECS_TO_TIMER_UNITS( uiSeconds); } /**************************************************************************** Desc: Gets the maximum seconds between checkpoints ****************************************************************************/ -FLMUINT XFLMAPI F_DbSystem::getCheckpointInterval( void) +FLMUINT FLMAPI F_DbSystem::getCheckpointInterval( void) { - FLMUINT uiTmp; - - FLM_TIMER_UNITS_TO_SECS( gv_XFlmSysData.uiMaxCPInterval, uiTmp); - return( uiTmp); + return( FLM_TIMER_UNITS_TO_SECS( gv_XFlmSysData.uiMaxCPInterval)); } /**************************************************************************** Desc: Sets the interval for dynamically adjusting the cache limit. ****************************************************************************/ -void XFLMAPI F_DbSystem::setCacheAdjustInterval( +void FLMAPI F_DbSystem::setCacheAdjustInterval( FLMUINT uiSeconds) { - FLM_SECS_TO_TIMER_UNITS( uiSeconds, - gv_XFlmSysData.pGlobalCacheMgr->m_uiCacheAdjustInterval); + gv_XFlmSysData.pGlobalCacheMgr->m_uiCacheAdjustInterval = + FLM_SECS_TO_TIMER_UNITS( uiSeconds); } /**************************************************************************** Desc: Sets the interval for dynamically adjusting the cache limit. ****************************************************************************/ -FLMUINT XFLMAPI F_DbSystem::getCacheAdjustInterval( void) +FLMUINT FLMAPI F_DbSystem::getCacheAdjustInterval( void) { - FLMUINT uiTmp; - - FLM_TIMER_UNITS_TO_SECS( - gv_XFlmSysData.pGlobalCacheMgr->m_uiCacheAdjustInterval, uiTmp); - return( uiTmp); + return( FLM_TIMER_UNITS_TO_SECS( + gv_XFlmSysData.pGlobalCacheMgr->m_uiCacheAdjustInterval)); } /**************************************************************************** Desc: Sets the interval for dynamically cleaning out old cache blocks and records ****************************************************************************/ -void XFLMAPI F_DbSystem::setCacheCleanupInterval( +void FLMAPI F_DbSystem::setCacheCleanupInterval( FLMUINT uiSeconds) { - FLM_SECS_TO_TIMER_UNITS( uiSeconds, - gv_XFlmSysData.pGlobalCacheMgr->m_uiCacheCleanupInterval); + gv_XFlmSysData.pGlobalCacheMgr->m_uiCacheCleanupInterval = + FLM_SECS_TO_TIMER_UNITS( uiSeconds); } /**************************************************************************** Desc: Gets the interval for dynamically cleaning out old cache blocks and records ****************************************************************************/ -FLMUINT XFLMAPI F_DbSystem::getCacheCleanupInterval( void) +FLMUINT FLMAPI F_DbSystem::getCacheCleanupInterval( void) { - FLMUINT uiTmp; - - FLM_TIMER_UNITS_TO_SECS( - gv_XFlmSysData.pGlobalCacheMgr->m_uiCacheCleanupInterval, uiTmp); - return( uiTmp); + return( FLM_TIMER_UNITS_TO_SECS( + gv_XFlmSysData.pGlobalCacheMgr->m_uiCacheCleanupInterval)); } /**************************************************************************** Desc: Set interval for cleaning up unused structures ****************************************************************************/ -void XFLMAPI F_DbSystem::setUnusedCleanupInterval( +void FLMAPI F_DbSystem::setUnusedCleanupInterval( FLMUINT uiSeconds) { - FLM_SECS_TO_TIMER_UNITS( uiSeconds, - gv_XFlmSysData.pGlobalCacheMgr->m_uiUnusedCleanupInterval); + gv_XFlmSysData.pGlobalCacheMgr->m_uiUnusedCleanupInterval = + FLM_SECS_TO_TIMER_UNITS( uiSeconds); } /**************************************************************************** Desc: Gets the interval for cleaning up unused structures ****************************************************************************/ -FLMUINT XFLMAPI F_DbSystem::getUnusedCleanupInterval( void) +FLMUINT FLMAPI F_DbSystem::getUnusedCleanupInterval( void) { - FLMUINT uiTmp; - - FLM_TIMER_UNITS_TO_SECS( - gv_XFlmSysData.pGlobalCacheMgr->m_uiUnusedCleanupInterval, uiTmp); - return( uiTmp); + return( FLM_TIMER_UNITS_TO_SECS( + gv_XFlmSysData.pGlobalCacheMgr->m_uiUnusedCleanupInterval)); } /**************************************************************************** Desc: Set the maximum time for an item to be unused before it is cleaned up ****************************************************************************/ -void XFLMAPI F_DbSystem::setMaxUnusedTime( +void FLMAPI F_DbSystem::setMaxUnusedTime( FLMUINT uiSeconds) { - FLM_SECS_TO_TIMER_UNITS( uiSeconds, gv_XFlmSysData.uiMaxUnusedTime); + gv_XFlmSysData.uiMaxUnusedTime = FLM_SECS_TO_TIMER_UNITS( uiSeconds); } /**************************************************************************** Desc: Gets the maximum time for an item to be unused ****************************************************************************/ -FLMUINT XFLMAPI F_DbSystem::getMaxUnusedTime( void) +FLMUINT FLMAPI F_DbSystem::getMaxUnusedTime( void) { - FLMUINT uiTmp; - - FLM_TIMER_UNITS_TO_SECS( gv_XFlmSysData.uiMaxUnusedTime, uiTmp); - return( uiTmp); -} - -/**************************************************************************** -Desc: Enables or disables out-of-memory simulation -****************************************************************************/ -void F_DbSystem::enableOutOfMemorySimulation( - FLMBOOL bEnable) -{ -#ifdef DEBUG_SIM_OUT_OF_MEM - gv_XFlmSysData.uiOutOfMemSimEnabledFlag = bEnable - ? OUT_OF_MEM_SIM_ENABLED_FLAG - : 0; -#else - F_UNREFERENCED_PARM( bEnable); -#endif -} - -/**************************************************************************** -Desc: Returns the state of out-of-memory simulation -****************************************************************************/ -FLMBOOL F_DbSystem::outOfMemorySimulationEnabled( void) -{ -#ifdef DEBUG_SIM_OUT_OF_MEM - if( gv_XFlmSysData.uiOutOfMemSimEnabledFlag == OUT_OF_MEM_SIM_ENABLED_FLAG) - { - return( TRUE); - } -#endif - - return( FALSE); + return( FLM_TIMER_UNITS_TO_SECS( gv_XFlmSysData.uiMaxUnusedTime)); } /**************************************************************************** Desc: Sets the logging object to be used for internal status messages ****************************************************************************/ -void XFLMAPI F_DbSystem::setLogger( +void FLMAPI F_DbSystem::setLogger( IF_LoggerClient * pLogger) { IF_LoggerClient * pOldLogger = NULL; @@ -3783,7 +2960,7 @@ void XFLMAPI F_DbSystem::setLogger( /**************************************************************************** Desc: Enables or disables the use of ESM (if available) ****************************************************************************/ -void XFLMAPI F_DbSystem::enableExtendedServerMemory( +void FLMAPI F_DbSystem::enableExtendedServerMemory( FLMBOOL bEnable) { gv_XFlmSysData.bOkToUseESM = bEnable; @@ -3792,7 +2969,7 @@ void XFLMAPI F_DbSystem::enableExtendedServerMemory( /**************************************************************************** Desc: Returns the state of ESM ****************************************************************************/ -FLMBOOL XFLMAPI F_DbSystem::extendedServerMemoryEnabled( void) +FLMBOOL FLMAPI F_DbSystem::extendedServerMemoryEnabled( void) { return( gv_XFlmSysData.bOkToUseESM); } @@ -3803,7 +2980,7 @@ Desc: Deactivates open database handles, forcing the database to be Notes: Passing NULL for the path values will cause all active database handles to be deactivated ****************************************************************************/ -void XFLMAPI F_DbSystem::deactivateOpenDb( +void FLMAPI F_DbSystem::deactivateOpenDb( const char * pszDbFileName, const char * pszDataDir) { @@ -3847,7 +3024,7 @@ void XFLMAPI F_DbSystem::deactivateOpenDb( /**************************************************************************** Desc: Sets the maximum number of queries to save ****************************************************************************/ -void XFLMAPI F_DbSystem::setQuerySaveMax( +void FLMAPI F_DbSystem::setQuerySaveMax( FLMUINT uiMaxToSave) { f_mutexLock( gv_XFlmSysData.hQueryMutex); @@ -3859,7 +3036,7 @@ void XFLMAPI F_DbSystem::setQuerySaveMax( /**************************************************************************** Desc: Gets the maximum number of queries to save ****************************************************************************/ -FLMUINT XFLMAPI F_DbSystem::getQuerySaveMax( void) +FLMUINT FLMAPI F_DbSystem::getQuerySaveMax( void) { return( gv_XFlmSysData.uiMaxQueries); } @@ -3867,7 +3044,7 @@ FLMUINT XFLMAPI F_DbSystem::getQuerySaveMax( void) /**************************************************************************** Desc: Sets the maximum amount of dirty cache allowed ****************************************************************************/ -void XFLMAPI F_DbSystem::setDirtyCacheLimits( +void FLMAPI F_DbSystem::setDirtyCacheLimits( FLMUINT uiMaxDirty, FLMUINT uiLowDirty) { @@ -3898,7 +3075,7 @@ void XFLMAPI F_DbSystem::setDirtyCacheLimits( /**************************************************************************** Desc: Gets the maximum amount of dirty cache allowed ****************************************************************************/ -void XFLMAPI F_DbSystem::getDirtyCacheLimits( +void FLMAPI F_DbSystem::getDirtyCacheLimits( FLMUINT * puiMaxDirty, FLMUINT * puiLowDirty) { @@ -3919,48 +3096,30 @@ void XFLMAPI F_DbSystem::getDirtyCacheLimits( /**************************************************************************** Desc: Returns information about threads owned by the database engine ****************************************************************************/ -RCODE XFLMAPI F_DbSystem::getThreadInfo( - IF_ThreadInfo ** ppThreadInfo - ) +RCODE FLMAPI F_DbSystem::getThreadInfo( + IF_ThreadInfo ** ppThreadInfo) { - RCODE rc = NE_XFLM_OK; - F_ThreadInfo * pThreadInfo = NULL; + return( FlmGetThreadInfo( ppThreadInfo)); +} - if ((pThreadInfo = f_new F_ThreadInfo) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if (RC_BAD( rc = gv_XFlmSysData.pThreadMgr->getThreadInfo( - &pThreadInfo->m_Pool, - &pThreadInfo->m_pThreadInfoArray, - &pThreadInfo->m_uiNumThreads))) - { - goto Exit; - } - -Exit: - - if (RC_BAD( rc) && pThreadInfo) - { - pThreadInfo->Release(); - pThreadInfo = NULL; - } - - *ppThreadInfo = (IF_ThreadInfo *)pThreadInfo; - return( rc); +/**************************************************************************** +Desc: +****************************************************************************/ +void FLMAPI F_DbSystem::getFileSystem( + IF_FileSystem ** ppFileSystem) +{ + FlmGetFileSystem( ppFileSystem); } /**************************************************************************** Desc: Registers for an event ****************************************************************************/ -RCODE XFLMAPI F_DbSystem::registerForEvent( - eEventCategory eCategory, +RCODE FLMAPI F_DbSystem::registerForEvent( + eEventCategory eCategory, IF_EventClient * pEventClient) { - RCODE rc = NE_XFLM_OK; - FEVENT * pEvent; + RCODE rc = NE_XFLM_OK; + FEVENT * pEvent; // Make sure it is a legal event category to register for. @@ -4004,7 +3163,7 @@ Exit: /**************************************************************************** Desc: De-registers for an event ****************************************************************************/ -void XFLMAPI F_DbSystem::deregisterForEvent( +void FLMAPI F_DbSystem::deregisterForEvent( eEventCategory eCategory, IF_EventClient * pEventClient) { @@ -4030,12 +3189,12 @@ void XFLMAPI F_DbSystem::deregisterForEvent( Desc: Returns TRUE if the specified error indicates that the database is corrupt ****************************************************************************/ -RCODE XFLMAPI F_DbSystem::getNextMetaphone( +RCODE FLMAPI F_DbSystem::getNextMetaphone( IF_IStream * pIStream, FLMUINT * puiMetaphone, FLMUINT * puiAltMetaphone) { - return( flmGetNextMetaphone( + return( f_getNextMetaphone( pIStream, puiMetaphone, puiAltMetaphone)); } @@ -4043,7 +3202,7 @@ RCODE XFLMAPI F_DbSystem::getNextMetaphone( Desc: Returns TRUE if the specified error indicates that the database is corrupt ****************************************************************************/ -FLMBOOL XFLMAPI F_DbSystem::errorIsFileCorrupt( +FLMBOOL FLMAPI F_DbSystem::errorIsFileCorrupt( RCODE rc) { FLMBOOL bIsCorrupt = FALSE; @@ -4065,286 +3224,12 @@ FLMBOOL XFLMAPI F_DbSystem::errorIsFileCorrupt( return( bIsCorrupt); } -/**************************************************************************** -Desc: -****************************************************************************/ -FINLINE FLMBYTE flmShiftRightRetByte( - FLMUINT64 ui64Num, - FLMBYTE ucBits) -{ - return( ucBits < 64 ? (FLMBYTE)(ui64Num >> ucBits) : 0); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMUINT flmGetSENByteCount( - FLMUINT64 ui64Num) -{ - FLMUINT uiCount = 0; - - if( ui64Num < 0x80) - { - return( 1); - } - - while( ui64Num) - { - uiCount++; - ui64Num >>= 7; - } - - // If the high bit is set, the counter will be incremented 1 beyond - // the actual number of bytes need to represent the SEN. We will need - // to re-visit this if we ever go beyond 64-bits. - - return( uiCount < FLM_MAX_SEN_LEN ? uiCount : FLM_MAX_SEN_LEN); -} - -/**************************************************************************** -Desc: Encodes a number as a SEN -****************************************************************************/ -FLMUINT flmEncodeSEN( - FLMUINT64 ui64Value, - FLMBYTE ** ppucBuffer, - FLMUINT uiSizeWanted) -{ - FLMBYTE * pucBuffer = *ppucBuffer; - FLMUINT uiSenLen = flmGetSENByteCount( ui64Value); - - flmAssert( uiSizeWanted <= FLM_MAX_SEN_LEN && - (!uiSizeWanted || uiSizeWanted >= uiSenLen)); - - uiSenLen = uiSizeWanted > uiSenLen ? uiSizeWanted : uiSenLen; - - if( uiSenLen == 1) - { - *pucBuffer++ = (FLMBYTE)ui64Value; - } - else - { - FLMUINT uiTmp = (uiSenLen - 1) << 3; - - *pucBuffer++ = ucSENPrefixArray[ uiSenLen] + - flmShiftRightRetByte( ui64Value, (FLMBYTE)uiTmp); - while( uiTmp) - { - uiTmp -= 8; - *pucBuffer++ = flmShiftRightRetByte( ui64Value, (FLMBYTE)uiTmp); - } - } - - *ppucBuffer = pucBuffer; - return( uiSenLen); -} - -/**************************************************************************** -Desc: Encodes a number as a SEN -****************************************************************************/ -RCODE flmEncodeSEN( - FLMUINT64 ui64Value, - FLMBYTE ** ppucBuffer, - FLMBYTE * pucEnd) -{ - RCODE rc = NE_XFLM_OK; - FLMBYTE * pucBuffer = *ppucBuffer; - FLMUINT uiSenLen = flmGetSENByteCount( ui64Value); - - if( *ppucBuffer + uiSenLen > pucEnd) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_CONV_DEST_OVERFLOW); - goto Exit; - } - - if( uiSenLen == 1) - { - *pucBuffer++ = (FLMBYTE)ui64Value; - } - else - { - FLMUINT uiTmp = (uiSenLen - 1) << 3; - - *pucBuffer++ = ucSENPrefixArray[ uiSenLen] + - flmShiftRightRetByte( ui64Value, (FLMBYTE)uiTmp); - while( uiTmp) - { - uiTmp -= 8; - *pucBuffer++ = flmShiftRightRetByte( ui64Value, (FLMBYTE)uiTmp); - } - } - - *ppucBuffer = pucBuffer; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Encodes a number as a SEN -****************************************************************************/ -FLMUINT flmEncodeSENKnownLength( - FLMUINT64 ui64Value, - FLMUINT uiSenLen, - FLMBYTE ** ppucBuffer) -{ - FLMBYTE * pucBuffer = *ppucBuffer; - - if( uiSenLen == 1) - { - *pucBuffer++ = (FLMBYTE)ui64Value; - } - else - { - FLMUINT uiTmp = (uiSenLen - 1) << 3; - - *pucBuffer++ = ucSENPrefixArray[ uiSenLen] + - flmShiftRightRetByte( ui64Value, (FLMBYTE)uiTmp); - while( uiTmp) - { - uiTmp -= 8; - *pucBuffer++ = flmShiftRightRetByte( ui64Value, (FLMBYTE)uiTmp); - } - } - - *ppucBuffer = pucBuffer; - return( uiSenLen); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE flmDecodeSEN64( - const FLMBYTE ** ppucBuffer, - const FLMBYTE * pucEnd, - FLMUINT64 * pui64Value) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiSENLength; - const FLMBYTE * pucBuffer = *ppucBuffer; - - uiSENLength = gv_ucSENLengthArray[ *pucBuffer]; - if( pucBuffer + uiSENLength > pucEnd) - { - if (pui64Value) - { - *pui64Value = 0; - } - rc = RC_SET( NE_XFLM_BAD_SEN); - goto Exit; - } - - if (pui64Value) - { - switch( uiSENLength) - { - case 1: - *pui64Value = *pucBuffer; - break; - - case 2: - *pui64Value = (((FLMUINT64)(*pucBuffer & 0x3F)) << 8) + pucBuffer[ 1]; - break; - - case 3: - *pui64Value = (((FLMUINT64)(*pucBuffer & 0x1F)) << 16) + - (((FLMUINT64)pucBuffer[ 1]) << 8) + pucBuffer[ 2]; - break; - - case 4: - *pui64Value = (((FLMUINT64)(*pucBuffer & 0x0F)) << 24) + - (((FLMUINT64)pucBuffer[ 1]) << 16) + - (((FLMUINT64)pucBuffer[ 2]) << 8) + pucBuffer[ 3]; - break; - - case 5: - *pui64Value = (((FLMUINT64)(*pucBuffer & 0x07)) << 32) + - (((FLMUINT64)pucBuffer[ 1]) << 24) + - (((FLMUINT64)pucBuffer[ 2]) << 16) + - (((FLMUINT64)pucBuffer[ 3]) << 8) + pucBuffer[ 4]; - break; - - case 6: - *pui64Value = (((FLMUINT64)(*pucBuffer & 0x03)) << 40) + - (((FLMUINT64)pucBuffer[ 1]) << 32) + - (((FLMUINT64)pucBuffer[ 2]) << 24) + - (((FLMUINT64)pucBuffer[ 3]) << 16) + - (((FLMUINT64)pucBuffer[ 4]) << 8) + pucBuffer[ 5]; - break; - - case 7: - *pui64Value = (((FLMUINT64)(*pucBuffer & 0x01)) << 48) + - (((FLMUINT64)pucBuffer[ 1]) << 40) + - (((FLMUINT64)pucBuffer[ 2]) << 32) + - (((FLMUINT64)pucBuffer[ 3]) << 24) + - (((FLMUINT64)pucBuffer[ 4]) << 16) + - (((FLMUINT64)pucBuffer[ 5]) << 8) + pucBuffer[ 6]; - break; - - case 8: - *pui64Value = (((FLMUINT64)pucBuffer[ 1]) << 48) + - (((FLMUINT64)pucBuffer[ 2]) << 40) + - (((FLMUINT64)pucBuffer[ 3]) << 32) + - (((FLMUINT64)pucBuffer[ 4]) << 24) + - (((FLMUINT64)pucBuffer[ 5]) << 16) + - (((FLMUINT64)pucBuffer[ 6]) << 8) + pucBuffer[ 7]; - break; - - case 9: - *pui64Value = (((FLMUINT64)pucBuffer[ 1]) << 56) + - (((FLMUINT64)pucBuffer[ 2]) << 48) + - (((FLMUINT64)pucBuffer[ 3]) << 40) + - (((FLMUINT64)pucBuffer[ 4]) << 32) + - (((FLMUINT64)pucBuffer[ 5]) << 24) + - (((FLMUINT64)pucBuffer[ 6]) << 16) + - (((FLMUINT64)pucBuffer[ 7]) << 8) + pucBuffer[ 8]; - break; - - default: - *pui64Value = 0; - flmAssert( 0); - break; - } - } - -Exit: - - *ppucBuffer = pucBuffer + uiSENLength; - - return( rc); -} - -/**************************************************************************** -Desc: COM query interface -****************************************************************************/ -RCODE XFLMAPI F_DbSystem::QueryInterface( - RXFLMIID riid, - void ** ppvInt) -{ - RCODE rc = NE_XFLM_OK; - - if( (f_memcmp(&riid, &Internal_IID_IF_DbSystem, - sizeof( Internal_IID_IF_DbSystem)) == 0) || - (f_memcmp(&riid, &Internal_IID_XFLMIUnknown, - sizeof( Internal_IID_XFLMIUnknown)) == 0) ) - { - *ppvInt = this; - AddRef(); - } - else - { - rc = RC_SET( NE_XFLM_UNSUPPORTED_INTERFACE); - } - - return( rc); -} - /**************************************************************************** Desc: Increment the database system use count ****************************************************************************/ -FLMINT XFLMAPI F_DbSystem::AddRef(void) +FLMINT FLMAPI F_DbSystem::AddRef(void) { - FLMINT iRefCnt = flmAtomicInc( &m_refCnt); + FLMINT iRefCnt = f_atomicInc( &m_refCnt); // Note: We don't bother with a call to LockModule() here because // it's done in the constructor. In fact, it's unlikely that @@ -4358,9 +3243,9 @@ FLMINT XFLMAPI F_DbSystem::AddRef(void) /**************************************************************************** Desc: Decrement the database system use count ****************************************************************************/ -FLMINT XFLMAPI F_DbSystem::Release(void) +FLMINT FLMAPI F_DbSystem::Release(void) { - FLMINT iRefCnt = flmAtomicDec( &m_refCnt); + FLMINT iRefCnt = f_atomicDec( &m_refCnt); if (iRefCnt == 0) { @@ -4370,181 +3255,15 @@ FLMINT XFLMAPI F_DbSystem::Release(void) return( iRefCnt); } -/**************************************************************************** -Desc: Returns a pointer to the ASCII string representation - of a return code. -****************************************************************************/ -const char * F_DbSystem::errorString( - RCODE rc) -{ - const char * pszErrorStr; - - if( rc == NE_XFLM_OK) - { - pszErrorStr = "NE_XFLM_OK"; - } - else if( rc > NE_XFLM_FIRST_COMMON_ERROR && - rc < NE_XFLM_LAST_COMMON_ERROR) - { - pszErrorStr = gv_FlmCommonErrors[ - rc - NE_XFLM_FIRST_COMMON_ERROR - 1].pszErrorStr; - } - else if( rc > NE_XFLM_FIRST_GENERAL_ERROR && - rc < NE_XFLM_LAST_GENERAL_ERROR) - { - pszErrorStr = gv_FlmGeneralErrors[ - rc - NE_XFLM_FIRST_GENERAL_ERROR - 1].pszErrorStr; - } - else if( rc > NE_XFLM_FIRST_DOM_ERROR && - rc < NE_XFLM_LAST_DOM_ERROR) - { - pszErrorStr = gv_FlmDomErrors[ - rc - NE_XFLM_FIRST_DOM_ERROR - 1].pszErrorStr; - } - else if( rc > NE_XFLM_FIRST_IO_ERROR && - rc < NE_XFLM_LAST_IO_ERROR) - { - pszErrorStr = gv_FlmIoErrors[ - rc - NE_XFLM_FIRST_IO_ERROR - 1].pszErrorStr; - } - else if( rc > NE_XFLM_FIRST_NET_ERROR && - rc < NE_XFLM_LAST_NET_ERROR) - { - pszErrorStr = gv_FlmNetErrors[ - rc - NE_XFLM_FIRST_NET_ERROR - 1].pszErrorStr; - } - else if( rc > NE_XFLM_FIRST_QUERY_ERROR && - rc < NE_XFLM_LAST_QUERY_ERROR) - { - pszErrorStr = gv_FlmQueryErrors[ - rc - NE_XFLM_FIRST_QUERY_ERROR - 1].pszErrorStr; - } - else if( rc > NE_XFLM_FIRST_STREAM_ERROR && - rc < NE_XFLM_LAST_STREAM_ERROR) - { - pszErrorStr = gv_FlmStreamErrors[ - rc - NE_XFLM_FIRST_STREAM_ERROR - 1].pszErrorStr; - } - else if( rc > NE_XFLM_FIRST_NICI_ERROR && - rc < NE_XFLM_LAST_NICI_ERROR) - { - pszErrorStr = gv_FlmNiciErrors[ - rc - NE_XFLM_FIRST_NICI_ERROR - 1].pszErrorStr; - } - else - { - pszErrorStr = "Unknown error"; - } - - return( pszErrorStr); -} - -/**************************************************************************** -Desc: Checks the error code mapping tables on startup -****************************************************************************/ -RCODE F_DbSystem::checkErrorCodeTables( void) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiLoop; - - for( uiLoop = 0; - uiLoop < (NE_XFLM_LAST_GENERAL_ERROR - NE_XFLM_FIRST_GENERAL_ERROR - 1); - uiLoop++) - { - if( gv_FlmGeneralErrors[ uiLoop].rc != - (RCODE)(uiLoop + NE_XFLM_FIRST_GENERAL_ERROR + 1)) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_BAD_RCODE_TABLE); - goto Exit; - } - } - - for( uiLoop = 0; - uiLoop < (NE_XFLM_LAST_DOM_ERROR - NE_XFLM_FIRST_DOM_ERROR - 1); - uiLoop++) - { - if( gv_FlmDomErrors[ uiLoop].rc != - (RCODE)(uiLoop + NE_XFLM_FIRST_DOM_ERROR + 1)) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_BAD_RCODE_TABLE); - goto Exit; - } - } - - for( uiLoop = 0; - uiLoop < (NE_XFLM_LAST_IO_ERROR - NE_XFLM_FIRST_IO_ERROR - 1); - uiLoop++) - { - if( gv_FlmIoErrors[ uiLoop].rc != - (RCODE)(uiLoop + NE_XFLM_FIRST_IO_ERROR + 1)) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_BAD_RCODE_TABLE); - goto Exit; - } - } - - for( uiLoop = 0; - uiLoop < (NE_XFLM_LAST_NET_ERROR - NE_XFLM_FIRST_NET_ERROR - 1); - uiLoop++) - { - if( gv_FlmNetErrors[ uiLoop].rc != - (RCODE)(uiLoop + NE_XFLM_FIRST_NET_ERROR + 1)) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_BAD_RCODE_TABLE); - goto Exit; - } - } - - for( uiLoop = 0; - uiLoop < (NE_XFLM_LAST_QUERY_ERROR - NE_XFLM_FIRST_QUERY_ERROR - 1); - uiLoop++) - { - if( gv_FlmQueryErrors[ uiLoop].rc != - (RCODE)(uiLoop + NE_XFLM_FIRST_QUERY_ERROR + 1)) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_BAD_RCODE_TABLE); - goto Exit; - } - } - - for( uiLoop = 0; - uiLoop < (NE_XFLM_LAST_STREAM_ERROR - NE_XFLM_FIRST_STREAM_ERROR - 1); - uiLoop++) - { - if( gv_FlmStreamErrors[ uiLoop].rc != - (RCODE)(uiLoop + NE_XFLM_FIRST_STREAM_ERROR + 1)) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_BAD_RCODE_TABLE); - goto Exit; - } - } - - for( uiLoop = 0; - uiLoop < (NE_XFLM_LAST_NICI_ERROR - NE_XFLM_FIRST_NICI_ERROR - 1); - uiLoop++) - { - if( gv_FlmNiciErrors[ uiLoop].rc != - (RCODE)(uiLoop + NE_XFLM_FIRST_NICI_ERROR + 1)) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_BAD_RCODE_TABLE); - goto Exit; - } - } - -Exit: - - return( rc); -} - /**************************************************************************** Desc: Allocates an F_DbSystem object for non-COM applications ****************************************************************************/ -XFLMEXP RCODE XFLMAPI FlmAllocDbSystem( +FLMEXP RCODE FLMAPI FlmAllocDbSystem( IF_DbSystem ** ppDbSystem) { flmAssert( ppDbSystem && *ppDbSystem == NULL); - if( (*ppDbSystem = (IF_DbSystem *)f_new F_DbSystem) == NULL) + if( (*ppDbSystem = f_new F_DbSystem) == NULL) { return( RC_SET( NE_XFLM_MEM)); } @@ -4595,21 +3314,15 @@ RCODE F_DbSystem::readIniFile() { RCODE rc = NE_XFLM_OK; FLMBOOL bMutexLocked = FALSE; - F_IniFile * pIniFile = NULL; + IF_IniFile * pIniFile = NULL; char szIniFileName [F_PATH_MAX_SIZE]; FLMUINT uiParamValue; FLMUINT uiMaxDirtyCache; FLMUINT uiLowDirtyCache; // Initialize the ini file object... - - if ((pIniFile = f_new F_IniFile) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if (RC_BAD( rc = pIniFile->Init())) + + if( RC_BAD( rc = FlmAllocIniFile( &pIniFile))) { goto Exit; } @@ -4625,7 +3338,7 @@ RCODE F_DbSystem::readIniFile() goto Exit; } - if (RC_BAD( rc = pIniFile->Read( szIniFileName))) + if (RC_BAD( rc = pIniFile->read( szIniFileName))) { goto Exit; } @@ -4673,21 +3386,15 @@ Desc: Given a tag and a value this function will open/create the NOTE: This function expects gv_XFlmSysData.hIniMutex to already be locked! ****************************************************************************/ -RCODE XFLMAPI F_DbSystem::updateIniFile( +RCODE FLMAPI F_DbSystem::updateIniFile( const char * pszParamName, const char * pszValue) { RCODE rc = NE_XFLM_OK; - F_IniFile * pIniFile = NULL; + IF_IniFile * pIniFile = NULL; char szIniFileName [F_PATH_MAX_SIZE]; - - if ((pIniFile = f_new F_IniFile) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if (RC_BAD( rc = pIniFile->Init())) + + if( RC_BAD( rc = FlmAllocIniFile( &pIniFile))) { goto Exit; } @@ -4698,17 +3405,17 @@ RCODE XFLMAPI F_DbSystem::updateIniFile( goto Exit; } - if (RC_BAD( rc = pIniFile->Read( szIniFileName))) + if (RC_BAD( rc = pIniFile->read( szIniFileName))) { goto Exit; } - if (RC_BAD( rc = pIniFile->SetParam( pszParamName, pszValue))) + if (RC_BAD( rc = pIniFile->setParam( pszParamName, pszValue))) { goto Exit; } - if (RC_BAD( rc = pIniFile->Write())) + if (RC_BAD( rc = pIniFile->write())) { goto Exit; } @@ -4723,7 +3430,7 @@ Exit: Desc: Sets the parameters for controlling cache. ****************************************************************************/ RCODE F_DbSystem::setCacheParams( - F_IniFile * pIniFile) + IF_IniFile * pIniFile) { RCODE rc = NE_XFLM_OK; char * pszCacheParam = NULL; @@ -4930,12 +3637,12 @@ Exit: Desc: Gets a string parameter from the .ini file. ****************************************************************************/ FSTATIC void flmGetStringParam( - const char * pszParamName, - char ** ppszValue, - F_IniFile * pIniFile) + const char * pszParamName, + char ** ppszValue, + IF_IniFile * pIniFile) { flmAssert( pIniFile); - (void)pIniFile->GetParam( pszParamName, ppszValue); + (void)pIniFile->getParam( pszParamName, ppszValue); } /**************************************************************************** @@ -4987,10 +3694,10 @@ FSTATIC void flmGetUintParam( const char * pszParamName, FLMUINT uiDefaultValue, FLMUINT * puiUint, - F_IniFile * pIniFile) + IF_IniFile * pIniFile) { flmAssert( pIniFile); - if (!pIniFile->GetParam( pszParamName, puiUint)) + if (!pIniFile->getParam( pszParamName, puiUint)) { *puiUint = uiDefaultValue; } @@ -5003,10 +3710,10 @@ void flmGetBoolParam( const char * pszParamName, FLMBOOL bDefaultValue, FLMBOOL * pbBool, - F_IniFile * pIniFile) + IF_IniFile * pIniFile) { flmAssert( pIniFile); - if (!pIniFile->GetParam( pszParamName, pbBool)) + if (!pIniFile->getParam( pszParamName, pbBool)) { *pbBool = bDefaultValue; } @@ -5017,12 +3724,11 @@ Desc: ****************************************************************************/ FSTATIC RCODE flmGetIniFileName( FLMBYTE * pszIniFileName, - FLMUINT uiBufferSz - ) + FLMUINT uiBufferSz) { - RCODE rc = NE_XFLM_OK; - FLMUINT uiFileNameLen = 0; - F_DirHdl * pDirHdl = NULL; + RCODE rc = NE_XFLM_OK; + FLMUINT uiFileNameLen = 0; + IF_DirHdl * pDirHdl = NULL; if (!uiBufferSz) { @@ -5041,21 +3747,16 @@ FSTATIC RCODE flmGetIniFileName( { // Perhaps we can find a data directory. If there is one, we will // look in there. - - if( (pDirHdl = f_new F_DirHdl) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - if( RC_OK( rc = pDirHdl->OpenDir( (char *)".", (char *)"data"))) + if( RC_OK( rc = gv_XFlmSysData.pFileSystem->openDir( + (char *)".", (char *)"data", &pDirHdl))) { - if (RC_OK( rc = pDirHdl->Next())) + if (RC_OK( rc = pDirHdl->next())) { - if (pDirHdl->CurrentItemIsDir()) + if (pDirHdl->currentItemIsDir()) { // Directory exists. We will look there. - f_strcpy( pszIniFileName, "data"); + f_strcpy( (char *)pszIniFileName, "data"); } else { @@ -5074,11 +3775,12 @@ NoDataDir: // Data directory does not exist. We will look in the // current (default) dir. - f_strcpy( pszIniFileName, "."); + f_strcpy( (char *)pszIniFileName, "."); } } - gv_pFileSystem->pathAppend( (char *)pszIniFileName, XFLM_INI_FILE_NAME); + gv_XFlmSysData.pFileSystem->pathAppend( + (char *)pszIniFileName, XFLM_INI_FILE_NAME); Exit: @@ -5089,3 +3791,219 @@ Exit: return( rc); } + +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE FLMAPI F_DbSystem::openBufferIStream( + const char * pucBuffer, + FLMUINT uiLength, + IF_PosIStream ** ppIStream) +{ + return( FlmOpenBufferIStream( pucBuffer, uiLength, ppIStream)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE FLMAPI F_DbSystem::openFileIStream( + const char * pszPath, + IF_PosIStream ** ppIStream) +{ + return( FlmOpenFileIStream( pszPath, ppIStream)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE FLMAPI F_DbSystem::openMultiFileIStream( + const char * pszDirectory, + const char * pszBaseName, + IF_IStream ** ppIStream) +{ + return( FlmOpenMultiFileIStream( pszDirectory, pszBaseName, ppIStream)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE FLMAPI F_DbSystem::openBufferedIStream( + IF_IStream * pSourceIStream, + FLMUINT uiBufferSize, + IF_IStream ** ppIStream) +{ + return( FlmOpenBufferedIStream( pSourceIStream, uiBufferSize, ppIStream)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE FLMAPI F_DbSystem::openUncompressingIStream( + IF_IStream * pIStream, + IF_IStream ** ppIStream) +{ + return( FlmOpenUncompressingIStream( pIStream, ppIStream)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE FLMAPI F_DbSystem::openFileOStream( + const char * pszFileName, + FLMBOOL bTruncateIfExists, + IF_OStream ** ppOStream) +{ + return( FlmOpenFileOStream( pszFileName, bTruncateIfExists, ppOStream)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE FLMAPI F_DbSystem::openMultiFileOStream( + const char * pszDirectory, + const char * pszBaseName, + FLMUINT uiMaxFileSize, + FLMBOOL bOkToOverwrite, + IF_OStream ** ppStream) +{ + return( FlmOpenMultiFileOStream( pszDirectory, pszBaseName, + uiMaxFileSize, bOkToOverwrite, ppStream)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE FLMAPI F_DbSystem::removeMultiFileStream( + const char * pszDirectory, + const char * pszBaseName) +{ + return( FlmRemoveMultiFileStream( pszDirectory, pszBaseName)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE FLMAPI F_DbSystem::openBufferedOStream( + IF_OStream * pOStream, + FLMUINT uiBufferSize, + IF_OStream ** ppOStream) +{ + return( FlmOpenBufferedOStream( pOStream, uiBufferSize, ppOStream)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE FLMAPI F_DbSystem::openCompressingOStream( + IF_OStream * pOStream, + IF_OStream ** ppOStream) +{ + return( FlmOpenCompressingOStream( pOStream, ppOStream)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE FLMAPI F_DbSystem::writeToOStream( + IF_IStream * pIStream, + IF_OStream * pOStream) +{ + return( FlmWriteToOStream( pIStream, pOStream)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE FLMAPI F_DbSystem::openBase64Encoder( + IF_IStream * pInputStream, + FLMBOOL bInsertLineBreaks, + IF_IStream ** ppEncodedStream) +{ + return( FlmOpenBase64EncoderIStream( pInputStream, + bInsertLineBreaks, ppEncodedStream)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE FLMAPI F_DbSystem::openBase64Decoder( + IF_IStream * pInputStream, + IF_IStream ** ppDecodedStream) +{ + return( FlmOpenBase64DecoderIStream( pInputStream, ppDecodedStream)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE FLMAPI F_DbSystem::createIFResultSet( + IF_ResultSet ** ifppResultSet) +{ + return( FlmAllocResultSet( ifppResultSet)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMBOOL FLMAPI F_DbSystem::uniIsUpper( + FLMUNICODE uChar) +{ + return( f_uniIsUpper( uChar)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMBOOL FLMAPI F_DbSystem::uniIsLower( + FLMUNICODE uChar) +{ + return( f_uniIsLower( uChar)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMBOOL FLMAPI F_DbSystem::uniIsAlpha( + FLMUNICODE uChar) +{ + return( f_uniIsAlpha( uChar)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMBOOL FLMAPI F_DbSystem::uniIsDecimalDigit( + FLMUNICODE uChar) +{ + return( f_uniIsDecimalDigit( uChar)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMUNICODE FLMAPI F_DbSystem::uniToLower( + FLMUNICODE uChar) +{ + return( f_uniToLower( uChar)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE FLMAPI F_DbSystem::nextUCS2Char( + const FLMBYTE ** ppszUTF8, + const FLMBYTE * pszEndOfUTF8String, + FLMUNICODE * puzChar) +{ + return( f_nextUCS2Char( ppszUTF8, pszEndOfUTF8String, puzChar)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +RCODE FLMAPI F_DbSystem::numUCS2Chars( + const FLMBYTE * pszUTF8, + FLMUINT * puiNumChars) +{ + return( f_numUCS2Chars( pszUTF8, puiNumChars)); +} diff --git a/xflaim/src/ftk.h b/xflaim/src/ftk.h deleted file mode 100644 index c1554d5..0000000 --- a/xflaim/src/ftk.h +++ /dev/null @@ -1,3014 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Cross-platform macros, defines, etc. Must visit this file -// to port XFLAIM to another platform. -// -// Tabs: 3 -// -// Copyright (c) 1991-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: ftk.h 3123 2006-01-24 17:19:50 -0700 (Tue, 24 Jan 2006) ahodgkinson $ -//------------------------------------------------------------------------------ - -#ifndef FTK_H -#define FTK_H - - #ifndef FLM_PLATFORM_CONFIGURED - #error Platform not configured - #endif - - /**************************************************************************** - Desc: Internal return code macros - ****************************************************************************/ - #ifdef FLM_DEBUG - RCODE flmMakeErr( - RCODE rc, - const char * pszFile, - int iLine, - FLMBOOL bAssert); - - #define RC_SET( rc) \ - flmMakeErr( rc, __FILE__, __LINE__, FALSE) - - #define RC_SET_AND_ASSERT( rc) \ - flmMakeErr( rc, __FILE__, __LINE__, TRUE) - - #define RC_UNEXPECTED_ASSERT( rc) \ - flmMakeErr( rc, __FILE__, __LINE__, TRUE) - #else - #define RC_SET( rc) (rc) - #define RC_SET_AND_ASSERT( rc) (rc) - #define RC_UNEXPECTED_ASSERT( rc) - #endif - - #define F_SEM_WAITFOREVER (0xFFFFFFFF) - - /**************************************************************************** - Desc: NLM - ****************************************************************************/ - #if defined( FLM_NLM) - - #if defined( FLM_WATCOM_NLM) - #pragma warning 007 9 - - // Disable "Warning! W549: col(XX) 'sizeof' operand contains - // compiler generated information" - - #pragma warning 549 9 - - // Disable "Warning! W656: col(1) define this function inside its class - // definition (may improve code quality)" - - #pragma warning 656 9 - #endif - - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - - // The typedef for va_list in stdarg.h do not function properly when - // a va_list is passed down multiple layers as a pointer (va_list *). - // Therefore, the following definitions/typedefs were taken from a - // "fixed" version of stdarg.h implemented by DS. - - typedef unsigned long f_va_list; - - #define f_argsize(x) \ - ((sizeof(x)+sizeof(int)-1) & ~(sizeof(int)-1)) - - #define f_va_start(ap, parmN) \ - ((void)((ap) = (unsigned long)&(parmN) + f_argsize(parmN))) - - #define f_va_arg(ap, type) \ - (*(type *)(((ap) += f_argsize(type)) - (f_argsize(type)))) - - #define f_va_end(ap) ((void)0) - #define FSTATIC - - #ifndef _SIZE_T - #define _SIZE_T - typedef unsigned int size_t; - #endif - - #ifndef _WCHAR_T - #define _WCHAR_T - typedef unsigned short wchar_t; - #endif - - #ifndef WCHAR - #define WCHAR wchar_t - #endif - - #ifndef LONG - #define LONG unsigned long - #endif - - #ifndef BYTE - #define BYTE unsigned char - #endif - - #ifndef UINT - #define UINT unsigned int - #endif - - typedef void * MUTEX; - typedef MUTEX F_MUTEX; - typedef MUTEX * F_MUTEX_p; - - #define F_MUTEX_NULL 0 - - typedef void * SEMAPHORE; - typedef unsigned long ERROR; - - extern "C" SEMAPHORE kSemaphoreAlloc( - BYTE * pSemaName, - UINT SemaCount); - - extern "C" ERROR kSemaphoreFree( - SEMAPHORE SemaHandle); - - extern "C" ERROR kSemaphoreWait( - SEMAPHORE SemaHandle); - - extern "C" ERROR kSemaphoreTimedWait( - SEMAPHORE SemaHandle, - UINT MilliSecondTimeOut); - - extern "C" ERROR kSemaphoreSignal( - SEMAPHORE SemaHandle); - - extern "C" UINT kSemaphoreExamineCount( - SEMAPHORE SemaHandle); - - extern "C" MUTEX kMutexAlloc( - BYTE * MutexName); - - extern "C" ERROR kMutexFree( - MUTEX MutexHandle); - - extern "C" ERROR kMutexLock( - MUTEX MutexHandle); - - extern "C" ERROR kMutexUnlock( - MUTEX MutexHandle); - - // External Netware Symbols - - extern "C" FLMUINT f_getNLMHandle( void); - - extern "C" RCODE f_netwareStartup( void); - - extern "C" void f_netwareShutdown( void); - - #define f_stricmp(str1,str2) \ - strcasecmp((char *)(str1),(char *)(str2)) - - #define f_strnicmp(str1,str2,size_t) \ - strncasecmp((char *)(str1),(char *)(str2),size_t) - - #define f_memmove( dest, src, len) \ - memmove( (void*)(dest), (void*)(src), len) - - #define f_memset( src, chr, size) \ - memset((void *)(src),(chr),(size_t)(size)) - - #define f_memcmp( str1, str2, length) \ - memcmp((void *)(str1), (void *)(str2),(size_t)(length)) - - #define f_strcat( dest, src) \ - strcat( (char*)(dest), (char*)(src)) - - #define f_strchr( str, value) \ - strchr( (char*)str, (int)value) - - #define f_strcmp( str1, str2) \ - strcmp( (char*)(str1), (char*)(str2)) - - #define f_strcpy( dest, src) \ - strcpy( (char*)(dest), (char*)(src)) - - #define f_strncpy( dest, src, length) \ - strncpy( (char*)(dest), (char*)(src), (size_t)(length)) - - #define f_strlen( str) \ - strlen( (char*)(str)) - - #define f_strncmp( str1, str2, size) \ - strncmp( (char*)(str1), (char*)(str2), (size_t)(size)) - - #define f_strrchr( str, value ) \ - strrchr( (char*)(str), (int)value) - - #define f_strstr( str1, str2) \ - (char *)strstr( (char*)(str1), (char*)(str2)) - - #define f_strncat( str1, str2, n) \ - strncat( (char *)(str1), (char *)(str2), n) - - #define f_strupr( str) \ - strupr( (char *)(str)) - - #endif - - /**************************************************************************** - Desc: WIN - ****************************************************************************/ - #if defined( FLM_WIN) - - #ifndef WIN32_LEAN_AND_MEAN - #define WIN32_LEAN_AND_MEAN - #endif - - #ifndef WIN32_EXTRA_LEAN - #define WIN32_EXTRA_LEAN - #endif - - // Enable critical section and spin count API to be visible in header - // file. - - #define _WIN32_WINNT 0x0403 - - #pragma pack( push, enter_windows, 8) - #include - #include - #include - #include - #include - #include - #include - #pragma pack( pop, enter_windows) - - // Conversion from XXX to YYY, possible loss of data - #pragma warning( disable : 4244) - - // Local variable XXX may be used without having been initialized - #pragma warning( disable : 4701) - - // Function XXX not inlined - #pragma warning( disable : 4710) - - #define FSTATIC static - - #define ENDLINE ENDLINE_CRLF - #define f_va_list va_list - #define f_va_start va_start - #define f_va_arg va_arg - #define f_va_end va_end - - typedef struct - { - FLMATOMIC locked; - #ifdef FLM_DEBUG - FLMUINT uiThreadId; - FLMATOMIC lockedCount; - FLMATOMIC waitCount; - #endif - } F_INTERLOCK; - - typedef F_INTERLOCK * F_MUTEX; - typedef F_INTERLOCK ** F_MUTEX_p; - #define F_MUTEX_NULL NULL - - typedef HANDLE F_SEM; - typedef HANDLE * F_SEM_p; - #define F_SEM_NULL NULL - - #define f_stricmp( str1, str2) \ - _stricmp((char *)(str1), (char *)(str2)) - - #define f_strnicmp( str1, str2, size) \ - _strnicmp((char *)(str1), (char *)(str2),(size_t)(size)) - - #define f_memmove( dest, src, length) \ - memmove((void *)(dest), (void *)(src),(size_t)(length)) - - #define f_memset( src, chr, size) \ - memset((void *)(src),(chr),(size_t)(size)) - - #define f_memcmp( str1, str2, length) \ - memcmp((void *)(str1), (void *)(str2),(size_t)(length)) - - #define f_strcat( dest, src) \ - strcat( (char*)(dest), (char*)(src)) - - #define f_strchr( str, value) \ - strchr( (char*)str, (int)value) - - #define f_strcmp( str1, str2) \ - strcmp( (char*)(str1), (char*)(str2)) - - #define f_strcpy( dest, src) \ - strcpy( (char*)(dest), (char*)(src)) - - #define f_strncpy( dest, src, length) \ - strncpy( (char*)(dest), (char*)(src), (size_t)(length)) - - #define f_strlen( str) \ - strlen( (char*)(str)) - - #define f_strncmp( str1, str2, size) \ - strncmp( (char*)(str1), (char*)(str2), (size_t)(size)) - - #define f_strrchr( str, value ) \ - strrchr( (char*)(str), (int)value) - - #define f_strstr( str1, str2) \ - (char *)strstr( (char*)(str1), (char*)(str2)) - - #define f_strncat( str1, str2, n) \ - strncat( (char *)(str1), (char *)(str2), n) - - #define f_strupr( str) \ - _strupr( (char *)(str)) - - #endif - - /**************************************************************************** - Desc: UNIX - ****************************************************************************/ - #if defined( FLM_UNIX) - - #define FSTATIC static - - #ifdef HAVE_CONFIG_H - #include "config.h" - #endif - - #ifdef FLM_AIX - #ifndef _LARGE_FILES - #define _LARGE_FILES - #endif - #include - #include - #include - #endif - - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - - #ifdef FLM_AIX - #include - #endif - - #ifdef FLM_OSX - #include - #endif - - #define f_stricmp(str1,str2) \ - strcasecmp((char *)(str1),(char *)(str2)) - - #define f_strnicmp(str1,str2,size_t) \ - strncasecmp((char *)(str1),(char *)(str2),size_t) - - #define f_memmove( dest, src, len) \ - memmove( (void*)(dest), (void*)(src), len) - - #define f_memset( src, chr, size) \ - memset((void *)(src),(chr),(size_t)(size)) - - #define f_memcmp( str1, str2, length) \ - memcmp((void *)(str1), (void *)(str2),(size_t)(length)) - - #define f_strcat( dest, src) \ - strcat( (char*)(dest), (char*)(src)) - - #define f_strchr( str, value) \ - strchr( (char*)str, (int)value) - - #define f_strcmp( str1, str2) \ - strcmp( (char*)(str1), (char*)(str2)) - - #define f_strcpy( dest, src) \ - strcpy( (char*)(dest), (char*)(src)) - - #define f_strncpy( dest, src, length) \ - strncpy( (char*)(dest), (char*)(src), (size_t)(length)) - - #define f_strlen( str) \ - strlen( (char*)(str)) - - #define f_strncmp( str1, str2, size) \ - strncmp( (char*)(str1), (char*)(str2), (size_t)(size)) - - #define f_strrchr( str, value ) \ - strrchr( (char*)(str), (int)value) - - #define f_strstr( str1, str2) \ - (char *)strstr( (char*)(str1), (char*)(str2)) - - #define f_strncat( str1, str2, n) \ - strncat( (char *)(str1), (char *)(str2), n) - - #define f_strupr( str) \ - strupr( (char *)(str)) - - #define f_va_list va_list - #define f_va_start va_start - #define f_va_arg va_arg - #define f_va_end va_end - - typedef pthread_mutex_t * F_MUTEX; - typedef F_MUTEX * F_MUTEX_p; - #define F_MUTEX_NULL NULL - - void f_mutexLock( - F_MUTEX hMutex); - - void f_mutexUnlock( - F_MUTEX hMutex); - - typedef struct - { - pthread_mutex_t lock; - pthread_cond_t cond; - int count; - } sema_t; - - typedef sema_t * F_SEM; - typedef F_SEM * F_SEM_p; - #define F_SEM_NULL NULL - - typedef int SOCKET; - #define INVALID_SOCKET -1 - - #endif - - /**************************************************************************** - Desc: Cross-platform inline functions - ****************************************************************************/ - FINLINE void f_memcpy( - void * pvDest, - const void * pvSrc, - FLMSIZET iSize) - { - if( iSize == 1) - { - *((FLMBYTE *)pvDest) = *((FLMBYTE *)pvSrc); - } - else - { - (void)memcpy( pvDest, pvSrc, iSize); - } - } - - #if defined( __va_copy) - #define f_va_copy(to, from) __va_copy(to, from) - #else - #define f_va_copy(to, from) ((to) = (from)) - #endif - - /**************************************************************************** - Desc: Internal base class - ****************************************************************************/ - class F_OSBase - { - public: - - F_OSBase() - { - m_refCnt = 1; - } - - virtual ~F_OSBase() - { - } - - FINLINE FLMUINT getRefCount( void) - { - return( m_refCnt); - } - - void * operator new( - FLMSIZET uiSize); - - #ifdef FLM_DEBUG - void * operator new( - FLMSIZET uiSize, - const char * pszFile, - int iLine); - #endif - - void operator delete( - void * ptr); - - void operator delete[]( - void * ptr); - - #if defined( FLM_DEBUG) && !defined( FLM_WATCOM_NLM) && !defined( FLM_SOLARIS) - void operator delete( - void * ptr, - const char *, // file - int); // line - #endif - - #if defined( FLM_DEBUG) && !defined( FLM_WATCOM_NLM) && !defined( FLM_SOLARIS) - void operator delete[]( - void * ptr, - const char *, // file - int); // line - #endif - - virtual FINLINE FLMINT XFLMAPI AddRef( void) - { - return( ++m_refCnt); - } - - virtual FINLINE FLMINT XFLMAPI Release( void) - { - FLMINT iRefCnt = --m_refCnt; - - if( !iRefCnt) - { - delete this; - } - - return( iRefCnt); - } - - protected: - - FLMATOMIC m_refCnt; - }; - - /**************************************************************************** - Desc: Base class - ****************************************************************************/ - class XF_Base - { - public: - - XF_Base() - { - } - - virtual ~XF_Base() - { - } - - void * operator new( - FLMSIZET uiSize); - - void * operator new[]( - FLMSIZET uiSize); - - #ifdef FLM_DEBUG - void * operator new( - FLMSIZET uiSize, - const char * pszFile, - int iLine); - #endif - - #ifdef FLM_DEBUG - void * operator new[]( - FLMSIZET uiSize, - const char * pszFile, - int iLine); - #endif - - void operator delete( - void * ptr); - - void operator delete[]( - void * ptr); - - #if defined( FLM_DEBUG) && !defined( FLM_WATCOM_NLM) && !defined( FLM_SOLARIS) - void operator delete( - void * ptr, - const char * file, - int line); - - void operator delete[]( - void * ptr, - const char * file, - int line); - #endif - - }; - - /**************************************************************************** - Desc: This class is used to do pool memory allocations. - ****************************************************************************/ - class F_Pool : public IF_Pool, public XF_Base - { - public: - - typedef struct PoolMemoryBlock - { - PoolMemoryBlock * pPrevBlock; - FLMUINT uiBlockSize; - FLMUINT uiFreeOffset; - FLMUINT uiFreeSize; - } MBLK; - - typedef struct - { - FLMUINT uiAllocBytes; - FLMUINT uiCount; - } POOL_STATS; - - F_Pool() - { - m_uiBytesAllocated = 0; - m_pLastBlock = NULL; - m_pPoolStats = NULL; - m_uiBlockSize = 0; - } - - ~F_Pool(); - - FINLINE void poolInit( - FLMUINT uiBlockSize) - { - m_uiBlockSize = uiBlockSize; - } - - void smartPoolInit( - POOL_STATS * pPoolStats); - - RCODE poolAlloc( - FLMUINT uiSize, - void ** ppvPtr); - - RCODE poolCalloc( - FLMUINT uiSize, - void ** ppvPtr); - - void poolFree( void); - - void poolReset( - void * pvMark, - FLMBOOL bReduceFirstBlock = FALSE); - - FINLINE void * poolMark( void) - { - return (void *)(m_pLastBlock - ? (FLMBYTE *)m_pLastBlock + m_pLastBlock->uiFreeOffset - : NULL); - } - - FINLINE FLMUINT getBlockSize( void) - { - return( m_uiBlockSize); - } - - FINLINE FLMUINT getBytesAllocated( void) - { - return( m_uiBytesAllocated); - } - - private: - - FINLINE void updateSmartPoolStats( void) - { - if (m_uiBytesAllocated) - { - if( (m_pPoolStats->uiAllocBytes + m_uiBytesAllocated) >= 0xFFFF0000) - { - m_pPoolStats->uiAllocBytes = - (m_pPoolStats->uiAllocBytes / m_pPoolStats->uiCount) * 100; - m_pPoolStats->uiCount = 100; - } - else - { - m_pPoolStats->uiAllocBytes += m_uiBytesAllocated; - m_pPoolStats->uiCount++; - } - m_uiBytesAllocated = 0; - } - } - - FINLINE void setInitialSmartPoolBlkSize( void) - { - // Determine starting block size: - // 1) average of bytes allocated / # of frees/resets (average size needed) - // 2) add 10% - to minimize extra allocs - - m_uiBlockSize = (m_pPoolStats->uiAllocBytes / m_pPoolStats->uiCount); - m_uiBlockSize += (m_uiBlockSize / 10); - - if (m_uiBlockSize < 512) - { - m_uiBlockSize = 512; - } - } - - void freeToMark( - void * pvMark); - - PoolMemoryBlock * m_pLastBlock; - FLMUINT m_uiBlockSize; - FLMUINT m_uiBytesAllocated; - POOL_STATS * m_pPoolStats; - }; - - /**************************************************************************** - CROSS PLATFORM DEFINITIONS - ****************************************************************************/ - #define F_UNREFERENCED_PARM( parm) \ - (void)parm - - #define f_min(a, b) \ - ((a) < (b) ? (a) : (b)) - - #define f_max(a, b) \ - ((a) < (b) ? (b) : (a)) - - #define f_swap( a, b, tmp) \ - ((tmp) = (a), (a) = (b), (b) = (tmp)) - - char * f_uwtoa( - FLMUINT16 value, - char * ptr); - - char * f_udtoa( - FLMUINT value, - char * ptr); - - char * f_wtoa( - FLMINT16 value, - char * ptr); - - char * f_dtoa( - FLMINT value, - char * ptr); - - char * f_ui64toa( - FLMUINT64 value, - char * ptr); - - char * f_i64toa( - FLMINT64 value, - char * ptr); - - FLMINT f_atoi( - char * ptr); - - FLMINT f_atol( - char * ptr); - - FLMINT f_atod( - char * ptr); - - FLMUINT f_atoud( - char * ptr, - FLMBOOL bAllowUnprefixedHex = FALSE); - - FLMUINT64 f_atou64( - char * pszBuf); - - FLMUINT f_unilen( - const FLMUNICODE * puzStr); - - FLMUNICODE * f_unicpy( - FLMUNICODE * puzDestStr, - const FLMUNICODE * puzSrcStr); - - FLMUNICODE f_unitolower( - FLMUNICODE uChar); - - FLMINT f_unicmp( - const FLMUNICODE * puzStr1, - const FLMUNICODE * puzStr2); - - FLMINT f_uniicmp( - const FLMUNICODE * puzStr1, - const FLMUNICODE * puzStr2); - - FLMINT f_uninativecmp( - const FLMUNICODE * puzStr1, - const char * pszStr2); - - FLMINT f_uninativencmp( - const FLMUNICODE * puzStr1, - const char * pszStr2, - FLMUINT uiCount); - - /**************************************************************************** - FLAIM's Assert Layer - - This section contains prototypes and macros for FLAIM's assert. This layer - enables FLAIM to redirect assert calls. - ****************************************************************************/ - - #ifdef FLM_DEBUG - - #ifdef FLM_DBG_LOG - void flmDbgLogFlush( void); - #endif - - #if defined( FLM_WIN) - #ifdef FLM_DBG_LOG - #define flmAssert( exp) \ - (void)( (exp) || (flmDbgLogFlush(), DebugBreak(), 0)) - #else - #define flmAssert( exp) \ - (void)( (exp) || (DebugBreak(), 0)) - #endif - - #elif defined( FLM_NLM) - extern "C" void EnterDebugger(void); - - #ifdef FLM_DBG_LOG - #define flmAssert( exp) \ - (void)( (exp) || (flmDbgLogFlush(), EnterDebugger(), 0)) - #else - #define flmAssert( exp) \ - (void)( (exp) || ( EnterDebugger(), 0)) - #endif - - #elif defined( FLM_UNIX) - #ifdef FLM_DBG_LOG - #define flmAssert( exp) \ - (void)( (exp) || (flmDbgLogFlush(), assert(0), 0)) - #else - #define flmAssert( exp) \ - (void)( (exp) || (assert(0), 0)) - #endif - - #else - #define flmAssert( exp) - #endif - - #else - #define flmAssert( exp) - #endif - - FLMUINT f_breakpoint( - FLMUINT uiBreakFlag); - - /**************************************************************************** - Character Value Constants - ****************************************************************************/ - - #define ASCII_TAB 0x09 - #define ASCII_NEWLINE 0x0A - #define ASCII_CR 0x0D - #define ASCII_CTRLZ 0x1A - #define ASCII_SPACE 0x20 - #define ASCII_DQUOTE 0x22 - #define ASCII_POUND 0x23 - #define ASCII_DOLLAR 0x24 - #define ASCII_SQUOTE 0x27 - #define ASCII_WILDCARD 0x2A - #define ASCII_PLUS 0x2B - #define ASCII_COMMA 0x2C - #define ASCII_DASH 0x2D - #define ASCII_MINUS 0x2D - #define ASCII_DOT 0x2E - #define ASCII_SLASH 0x2F - #define ASCII_COLON 0x3A - #define ASCII_SEMICOLON 0x3B - #define ASCII_EQUAL 0x3D - #define ASCII_QUESTIONMARK 0x3F - #define ASCII_AT 0x40 - #define ASCII_BACKSLASH 0x5C - #define ASCII_CARAT 0x5E - #define ASCII_UNDERSCORE 0x5F - #define ASCII_TILDE 0x7E - #define ASCII_AMP 0x26 - - #define ASCII_UPPER_A 0x41 - #define ASCII_UPPER_B 0x42 - #define ASCII_UPPER_C 0x43 - #define ASCII_UPPER_D 0x44 - #define ASCII_UPPER_E 0x45 - #define ASCII_UPPER_F 0x46 - #define ASCII_UPPER_G 0x47 - #define ASCII_UPPER_H 0x48 - #define ASCII_UPPER_I 0x49 - #define ASCII_UPPER_J 0x4A - #define ASCII_UPPER_K 0x4B - #define ASCII_UPPER_L 0x4C - #define ASCII_UPPER_M 0x4D - #define ASCII_UPPER_N 0x4E - #define ASCII_UPPER_O 0x4F - #define ASCII_UPPER_P 0x50 - #define ASCII_UPPER_Q 0x51 - #define ASCII_UPPER_R 0x52 - #define ASCII_UPPER_S 0x53 - #define ASCII_UPPER_T 0x54 - #define ASCII_UPPER_U 0x55 - #define ASCII_UPPER_V 0x56 - #define ASCII_UPPER_W 0x57 - #define ASCII_UPPER_X 0x58 - #define ASCII_UPPER_Y 0x59 - #define ASCII_UPPER_Z 0x5A - - #define ASCII_LOWER_A 0x61 - #define ASCII_LOWER_B 0x62 - #define ASCII_LOWER_C 0x63 - #define ASCII_LOWER_D 0x64 - #define ASCII_LOWER_E 0x65 - #define ASCII_LOWER_F 0x66 - #define ASCII_LOWER_G 0x67 - #define ASCII_LOWER_H 0x68 - #define ASCII_LOWER_I 0x69 - #define ASCII_LOWER_J 0x6A - #define ASCII_LOWER_K 0x6B - #define ASCII_LOWER_L 0x6C - #define ASCII_LOWER_M 0x6D - #define ASCII_LOWER_N 0x6E - #define ASCII_LOWER_O 0x6F - #define ASCII_LOWER_P 0x70 - #define ASCII_LOWER_Q 0x71 - #define ASCII_LOWER_R 0x72 - #define ASCII_LOWER_S 0x73 - #define ASCII_LOWER_T 0x74 - #define ASCII_LOWER_U 0x75 - #define ASCII_LOWER_V 0x76 - #define ASCII_LOWER_W 0x77 - #define ASCII_LOWER_X 0x78 - #define ASCII_LOWER_Y 0x79 - #define ASCII_LOWER_Z 0x7A - - #define ASCII_ZERO 0x30 - #define ASCII_ONE 0x31 - #define ASCII_TWO 0x32 - #define ASCII_THREE 0x33 - #define ASCII_FOUR 0x34 - #define ASCII_FIVE 0x35 - #define ASCII_SIX 0x36 - #define ASCII_SEVEN 0x37 - #define ASCII_EIGHT 0x38 - #define ASCII_NINE 0x39 - - #define NATIVE_SPACE ' ' - #define NATIVE_DOT '.' - #define NATIVE_PLUS '+' - #define NATIVE_MINUS '-' - #define NATIVE_WILDCARD '*' - #define NATIVE_QUESTIONMARK '?' - - #define NATIVE_UPPER_A 'A' - #define NATIVE_UPPER_F 'F' - #define NATIVE_UPPER_X 'X' - #define NATIVE_UPPER_Z 'Z' - #define NATIVE_LOWER_A 'a' - #define NATIVE_LOWER_F 'f' - #define NATIVE_LOWER_X 'x' - #define NATIVE_LOWER_Z 'z' - #define NATIVE_ZERO '0' - #define NATIVE_NINE '9' - - #define f_stringToAscii( str) - - #define f_toascii( native) \ - (native) - - #define f_tonative( ascii) \ - (ascii) - - #define f_toupper( native) \ - (((native) >= 'a' && (native) <= 'z') \ - ? (native) - 'a' + 'A' \ - : (native)) - - #define f_tolower( native) \ - (((native) >= 'A' && (native) <= 'Z') \ - ? (native) - 'A' + 'a' \ - : (native)) - - #define f_islower( native) \ - ((native) >= 'a' && (native) <= 'z') - - #ifndef FLM_ASCII_PLATFORM - #define FLM_ASCII_PLATFORM - #endif - - // Unicode character constants - - #define FLM_UNICODE_LINEFEED ((FLMUNICODE)10) - #define FLM_UNICODE_SPACE ((FLMUNICODE)32) - #define FLM_UNICODE_BANG ((FLMUNICODE)33) - #define FLM_UNICODE_QUOTE ((FLMUNICODE)34) - #define FLM_UNICODE_POUND ((FLMUNICODE)35) - #define FLM_UNICODE_DOLLAR ((FLMUNICODE)36) - #define FLM_UNICODE_PERCENT ((FLMUNICODE)37) - #define FLM_UNICODE_AMP ((FLMUNICODE)38) - #define FLM_UNICODE_APOS ((FLMUNICODE)39) - #define FLM_UNICODE_LPAREN ((FLMUNICODE)40) - #define FLM_UNICODE_RPAREN ((FLMUNICODE)41) - #define FLM_UNICODE_ASTERISK ((FLMUNICODE)42) - #define FLM_UNICODE_PLUS ((FLMUNICODE)43) - #define FLM_UNICODE_COMMA ((FLMUNICODE)44) - #define FLM_UNICODE_HYPHEN ((FLMUNICODE)45) - #define FLM_UNICODE_PERIOD ((FLMUNICODE)46) - #define FLM_UNICODE_FSLASH ((FLMUNICODE)47) - - #define FLM_UNICODE_0 ((FLMUNICODE)48) - #define FLM_UNICODE_1 ((FLMUNICODE)49) - #define FLM_UNICODE_2 ((FLMUNICODE)50) - #define FLM_UNICODE_3 ((FLMUNICODE)51) - #define FLM_UNICODE_4 ((FLMUNICODE)52) - #define FLM_UNICODE_5 ((FLMUNICODE)53) - #define FLM_UNICODE_6 ((FLMUNICODE)54) - #define FLM_UNICODE_7 ((FLMUNICODE)55) - #define FLM_UNICODE_8 ((FLMUNICODE)56) - #define FLM_UNICODE_9 ((FLMUNICODE)57) - - #define FLM_UNICODE_COLON ((FLMUNICODE)58) - #define FLM_UNICODE_SEMI ((FLMUNICODE)59) - #define FLM_UNICODE_LT ((FLMUNICODE)60) - #define FLM_UNICODE_EQ ((FLMUNICODE)61) - #define FLM_UNICODE_GT ((FLMUNICODE)62) - #define FLM_UNICODE_QUEST ((FLMUNICODE)63) - #define FLM_UNICODE_ATSIGN ((FLMUNICODE)64) - - #define FLM_UNICODE_A ((FLMUNICODE)65) - #define FLM_UNICODE_B ((FLMUNICODE)66) - #define FLM_UNICODE_C ((FLMUNICODE)67) - #define FLM_UNICODE_D ((FLMUNICODE)68) - #define FLM_UNICODE_E ((FLMUNICODE)69) - #define FLM_UNICODE_F ((FLMUNICODE)70) - #define FLM_UNICODE_G ((FLMUNICODE)71) - #define FLM_UNICODE_H ((FLMUNICODE)72) - #define FLM_UNICODE_I ((FLMUNICODE)73) - #define FLM_UNICODE_J ((FLMUNICODE)74) - #define FLM_UNICODE_K ((FLMUNICODE)75) - #define FLM_UNICODE_L ((FLMUNICODE)76) - #define FLM_UNICODE_M ((FLMUNICODE)77) - #define FLM_UNICODE_N ((FLMUNICODE)78) - #define FLM_UNICODE_O ((FLMUNICODE)79) - #define FLM_UNICODE_P ((FLMUNICODE)80) - #define FLM_UNICODE_Q ((FLMUNICODE)81) - #define FLM_UNICODE_R ((FLMUNICODE)82) - #define FLM_UNICODE_S ((FLMUNICODE)83) - #define FLM_UNICODE_T ((FLMUNICODE)84) - #define FLM_UNICODE_U ((FLMUNICODE)85) - #define FLM_UNICODE_V ((FLMUNICODE)86) - #define FLM_UNICODE_W ((FLMUNICODE)87) - #define FLM_UNICODE_X ((FLMUNICODE)88) - #define FLM_UNICODE_Y ((FLMUNICODE)89) - #define FLM_UNICODE_Z ((FLMUNICODE)90) - - #define FLM_UNICODE_LBRACKET ((FLMUNICODE)91) - #define FLM_UNICODE_BACKSLASH ((FLMUNICODE)92) - #define FLM_UNICODE_RBRACKET ((FLMUNICODE)93) - #define FLM_UNICODE_UNDERSCORE ((FLMUNICODE)95) - - #define FLM_UNICODE_a ((FLMUNICODE)97) - #define FLM_UNICODE_b ((FLMUNICODE)98) - #define FLM_UNICODE_c ((FLMUNICODE)99) - #define FLM_UNICODE_d ((FLMUNICODE)100) - #define FLM_UNICODE_e ((FLMUNICODE)101) - #define FLM_UNICODE_f ((FLMUNICODE)102) - #define FLM_UNICODE_g ((FLMUNICODE)103) - #define FLM_UNICODE_h ((FLMUNICODE)104) - #define FLM_UNICODE_i ((FLMUNICODE)105) - #define FLM_UNICODE_j ((FLMUNICODE)106) - #define FLM_UNICODE_k ((FLMUNICODE)107) - #define FLM_UNICODE_l ((FLMUNICODE)108) - #define FLM_UNICODE_m ((FLMUNICODE)109) - #define FLM_UNICODE_n ((FLMUNICODE)110) - #define FLM_UNICODE_o ((FLMUNICODE)111) - #define FLM_UNICODE_p ((FLMUNICODE)112) - #define FLM_UNICODE_q ((FLMUNICODE)113) - #define FLM_UNICODE_r ((FLMUNICODE)114) - #define FLM_UNICODE_s ((FLMUNICODE)115) - #define FLM_UNICODE_t ((FLMUNICODE)116) - #define FLM_UNICODE_u ((FLMUNICODE)117) - #define FLM_UNICODE_v ((FLMUNICODE)118) - #define FLM_UNICODE_w ((FLMUNICODE)119) - #define FLM_UNICODE_x ((FLMUNICODE)120) - #define FLM_UNICODE_y ((FLMUNICODE)121) - #define FLM_UNICODE_z ((FLMUNICODE)122) - - #define FLM_UNICODE_LBRACE ((FLMUNICODE)123) - #define FLM_UNICODE_PIPE ((FLMUNICODE)124) - #define FLM_UNICODE_RBRACE ((FLMUNICODE)125) - #define FLM_UNICODE_TILDE ((FLMUNICODE)126) - #define FLM_UNICODE_C_CEDILLA ((FLMUNICODE)199) - #define FLM_UNICODE_N_TILDE ((FLMUNICODE)209) - #define FLM_UNICODE_c_CEDILLA ((FLMUNICODE)231) - #define FLM_UNICODE_n_TILDE ((FLMUNICODE)241) - - FINLINE FLMBOOL f_isvowel( - FLMUNICODE uChar) - { - uChar = f_unitolower( uChar); - - if( uChar == FLM_UNICODE_a || - uChar == FLM_UNICODE_e || - uChar == FLM_UNICODE_i || - uChar == FLM_UNICODE_o || - uChar == FLM_UNICODE_u || - uChar == FLM_UNICODE_y) - { - return( TRUE); - } - - return( FALSE); - } - - /**************************************************************************** - WORD/BYTE ORDERING MACROS - ****************************************************************************/ - - FINLINE FLMUINT32 byteToLong( - const FLMBYTE * pucBuf) - { - FLMUINT32 ui32Val = 0; - - ui32Val |= ((FLMUINT32)pucBuf[ 0]) << 24; - ui32Val |= ((FLMUINT32)pucBuf[ 1]) << 16; - ui32Val |= ((FLMUINT32)pucBuf[ 2]) << 8; - ui32Val |= ((FLMUINT32)pucBuf[ 3]); - - return( ui32Val); - } - - FINLINE FLMUINT64 byteToLong64( - const FLMBYTE * pucBuf) - { - FLMUINT64 ui64Val = 0; - - ui64Val |= ((FLMUINT64)pucBuf[ 0]) << 56; - ui64Val |= ((FLMUINT64)pucBuf[ 1]) << 48; - ui64Val |= ((FLMUINT64)pucBuf[ 2]) << 40; - ui64Val |= ((FLMUINT64)pucBuf[ 3]) << 32; - ui64Val |= ((FLMUINT64)pucBuf[ 4]) << 24; - ui64Val |= ((FLMUINT64)pucBuf[ 5]) << 16; - ui64Val |= ((FLMUINT64)pucBuf[ 6]) << 8; - ui64Val |= ((FLMUINT64)pucBuf[ 7]); - - return( ui64Val); - } - - FLMUINT32 byteToInt( const FLMBYTE * ptr); - #define byteToInt(p) ( \ - (FLMUINT16) ( ((((FLMBYTE *)(p))[ 0]) << 8) | (((FLMBYTE *)(p))[ 1]) ) ) - - void longToByte( FLMINT32 uiNum, FLMBYTE * ptr); - #define longToByte( n, p) { \ - FLMUINT32 ui32Temp = (FLMUINT32) (n); FLMBYTE * pTemp = (FLMBYTE *)(p); \ - pTemp[0] = (FLMBYTE) (ui32Temp >> 24); \ - pTemp[1] = (FLMBYTE) (ui32Temp >> 16); \ - pTemp[2] = (FLMBYTE) (ui32Temp >> 8); \ - pTemp[3] = (FLMBYTE) (ui32Temp ); \ - } - - void long64ToByte( FLMINT64 uiNum, FLMBYTE * ptr); - #define long64ToByte( n, p) { \ - FLMUINT64 ui64Temp = (FLMUINT64) (n); FLMBYTE * pTemp = (FLMBYTE *)(p); \ - pTemp[0] = (FLMBYTE) (ui64Temp >> 56); \ - pTemp[1] = (FLMBYTE) (ui64Temp >> 48); \ - pTemp[2] = (FLMBYTE) (ui64Temp >> 40); \ - pTemp[3] = (FLMBYTE) (ui64Temp >> 32); \ - pTemp[4] = (FLMBYTE) (ui64Temp >> 24); \ - pTemp[5] = (FLMBYTE) (ui64Temp >> 16); \ - pTemp[6] = (FLMBYTE) (ui64Temp >> 8); \ - pTemp[7] = (FLMBYTE) (ui64Temp ); \ - } - - void intToByte( FLMINT16 uiNum, FLMBYTE * ptr); - #define intToByte( n, p) { \ - FLMUINT16 ui16Temp = (FLMUINT16) (n); FLMBYTE * pTemp = (FLMBYTE *) (p); \ - pTemp[0] = (FLMBYTE) (ui16Temp >> 8); \ - pTemp[1] = (FLMBYTE) (ui16Temp ); \ - } - - #ifndef FLM_BIG_ENDIAN - - #if defined( FLM_SPARC) - #error Wrong endian order selected - #endif - - #define LO(wrd) (*(FLMUINT8 *)&wrd) - #define HI(wrd) (*((FLMUINT8 *)&wrd + 1)) - - #if defined( FLM_STRICT_ALIGNMENT) - - #define FB2UW( bp) \ - ((FLMUINT16)((((FLMUINT16)(((FLMUINT8 *)(bp))[1])) << 8) | \ - (((FLMUINT16)(((FLMUINT8 *)(bp))[0]))))) - - #define FB2UD( bp) \ - ((FLMUINT32)((((FLMUINT32)(((FLMUINT8 *)(bp))[3]))<< 24) | \ - (((FLMUINT32)(((FLMUINT8 *)(bp))[2]))<< 16) | \ - (((FLMUINT32)(((FLMUINT8 *)(bp))[1]))<< 8) | \ - (((FLMUINT32)(((FLMUINT8 *)(bp))[0]))))) - - #define FB2U64( bp) \ - ((FLMUINT64)((((FLMUINT64)(((FLMUINT8 *)(bp))[7])) << 56) | \ - (((FLMUINT64)(((FLMUINT8 *)(bp))[6])) << 48) | \ - (((FLMUINT64)(((FLMUINT8 *)(bp))[5])) << 40) | \ - (((FLMUINT64)(((FLMUINT8 *)(bp))[4])) << 32) | \ - (((FLMUINT64)(((FLMUINT8 *)(bp))[3])) << 24) | \ - (((FLMUINT64)(((FLMUINT8 *)(bp))[2])) << 16) | \ - (((FLMUINT64)(((FLMUINT8 *)(bp))[1]))<< 8) | \ - (((FLMUINT64)(((FLMUINT8 *)(bp))[0]))))) - - #define UW2FBA( uw, bp) \ - (((FLMUINT8 *)(bp))[0] = ((FLMUINT8)(uw)), \ - ((FLMUINT8 *)(bp))[1] = ((FLMUINT8)((((uw) & 0xff00) >> 8)))) - - #define UD2FBA( udw, bp) \ - (((FLMUINT8 *)(bp))[0] = ((FLMUINT8)((udw) & 0xff)), \ - ((FLMUINT8 *)(bp))[1] = ((FLMUINT8)(((udw) & 0xff00) >> 8)), \ - ((FLMUINT8 *)(bp))[2] = ((FLMUINT8)(((udw) & 0xff0000) >> 16)), \ - ((FLMUINT8 *)(bp))[3] = ((FLMUINT8)(((udw) & 0xff000000) >> 24))) - - #define U642FBA( u64, bp) \ - (((FLMUINT8 *)(bp))[0] = ((FLMUINT8)((u64) & 0xff)), \ - ((FLMUINT8 *)(bp))[1] = ((FLMUINT8)(((u64) & 0xff00) >> 8)), \ - ((FLMUINT8 *)(bp))[2] = ((FLMUINT8)(((u64) & 0xff0000) >> 16)), \ - ((FLMUINT8 *)(bp))[3] = ((FLMUINT8)(((u64) & 0xff000000) >> 24)), \ - ((FLMUINT8 *)(bp))[4] = ((FLMUINT8)(((u64) & 0xff00000000) >> 32)), \ - ((FLMUINT8 *)(bp))[5] = ((FLMUINT8)(((u64) & 0xff0000000000) >> 40)), \ - ((FLMUINT8 *)(bp))[6] = ((FLMUINT8)(((u64) & 0xff000000000000) >> 48)), \ - ((FLMUINT8 *)(bp))[7] = ((FLMUINT8)(((u64) & 0xff00000000000000) >> 56))) - #else - #define FB2UW( fbp) \ - (*((FLMUINT16 *)(fbp))) - - #define FB2UD( fbp) \ - (*((FLMUINT32 *)(fbp))) - - #define FB2U64( fbp) \ - (*((FLMUINT64 *)(fbp))) - - #define UW2FBA( uw, fbp) \ - (*((FLMUINT16 *)(fbp)) = ((FLMUINT16) (uw))) - - #define UD2FBA( uw, fbp) \ - (*((FLMUINT32 *)(fbp)) = ((FLMUINT32) (uw))) - - #define U642FBA( uw, fbp) \ - (*((FLMUINT64 *)(fbp)) = ((FLMUINT64) (uw))) - #endif - - #else - - #if defined( __i386__) - #error Wrong endian order selected - #endif - - #define LO( wrd) \ - (*((FLMUINT8 *)&wrd + 1)) - - #define HI( wrd) \ - (*(FLMUINT8 *)&wrd) - - #define FB2UW( bp) \ - ((FLMUINT16)((((FLMUINT16)(((FLMUINT8 *)(bp))[1])) << 8) | \ - (((FLMUINT16)(((FLMUINT8 *)(bp))[0]))))) - - #define FB2UD( bp) \ - ((FLMUINT32)((((FLMUINT32)(((FLMUINT8 *)(bp))[3])) << 24) | \ - (((FLMUINT32)(((FLMUINT8 *)(bp))[2])) << 16) | \ - (((FLMUINT32)(((FLMUINT8 *)(bp))[1])) << 8) | \ - (((FLMUINT32)(((FLMUINT8 *)(bp))[0]))))) - - #define FB2U64( bp) \ - ((FLMUINT64)((((FLMUINT64)(((FLMUINT8 *)(bp))[7])) << 56) | \ - (((FLMUINT64)(((FLMUINT8 *)(bp))[6])) << 48) | \ - (((FLMUINT64)(((FLMUINT8 *)(bp))[5])) << 40) | \ - (((FLMUINT64)(((FLMUINT8 *)(bp))[4])) << 32) | \ - (((FLMUINT64)(((FLMUINT8 *)(bp))[3])) << 24) | \ - (((FLMUINT64)(((FLMUINT8 *)(bp))[2])) << 16) | \ - (((FLMUINT64)(((FLMUINT8 *)(bp))[1])) << 8) | \ - (((FLMUINT64)(((FLMUINT8 *)(bp))[0]))))) - - #define UW2FBA( uw, bp) \ - (((FLMUINT8 *)(bp))[0] = ((FLMUINT8)(uw)), \ - ((FLMUINT8 *)(bp))[1] = ((FLMUINT8)((((uw) & 0xff00) >> 8)))) - - #define UD2FBA( udw, bp) \ - (((FLMUINT8 *)(bp))[0] = ((FLMUINT8)((udw) & 0xff)), \ - ((FLMUINT8 *)(bp))[1] = ((FLMUINT8)(((udw) & 0xff00) >> 8)), \ - ((FLMUINT8 *)(bp))[2] = ((FLMUINT8)(((udw) & 0xff0000) >> 16)), \ - ((FLMUINT8 *)(bp))[3] = ((FLMUINT8)(((udw) & 0xff000000) >> 24))) - - #ifdef FLM_UNIX - #define U642FBA( u64, bp) \ - (((FLMUINT8 *)(bp))[0] = ((FLMUINT8)((u64) & 0xffULL)), \ - ((FLMUINT8 *)(bp))[1] = ((FLMUINT8)(((u64) & 0xff00ULL) >> 8)), \ - ((FLMUINT8 *)(bp))[2] = ((FLMUINT8)(((u64) & 0xff0000ULL) >> 16)), \ - ((FLMUINT8 *)(bp))[3] = ((FLMUINT8)(((u64) & 0xff000000ULL) >> 24)), \ - ((FLMUINT8 *)(bp))[4] = ((FLMUINT8)(((u64) & 0xff00000000ULL) >> 32)), \ - ((FLMUINT8 *)(bp))[5] = ((FLMUINT8)(((u64) & 0xff0000000000ULL) >> 40)), \ - ((FLMUINT8 *)(bp))[6] = ((FLMUINT8)(((u64) & 0xff000000000000ULL) >> 48)), \ - ((FLMUINT8 *)(bp))[7] = ((FLMUINT8)(((u64) & 0xff00000000000000ULL) >> 56))) - #else - #define U642FBA( u64, bp) \ - (((FLMUINT8 *)(bp))[0] = ((FLMUINT8)((u64) & 0xff)), \ - ((FLMUINT8 *)(bp))[1] = ((FLMUINT8)(((u64) & 0xff00) >> 8)), \ - ((FLMUINT8 *)(bp))[2] = ((FLMUINT8)(((u64) & 0xff0000) >> 16)), \ - ((FLMUINT8 *)(bp))[3] = ((FLMUINT8)(((u64) & 0xff000000) >> 24)), \ - ((FLMUINT8 *)(bp))[4] = ((FLMUINT8)(((u64) & 0xff00000000) >> 32)), \ - ((FLMUINT8 *)(bp))[5] = ((FLMUINT8)(((u64) & 0xff0000000000) >> 40)), \ - ((FLMUINT8 *)(bp))[6] = ((FLMUINT8)(((u64) & 0xff000000000000) >> 48)), \ - ((FLMUINT8 *)(bp))[7] = ((FLMUINT8)(((u64) & 0xff00000000000000) >> 56))) - #endif - #endif - - /**************************************************************************** - File Path Functions & Macros - ****************************************************************************/ - - // This defines the maximum file size we can support for ANY - // platform, ANY file type. It is not 4Gb because of a bug in direct IO - // on Netware. The limitation is that in direct IO mode (on the legacy file - // system) we are not allowed room for the last block. If the block - // size were 64K for example, direct IO only lets us expand to a size of - // 0xFFFF0000. Since we can't anticipate what the block size will be, - // we have to set a maximum that accounts for the maximum block size we - // may ever see. At this point, we are assuming it won't ever be more - // than 256K on legacy file systems. Thus, our limit of 0xFFFC0000. - // (See define of F_MAXIMUM_FILE_SIZE in xflaim.h) - - #if defined( FLM_WIN) || defined( FLM_NLM) - #define FWSLASH '/' - #define SLASH '\\' - #define SSLASH "\\" - #define COLON ':' - #define PERIOD '.' - #define PARENT_DIR ".." - #define CURRENT_DIR "." - #else - #ifndef FWSLASH - #define FWSLASH '/' - #endif - - #ifndef SLASH - #define SLASH '/' - #endif - - #ifndef SSLASH - #define SSLASH "/" - #endif - - #ifndef COLON - #define COLON ':' - #endif - - #ifndef PERIOD - #define PERIOD '.' - #endif - - #ifndef PARENT_DIR - #define PARENT_DIR ".." - #endif - - #ifndef CURRENT_DIR - #define CURRENT_DIR "." - #endif - #endif - - /**************************************************************************** - CPU Release Functions - ****************************************************************************/ - - #ifdef FLM_NLM - #define f_yieldCPU() \ - pthread_yield() - #else - #define f_yieldCPU() - #endif - - void f_sleep( - FLMUINT uiMilliseconds); - - #ifdef FLM_WIN - #define f_sleep( uiMilliseconds) \ - Sleep( (DWORD)uiMilliseconds) - #endif - - /**************************************************************************** - Random Numbers - ****************************************************************************/ - - #define MAX_RANDOM 2147483646L - - class F_RandomGenerator : public XF_RefCount, public XF_Base - { - public: - - void randomize( void); - - void randomSetSeed( - FLMINT32 i32seed); - - FLMINT32 randomLong( void); - - FLMINT32 randomChoice( - FLMINT32 lo, - FLMINT32 hi); - - FLMINT randomTruth( - FLMINT iPercentageTrue); - - FLMINT getSeed( void) - { - return( m_i32Seed); - } - - private: - - FLMINT32 m_i32Seed; - }; - - /**************************************************************************** - Time, date, timestamp functions - ****************************************************************************/ - - typedef struct - { - FLMUINT16 year; - FLMBYTE month; - FLMBYTE day; - FLMBYTE hour; - FLMBYTE minute; - FLMBYTE second; - FLMBYTE hundredth; - } F_TMSTAMP; - - #define f_timeIsLeapYear(year) \ - ((((year) & 0x03) == 0) && (((year) % 100) != 0) || (((year) % 400) == 0)) - - void f_timeGetSeconds( - FLMUINT * puiSeconds); - - void f_timeGetTimeStamp( - F_TMSTAMP * pTimeStamp); - - FLMINT f_timeGetLocalOffset( void); - - void f_timeSecondsToDate( - FLMUINT uiSeconds, - F_TMSTAMP * pTimeStamp); - - void f_timeDateToSeconds( - F_TMSTAMP * pTimeStamp, - FLMUINT * puiSeconds); - - FLMINT f_timeCompareTimeStamps( - F_TMSTAMP * pTimeStamp1, - F_TMSTAMP * pTimeStamp2, - FLMUINT flag); - - #if defined( FLM_UNIX) - unsigned f_timeGetMilliTime(); - #endif - - FINLINE FLMUINT flmLocalToUTC( - FLMUINT uiSeconds) - { - return( uiSeconds + f_timeGetLocalOffset()); - } - - /********************************************************************** - Desc: - **********************************************************************/ - #if defined( FLM_SOLARIS) && defined( FLM_SPARC) && !defined( FLM_GNUC) - extern "C" FLMINT32 sparc_atomic_add_32( - volatile FLMINT32 * piTarget, - FLMINT32 iDelta); - #endif - - /********************************************************************** - Desc: - **********************************************************************/ - #if defined( FLM_SOLARIS) && defined( FLM_SPARC) && !defined( FLM_GNUC) - extern "C" FLMINT32 sparc_atomic_xchg_32( - volatile FLMINT32 * piTarget, - FLMINT32 iNewValue); - #endif - - /********************************************************************** - Desc: - **********************************************************************/ - #if defined( FLM_AIX) - FINLINE int aix_atomic_add( - volatile int * piTarget, - int iDelta) - { - return( fetch_and_add( (int *)piTarget, iDelta) + iDelta); - } - #endif - - /********************************************************************** - Desc: - **********************************************************************/ - #if defined( FLM_UNIX) - extern "C" FLMINT32 posix_atomic_add_32( - volatile FLMINT32 * piTarget, - FLMINT32 iDelta); - #endif - - /********************************************************************** - Desc: - **********************************************************************/ - #if defined( FLM_UNIX) - extern "C" FLMINT32 posix_atomic_xchg_32( - volatile FLMINT32 * piTarget, - FLMINT32 iNewValue); - #endif - - /********************************************************************** - Desc: - **********************************************************************/ - FINLINE FLMINT32 flmAtomicInc( - FLMATOMIC * piTarget) - { - #if defined( FLM_NLM) - { - return( (FLMINT32)nlm_AtomicIncrement( (volatile LONG *)piTarget)); - } - #elif defined( FLM_WIN) - { - return( (FLMINT32)InterlockedIncrement( (volatile LONG *)piTarget)); - } - #elif defined( FLM_AIX) - { - return( (FLMINT32)aix_atomic_add( piTarget, 1)); - } - #elif defined( FLM_OSX) - { - return( (FLMINT32)OSAtomicIncrement32( (int32_t *)piTarget)); - } - #elif defined( FLM_SOLARIS) && defined( FLM_SPARC) && !defined( FLM_GNUC) - { - return( sparc_atomic_add_32( piTarget, 1)); - } - #elif (defined( __i386__) || defined( __x86_64__)) && defined( FLM_GNUC) - { - FLMINT32 i32Tmp; - - __asm__ __volatile__ ( - "lock;" - "xaddl %0, %1" - : "=r" (i32Tmp), "=m" (*piTarget) - : "0" (1), "m" (*piTarget)); - - return( i32Tmp + 1); - } - #elif defined( FLM_UNIX) - return( posix_atomic_add_32( piTarget, 1)); - #else - #error Atomic operations aren't supported - #endif - } - - /********************************************************************** - Desc: - **********************************************************************/ - FINLINE FLMINT32 flmAtomicDec( - FLMATOMIC * piTarget) - { - #if defined( FLM_NLM) - { - return( (FLMINT32)nlm_AtomicDecrement( (volatile LONG *)piTarget)); - } - #elif defined( FLM_WIN) - { - return( (FLMINT32)InterlockedDecrement( (volatile LONG *)piTarget)); - } - #elif defined( FLM_AIX) - { - return( (FLMINT32)aix_atomic_add( piTarget, -1)); - } - #elif defined( FLM_OSX) - { - return( (FLMINT32)OSAtomicDecrement32( (int32_t *)piTarget)); - } - #elif defined( FLM_SOLARIS) && defined( FLM_SPARC) && !defined( FLM_GNUC) - { - return( sparc_atomic_add_32( piTarget, -1)); - } - #elif (defined( __i386__) || defined( __x86_64__)) && defined( FLM_GNUC) - { - FLMINT32 i32Tmp; - - __asm__ __volatile__ ( - "lock;" - "xaddl %0, %1" - : "=r" (i32Tmp), "=m" (*piTarget) - : "0" (-1), "m" (*piTarget)); - - return( i32Tmp - 1); - } - #elif defined( FLM_UNIX) - return( posix_atomic_add_32( piTarget, -1)); - #else - #error Atomic operations aren't supported - #endif - } - - /********************************************************************** - Desc: - **********************************************************************/ - FINLINE FLMINT32 flmAtomicExchange( - FLMATOMIC * piTarget, - FLMINT32 i32NewVal) - { - #if defined( FLM_NLM) - { - return( (FLMINT32)nlm_AtomicExchange( - (volatile LONG *)piTarget, i32NewVal)); - } - #elif defined( FLM_WIN) - { - return( (FLMINT32)InterlockedExchange( (volatile LONG *)piTarget, - i32NewVal)); - } - #elif defined( FLM_AIX) - { - int iOldVal; - - for( ;;) - { - iOldVal = (int)*piTarget; - - if( compare_and_swap( (int *)piTarget, &iOldVal, i32NewVal)) - { - break; - } - } - - return( (FLMINT32)iOldVal); - } - #elif defined( FLM_OSX) - { - int32_t iOldVal; - - for( ;;) - { - iOldVal = (int32_t)*piTarget; - - if( OSAtomicCompareAndSwap32( iOldVal, i32NewVal, - (int32_t *)piTarget)) - { - break; - } - } - - return( (FLMINT32)iOldVal); - } - #elif defined( FLM_SOLARIS) && defined( FLM_SPARC) && !defined( FLM_GNUC) - { - return( sparc_atomic_xchg_32( piTarget, i32NewVal)); - } - #elif (defined( __i386__) || defined( __x86_64__)) && defined( FLM_GNUC) - { - FLMINT32 i32OldVal; - - __asm__ __volatile__ ( - "1: lock;" - " cmpxchgl %2, %0;" - " jne 1b" - : "=m" (*piTarget), "=a" (i32OldVal) - : "r" (i32NewVal), "m" (*piTarget), "a" (*piTarget)); - - return( i32OldVal); - } - #elif defined( FLM_UNIX) - return( posix_atomic_xchg_32( piTarget, i32NewVal)); - #else - #error Atomic operations aren't supported - #endif - } - - /**************************************************************************** - Desc: Mutex and semaphore routines - ****************************************************************************/ - #ifdef FLM_NLM - FINLINE RCODE f_mutexCreate( - F_MUTEX * phMutex) - { - if( (*phMutex = (F_MUTEX)kMutexAlloc( (BYTE *)"NOVDB")) == F_MUTEX_NULL) - { - return RC_SET( NE_XFLM_MEM); - } - - return NE_XFLM_OK; - } - - FINLINE void f_mutexDestroy( - F_MUTEX * phMutex) - { - if (*phMutex != F_MUTEX_NULL) - { - if( kMutexFree( (MUTEX)(*phMutex))) - { - flmAssert( 0); - } - - *phMutex = F_MUTEX_NULL; - } - } - - FINLINE void f_mutexLock( - F_MUTEX hMutex) - { - (void)kMutexLock( (MUTEX)hMutex); - } - - FINLINE void f_mutexUnlock( - F_MUTEX hMutex) - { - (void)kMutexUnlock( (MUTEX)hMutex); - } - - FINLINE void f_assertMutexLocked( - F_MUTEX) - { - } - - typedef SEMAPHORE F_SEM; - typedef SEMAPHORE * F_SEM_p; - #define F_SEM_NULL 0 - - FINLINE RCODE f_semCreate( - F_SEM * phSem) - { - if( (*phSem = (F_SEM)kSemaphoreAlloc( (BYTE *)"NOVDB", 0)) == F_SEM_NULL) - { - return RC_SET( NE_XFLM_MEM); - } - - return NE_XFLM_OK; - } - - FINLINE void f_semDestroy( - F_SEM * phSem) - { - if (*phSem != F_SEM_NULL) - { - (void)kSemaphoreFree( (SEMAPHORE)(*phSem)); - *phSem = F_SEM_NULL; - } - } - - FINLINE RCODE f_semWait( - F_SEM hSem, - FLMUINT uiTimeout) - { - RCODE rc = NE_XFLM_OK; - - if( uiTimeout == F_SEM_WAITFOREVER) - { - if( kSemaphoreWait( (SEMAPHORE)hSem) != 0) - { - rc = RC_SET( NE_XFLM_ERROR_WAITING_ON_SEMPAHORE); - } - } - else - { - if( kSemaphoreTimedWait( (SEMAPHORE)hSem, (UINT)uiTimeout) != 0) - { - rc = RC_SET( NE_XFLM_ERROR_WAITING_ON_SEMPAHORE); - } - } - - return( rc); - } - - FINLINE void f_semSignal( - F_SEM hSem) - { - (void)kSemaphoreSignal( (SEMAPHORE)hSem); - } - - #elif defined( FLM_WIN) - - RCODE f_mutexCreate( - F_MUTEX * phMutex); - - void f_mutexDestroy( - F_MUTEX * phMutex); - - FINLINE void f_mutexLock( - F_MUTEX hMutex) - { - while( flmAtomicExchange( - &(((F_INTERLOCK *)hMutex)->locked), 1) != 0) - { - #ifdef FLM_DEBUG - flmAtomicInc( &(((F_INTERLOCK *)hMutex)->waitCount)); - #endif - Sleep( 0); - } - - #ifdef FLM_DEBUG - flmAssert( ((F_INTERLOCK *)hMutex)->uiThreadId == 0); - ((F_INTERLOCK *)hMutex)->uiThreadId = _threadid; - flmAtomicInc( &(((F_INTERLOCK *)hMutex)->lockedCount)); - #endif - } - - FINLINE void f_mutexUnlock( - F_MUTEX hMutex) - { - flmAssert( ((F_INTERLOCK *)hMutex)->locked == 1); - #ifdef FLM_DEBUG - flmAssert( ((F_INTERLOCK *)hMutex)->uiThreadId == _threadid); - ((F_INTERLOCK *)hMutex)->uiThreadId = 0; - #endif - flmAtomicExchange( &(((F_INTERLOCK *)hMutex)->locked), 0); - } - - FINLINE void f_assertMutexLocked( - F_MUTEX hMutex) - { - #ifdef FLM_DEBUG - flmAssert( ((F_INTERLOCK *)hMutex)->locked == 1); - flmAssert( ((F_INTERLOCK *)hMutex)->uiThreadId == _threadid); - #else - F_UNREFERENCED_PARM( hMutex); - #endif - } - - FINLINE RCODE f_semCreate( - F_SEM * phSem) - { - if( (*phSem = CreateSemaphore( (LPSECURITY_ATTRIBUTES)NULL, - 0, 10000, NULL )) == NULL) - { - return( RC_SET( NE_XFLM_COULD_NOT_CREATE_SEMAPHORE)); - } - - return NE_XFLM_OK; - } - - FINLINE void f_semDestroy( - F_SEM * phSem) - { - if (*phSem != F_SEM_NULL) - { - CloseHandle( *phSem); - *phSem = F_SEM_NULL; - } - } - - FINLINE RCODE f_semWait( - F_SEM hSem, - FLMUINT uiTimeout) - { - if( WaitForSingleObject( hSem, uiTimeout ) == WAIT_OBJECT_0) - { - return( NE_XFLM_OK); - } - else - { - return( RC_SET( NE_XFLM_ERROR_WAITING_ON_SEMPAHORE)); - } - } - - FINLINE void f_semSignal( - F_SEM hSem) - { - (void)ReleaseSemaphore( hSem, 1, NULL); - } - #elif defined( FLM_UNIX) - RCODE f_mutexCreate( - F_MUTEX * phMutex); - - void f_mutexDestroy( - F_MUTEX * phMutex); - - FINLINE void f_mutexLock( - F_MUTEX hMutex) - { - (void)pthread_mutex_lock( hMutex); - } - - FINLINE void f_mutexUnlock( - F_MUTEX hMutex) - { - (void)pthread_mutex_unlock( hMutex); - } - - FINLINE void f_assertMutexLocked( - F_MUTEX) - { - } - - int sema_signal( - sema_t * sem); - - void f_semDestroy( - F_SEM * phSem); - - RCODE f_semCreate( - F_SEM * phSem); - - RCODE f_semWait( - F_SEM hSem, - FLMUINT uiTimeout); - - FINLINE void f_semSignal( - F_SEM hSem) - { - (void)sema_signal( hSem); - } - - #endif - - /**************************************************************************** - Pseudo Serial Numbers - ****************************************************************************/ - - RCODE f_initSerialNumberGenerator( void); - - RCODE f_createSerialNumber( - FLMBYTE * pszGuid); - - void f_freeSerialNumberGenerator( void); - - /**************************************************************************** - CRC - ****************************************************************************/ - - RCODE f_initCRCTable( - FLMUINT32 ** ppui32CRCTbl); - - void f_updateCRC( - FLMUINT32 * pui32CRCTbl, - FLMBYTE * pucBlk, - FLMUINT uiBlkSize, - FLMUINT32 * pui32CRC); - - #define f_freeCRCTable( ppui32CRCTbl) \ - f_free( ppui32CRCTbl) - - /**************************************************************************** - Desc: - ****************************************************************************/ - class F_IStream : public IF_IStream, public XF_Base - { - public: - - F_IStream(); - - virtual ~F_IStream(); - - void lockModule( void); - - private: - - FLMBOOL m_bLockedModule; - }; - - /**************************************************************************** - Desc: - ****************************************************************************/ - class F_OStream : public IF_OStream, public XF_Base - { - public: - - F_OStream(); - - virtual ~F_OStream(); - - void lockModule( void); - - private: - - FLMBOOL m_bLockedModule; - }; - - /**************************************************************************** - Desc: - ****************************************************************************/ - class F_PosIStream : public IF_PosIStream, public XF_Base - { - public: - - F_PosIStream(); - - virtual ~F_PosIStream(); - - void lockModule( void); - - private: - - FLMBOOL m_bLockedModule; - }; - - /**************************************************************************** - Desc: - ****************************************************************************/ - class F_BufferIStream : public F_PosIStream - { - public: - - F_BufferIStream() - { - m_pucBuffer = NULL; - m_uiBufferLen = 0; - m_uiOffset = 0; - m_bAllocatedBuffer = FALSE; - m_bIsOpen = FALSE; - } - - virtual ~F_BufferIStream(); - - RCODE XFLMAPI open( - const FLMBYTE * pucBuffer, - FLMUINT uiLength, - FLMBYTE ** ppucAllocatedBuffer = NULL); - - FINLINE FLMUINT64 XFLMAPI totalSize( void) - { - flmAssert( m_bIsOpen); - return( m_uiBufferLen); - } - - FINLINE FLMUINT64 XFLMAPI remainingSize( void) - { - flmAssert( m_bIsOpen); - return( m_uiBufferLen - m_uiOffset); - } - - RCODE XFLMAPI close( void); - - FINLINE RCODE XFLMAPI positionTo( - FLMUINT64 ui64Position) - { - flmAssert( m_bIsOpen); - - if( ui64Position < m_uiBufferLen) - { - m_uiOffset = (FLMUINT)ui64Position; - } - else - { - m_uiOffset = m_uiBufferLen; - } - - return( NE_XFLM_OK); - } - - FINLINE FLMUINT64 XFLMAPI getCurrPosition( void) - { - flmAssert( m_bIsOpen); - return( m_uiOffset); - } - - RCODE XFLMAPI read( - void * pvBuffer, - FLMUINT uiBytesToRead, - FLMUINT * puiBytesRead); - - FINLINE const FLMBYTE * getBuffer( void) - { - flmAssert( m_bIsOpen); - return( m_pucBuffer); - } - - FINLINE const FLMBYTE * getBufferAtCurrentOffset( void) - { - flmAssert( m_bIsOpen); - return( m_pucBuffer ? &m_pucBuffer[ m_uiOffset] : NULL); - } - - FINLINE void truncate( - FLMUINT uiOffset) - { - flmAssert( m_bIsOpen); - flmAssert( uiOffset >= m_uiOffset); - flmAssert( uiOffset <= m_uiBufferLen); - - m_uiBufferLen = uiOffset; - } - - FINLINE FLMBOOL isOpen( void) - { - return( m_bIsOpen); - } - - private: - - const FLMBYTE * m_pucBuffer; - FLMUINT m_uiBufferLen; - FLMUINT m_uiOffset; - FLMBOOL m_bAllocatedBuffer; - FLMBOOL m_bIsOpen; - }; - - /**************************************************************************** - Desc: - ****************************************************************************/ - class F_FileIStream : public F_PosIStream - { - public: - - F_FileIStream() - { - m_pFileHdl = NULL; - m_ui64FileOffset = 0; - } - - virtual ~F_FileIStream() - { - if( m_pFileHdl) - { - m_pFileHdl->Release(); - } - } - - RCODE XFLMAPI open( - const char * pszPath); - - RCODE XFLMAPI close( void); - - RCODE XFLMAPI positionTo( - FLMUINT64 ui64Position); - - FLMUINT64 XFLMAPI totalSize( void); - - FLMUINT64 XFLMAPI remainingSize( void); - - FLMUINT64 XFLMAPI getCurrPosition( void); - - RCODE XFLMAPI read( - void * pvBuffer, - FLMUINT uiBytesToRead, - FLMUINT * puiBytesRead); - - private: - - IF_FileHdl * m_pFileHdl; - FLMUINT64 m_ui64FileOffset; - }; - - /**************************************************************************** - Desc: - ****************************************************************************/ - class F_BufferedIStream : public F_PosIStream - { - public: - - F_BufferedIStream() - { - m_pIStream = NULL; - m_pucBuffer = NULL; - } - - virtual ~F_BufferedIStream() - { - close(); - } - - RCODE XFLMAPI open( - IF_IStream * pIStream, - FLMUINT uiBufferSize); - - RCODE XFLMAPI read( - void * pvBuffer, - FLMUINT uiBytesToRead, - FLMUINT * puiBytesRead); - - RCODE XFLMAPI close( void); - - FINLINE FLMUINT64 XFLMAPI totalSize( void) - { - if (!m_pIStream) - { - flmAssert( 0); - return( 0); - } - - return( m_uiBytesAvail); - } - - FINLINE FLMUINT64 XFLMAPI remainingSize( void) - { - if( !m_pIStream) - { - flmAssert( 0); - return( 0); - } - - return( m_uiBytesAvail - m_uiBufferOffset); - } - - FINLINE RCODE XFLMAPI positionTo( - FLMUINT64 ui64Position) - { - if( !m_pIStream) - { - flmAssert( 0); - return( RC_SET( NE_XFLM_ILLEGAL_OP)); - } - - if( ui64Position < m_uiBytesAvail) - { - m_uiBufferOffset = (FLMUINT)ui64Position; - } - else - { - m_uiBufferOffset = m_uiBytesAvail; - } - - return( NE_XFLM_OK); - } - - FINLINE FLMUINT64 XFLMAPI getCurrPosition( void) - { - if( !m_pIStream) - { - flmAssert( 0); - return( 0); - } - - return( m_uiBufferOffset); - } - - private: - - IF_IStream * m_pIStream; - FLMBYTE * m_pucBuffer; - FLMUINT m_uiBufferSize; - FLMUINT m_uiBufferOffset; - FLMUINT m_uiBytesAvail; - }; - - /**************************************************************************** - Desc: - ****************************************************************************/ - class F_BufferedOStream : public F_OStream - { - public: - - F_BufferedOStream() - { - m_pOStream = NULL; - m_pucBuffer = NULL; - } - - virtual ~F_BufferedOStream() - { - close(); - } - - RCODE XFLMAPI open( - IF_OStream * pOStream, - FLMUINT uiBufferSize); - - RCODE XFLMAPI write( - const void * pvBuffer, - FLMUINT uiBytesToWrite, - FLMUINT * puiBytesWritten); - - RCODE XFLMAPI close( void); - - RCODE XFLMAPI flush( void); - - private: - - IF_OStream * m_pOStream; - FLMBYTE * m_pucBuffer; - FLMUINT m_uiBufferSize; - FLMUINT m_uiBufferOffset; - }; - - /**************************************************************************** - Desc: - ****************************************************************************/ - class F_FileOStream : public F_OStream - { - public: - - F_FileOStream() - { - m_pFileHdl = NULL; - } - - virtual ~F_FileOStream() - { - close(); - } - - RCODE XFLMAPI open( - const char * pszFilePath, - FLMBOOL bTruncateIfExists); - - RCODE XFLMAPI write( - const void * pvBuffer, - FLMUINT uiBytesToWrite, - FLMUINT * puiBytesWritten); - - RCODE XFLMAPI close( void); - - private: - - IF_FileHdl * m_pFileHdl; - FLMUINT64 m_ui64FileOffset; - }; - - /**************************************************************************** - Desc: - ****************************************************************************/ - class F_MultiFileIStream : public F_IStream - { - public: - - F_MultiFileIStream() - { - m_pIStream = NULL; - m_bOpen = FALSE; - } - - virtual ~F_MultiFileIStream() - { - close(); - } - - RCODE XFLMAPI open( - const char * pszDirectory, - const char * pszBaseName); - - RCODE XFLMAPI read( - void * pvBuffer, - FLMUINT uiBytesToRead, - FLMUINT * puiBytesRead); - - RCODE XFLMAPI close( void); - - private: - - RCODE rollToNextFile( void); - - IF_IStream * m_pIStream; - FLMBOOL m_bOpen; - FLMBOOL m_bEndOfStream; - FLMUINT m_uiFileNum; - FLMUINT64 m_ui64FileOffset; - FLMBYTE m_szDirectory[ F_PATH_MAX_SIZE + 1]; - FLMBYTE m_szBaseName[ F_PATH_MAX_SIZE + 1]; - }; - - /**************************************************************************** - Desc: - ****************************************************************************/ - class F_MultiFileOStream : public F_OStream - { - public: - - F_MultiFileOStream() - { - m_pOStream = NULL; - m_bOpen = FALSE; - } - - virtual ~F_MultiFileOStream() - { - close(); - } - - RCODE create( - const char * pszDirectory, - const char * pszBaseName, - FLMUINT uiMaxFileSize, - FLMBOOL bOkToOverwrite); - - RCODE XFLMAPI write( - const void * pvBuffer, - FLMUINT uiBytesToWrite, - FLMUINT * puiBytesWritten); - - RCODE XFLMAPI close( void); - - private: - - RCODE rollToNextFile( void); - - RCODE processDirectory( - const char * pszDirectory, - const char * pszBaseName, - FLMBOOL bOkToDelete); - - F_OStream * m_pOStream; - FLMBOOL m_bOpen; - FLMUINT m_uiFileNum; - FLMUINT64 m_ui64MaxFileSize; - FLMUINT64 m_ui64FileOffset; - FLMBYTE m_szDirectory[ F_PATH_MAX_SIZE + 1]; - FLMBYTE m_szBaseName[ F_PATH_MAX_SIZE + 1]; - - friend class F_DbSystem; - }; - - /**************************************************************************** - Desc: Decodes an ASCII base64 stream to binary - ****************************************************************************/ - class F_Base64DecoderIStream : public F_IStream - { - public: - - F_Base64DecoderIStream() - { - m_pIStream = NULL; - m_uiBufOffset = 0; - m_uiAvailBytes = 0; - } - - ~F_Base64DecoderIStream() - { - close(); - } - - RCODE XFLMAPI open( - IF_IStream * pIStream); - - RCODE XFLMAPI read( - void * pvBuffer, - FLMUINT uiBytesToRead, - FLMUINT * puiBytesRead); - - FINLINE RCODE XFLMAPI close( void) - { - RCODE rc = NE_XFLM_OK; - - if( m_pIStream) - { - if( m_pIStream->getRefCount() == 1) - { - rc = m_pIStream->close(); - } - - m_pIStream->Release(); - m_pIStream = NULL; - } - - m_uiAvailBytes = 0; - m_uiBufOffset = 0; - - return( rc); - } - - private: - - IF_IStream * m_pIStream; - FLMUINT m_uiBufOffset; - FLMUINT m_uiAvailBytes; - FLMBYTE m_ucBuffer[ 8]; - static FLMBYTE m_ucDecodeTable[ 256]; - }; - - /**************************************************************************** - Desc: Encodes a binary input stream into ASCII base64. - ****************************************************************************/ - class F_Base64EncoderIStream : public F_IStream - { - public: - - F_Base64EncoderIStream() - { - m_pIStream = NULL; - } - - ~F_Base64EncoderIStream() - { - close(); - } - - RCODE XFLMAPI open( - IF_IStream * pIStream, - FLMBOOL bLineBreaks); - - RCODE XFLMAPI read( - void * pvBuffer, - FLMUINT uiBytesToRead, - FLMUINT * puiBytesRead); - - FINLINE RCODE XFLMAPI close( void) - { - RCODE rc = NE_XFLM_OK; - - if( m_pIStream) - { - if( m_pIStream->getRefCount() == 1) - { - rc = m_pIStream->close(); - } - - m_pIStream->Release(); - m_pIStream = NULL; - } - - return( rc); - } - - private: - - IF_IStream * m_pIStream; - FLMBOOL m_bInputExhausted; - FLMBOOL m_bLineBreaks; - FLMBOOL m_bPriorLineEnd; - FLMUINT m_uiBase64Count; - FLMUINT m_uiBufOffset; - FLMUINT m_uiAvailBytes; - FLMBYTE m_ucBuffer[ 8]; - static FLMBYTE m_ucEncodeTable[ 64]; - }; - - typedef struct LZWODictItem - { - LZWODictItem * pNext; - FLMUINT16 ui16Code; - FLMUINT16 ui16ParentCode; - FLMBYTE ucChar; - } LZWODictItem; - - /**************************************************************************** - Desc: - ****************************************************************************/ - class F_CompressingOStream : public F_OStream - { - public: - - F_CompressingOStream() - { - m_pOStream = NULL; - m_ppHashTbl = NULL; - m_pool.poolInit( 64 * 1024); - } - - virtual ~F_CompressingOStream() - { - close(); - } - - RCODE XFLMAPI open( - IF_OStream * pOStream); - - RCODE XFLMAPI write( - const void * pvBuffer, - FLMUINT uiBytesToWrite, - FLMUINT * puiBytesWritten); - - RCODE XFLMAPI close( void); - - private: - - FINLINE FLMUINT getHashBucket( - FLMUINT16 ui16CurrentCode, - FLMBYTE ucChar) - { - return( ((((FLMUINT)ui16CurrentCode) << 8) | - ((FLMUINT)ucChar)) % m_uiHashTblSize); - } - - LZWODictItem * findDictEntry( - FLMUINT16 ui16CurrentCode, - FLMBYTE ucChar); - - IF_OStream * m_pOStream; - LZWODictItem ** m_ppHashTbl; - FLMUINT m_uiHashTblSize; - FLMUINT m_uiLastRatio; - FLMUINT m_uiBestRatio; - FLMUINT m_uiCurrentBytesIn; - FLMUINT m_uiTotalBytesIn; - FLMUINT m_uiCurrentBytesOut; - FLMUINT m_uiTotalBytesOut; - FLMBOOL m_bStopCompression; - FLMUINT16 m_ui16CurrentCode; - FLMUINT16 m_ui16FreeCode; - F_Pool m_pool; - }; - - typedef struct LZWIDictItem - { - LZWODictItem * pNext; - FLMUINT16 ui16ParentCode; - FLMBYTE ucChar; - } LZWIDictItem; - - /**************************************************************************** - Desc: - ****************************************************************************/ - class F_UncompressingIStream : public F_IStream - { - public: - - F_UncompressingIStream() - { - m_pIStream = NULL; - m_pDict = NULL; - m_pucDecodeBuffer = NULL; - } - - virtual ~F_UncompressingIStream() - { - close(); - } - - RCODE XFLMAPI open( - IF_IStream * pIStream); - - RCODE XFLMAPI read( - void * pvBuffer, - FLMUINT uiBytesToRead, - FLMUINT * puiBytesRead); - - RCODE XFLMAPI close( void); - - private: - - RCODE readCode( - FLMUINT16 * pui16Code); - - RCODE decodeToBuffer( - FLMUINT16 ui16Code); - - IF_IStream * m_pIStream; - LZWIDictItem * m_pDict; - FLMBYTE * m_pucDecodeBuffer; - FLMUINT m_uiDecodeBufferSize; - FLMUINT m_uiDecodeBufferOffset; - FLMUINT16 m_ui16FreeCode; - FLMUINT16 m_ui16LastCode; - FLMBOOL m_bStopCompression; - FLMBOOL m_bEndOfStream; - }; - - /**************************************************************************** - Desc: - ****************************************************************************/ - class F_TCPStream : public F_IStream, public F_OStream - { - public: - - F_TCPStream( void); - - virtual ~F_TCPStream( void); - - RCODE openConnection( - const char * pucHostAddress, - FLMUINT uiPort, - FLMUINT uiConnectTimeout = 3, - FLMUINT uiDataTimeout = 15); - - RCODE XFLMAPI read( - void * pvBuffer, - FLMUINT uiBytesToRead, - FLMUINT * puiBytesRead); - - RCODE XFLMAPI write( - const void * pvBuffer, - FLMUINT uiBytesToWrite, - FLMUINT * puiBytesWritten); - - FINLINE RCODE socketPeekWrite( - FLMINT iTimeOut) - { - return( socketPeek( iTimeOut, FALSE)); - } - - FINLINE RCODE socketPeekRead( - FLMINT iTimeOut) - { - return( socketPeek( iTimeOut, TRUE)); - }; - - FINLINE const char * getName( void) - { - getLocalInfo(); - return( (const char *)m_pszName); - }; - - FINLINE const char * getAddr( void) - { - getLocalInfo(); - return( (const char *)m_pszIp); - }; - - FINLINE const char * getPeerName( void) - { - getRemoteInfo(); - return( (const char *)m_pszPeerName); - }; - - FINLINE const char * getPeerAddr( void) - { - getRemoteInfo(); - return( (const char *)m_pszPeerIp); - }; - - RCODE readNoWait( - FLMBYTE * pucBuffer, - FLMUINT uiCount, - FLMUINT * puiReadRead); - - RCODE readAll( - FLMBYTE * pucBuffer, - FLMUINT uiCount, - FLMUINT * puiBytesRead); - - RCODE setTcpDelay( - FLMBOOL bOn); - - RCODE XFLMAPI close( void); - - private: - - RCODE getLocalInfo( void); - - RCODE getRemoteInfo( void); - - RCODE socketPeek( - FLMINT iTimoutVal, - FLMBOOL bPeekRead); - - #ifndef FLM_UNIX - WSADATA m_wsaData; - #endif - FLMBOOL m_bInitialized; - SOCKET m_iSocket; - FLMUINT m_uiIOTimeout; - FLMBOOL m_bConnected; - char m_pszIp[ 256]; - char m_pszName[ 256]; - char m_pszPeerIp[ 256]; - char m_pszPeerName[ 256]; - unsigned long m_ulRemoteAddr; - }; - - /**************************************************************************** - Misc. - ****************************************************************************/ - - FINLINE FLMBOOL f_isHexChar( - FLMBYTE ucChar) - { - if( (ucChar >= '0' && ucChar <= '9') || - (ucChar >= 'A' && ucChar <= 'F') || - (ucChar >= 'a' && ucChar <= 'f')) - { - return( TRUE); - } - - return( FALSE); - } - - FINLINE FLMBOOL f_isHexChar( - FLMUNICODE uChar) - { - if( uChar > 127) - { - return( FALSE); - } - - return( f_isHexChar( f_tonative( (FLMBYTE)uChar))); - } - - FINLINE FLMBYTE f_getHexVal( - FLMBYTE ucChar) - { - if( ucChar >= '0' && ucChar <= '9') - { - return( (FLMBYTE)(ucChar - '0')); - } - else if( ucChar >= 'A' && ucChar <= 'F') - { - return( (FLMBYTE)((ucChar - 'A') + 10)); - } - else if( ucChar >= 'a' && ucChar <= 'f') - { - return( (FLMBYTE)((ucChar - 'a') + 10)); - } - - return( 0); - } - - FINLINE FLMBYTE f_getHexVal( - FLMUNICODE uChar) - { - return( f_getHexVal( f_tonative( (FLMBYTE)uChar))); - } - - FINLINE FLMBOOL f_isValidHexNum( - const FLMBYTE * pszString) - { - if( *pszString == 0) - { - return( FALSE); - } - - while( *pszString) - { - if( !f_isHexChar( *pszString)) - { - return( TRUE); - } - - pszString++; - } - - return( TRUE); - } - - /**************************************************************************** - Process ID Functions - ****************************************************************************/ - - #if defined( FLM_WIN) - - FINLINE FLMUINT f_getpid( void) - { - return _getpid(); - } - - #elif defined( FLM_UNIX) - - pid_t getpid( void); - - FINLINE FLMUINT f_getpid( void) - { - return getpid(); - } - - #elif defined( FLM_NLM) - - FINLINE FLMUINT f_getpid() - { - return( f_getNLMHandle()); - } - - #else - #error "Unsupported Platform" - #endif - - /**************************************************************************** - f_sprintf - ****************************************************************************/ - - typedef struct - { - FLMBYTE * pszDestStr; - } F_SPRINTF_INFO; - - // Percent formating prefixes - - #define FLM_PREFIX_NONE 0 - #define FLM_PREFIX_MINUS 1 - #define FLM_PREFIX_PLUS 2 - #define FLM_PREFIX_POUND 3 - - // Width and Precision flags - - #define FLM_PRINTF_MINUS_FLAG 0x0001 - #define FLM_PRINTF_PLUS_FLAG 0x0002 - #define FLM_PRINTF_SPACE_FLAG 0x0004 - #define FLM_PRINTF_POUND_FLAG 0x0008 - #define FLM_PRINTF_ZERO_FLAG 0x0010 - #define FLM_PRINTF_SHORT_FLAG 0x0020 - #define FLM_PRINTF_LONG_FLAG 0x0040 - #define FLM_PRINTF_DOUBLE_FLAG 0x0080 - #define FLM_PRINTF_INT64_FLAG 0x0100 - #define FLM_PRINTF_COMMA_FLAG 0x0200 - - void flmSprintfProcessFieldInfo( - FLMBYTE ** ppszFormat, - FLMUINT * puiWidth, - FLMUINT * puiPrecision, - FLMUINT * puiFlags, - f_va_list * args); - - void flmSprintfStringFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - F_SPRINTF_INFO * pInfo, - f_va_list * args); - - void flmSprintfCharFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - F_SPRINTF_INFO * pInfo, - f_va_list * args); - - void flmSprintfErrorFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - F_SPRINTF_INFO * pInfo, - f_va_list * args); - - void flmSprintfNotHandledFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - F_SPRINTF_INFO * pInfo, - f_va_list * args); - - void flmSprintfNumberFormatter( - FLMBYTE ucFormatChar, - FLMUINT uiWidth, - FLMUINT uiPrecision, - FLMUINT uiFlags, - F_SPRINTF_INFO * pInfo, - f_va_list * args); - - FLMINT f_vsprintf( - char * pszDestStr, - const char * pszFormat, - f_va_list * args); - - FLMINT f_sprintf( - char * pszDestStr, - const char * pszFormat, - ...); - - /**************************************************************************** - Quick Sort - ****************************************************************************/ - - typedef FLMINT (* F_SORT_COMPARE_FUNC)( - void * pvBuffer, - FLMUINT uiPos1, - FLMUINT uiPos2); - - typedef void (* F_SORT_SWAP_FUNC)( - void * pvBuffer, - FLMUINT uiPos1, - FLMUINT uiPos2); - - FLMINT flmQSortUINTCompare( - void * pvBuffer, - FLMUINT uiPos1, - FLMUINT uiPos2); - - void flmQSortUINTSwap( - void * pvBuffer, - FLMUINT uiPos1, - FLMUINT uiPos2); - - void f_qsort( - void * pvBuffer, - FLMUINT uiLowerBounds, - FLMUINT uiUpperBounds, - F_SORT_COMPARE_FUNC fnCompare, - F_SORT_SWAP_FUNC fnSwap); - - /**************************************************************************** - Environment - ****************************************************************************/ - - void f_getenv( - const char * pszKey, - FLMBYTE * pszBuffer, - FLMUINT uiBufferSize, - FLMUINT * puiValueLen = NULL); - - /**************************************************************************** - NECESSARY INCLUDE FILES - ****************************************************************************/ - - #include "ftkmem.h" - -#endif // FTK_H diff --git a/xflaim/src/ftkdir.cpp b/xflaim/src/ftkdir.cpp deleted file mode 100644 index 291acf0..0000000 --- a/xflaim/src/ftkdir.cpp +++ /dev/null @@ -1,911 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Class for doing file directory operations. -// -// Tabs: 3 -// -// Copyright (c) 1998-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: ftkdir.cpp 3115 2006-01-19 13:24:39 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -#define ERR_NO_FILES_FOUND 0xFF -#define ERR_INVALID_PATH 0x9C - -#if defined( FLM_WIN) - - FSTATIC FLMBOOL f_fileMeetsFindCriteria( - F_IO_FIND_DATA * pFindData); - -#elif defined( FLM_UNIX) || defined( FLM_NLM) - - FSTATIC int Find1( - char * FindTemplate, - F_IO_FIND_DATA * DirInfo); - - - FSTATIC int Find2( - F_IO_FIND_DATA * DirStuff); - - FSTATIC FLMBYTE ReturnAttributes( - mode_t FileMode, - char * pszFileName); - - FSTATIC int RetrieveFileStat( - char * FilePath, - struct stat * StatusRec); - -#else - - #error Platform not supported - -#endif - -/**************************************************************************** -Desc: Constructor -****************************************************************************/ -F_DirHdl::F_DirHdl() -{ - m_rc = NE_XFLM_OK; - m_bFirstTime = TRUE; - m_bFindOpen = FALSE; - m_uiAttrib = 0; - m_szPattern[ 0] = '\0'; -} - -/**************************************************************************** -Desc: -****************************************************************************/ -const char * XFLMAPI F_DirHdl::CurrentItemName( void) -{ - const char * pszName = NULL; - - if( RC_OK( m_rc)) - { - pszName = m_szFileName; - } - - return( pszName); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMBOOL XFLMAPI F_DirHdl::CurrentItemIsDir( void) -{ - return( ((m_uiAttrib & XF_IO_FA_DIRECTORY) - ? TRUE - : FALSE)); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMUINT64 XFLMAPI F_DirHdl::CurrentItemSize( void) -{ - FLMUINT64 ui64Size = 0; - - if( RC_OK( m_rc)) - { -#if defined( FLM_WIN) - ui64Size = (((FLMUINT64)m_FindData.findBuffer.nFileSizeHigh) << 32) + - m_FindData.findBuffer.nFileSizeLow; -#elif defined( FLM_UNIX) || defined ( FLM_NLM) - ui64Size = m_FindData.FileStat.st_size; -#endif - } - return( ui64Size); -} - -/**************************************************************************** -Desc: Get the next item in a directory -****************************************************************************/ -RCODE XFLMAPI F_DirHdl::Next( void) -{ - char szFoundPath[ F_PATH_MAX_SIZE]; - char szDummyPath[ F_PATH_MAX_SIZE]; - FLMUINT uiSearchAttributes; - FLMUINT uiFoundAttrib; - - if( RC_BAD( m_rc)) - { - goto Exit; - } - - uiSearchAttributes = - XF_IO_FA_NORMAL | XF_IO_FA_RDONLY | XF_IO_FA_ARCHIVE | XF_IO_FA_DIRECTORY; - - for( ;;) - { - if ( m_bFirstTime ) - { - m_bFirstTime = FALSE; - - if( RC_BAD( m_rc = f_fileFindFirst( m_szDirectoryPath, uiSearchAttributes, - &m_FindData, szFoundPath, &uiFoundAttrib))) - { - goto Exit; - } - - m_bFindOpen = TRUE; - m_uiAttrib = uiFoundAttrib; - } - else - { - if( RC_BAD( m_rc = f_fileFindNext( &m_FindData, - szFoundPath, &uiFoundAttrib))) - { - goto Exit; - } - - m_uiAttrib = uiFoundAttrib; - } - - if( RC_BAD( m_rc = gv_pFileSystem->pathReduce( szFoundPath, - szDummyPath, m_szFileName))) - { - goto Exit; - } - - if( gv_pFileSystem->doesFileMatch( m_szFileName, m_szPattern)) - { - break; - } - } - -Exit: - - return( m_rc); -} - -/**************************************************************************** -Desc: Open a directory -****************************************************************************/ -RCODE XFLMAPI F_DirHdl::OpenDir( - const char * pszDirName, - const char * pszPattern) -{ - RCODE rc = NE_XFLM_OK; - - m_rc = NE_XFLM_OK; - m_bFirstTime = TRUE; - m_bFindOpen = FALSE; - m_uiAttrib = 0; - - f_strcpy( m_szDirectoryPath, pszDirName); - - if( pszPattern) - { - if( f_strlen( pszPattern) >= sizeof( m_szPattern)) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - f_strcpy( m_szPattern, pszPattern); - } - -Exit: - - return( rc); - -} - -/**************************************************************************** -Desc: Create a directory (and parent directories if necessary). -****************************************************************************/ -RCODE XFLMAPI F_DirHdl::CreateDir( - const char * pszDirPath) -{ - char * pszParentDir = NULL; - RCODE rc = NE_XFLM_OK; - - if( RC_BAD( rc = f_alloc( F_PATH_MAX_SIZE, &pszParentDir))) - { - goto Exit; - } - - // Discover the parent directory of the given one - - if( RC_BAD( rc = gv_pFileSystem->pathReduce( pszDirPath, - pszParentDir, NULL))) - { - goto Exit; - } - - // If gv_pFileSystem->pathReduce couldn't reduce the path at all, then an - // invalid path was supplied. - - if( f_strcmp( pszDirPath, pszParentDir) == 0) - { - rc = RC_SET( NE_XFLM_IO_INVALID_FILENAME); - goto Exit; - } - - // If a parent directory was found, and it doesn't already exist, create it - - if( *pszParentDir) - { - // If the "parent" is actually a regular file we need to return an error - - if( RC_OK( gv_pFileSystem->Exists( pszParentDir))) - { - if( !gv_pFileSystem->IsDir( pszParentDir)) - { - rc = RC_SET( NE_XFLM_IO_ACCESS_DENIED); - goto Exit; - } - } - - // Recurse on the parent directory - - else if( RC_BAD( rc = this->CreateDir( pszParentDir))) - { - goto Exit; - } - } - -#if defined( FLM_WIN) - - if( !CreateDirectory((LPTSTR)pszDirPath, NULL)) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_CREATING_FILE); - } - -#elif defined( FLM_UNIX) || defined( FLM_NLM) - - if( mkdir( (char *)pszDirPath, 0777) == -1) - { - rc = MapErrnoToFlaimErr( errno, NE_XFLM_CREATING_FILE); - } - -#endif - -Exit: - - if( pszParentDir) - { - f_free( &pszParentDir); - } - - return( rc); -} - -/**************************************************************************** -Desc: Remove a directory -Notes: The directory must be empty. -****************************************************************************/ -RCODE XFLMAPI F_DirHdl::RemoveDir( - const char * pszDirName) -{ -#if defined( FLM_WIN) - - if( !RemoveDirectory((LPTSTR)pszDirName)) - { - return( MapWinErrorToFlaim( GetLastError(), NE_XFLM_IO_DELETING_FILE)); - } - - return( NE_XFLM_OK); - -#elif defined( FLM_UNIX) || defined( FLM_NLM) - - if( rmdir( (char *)pszDirName) == -1) - { - return( MapErrnoToFlaimErr( errno, NE_XFLM_IO_DELETING_FILE)); - } - - return( NE_XFLM_OK); - -#endif -} - -/**************************************************************************** -Desc: Find the first file that matches the supplied criteria -****************************************************************************/ -RCODE f_fileFindFirst( - char * pszSearchPath, - FLMUINT uiSearchAttrib, - F_IO_FIND_DATA * pFindData, - char * pszFoundPath, - FLMUINT * puiFoundAttrib) -{ -#ifdef FLM_WIN - char szTmpPath[ F_PATH_MAX_SIZE]; - char * pszWildCard = "*.*"; - RCODE rc = NE_XFLM_OK; - - f_memset( pFindData, 0, sizeof( F_IO_FIND_DATA)); - pFindData->findHandle = INVALID_HANDLE_VALUE; - pFindData->uiSearchAttrib = uiSearchAttrib; - - if( !pszSearchPath) - { - rc = RC_SET( NE_XFLM_IO_PATH_NOT_FOUND); - goto Exit; - } - - f_strcpy( pFindData->szSearchPath, pszSearchPath); - - if( uiSearchAttrib & XF_IO_FA_NORMAL ) - { - uiSearchAttrib |= XF_IO_FA_ARCHIVE; - } - - f_strcpy( szTmpPath, pszSearchPath); - - if( RC_BAD( rc = gv_pFileSystem->pathAppend( szTmpPath, pszWildCard))) - { - goto Exit; - } - - if( (pFindData->findHandle = FindFirstFile( (LPTSTR)szTmpPath, - &(pFindData->findBuffer))) == INVALID_HANDLE_VALUE) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_OPENING_FILE); - goto Exit; - } - - // Loop until a file with correct attributes is found - - for( ;;) - { - if( f_fileMeetsFindCriteria( pFindData)) - { - break; - } - - if( FindNextFile( pFindData->findHandle, - &(pFindData->findBuffer)) == FALSE) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_READING_FILE); - goto Exit; - } - } - - // Append the file name to the path name - - f_strcpy( pszFoundPath, pFindData->szSearchPath); - - if( RC_BAD( rc = gv_pFileSystem->pathAppend( pszFoundPath, - (char *)pFindData->findBuffer.cFileName))) - { - goto Exit; - } - - // Return the found file attribute - - *puiFoundAttrib = pFindData->findBuffer.dwFileAttributes; - -Exit: - - if( RC_BAD( rc) && pFindData && - pFindData->findHandle != INVALID_HANDLE_VALUE) - { - f_fileFindClose( pFindData); - } - - return( rc); - -#else - - char szTmpPath[ F_PATH_MAX_SIZE]; - FSTATIC char pszWildCard[] = {'*',0}; - int iRetVal; - RCODE rc = NE_XFLM_OK; - - if( !pszSearchPath) - { - rc = RC_SET( NE_XFLM_IO_PATH_NOT_FOUND); - goto Exit; - } - - f_strcpy( szTmpPath, pszSearchPath); - if( RC_BAD( rc = gv_pFileSystem->pathAppend( szTmpPath, pszWildCard))) - { - goto Exit; - } - - f_memset( pFindData, 0, sizeof( F_IO_FIND_DATA)); - if( uiSearchAttrib & XF_IO_FA_DIRECTORY) - { - pFindData->mode_flag |= S_IFDIR; - } - - if( uiSearchAttrib & XF_IO_FA_RDONLY) - { - pFindData->mode_flag |= S_IREAD; - } - - iRetVal = Find1( (char*)szTmpPath, pFindData); - - if( iRetVal != 0) - { - // If there were no more files found then return no more files - // instead of mapping to error path not found or io error. - // To return no more files ret_val is ENOENT (set in Find2) - // and errno is not set - - if( iRetVal == ENOENT && errno == 0) - { - rc = RC_SET( NE_XFLM_IO_NO_MORE_FILES); - } - else - { - rc = MapErrnoToFlaimErr( errno, NE_XFLM_READING_FILE); - } - - goto Exit; - } - - // filter out ".." (PARENT) and "." (CURRENT) directories - - if( uiSearchAttrib & XF_IO_FA_DIRECTORY ) - { - while( (f_strcmp( (FLMBYTE *)pFindData->name, (FLMBYTE *)"..") == 0) || - (f_strcmp( (FLMBYTE *)pFindData->name, (FLMBYTE *)".") == 0)) - { - if( (iRetVal = Find2( pFindData)) != 0) - { - // If there were no more files found then return no more files - // instead of mapping to error path not found or io error. - // To return no more files ret_val is ENOENT (set in Find2) - // and errno is not set - - if( iRetVal == ENOENT && errno == 0) - { - rc = RC_SET( NE_XFLM_IO_NO_MORE_FILES); - } - else - { - rc = MapErrnoToFlaimErr( errno, NE_XFLM_READING_FILE); - } - - goto Exit; - } - } - } - - // Append the file name to the path name - - f_strcpy( pszFoundPath, pszSearchPath); - - if( RC_BAD( rc = gv_pFileSystem->pathAppend( pszFoundPath, - (char *)pFindData->name))) - { - goto Exit; - } - - *puiFoundAttrib = (FLMUINT)ReturnAttributes( - pFindData->FileStat.st_mode, pszFoundPath); - - // Save the search path in the NE_XFLM_IO_FIND_DATA struct - // for a find next call - - f_strcpy( pFindData->search_path, pszSearchPath); - -Exit: - - return( rc); -#endif -} - -/**************************************************************************** -Desc: Find the next file that matches the supplied criteria -****************************************************************************/ -RCODE f_fileFindNext( - F_IO_FIND_DATA * pFindData, - char * pszFoundPath, - FLMUINT * puiFoundAttrib) -{ - RCODE rc = NE_XFLM_OK; - -#ifdef FLM_WIN - - if( FindNextFile( pFindData->findHandle, - &(pFindData->findBuffer)) == FALSE) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_READING_FILE); - goto Exit; - } - - // Loop until a file with correct attributes is found - - for( ;;) - { - if( f_fileMeetsFindCriteria( pFindData)) - { - break; - } - - if( FindNextFile( pFindData->findHandle, - &(pFindData->findBuffer)) == FALSE) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_READING_FILE); - goto Exit; - } - } - - // Append the file name to the path name - - f_strcpy( pszFoundPath, pFindData->szSearchPath); - - if( RC_BAD( rc = gv_pFileSystem->pathAppend( pszFoundPath, - (char *)pFindData->findBuffer.cFileName))) - { - goto Exit; - } - - // Return the found file attribute - - *puiFoundAttrib = pFindData->findBuffer.dwFileAttributes; - -#elif defined( FLM_UNIX) || defined( FLM_NLM) - int iRetVal; - - if( (iRetVal = Find2( pFindData)) != 0) - { - // If there were no more files found then return no more files - // instead of mapping to error path not found or io error. - // To return no more files ret_val is ENOENT (set in Find2) - // and errno is not set - - if( iRetVal == ENOENT && errno == 0) - { - return( RC_SET( NE_XFLM_IO_NO_MORE_FILES)); - } - - return( MapErrnoToFlaimErr( errno, NE_XFLM_READING_FILE)); - } - - // Append the file name to the path name - - f_strcpy( pszFoundPath, pFindData->search_path); - - if( RC_BAD( rc = gv_pFileSystem->pathAppend( pszFoundPath, - (char *)pFindData->name))) - { - goto Exit; - } - - *puiFoundAttrib = (FLMUINT)ReturnAttributes( - pFindData->FileStat.st_mode, pszFoundPath); -#else - rc = RC_SET_AND_ASSERT( NE_XFLM_NOT_IMPLEMENTED); - goto Exit; -#endif - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Releases any memory allocated to an F_IO_FIND_DATA structure -****************************************************************************/ -void f_fileFindClose( - F_IO_FIND_DATA * pFindData) -{ -#ifdef FLM_WIN - - // Don't call it on an already closed or invalid handle. - - if( pFindData->findHandle != INVALID_HANDLE_VALUE) - { - FindClose( pFindData->findHandle ); - pFindData->findHandle = INVALID_HANDLE_VALUE; - } -#elif defined( FLM_UNIX) || defined ( FLM_NLM) - if( pFindData->globbuf.gl_pathv) - { - pFindData->globbuf.gl_offs = 0; - globfree( &pFindData->globbuf); - pFindData->globbuf.gl_pathv = 0; - } -#endif -} - -/**************************************************************************** -Desc: Find the next file that matches the supplied criteria -****************************************************************************/ -#ifdef FLM_WIN -FSTATIC FLMBOOL f_fileMeetsFindCriteria( - F_IO_FIND_DATA * pFindData) -{ - // Fail ".." (PARENT) and "." (CURRENT) directories. Then, - // if the file found possesses any of the search attributes, it's - // a match. - - if( !((f_strcmp( pFindData->findBuffer.cFileName, "..") == 0) || - (f_strcmp( pFindData->findBuffer.cFileName, ".") == 0) || - (!(pFindData->uiSearchAttrib & XF_IO_FA_DIRECTORY) && - (pFindData->findBuffer.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)))) - { - if( (pFindData->findBuffer.dwFileAttributes & - pFindData->uiSearchAttrib) || - ((pFindData->uiSearchAttrib & XF_IO_FA_NORMAL) && - (pFindData->findBuffer.dwFileAttributes == 0))) - { - return( TRUE); - } - } - - return( FALSE); -} -#endif - -/**************************************************************************** -Desc: Search for file names matching FindTemplate (UNIX) -****************************************************************************/ -#if defined( FLM_UNIX) || defined( FLM_NLM) - -FSTATIC int Find1( - char * FindTemplate, - F_IO_FIND_DATA * DirInfo) -{ - char MaskNam[ F_PATH_MAX_SIZE]; - char *PathSeparator; - FLMINT uiFindLen; - FLMINT uiLen; -#ifdef FLM_NLM - char szPosixNam[ F_PATH_MAX_SIZE]; - FLMINT uiCount; -#endif - - // If supplied template is illegal, return immediately - - if( (FindTemplate == (char*)NULL) || !( uiFindLen = f_strlen( FindTemplate))) - { - return( EINVAL); - } - - // Now separate the template into a PATH and a template MASK - // If no separating slash character found, use current directory - // as path! - - f_strcpy( DirInfo->full_path, FindTemplate); - -#ifdef FLM_NLM - if( (( PathSeparator = strrchr( DirInfo->full_path, '/')) == NULL) && - ( PathSeparator = strrchr( DirInfo->full_path, '\\')) == NULL) -#else - if( (PathSeparator = strrchr( DirInfo->full_path, '/')) == NULL) -#endif - { - (void) getcwd( DirInfo->full_path, F_PATH_MAX_SIZE); - uiLen = f_strlen( DirInfo->full_path ); - DirInfo->full_path[uiLen] = '/'; - DirInfo->full_path[uiLen+1] = '\0'; - (void) f_strcat( DirInfo->full_path, FindTemplate ); - PathSeparator = strrchr( DirInfo->full_path, '/'); - } - - // Copy the template MASK, and null terminate the PATH - - f_strcpy( MaskNam, PathSeparator + 1); - - if( ! f_strlen(MaskNam)) - { - (void) f_strcpy( MaskNam, "*"); - } - - *PathSeparator = '\0'; - - // Use ROOT directory if PATH is empty - - if( ! f_strlen(DirInfo->full_path)) - { - (void) f_strcpy( DirInfo->full_path, "/"); - } - - f_strcpy( DirInfo->dirpath, DirInfo->full_path ); - - // Open the specified directory. Return immediately - // if error detected! - - errno = 0; - DirInfo->globbuf.gl_pathv = 0; - -#ifdef FLM_NLM - // glob does not seem to be able to handle a non-posix path - // on NetWare. - for( uiCount = 0; uiCount <= uiFindLen; uiCount++) - { - if( FindTemplate[ uiCount] == '\\') - { - szPosixNam[ uiCount] = '/'; - } - else - { - szPosixNam[ uiCount] = FindTemplate[ uiCount]; - } - } - if( glob( szPosixNam, GLOB_NOSORT, 0, &DirInfo->globbuf) != 0 && - !DirInfo->globbuf.gl_pathc) -#else - if( glob( FindTemplate, GLOB_NOSORT, 0, &DirInfo->globbuf) != 0 && - !DirInfo->globbuf.gl_pathc) -#endif - { - globfree(&DirInfo->globbuf); - DirInfo->globbuf.gl_pathv = 0; - return ENOENT; - } - - // Call Find2 to get the 1st matching file - - return( Find2(DirInfo) ); -} -#endif - - -/**************************************************************************** -Desc: Search for file names matching FindTemplate (UNIX) -****************************************************************************/ -#if defined( FLM_UNIX) || defined( FLM_NLM) -FSTATIC int Find2( - F_IO_FIND_DATA * DirStuff) -{ - int stat; - glob_t * pglob = &DirStuff->globbuf; - char * pszTmp; - char * pszLastSlash; - - errno = 0; - - for( ;;) - { - if( pglob->gl_offs == pglob->gl_pathc) - { - pglob->gl_offs = 0; - globfree(pglob); - pglob->gl_pathv = 0; - return ENOENT; - } - - // Get status of file - - f_strcpy(DirStuff->full_path, pglob->gl_pathv[pglob->gl_offs++]); - if( (stat = RetrieveFileStat( DirStuff->full_path, - &DirStuff->FileStat)) != 0 ) - { - // If file name just read from directory is NO - // longer there (deleted by another process) - // then just advance to the next file in - // directory! - - if( stat == ENOENT) - { - continue; - } - else - { - break; - } - } - - // If we don't want directories, and current entry - // is a directory, then skip it! - - if( (! S_ISDIR(DirStuff->mode_flag)) && - S_ISDIR(DirStuff->FileStat.st_mode)) - { - continue; - } - - // If we only want regular files and file is NOT - // regular, then skip it! This means there is no - // way to retrieve named pipes, sockets, or links! - - if ( (DirStuff->mode_flag == XF_IO_FA_NORMAL) && - (! S_ISREG(DirStuff->FileStat.st_mode)) ) - { - continue; - } - - pszTmp = &DirStuff->full_path[ 0]; - pszLastSlash = NULL; - while( *pszTmp) - { - if( *pszTmp == '/') - { - pszLastSlash = pszTmp; - } - pszTmp++; - } - - if( pszLastSlash) - { - f_strcpy( DirStuff->name, &pszLastSlash[ 1]); - } - else - { - f_strcpy( DirStuff->name, DirStuff->full_path); - } - stat = 0; - break; - } - - return( stat); -} -#endif -/**************************************************************************** -Desc: Return file's attributes (UNIX) -****************************************************************************/ -#if defined( FLM_UNIX) || defined( FLM_NLM) -FSTATIC FLMBYTE ReturnAttributes( - mode_t FileMode, - char * fileName) -{ - FLMBYTE IOmode = 0; - - // Return the found file attribute - - if( S_ISDIR( FileMode ) ) - { - IOmode |= XF_IO_FA_DIRECTORY; - } - else - { - if( access( (char *)fileName, (int)(R_OK | W_OK)) == 0) - { - IOmode |= XF_IO_FA_NORMAL; - } - else if( access( (char *)fileName, (int)R_OK ) == 0) - { - IOmode |= XF_IO_FA_RDONLY; - } - } - - return( IOmode); -} -#endif - -/**************************************************************************** -Desc: Return file's attributes (UNIX) || (NetWare) -****************************************************************************/ -#if defined( FLM_UNIX) || defined( FLM_NLM) -FSTATIC int RetrieveFileStat( - char * FilePath, - struct stat * StatusRec) -{ - // Get status of last file read from directory, using the standard - // UNIX stat call - - errno = 0; - if( stat( FilePath, StatusRec ) == -1) - { - if( errno == ENOENT || errno == ELOOP) - { - // Get status of symbolic link rather than referenced file! - - errno = 0; - if( lstat( FilePath, StatusRec ) == -1) - { - return( errno); - } - } - else - { - return( errno); - } - } - - return( 0); -} -#endif diff --git a/xflaim/src/ftkmem.h b/xflaim/src/ftkmem.h deleted file mode 100644 index b9ad213..0000000 --- a/xflaim/src/ftkmem.h +++ /dev/null @@ -1,207 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Contains prototypes for memory functions. -// -// Tabs: 3 -// -// Copyright (c) 2000-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: ftkmem.h 3109 2006-01-19 13:07:07 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#ifndef FTKMEM_H -#define FTKMEM_H - -extern "C" -{ -#if defined( FLM_UNIX) - - #ifdef HAVE_CONFIG_H - #include "config.h" - #endif - - #if !defined ( USE_ALT_MEM_MANAGER) - #include - #endif -#else - #include -#endif -} - -#ifdef USE_ALT_MEM_MANAGER - - // Mappings - - #define os_malloc f_alt_malloc - #define os_realloc f_alt_realloc - #define os_free f_alt_free - -#else - - #define os_malloc malloc - #define os_realloc realloc - #define os_free free - -#endif - -typedef struct F_MemHdrTag -{ - FLMUINT uiDataSize; -#ifdef FLM_DEBUG - const char * pszFileName; - FLMINT iLineNumber; - FLMBOOL bAllocFromNewOp; - FLMUINT uiAllocationId; - FLMUINT uiAllocCnt; - FLMUINT * puiStack; -#endif -#if FLM_ALIGN_SIZE == 8 - FLMUINT uiDummy; -#endif -} F_MEM_HDR; - -#define F_GET_ALLOC_PTR( pDataPtr) \ - (FLMBYTE *)((FLMBYTE *)(pDataPtr) - sizeof( F_MEM_HDR)) - -#define F_GET_DATA_PTR( pAllocPtr) \ - (FLMBYTE *)((FLMBYTE *)(pAllocPtr) + sizeof( F_MEM_HDR)) - -#define F_GET_MEM_DATA_SIZE( pDataPtr) \ - (((F_MEM_HDR *)(F_GET_ALLOC_PTR( pDataPtr)))->uiDataSize) - -// Picket fence - -#define F_PICKET_FENCE "FFFFFFFF" -#if defined( FLM_DEBUG) -#define F_PICKET_FENCE_SIZE 8 -#else -#define F_PICKET_FENCE_SIZE 0 -#endif - -#ifdef FLM_DEBUG -RCODE f_allocImp( // Source: flalloc.cpp - FLMUINT uiSize, - void ** ppvPtr, - FLMBOOL bAllocFromNewOp, - const char * pszFileName, - FLMINT iLineNumber); - -RCODE f_callocImp( // Source: flalloc.cpp - FLMUINT uiSize, - void ** ppvPtr, - const char * pszFileName, - FLMINT iLineNumber); - -RCODE f_reallocImp( // Source: flalloc.cpp - FLMUINT uiSize, - void ** ppvPtr, - const char * pszFileName, - FLMINT iLineNumber); - -RCODE f_recallocImp( // Source: flalloc.cpp - FLMUINT uiSize, - void ** ppvPtr, - const char * pszFileName, - FLMINT iLineNumber); - -void f_resetStackInfoImp( // Source: flalloc.cpp - void * pvPtr, - const char * pszFileName, - FLMINT iLineNumber); - -#define f_alloc(uiSize,ppvPtr) \ - f_allocImp(uiSize,(void **)(ppvPtr),FALSE,__FILE__,__LINE__) - -#define f_calloc(uiSize,ppvPtr) \ - f_callocImp(uiSize,(void **)(ppvPtr),__FILE__,__LINE__) - -#define f_realloc(uiSize,ppvPtr) \ - f_reallocImp(uiSize,(void **)(ppvPtr),__FILE__,__LINE__) - -#define f_recalloc(uiSize,ppvPtr) \ - f_recallocImp(uiSize,(void **)(ppvPtr),__FILE__,__LINE__) - -#define f_resetStackInfo(pvPtr) \ - f_resetStackInfoImp(pvPtr,__FILE__,__LINE__) - -#else -RCODE f_allocImp( // Source: flalloc.cpp - FLMUINT uiSize, - void ** ppvPtr); - -RCODE f_callocImp( // Source: flalloc.cpp - FLMUINT uiSize, - void ** ppvPtr); - -RCODE f_reallocImp( // Source: flalloc.cpp - FLMUINT uiSize, - void ** ppvPtr); - -RCODE f_recallocImp( // Source: flalloc.cpp - FLMUINT uiSize, - void ** ppvPtr); - -#define f_alloc(uiSize,ppvPtr) \ - f_allocImp(uiSize,(void **)(ppvPtr)) - -#define f_calloc(uiSize,ppvPtr) \ - f_callocImp(uiSize,(void **)(ppvPtr)) - -#define f_realloc(uiSize,ppvPtr) \ - f_reallocImp(uiSize,(void **)(ppvPtr)) - -#define f_recalloc(uiSize,ppvPtr) \ - f_recallocImp(uiSize,(void **)(ppvPtr)) - -#define f_resetStackInfo(pvPtr) - -#endif - -#define f_free(ppvPtr) f_freeImp( (void **)ppvPtr,FALSE) - -void f_freeImp( // Source: flalloc.cpp - void ** ppvPtr, - FLMBOOL bFreeFromDeleteOp); - -FINLINE FLMUINT f_msize( - void * pvPtr) -{ -#if defined( FLM_UNIX) || defined( USE_ALT_MEM_MANAGER) - return( pvPtr ? F_GET_MEM_DATA_SIZE( (pvPtr)) : 0); -#elif defined ( FLM_NLM) - return( pvPtr ? msize( (F_GET_ALLOC_PTR( (pvPtr)))) : 0); -#else - return( pvPtr ? _msize( (F_GET_ALLOC_PTR( (pvPtr)))) : 0); -#endif -} - -void f_memoryInit( void); // Source: flalloc.cpp - -void f_memoryCleanup( void); // Source: flalloc.cpp - -FLMUINT * memWalkStack( void); - -void logMemLeak( - F_MEM_HDR * pHdr); - -#ifdef FLM_DEBUG - #define f_new new( __FILE__, __LINE__) -#else - #define f_new new -#endif - -#endif // FTKMEM_H diff --git a/xflaim/src/ftkmisc.cpp b/xflaim/src/ftkmisc.cpp deleted file mode 100644 index a9ffbd9..0000000 --- a/xflaim/src/ftkmisc.cpp +++ /dev/null @@ -1,398 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: This file contains misc toolkit functions -// -// Tabs: 3 -// -// Copyright (c) 2000-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: ftkmisc.cpp 3115 2006-01-19 13:24:39 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -// Global data - -FLMUINT gv_uiSerialInitCount = 0; -F_MUTEX gv_hSerialMutex = F_MUTEX_NULL; - -#ifdef FLM_UNIX - F_RandomGenerator gv_SerialRandom; -#endif - -#ifdef FLM_NLM - void f_sleep( - FLMUINT uiMilliseconds) - { - if( ! uiMilliseconds ) - { - kYieldThread(); - } - else - { - kDelayThread( uiMilliseconds); - } - } - -#endif - -#if defined( FLM_UNIX) - - #ifdef FLM_AIX - #ifndef nsleep - extern "C" - { - extern int nsleep( struct timestruc_t *, struct timestruc_t *); - } - #endif - #endif - -/**************************************************************************** -Desc: This routine causes the calling process to delay the given number - of milliseconds. Due to the nature of the call, the actual sleep - time is almost guaranteed to be different from requested sleep time. -In: milliseconds - the number of milliseconds to delay -****************************************************************************/ -void f_sleep( - FLMUINT uiMilliseconds) -{ -#ifdef FLM_AIX - struct timestruc_t timeout; - struct timestruc_t remain; -#else - struct timespec timeout; -#endif - - timeout.tv_sec = (uiMilliseconds / 1000); - timeout.tv_nsec = (uiMilliseconds % 1000) * 1000000; - -#ifdef FLM_AIX - nsleep(&timeout, &remain); -#else - nanosleep(&timeout, 0); -#endif -} -#endif - -/*************************************************************************** -Desc: Map POSIX errno to Flaim IO errors. -***************************************************************************/ -#if defined( FLM_UNIX) || defined( FLM_NLM) -RCODE MapErrnoToFlaimErr( - int err, - RCODE defaultRc) -{ - /* Switch on passed in error code value */ - - switch (err) - { - case 0: - return( NE_XFLM_OK); - - case ENOENT: - return( RC_SET( NE_XFLM_IO_PATH_NOT_FOUND)); - - case EACCES: - case EEXIST: - return( RC_SET( NE_XFLM_IO_ACCESS_DENIED)); - - case EINVAL: - return( RC_SET( NE_XFLM_IO_PATH_TOO_LONG)); - - case EIO: - return( RC_SET( NE_XFLM_IO_DISK_FULL)); - - case ENOTDIR: - return( RC_SET( NE_XFLM_IO_DIRECTORY_ERR)); - -#ifdef EBADFD - case EBADFD: - return( RC_SET( NE_XFLM_IO_BAD_FILE_HANDLE)); -#endif - -#ifdef EOF - case EOF: - return( RC_SET( NE_XFLM_IO_END_OF_FILE)); -#endif - - case EMFILE: - return( RC_SET( NE_XFLM_IO_NO_MORE_FILES)); - - default: - return( RC_SET( defaultRc)); - } -} -#endif - -/**************************************************************************** -Desc: This routine initializes the serial number generator. If the O/S - does not provide support for GUID generation or if the GUID - routines fail for some reason, a pseudo-GUID will be generated. -Notes: This routine should only be called once by the process. -****************************************************************************/ -RCODE f_initSerialNumberGenerator( void) -{ - FLMUINT uiTime; - RCODE rc = NE_XFLM_OK; - - if (++gv_uiSerialInitCount > 1) - { - goto Exit; - } - - if( RC_BAD( rc = f_mutexCreate( &gv_hSerialMutex))) - { - goto Exit; - } - - f_timeGetSeconds( &uiTime ); - -#if defined( FLM_UNIX) - gv_SerialRandom.randomSetSeed( (FLMUINT32)(uiTime ^ (FLMUINT)getpid())); -#endif - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: This routine will use the operating system calls to generate a - "globally unique" identifier. Typically, this is based on the - MAC address of an ethernet card installed in the machine. If the - machine does not have an ethernet card, or if the OS does not - support generating GUIDs, this routine will generate a pseudo-GUID - using a random number generator. A serial number is 16-bytes. -****************************************************************************/ -RCODE f_createSerialNumber( - FLMBYTE * pszSerialNum) -{ - RCODE rc = NE_XFLM_OK; - -#if defined( FLM_WIN) - - UUID uuidVal; - RPC_STATUS err = UuidCreate( &uuidVal); - - if (err == RPC_S_OK || err == RPC_S_UUID_LOCAL_ONLY) - { - UD2FBA( (FLMUINT32)uuidVal.Data1, &pszSerialNum[ 0]); - UW2FBA( (FLMUINT16)uuidVal.Data2, &pszSerialNum[ 4]); - UW2FBA( (FLMUINT16)uuidVal.Data3, &pszSerialNum[ 6]); - f_memcpy( &pszSerialNum[ 8], (FLMBYTE *)uuidVal.Data4, 8); - goto Exit; - } - -#elif defined( FLM_NLM) - - NWGUID guidVal; - int err = SGUIDCreate( &guidVal); - - if( !err || err == 1) // NOTE: 1 == SGUID_WARN_RANDOM_NODE - { - UD2FBA( guidVal.time_low, &pszSerialNum[ 0]); - UW2FBA( guidVal.time_mid, &pszSerialNum[ 4]); - UW2FBA( guidVal.time_hi_and_version, &pszSerialNum[ 6]); - pszSerialNum[ 8] = guidVal.clk_seq_hi_res; - pszSerialNum[ 9] = guidVal.clk_seq_low; - f_memcpy( &pszSerialNum[ 10], (FLMBYTE *)guidVal.node, 6); - goto Exit; - } - -#elif defined( FLM_UNIX) - - // Generate a pseudo GUID value - - flmAssert( gv_hSerialMutex != F_MUTEX_NULL); - - f_mutexLock( gv_hSerialMutex); - - UD2FBA( (FLMUINT32)gv_SerialRandom.randomLong(), &pszSerialNum[ 0]); - UD2FBA( (FLMUINT32)gv_SerialRandom.randomLong(), &pszSerialNum[ 4]); - UD2FBA( (FLMUINT32)gv_SerialRandom.randomLong(), &pszSerialNum[ 8]); - UD2FBA( (FLMUINT32)gv_SerialRandom.randomLong(), &pszSerialNum[ 12]); - - f_mutexUnlock( gv_hSerialMutex); - -#endif - -#if defined( FLM_WIN) || defined( FLM_NLM) -Exit: -#endif - - return( rc); -} - -/**************************************************************************** -Notes: This routine should only be called once by the process. -****************************************************************************/ -void f_freeSerialNumberGenerator( void) -{ - if( (--gv_uiSerialInitCount) > 0) - { - return; - } - - if( gv_hSerialMutex != F_MUTEX_NULL) - { - f_mutexDestroy( &gv_hSerialMutex); - } -} - -/**************************************************************************** -Desc: Generates a table of remainders for each 8-bit byte. The resulting - table is used by flmUpdateCRC to calculate a CRC value. The table - must be freed via a call to f_freeCRCTable. -*****************************************************************************/ -RCODE f_initCRCTable( - FLMUINT32 ** ppui32CRCTbl) -{ - FLMUINT32 * pTable; - FLMUINT32 ui32Val; - FLMUINT32 ui32Loop; - FLMUINT32 ui32SubLoop; - RCODE rc = NE_XFLM_OK; - - // Use the standard degree-32 polynomial used by - // Ethernet, PKZIP, etc. for computing the CRC of - // a data stream. This is the little-endian - // representation of the polynomial. The big-endian - // representation is 0x04C11DB7. - -#define CRC_POLYNOMIAL ((FLMUINT32)0xEDB88320) - - *ppui32CRCTbl = NULL; - - if( RC_BAD( rc = f_alloc( 256 * sizeof( FLMUINT32), &pTable))) - { - goto Exit; - } - - for( ui32Loop = 0; ui32Loop < 256; ui32Loop++) - { - ui32Val = ui32Loop; - for( ui32SubLoop = 0; ui32SubLoop < 8; ui32SubLoop++) - { - if( ui32Val & 0x00000001) - { - ui32Val = CRC_POLYNOMIAL ^ (ui32Val >> 1); - } - else - { - ui32Val >>= 1; - } - } - - pTable[ ui32Loop] = ui32Val; - } - - *ppui32CRCTbl = pTable; - pTable = NULL; - -Exit: - - if( pTable) - { - f_free( &pTable); - } - - return( rc); -} - -/**************************************************************************** -Desc: Computes the CRC of the passed-in data buffer. Multiple calls can - be made to this routine to build a CRC over multiple data buffers. - On the first call, *pui32CRC must be initialized to something - (0, etc.). For generating CRCs that are compatible with PKZIP, - *pui32CRC should be initialized to 0xFFFFFFFF and the ones complement - of the resulting CRC should be computed. -*****************************************************************************/ -void f_updateCRC( - FLMUINT32 * pui32CRCTbl, - FLMBYTE * pucBlk, - FLMUINT uiBlkSize, - FLMUINT32 * pui32CRC) -{ - FLMUINT32 ui32CRC = *pui32CRC; - FLMUINT uiLoop; - - for( uiLoop = 0; uiLoop < uiBlkSize; uiLoop++) - { - ui32CRC = (ui32CRC >> 8) ^ pui32CRCTbl[ - ((FLMBYTE)(ui32CRC & 0x000000FF)) ^ pucBlk[ uiLoop]]; - } - - *pui32CRC = ui32CRC; -} - -/**************************************************************************** -Desc: -****************************************************************************/ -FLMUINT f_breakpoint( - FLMUINT uiBreakFlag) -{ - if( uiBreakFlag) - { -#ifdef FLM_NLM - EnterDebugger(); -#else - flmAssert( 0); -#endif - } - - return( 0); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void f_getenv( - const char * pszKey, - FLMBYTE * pszBuffer, - FLMUINT uiBufferSize, - FLMUINT * puiValueLen) -{ - FLMUINT uiValueLen = 0; - - if( !uiBufferSize) - { - goto Exit; - } - - pszBuffer[ 0] = 0; - -#if defined( FLM_WIN) || defined( FLM_UNIX) - char * pszValue; - - if( (pszValue = getenv( pszKey)) != NULL && - (uiValueLen = f_strlen( pszValue)) < uiBufferSize) - { - f_strcpy( pszBuffer, pszValue); - } -#else - F_UNREFERENCED_PARM( pszKey); -#endif - -Exit: - - if( puiValueLen) - { - *puiValueLen = uiValueLen; - } - - return; -} diff --git a/xflaim/src/ftkpath.cpp b/xflaim/src/ftkpath.cpp deleted file mode 100644 index 4550ff6..0000000 --- a/xflaim/src/ftkpath.cpp +++ /dev/null @@ -1,775 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Contains functions for file name/path manipulation -// -// Tabs: 3 -// -// Copyright (c) 1998-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: ftkpath.cpp 3115 2006-01-19 13:24:39 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -FSTATIC FLMBOOL f_canReducePath( - const char * pszSource); - -FSTATIC const char * f_findFileNameStart( - const char * pszPath); - -FSTATIC char * f_getPathComponent( - char ** ppszPath, - FLMUINT * puiEndChar); - -/**************************************************************************** -Desc: Returns TRUE if character is a "slash" separator -****************************************************************************/ -FINLINE FLMBOOL f_isSlashSeparator( - char cChar) -{ -#ifdef FLM_UNIX - return( cChar == '/' ? TRUE : FALSE); -#else - return( cChar == '/' || cChar == '\\' ? TRUE : FALSE); -#endif -} - -/**************************************************************************** -Desc: Return a pointer to the next path component in ppszPath. -****************************************************************************/ -FSTATIC char * f_getPathComponent( - char ** ppszPath, - FLMUINT * puiEndChar) -{ - char * pszComponent; - char * pszEnd; - - pszComponent = pszEnd = *ppszPath; - if (f_isSlashSeparator( *pszEnd)) - { - // handle the condition of sys:\system the colon would have terminated - // the previous token, to pComponent would now be pointing at the '\'. - // We need to move past the '\' to find the next token. - - pszEnd++; - } - - // Find the end of the path component - - while (*pszEnd) - { - if (f_isSlashSeparator( *pszEnd) -#ifndef FLM_UNIX - || *pszEnd == ':' -#endif - ) - { - break; - } - pszEnd++; - } - - if (*pszEnd) - { - - // A delimiter was found, assume that there is another path component - // after this one. - // Return a pointer to the beginning of the next path component - - *ppszPath = pszEnd + 1; - - *puiEndChar = *pszEnd; - - // NULL terminate the path component - - *pszEnd = 0; - } - else - { - - // There is no "next path component" so return a pointer to the - // NULL-terminator - - *ppszPath = pszEnd; - *puiEndChar = 0; - } - - // Return the path component - - return( pszComponent); -} - -/**************************************************************************** -Desc: Split the path into its components -Output: - pServer - pointer to a buffer to hold the server name - pVolume - pointer to a buffer to hold the volume name - pDirPath - pointer to a buffer to hold the path - pFileName pointer to a buffer to hold the filename - - All of the output parameters are optional. If you do not want one - of the components, simply give a NULL pointer. - -Note: if the input path has no file name, d:\dir_1 for example, then - pass a NULL pointer for pFileName. Otherwise dir_1 will be returned - as pFileName. - - The server name may be ommitted in the input path: - sys:\system\autoexec.ncf - - UNC paths of the form: - \\server-name\volume-name\dir_1\dir_2\file.ext - are supported. - - DOS paths of the form: - d:\dir_1\dir_2\file.ext - are also supported. - -Example: - Given this input: orm-prod48/sys:\system\autoexec.ncf - The output would be: - pServer = "orm-prod48" - pVolume = "sys:" - pDirPath = "\system" - pFileName "autoexec.ncf" -****************************************************************************/ -void XFLMAPI F_FileSystem::pathParse( - const char * pszInputPath, - char * pszServer, - char * pszVolume, - char * pszDirPath, - char * pszFileName) -{ - char szInput[ F_PATH_MAX_SIZE]; - char * pszNext; - char * pszColon; - char * pszComponent; - FLMUINT uiEndChar; - FLMBOOL bUNC = FALSE; - - // Initialize return buffers - - if (pszServer) - { - *pszServer = 0; - } - if (pszVolume) - { - *pszVolume = 0; - } - if (pszDirPath) - { - *pszDirPath = 0; - } - if (pszFileName) - { - - // Get the file name - - *pszFileName = 0; - pathReduce( pszInputPath, szInput, pszFileName); - } - else - { - f_strcpy( szInput, pszInputPath); - } - - // Split out the rest of the components - - pszComponent = &szInput [0]; - - // Is this a UNC path? - - if (szInput[0] == '\\' && szInput[1] == '\\') - { - - // Yes, assume a UNC path - - pszComponent += 2; - bUNC = TRUE; - } - - pszNext = pszColon = pszComponent; - - // Is there a ':' in the szInput path? - - while (*pszColon && *pszColon != ':') - { - pszColon++; - } - if (*pszColon || bUNC) - { - - // Yes, assume there is a volume in the path - - pszComponent = f_getPathComponent( &pszNext, &uiEndChar); - if (uiEndChar != ':') - { - // Assume that this component is the server - - if (pszServer) - { - f_strcpy( pszServer, pszComponent); - } - - // Get the next component - - pszComponent = f_getPathComponent( &pszNext, &uiEndChar); - } - - // Assume that this component is the volume - - if (pszVolume) - { - char * pszSrc = pszComponent; - char * pszDst = pszVolume; - - while (*pszSrc) - { - *pszDst++ = *pszSrc++; - } - *pszDst++ = ':'; - *pszDst = 0; - } - - // For UNC paths, the leading '\' of the path is set to 0 by - // f_getPathComponent. This code restores the leading '\'. - - if (f_isSlashSeparator( (char)uiEndChar)) - { - *(--pszNext) = (char)uiEndChar; - } - } - - // Assume that all that is left of the input is the path - - if (pszDirPath) - { - f_strcpy( pszDirPath, pszNext); - } -} - -/**************************************************************************** -Desc: Will determine whether any format of (UNC, drive based, NetWare - UNC) path can be reduced any further. -****************************************************************************/ -FSTATIC FLMBOOL f_canReducePath( - const char * pszSource) -{ -#if defined FLM_UNIX - F_UNREFERENCED_PARM( pszSource); - return( TRUE); -#else - FLMBOOL bCanReduce; - const char * pszTemp = pszSource; - - // Determine whether the passed path is UNC or not - // (UNC format is: \\FileServer\Volume\Path). - - if (f_strncmp( "\\\\", pszSource, 2 ) == 0) - { - FLMUINT uiSlashCount = 0; - - pszTemp += 2; - - // Search forward for at least two slash separators - // If we find at least two, the path can be reduced. - - bCanReduce = FALSE; - while (*pszTemp) - { - pszTemp++; - if (f_isSlashSeparator( *pszTemp)) - { - ++uiSlashCount; - if (uiSlashCount == 2) - { - bCanReduce = TRUE; - break; - } - } - } - } - else - { - bCanReduce = TRUE; - - // Search forward for the colon. - - while (*pszTemp) - { - if (*pszTemp == ':') - { - - // If nothing comes after the colon, - // we can't reduce any more. - - if (*(pszTemp + 1) == 0) - { - bCanReduce = FALSE; - } - break; - } - pszTemp++; - } - } - - return( bCanReduce); -#endif -} - -/**************************************************************************** -Desc: Return pointer to start of filename part of path. - Search for the last slash separator. -****************************************************************************/ -FSTATIC const char * f_findFileNameStart( - const char * pszPath) -{ - const char * pszFileNameStart; - - pszFileNameStart = pszPath; - while (*pszPath) - { - if (f_isSlashSeparator( *pszPath)) - { - pszFileNameStart = pszPath + 1; - } - pszPath++; - } - return( pszFileNameStart); -} - -/**************************************************************************** -Desc: This function will strip off the filename or trailing - directory of a path. The stripped component of the path will - be placed into the area pointed at by string. The source - path will not be modified. The dest path will contain the - remainder of the stripped path. A stripped path can be processed - repeatedly by this function until there is no more path to reduce. - If the string is set to NULL, the copying of the stripped portion of - the path will be bypassed by the function. - -Notes: This function handles drive based, UNC, Netware, and UNIX type - paths. -****************************************************************************/ -RCODE XFLMAPI F_FileSystem::pathReduce( - const char * pszPath, - char * pszDir, - char * pszPathComponent) -{ - RCODE rc = NE_XFLM_OK; - const char * pszFileNameStart; - char szLocalPath[ F_PATH_MAX_SIZE]; - FLMUINT uiLen; - - // Check for valid path pointers - - if( !pszPath || !pszDir) - { - rc = RC_SET( NE_XFLM_INVALID_PARM); - goto Exit; - } - - if ((uiLen = f_strlen( pszPath)) == 0) - { - rc = RC_SET( NE_XFLM_IO_CANNOT_REDUCE_PATH); - goto Exit; - } - - // Trim out any trailing slash separators - - if( f_isSlashSeparator( pszPath [uiLen - 1])) - { - f_strcpy( szLocalPath, pszPath); - - while( f_isSlashSeparator( szLocalPath[ uiLen - 1])) - { - szLocalPath[ --uiLen] = 0; - if( !uiLen) - { - rc = RC_SET( NE_XFLM_IO_CANNOT_REDUCE_PATH); - goto Exit; - } - } - - pszPath = szLocalPath; - } - - if( f_canReducePath( pszPath)) - { - // Search for a slash or beginning of path - - pszFileNameStart = f_findFileNameStart( pszPath); - - // Copy the sliced portion of the path if requested by caller - - if( pszPathComponent) - { - f_strcpy( pszPathComponent, pszFileNameStart); - } - - // Copy the reduced source path to the dir path - - if (pszFileNameStart > pszPath) - { - uiLen = (FLMUINT)(pszFileNameStart - pszPath); - f_memcpy( pszDir, pszPath, uiLen); - - if (uiLen >= 2 && f_isSlashSeparator( pszDir [uiLen - 1]) -#ifndef FLM_UNIX - && pszDir [uiLen - 2] != ':' -#endif - ) - { - // Trim off the trailing path separator - - pszDir [uiLen - 1] = 0; - } - else - { - pszDir [uiLen] = 0; - } - } - else - { - *pszDir = 0; - } - } - else - { - // We've found the drive id or server\volume specifier. - - if (pszPathComponent) - { - f_strcpy( pszPathComponent, pszPath); - } - - *pszDir = 0; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Internal function for WpioPathBuild() and WpioPathModify(). - Appends string the path & adds a path delimiter if necessary. -In: *path = pointer to an IO_PATH - *string = pointer to a NULL terminated string - *end_ptr = pointer to the end of the IO_PATH which is being built. -****************************************************************************/ -RCODE XFLMAPI F_FileSystem::pathAppend( - char * pszPath, - const char * pszPathComponent) -{ - - // Don't put a slash separator if pszPath is empty - - if (*pszPath) - { - FLMUINT uiStrLen = f_strlen( pszPath); - char * pszEnd = pszPath + uiStrLen - 1; - - if (!f_isSlashSeparator( *pszEnd)) - { - - // Check for maximum path size - 2 is for slash separator - // and null byte. - - if (uiStrLen + 2 + f_strlen( pszPathComponent) > F_PATH_MAX_SIZE) - { - return RC_SET( NE_XFLM_IO_PATH_TOO_LONG); - } - - pszEnd++; -#if defined( FLM_UNIX) - *pszEnd = '/'; -#else - *pszEnd = '\\'; -#endif - } - else - { - - // Check for maximum path size +1 is for null byte. - - if (uiStrLen + 1 + f_strlen( pszPathComponent) > F_PATH_MAX_SIZE) - { - return RC_SET( NE_XFLM_IO_PATH_TOO_LONG); - } - } - - f_strcpy( pszEnd + 1, pszPathComponent); - } - else - { - f_strcpy( pszPath, pszPathComponent); - } - - return( NE_XFLM_OK); -} - -/**************************************************************************** -Desc: Convert an PATH into a fully qualified, storable C string - reference to a file or directory. -In: pszPath - the path to convert. - pszStorageString - a pointer to a string that is atleast - F_PATH_MAX_SIZE in size -****************************************************************************/ -RCODE XFLMAPI F_FileSystem::pathToStorageString( - const char * pszPath, - char * pszStorageString) -{ -#ifdef FLM_WIN - char * pszNamePart; - - if (GetFullPathName( (LPCSTR)pszPath, - (DWORD)F_PATH_MAX_SIZE - 1, - (LPSTR)pszStorageString, - (LPSTR *)&pszNamePart) != 0) - { - - } - else - { - // Convert to upper case. - - while (*pszPath) - { - *pszStorageString++ = *pszPath; - pszPath++; - } - *pszStorageString = 0; - } - return NE_XFLM_OK; -#else - - char szFile[ F_PATH_MAX_SIZE]; - char szDir[ F_PATH_MAX_SIZE]; - char * pszRealPath = NULL; - RCODE rc = NE_XFLM_OK; - - if (RC_BAD( rc = pathReduce( pszPath, szDir, szFile))) - { - goto Exit; - } - - if (!szDir [0]) - { - szDir [0] = '.'; - szDir [1] = '\0'; - } - - if (RC_BAD( rc = f_alloc( (FLMUINT)PATH_MAX, &pszRealPath))) - { - goto Exit; - } - - if (!realpath( (char *)szDir, (char *)pszRealPath)) - { - rc = MapErrnoToFlaimErr( errno, NE_XFLM_PARSING_FILE_NAME); - goto Exit; - } - - if (f_strlen( pszRealPath) >= F_PATH_MAX_SIZE) - { - rc = RC_SET( NE_XFLM_IO_PATH_TOO_LONG); - goto Exit; - } - - f_strcpy( pszStorageString, pszRealPath); - - if (RC_BAD( rc = pathAppend( pszStorageString, szFile))) - { - goto Exit; - } - -Exit: - - if (pszRealPath) - { - f_free( &pszRealPath); - } - - return( rc); -#endif -} - -/**************************************************************************** -Desc: -****************************************************************************/ -FINLINE void HexToNative( - FLMBYTE ucHexVal, - char * pszNativeChar) -{ - *pszNativeChar = (char)(ucHexVal < 10 - ? ucHexVal + NATIVE_ZERO - : (ucHexVal - 10) + NATIVE_LOWER_A); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -FINLINE void SetUpTime( - FLMUINT * puiBaseTime, - FLMBYTE * pbyHighByte) -{ - FLMUINT uiSdTime = 0; - f_timeGetSeconds( &uiSdTime); - *pbyHighByte = (FLMBYTE)(uiSdTime >> 24); - uiSdTime = uiSdTime << 5; - if( *puiBaseTime < uiSdTime) - *puiBaseTime = uiSdTime; -} - -/**************************************************************************** -Desc: Generates a file name given a seed and some modifiers, it is built - to be called in a loop until the file can be sucessfully written or - created with the increment being changed every time. -In: bModext -> if TRUE then we will use the extension for collisions. -In\Out: puiTime -> a modified time stamp which is used as the base - filename. To properly set up this value, make sure - the puiTime points to a 0 the first time this routine - is called and it will be set up for you. Thereafter, - do not change it between calls. - pHighChars-> these are the 8 bits that were shifted off the top of - the time struct. It will be set up for you the first - time you call this routine if puiTime points to a 0 - the first time this routine is called. Do not change - this value between calls. - pszFileName -> should be pointing to a null string on the way in. - going out it will be the complete filename. - pszFileExt -> the last char of the ext will be used for collisions, - depending on the bModext flag. If null then - the extension will be .00x where x is the collision - counter. -Notes: The counter on the collision is 0-9, a-z. -****************************************************************************/ -void XFLMAPI F_FileSystem::pathCreateUniqueName( - FLMUINT * puiTime, - char * pszFileName, - const char * pszFileExt, - FLMBYTE * pHighChars, - FLMBOOL bModext) -{ - FLMINT iCount, iLength; - FLMUINT uiSdTmp = 0; - FLMUINT uiIncVal = 1; - - SetUpTime( puiTime, pHighChars); - uiSdTmp = *puiTime; - - /* Add on the filename extension if passed from the caller */ - *(pszFileName + 8) = NATIVE_DOT; - f_memset( (pszFileName + 9), NATIVE_ZERO, 3 ); - if ( ( pszFileExt != NULL )) - { - if ((iLength = f_strlen(pszFileExt)) > 3) - { - iLength = 3; - } - f_memmove( (pszFileName + 9), pszFileExt, iLength); - } - - if( bModext == TRUE) - { - HexToNative((FLMBYTE)(uiSdTmp & 0x0000001F), pszFileName+(11)); - } - else - { - uiIncVal = 32; - } - uiSdTmp = uiSdTmp >> 5; - for( iCount = 0; iCount < 6; iCount++) /* set pos 2-7 of filename */ - { - HexToNative((FLMBYTE)(uiSdTmp & 0x0000000F), pszFileName+(7-iCount)); - uiSdTmp = uiSdTmp >> 4; - } /* End for() */ - - for( iCount = 0; iCount < 2; iCount++) /* set pos 0-1 of filename */ - { - HexToNative((FLMBYTE)(*pHighChars & 0x0000000F), pszFileName+(1-iCount)); - *pHighChars = *pHighChars >> 4; - } /* End for() */ - - /* Append on a NULL terminator */ - *(pszFileName + 12) = '\0'; - *puiTime += uiIncVal; - - return; -} - -/**************************************************************************** -Desc: Compares the current file against a pattern template -****************************************************************************/ -FLMBOOL XFLMAPI F_FileSystem::doesFileMatch( - const char * pszFileName, - const char * pszTemplate) -{ - FLMUINT uiPattern; - FLMUINT uiChar; - - if( !*pszTemplate) - { - return( TRUE); - } - - while( *pszTemplate) - { - uiPattern = *pszTemplate++; - switch( uiPattern) - { - case NATIVE_WILDCARD: - /* if the match_template ends in an asterisk, then we match the*/ - /* remaining string by default, return a match. */ - - if( *pszTemplate == 0) - { - return( TRUE); - } - - /* Found an asterisk somewhere in the match_template, now let's - see if we match anywhere on the remaining input string. */ - - while( *pszFileName) - { - if( gv_pFileSystem->doesFileMatch( pszFileName, pszTemplate)) - { - return( TRUE); /* found a match, return */ - } - pszFileName++; - } - return( FALSE); /* did not find match, return */ - case NATIVE_QUESTIONMARK: - if( *pszFileName++ == 0) /* skip one character for '?' */ - { - return( FALSE); - } - break; - default: - uiChar = *pszFileName++; - if( f_toupper( uiPattern) != f_toupper( uiChar)) - { - return( FALSE); - } - break; - } - } - - return( (*pszFileName != 0) ? FALSE : TRUE ); -} diff --git a/xflaim/src/ftkrand.cpp b/xflaim/src/ftkrand.cpp deleted file mode 100644 index c12424d..0000000 --- a/xflaim/src/ftkrand.cpp +++ /dev/null @@ -1,206 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Random number routines -// -// Tabs: 3 -// -// Copyright (c) 1995-1998, 2000, 2003,2005-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: ftkrand.cpp 3115 2006-01-19 13:24:39 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -/**************************************************************************** - This random number generator is based on Park & Miller's "suggested -minimal standard" for random number generation, pp 1192-1201 of the Oct 1988 -issue of _Communications_of_the_ACM_ (vol 31 number 10). It is a Lehmer -generator, which are of the form x[n] = A * x[n-1] % M, with A and M being -judiciously chosen constants. More formally, this is a "prime modulus -multiplicative linear congruential generator," or PMMLCG. - Park & Miller originally suggested A==16807 and M==2**31-1, but an update -in CACM Vol 36, No. 7 pp 108-110 (July 1993) indicates that they have found -a better multiplier (A == 48271) to use with the same modulus (2**31-1). -This implementation uses the updated multiplier. - To quote Park & Miller 1988, "We believe that this is the generator that -should always be used--unless one has access to a random number generator -KNOWN to be better." - This algorithm produces a full-period generator; that is, starting from -any seed between 1 and 2**31-2, it generates all other values between 1 -and 2**31-2 before it returns to the starting point -- whereupon it repeats -the same sequence of 31-bit values. This is true for either choice of A -(16807 or 48271). - The July 1993 article includes criticism by George Marsaglia of the Park -and Miller generator. Marsaglia feels that longer periods are needed. For -a description of his "subtract-with-borrow" (SWB) generators, see "A New -Class of Random Number Generators", The Annals of Applied Probability, -(1991) Vol. 1, No. 3, pp. 462-480. These generators require more state -information (~48 longwords) but produce generators with periods on the -order of 10**445. They also pass more stringent tests than the congruential -generators, and so might be considered 'a random number generator KNOWN to -be better.' However, Marsaglia does not spell out all the details needed to -implement SWB, nor does he give any simple test to determine whether an SWB -implementation is correct. -****************************************************************************/ - -/************************************************************************* -Desc: Set the seed from the date and time -*************************************************************************/ -void F_RandomGenerator::randomize( void) -{ - FLMUINT uiTime; - - f_timeGetSeconds( &uiTime ); - randomSetSeed( (FLMUINT32)(((FLMUINT32)uiTime % MAX_RANDOM) + 1)); -} - -/************************************************************************* -Desc: initialize the seed to a known value -*************************************************************************/ -void F_RandomGenerator::randomSetSeed( - FLMINT32 ui32Seed) -{ - register FLMINT32 i32Seed = (FLMINT32)ui32Seed; - - if( i32Seed > 0 && i32Seed <= MAX_RANDOM) - { - m_i32Seed = i32Seed; - } - else - { - randomSetSeed( (FLMUINT32) - (i32Seed < 1 - ? i32Seed + MAX_RANDOM - : i32Seed - MAX_RANDOM)); - } -} - -/************************************************************************* -Desc: Generate the next number in the pseudo-random sequence - i.e., "f_randomLong( &r) > MAX_RANDOM/2" will be true half the - time, on average. Likewise, "f_randomLong( &r) & 0x1" has a 50-50 - chance of being true. -*************************************************************************/ -FLMINT32 F_RandomGenerator::randomLong( void) -{ - -#define M 2147483647 /* PMMLCG modulus == MAX_RANDOM + 1 */ -#define A 48271 /* PMMLCG multiplier */ -#define CHECK 399268537 /* produced by 10000 iterations from seed of 1 */ - - register FLMUINT32 hi; - register FLMUINT32 lo; - register FLMUINT32 ui32Seed = m_i32Seed; /* input is 31-bit number */ - - hi = (ui32Seed >> 16); /* hi = a (high-order 15 bits of x[n-1]) */ - lo = ui32Seed & 0xFFFF; /* lo = b (low-order 16 bits of x[n-1]) */ - lo *= A; /* lo = c * b = d:e (16:16 bits = 32 bits) */ - hi *= A; /* hi = c * a = f:g (15:16 bits = 31 bits) */ - - hi += (lo >> 16) & 0xFFFF; /* hi = f:g + d = h (31 bits) */ - lo &= 0xFFFF; /* lo = e (16 bits) */ - - /* - * Now, the 'longhand' product has been calculated. It is stored in - * hi:lo (31:16 bits) = h:e (31:16 bits). - * - * Now, redistribute the number h:e (31:16 bits) into x:y (16:31 bits) - */ - - lo |= (hi & 0x7FFF) << 16; /* lo = y = (low 15 bits of h spliced into e) */ - hi >>= 15; /* hi = x (high 16 bits of h) */ - lo += hi; /* lo = z = y + x (32 bits) */ - - /* - * At this point, the value has been reduced modulo M to the 32-bit - * value z, stored in lo. Reduce if the high-order bit is set. - */ - - if( lo & 0x80000000L) /* subtract 2**31 - 1 if necessary */ - { - lo &= 0x7FFFFFFF; /* equivalent to lo = lo - 2**31 */ - lo++; /* equivalent to lo = lo + 1 */ - } - - /* we don't need to worry about lo == M, because it can't happen */ - - return( m_i32Seed = lo); -} - -/************************************************************************* -Desc: return a random integer between lo and hi, inclusive. - (where lo and hi are integer arguments). -Example: - The code "RandomChoice( &r, 1, 6) + RandomChoice( &r, 1, 6)" will - simulate the roll of a standard 6-sided die. -Note: The distance (range) between lo and hi must be no greater than - MAX_RANDOM. Normally, RandomChoice computes its answer by taking - a f_randomLong modulo the desired range. If the range is large enough, - aliasing effects would cause some answers to be produced too often. - Therefore, f_randomChoice uses a better but slower algorithm if the - range is >= 1 Meg (2**20). -*************************************************************************/ -FLMINT32 F_RandomGenerator::randomChoice( - FLMINT32 lo, /* lowest allowed return value */ - FLMINT32 hi /* highest allowed return value */ - ) -{ - register FLMINT32 range = hi - lo + 1; - - if( range < (1L << 20)) - { - return( lo + randomLong() % range); - } - else - { - register FLMINT32 mask = 0; - register FLMINT32 x; - - range--; - for( x = range; x > 0; x >>= 1) - { - mask = (mask << 1) | 1; - } - - do - { - x = randomLong() & mask; - } while( x > range); - - return( lo + x); - } -} - - -/************************************************************************* -Desc: Return TRUE a certain percentage of the time -Example: - This code will decimate a population (that is, it will kill 10% of - the "life_force" group): - - for( i=0; ilocked = 0; -#ifdef FLM_DEBUG - (*phMutex)->uiThreadId = 0; - (*phMutex)->lockedCount = 0; - (*phMutex)->waitCount = 0; -#endif - - return( NE_XFLM_OK); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void f_mutexDestroy( - F_MUTEX * phMutex) -{ - flmAssert( phMutex != NULL); - - if (*phMutex != F_MUTEX_NULL) - { - os_free( *phMutex); - *phMutex = F_MUTEX_NULL; - } -} - -#elif defined( FLM_UNIX) - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE f_mutexCreate( - F_MUTEX * phMutex) -{ - RCODE rc = NE_XFLM_OK; - pthread_mutexattr_t * pMutexAttr = NULL; - - flmAssert( phMutex != NULL); - - // NOTE: Cannot call f_alloc because the memory initialization needs - // to be able to set up mutexes. - - if ((*phMutex = (F_MUTEX)os_malloc( - sizeof( pthread_mutex_t))) == F_MUTEX_NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - -#if defined( FLM_DEBUG) && defined( FLM_LINUX) - { - pthread_mutexattr_t mutexAttr; - - if( !pthread_mutexattr_init( &mutexAttr)) - { - pMutexAttr = &mutexAttr; - pthread_mutexattr_settype( pMutexAttr, PTHREAD_MUTEX_ERRORCHECK_NP); - } - } -#endif - - if( pthread_mutex_init( *phMutex, pMutexAttr) != 0) - { - // NOTE: Cannot call f_free because we had to use os_malloc up above due - // to the fact that the memory subsystem uses a mutex before itis - // completely ready to go. - - os_free( *phMutex); - *phMutex = F_MUTEX_NULL; - rc = RC_SET( NE_XFLM_COULD_NOT_CREATE_MUTEX); - goto Exit; - } - -Exit: - - if( pMutexAttr) - { - pthread_mutexattr_destroy( pMutexAttr); - } - - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void f_mutexDestroy( - F_MUTEX * phMutex) -{ - flmAssert( phMutex != NULL); - - if (*phMutex != F_MUTEX_NULL) - { - pthread_mutex_destroy( *phMutex); - - // NOTE: Cannot call f_free because we had to use os_malloc up above due - // to the fact that the memory subsystem uses a mutex before it is - // completely ready to go. - - os_free( *phMutex); - *phMutex = F_MUTEX_NULL; - } -} - -/**************************************************************************** -Desc: Initializes a semaphore handle on UNIX -****************************************************************************/ -FINLINE int sema_init( - sema_t * pSem) -{ - int iErr = 0; - - if( (iErr = pthread_mutex_init( &pSem->lock, NULL)) < 0) - { - goto Exit; - } - - if( (iErr = pthread_cond_init( &pSem->cond, NULL)) < 0) - { - pthread_mutex_destroy( &pSem->lock); - goto Exit; - } - - pSem->count = 0; - -Exit: - - return( iErr); -} - -/**************************************************************************** -Desc: Frees a semaphore handle on UNIX -****************************************************************************/ -FINLINE void sema_destroy( - sema_t * pSem) -{ - pthread_mutex_destroy( &pSem->lock); - pthread_cond_destroy( &pSem->cond); -} - -/**************************************************************************** -Desc: Waits for a semaphore to be signaled on UNIX -****************************************************************************/ -FINLINE int sema_wait( - sema_t * pSem) -{ - int iErr = 0; - - pthread_mutex_lock( &pSem->lock); - while( !pSem->count) - { - if( (iErr = pthread_cond_wait( &pSem->cond, &pSem->lock))) - { - if( iErr == EINTR) - { - iErr = 0; - } - else - { - goto Exit; - } - } - } - - pSem->count--; - flmAssert( pSem->count >= 0); - -Exit: - - pthread_mutex_unlock( &pSem->lock); - return( iErr); -} - -/**************************************************************************** -Desc: Waits a specified number of milliseconds for a semaphore - to be signaled on UNIX -****************************************************************************/ -FINLINE int sema_timedwait( - sema_t * pSem, - unsigned int msecs) -{ - struct timeval now; - struct timespec abstime; - int iErr = 0; - - // If timeout is F_SEM_WAITFOREVER, do sem_wait. - - if( msecs == F_SEM_WAITFOREVER) - { - iErr = sema_wait( pSem); - return( iErr); - } - - pthread_mutex_lock( &pSem->lock); - - gettimeofday( &now, NULL); - abstime.tv_sec = now.tv_sec + ((msecs) ? (msecs / 1000) : 0); - abstime.tv_nsec = ( now.tv_usec + ((msecs % 1000) * 1000)) * 1000; - -Restart: - - while( !pSem->count) - { - if( (iErr = pthread_cond_timedwait( &pSem->cond, - &pSem->lock, &abstime))) - { - if( iErr == EINTR) - { - iErr = 0; - goto Restart; - } - goto Exit; - } - } - - pSem->count--; - flmAssert( pSem->count >= 0); - -Exit: - - pthread_mutex_unlock( &pSem->lock); - return( iErr); -} - -/**************************************************************************** -Desc: Signals a semaphore on UNIX -****************************************************************************/ -int sema_signal( - sema_t * pSem) -{ - pthread_mutex_lock( &pSem->lock); - pSem->count++; - flmAssert( pSem->count > 0); - pthread_cond_signal( &pSem->cond); - pthread_mutex_unlock( &pSem->lock); - - return( 0); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE f_semCreate( - F_SEM * phSem) -{ - RCODE rc = NE_XFLM_OK; - - flmAssert( phSem != NULL); - - if( RC_BAD( rc = f_alloc( sizeof( sema_t), phSem))) - { - goto Exit; - } - - if( sema_init( *phSem) < 0) - { - f_free( phSem); - *phSem = F_SEM_NULL; - rc = RC_SET( NE_XFLM_COULD_NOT_CREATE_SEMAPHORE); - goto Exit; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -void f_semDestroy( - F_SEM * phSem) -{ - flmAssert( phSem != NULL); - - if (*phSem != F_SEM_NULL) - { - sema_destroy( *phSem); - f_free( phSem); - *phSem = F_SEM_NULL; - } -} - -/**************************************************************************** -Desc: Get the lock on a semaphore - p operation -****************************************************************************/ -RCODE f_semWait( - F_SEM hSem, - FLMUINT uiTimeout) -{ - RCODE rc = NE_XFLM_OK; - - flmAssert( hSem != F_SEM_NULL); - - //catch the F_SEM_WAITFOREVER flag so we can directly call sema_wait - //instead of passing F_SEM_WAITFOREVER through to sema_timedwait. - //Note that on AIX the datatype of the uiTimeout (in the timespec - //struct) is surprisingly a signed int, which makes this catch - //essential. - - if( uiTimeout == F_SEM_WAITFOREVER) - { - if( sema_wait( hSem)) - { - rc = RC_SET( NE_XFLM_ERROR_WAITING_ON_SEMPAHORE); - } - } - else - { - if( sema_timedwait( hSem, (unsigned int)uiTimeout)) - { - rc = RC_SET( NE_XFLM_ERROR_WAITING_ON_SEMPAHORE); - } - } - - return( rc); -} -#endif - -#if defined( FLM_WATCOM_NLM) - int gv_DummyFtksem(void) - { - return( 0); - } -#endif diff --git a/xflaim/src/ftkthrd.cpp b/xflaim/src/ftkthrd.cpp deleted file mode 100644 index 468306c..0000000 --- a/xflaim/src/ftkthrd.cpp +++ /dev/null @@ -1,1006 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Functions for creating, starting, stopping, controlling threads. -// -// Tabs: 3 -// -// Copyright (c) 2000-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: ftkthrd.cpp 3115 2006-01-19 13:24:39 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -#if defined( FLM_UNIX) - #include -#endif - -#ifdef FLM_NLM - void * threadStub( - void * pvThread); -#elif defined( FLM_WIN) - unsigned __stdcall threadStub( - void * pvThread); -#elif defined( FLM_UNIX) - extern "C" void * threadStub( - void * pvThread); -#endif - -/**************************************************************************** -Desc: Add a Reference to this object. -****************************************************************************/ -FLMINT F_Thread::AddRef( void) -{ - return( flmAtomicInc( &m_refCnt)); -} - -/**************************************************************************** -Desc: Removes a reference to this object. -****************************************************************************/ -FLMINT F_Thread::Release( void) -{ - FLMINT iRefCnt = flmAtomicDec( &m_refCnt); - - if( !iRefCnt) - { - delete this; - } - - return( iRefCnt); -} - -/**************************************************************************** -Desc: Performs various setup work and starts a new thread -****************************************************************************/ -RCODE F_Thread::startThread( - F_THREAD_FUNC fnThread, - const char * pszThreadName, - FLMUINT uiThreadGroup, - FLMUINT uiAppId, - void * pvParm1, - void * pvParm2, - FLMUINT uiStackSize) -{ - RCODE rc = NE_XFLM_OK; - FLMBOOL bManagerMutexLocked = FALSE; -#ifdef FLM_NLM - pthread_attr_t thread_attr; - pthread_t uiThreadId; -#endif -#ifdef FLM_WIN - unsigned uiThreadId; -#endif -#if defined( FLM_UNIX) - #if defined( _POSIX_THREADS) - pthread_attr_t thread_attr; - pthread_t uiThreadId; - #else - threadid_p uiThreadId; - #endif -#endif - - flmAssert( fnThread != NULL && m_fnThread == NULL); - - m_fnThread = fnThread; - m_pvParm1 = pvParm1; - m_pvParm2 = pvParm2; - - // Initialize the thread's mutex - - if( RC_BAD( rc = f_mutexCreate( &m_hMutex))) - { - goto Exit; - } - - // Set the stack size - - m_uiStackSize = (uiStackSize < F_THREAD_MIN_STACK_SIZE) - ? F_THREAD_MIN_STACK_SIZE - : uiStackSize; - - // Set the thread name - - if( pszThreadName && *pszThreadName) - { - FLMUINT uiNameLen = f_strlen( pszThreadName) + 1; - - if( RC_BAD( rc = f_alloc( uiNameLen, &m_pszThreadName))) - { - goto Exit; - } - - f_memcpy( m_pszThreadName, pszThreadName, uiNameLen); - } - - // Set the thread group ID and the application-specified thread ID - - m_uiThreadGroup = uiThreadGroup; - m_uiAppId = uiAppId; - - // Set the thread's state to "running" -- if we fail to - // start the thread, this will be set back to false when - // the cleanupThread() method is called below. We set this - // to TRUE here so that the stopThread() method won't get - // stuck in an infinite loop if the thread was never started. - - m_bRunning = TRUE; - - // Lock the thread manager's mutex. - - f_mutexLock( gv_XFlmSysData.pThreadMgr->m_hMutex); - bManagerMutexLocked = TRUE; - - // Increment the active thread count - - gv_XFlmSysData.pThreadMgr->m_uiNumThreads++; - - // Link the thread into the manager's list. We can't link threads in order - // by thread ID at this point, because we don't know what the new thread's - // ID will be. - - if( gv_XFlmSysData.pThreadMgr->m_pThreadList) - { - gv_XFlmSysData.pThreadMgr->m_pThreadList->m_pPrev = this; - } - - m_pNext = gv_XFlmSysData.pThreadMgr->m_pThreadList; - gv_XFlmSysData.pThreadMgr->m_pThreadList = this; - - // Increment the reference count of the thread object now - // that it is linked into the thread manager's list. - - m_refCnt++; - - // Start the thread - -#ifdef FLM_WIN - if( _beginthreadex( - NULL, (unsigned int)m_uiStackSize, threadStub, - (void *)this, 0, &uiThreadId) == 0) // 0 indicates a failure - { - rc = RC_SET( NE_XFLM_COULD_NOT_START_THREAD); - goto Exit; - } - m_uiThreadId = (FLMUINT)uiThreadId; -#elif defined( FLM_NLM) - pthread_attr_init( &thread_attr); - pthread_attr_setdetachstate( &thread_attr, PTHREAD_CREATE_DETACHED); - - if (pthread_create( &uiThreadId, &thread_attr, - threadStub, this) != 0) - { - rc = RC_SET( NE_XFLM_COULD_NOT_START_THREAD); - goto Exit; - } - - m_uiThreadId = (FLMUINT)uiThreadId; - pthread_attr_destroy( &thread_attr); -#elif defined( FLM_UNIX) - #ifdef _POSIX_THREADS - pthread_attr_init( &thread_attr); - pthread_attr_setdetachstate( &thread_attr, PTHREAD_CREATE_DETACHED); - - if (pthread_create( &uiThreadId, &thread_attr, - threadStub, this) != 0) - { - rc = RC_SET( NE_XFLM_COULD_NOT_START_THREAD); - goto Exit; - } - #else - m_uiStackSize = f_max( m_uiStackSize, thr_minstack()); - m_uiStackSize = f_max( m_uiStackSize, thr_min_stack()); - - if( thr_create( (void*)NULL, (size_t)uiStackSize, - threadStub, this, (long)0, &uiThreadId) != 0) - { - rc = RC_SET( NE_XFLM_COULD_NOT_START_THREAD); - goto Exit; - } - #endif - - m_uiThreadId = (FLMUINT)uiThreadId; - - #ifdef _POSIX_THREADS - pthread_attr_destroy( &thread_attr); - #endif -#endif - - // Code is not designed to handle a thread ID of 0 - - flmAssert( m_uiThreadId != 0); - - // Unlock the thread manager's mutex. - - f_mutexUnlock( gv_XFlmSysData.pThreadMgr->m_hMutex); - bManagerMutexLocked = FALSE; - -Exit: - - if( RC_BAD( rc)) - { - // Unlink the thread from the manager's list. This call - // won't do anything if the thread was not linked above. - - gv_XFlmSysData.pThreadMgr->unlinkThread( this, bManagerMutexLocked); - - // Reset the thread object back to its initial state - - cleanupThread(); - } - - if( bManagerMutexLocked) - { - f_mutexUnlock( gv_XFlmSysData.pThreadMgr->m_hMutex); - } - - return( rc); -} - -/**************************************************************************** -Desc: Stop a running thread -****************************************************************************/ -void F_Thread::stopThread( void) -{ - // Set the shutdown flag and wait for the thread's - // status to be something other than "running" - - m_bShutdown = TRUE; - while( m_bRunning) - { - f_sleep( 10); - } - - // Reset the shutdown flag in case this object is re-used. - - m_bShutdown = FALSE; -} - -/**************************************************************************** -Desc: Begins a new thread of execution and calls the passed function. - Performs generic thread init and cleanup functions. -****************************************************************************/ -#ifdef FLM_NLM -void * threadStub( - void * pvThread) -#elif defined( FLM_WIN) -unsigned __stdcall threadStub( - void * pvThread) -#elif defined( FLM_UNIX) -void * threadStub( - void * pvThread) -#endif -{ - F_Thread * pThread = (F_Thread *)pvThread; - -#if defined( FLM_UNIX) || defined( FLM_NLM) - // Block all signals (main thread will handle all signals) - - sigset_t mask; - sigfillset(&mask); - pthread_sigmask(SIG_SETMASK, &mask, 0); -#endif - - // Lock the manager's mutex - - gv_XFlmSysData.pThreadMgr->lockMutex(); - - // At this point, the thread ID must match. - - flmAssert( pThread->m_uiThreadId == f_threadId()); - - // Set the start time - - f_timeGetSeconds( &pThread->m_uiStartTime); - - // Unlock the manager's mutex - - gv_XFlmSysData.pThreadMgr->unlockMutex(); - - // Call the thread's function - - pThread->m_exitRc = pThread->m_fnThread( pThread); - - // Add a temporary reference to the thread object so - // it doesn't go away when we unlink it from the - // manager - - pThread->AddRef(); - - // Unlink the thread from the thread manager. - - gv_XFlmSysData.pThreadMgr->unlinkThread( pThread, FALSE); - - // Set the running flag to FALSE - - pThread->m_bRunning = FALSE; - - // Release the temporary reference to the thread. Once the - // reference is release, pThread must not be accessed because - // the object may have gone away. - - pThread->Release(); - pThread = NULL; - - // Terminate the thread - -#if defined( FLM_WIN) - _endthreadex( 0); - return( 0); -#endif - -#if defined( FLM_NLM) || defined( FLM_UNIX) - return( NULL); -#endif -} - -/**************************************************************************** -Desc: Frees any resources allocated to the thread and resets member - variables to their initial state -****************************************************************************/ -void F_Thread::cleanupThread( void) -{ - flmAssert( !m_pPrev && !m_pNext); - if( m_hMutex != F_MUTEX_NULL) - { - f_mutexDestroy( &m_hMutex); - } - - if( m_pszThreadName) - { - f_free( &m_pszThreadName); - } - - if( m_pszThreadStatus) - { - f_free( &m_pszThreadStatus); - } - - m_uiStatusBufLen = 0; - m_bShutdown = FALSE; - m_fnThread = NULL; - m_bRunning = FALSE; - m_uiStackSize = 0; - m_pvParm1 = NULL; - m_pvParm2 = NULL; - m_uiThreadId = 0; - m_uiThreadGroup = FLM_DEFAULT_THREAD_GROUP; - m_uiAppId = 0; - m_uiStartTime = 0; - m_exitRc = NE_XFLM_OK; -} - -/**************************************************************************** -Desc: Set the thread's status -****************************************************************************/ -void F_Thread::setThreadStatusStr( - const char * pszStatus) -{ - FLMUINT uiStatusLen = f_strlen( pszStatus) + 1; - - if( m_uiStatusBufLen < uiStatusLen) - { - FLMUINT uiAllocSize = uiStatusLen < 128 ? 128 : uiStatusLen; - - if( m_pszThreadStatus != NULL) - { - f_free( &m_pszThreadStatus); - } - m_uiStatusBufLen = 0; - - if( RC_BAD( f_alloc( uiAllocSize, &m_pszThreadStatus))) - { - goto Exit; - } - m_uiStatusBufLen = uiAllocSize; - } - - f_mutexLock( m_hMutex); - f_memcpy( m_pszThreadStatus, pszStatus, uiStatusLen); - f_mutexUnlock( m_hMutex); - -Exit: - - return; -} - -/**************************************************************************** -Desc: Set the thread's status -****************************************************************************/ -void F_Thread::setThreadStatus( - const char * pszFormat, ...) -{ - char pucBuffer[ 128]; - f_va_list args; - - f_va_start( args, pszFormat); - f_vsprintf( pucBuffer, pszFormat, &args); - f_va_end( args); - - setThreadStatusStr( pucBuffer); -} - -/**************************************************************************** -Desc: Set the thread's status to a generic string -****************************************************************************/ -void F_Thread::setThreadStatus( - FlmThreadStatus eGenericStatus) -{ - const char * pszStatus = NULL; - - switch( eGenericStatus) - { - case FLM_THREAD_STATUS_INITIALIZING: - pszStatus = "Initializing"; - break; - - case FLM_THREAD_STATUS_RUNNING: - pszStatus = "Running"; - break; - - case FLM_THREAD_STATUS_SLEEPING: - pszStatus = "Sleeping"; - break; - - case FLM_THREAD_STATUS_TERMINATING: - pszStatus = "Terminating"; - break; - - case FLM_THREAD_STATUS_STARTING_TRANS: - pszStatus = "Starting transaction"; - break; - - case FLM_THREAD_STATUS_COMMITTING_TRANS: - pszStatus = "Committing transaction"; - break; - - case FLM_THREAD_STATUS_ABORTING_TRANS: - pszStatus = "Aborting transaction"; - break; - - case FLM_THREAD_STATUS_UNKNOWN: - default: - pszStatus = "Unknown"; - break; - } - - if( pszStatus) - { - setThreadStatusStr( pszStatus); - } -} - -/**************************************************************************** -Desc: Allocates resources needed by the thread manager -****************************************************************************/ -RCODE F_ThreadMgr::setupThreadMgr( void) -{ - RCODE rc = NE_XFLM_OK; - - flmAssert( m_hMutex == F_MUTEX_NULL); - - if( RC_BAD( rc = f_mutexCreate( &m_hMutex))) - { - goto Exit; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Removes a thread from the thread manager's list -Notes: This routine assumes that the manager's mutex is already locked. -****************************************************************************/ -void F_ThreadMgr::unlinkThread( - F_Thread * pThread, - FLMBOOL bMutexIsLocked) -{ - // Lock the thread manager's mutex - - if( !bMutexIsLocked) - { - f_mutexLock( m_hMutex); - } - - // If the thread isn't linked into the list, - // don't do anything - - if( !pThread->m_pPrev && !pThread->m_pNext && - m_pThreadList != pThread) - { - goto Exit; - } - - // Decrement the active thread count - - flmAssert( m_uiNumThreads); - m_uiNumThreads--; - - if( pThread->m_pPrev) - { - pThread->m_pPrev->m_pNext = pThread->m_pNext; - } - else - { - m_pThreadList = pThread->m_pNext; - } - - if( pThread->m_pNext) - { - pThread->m_pNext->m_pPrev = pThread->m_pPrev; - } - - pThread->m_pNext = NULL; - pThread->m_pPrev = NULL; - - // Release the thread object - - pThread->Release(); - -Exit: - - if( !bMutexIsLocked) - { - f_mutexUnlock( m_hMutex); - } -} - -/**************************************************************************** -Desc: Signals all threads in a thread group to shut down and waits - for them to terminate. -****************************************************************************/ -void F_ThreadMgr::shutdownThreadGroup( - FLMUINT uiThreadGroup) -{ - F_Thread * pThread; - FLMUINT uiCount; - - for( ;;) - { - f_mutexLock( m_hMutex); - - uiCount = 0; - pThread = m_pThreadList; - while( pThread) - { - if( pThread->m_uiThreadGroup == uiThreadGroup) - { - pThread->setShutdownFlag(); - uiCount++; - } - pThread = pThread->m_pNext; - } - - f_mutexUnlock( m_hMutex); - - if( !uiCount) - { - break; - } - - // The threads will automatically unlink themselves from - // the manager before they terminate. Just sleep for - // a few milliseconds and look through the list again to - // verify that there are no more threads in the group. - - f_sleep( 200); - } -} - -/**************************************************************************** -Desc: Signals a thread to shut down. -****************************************************************************/ -void F_ThreadMgr::setThreadShutdownFlag( - FLMUINT uiThreadId) -{ - F_Thread * pThread; - - flmAssert( uiThreadId != 0); - - f_mutexLock( m_hMutex); - pThread = m_pThreadList; - while( pThread) - { - if( pThread->m_uiThreadId == uiThreadId) - { - pThread->setShutdownFlag(); - break; - } - pThread = pThread->m_pNext; - } - - f_mutexUnlock( m_hMutex); -} - -/**************************************************************************** -Desc: Allocates an array of F_THREAD_INFO structures and populates them - with information about the threads being managed by this object. -****************************************************************************/ -RCODE F_ThreadMgr::getThreadInfo( - F_Pool * pPool, - F_THREAD_INFO ** ppThreadInfo, - FLMUINT * puiNumThreads) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiOffset; - FLMUINT uiLoop; - FLMUINT uiSubLoop; - FLMUINT uiLen; - FLMBOOL bMutexLocked = FALSE; - F_THREAD_INFO * pThreadInfo = NULL; - F_THREAD_INFO tmpThreadInfo; - F_Thread * pCurThread; - void * pvMark = pPool->poolMark(); - - *ppThreadInfo = NULL; - *puiNumThreads = 0; - - f_mutexLock( m_hMutex); - bMutexLocked = TRUE; - - if( m_uiNumThreads == 0) - { - goto Exit; - } - - if (RC_BAD( rc = pPool->poolCalloc( sizeof( F_THREAD_INFO) * m_uiNumThreads, - (void **)&pThreadInfo))) - { - goto Exit; - } - - uiOffset = 0; - pCurThread = m_pThreadList; - while( pCurThread) - { - flmAssert( uiOffset < m_uiNumThreads); - f_mutexLock( pCurThread->m_hMutex); - - pThreadInfo[ uiOffset].uiThreadId = pCurThread->m_uiThreadId; - pThreadInfo[ uiOffset].uiThreadGroup = pCurThread->m_uiThreadGroup; - pThreadInfo[ uiOffset].uiAppId = pCurThread->m_uiAppId; - pThreadInfo[ uiOffset].uiStartTime = pCurThread->m_uiStartTime; - - if( pCurThread->m_pszThreadName) - { - uiLen = f_strlen( pCurThread->m_pszThreadName) + 1; - - if (RC_OK( pPool->poolCalloc( uiLen, - (void **)&pThreadInfo[ uiOffset].pszThreadName))) - { - f_memcpy( pThreadInfo[ uiOffset].pszThreadName, - pCurThread->m_pszThreadName, uiLen); - } - } - - if( pCurThread->m_pszThreadStatus) - { - uiLen = f_strlen( pCurThread->m_pszThreadStatus) + 1; - - if (RC_OK( pPool->poolCalloc( uiLen, - (void **)&pThreadInfo[ uiOffset].pszThreadStatus))) - { - f_memcpy( pThreadInfo[ uiOffset].pszThreadStatus, - pCurThread->m_pszThreadStatus, uiLen); - } - } - - f_mutexUnlock( pCurThread->m_hMutex); - uiOffset++; - pCurThread = pCurThread->m_pNext; - } - - flmAssert( uiOffset == m_uiNumThreads); - *puiNumThreads = m_uiNumThreads; - - f_mutexUnlock( m_hMutex); - bMutexLocked = FALSE; - - // Sort the list by thread ID - - for( uiLoop = 0; uiLoop < *puiNumThreads; uiLoop++) - { - for( uiSubLoop = uiLoop + 1; uiSubLoop < *puiNumThreads; uiSubLoop++) - { - if( pThreadInfo[ uiLoop].uiThreadId > - pThreadInfo[ uiSubLoop].uiThreadId) - { - f_memcpy( &tmpThreadInfo, - &pThreadInfo[ uiLoop], sizeof( F_THREAD_INFO)); - f_memcpy( &pThreadInfo[ uiLoop], - &pThreadInfo[ uiSubLoop], sizeof( F_THREAD_INFO)); - f_memcpy( &pThreadInfo[ uiSubLoop], - &tmpThreadInfo, sizeof( F_THREAD_INFO)); - } - } - } - - *ppThreadInfo = pThreadInfo; - -Exit: - - if( RC_BAD( rc)) - { - pPool->poolReset( pvMark); - } - - if( bMutexLocked) - { - f_mutexUnlock( m_hMutex); - } - - return( rc); -} - -/**************************************************************************** -Desc: Finds a thread based on user-specified identifiers -****************************************************************************/ -RCODE F_ThreadMgr::findThread( - F_Thread ** ppThread, - FLMUINT uiThreadGroup, - FLMUINT uiAppId, - FLMBOOL bOkToFindMe) -{ - RCODE rc = NE_XFLM_OK; - FLMBOOL bMutexLocked = FALSE; - F_Thread * pCurThread; - - *ppThread = NULL; - - f_mutexLock( m_hMutex); - bMutexLocked = TRUE; - - if( m_uiNumThreads == 0) - { - rc = RC_SET( NE_XFLM_NOT_FOUND); - goto Exit; - } - - pCurThread = m_pThreadList; - while( pCurThread) - { - f_mutexLock( pCurThread->m_hMutex); - - if( pCurThread->m_uiThreadGroup == uiThreadGroup && - pCurThread->m_uiAppId == uiAppId) - { - if( bOkToFindMe || - (!bOkToFindMe && pCurThread->m_uiThreadId != f_threadId())) - { - // Found a match. - - pCurThread->AddRef(); - *ppThread = pCurThread; - f_mutexUnlock( pCurThread->m_hMutex); - goto Exit; - } - } - - f_mutexUnlock( pCurThread->m_hMutex); - pCurThread = pCurThread->m_pNext; - } - - rc = RC_SET( NE_XFLM_NOT_FOUND); - -Exit: - - if( bMutexLocked) - { - f_mutexUnlock( m_hMutex); - } - - return( rc); -} - -/**************************************************************************** -Desc: Finds a thread based on user-specified identifiers -****************************************************************************/ -RCODE F_ThreadMgr::getNextGroupThread( - F_Thread ** ppThread, - FLMUINT uiThreadGroup, - FLMUINT * puiThreadId) -{ - RCODE rc = NE_XFLM_OK; - FLMBOOL bMutexLocked = FALSE; - F_Thread * pCurThread; - F_Thread * pFoundThread = NULL; - - f_mutexLock( m_hMutex); - bMutexLocked = TRUE; - - if( m_uiNumThreads == 0) - { - rc = RC_SET( NE_XFLM_NOT_FOUND); - goto Exit; - } - - pCurThread = m_pThreadList; - while( pCurThread) - { - if( pCurThread->m_uiThreadGroup == uiThreadGroup && - pCurThread->m_uiThreadId > *puiThreadId) - { - // The threads are not kept in order by thread ID in the - // manager's list. So, we need to make sure we get the - // thread with the next ID beyond the ID passed into the - // routine. - - if( !pFoundThread || - pCurThread->m_uiThreadId < pFoundThread->m_uiThreadId) - { - pFoundThread = pCurThread; - } - } - - pCurThread = pCurThread->m_pNext; - } - - if( !pFoundThread) - { - rc = RC_SET( NE_XFLM_NOT_FOUND); - goto Exit; - } - - pFoundThread->AddRef(); - *ppThread = pFoundThread; - *puiThreadId = pFoundThread->m_uiThreadId; - -Exit: - - if( RC_BAD( rc)) - { - *ppThread = NULL; - *puiThreadId = 0xFFFFFFFF; - } - - if( bMutexLocked) - { - f_mutexUnlock( m_hMutex); - } - - return( rc); -} - -/**************************************************************************** -Desc: Returns a count of the number of threads in a specified group -****************************************************************************/ -FLMUINT F_ThreadMgr::getThreadGroupCount( - FLMUINT uiThreadGroup) -{ - F_Thread * pThread; - FLMUINT uiCount; - - f_mutexLock( m_hMutex); - - uiCount = 0; - pThread = m_pThreadList; - while( pThread) - { - if( pThread->m_uiThreadGroup == uiThreadGroup) - { - uiCount++; - } - pThread = pThread->m_pNext; - } - - f_mutexUnlock( m_hMutex); - return( uiCount); -} - -/**************************************************************************** -Desc: Allocate a thread object and start the thread -****************************************************************************/ -RCODE f_threadCreate( - F_Thread ** ppThread, - F_THREAD_FUNC fnThread, - const char * pszThreadName, - FLMUINT uiThreadGroup, - FLMUINT uiAppId, - void * pvParm1, - void * pvParm2, - FLMUINT uiStackSize) -{ - RCODE rc = NE_XFLM_OK; - F_Thread * pThread = NULL; - - if( ppThread) - { - *ppThread = NULL; - } - - if( (pThread = f_new F_Thread) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - if( RC_BAD( rc = pThread->startThread( - fnThread, pszThreadName, uiThreadGroup, uiAppId, - pvParm1, pvParm2, uiStackSize))) - { - goto Exit; - } - - if( ppThread) - { - *ppThread = pThread; - - // Set pThread to NULL so that the object won't be released - // below. The application has indicated (by passing in a - // non-NULL ppThread) that it wants to keep a reference to - // the thread. - - pThread = NULL; - } - -Exit: - - if( pThread) - { - pThread->Release(); - } - - return( rc); -} - -/**************************************************************************** -Desc: Deletes a thread object and sets the passed-in pointer to NULL -Notes: Should not be used on threads that were started with the - auto-destroy flag set to TRUE -****************************************************************************/ -void f_threadDestroy( - F_Thread ** ppThread) -{ - // Shutdown the thread - - if( *ppThread != NULL) - { - (*ppThread)->stopThread(); - (*ppThread)->Release(); - *ppThread = NULL; - } -} - -/**************************************************************************** -Desc: -****************************************************************************/ -F_ThreadMgr::~F_ThreadMgr() -{ - F_Thread * pTmpThread; - - if( m_hMutex != F_MUTEX_NULL) - { - f_mutexLock( m_hMutex); - pTmpThread = m_pThreadList; - while( pTmpThread) - { - pTmpThread->setShutdownFlag(); - pTmpThread = pTmpThread->m_pNext; - } - - while( m_pThreadList) - { - f_mutexUnlock( m_hMutex); - f_sleep( 50); - f_mutexLock( m_hMutex); - } - - f_mutexUnlock( m_hMutex); - f_mutexDestroy( &m_hMutex); - } -} diff --git a/xflaim/src/ftkthrd.h b/xflaim/src/ftkthrd.h deleted file mode 100644 index 26189cb..0000000 --- a/xflaim/src/ftkthrd.h +++ /dev/null @@ -1,350 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: This file defines the needed prototypes, defines, macros needed -// for FLAIM's Thread functions. -// -// Tabs: 3 -// -// Copyright (c) 2000-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: ftkthrd.h 3109 2006-01-19 13:07:07 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#ifndef FTKTHRD_H -#define FTKTHRD_H - -#if defined( FLM_UNIX) - #include - #include // defines _POSIX_THREADS - #ifndef _POSIX_THREADS - #define _POSIX_THREADS - #endif -#endif - -#ifdef FLM_WIN - #ifndef __STDDEF_H - #include /* _threadid */ - #endif - #define f_threadId() (FLMUINT)_threadid -#endif - -#ifdef FLM_NLM - FINLINE FLMUINT f_threadId(void) - { - pthread_t thrd = pthread_self(); - return( (FLMUINT) thrd); - } -#endif - -#ifdef FLM_UNIX - FINLINE FLMUINT f_threadId(void) - { - #ifdef _POSIX_THREADS - pthread_t thrd = pthread_self(); - #endif - - #if defined( SCO) - return( (FLMUINT) thrd.field2); - #else - return( (FLMUINT) thrd); - #endif - } -#endif - -#define F_THREAD_MIN_STACK_SIZE (16 * 1024) -#define F_THREAD_DEFAULT_STACK_SIZE (16 * 1024) - -// Forward declarations - -class F_Thread; -class F_ThreadMgr; - -// Typedefs - -typedef enum eFlmThreadStatusType -{ - FLM_THREAD_STATUS_UNKNOWN = 0, - FLM_THREAD_STATUS_INITIALIZING, - FLM_THREAD_STATUS_RUNNING, - FLM_THREAD_STATUS_SLEEPING, - FLM_THREAD_STATUS_TERMINATING, - FLM_THREAD_STATUS_STARTING_TRANS, - FLM_THREAD_STATUS_COMMITTING_TRANS, - FLM_THREAD_STATUS_ABORTING_TRANS -} FlmThreadStatus; - -typedef struct -{ - FLMUINT uiThreadId; - FLMUINT uiThreadGroup; - FLMUINT uiAppId; - FLMUINT uiStartTime; - char * pszThreadName; - char * pszThreadStatus; -} F_THREAD_INFO; - -// Thread types - -#define FLM_DEFAULT_THREAD_GROUP 1 -#define FLM_CHECKPOINT_THREAD_GROUP 2 -#define FLM_BACKGROUND_INDEXING_THREAD_GROUP 3 -#define FLM_DB_THREAD_GROUP 4 - -// NOTE: SMI defines thread groups starting at 0x8F000000 - -/*============================================================================ -Class: F_ThreadMgr -Desc: Class for managing a set of threads -============================================================================*/ -class F_ThreadMgr : public XF_RefCount, public XF_Base -{ -public: - - // Constructors - - F_ThreadMgr() - { - m_hMutex = F_MUTEX_NULL; - m_pThreadList = NULL; - m_uiNumThreads = 0; - } - - // Destructor - - ~F_ThreadMgr(); - - // Setup - - RCODE setupThreadMgr( void); - - // Shutdown - - void shutdownThreadGroup( - FLMUINT uiThreadGroup); - - void setThreadShutdownFlag( - FLMUINT uiThreadId); - - // Search - - RCODE findThread( - F_Thread ** ppThread, - FLMUINT uiThreadGroup, - FLMUINT uiAppId = 0, - FLMBOOL bOkToFindMe = TRUE); - - RCODE getNextGroupThread( - F_Thread ** ppThread, - FLMUINT uiThreadGroup, - FLMUINT * puiThreadId); - - // Statistics - - RCODE getThreadInfo( - F_Pool * pPool, - F_THREAD_INFO ** ppThreadInfo, - FLMUINT * puiNumThreads); - - FLMUINT getThreadGroupCount( - FLMUINT uiThreadGroup); - - inline void lockMutex( void) - { - f_mutexLock( m_hMutex); - } - - inline void unlockMutex( void) - { - f_mutexUnlock( m_hMutex); - } - - void unlinkThread( - F_Thread * pThread, - FLMBOOL bMutexLocked); - -private: - - F_MUTEX m_hMutex; - F_Thread * m_pThreadList; - FLMUINT m_uiNumThreads; - -friend class F_Thread; -}; - -// Thread function prototype - -typedef RCODE (*F_THREAD_FUNC)(F_Thread *); - -/*============================================================================ -Class: F_Thread -Desc: Class for creating and managing a thread -============================================================================*/ -class F_Thread : public XF_RefCount, public XF_Base -{ -public: - - // Constructors - - F_Thread() - { - m_hMutex = F_MUTEX_NULL; - m_pszThreadName = NULL; - m_pszThreadStatus = NULL; - m_uiStatusBufLen = 0; - m_pPrev = NULL; - m_pNext = NULL; - cleanupThread(); - } - - // Destructor - - ~F_Thread() - { - stopThread(); - cleanupThread(); - } - - FLMINT XFLMAPI AddRef( void); - - FLMINT XFLMAPI Release( void); - - // Other methods - - RCODE startThread( - F_THREAD_FUNC fnThread, - const char * pszThreadName = NULL, - FLMUINT uiThreadGroup = FLM_DEFAULT_THREAD_GROUP, - FLMUINT uiAppId = 0, - void * pvParm1 = NULL, - void * pvParm2 = NULL, - FLMUINT uiStackSize = F_THREAD_DEFAULT_STACK_SIZE); - - void stopThread( void); - - FINLINE FLMUINT getThreadId( void) - { - return( m_uiThreadId); - } - - FINLINE FLMBOOL getShutdownFlag( void) - { - return( m_bShutdown); - } - - FINLINE RCODE getExitCode( void) - { - return( m_exitRc); - } - - FINLINE void * getParm1( void) - { - return( m_pvParm1); - } - - FINLINE void setParm1( - void * pvParm) - { - m_pvParm1 = pvParm; - } - - FINLINE void * getParm2( void) - { - return( m_pvParm2); - } - - FINLINE void setParm2( - void * pvParm) - { - m_pvParm2 = pvParm; - } - - FINLINE void setShutdownFlag( void) - { - m_bShutdown = TRUE; - } - - FINLINE FLMBOOL isThreadRunning( void) - { - return( m_bRunning); - } - - void setThreadStatusStr( - const char * pszStatus); - - void setThreadStatus( - const char * pszBuffer, ...); - - void setThreadStatus( - FlmThreadStatus eGenericStatus); - - FINLINE void setThreadAppId( - FLMUINT uiAppId) - { - f_mutexLock( m_hMutex); - m_uiAppId = uiAppId; - f_mutexUnlock( m_hMutex); - } - - FINLINE FLMUINT getThreadAppId( void) - { - return( m_uiAppId); - } - - FINLINE FLMUINT getThreadGroup( void) - { - return( m_uiThreadGroup); - } - - void cleanupThread( void); - - F_MUTEX m_hMutex; - F_Thread * m_pPrev; - F_Thread * m_pNext; - char * m_pszThreadName; - char * m_pszThreadStatus; - FLMUINT m_uiStatusBufLen; - FLMBOOL m_bShutdown; - F_THREAD_FUNC m_fnThread; - FLMBOOL m_bRunning; - FLMUINT m_uiStackSize; - void * m_pvParm1; - void * m_pvParm2; - FLMUINT m_uiThreadId; - FLMUINT m_uiThreadGroup; - FLMUINT m_uiAppId; - FLMUINT m_uiStartTime; - RCODE m_exitRc; - -friend class F_ThreadMgr; -}; - -// Misc. functions - -RCODE f_threadCreate( // Source: ftkthrd.cpp - F_Thread ** ppThread, - F_THREAD_FUNC fnThread, - const char * pszThreadName = NULL, - FLMUINT uiThreadGroup = FLM_DEFAULT_THREAD_GROUP, - FLMUINT uiAppId = 0, - void * pvParm1 = NULL, - void * pvParm2 = NULL, - FLMUINT uiStackSize = F_THREAD_DEFAULT_STACK_SIZE); - -void f_threadDestroy( // Source: ftkthrd.cpp - F_Thread ** ppThread); - -#endif // #ifndef FTKTHRD_H diff --git a/xflaim/src/ftktime.cpp b/xflaim/src/ftktime.cpp deleted file mode 100644 index 85505eb..0000000 --- a/xflaim/src/ftktime.cpp +++ /dev/null @@ -1,335 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Date and time functions -// -// Tabs: 3 -// -// Copyright (c) 1991-2000, 2002-2003,2005-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: ftktime.cpp 3115 2006-01-19 13:24:39 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -#define BASEYR 1970 /* all gmt calcs done since 1970 */ -#define SECONDSPERDAY 86400l /* 24 hours * 60 minutes * 60 seconds */ -#define SECONDSPERHOUR 3600 /* 60 minutes * 60 seconds */ -#define DDAYSPERYEAR 365 /* 365 days/year */ - -static FLMUINT8 ui8NumDaysPerMonth[2][12] = { /* days of the months */ - {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, - {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} }; - -static FLMUINT16 ui16NumDaysFromJan1st[2][12] = { - /* current total of the days in the year by mon */ - { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}, - { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335} }; - -static F_TMSTAMP maxdate = - { 2106, 1, 6, 11, 0, 0, 0 }; - -static FLMUINT f_timeLeapYearsSince1970( - FLMUINT16 year); - -/**************************************************************************** -Desc: Gets the number of seconds since 1980 or 1970. -****************************************************************************/ -void f_timeGetSeconds( - FLMUINT * puiSeconds) -{ -#if defined( FLM_WIN) - *puiSeconds = (FLMUINT) time( NULL); - -#elif defined( FLM_UNIX) || defined( FLM_NLM) - *puiSeconds = (FLMUINT) time( 0); - -#else - #error Platform not supported -#endif -} - -/**************************************************************************** -Desc: Gets the time stamp from the system clock. -Notes: -****************************************************************************/ -void f_timeGetTimeStamp( - F_TMSTAMP * pTimeStamp) -{ -#if defined( FLM_WIN) - SYSTEMTIME rightnow; - - GetLocalTime( &rightnow ); - - pTimeStamp->year = rightnow.wYear; - pTimeStamp->month = (FLMUINT8)(rightnow.wMonth - 1); - pTimeStamp->day = (FLMUINT8)rightnow.wDay; - - pTimeStamp->hour = (FLMUINT8)rightnow.wHour; - pTimeStamp->minute = (FLMUINT8)rightnow.wMinute; - pTimeStamp->second = (FLMUINT8)rightnow.wSecond; - pTimeStamp->hundredth = rightnow.wMilliseconds / 10; - -#elif defined( FLM_UNIX) || defined( FLM_NLM) - time_t now; - struct tm rightnow; - - now = time( (time_t *) 0 ); - (void)localtime_r( &now, &rightnow ); - - pTimeStamp->year = rightnow.tm_year + 1900; - pTimeStamp->month = rightnow.tm_mon; - pTimeStamp->day = rightnow.tm_mday; - pTimeStamp->hour = rightnow.tm_hour; - pTimeStamp->minute = rightnow.tm_min; - pTimeStamp->second = rightnow.tm_sec; - pTimeStamp->hundredth = 0; -#else - #error Platform not supported -#endif -} - -/**************************************************************************** -Desc: Returns the local time bias in seconds -****************************************************************************/ -FLMINT f_timeGetLocalOffset( void) -{ - FLMINT iOffset = 0; - -#if defined( FLM_WIN) - TIME_ZONE_INFORMATION tzInfo; - DWORD retVal; - - retVal = GetTimeZoneInformation( &tzInfo); - - if( retVal != TIME_ZONE_ID_UNKNOWN) - { - iOffset = - (retVal == TIME_ZONE_ID_DAYLIGHT && tzInfo.DaylightDate.wMonth - ? tzInfo.Bias + tzInfo.DaylightBias - : tzInfo.Bias) * 60; - } - -#elif defined( FLM_UNIX) || defined( FLM_NLM) - time_t gmtTime; - time_t localTime; - struct tm gmtTm; - - gmtTime = time( (time_t *)0); - gmtime_r( &gmtTime, &gmtTm); - localTime = mktime( &gmtTm); - iOffset = (FLMINT)((FLMINT64)localTime - (FLMINT64)gmtTime); - -#else - #error Platform not supported -#endif - - return( iOffset); -} - -/**************************************************************************** -Desc: Count the number of leap years from 1970 to given year. - -In: year - FLMUINT16 value containing the year -Out: (None) -Ret: Number of leap years since 1970 -Notes: According to the Gregorian calendar (which we currently use), the - year is a leap year if it is divisible by 4, unless it is a century - year, then it must be divisible by 400. -****************************************************************************/ -static FLMUINT f_timeLeapYearsSince1970( - FLMUINT16 ui16Year) -{ - FLMUINT uiTemp; - - /* first calculate # of leap years since 1600 */ - - ui16Year -= 1601; /* ui16Year = number of years since 1600*/ - uiTemp = ( /* Count leap years */ - (ui16Year / 4) - /* Count potential leap years */ - (ui16Year / 100) + /* Subtract out century years */ - (ui16Year / 400) + /* Add back in quadricentenial years*/ - 1 /* And don't forget to count 1600 */ - ); - - /* now subtract # of leap years between 1600 and 1970 */ - /* (the following becomes a constant at compile time) */ - - uiTemp -= ((BASEYR-1600) / 4) - ((BASEYR-1600) / 100) + 1; - return(uiTemp); -} - -/**************************************************************************** -Desc: Convert from seconds to the F_TMSTAMP structure. -Notes: -****************************************************************************/ -void f_timeSecondsToDate( - FLMUINT uiSeconds, - F_TMSTAMP * date) -{ - FLMUINT uiLeapYear; - FLMUINT uiMonth; - FLMUINT uiDaysInMonth; - FLMUINT uiDay; - - uiDay = uiSeconds / SECONDSPERDAY; // # of days since 1970 - date->year = (FLMUINT16)((uiDay / DDAYSPERYEAR) + BASEYR); - uiDay = uiDay % DDAYSPERYEAR; // # of days into year - - /* - Check to see that the value for the current day is greater than the - number of leap years since 1970. This is because we will be - subtracting the leap days from the current day and we don't want - the value for the day to go negative. - */ - - while( uiDay < f_timeLeapYearsSince1970(date->year)) // if day < # of leap years - { - date->year--; // decrement the year - uiDay += DDAYSPERYEAR; // adjust day by days/year - } - - uiDay -= f_timeLeapYearsSince1970( date->year); // subtract leap days - uiLeapYear = f_timeIsLeapYear( date->year ); // set leap year flag - - /* - Find what our offset into the current month is. - To do this, we subtract out the number of days for each month, until - the number of days left does not span the end of the current month - */ - - for( uiMonth = 0; - uiMonth < 12 && - (uiDay >= (uiDaysInMonth = ui8NumDaysPerMonth[uiLeapYear][uiMonth])); - uiMonth++) - { - uiDay -= uiDaysInMonth; // subtract days in month - } - date->month = (FLMUINT8) uiMonth; // set month, day - date->day = (FLMUINT8) (++uiDay); - - uiDay = uiSeconds % SECONDSPERDAY; // mod by seconds/day - date->hour = (FLMUINT8)(uiDay / SECONDSPERHOUR);// get # of hours - uiDay = uiDay % SECONDSPERHOUR; - date->minute = (FLMUINT8)(uiDay / 60); // get # of minutes - date->second = (FLMUINT8)(uiDay % 60); - date->hundredth = 0; // no fractional seconds -} - -/**************************************************************************** -Desc: Convert a time stamp to the number of seconds. -****************************************************************************/ -void f_timeDateToSeconds( - F_TMSTAMP * pTimeStamp, // [in] - time stamp of date - FLMUINT * puiSeconds) // [out] - seconds of time stamp -{ - FLMUINT uiDays = 0; - - // is date past max? - if( f_timeCompareTimeStamps( pTimeStamp, &maxdate, 0) > 0) - { - *pTimeStamp = maxdate; - } - - // Do date portion of calculation - result is days since 1/1/1970. - - if( pTimeStamp->year) - { - uiDays = - (pTimeStamp->year - BASEYR) * 365 + // years since BASE * days - f_timeLeapYearsSince1970( pTimeStamp->year) +// leap years since BASE - ui16NumDaysFromJan1st[ f_timeIsLeapYear(pTimeStamp->year)][pTimeStamp->month] + - pTimeStamp->day - 1; // days since 1st of month - } - - // Do time part of calculation - secs since 1/1/1970 12:00am. - - *puiSeconds = (((uiDays * 24) + // convert days to hours - pTimeStamp->hour ) * 60 + // convert hours to min - pTimeStamp->minute) * 60 + // convert min to sec - pTimeStamp->second; // give secs granularity - -} - -/**************************************************************************** -Desc: Compare two time stamps -In: date1, date2 - pointers to two DATIM structures - flag - flag to indicate the type of comparison - 0 - compare date and time - 1 - compare date only - 2 - compare time only -Out: -Ret: -1 if date1 is less than date2 - 0 if date1 is equal to date2 - 1 if date1 is greater than date2 -Notes: -****************************************************************************/ -FLMINT f_timeCompareTimeStamps( - F_TMSTAMP * pTimeStamp1, - F_TMSTAMP * pTimeStamp2, - FLMUINT flag) -{ - if( flag != 2) /* not comparing times only */ - { - if( pTimeStamp1->year != pTimeStamp2->year) - { - return((pTimeStamp1->year < pTimeStamp2->year) ? -1 : 1); - } - if( pTimeStamp1->month != pTimeStamp2->month) - { - return((pTimeStamp1->month < pTimeStamp2->month) ? -1 : 1); - } - if( pTimeStamp1->day != pTimeStamp2->day) - { - return((pTimeStamp1->day < pTimeStamp2->day) ? -1 : 1); - } - } - if( flag != 1) - { - if( pTimeStamp1->hour != pTimeStamp2->hour) - { - return((pTimeStamp1->hour < pTimeStamp2->hour) ? -1 : 1); - } - if( pTimeStamp1->minute != pTimeStamp2->minute) - { - return((pTimeStamp1->minute < pTimeStamp2->minute) ? -1 : 1); - } - if( pTimeStamp1->second != pTimeStamp2->second) - { - return((pTimeStamp1->second < pTimeStamp2->second) ? -1 : 1); - } - } - return(0); -} - -/**************************************************************************** -Desc: Get the current time in milliseconds. -****************************************************************************/ -#if defined( FLM_UNIX) -unsigned f_timeGetMilliTime() -{ -#if defined( FLM_SOLARIS) - return( (unsigned)((FLMUINT64)gethrtime() / (FLMUINT64)1000000)); -#else - struct timeval tv; - - gettimeofday(&tv, 0); - - return( (((FLMUINT64)tv.tv_sec * (FLMUINT64)1000000) + - (FLMUINT64)tv.tv_usec) / 1000); -#endif -} -#endif diff --git a/xflaim/src/funicode.cpp b/xflaim/src/funicode.cpp index eb2289c..eec7125 100644 --- a/xflaim/src/funicode.cpp +++ b/xflaim/src/funicode.cpp @@ -23,1535 +23,9 @@ // $Id: funicode.cpp 3115 2006-01-19 13:24:39 -0700 (Thu, 19 Jan 2006) dsanders $ //------------------------------------------------------------------------------ -#define DEF_FLM_UNI_GLOBALS +//#define DEF_FLM_UNI_GLOBALS #include "flaimsys.h" -// Local constants - -#define UTOWP60_ENTRIES 1502 - -// Mapping table - -/**************************************************************************** -Desc: UNICODE to WP6 character mapping table -Notes: This table is used to convert a subset of Unicode characters to - their WordPerfect equivalents so that the WP collation routines - can be used for indexing. This contains characters that can be - mapped 1:1 from Unicode->WP and from WP->Unicode. There is - no ambiguity and there are no character expansions or - contractions. -****************************************************************************/ -FLMUINT16 WP_UTOWP60[ UTOWP60_ENTRIES][2] = -{ - { 0x00A1, 0x0407 }, // 7 , 4 - { 0x00A2, 0x0413 }, // 19 , 4 - { 0x00A3, 0x040b }, // 11 , 4 - { 0x00A4, 0x0418 }, // 24 , 4 - { 0x00A5, 0x040c }, // 12 , 4 - { 0x00A7, 0x0406 }, // 6 , 4 - { 0x00A9, 0x0417 }, // 23 , 4 - { 0x00AA, 0x040f }, // 15 , 4 - { 0x00AB, 0x0409 }, // 9 , 4 - { 0x00AC, 0x0614 }, // 20 , 6 - { 0x00AE, 0x0416 }, // 22 , 4 - { 0x00B0, 0x0624 }, // 36 , 6 - { 0x00B1, 0x0601 }, // 1 , 6 - { 0x00B2, 0x0414 }, // 20 , 4 - { 0x00B3, 0x041a }, // 26 , 4 - { 0x00B5, 0x0625 }, // 37 , 6 - { 0x00B6, 0x0405 }, // 5 , 4 - { 0x00B7, 0x0101 }, // 101, 1 - { 0x00B9, 0x044e }, // 78 , 4 - { 0x00BA, 0x0410 }, // 16 , 4 - { 0x00BB, 0x040a }, // 10 , 4 - { 0x00BC, 0x0412 }, // 18 , 4 - { 0x00BD, 0x0411 }, // 17 , 4 - { 0x00BE, 0x0419 }, // 25 , 4 - { 0x00BF, 0x0408 }, // 8 , 4 - { 0x00C0, 0x0120 }, // 32 , 1 - { 0x00C1, 0x011a }, // 26 , 1 - { 0x00C2, 0x011c }, // 28 , 1 - { 0x00C3, 0x014c }, // 76 , 1 - { 0x00C4, 0x011e }, // 30 , 1 - { 0x00C5, 0x0122 }, // 34 , 1 - { 0x00C6, 0x0124 }, // 36 , 1 - { 0x00C7, 0x0126 }, // 38 , 1 - { 0x00C8, 0x012e }, // 46 , 1 - { 0x00C9, 0x0128 }, // 40 , 1 - { 0x00CA, 0x012a }, // 42 , 1 - { 0x00CB, 0x012c }, // 44 , 1 - { 0x00CC, 0x0136 }, // 54 , 1 - { 0x00CD, 0x0130 }, // 48 , 1 - { 0x00CE, 0x0132 }, // 50 , 1 - { 0x00CF, 0x0134 }, // 52 , 1 - { 0x00D0, 0x0156 }, // 86 , 1 - { 0x00D1, 0x0138 }, // 56 , 1 - { 0x00D2, 0x0140 }, // 64 , 1 - { 0x00D3, 0x013a }, // 58 , 1 - { 0x00D4, 0x013c }, // 60 , 1 - { 0x00D5, 0x0152 }, // 82 , 1 - { 0x00D6, 0x013e }, // 62 , 1 - { 0x00D7, 0x0627 }, // 39 , 6 - { 0x00D8, 0x0150 }, // 80 , 1 - { 0x00D9, 0x0148 }, // 72 , 1 - { 0x00DA, 0x0142 }, // 66 , 1 - { 0x00DB, 0x0144 }, // 68 , 1 - { 0x00DC, 0x0146 }, // 70 , 1 - { 0x00DD, 0x0154 }, // 84 , 1 - { 0x00DE, 0x0158 }, // 88 , 1 - { 0x00DF, 0x0117 }, // 23 , 1 - { 0x00E0, 0x0121 }, // 33 , 1 - { 0x00E1, 0x011b }, // 27 , 1 - { 0x00E2, 0x011d }, // 29 , 1 - { 0x00E3, 0x014d }, // 77 , 1 - { 0x00E4, 0x011f }, // 31 , 1 - { 0x00E5, 0x0123 }, // 35 , 1 - { 0x00E6, 0x0125 }, // 37 , 1 - { 0x00E7, 0x0127 }, // 39 , 1 - { 0x00E8, 0x012f }, // 47 , 1 - { 0x00E9, 0x0129 }, // 41 , 1 - { 0x00EA, 0x012b }, // 43 , 1 - { 0x00EB, 0x012d }, // 45 , 1 - { 0x00EC, 0x0137 }, // 55 , 1 - { 0x00ED, 0x0131 }, // 49 , 1 - { 0x00EE, 0x0133 }, // 51 , 1 - { 0x00EF, 0x0135 }, // 53 , 1 - { 0x00F0, 0x0157 }, // 87 , 1 - { 0x00F1, 0x0139 }, // 57 , 1 - { 0x00F2, 0x0141 }, // 65 , 1 - { 0x00F3, 0x013b }, // 59 , 1 - { 0x00F4, 0x013d }, // 61 , 1 - { 0x00F5, 0x0153 }, // 83 , 1 - { 0x00F6, 0x013f }, // 63 , 1 - { 0x00F7, 0x0608 }, // 8 , 6 - { 0x00F8, 0x0151 }, // 81 , 1 - { 0x00F9, 0x0149 }, // 73 , 1 - { 0x00FA, 0x0143 }, // 67 , 1 - { 0x00FB, 0x0145 }, // 69 , 1 - { 0x00FC, 0x0147 }, // 71 , 1 - { 0x00FD, 0x0155 }, // 85 , 1 - { 0x00FE, 0x0159 }, // 89 , 1 - { 0x00FF, 0x014b }, // 75 , 1 - { 0x0100, 0x015c }, // 92 , 1 - { 0x0101, 0x015d }, // 93 , 1 - { 0x0102, 0x015a }, // 90 , 1 - { 0x0103, 0x015b }, // 91 , 1 - { 0x0104, 0x015e }, // 94 , 1 - { 0x0105, 0x015f }, // 95 , 1 - { 0x0106, 0x0160 }, // 96 , 1 - { 0x0107, 0x0161 }, // 97 , 1 - { 0x0108, 0x0164 }, // 100, 1 - { 0x0109, 0x0165 }, // 101, 1 - { 0x010A, 0x0166 }, // 102, 1 - { 0x010B, 0x0167 }, // 103, 1 - { 0x010C, 0x0162 }, // 98 , 1 - { 0x010D, 0x0163 }, // 99 , 1 - { 0x010E, 0x0168 }, // 104, 1 - { 0x010F, 0x0169 }, // 105, 1 - { 0x0110, 0x014e }, // 78 , 1 - { 0x0111, 0x014f }, // 79 , 1 - { 0x0112, 0x016e }, // 110, 1 - { 0x0113, 0x016f }, // 111, 1 - { 0x0114, 0x01ea }, // 234, 1 - { 0x0115, 0x01eb }, // 235, 1 - { 0x0116, 0x016c }, // 108, 1 - { 0x0117, 0x016d }, // 109, 1 - { 0x0118, 0x0170 }, // 112, 1 - { 0x0119, 0x0171 }, // 113, 1 - { 0x011A, 0x016a }, // 106, 1 - { 0x011B, 0x016b }, // 107, 1 - { 0x011C, 0x017a }, // 122, 1 - { 0x011D, 0x017b }, // 123, 1 - { 0x011E, 0x0174 }, // 116, 1 - { 0x011F, 0x0175 }, // 117, 1 - { 0x0120, 0x017c }, // 124, 1 - { 0x0121, 0x017d }, // 125, 1 - { 0x0122, 0x0178 }, // 120, 1 - { 0x0123, 0x0179 }, // 121, 1 - { 0x0124, 0x017e }, // 126, 1 - { 0x0125, 0x017f }, // 127, 1 - { 0x0126, 0x0180 }, // 128, 1 - { 0x0127, 0x0181 }, // 129, 1 - { 0x0128, 0x0188 }, // 136, 1 - { 0x0129, 0x0189 }, // 137, 1 - { 0x012A, 0x0184 }, // 132, 1 - { 0x012B, 0x0185 }, // 133, 1 - { 0x012C, 0x01ec }, // 236, 1 - { 0x012D, 0x01ed }, // 237, 1 - { 0x012E, 0x0186 }, // 134, 1 - { 0x012F, 0x0187 }, // 135, 1 - { 0x0130, 0x0182 }, // 130, 1 - { 0x0131, 0x01ef }, // 239, 1 - { 0x0132, 0x018a }, // 138, 1 - { 0x0133, 0x018b }, // 139, 1 - { 0x0134, 0x018c }, // 140, 1 - { 0x0135, 0x018d }, // 141, 1 - { 0x0136, 0x018e }, // 142, 1 - { 0x0137, 0x018f }, // 143, 1 - { 0x0138, 0x0118 }, // 24 , 1 - { 0x0139, 0x0190 }, // 144, 1 - { 0x013A, 0x0191 }, // 145, 1 - { 0x013B, 0x0194 }, // 148, 1 - { 0x013C, 0x0195 }, // 149, 1 - { 0x013D, 0x0192 }, // 146, 1 - { 0x013E, 0x0193 }, // 147, 1 - { 0x013F, 0x0196 }, // 150, 1 - { 0x0140, 0x0197 }, // 151, 1 - { 0x0141, 0x0198 }, // 152, 1 - { 0x0142, 0x0199 }, // 153, 1 - { 0x0143, 0x019a }, // 154, 1 - { 0x0144, 0x019b }, // 155, 1 - { 0x0145, 0x01a0 }, // 160, 1 - { 0x0146, 0x01a1 }, // 161, 1 - { 0x0147, 0x019e }, // 158, 1 - { 0x0148, 0x019f }, // 159, 1 - { 0x0149, 0x019d }, // 157, 1 - { 0x014A, 0x01d2 }, // 210, 1 - { 0x014B, 0x01d3 }, // 211, 1 - { 0x014C, 0x01a4 }, // 164, 1 - { 0x014D, 0x01a5 }, // 165, 1 - { 0x014E, 0x01f0 }, // 240, 1 - { 0x014F, 0x01f1 }, // 241, 1 - { 0x0150, 0x01a2 }, // 162, 1 - { 0x0151, 0x01a3 }, // 163, 1 - { 0x0152, 0x01a6 }, // 166, 1 - { 0x0153, 0x01a7 }, // 167, 1 - { 0x0154, 0x01a8 }, // 168, 1 - { 0x0155, 0x01a9 }, // 169, 1 - { 0x0156, 0x01ac }, // 172, 1 - { 0x0157, 0x01ad }, // 173, 1 - { 0x0158, 0x01aa }, // 170, 1 - { 0x0159, 0x01ab }, // 171, 1 - { 0x015A, 0x01ae }, // 174, 1 - { 0x015B, 0x01af }, // 175, 1 - { 0x015C, 0x01b4 }, // 180, 1 - { 0x015D, 0x01b5 }, // 181, 1 - { 0x015E, 0x01b2 }, // 178, 1 - { 0x015F, 0x01b3 }, // 179, 1 - { 0x0160, 0x01b0 }, // 176, 1 - { 0x0161, 0x01b1 }, // 177, 1 - { 0x0162, 0x01b8 }, // 184, 1 - { 0x0163, 0x01b9 }, // 185, 1 - { 0x0164, 0x01b6 }, // 182, 1 - { 0x0165, 0x01b7 }, // 183, 1 - { 0x0166, 0x01ba }, // 186, 1 - { 0x0167, 0x01bb }, // 187, 1 - { 0x0168, 0x01c6 }, // 198, 1 - { 0x0169, 0x01c7 }, // 199, 1 - { 0x016A, 0x01c0 }, // 192, 1 - { 0x016B, 0x01c1 }, // 193, 1 - { 0x016C, 0x01bc }, // 188, 1 - { 0x016D, 0x01bd }, // 189, 1 - { 0x016E, 0x01c4 }, // 196, 1 - { 0x016F, 0x01c5 }, // 197, 1 - { 0x0170, 0x01be }, // 190, 1 - { 0x0171, 0x01bf }, // 191, 1 - { 0x0172, 0x01c2 }, // 194, 1 - { 0x0173, 0x01c3 }, // 195, 1 - { 0x0174, 0x01c8 }, // 200, 1 - { 0x0175, 0x01c9 }, // 201, 1 - { 0x0176, 0x01ca }, // 202, 1 - { 0x0177, 0x01cb }, // 203, 1 - { 0x0178, 0x014a }, // 74 , 1 - { 0x0179, 0x01cc }, // 204, 1 - { 0x017A, 0x01cd }, // 205, 1 - { 0x017B, 0x01d0 }, // 208, 1 - { 0x017C, 0x01d1 }, // 209, 1 - { 0x017D, 0x01ce }, // 206, 1 - { 0x017E, 0x01cf }, // 207, 1 - { 0x0192, 0x040e }, // 14 , 4 - { 0x0194, 0x0a7c }, // 124, 10 - { 0x01A0, 0x01e6 }, // 230, 1 - { 0x01A1, 0x01e7 }, // 231, 1 - { 0x01AF, 0x01e8 }, // 232, 1 - { 0x01B0, 0x01e9 }, // 233, 1 - { 0x01C0, 0x0605 }, // 5 , 6 - { 0x0250, 0x0237 }, // 55 , 2 - { 0x0251, 0x0238 }, // 56 , 2 - { 0x0252, 0x0239 }, // 57 , 2 - { 0x0253, 0x023a }, // 58 , 2 - { 0x0254, 0x023c }, // 60 , 2 - { 0x0255, 0x023d }, // 61 , 2 - { 0x0256, 0x023f }, // 63 , 2 - { 0x0257, 0x0240 }, // 64 , 2 - { 0x0258, 0x0241 }, // 65 , 2 - { 0x0259, 0x0242 }, // 66 , 2 - { 0x025A, 0x0243 }, // 67 , 2 - { 0x025B, 0x0244 }, // 68 , 2 - { 0x025C, 0x0245 }, // 69 , 2 - { 0x025D, 0x0246 }, // 70 , 2 - { 0x025E, 0x0248 }, // 72 , 2 - { 0x025F, 0x0249 }, // 73 , 2 - { 0x0260, 0x024c }, // 76 , 2 - { 0x0261, 0x024b }, // 75 , 2 - { 0x0262, 0x024d }, // 77 , 2 - { 0x0263, 0x024f }, // 79 , 2 - { 0x0264, 0x0250 }, // 80 , 2 - { 0x0265, 0x0251 }, // 81 , 2 - { 0x0266, 0x0252 }, // 82 , 2 - { 0x0267, 0x0253 }, // 83 , 2 - { 0x0268, 0x0255 }, // 85 , 2 - { 0x0269, 0x0257 }, // 87 , 2 - { 0x026A, 0x0256 }, // 86 , 2 - { 0x026B, 0x025a }, // 90 , 2 - { 0x026C, 0x025b }, // 91 , 2 - { 0x026D, 0x025c }, // 92 , 2 - { 0x026E, 0x025e }, // 94 , 2 - { 0x026F, 0x0260 }, // 96 , 2 - { 0x0270, 0x0261 }, // 97 , 2 - { 0x0271, 0x0262 }, // 98 , 2 - { 0x0272, 0x0263 }, // 99 , 2 - { 0x0273, 0x0264 }, // 100, 2 - { 0x0274, 0x0265 }, // 101, 2 - { 0x0275, 0x0279 }, // 121, 2 - { 0x0276, 0x0266 }, // 102, 2 - { 0x0277, 0x0267 }, // 103, 2 - { 0x0278, 0x024a }, // 74 , 2 - { 0x0279, 0x0269 }, // 105, 2 - { 0x027A, 0x026a }, // 106, 2 - { 0x027B, 0x026b }, // 107, 2 - { 0x027C, 0x026c }, // 108, 2 - { 0x027D, 0x026d }, // 109, 2 - { 0x027E, 0x026e }, // 110, 2 - { 0x027F, 0x026f }, // 111, 2 - { 0x0280, 0x0270 }, // 112, 2 - { 0x0281, 0x0271 }, // 113, 2 - { 0x0282, 0x0272 }, // 114, 2 - { 0x0283, 0x0273 }, // 115, 2 - { 0x0284, 0x0274 }, // 116, 2 - { 0x0285, 0x0275 }, // 117, 2 - { 0x0286, 0x0276 }, // 118, 2 - { 0x0287, 0x0277 }, // 119, 2 - { 0x0288, 0x0278 }, // 120, 2 - { 0x0289, 0x027a }, // 122, 2 - { 0x028A, 0x027b }, // 123, 2 - { 0x028B, 0x027d }, // 125, 2 - { 0x028C, 0x027c }, // 124, 2 - { 0x028D, 0x027e }, // 126, 2 - { 0x028E, 0x025f }, // 95 , 2 - { 0x028F, 0x0280 }, // 128, 2 - { 0x0290, 0x0281 }, // 129, 2 - { 0x0291, 0x0282 }, // 130, 2 - { 0x0292, 0x0283 }, // 131, 2 - { 0x0293, 0x0284 }, // 132, 2 - { 0x0294, 0x0285 }, // 133, 2 - { 0x0295, 0x0286 }, // 134, 2 - { 0x0296, 0x0287 }, // 135, 2 - { 0x0297, 0x023e }, // 62 , 2 - { 0x0298, 0x028a }, // 138, 2 - { 0x0299, 0x023b }, // 59 , 2 - { 0x029A, 0x0247 }, // 71 , 2 - { 0x029B, 0x024e }, // 78 , 2 - { 0x029C, 0x0254 }, // 84 , 2 - { 0x029D, 0x0258 }, // 88 , 2 - { 0x029E, 0x0259 }, // 89 , 2 - { 0x029F, 0x025d }, // 93 , 2 - { 0x02A0, 0x0268 }, // 104, 2 - { 0x02A1, 0x0288 }, // 136, 2 - { 0x02A2, 0x0289 }, // 137, 2 - { 0x02A3, 0x028b }, // 139, 2 - { 0x02A4, 0x028c }, // 140, 2 - { 0x02A5, 0x028d }, // 141, 2 - { 0x02A6, 0x028e }, // 142, 2 - { 0x02A7, 0x028f }, // 143, 2 - { 0x02A8, 0x0290 }, // 144, 2 - { 0x02B0, 0x0235 }, // 53 , 2 - { 0x02B6, 0x0236 }, // 54 , 2 - { 0x02B9, 0x0200 }, // 0 , 2 - { 0x02BA, 0x0201 }, // 1 , 2 - { 0x02BB, 0x0202 }, // 2 , 2 - { 0x02BC, 0x0205 }, // 5 , 2 - { 0x02BD, 0x0204 }, // 4 , 2 - { 0x02BE, 0x0207 }, // 7 , 2 - { 0x02BF, 0x0208 }, // 8 , 2 - { 0x02C6, 0x0217 }, // 23 , 2 - { 0x02C7, 0x0218 }, // 24 , 2 - { 0x02C8, 0x020f }, // 15 , 2 - { 0x02C9, 0x0211 }, // 17 , 2 - { 0x02CA, 0x0212 }, // 18 , 2 - { 0x02CB, 0x0213 }, // 19 , 2 - { 0x02CC, 0x0210 }, // 16 , 2 - { 0x02CD, 0x0214 }, // 20 , 2 - { 0x02CE, 0x0215 }, // 21 , 2 - { 0x02CF, 0x0216 }, // 22 , 2 - { 0x02D0, 0x020a }, // 10 , 2 - { 0x02D1, 0x020b }, // 11 , 2 - { 0x02D2, 0x022a }, // 42 , 2 - { 0x02D3, 0x022b }, // 43 , 2 - { 0x02DA, 0x021b }, // 27 , 2 - { 0x02DB, 0x0231 }, // 49 , 2 - { 0x02DC, 0x0219 }, // 25 , 2 - { 0x02DE, 0x0233 }, // 51 , 2 - { 0x0300, 0x0100 }, // 0 , 1 - { 0x0301, 0x0106 }, // 6 , 1 - { 0x0302, 0x0103 }, // 3 , 1 - { 0x0303, 0x0102 }, // 2 , 1 - { 0x0304, 0x0108 }, // 8 , 1 - { 0x0305, 0x0115 }, // 21 , 1 - { 0x0306, 0x0116 }, // 22 , 1 - { 0x0307, 0x010f }, // 15 , 1 - { 0x0308, 0x0107 }, // 7 , 1 - { 0x030A, 0x010e }, // 14 , 1 - { 0x030B, 0x0110 }, // 16 , 1 - { 0x030C, 0x0113 }, // 19 , 1 - { 0x0310, 0x0209 }, // 9 , 2 - { 0x0311, 0x0858 }, // 88 , 8 - { 0x0313, 0x0109 }, // 9 , 1 - { 0x0314, 0x085a }, // 90 , 8 - { 0x0315, 0x010a }, // 10 , 1 - { 0x031C, 0x0221 }, // 33 , 2 - { 0x031D, 0x0222 }, // 34 , 2 - { 0x031E, 0x0223 }, // 35 , 2 - { 0x031F, 0x0224 }, // 36 , 2 - { 0x0320, 0x0225 }, // 37 , 2 - { 0x0321, 0x0226 }, // 38 , 2 - { 0x0322, 0x0227 }, // 39 , 2 - { 0x0323, 0x021e }, // 30 , 2 - { 0x0324, 0x0220 }, // 32 , 2 - { 0x0325, 0x021a }, // 26 , 2 - { 0x0326, 0x010c }, // 12 , 1 - { 0x0327, 0x0111 }, // 17 , 1 - { 0x0328, 0x0112 }, // 18 , 1 - { 0x0329, 0x020e }, // 14 , 2 - { 0x032A, 0x0228 }, // 40 , 2 - { 0x032B, 0x0229 }, // 41 , 2 - { 0x032C, 0x021d }, // 29 , 2 - { 0x032D, 0x021c }, // 28 , 2 - { 0x032E, 0x020d }, // 13 , 2 - { 0x0335, 0x0104 }, // 4 , 1 - { 0x0337, 0x0114 }, // 20 , 1 - { 0x0338, 0x0105 }, // 5 , 1 - { 0x033E, 0x0230 }, // 48 , 2 - { 0x0345, 0x085b }, // 91 , 8 - { 0x0374, 0x0851 }, // 81 , 8 - { 0x0375, 0x0852 }, // 82 , 8 - { 0x0391, 0x0800 }, // 0 , 8 - { 0x0392, 0x0802 }, // 2 , 8 - { 0x0393, 0x0806 }, // 6 , 8 - { 0x0394, 0x0808 }, // 8 , 8 - { 0x0395, 0x080a }, // 10 , 8 - { 0x0396, 0x080c }, // 12 , 8 - { 0x0397, 0x080e }, // 14 , 8 - { 0x0398, 0x0810 }, // 16 , 8 - { 0x0399, 0x0812 }, // 18 , 8 - { 0x039A, 0x0814 }, // 20 , 8 - { 0x039B, 0x0816 }, // 22 , 8 - { 0x039C, 0x0818 }, // 24 , 8 - { 0x039D, 0x081a }, // 26 , 8 - { 0x039E, 0x081c }, // 28 , 8 - { 0x039F, 0x081e }, // 30 , 8 - { 0x03A0, 0x0820 }, // 32 , 8 - { 0x03A1, 0x0822 }, // 34 , 8 - { 0x03A3, 0x0824 }, // 36 , 8 - { 0x03A4, 0x0828 }, // 40 , 8 - { 0x03A5, 0x082a }, // 42 , 8 - { 0x03A6, 0x082c }, // 44 , 8 - { 0x03A7, 0x082e }, // 46 , 8 - { 0x03A8, 0x0830 }, // 48 , 8 - { 0x03A9, 0x0832 }, // 50 , 8 - { 0x03AA, 0x083c }, // 60 , 8 - { 0x03AB, 0x0842 }, // 66 , 8 - { 0x03AC, 0x0835 }, // 53 , 8 - { 0x03AD, 0x0837 }, // 55 , 8 - { 0x03AE, 0x0839 }, // 57 , 8 - { 0x03AF, 0x083b }, // 59 , 8 - { 0x03B1, 0x0801 }, // 1 , 8 - { 0x03B2, 0x0803 }, // 3 , 8 - { 0x03B3, 0x0807 }, // 7 , 8 - { 0x03B4, 0x0809 }, // 9 , 8 - { 0x03B5, 0x080b }, // 11 , 8 - { 0x03B6, 0x080d }, // 13 , 8 - { 0x03B7, 0x080f }, // 15 , 8 - { 0x03B8, 0x0811 }, // 17 , 8 - { 0x03B9, 0x0813 }, // 19 , 8 - { 0x03BA, 0x0815 }, // 21 , 8 - { 0x03BB, 0x0817 }, // 23 , 8 - { 0x03BC, 0x0819 }, // 25 , 8 - { 0x03BD, 0x081b }, // 27 , 8 - { 0x03BE, 0x081d }, // 29 , 8 - { 0x03BF, 0x081f }, // 31 , 8 - { 0x03C0, 0x0821 }, // 33 , 8 - { 0x03C1, 0x0823 }, // 35 , 8 - { 0x03C2, 0x0827 }, // 39 , 8 - { 0x03C3, 0x0825 }, // 37 , 8 - { 0x03C4, 0x0829 }, // 41 , 8 - { 0x03C5, 0x082b }, // 43 , 8 - { 0x03C6, 0x082d }, // 45 , 8 - { 0x03C7, 0x082f }, // 47 , 8 - { 0x03C8, 0x0831 }, // 49 , 8 - { 0x03C9, 0x0833 }, // 51 , 8 - { 0x03CA, 0x083d }, // 61 , 8 - { 0x03CB, 0x0843 }, // 67 , 8 - { 0x03CC, 0x083f }, // 63 , 8 - { 0x03CD, 0x0841 }, // 65 , 8 - { 0x03CE, 0x0845 }, // 69 , 8 - { 0x03D0, 0x0805 }, // 5 , 8 - { 0x03D1, 0x0847 }, // 71 , 8 - { 0x03D2, 0x084c }, // 76 , 8 - { 0x03D5, 0x084d }, // 77 , 8 - { 0x03D6, 0x0849 }, // 73 , 8 - { 0x03D7, 0x084f }, // 79 , 8 - { 0x03DA, 0x08d7 }, // 215, 8 - { 0x03DB, 0x084B }, // 75 , 8 - { 0x03DC, 0x08d8 }, // 216, 8 - { 0x03DE, 0x08d9 }, // 217, 8 - { 0x03E0, 0x08da }, // 218, 8 - { 0x03F0, 0x0848 }, // 72 , 8 - { 0x03F1, 0x084a }, // 74 , 8 - { 0x0401, 0x0a0c }, // 12 , 10 - { 0x0402, 0x0a4a }, // 74 , 10 - { 0x0403, 0x0a44 }, // 68 , 10 - { 0x0404, 0x0a4e }, // 78 , 10 - { 0x0405, 0x0a52 }, // 82 , 10 - { 0x0406, 0x0a58 }, // 88 , 10 - { 0x0407, 0x0a5a }, // 90 , 10 - { 0x0408, 0x0a5e }, // 94 , 10 - { 0x0409, 0x0a68 }, // 104, 10 - { 0x040A, 0x0a6c }, // 108, 10 - { 0x040B, 0x0a72 }, // 114, 10 - { 0x040C, 0x0a60 }, // 96 , 10 - { 0x040E, 0x0a74 }, // 116, 10 - { 0x040F, 0x0a86 }, // 134, 10 - { 0x0410, 0x0a00 }, // 0 , 10 - { 0x0411, 0x0a02 }, // 2 , 10 - { 0x0412, 0x0a04 }, // 4 , 10 - { 0x0413, 0x0a06 }, // 6 , 10 - { 0x0414, 0x0a08 }, // 8 , 10 - { 0x0415, 0x0a0a }, // 10 , 10 - { 0x0416, 0x0a0e }, // 14 , 10 - { 0x0417, 0x0a10 }, // 16 , 10 - { 0x0418, 0x0a12 }, // 18 , 10 - { 0x0419, 0x0a14 }, // 20 , 10 - { 0x041A, 0x0a16 }, // 22 , 10 - { 0x041B, 0x0a18 }, // 24 , 10 - { 0x041C, 0x0a1a }, // 26 , 10 - { 0x041D, 0x0a1c }, // 28 , 10 - { 0x041E, 0x0a1e }, // 30 , 10 - { 0x041F, 0x0a20 }, // 32 , 10 - { 0x0420, 0x0a22 }, // 34 , 10 - { 0x0421, 0x0a24 }, // 36 , 10 - { 0x0422, 0x0a26 }, // 38 , 10 - { 0x0423, 0x0a28 }, // 40 , 10 - { 0x0424, 0x0a2a }, // 42 , 10 - { 0x0425, 0x0a2c }, // 44 , 10 - { 0x0426, 0x0a2e }, // 46 , 10 - { 0x0427, 0x0a30 }, // 48 , 10 - { 0x0428, 0x0a32 }, // 50 , 10 - { 0x0429, 0x0a34 }, // 52 , 10 - { 0x042A, 0x0a36 }, // 54 , 10 - { 0x042B, 0x0a38 }, // 56 , 10 - { 0x042C, 0x0a3a }, // 58 , 10 - { 0x042D, 0x0a3c }, // 60 , 10 - { 0x042E, 0x0a3e }, // 62 , 10 - { 0x042F, 0x0a40 }, // 64 , 10 - { 0x0430, 0x0a01 }, // 1 , 10 - { 0x0431, 0x0a03 }, // 3 , 10 - { 0x0432, 0x0a05 }, // 5 , 10 - { 0x0433, 0x0a07 }, // 7 , 10 - { 0x0434, 0x0a09 }, // 9 , 10 - { 0x0435, 0x0a0b }, // 11 , 10 - { 0x0436, 0x0a0f }, // 15 , 10 - { 0x0437, 0x0a11 }, // 17 , 10 - { 0x0438, 0x0a13 }, // 19 , 10 - { 0x0439, 0x0a15 }, // 21 , 10 - { 0x043A, 0x0a17 }, // 23 , 10 - { 0x043B, 0x0a19 }, // 25 , 10 - { 0x043C, 0x0a1b }, // 27 , 10 - { 0x043D, 0x0a1d }, // 29 , 10 - { 0x043E, 0x0a1f }, // 31 , 10 - { 0x043F, 0x0a21 }, // 33 , 10 - { 0x0440, 0x0a23 }, // 35 , 10 - { 0x0441, 0x0a25 }, // 37 , 10 - { 0x0442, 0x0a27 }, // 39 , 10 - { 0x0443, 0x0a29 }, // 41 , 10 - { 0x0444, 0x0a2b }, // 43 , 10 - { 0x0445, 0x0a2d }, // 45 , 10 - { 0x0446, 0x0a2f }, // 47 , 10 - { 0x0447, 0x0a31 }, // 49 , 10 - { 0x0448, 0x0a33 }, // 51 , 10 - { 0x0449, 0x0a35 }, // 53 , 10 - { 0x044A, 0x0a37 }, // 55 , 10 - { 0x044B, 0x0a39 }, // 57 , 10 - { 0x044C, 0x0a3b }, // 59 , 10 - { 0x044D, 0x0a3d }, // 61 , 10 - { 0x044E, 0x0a3f }, // 63 , 10 - { 0x044F, 0x0a41 }, // 65 , 10 - { 0x0451, 0x0a0d }, // 13 , 10 - { 0x0452, 0x0a4b }, // 75 , 10 - { 0x0453, 0x0a45 }, // 69 , 10 - { 0x0454, 0x0a4f }, // 79 , 10 - { 0x0455, 0x0a53 }, // 83 , 10 - { 0x0456, 0x0a59 }, // 89 , 10 - { 0x0457, 0x0a5b }, // 91 , 10 - { 0x0458, 0x0a5f }, // 95 , 10 - { 0x0459, 0x0a69 }, // 105, 10 - { 0x045A, 0x0a6d }, // 109, 10 - { 0x045B, 0x0a73 }, // 115, 10 - { 0x045C, 0x0a61 }, // 97 , 10 - { 0x045E, 0x0a75 }, // 117, 10 - { 0x045F, 0x0a87 }, // 135, 10 - { 0x0460, 0x0a70 }, // 112, 10 - { 0x0461, 0x0a71 }, // 113, 10 - { 0x0462, 0x0a8e }, // 142, 10 - { 0x0463, 0x0a8f }, // 143, 10 - { 0x0466, 0x0a90 }, // 144, 10 - { 0x0467, 0x0a91 }, // 145, 10 - { 0x046A, 0x0a92 }, // 146, 10 - { 0x046B, 0x0a93 }, // 147, 10 - { 0x046E, 0x0a94 }, // 148, 10 - { 0x046F, 0x0a95 }, // 149, 10 - { 0x0470, 0x0a96 }, // 150, 10 - { 0x0471, 0x0a97 }, // 151, 10 - { 0x0472, 0x0a98 }, // 152, 10 - { 0x0473, 0x0a99 }, // 153, 10 - { 0x0474, 0x0a9a }, // 154, 10 - { 0x0475, 0x0a9b }, // 155, 10 - { 0x047A, 0x0a6e }, // 110, 10 - { 0x047B, 0x0a6f }, // 111, 10 - { 0x047E, 0x0a84 }, // 132, 10 - { 0x047F, 0x0a85 }, // 133, 10 - { 0x0490, 0x0a46 }, // 70 , 10 - { 0x0491, 0x0a47 }, // 71 , 10 - { 0x0492, 0x0a48 }, // 72 , 10 - { 0x0493, 0x0a49 }, // 73 , 10 - { 0x0496, 0x0a50 }, // 80 , 10 - { 0x0497, 0x0a51 }, // 81 , 10 - { 0x049A, 0x0a62 }, // 98 , 10 - { 0x049B, 0x0a63 }, // 99 , 10 - { 0x049C, 0x0a66 }, // 102, 10 - { 0x049D, 0x0a67 }, // 103, 10 - { 0x04A2, 0x0a6a }, // 106, 10 - { 0x04A3, 0x0a6b }, // 107, 10 - { 0x04AE, 0x0a78 }, // 120, 10 - { 0x04AF, 0x0a79 }, // 121, 10 - { 0x04B0, 0x0a7a }, // 122, 10 - { 0x04B1, 0x0a7b }, // 123, 10 - { 0x04B2, 0x0a7e }, // 126, 10 - { 0x04B3, 0x0a7f }, // 127, 10 - { 0x04B6, 0x0a88 }, // 136, 10 - { 0x04B7, 0x0a89 }, // 137, 10 - { 0x04B8, 0x0a8a }, // 138, 10 - { 0x04B9, 0x0a8b }, // 139, 10 - { 0x04BA, 0x0a82 }, // 130, 10 - { 0x04BB, 0x0a83 }, // 131, 10 - { 0x04D8, 0x0a42 }, // 66 , 10 - { 0x04D9, 0x0a43 }, // 67 , 10 - { 0x04EE, 0x0a76 }, // 118, 10 - { 0x04EF, 0x0a77 }, // 119, 10 - { 0x05B0, 0x0920 }, // 32 , 9 - { 0x05B1, 0x0921 }, // 33 , 9 - { 0x05B2, 0x0922 }, // 34 , 9 - { 0x05B3, 0x0923 }, // 35 , 9 - { 0x05B4, 0x0924 }, // 36 , 9 - { 0x05B5, 0x0925 }, // 37 , 9 - { 0x05B6, 0x0926 }, // 38 , 9 - { 0x05B7, 0x0927 }, // 39 , 9 - { 0x05B8, 0x0928 }, // 40 , 9 - { 0x05B9, 0x0929 }, // 41 , 9 - { 0x05BB, 0x092b }, // 43 , 9 - { 0x05BC, 0x092c }, // 44 , 9 - { 0x05BD, 0x092d }, // 45 , 9 - { 0x05BF, 0x092e }, // 46 , 9 - { 0x05C0, 0x091c }, // 28 , 9 - { 0x05C3, 0x091d }, // 29 , 9 - { 0x05D0, 0x0900 }, // 0 , 9 - { 0x05D1, 0x0901 }, // 1 , 9 - { 0x05D2, 0x0902 }, // 2 , 9 - { 0x05D3, 0x0903 }, // 3 , 9 - { 0x05D4, 0x0904 }, // 4 , 9 - { 0x05D5, 0x0905 }, // 5 , 9 - { 0x05D6, 0x0906 }, // 6 , 9 - { 0x05D7, 0x0907 }, // 7 , 9 - { 0x05D8, 0x0908 }, // 8 , 9 - { 0x05D9, 0x0909 }, // 9 , 9 - { 0x05DA, 0x090a }, // 10 , 9 - { 0x05DB, 0x090b }, // 11 , 9 - { 0x05DC, 0x090c }, // 12 , 9 - { 0x05DD, 0x090d }, // 13 , 9 - { 0x05DE, 0x090e }, // 14 , 9 - { 0x05DF, 0x090f }, // 15 , 9 - { 0x05E0, 0x0910 }, // 16 , 9 - { 0x05E1, 0x0911 }, // 17 , 9 - { 0x05E2, 0x0912 }, // 18 , 9 - { 0x05E3, 0x0913 }, // 19 , 9 - { 0x05E4, 0x0914 }, // 20 , 9 - { 0x05E5, 0x0915 }, // 21 , 9 - { 0x05E6, 0x0916 }, // 22 , 9 - { 0x05E7, 0x0917 }, // 23 , 9 - { 0x05E8, 0x0918 }, // 24 , 9 - { 0x05E9, 0x0919 }, // 25 , 9 - { 0x05EA, 0x091a }, // 26 , 9 - { 0x05F0, 0x0931 }, // 49 , 9 - { 0x05F1, 0x0932 }, // 50 , 9 - { 0x05F2, 0x0933 }, // 51 , 9 - { 0x05F3, 0x091e }, // 30 , 9 - { 0x05F4, 0x091f }, // 31 , 9 - { 0x060C, 0x0d26 }, // 38 , 13 - { 0x061B, 0x0d27 }, // 39 , 13 - { 0x061F, 0x0d28 }, // 40 , 13 - { 0x0621, 0x0da4 }, // 164, 13 - { 0x0622, 0x0db1 }, // 177, 13 - { 0x0623, 0x0da5 }, // 165, 13 - { 0x0624, 0x0da9 }, // 169, 13 - { 0x0625, 0x0da7 }, // 167, 13 - { 0x0626, 0x0dab }, // 171, 13 - { 0x0627, 0x0d3a }, // 58 , 13 - { 0x0628, 0x0d3c }, // 60 , 13 - { 0x0629, 0x0d98 }, // 152, 13 - { 0x062A, 0x0d40 }, // 64 , 13 - { 0x062B, 0x0d44 }, // 68 , 13 - { 0x062C, 0x0d48 }, // 72 , 13 - { 0x062D, 0x0d4c }, // 76 , 13 - { 0x062E, 0x0d50 }, // 80 , 13 - { 0x062F, 0x0d54 }, // 84 , 13 - { 0x0630, 0x0d56 }, // 86 , 13 - { 0x0631, 0x0d58 }, // 88 , 13 - { 0x0632, 0x0d5a }, // 90 , 13 - { 0x0633, 0x0d5c }, // 92 , 13 - { 0x0634, 0x0d60 }, // 96 , 13 - { 0x0635, 0x0d64 }, // 100, 13 - { 0x0636, 0x0d68 }, // 104, 13 - { 0x0637, 0x0d6c }, // 108, 13 - { 0x0638, 0x0d70 }, // 112, 13 - { 0x0639, 0x0d74 }, // 116, 13 - { 0x063A, 0x0d78 }, // 120, 13 - { 0x0640, 0x0dc2 }, // 194, 13 - { 0x0641, 0x0d7c }, // 124, 13 - { 0x0642, 0x0d80 }, // 128, 13 - { 0x0643, 0x0d84 }, // 132, 13 - { 0x0644, 0x0d88 }, // 136, 13 - { 0x0645, 0x0d8c }, // 140, 13 - { 0x0646, 0x0d90 }, // 144, 13 - { 0x0647, 0x0d94 }, // 148, 13 - { 0x0648, 0x0d9a }, // 154, 13 - { 0x0649, 0x0da0 }, // 160, 13 - { 0x064A, 0x0d9c }, // 156, 13 - { 0x064B, 0x0d10 }, // 16 , 13 - { 0x064C, 0x0d11 }, // 17 , 13 - { 0x064E, 0x0d0a }, // 10 , 13 - { 0x064F, 0x0d0c }, // 12 , 13 - { 0x0650, 0x0d0e }, // 14 , 13 - { 0x0651, 0x0d16 }, // 22 , 13 - { 0x0652, 0x0d14 }, // 20 , 13 - { 0x0660, 0x0d38 }, // 56 , 13 - { 0x0661, 0x0d2f }, // 47 , 13 - { 0x0662, 0x0d30 }, // 48 , 13 - { 0x0663, 0x0d31 }, // 49 , 13 - { 0x0664, 0x0d32 }, // 50 , 13 - { 0x0665, 0x0d33 }, // 51 , 13 - { 0x0666, 0x0d34 }, // 52 , 13 - { 0x0667, 0x0d35 }, // 53 , 13 - { 0x0668, 0x0d36 }, // 54 , 13 - { 0x0669, 0x0d37 }, // 55 , 13 - { 0x066A, 0x0d2a }, // 42 , 13 - { 0x0671, 0x0db3 }, // 179, 13 - { 0x0674, 0x0d24 }, // 36 , 13 - { 0x0679, 0x0e3c }, // 60 , 14 - { 0x067A, 0x0e4c }, // 76 , 14 - { 0x067B, 0x0e30 }, // 48 , 14 - { 0x067C, 0x0e40 }, // 64 , 14 - { 0x067D, 0x0e48 }, // 72 , 14 - { 0x067E, 0x0e38 }, // 56 , 14 - { 0x067F, 0x0e44 }, // 68 , 14 - { 0x0680, 0x0e34 }, // 52 , 14 - { 0x0681, 0x0e64 }, // 100, 14 - { 0x0683, 0x0e54 }, // 84 , 14 - { 0x0684, 0x0e50 }, // 80 , 14 - { 0x0685, 0x0e60 }, // 96 , 14 - { 0x0686, 0x0e58 }, // 88 , 14 - { 0x0687, 0x0e5c }, // 92 , 14 - { 0x0688, 0x0e68 }, // 104, 14 - { 0x0689, 0x0e6a }, // 106, 14 - { 0x068A, 0x0e70 }, // 112, 14 - { 0x068C, 0x0e6c }, // 108, 14 - { 0x068D, 0x0e72 }, // 114, 14 - { 0x068E, 0x0e6e }, // 110, 14 - { 0x0691, 0x0e76 }, // 118, 14 - { 0x0692, 0x0e7C }, // 124, 14 - { 0x0693, 0x0e74 }, // 116, 14 - { 0x0695, 0x0e7a }, // 122, 14 - { 0x0696, 0x0e80 }, // 128, 14 - { 0x0698, 0x0e7e }, // 126, 14 - { 0x0699, 0x0e78 }, // 120, 14 - { 0x069A, 0x0e84 }, // 132, 14 - { 0x06A0, 0x0e88 }, // 136, 14 - { 0x06A4, 0x0e8c }, // 140, 14 - { 0x06A6, 0x0e90 }, // 144, 14 - { 0x06A9, 0x0e94 }, // 148, 14 - { 0x06AA, 0x0e9c }, // 156, 14 - { 0x06AB, 0x0ea8 }, // 168, 14 - { 0x06AF, 0x0ea0 }, // 160, 14 - { 0x06B1, 0x0eac }, // 172, 14 - { 0x06B3, 0x0eb0 }, // 176, 14 - { 0x06B5, 0x0eb4 }, // 180, 14 - { 0x06BA, 0x0eba }, // 186, 14 - { 0x06BB, 0x0ec2 }, // 194, 14 - { 0x06BC, 0x0ebe }, // 190, 14 - { 0x06C0, 0x0eda }, // 218, 14 - { 0x06C6, 0x0ec6 }, // 198, 14 - { 0x06CA, 0x0ec8 }, // 200, 14 - { 0x06CE, 0x0ed0 }, // 208, 14 - { 0x06D1, 0x0ed6 }, // 214, 14 - { 0x06D2, 0x0ed4 }, // 212, 14 - { 0x06D6, 0x0d25 }, // 37 , 13 - { 0x06E4, 0x0d22 }, // 34 , 13 - { 0x06F4, 0x0e29 }, // 41 , 14 - { 0x06F5, 0x0e2b }, // 43 , 14 - { 0x06F6, 0x0e2c }, // 44 , 14 - { 0x06F7, 0x0e2e }, // 46 , 14 - { 0x06F8, 0x0e2f }, // 47 , 14 - { 0x10D0, 0x0ad2 }, // 210, 10 - { 0x10D1, 0x0ad3 }, // 211, 10 - { 0x10D2, 0x0ad4 }, // 212, 10 - { 0x10D3, 0x0ad5 }, // 213, 10 - { 0x10D4, 0x0ad6 }, // 214, 10 - { 0x10D5, 0x0ad7 }, // 215, 10 - { 0x10D6, 0x0ad8 }, // 216, 10 - { 0x10D7, 0x0ada }, // 218, 10 - { 0x10D8, 0x0adb }, // 219, 10 - { 0x10D9, 0x0adc }, // 220, 10 - { 0x10DA, 0x0add }, // 221, 10 - { 0x10DB, 0x0ade }, // 222, 10 - { 0x10DC, 0x0adf }, // 223, 10 - { 0x10DD, 0x0ae1 }, // 225, 10 - { 0x10DE, 0x0ae2 }, // 226, 10 - { 0x10DF, 0x0ae3 }, // 227, 10 - { 0x10E0, 0x0ae4 }, // 228, 10 - { 0x10E1, 0x0ae5 }, // 229, 10 - { 0x10E2, 0x0ae6 }, // 230, 10 - { 0x10E3, 0x0ae7 }, // 231, 10 - { 0x10E4, 0x0ae9 }, // 233, 10 - { 0x10E5, 0x0aea }, // 234, 10 - { 0x10E6, 0x0aeb }, // 235, 10 - { 0x10E7, 0x0aec }, // 236, 10 - { 0x10E8, 0x0aed }, // 237, 10 - { 0x10E9, 0x0aee }, // 238, 10 - { 0x10EA, 0x0aef }, // 239, 10 - { 0x10EB, 0x0af0 }, // 240, 10 - { 0x10EC, 0x0af1 }, // 241, 10 - { 0x10ED, 0x0af2 }, // 242, 10 - { 0x10EE, 0x0af3 }, // 243, 10 - { 0x10EF, 0x0af5 }, // 245, 10 - { 0x10F0, 0x0af6 }, // 246, 10 - { 0x10F1, 0x0ad9 }, // 217, 10 - { 0x10F2, 0x0ae0 }, // 224, 10 - { 0x10F3, 0x0ae8 }, // 232, 10 - { 0x10F4, 0x0af4 }, // 244, 10 - { 0x10F5, 0x0af7 }, // 247, 10 - { 0x10F6, 0x0af8 }, // 248, 10 - { 0x1F00, 0x0873 }, // 115, 8 - { 0x1F01, 0x087b }, // 123, 8 - { 0x1F02, 0x0875 }, // 117, 8 - { 0x1F03, 0x087d }, // 125, 8 - { 0x1F04, 0x0874 }, // 116, 8 - { 0x1F05, 0x087c }, // 124, 8 - { 0x1F10, 0x0884 }, // 132, 8 - { 0x1F11, 0x0887 }, // 135, 8 - { 0x1F12, 0x0886 }, // 134, 8 - { 0x1F13, 0x0889 }, // 137, 8 - { 0x1F14, 0x0885 }, // 133, 8 - { 0x1F15, 0x0888 }, // 136, 8 - { 0x1F20, 0x0890 }, // 144, 8 - { 0x1F21, 0x0898 }, // 152, 8 - { 0x1F22, 0x0892 }, // 146, 8 - { 0x1F23, 0x089a }, // 154, 8 - { 0x1F24, 0x0891 }, // 145, 8 - { 0x1F25, 0x0899 }, // 153, 8 - { 0x1F30, 0x08a4 }, // 164, 8 - { 0x1F31, 0x08a8 }, // 168, 8 - { 0x1F32, 0x08a6 }, // 166, 8 - { 0x1F33, 0x08aa }, // 170, 8 - { 0x1F34, 0x08a5 }, // 165, 8 - { 0x1F35, 0x08a9 }, // 169, 8 - { 0x1F40, 0x08ad }, // 173, 8 - { 0x1F41, 0x08b0 }, // 176, 8 - { 0x1F42, 0x08af }, // 175, 8 - { 0x1F43, 0x08b2 }, // 178, 8 - { 0x1F44, 0x08ae }, // 174, 8 - { 0x1F45, 0x08b1 }, // 177, 8 - { 0x1F50, 0x08b9 }, // 185, 8 - { 0x1F51, 0x08bd }, // 189, 8 - { 0x1F52, 0x08bb }, // 187, 8 - { 0x1F53, 0x08bf }, // 191, 8 - { 0x1F54, 0x08ba }, // 186, 8 - { 0x1F55, 0x08be }, // 190, 8 - { 0x1F60, 0x08c7 }, // 199, 8 - { 0x1F61, 0x08cf }, // 207, 8 - { 0x1F62, 0x08c9 }, // 201, 8 - { 0x1F63, 0x08d1 }, // 209, 8 - { 0x1F64, 0x08c8 }, // 200, 8 - { 0x1F65, 0x08d0 }, // 208, 8 - { 0x1F70, 0x086d }, // 109, 8 - { 0x1F72, 0x0883 }, // 131, 8 - { 0x1F74, 0x088a }, // 138, 8 - { 0x1F76, 0x08a0 }, // 160, 8 - { 0x1F78, 0x08ac }, // 172, 8 - { 0x1F7A, 0x08b5 }, // 181, 8 - { 0x1F7C, 0x08c1 }, // 193, 8 - { 0x1F80, 0x0877 }, // 119, 8 - { 0x1F81, 0x087f }, // 127, 8 - { 0x1F82, 0x0879 }, // 121, 8 - { 0x1F83, 0x0881 }, // 129, 8 - { 0x1F84, 0x0878 }, // 120, 8 - { 0x1F85, 0x0880 }, // 128, 8 - { 0x1F90, 0x0894 }, // 148, 8 - { 0x1F91, 0x089c }, // 156, 8 - { 0x1F92, 0x0896 }, // 150, 8 - { 0x1F93, 0x089e }, // 158, 8 - { 0x1F94, 0x0895 }, // 149, 8 - { 0x1F95, 0x089d }, // 157, 8 - { 0x1FA0, 0x08cb }, // 203, 8 - { 0x1FA1, 0x08d3 }, // 211, 8 - { 0x1FA2, 0x08cd }, // 205, 8 - { 0x1FA3, 0x08d5 }, // 213, 8 - { 0x1FA4, 0x08cc }, // 204, 8 - { 0x1FA5, 0x08d4 }, // 212, 8 - { 0x1FB2, 0x0871 }, // 113, 8 - { 0x1FB3, 0x086f }, // 111, 8 - { 0x1FB4, 0x0870 }, // 112, 8 - { 0x1FC2, 0x088e }, // 142, 8 - { 0x1FC3, 0x088c }, // 140, 8 - { 0x1FC4, 0x088d }, // 141, 8 - { 0x1FCD, 0x085e }, // 94 , 8 - { 0x1FCE, 0x085c }, // 92 , 8 - { 0x1FDD, 0x085f }, // 95 , 8 - { 0x1FDE, 0x085d }, // 93 , 8 - { 0x1FE4, 0x08B4 }, // 180, 8 - { 0x1FE5, 0x08B3 }, // 179, 8 - { 0x1FF2, 0x08c5 }, // 197, 8 - { 0x1FF3, 0x08c3 }, // 195, 8 - { 0x1FF4, 0x08c4 }, // 196, 8 - { 0x2007, 0x0517 }, // 23 , 5 - { 0x2012, 0x0432 }, // 50 , 4 - { 0x2013, 0x0421 }, // 33 , 4 - { 0x2014, 0x0422 }, // 34 , 4 - { 0x2017, 0x022f }, // 47 , 2 - { 0x2018, 0x041d }, // 29 , 4 - { 0x2019, 0x041c }, // 28 , 4 - { 0x201A, 0x043e }, // 62 , 4 - { 0x201B, 0x041b }, // 27 , 4 - { 0x201C, 0x0420 }, // 32 , 4 - { 0x201D, 0x041f }, // 31 , 4 - { 0x201E, 0x043f }, // 63 , 4 - { 0x201F, 0x041e }, // 30 , 4 - { 0x2020, 0x0427 }, // 39 , 4 - { 0x2021, 0x0428 }, // 40 , 4 - { 0x2022, 0x0403 }, // 3 , 4 - { 0x2026, 0x0438 }, // 56 , 4 - { 0x2030, 0x044b }, // 75 , 4 - { 0x2033, 0x0580 }, // 128, 5 - { 0x2034, 0x0671 }, // 113, 6 - { 0x2036, 0x057f }, // 127, 5 - { 0x2039, 0x0423 }, // 35 , 4 - { 0x203A, 0x0424 }, // 36 , 4 - { 0x203C, 0x050d }, // 13 , 5 - { 0x203E, 0x0626 }, // 38 , 6 - { 0x207F, 0x0415 }, // 21 , 4 - { 0x20A0, 0x043c }, // 60 , 4 - { 0x20A2, 0x043b }, // 59 , 4 - { 0x20A3, 0x043a }, // 58 , 4 - { 0x20A4, 0x043d }, // 61 , 4 - { 0x20A6, 0x0457 }, // 87 , 4 - { 0x20A7, 0x040d }, // 13 , 4 - { 0x20A8, 0x0458 }, // 88 , 4 - { 0x20A9, 0x0456 }, // 86 , 4 - { 0x20AA, 0x097A }, // 122, 9 - { 0x20AC, 0x0466 }, // 102, 4, Euro Sign - GW assigned x448 [4,72] - { 0x20DD, 0x066d }, // 109, 6 - { 0x20E1, 0x06e1 }, // 225, 6 - { 0x2102, 0x06d5 }, // 213, 6 - { 0x2104, 0x0515 }, // 21 , 5 - { 0x2105, 0x0449 }, // 73 , 4 - { 0x2106, 0x044a }, // 74 , 4 - { 0x210C, 0x06e9 }, // 233, 6 - { 0x210F, 0x0632 }, // 50 , 6 - { 0x2111, 0x0633 }, // 51 , 6 - { 0x2112, 0x0669 }, // 105, 6 - { 0x2113, 0x0631 }, // 49 , 6 - { 0x2115, 0x06d7 }, // 215, 6 - { 0x2116, 0x044c }, // 76 , 4 - { 0x2118, 0x0635 }, // 53 , 6 - { 0x211C, 0x0634 }, // 52 , 6 - { 0x211D, 0x06d8 }, // 216, 6 - { 0x211E, 0x042b }, // 43 , 4 - { 0x2120, 0x042a }, // 42 , 4 - { 0x2122, 0x0429 }, // 41 , 4 - { 0x2127, 0x06a7 }, // 167, 6 - { 0x2128, 0x066b }, // 107, 6 - { 0x212B, 0x0623 }, // 35 , 6 - { 0x212D, 0x066a }, // 106, 6 - { 0x212F, 0x0630 }, // 48 , 6 - { 0x2130, 0x06d3 }, // 211, 6 - { 0x2131, 0x06d4 }, // 212, 6 - { 0x2153, 0x0440 }, // 64 , 4 - { 0x2154, 0x0441 }, // 65 , 4 - { 0x215B, 0x0442 }, // 66 , 4 - { 0x215C, 0x0443 }, // 67 , 4 - { 0x215D, 0x0444 }, // 68 , 4 - { 0x215E, 0x0445 }, // 69 , 4 - { 0x2190, 0x0590 }, // 144, 5 - { 0x2191, 0x0617 }, // 23 , 6 - { 0x2192, 0x05d5 }, // 213, 5 - { 0x2193, 0x0618 }, // 24 , 6 - { 0x2194, 0x05d6 }, // 214, 5 - { 0x2195, 0x05d7 }, // 215, 5 - { 0x2196, 0x0640 }, // 64 , 6 - { 0x2197, 0x063e }, // 62 , 6 - { 0x2198, 0x063f }, // 63 , 6 - { 0x2199, 0x0641 }, // 65 , 6 - { 0x219D, 0x0690 }, // 144, 6 - { 0x21A3, 0x0693 }, // 147, 6 - { 0x21A8, 0x050f }, // 15 , 5 - { 0x21A9, 0x0691 }, // 145, 6 - { 0x21AA, 0x0692 }, // 146, 6 - { 0x21B5, 0x0514 }, // 20 , 5 - { 0x21BC, 0x0694 }, // 148, 6 - { 0x21BD, 0x0695 }, // 149, 6 - { 0x21BE, 0x069b }, // 155, 6 - { 0x21BF, 0x069a }, // 154, 6 - { 0x21C0, 0x0696 }, // 150, 6 - { 0x21C1, 0x0697 }, // 151, 6 - { 0x21C2, 0x069d }, // 157, 6 - { 0x21C3, 0x069c }, // 156, 6 - { 0x21C4, 0x0636 }, // 54 , 6 - { 0x21C6, 0x0637 }, // 55 , 6 - { 0x21C7, 0x069f }, // 159, 6 - { 0x21C9, 0x069e }, // 158, 6 - { 0x21CB, 0x0699 }, // 153, 6 - { 0x21CC, 0x0698 }, // 152, 6 - { 0x21D0, 0x0639 }, // 57 , 6 - { 0x21D1, 0x063a }, // 58 , 6 - { 0x21D2, 0x0638 }, // 56 , 6 - { 0x21D3, 0x063b }, // 59 , 6 - { 0x21D4, 0x063c }, // 60 , 6 - { 0x21D5, 0x063d }, // 61 , 6 - { 0x21E6, 0x0597 }, // 151, 5 - { 0x21E8, 0x0596 }, // 150, 5 - { 0x2200, 0x067a }, // 122, 6 - { 0x2202, 0x062c }, // 44 , 6 - { 0x2203, 0x0679 }, // 121, 6 - { 0x2204, 0x06d0 }, // 208, 6 - { 0x2205, 0x0648 }, // 72 , 6 - { 0x2207, 0x062b }, // 43 , 6 - { 0x2208, 0x060f }, // 15 , 6 - { 0x2209, 0x06d1 }, // 209, 6 - { 0x220B, 0x06db }, // 219, 6 - { 0x220D, 0x0647 }, // 71 , 6 - { 0x220F, 0x0629 }, // 41 , 6 - { 0x2210, 0x0672 }, // 114, 6 - { 0x2211, 0x0612 }, // 18 , 6 - { 0x2212, 0x0600 }, // 0 , 6 - { 0x2213, 0x062a }, // 42 , 6 - { 0x2214, 0x06ae }, // 174, 6 - { 0x2215, 0x0606 }, // 6 , 6 - { 0x2216, 0x0607 }, // 7 , 6 - { 0x2218, 0x0621 }, // 33 , 6 - { 0x2219, 0x0622 }, // 34 , 6 - { 0x221A, 0x0704 }, // 4 , 7 - { 0x221D, 0x0604 }, // 4 , 6 - { 0x221E, 0x0613 }, // 19 , 6 - { 0x221F, 0x06da }, // 218, 6 - { 0x2220, 0x064f }, // 79 , 6 - { 0x2221, 0x06a8 }, // 168, 6 - { 0x2222, 0x06a9 }, // 169, 6 - { 0x2223, 0x0609 }, // 9 , 6 - { 0x2224, 0x06ce }, // 206, 6 - { 0x2225, 0x0611 }, // 17 , 6 - { 0x2226, 0x06cd }, // 205, 6 - { 0x2227, 0x0655 }, // 85 , 6 - { 0x2228, 0x0656 }, // 86 , 6 - { 0x2229, 0x0610 }, // 16 , 6 - { 0x222A, 0x0642 }, // 66 , 6 - { 0x222B, 0x0628 }, // 40 , 6 - { 0x222E, 0x0668 }, // 104, 6 - { 0x2234, 0x0666 }, // 102, 6 - { 0x2235, 0x0665 }, // 101, 6 - { 0x2237, 0x0667 }, // 103, 6 - { 0x223C, 0x060c }, // 12 , 6 - { 0x2241, 0x06bd }, // 189, 6 - { 0x2243, 0x0673 }, // 115, 6 - { 0x2244, 0x06be }, // 190, 6 - { 0x2245, 0x0674 }, // 116, 6 - { 0x2247, 0x06bf }, // 191, 6 - { 0x2248, 0x060d }, // 13 , 6 - { 0x2249, 0x06c0 }, // 192, 6 - { 0x224D, 0x06b3 }, // 179, 6 - { 0x224E, 0x06b2 }, // 178, 6 - { 0x2250, 0x06af }, // 175, 6 - { 0x2252, 0x06b0 }, // 176, 6 - { 0x2253, 0x06b1 }, // 177, 6 - { 0x225F, 0x06d9 }, // 217, 6 - { 0x2260, 0x0663 }, // 99 , 6 - { 0x2261, 0x060e }, // 14 , 6 - { 0x2262, 0x0664 }, // 100, 6 - { 0x2264, 0x0602 }, // 2 , 6 - { 0x2265, 0x0603 }, // 3 , 6 - { 0x226A, 0x064d }, // 77 , 6 - { 0x226B, 0x064e }, // 78 , 6 - { 0x226C, 0x06b6 }, // 182, 6 - { 0x226D, 0x06cf }, // 207, 6 - { 0x226E, 0x06b9 }, // 185, 6 - { 0x226F, 0x06bb }, // 187, 6 - { 0x2270, 0x06ba }, // 186, 6 - { 0x2271, 0x06bc }, // 188, 6 - { 0x2272, 0x06eb }, // 235, 6 - { 0x2273, 0x06ec }, // 236, 6 - { 0x227A, 0x0675 }, // 117, 6 - { 0x227B, 0x0677 }, // 119, 6 - { 0x227C, 0x0676 }, // 118, 6 - { 0x227D, 0x0678 }, // 120, 6 - { 0x2280, 0x06c1 }, // 193, 6 - { 0x2281, 0x06c3 }, // 195, 6 - { 0x2282, 0x0643 }, // 67 , 6 - { 0x2283, 0x0644 }, // 68 , 6 - { 0x2284, 0x06c5 }, // 197, 6 - { 0x2285, 0x06c6 }, // 198, 6 - { 0x2286, 0x0645 }, // 69 , 6 - { 0x2287, 0x0646 }, // 70 , 6 - { 0x2288, 0x06c7 }, // 199, 6 - { 0x2289, 0x06c8 }, // 200, 6 - { 0x228A, 0x067e }, // 126, 6 - { 0x228B, 0x067f }, // 127, 6 - { 0x228E, 0x067d }, // 125, 6 - { 0x228F, 0x0682 }, // 130, 6 - { 0x2290, 0x0685 }, // 133, 6 - { 0x2291, 0x0683 }, // 131, 6 - { 0x2292, 0x0686 }, // 134, 6 - { 0x2293, 0x0680 }, // 128, 6 - { 0x2294, 0x0681 }, // 129, 6 - { 0x2295, 0x0651 }, // 81 , 6 - { 0x2296, 0x0652 }, // 82 , 6 - { 0x2297, 0x0650 }, // 80 , 6 - { 0x2299, 0x0654 }, // 84 , 6 - { 0x229A, 0x06a4 }, // 164, 6 - { 0x229B, 0x06a5 }, // 165, 6 - { 0x229D, 0x06a6 }, // 166, 6 - { 0x22A2, 0x065b }, // 91 , 6 - { 0x22A3, 0x065c }, // 92 , 6 - { 0x22A4, 0x0658 }, // 88 , 6 - { 0x22A5, 0x0659 }, // 89 , 6 - { 0x22A8, 0x06b4 }, // 180, 6 - { 0x22BB, 0x0657 }, // 87 , 6 - { 0x22C5, 0x061f }, // 31 , 6 - { 0x22C6, 0x0670 }, // 112, 6 - { 0x22C8, 0x068c }, // 140, 6 - { 0x22D0, 0x06a2 }, // 162, 6 - { 0x22D1, 0x06a3 }, // 163, 6 - { 0x22D2, 0x06a1 }, // 161, 6 - { 0x22D3, 0x06a0 }, // 160, 6 - { 0x22D8, 0x067b }, // 123, 6 - { 0x22D9, 0x067c }, // 124, 6 - { 0x22E0, 0x06c2 }, // 194, 6 - { 0x22E1, 0x06c4 }, // 196, 6 - { 0x22E2, 0x06cb }, // 203, 6 - { 0x22E3, 0x06cc }, // 204, 6 - { 0x22E4, 0x0684 }, // 132, 6 - { 0x22E5, 0x0687 }, // 135, 6 - { 0x22EE, 0x06de }, // 222, 6 - { 0x22EF, 0x06dc }, // 220, 6 - { 0x22F1, 0x06df }, // 223, 6 - { 0x2302, 0x050c }, // 12 , 5 - { 0x2308, 0x0649 }, // 73 , 6 - { 0x2309, 0x064a }, // 74 , 6 - { 0x230A, 0x064b }, // 75 , 6 - { 0x230B, 0x064c }, // 76 , 6 - { 0x2310, 0x0510 }, // 16 , 5 - { 0x2312, 0x065a }, // 90 , 6 - { 0x2319, 0x0511 }, // 17 , 5 - { 0x231A, 0x051f }, // 31 , 5 - { 0x231B, 0x0520 }, // 32 , 5 - { 0x2320, 0x0700 }, // 0 , 7 - { 0x2321, 0x0701 }, // 1 , 7 - { 0x2322, 0x068e }, // 142, 6 - { 0x2323, 0x068d }, // 141, 6 - { 0x2329, 0x060a }, // 10 , 6 - { 0x232A, 0x060b }, // 11 , 6 - { 0x2409, 0x044f }, // 79 , 4 - { 0x240A, 0x0452 }, // 82 , 4 - { 0x240B, 0x0454 }, // 84 , 4 - { 0x240C, 0x0450 }, // 80 , 4 - { 0x240D, 0x0451 }, // 81 , 4 - { 0x2424, 0x0453 }, // 83 , 4 - { 0x24C2, 0x0446 }, // 70 , 4 - { 0x24C5, 0x0447 }, // 71 , 4 - { 0x24CA, 0x0448 }, // 72 , 4, - circled U - { 0x2500, 0x0308 }, // 8 , 3 - { 0x2502, 0x0309 }, // 9 , 3 - { 0x250C, 0x030a }, // 10 , 3 - { 0x2510, 0x030b }, // 11 , 3 - { 0x2514, 0x030d }, // 13 , 3 - { 0x2518, 0x030c }, // 12 , 3 - { 0x251C, 0x030e }, // 14 , 3 - { 0x251E, 0x033e }, // 62 , 3 - { 0x251F, 0x033c }, // 60 , 3 - { 0x2521, 0x033f }, // 63 , 3 - { 0x2522, 0x033d }, // 61 , 3 - { 0x2524, 0x0310 }, // 16 , 3 - { 0x2526, 0x0345 }, // 69 , 3 - { 0x2527, 0x0344 }, // 68 , 3 - { 0x2529, 0x0347 }, // 71 , 3 - { 0x252A, 0x0346 }, // 70 , 3 - { 0x252C, 0x030f }, // 15 , 3 - { 0x252D, 0x0342 }, // 66 , 3 - { 0x252E, 0x0340 }, // 64 , 3 - { 0x2531, 0x0343 }, // 67 , 3 - { 0x2532, 0x0341 }, // 65 , 3 - { 0x2534, 0x0311 }, // 17 , 3 - { 0x2535, 0x034a }, // 74 , 3 - { 0x2536, 0x0348 }, // 72 , 3 - { 0x2539, 0x034b }, // 75 , 3 - { 0x253A, 0x0349 }, // 73 , 3 - { 0x253C, 0x0312 }, // 18 , 3 - { 0x253D, 0x0352 }, // 82 , 3 - { 0x253E, 0x034e }, // 78 , 3 - { 0x2540, 0x034f }, // 79 , 3 - { 0x2541, 0x034c }, // 76 , 3 - { 0x2543, 0x0355 }, // 85 , 3 - { 0x2544, 0x0350 }, // 80 , 3 - { 0x2545, 0x0353 }, // 83 , 3 - { 0x2546, 0x034d }, // 77 , 3 - { 0x2547, 0x0357 }, // 87 , 3 - { 0x2548, 0x0354 }, // 84 , 3 - { 0x2549, 0x0356 }, // 86 , 3 - { 0x254A, 0x0351 }, // 81 , 3 - { 0x2550, 0x0313 }, // 19 , 3 - { 0x2551, 0x0314 }, // 20 , 3 - { 0x2552, 0x031e }, // 30 , 3 - { 0x2553, 0x0322 }, // 34 , 3 - { 0x2554, 0x0315 }, // 21 , 3 - { 0x2555, 0x031f }, // 31 , 3 - { 0x2556, 0x0323 }, // 35 , 3 - { 0x2557, 0x0316 }, // 22 , 3 - { 0x2558, 0x0321 }, // 33 , 3 - { 0x2559, 0x0325 }, // 37 , 3 - { 0x255A, 0x0318 }, // 24 , 3 - { 0x255B, 0x0320 }, // 32 , 3 - { 0x255C, 0x0324 }, // 36 , 3 - { 0x255D, 0x0317 }, // 23 , 3 - { 0x255E, 0x0326 }, // 38 , 3 - { 0x255F, 0x032a }, // 42 , 3 - { 0x2560, 0x0319 }, // 25 , 3 - { 0x2561, 0x0328 }, // 40 , 3 - { 0x2562, 0x032c }, // 44 , 3 - { 0x2563, 0x031b }, // 27 , 3 - { 0x2564, 0x032b }, // 43 , 3 - { 0x2565, 0x0327 }, // 39 , 3 - { 0x2566, 0x031a }, // 26 , 3 - { 0x2567, 0x032d }, // 45 , 3 - { 0x2568, 0x0329 }, // 41 , 3 - { 0x2569, 0x031c }, // 28 , 3 - { 0x256A, 0x032f }, // 47 , 3 - { 0x256B, 0x032e }, // 46 , 3 - { 0x256C, 0x031d }, // 29 , 3 - { 0x2574, 0x0330 }, // 48 , 3 - { 0x2575, 0x0331 }, // 49 , 3 - { 0x2576, 0x0332 }, // 50 , 3 - { 0x2577, 0x0333 }, // 51 , 3 - { 0x2578, 0x0334 }, // 52 , 3 - { 0x2579, 0x0335 }, // 53 , 3 - { 0x257A, 0x0336 }, // 54 , 3 - { 0x257B, 0x0337 }, // 55 , 3 - { 0x257C, 0x0338 }, // 56 , 3 - { 0x257D, 0x033a }, // 58 , 3 - { 0x257E, 0x0339 }, // 57 , 3 - { 0x257F, 0x033b }, // 59 , 3 - { 0x2580, 0x0305 }, // 5 , 3 - { 0x2584, 0x0307 }, // 7 , 3 - { 0x2588, 0x0303 }, // 3 , 3 - { 0x258C, 0x0304 }, // 4 , 3 - { 0x2590, 0x0306 }, // 6 , 3 - { 0x2591, 0x0300 }, // 0 , 3 - { 0x2592, 0x0301 }, // 1 , 3 - { 0x2593, 0x0302 }, // 2 , 3 - { 0x25A0, 0x0402 }, // 2 , 4 - { 0x25A1, 0x0426 }, // 38 , 4 - { 0x25AA, 0x042f }, // 47 , 4 - { 0x25AB, 0x0431 }, // 49 , 4 - { 0x25AC, 0x050b }, // 11 , 5 - { 0x25B2, 0x0573 }, // 115, 5 - { 0x25B3, 0x0688 }, // 136, 6 - { 0x25B4, 0x061d }, // 29 , 6 - { 0x25B5, 0x06ac }, // 172, 6 - { 0x25B8, 0x061b }, // 27 , 6 - { 0x25B9, 0x068b }, // 139, 6 - { 0x25BC, 0x0574 }, // 116, 5 - { 0x25BD, 0x0689 }, // 137, 6 - { 0x25BE, 0x061e }, // 30 , 6 - { 0x25BF, 0x06ad }, // 173, 6 - { 0x25C2, 0x061c }, // 28 , 6 - { 0x25C3, 0x068a }, // 138, 6 - { 0x25C6, 0x0575 }, // 117, 5 - { 0x25C7, 0x066f }, // 111, 6 - { 0x25CA, 0x065f }, // 95 , 6 - { 0x25CB, 0x0401 }, // 1 , 4 - { 0x25CF, 0x0400 }, // 0 , 4 - { 0x25D6, 0x059e }, // 158, 5 - { 0x25D7, 0x0577 }, // 119, 5 - { 0x25D8, 0x0512 }, // 18 , 5 - { 0x25D9, 0x0513 }, // 19 , 5 - { 0x25E6, 0x042d }, // 45 , 4 - { 0x2605, 0x0548 }, // 72, 5 - { 0x260E, 0x051e }, // 30 , 5 - { 0x2610, 0x0518 }, // 24 , 5 - { 0x2612, 0x0519 }, // 25 , 5 - { 0x261B, 0x052a }, // 42 , 5 - { 0x261C, 0x0516 }, // 22 , 5 - { 0x261E, 0x052b }, // 43 , 5 - { 0x2639, 0x051a }, // 26 , 5 - { 0x263A, 0x0507 }, // 7 , 5 - { 0x263B, 0x0508 }, // 8 , 5 - { 0x263C, 0x0506 }, // 6 , 5 - { 0x2640, 0x0505 }, // 5 , 5 - { 0x2642, 0x0504 }, // 4 , 5 - { 0x2660, 0x05ab }, // 171, 5 - { 0x2661, 0x0500 }, // 0 , 5 - { 0x2662, 0x0501 }, // 1 , 5 - { 0x2663, 0x05a8 }, // 168, 5 - { 0x2664, 0x0503 }, // 3 , 5 - { 0x2665, 0x05aa }, // 170, 5 - { 0x2666, 0x05a9 }, // 169, 5 - { 0x2667, 0x0502 }, // 2 , 5 - { 0x266A, 0x0509 }, // 9 , 5 - { 0x266C, 0x050a }, // 10 , 5 - { 0x266D, 0x051c }, // 28 , 5 - { 0x266E, 0x051d }, // 29 , 5 - { 0x266F, 0x051b }, // 27 , 5 - { 0x2701, 0x0521 }, // 33 , 5 - { 0x2702, 0x0522 }, // 34 , 5 - { 0x2703, 0x0523 }, // 35 , 5 - { 0x2704, 0x0524 }, // 36 , 5 - { 0x2706, 0x0526 }, // 38 , 5 - { 0x2707, 0x0527 }, // 39 , 5 - { 0x2708, 0x0528 }, // 40 , 5 - { 0x2709, 0x0529 }, // 41 , 5 - { 0x270C, 0x052c }, // 44 , 5 - { 0x270D, 0x052d }, // 45 , 5 - { 0x270E, 0x052e }, // 46 , 5 - { 0x270F, 0x052f }, // 47 , 5 - { 0x2710, 0x0530 }, // 48 , 5 - { 0x2711, 0x0531 }, // 49 , 5 - { 0x2712, 0x0532 }, // 50 , 5 - { 0x2713, 0x0533 }, // 51 , 5 - { 0x2714, 0x0534 }, // 52 , 5 - { 0x2715, 0x0535 }, // 53 , 5 - { 0x2716, 0x0536 }, // 54 , 5 - { 0x2717, 0x0537 }, // 55 , 5 - { 0x2718, 0x0538 }, // 56 , 5 - { 0x2719, 0x0539 }, // 57 , 5 - { 0x271A, 0x053a }, // 58 , 5 - { 0x271B, 0x053b }, // 59 , 5 - { 0x271C, 0x053c }, // 60 , 5 - { 0x271D, 0x053d }, // 61 , 5 - { 0x271E, 0x053e }, // 62 , 5 - { 0x271F, 0x053f }, // 63 , 5 - { 0x2720, 0x0540 }, // 64 , 5 - { 0x2721, 0x0541 }, // 65 , 5 - { 0x2722, 0x0542 }, // 66 , 5 - { 0x2723, 0x0543 }, // 67 , 5 - { 0x2724, 0x0544 }, // 68 , 5 - { 0x2725, 0x0545 }, // 69 , 5 - { 0x2726, 0x0546 }, // 70 , 5 - { 0x2727, 0x0547 }, // 71 , 5 - { 0x2729, 0x0549 }, // 73 , 5 - { 0x272A, 0x054a }, // 74 , 5 - { 0x272B, 0x054b }, // 75 , 5 - { 0x272C, 0x054c }, // 76 , 5 - { 0x272D, 0x054d }, // 77 , 5 - { 0x272E, 0x054e }, // 78 , 5 - { 0x272F, 0x054f }, // 79 , 5 - { 0x2730, 0x0550 }, // 80 , 5 - { 0x2731, 0x0551 }, // 81 , 5 - { 0x2732, 0x0552 }, // 82 , 5 - { 0x2733, 0x0553 }, // 83 , 5 - { 0x2734, 0x0554 }, // 84 , 5 - { 0x2735, 0x0555 }, // 85 , 5 - { 0x2736, 0x0556 }, // 86 , 5 - { 0x2737, 0x0557 }, // 87 , 5 - { 0x2738, 0x0558 }, // 88 , 5 - { 0x2739, 0x0559 }, // 89 , 5 - { 0x273A, 0x055a }, // 90 , 5 - { 0x273B, 0x055b }, // 91 , 5 - { 0x273C, 0x055c }, // 92 , 5 - { 0x273D, 0x055d }, // 93 , 5 - { 0x273E, 0x055e }, // 94 , 5 - { 0x273F, 0x055f }, // 95 , 5 - { 0x2740, 0x0560 }, // 96 , 5 - { 0x2741, 0x0561 }, // 97 , 5 - { 0x2742, 0x0562 }, // 98 , 5 - { 0x2743, 0x0563 }, // 99 , 5 - { 0x2744, 0x0564 }, // 100, 5 - { 0x2745, 0x0565 }, // 101, 5 - { 0x2746, 0x0566 }, // 102, 5 - { 0x2747, 0x0567 }, // 103, 5 - { 0x2748, 0x0568 }, // 104, 5 - { 0x2749, 0x0569 }, // 105, 5 - { 0x274A, 0x056a }, // 106, 5 - { 0x274B, 0x056b }, // 107, 5 - { 0x274D, 0x056d }, // 109, 5 - { 0x274F, 0x056f }, // 111, 5 - { 0x2750, 0x0570 }, // 112, 5 - { 0x2751, 0x0571 }, // 113, 5 - { 0x2752, 0x0572 }, // 114, 5 - { 0x2756, 0x0576 }, // 118, 5 - { 0x2758, 0x0578 }, // 120, 5 - { 0x2759, 0x0579 }, // 121, 5 - { 0x275A, 0x057a }, // 122, 5 - { 0x275B, 0x057b }, // 123, 5 - { 0x275C, 0x057c }, // 124, 5 - { 0x275D, 0x057d }, // 125, 5 - { 0x275E, 0x057e }, // 126, 5 - { 0x2761, 0x05a1 }, // 161, 5 - { 0x2762, 0x05a2 }, // 162, 5 - { 0x2763, 0x05a3 }, // 163, 5 - { 0x2764, 0x05a4 }, // 164, 5 - { 0x2765, 0x05a5 }, // 165, 5 - { 0x2766, 0x05a6 }, // 166, 5 - { 0x2767, 0x05a7 }, // 167, 5 - { 0x2776, 0x05b6 }, // 182, 5 - { 0x2777, 0x05b7 }, // 183, 5 - { 0x2778, 0x05b8 }, // 184, 5 - { 0x2779, 0x05b9 }, // 185, 5 - { 0x277A, 0x05ba }, // 186, 5 - { 0x277B, 0x05bb }, // 187, 5 - { 0x277C, 0x05bc }, // 188, 5 - { 0x277D, 0x05bd }, // 189, 5 - { 0x277E, 0x05be }, // 190, 5 - { 0x277F, 0x05bf }, // 191, 5 - { 0x2780, 0x05c0 }, // 192, 5 - { 0x2781, 0x05c1 }, // 193, 5 - { 0x2782, 0x05c2 }, // 194, 5 - { 0x2783, 0x05c3 }, // 195, 5 - { 0x2784, 0x05c4 }, // 196, 5 - { 0x2785, 0x05c5 }, // 197, 5 - { 0x2786, 0x05c6 }, // 198, 5 - { 0x2787, 0x05c7 }, // 199, 5 - { 0x2788, 0x05c8 }, // 200, 5 - { 0x2789, 0x05c9 }, // 201, 5 - { 0x278A, 0x05ca }, // 202, 5 - { 0x278B, 0x05cb }, // 203, 5 - { 0x278C, 0x05cc }, // 204, 5 - { 0x278D, 0x05cd }, // 205, 5 - { 0x278E, 0x05ce }, // 206, 5 - { 0x278F, 0x05cf }, // 207, 5 - { 0x2790, 0x05d0 }, // 208, 5 - { 0x2791, 0x05d1 }, // 209, 5 - { 0x2792, 0x05d2 }, // 210, 5 - { 0x2793, 0x05d3 }, // 211, 5 - { 0x2794, 0x05d4 }, // 212, 5 - { 0x2798, 0x05d8 }, // 216, 5 - { 0x2799, 0x05d9 }, // 217, 5 - { 0x279A, 0x05da }, // 218, 5 - { 0x279B, 0x05db }, // 219, 5 - { 0x279C, 0x05dc }, // 220, 5 - { 0x279D, 0x05dd }, // 221, 5 - { 0x279E, 0x05de }, // 222, 5 - { 0x279F, 0x05df }, // 223, 5 - { 0x27A0, 0x05e0 }, // 224, 5 - { 0x27A1, 0x05e1 }, // 225, 5 - { 0x27A2, 0x05e2 }, // 226, 5 - { 0x27A3, 0x05e3 }, // 227, 5 - { 0x27A4, 0x05e4 }, // 228, 5 - { 0x27A5, 0x05e5 }, // 229, 5 - { 0x27A6, 0x05e6 }, // 230, 5 - { 0x27A7, 0x05e7 }, // 231, 5 - { 0x27A8, 0x05e8 }, // 232, 5 - { 0x27A9, 0x05e9 }, // 233, 5 - { 0x27AA, 0x05ea }, // 234, 5 - { 0x27AB, 0x05eb }, // 235, 5 - { 0x27AC, 0x05ec }, // 236, 5 - { 0x27AD, 0x05ed }, // 237, 5 - { 0x27AE, 0x05ee }, // 238, 5 - { 0x27AF, 0x05ef }, // 239, 5 - { 0x27B1, 0x05f1 }, // 241, 5 - { 0x27B2, 0x05f2 }, // 242, 5 - { 0x27B3, 0x05f3 }, // 243, 5 - { 0x27B4, 0x05f4 }, // 244, 5 - { 0x27B5, 0x05f5 }, // 245, 5 - { 0x27B6, 0x05f6 }, // 246, 5 - { 0x27B7, 0x05f7 }, // 247, 5 - { 0x27B8, 0x05f8 }, // 248, 5 - { 0x27B9, 0x05f9 }, // 249, 5 - { 0x27BA, 0x05fa }, // 250, 5 - { 0x27BB, 0x05fb }, // 251, 5 - { 0x27BC, 0x05fc }, // 252, 5 - { 0x27BD, 0x05fd }, // 253, 5 - { 0x27BE, 0x05fe }, // 254, 5 - - // Range 0xE000 through 0xF8FF is reserved for private use. - // We cannot try to interpret characters in this range nor - // assign any default collation or meaning. - - { 0xFB00, 0x0433 }, // 51 , 4 - { 0xFB01, 0x0436 }, // 54 , 4 - { 0xFB02, 0x0437 }, // 55 , 4 - { 0xFB03, 0x0434 }, // 52 , 4 - { 0xFB04, 0x0435 }, // 53 , 4 - { 0xFB1E, 0x0930 }, // 48 , 9 - { 0xFF61, 0x0b00 }, // 0 , 11 - { 0xFF62, 0x0b01 }, // 1 , 11 - { 0xFF63, 0x0b02 }, // 2 , 11 - { 0xFF64, 0x0b03 }, // 3 , 11 - { 0xFF65, 0x0b04 }, // 4 , 11 - { 0xFF66, 0x0b05 }, // 5 , 11 - { 0xFF67, 0x0b06 }, // 6 , 11 - { 0xFF68, 0x0b07 }, // 7 , 11 - { 0xFF69, 0x0b08 }, // 8 , 11 - { 0xFF6A, 0x0b09 }, // 9 , 11 - { 0xFF6B, 0x0b0a }, // 10 , 11 - { 0xFF6C, 0x0b0b }, // 11 , 11 - { 0xFF6D, 0x0b0c }, // 12 , 11 - { 0xFF6E, 0x0b0d }, // 13 , 11 - { 0xFF6F, 0x0b0e }, // 14 , 11 - { 0xFF70, 0x0b0f }, // 15 , 11 - { 0xFF71, 0x0b10 }, // 16 , 11 - { 0xFF72, 0x0b11 }, // 17 , 11 - { 0xFF73, 0x0b12 }, // 18 , 11 - { 0xFF74, 0x0b13 }, // 19 , 11 - { 0xFF75, 0x0b14 }, // 20 , 11 - { 0xFF76, 0x0b15 }, // 21 , 11 - { 0xFF77, 0x0b16 }, // 22 , 11 - { 0xFF78, 0x0b17 }, // 23 , 11 - { 0xFF79, 0x0b18 }, // 24 , 11 - { 0xFF7A, 0x0b19 }, // 25 , 11 - { 0xFF7B, 0x0b1a }, // 26 , 11 - { 0xFF7C, 0x0b1b }, // 27 , 11 - { 0xFF7D, 0x0b1c }, // 28 , 11 - { 0xFF7E, 0x0b1d }, // 29 , 11 - { 0xFF7F, 0x0b1e }, // 30 , 11 - { 0xFF80, 0x0b1f }, // 31 , 11 - { 0xFF81, 0x0b20 }, // 32 , 11 - { 0xFF82, 0x0b21 }, // 33 , 11 - { 0xFF83, 0x0b22 }, // 34 , 11 - { 0xFF84, 0x0b23 }, // 35 , 11 - { 0xFF85, 0x0b24 }, // 36 , 11 - { 0xFF86, 0x0b25 }, // 37 , 11 - { 0xFF87, 0x0b26 }, // 38 , 11 - { 0xFF88, 0x0b27 }, // 39 , 11 - { 0xFF89, 0x0b28 }, // 40 , 11 - { 0xFF8A, 0x0b29 }, // 41 , 11 - { 0xFF8B, 0x0b2a }, // 42 , 11 - { 0xFF8C, 0x0b2b }, // 43 , 11 - { 0xFF8D, 0x0b2c }, // 44 , 11 - { 0xFF8E, 0x0b2d }, // 45 , 11 - { 0xFF8F, 0x0b2e }, // 46 , 11 - { 0xFF90, 0x0b2f }, // 47 , 11 - { 0xFF91, 0x0b30 }, // 48 , 11 - { 0xFF92, 0x0b31 }, // 49 , 11 - { 0xFF93, 0x0b32 }, // 50 , 11 - { 0xFF94, 0x0b33 }, // 51 , 11 - { 0xFF95, 0x0b34 }, // 52 , 11 - { 0xFF96, 0x0b35 }, // 53 , 11 - { 0xFF97, 0x0b36 }, // 54 , 11 - { 0xFF98, 0x0b37 }, // 55 , 11 - { 0xFF99, 0x0b38 }, // 56 , 11 - { 0xFF9A, 0x0b39 }, // 57 , 11 - { 0xFF9B, 0x0b3a }, // 58 , 11 - { 0xFF9C, 0x0b3b }, // 59 , 11 - { 0xFF9D, 0x0b3c }, // 60 , 11 - { 0xFF9E, 0x0b3d }, // 61 , 11 - { 0xFF9F, 0x0b3e } // 62 , 11 -}; - /**************************************************************************** Desc: Encode a string into FLAIM's internal text format (SEN-prefixed, null-terminated UTF8). The string is prefixed with @@ -1620,9 +94,9 @@ RCODE flmUnicode2Storage( // Encode the number of characters as a SEN. If pucEncPtr is // NULL, the caller is only interested in the length of the encoded - // string, so a temporary buffer is used to call flmEncodeSEN. + // string, so a temporary buffer is used to call f_encodeSEN. - uiTmp = flmEncodeSEN( uiStrLen, &pucTmpSen); + uiTmp = f_encodeSEN( uiStrLen, &pucTmpSen); if( pucEncPtr) { @@ -1668,7 +142,7 @@ RCODE flmUnicode2Storage( } else { - if( RC_BAD( rc = flmUni2UTF8( uChar, pucEncPtr, &uiTmp))) + if( RC_BAD( rc = f_uni2UTF8( uChar, pucEncPtr, &uiTmp))) { goto Exit; } @@ -1797,9 +271,9 @@ RCODE flmNative2Storage( // Encode the number of characters as a SEN. If pucEncPtr is // NULL, the caller is only interested in the length of the encoded - // string, so a temporary buffer is used to call flmEncodeSEN. + // string, so a temporary buffer is used to call f_encodeSEN. - uiTmp = flmEncodeSEN( uiStrLen, &pucTmpSen); + uiTmp = f_encodeSEN( uiStrLen, &pucTmpSen); if( pucEncPtr) { if( (uiEncodedLen + uiTmp) >= uiMaxLen) @@ -1849,7 +323,7 @@ RCODE flmNative2Storage( // Convert the native character to ASCII before // mapping it to Unicode. - if( RC_BAD( rc = flmUni2UTF8( (FLMUNICODE)f_toascii( *pszPtr), + if( RC_BAD( rc = f_uni2UTF8( (FLMUNICODE)f_toascii( *pszPtr), pucEncPtr, &uiTmp))) { goto Exit; @@ -1952,7 +426,7 @@ RCODE flmUTF8ToStorage( pucPtr = pucUTF8; for( ;;) { - if( RC_BAD( rc = flmGetCharFromUTF8Buf( &pucPtr, pucEnd, &uChar))) + if( RC_BAD( rc = f_getCharFromUTF8Buf( &pucPtr, pucEnd, &uChar))) { goto Exit; } @@ -1975,9 +449,9 @@ RCODE flmUTF8ToStorage( // Encode the number of characters as a SEN. If pucEncPtr is // NULL, the caller is only interested in the length of the encoded - // string, so a temporary buffer is used to call flmEncodeSEN. + // string, so a temporary buffer is used to call f_encodeSEN. - uiTmp = flmEncodeSEN( uiCharCount, &pucTmpSen); + uiTmp = f_encodeSEN( uiCharCount, &pucTmpSen); if( pucEncPtr) { if( (uiEncodedLen + uiTmp) >= uiMaxLen) @@ -2106,14 +580,14 @@ RCODE flmStorage2Unicode( pucEnd = &pucBuffer[ uiBufLength]; - uiSenLen = flmGetSENLength( *pucBuffer); + uiSenLen = f_getSENLength( *pucBuffer); if( pucBuffer + uiSenLen >= pucEnd) { rc = RC_SET_AND_ASSERT( NE_XFLM_DATA_ERROR); goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucBuffer, pucEnd, &uiNumChars))) + if( RC_BAD( rc = f_decodeSEN( &pucBuffer, pucEnd, &uiNumChars))) { goto Exit; } @@ -2170,7 +644,7 @@ RCODE flmStorage2Unicode( { // Decode the bytes. - if( RC_BAD( rc = flmGetCharFromUTF8Buf( &pucBuffer, pucEnd, &uChar))) + if( RC_BAD( rc = f_getCharFromUTF8Buf( &pucBuffer, pucEnd, &uChar))) { goto Exit; } @@ -2303,7 +777,7 @@ RCODE flmStorage2Unicode( } pucEnd = &pucStorageBuffer[ uiStorageLength]; - uiSenLen = flmGetSENLength( *pucStorageBuffer); + uiSenLen = f_getSENLength( *pucStorageBuffer); if( pucStorageBuffer + uiSenLen >= pucEnd) { @@ -2311,7 +785,7 @@ RCODE flmStorage2Unicode( goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucStorageBuffer, pucEnd, &uiNumChars))) + if( RC_BAD( rc = f_decodeSEN( &pucStorageBuffer, pucEnd, &uiNumChars))) { goto Exit; } @@ -2326,7 +800,7 @@ RCODE flmStorage2Unicode( for( ;;) { - if( RC_BAD( rc = flmGetCharFromUTF8Buf( + if( RC_BAD( rc = f_getCharFromUTF8Buf( &pucStorageBuffer, pucEnd, puzDestBuffer))) { goto Exit; @@ -2408,14 +882,14 @@ RCODE flmStorage2UTF8( pucEnd = &pucBuffer[ uiBufLength]; - uiSenLen = flmGetSENLength( *pucBuffer); + uiSenLen = f_getSENLength( *pucBuffer); if( pucBuffer + uiSenLen >= pucEnd) { rc = RC_SET_AND_ASSERT( NE_XFLM_DATA_ERROR); goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucBuffer, pucEnd, NULL))) + if( RC_BAD( rc = f_decodeSEN( &pucBuffer, pucEnd, NULL))) { goto Exit; } @@ -2463,13 +937,13 @@ RCODE flmGetCharCountFromStorageBuf( goto Exit; } - if( (uiSenLen = flmGetSENLength( (*ppucBuf)[ 0])) >= uiBufSize) + if( (uiSenLen = f_getSENLength( (*ppucBuf)[ 0])) >= uiBufSize) { rc = RC_SET( NE_XFLM_DATA_ERROR); goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( ppucBuf, *ppucBuf + uiSenLen, &uiNumChars))) + if( RC_BAD( rc = f_decodeSEN( ppucBuf, *ppucBuf + uiSenLen, &uiNumChars))) { goto Exit; } @@ -2544,150 +1018,3 @@ Exit: return( rc); } - -/**************************************************************************** -Desc: Called by FlmStartup, this routine initializes the Unicode to - WP and WP to Unicode mapping tables. -****************************************************************************/ -RCODE F_DbSystem::initCharMappingTables( void) -{ - FLMUINT16 * puStaticPtr; - FLMUINT uiLoop; - FLMUINT uiEntries; - FLMUINT uiOffset; - RCODE rc = NE_XFLM_OK; - - if( gv_pUnicodeToWP60 || gv_pWP60ToUnicode) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_FAILURE); - goto Exit; - } - - gv_uiMinUniChar = 0; - gv_uiMaxUniChar = 0; - - gv_uiMinWPChar = 0; - gv_uiMaxWPChar = 0; - - // Make an initial pass over the table to determine - // what our allocation sizes will need to be. - - for( uiLoop = 0, puStaticPtr = (FLMUINT16 *)WP_UTOWP60; - uiLoop < UTOWP60_ENTRIES; - uiLoop++, puStaticPtr += 2) - { - // Unicode - - if( (FLMUINT)puStaticPtr[ 0] < gv_uiMinUniChar || - !gv_uiMinUniChar) - { - flmAssert( puStaticPtr[ 0] != 0); - gv_uiMinUniChar = (FLMUINT)puStaticPtr[ 0]; - } - - if( (FLMUINT)puStaticPtr[ 0] > gv_uiMaxUniChar) - { - gv_uiMaxUniChar = (FLMUINT)puStaticPtr[ 0]; - } - - // WordPerfect - - if( (FLMUINT)puStaticPtr[ 1] < gv_uiMinWPChar || - !gv_uiMinWPChar) - { - flmAssert( puStaticPtr[ 1] != 0); - gv_uiMinWPChar = (FLMUINT)puStaticPtr[ 1]; - } - - if( (FLMUINT)puStaticPtr[ 1] > gv_uiMaxWPChar) - { - gv_uiMaxWPChar = (FLMUINT)puStaticPtr[ 1]; - } - } - - // Allocate the Unicode table - - uiEntries = (gv_uiMaxUniChar - gv_uiMinUniChar) + 1; - if (RC_BAD( rc = f_calloc( uiEntries * sizeof( FLMUINT16), - &gv_pUnicodeToWP60))) - { - goto Exit; - } - - // Populate the Unicode table - - for( uiLoop = 0, puStaticPtr = (FLMUINT16 *)WP_UTOWP60; - uiLoop < UTOWP60_ENTRIES; uiLoop++, puStaticPtr += 2) - { - uiOffset = (FLMUINT)puStaticPtr[ 0] - gv_uiMinUniChar; - - flmAssert( gv_pUnicodeToWP60[ uiOffset] == 0); - gv_pUnicodeToWP60[ uiOffset] = puStaticPtr[ 1]; - } - - // Allocate the WordPerfect table - - uiEntries = (gv_uiMaxWPChar - gv_uiMinWPChar) + 1; - if (RC_BAD( rc = f_calloc( uiEntries * sizeof( FLMUINT16), - &gv_pWP60ToUnicode))) - { - goto Exit; - } - - // Populate the WordPerfect table - - for( uiLoop = 0, puStaticPtr = (FLMUINT16 *)WP_UTOWP60; - uiLoop < UTOWP60_ENTRIES; uiLoop++, puStaticPtr += 2) - { - uiOffset = (FLMUINT)puStaticPtr[ 1] - gv_uiMinWPChar; - - flmAssert( gv_pWP60ToUnicode[ uiOffset] == 0); - gv_pWP60ToUnicode[ uiOffset] = puStaticPtr[ 0]; - } - -Exit: - - if( RC_BAD( rc)) - { - if( gv_pUnicodeToWP60) - { - f_free( &gv_pUnicodeToWP60); - } - - if( gv_pWP60ToUnicode) - { - f_free( &gv_pWP60ToUnicode); - } - - gv_uiMinUniChar = 0; - gv_uiMaxUniChar = 0; - - gv_uiMinWPChar = 0; - gv_uiMaxWPChar = 0; - } - - return( rc); -} - -/**************************************************************************** -Desc: Called by FlmShutdown, this routine frees the Unicode to WP and - WP to Unicode mapping tables. -****************************************************************************/ -void F_DbSystem::freeCharMappingTables( void) -{ - if( gv_pUnicodeToWP60) - { - f_free( &gv_pUnicodeToWP60); - } - - if( gv_pWP60ToUnicode) - { - f_free( &gv_pWP60ToUnicode); - } - - gv_uiMinUniChar = 0; - gv_uiMaxUniChar = 0; - - gv_uiMinWPChar = 0; - gv_uiMaxWPChar = 0; -} diff --git a/xflaim/src/fvector.cpp b/xflaim/src/fvector.cpp index fa5dc37..1097b22 100644 --- a/xflaim/src/fvector.cpp +++ b/xflaim/src/fvector.cpp @@ -66,7 +66,7 @@ Desc: Clear the data vector, but don't free any buffers that have been method is so that we can get efficient re-use of the vector. So, if it has allocated buffers, etc. we don't want to free them. ****************************************************************************/ -void XFLMAPI F_DataVector::reset( void) +void FLMAPI F_DataVector::reset( void) { m_ui64DocumentID = 0; m_uiNumElements = 0; @@ -250,7 +250,7 @@ Exit: /**************************************************************************** Desc: Set the id for a vector element. ****************************************************************************/ -RCODE XFLMAPI F_DataVector::setID( +RCODE FLMAPI F_DataVector::setID( FLMUINT uiElementNumber, FLMUINT64 ui64ID) { @@ -276,7 +276,7 @@ Exit: /**************************************************************************** Desc: Set the name id for a vector element. ****************************************************************************/ -RCODE XFLMAPI F_DataVector::setNameId( +RCODE FLMAPI F_DataVector::setNameId( FLMUINT uiElementNumber, FLMUINT uiNameId, FLMBOOL bIsAttr, @@ -320,7 +320,7 @@ Exit: /**************************************************************************** Desc: Set a FLMINT value for a vector element. ****************************************************************************/ -RCODE XFLMAPI F_DataVector::setINT( +RCODE FLMAPI F_DataVector::setINT( FLMUINT uiElementNumber, FLMINT iNum) { @@ -367,7 +367,7 @@ Exit: /**************************************************************************** Desc: Set a FLMINT64 value for a vector element. ****************************************************************************/ -RCODE XFLMAPI F_DataVector::setINT64( +RCODE FLMAPI F_DataVector::setINT64( FLMUINT uiElementNumber, FLMINT64 i64Num) { @@ -403,7 +403,7 @@ Exit: /**************************************************************************** Desc: Set a FLMUINT value for a vector element. ****************************************************************************/ -RCODE XFLMAPI F_DataVector::setUINT( +RCODE FLMAPI F_DataVector::setUINT( FLMUINT uiElementNumber, FLMUINT uiNum) { @@ -443,7 +443,7 @@ Exit: /**************************************************************************** Desc: Set a FLMUINT64 value for a vector element. ****************************************************************************/ -RCODE XFLMAPI F_DataVector::setUINT64( +RCODE FLMAPI F_DataVector::setUINT64( FLMUINT uiElementNumber, FLMUINT64 ui64Num) { @@ -472,7 +472,7 @@ Exit: /**************************************************************************** Desc: Set a FLMUNICODE value for a vector element. ****************************************************************************/ -RCODE XFLMAPI F_DataVector::setUnicode( +RCODE FLMAPI F_DataVector::setUnicode( FLMUINT uiElementNumber, const FLMUNICODE * puzUnicode) { @@ -544,7 +544,7 @@ Exit: /**************************************************************************** Desc: Set a UTF8 value for a vector element. ****************************************************************************/ -RCODE XFLMAPI F_DataVector::setUTF8( +RCODE FLMAPI F_DataVector::setUTF8( FLMUINT uiElementNumber, const FLMBYTE * pszUTF8, FLMUINT uiBytesInBuffer) @@ -615,7 +615,7 @@ Exit: /**************************************************************************** Desc: Get a pointer to the UTF8 - no conversions are done. ****************************************************************************/ -RCODE XFLMAPI F_DataVector::getUTF8Ptr( +RCODE FLMAPI F_DataVector::getUTF8Ptr( FLMUINT uiElementNumber, const FLMBYTE ** ppszUTF8, FLMUINT * puiBufLen) @@ -674,7 +674,7 @@ Exit: /**************************************************************************** Desc: Allocate data for a unicode element and retrieve it. ****************************************************************************/ -RCODE XFLMAPI F_DataVector::getUnicode( +RCODE FLMAPI F_DataVector::getUnicode( FLMUINT uiElementNumber, FLMUNICODE ** ppuzUnicode) { @@ -719,7 +719,7 @@ Exit: /**************************************************************************** Desc: Compose a key buffer from the vector's components. ****************************************************************************/ -RCODE XFLMAPI F_DataVector::outputKey( +RCODE FLMAPI F_DataVector::outputKey( IF_Db * ifpDb, FLMUINT uiIndexNum, FLMUINT, // uiMatchFlags, //VISIT: Need to remove this from the interface. @@ -780,6 +780,7 @@ RCODE F_DataVector::outputKey( FLMBYTE * pucTmpSen; FLMUINT uiSenLen; FLMUINT uiIDMatchFlags = uiMatchFlags & (XFLM_MATCH_IDS | XFLM_MATCH_DOC_ID); + IF_BufferIStream * pBufferStream = NULL; if (uiIDMatchFlags) { @@ -792,12 +793,12 @@ RCODE F_DataVector::outputKey( if (sizeof( ucIDBuf) - uiIDLen >= 9) { - uiIDLen += flmEncodeSEN( m_ui64DocumentID, &pucToKey); + uiIDLen += f_encodeSEN( m_ui64DocumentID, &pucToKey); } else { pucTmpSen = &ucTmpSen [0]; - uiSenLen = flmEncodeSEN( m_ui64DocumentID, &pucTmpSen); + uiSenLen = f_encodeSEN( m_ui64DocumentID, &pucTmpSen); if (uiSenLen + uiIDLen > sizeof( ucIDBuf)) { rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); @@ -824,12 +825,12 @@ RCODE F_DataVector::outputKey( if (sizeof( ucIDBuf) - uiIDLen >= 9) { - uiIDLen += flmEncodeSEN( ui64Id, &pucToKey); + uiIDLen += f_encodeSEN( ui64Id, &pucToKey); } else { pucTmpSen = &ucTmpSen [0]; - uiSenLen = flmEncodeSEN( ui64Id, &pucTmpSen); + uiSenLen = f_encodeSEN( ui64Id, &pucTmpSen); if (uiSenLen + uiIDLen > sizeof( ucIDBuf)) { rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); @@ -856,12 +857,12 @@ RCODE F_DataVector::outputKey( if (sizeof( ucIDBuf) - uiIDLen >= 9) { - uiIDLen += flmEncodeSEN( ui64Id, &pucToKey); + uiIDLen += f_encodeSEN( ui64Id, &pucToKey); } else { pucTmpSen = &ucTmpSen [0]; - uiSenLen = flmEncodeSEN( ui64Id, &pucTmpSen); + uiSenLen = f_encodeSEN( ui64Id, &pucTmpSen); if (uiSenLen + uiIDLen > sizeof( ucIDBuf)) { rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); @@ -889,12 +890,12 @@ RCODE F_DataVector::outputKey( if (sizeof( ucIDBuf) - uiIDLen >= 9) { - uiIDLen += flmEncodeSEN( ui64Id, &pucToKey); + uiIDLen += f_encodeSEN( ui64Id, &pucToKey); } else { pucTmpSen = &ucTmpSen [0]; - uiSenLen = flmEncodeSEN( ui64Id, &pucTmpSen); + uiSenLen = f_encodeSEN( ui64Id, &pucTmpSen); if (uiSenLen + uiIDLen > sizeof( ucIDBuf)) { rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); @@ -963,7 +964,8 @@ RCODE F_DataVector::outputKey( rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); goto Exit; } - longToByte( (FLMUINT32)uiNum, pucToKey); + + f_UINT32ToByte( (FLMUINT32)uiNum, pucToKey); uiToKeyLen = 4; } else if (pIcd->uiFlags & ICD_METAPHONE) @@ -971,7 +973,6 @@ RCODE F_DataVector::outputKey( FLMUINT uiMeta; FLMBYTE ucStorageBuf[ FLM_MAX_NUM_BUF_SIZE]; FLMUINT uiStorageLen; - F_BufferIStream bufferStream; if (uiDataType != XFLM_TEXT_TYPE) { @@ -986,13 +987,22 @@ RCODE F_DataVector::outputKey( { goto Exit; } + + if( !pBufferStream) + { + if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferStream))) + { + goto Exit; + } + } - if (RC_BAD( rc = bufferStream.open( pucDataPtr, uiDataLen))) + if (RC_BAD( rc = pBufferStream->open( + (const char *)pucDataPtr, uiDataLen))) { goto Exit; } - if (RC_BAD( rc = flmGetNextMetaphone( &bufferStream, &uiMeta))) + if (RC_BAD( rc = f_getNextMetaphone( pBufferStream, &uiMeta))) { if( rc == NE_XFLM_EOF_HIT) { @@ -1001,7 +1011,7 @@ RCODE F_DataVector::outputKey( goto Exit; } - bufferStream.close(); + pBufferStream->close(); } else if (pVector->uiDataType == XFLM_NUMBER_TYPE) { @@ -1025,7 +1035,16 @@ RCODE F_DataVector::outputKey( goto Exit; } - if (RC_BAD( rc = bufferStream.open( ucStorageBuf, uiStorageLen))) + if( !pBufferStream) + { + if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferStream))) + { + goto Exit; + } + } + + if (RC_BAD( rc = pBufferStream->open( + (const char *)ucStorageBuf, uiStorageLen))) { goto Exit; } @@ -1034,19 +1053,19 @@ RCODE F_DataVector::outputKey( uiToKeyLen = uiMaxKeySize - uiKeyLen; if( RC_BAD( rc = KYCollateValue( pucToKey, &uiToKeyLen, - &bufferStream, XFLM_NUMBER_TYPE, + pBufferStream, XFLM_NUMBER_TYPE, pIcd->uiFlags, pIcd->uiCompareRules, pIcd->uiLimit, NULL, NULL, uiLanguage, FALSE, FALSE, &bDataTruncated, NULL))) { goto Exit; } + + pBufferStream->close(); } } else { - F_BufferIStream bufferStream; - if (uiDataType == XFLM_TEXT_TYPE) { if (RC_BAD( rc = getUTF8Ptr( uiKeyComponent, @@ -1060,16 +1079,26 @@ RCODE F_DataVector::outputKey( pucDataPtr = (FLMBYTE *)getDataPtr( pVector); uiDataLen = pVector->uiDataLength; } + if (uiDataLen) { - if (RC_BAD( rc = bufferStream.open( pucDataPtr, uiDataLen))) + if( !pBufferStream) + { + if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferStream))) + { + goto Exit; + } + } + + if (RC_BAD( rc = pBufferStream->open( + (const char *)pucDataPtr, uiDataLen))) { goto Exit; } uiToKeyLen = uiMaxKeySize - uiKeyLen; if( RC_BAD( rc = KYCollateValue( pucToKey, &uiToKeyLen, - &bufferStream, uiDataType, + pBufferStream, uiDataType, pIcd->uiFlags, pIcd->uiCompareRules, pIcd->uiLimit, NULL, NULL, uiLanguage, (FLMBOOL) ((pIcd->uiFlags & ICD_SUBSTRING) @@ -1081,6 +1110,8 @@ RCODE F_DataVector::outputKey( { goto Exit; } + + pBufferStream->close(); } } @@ -1126,13 +1157,19 @@ RCODE F_DataVector::outputKey( Exit: + if( pBufferStream) + { + pBufferStream->Release(); + pBufferStream = NULL; + } + return( rc); } /**************************************************************************** Desc: Populate a vector's components from the key part of an index key. ****************************************************************************/ -RCODE XFLMAPI F_DataVector::inputKey( +RCODE FLMAPI F_DataVector::inputKey( IF_Db * ifpDb, FLMUINT uiIndexNum, const FLMBYTE * pucKey, @@ -1223,7 +1260,7 @@ RCODE F_DataVector::inputKey( rc = RC_SET_AND_ASSERT( NE_XFLM_BTREE_ERROR); goto Exit; } - uiNum = (FLMUINT)byteToLong( pucKey); + uiNum = (FLMUINT)f_byteToUINT32( pucKey); // What is stored in the key better match the dictionary // number of the ICD. @@ -1407,7 +1444,7 @@ RCODE F_DataVector::inputKey( // See if we have a document ID. - if (RC_BAD( rc = flmDecodeSEN64( &pucKey, pucKeyEnd, &m_ui64DocumentID))) + if (RC_BAD( rc = f_decodeSEN64( &pucKey, pucKeyEnd, &m_ui64DocumentID))) { goto Exit; } @@ -1421,7 +1458,7 @@ RCODE F_DataVector::inputKey( // Extract the component node ID - if (RC_BAD( rc = flmDecodeSEN64( &pucKey, pucKeyEnd, &ui64Id))) + if (RC_BAD( rc = f_decodeSEN64( &pucKey, pucKeyEnd, &ui64Id))) { goto Exit; } @@ -1447,7 +1484,7 @@ RCODE F_DataVector::inputKey( // Extract the component node ID - if (RC_BAD( rc = flmDecodeSEN64( &pucKey, pucKeyEnd, &ui64Id))) + if (RC_BAD( rc = f_decodeSEN64( &pucKey, pucKeyEnd, &ui64Id))) { goto Exit; } @@ -1483,7 +1520,7 @@ RCODE F_DataVector::inputKey( // Extract the component node ID - if (RC_BAD( rc = flmDecodeSEN64( &pucKey, pucKeyEnd, &ui64Id))) + if (RC_BAD( rc = f_decodeSEN64( &pucKey, pucKeyEnd, &ui64Id))) { goto Exit; } @@ -1519,7 +1556,7 @@ Exit: /**************************************************************************** Desc: Compose a data buffer from the vector's components. ****************************************************************************/ -RCODE XFLMAPI F_DataVector::outputData( +RCODE FLMAPI F_DataVector::outputData( IF_Db * ifpDb, FLMUINT uiIndexNum, FLMBYTE * pucDataBuf, @@ -1585,7 +1622,7 @@ RCODE F_DataVector::outputData( // Output the length of the data as a SEN value - uiSENLen = flmEncodeSEN( uiDataLength, &pucTmpSen); + uiSENLen = f_encodeSEN( uiDataLength, &pucTmpSen); if (uiTotalLength + uiSENLen > uiDataBufSize) { rc = RC_SET( NE_XFLM_CONV_DEST_OVERFLOW); @@ -1625,7 +1662,7 @@ Exit: /**************************************************************************** Desc: Populate a vector's data components from the data part of a key. ****************************************************************************/ -RCODE XFLMAPI F_DataVector::inputData( +RCODE FLMAPI F_DataVector::inputData( IF_Db * ifpDb, FLMUINT uiIndexNum, const FLMBYTE * pucData, @@ -1672,14 +1709,14 @@ RCODE F_DataVector::inputData( // Get the data length - it is stored as a SEN - uiSENLen = flmGetSENLength( *pucData); + uiSENLen = f_getSENLength( *pucData); if (uiSENLen > uiInputLen) { rc = RC_SET( NE_XFLM_DATA_ERROR); goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucData, + if( RC_BAD( rc = f_decodeSEN( &pucData, &pucData[ uiSENLen], &uiDataLength))) { goto Exit; @@ -1745,7 +1782,7 @@ Exit: /**************************************************************************** Desc: Create and empty data vector and return it's interface... ****************************************************************************/ -RCODE XFLMAPI F_DbSystem::createIFDataVector( +RCODE FLMAPI F_DbSystem::createIFDataVector( IF_DataVector ** ifppDV) { RCODE rc = NE_XFLM_OK; diff --git a/xflaim/src/fwin.cpp b/xflaim/src/fwin.cpp deleted file mode 100644 index 62cb493..0000000 --- a/xflaim/src/fwin.cpp +++ /dev/null @@ -1,1674 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Contains the methods for the F_FileHdl class on Windows platforms. -// -// Tabs: 3 -// -// Copyright (c) 1999-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: fwin.cpp 3115 2006-01-19 13:24:39 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" -#include "ffilehdl.h" - -#if defined( FLM_WIN) - -FSTATIC RCODE _DeleteFile( - char * path); - -/*************************************************************************** -Desc: Maps WIN errors to IO errors. -***************************************************************************/ -RCODE MapWinErrorToFlaim( - DWORD udErrCode, - RCODE defaultRc) -{ - - // Switch on passed in error code value - - switch( udErrCode) - { - case ERROR_NOT_ENOUGH_MEMORY: - case ERROR_OUTOFMEMORY: - return( RC_SET( NE_XFLM_MEM)); - - case ERROR_BAD_NETPATH: - case ERROR_BAD_PATHNAME: - case ERROR_DIRECTORY: - case ERROR_FILE_NOT_FOUND: - case ERROR_INVALID_DRIVE: - case ERROR_INVALID_NAME: - case ERROR_NO_NET_OR_BAD_PATH: - case ERROR_PATH_NOT_FOUND: - return( RC_SET( NE_XFLM_IO_PATH_NOT_FOUND)); - - case ERROR_ACCESS_DENIED: - case ERROR_SHARING_VIOLATION: - case ERROR_FILE_EXISTS: - case ERROR_ALREADY_EXISTS: - return( RC_SET( NE_XFLM_IO_ACCESS_DENIED)); - - case ERROR_BUFFER_OVERFLOW: - case ERROR_FILENAME_EXCED_RANGE: - return( RC_SET( NE_XFLM_IO_PATH_TOO_LONG)); - - case ERROR_DISK_FULL: - case ERROR_HANDLE_DISK_FULL: - return( RC_SET( NE_XFLM_IO_DISK_FULL)); - - case ERROR_CURRENT_DIRECTORY: - case ERROR_DIR_NOT_EMPTY: - return( RC_SET( NE_XFLM_IO_DIRECTORY_ERR)); - - case ERROR_DIRECT_ACCESS_HANDLE: - case ERROR_INVALID_HANDLE: - case ERROR_INVALID_TARGET_HANDLE: - return( RC_SET( NE_XFLM_IO_BAD_FILE_HANDLE)); - - case ERROR_HANDLE_EOF: - return( RC_SET( NE_XFLM_IO_END_OF_FILE)); - - case ERROR_OPEN_FAILED: - return( RC_SET( NE_XFLM_IO_OPEN_ERR)); - - case ERROR_CANNOT_MAKE: - return( RC_SET( NE_XFLM_IO_PATH_CREATE_FAILURE)); - - case ERROR_LOCK_FAILED: - case ERROR_LOCK_VIOLATION: - return( RC_SET( NE_XFLM_IO_FILE_LOCK_ERR)); - - case ERROR_NEGATIVE_SEEK: - case ERROR_SEEK: - case ERROR_SEEK_ON_DEVICE: - return( RC_SET( NE_XFLM_IO_SEEK_ERR)); - - case ERROR_NO_MORE_FILES: - case ERROR_NO_MORE_SEARCH_HANDLES: - return( RC_SET( NE_XFLM_IO_NO_MORE_FILES)); - - case ERROR_TOO_MANY_OPEN_FILES: - return( RC_SET( NE_XFLM_IO_TOO_MANY_OPEN_FILES)); - - case NO_ERROR: - return( NE_XFLM_OK); - - case ERROR_DISK_CORRUPT: - case ERROR_DISK_OPERATION_FAILED: - case ERROR_FILE_CORRUPT: - case ERROR_FILE_INVALID: - case ERROR_NOT_SAME_DEVICE: - case ERROR_IO_DEVICE: - default: - return( RC_SET( defaultRc)); - - } -} - -/**************************************************************************** -Desc: -****************************************************************************/ -F_FileHdl::F_FileHdl() -{ - m_pNext = NULL; - m_pPrev = NULL; - m_bInList = FALSE; - m_uiAvailTime = 0; - m_bFileOpened = FALSE; - m_bDeleteOnRelease = FALSE; - m_bOpenedReadOnly = FALSE; - m_pszFileName = NULL; - - m_FileHandle = INVALID_HANDLE_VALUE; - m_uiBlockSize = 0; - m_uiBytesPerSector = 0; - m_ui64NotOnSectorBoundMask = 0; - m_ui64GetSectorBoundMask = 0; - m_bDoDirectIO = FALSE; - m_uiExtendSize = 0; - m_uiMaxAutoExtendSize = gv_XFlmSysData.uiMaxFileSize; - m_pucAlignedBuff = NULL; - m_uiAlignedBuffSize = 0; - m_ui64CurrentPos = 0; - m_bCanDoAsync = FALSE; // Change to TRUE when we want to do async writes. - m_Overlapped.hEvent = NULL; -} - -/**************************************************************************** -Desc: -****************************************************************************/ -F_FileHdl::~F_FileHdl() -{ - if( m_bFileOpened) - { - (void)Close(); - } - - if (m_pucAlignedBuff) - { - gv_XFlmSysData.pGlobalCacheMgr->decrTotalBytes( m_uiAlignedBuffSize); - - (void)VirtualFree( m_pucAlignedBuff, 0, MEM_RELEASE); - m_pucAlignedBuff = NULL; - m_uiAlignedBuffSize = 0; - } - - if (m_Overlapped.hEvent) - { - CloseHandle( m_Overlapped.hEvent); - } - - if (m_pszFileName) - { - f_free( &m_pszFileName); - } -} - -/*************************************************************************** -Desc: Open or create a file. -***************************************************************************/ -RCODE F_FileHdl::OpenOrCreate( - const char * pszFileName, - FLMUINT uiAccess, - FLMBOOL bCreateFlag) -{ - char szSaveFileName[ F_PATH_MAX_SIZE]; - RCODE rc = NE_XFLM_OK; - DWORD udAccessMode = 0; - DWORD udShareMode = 0; - DWORD udCreateMode = 0; - DWORD udAttrFlags = 0; - DWORD udErrCode; - - m_bDoDirectIO = (uiAccess & XFLM_IO_DIRECT) ? TRUE : FALSE; - - /* Save the file name in case we have to create the directory. */ - - if ((bCreateFlag) && (uiAccess & XFLM_IO_CREATE_DIR)) - { - f_strcpy( szSaveFileName, pszFileName); - } - - // If doing direct IO, need to get the sector size. - - if (m_bDoDirectIO) - { - if (!m_uiBlockSize) - { - m_bDoDirectIO = FALSE; - } - else - { - if (RC_BAD( rc = gv_pFileSystem->GetSectorSize( - pszFileName, &m_uiBytesPerSector))) - { - goto Exit; - } - - m_ui64NotOnSectorBoundMask = m_uiBytesPerSector - 1; - m_ui64GetSectorBoundMask = ~m_ui64NotOnSectorBoundMask; - - // Can't do direct IO if the block size isn't a multiple of - // the sector size. - - if (m_uiBlockSize < m_uiBytesPerSector || - m_uiBlockSize % m_uiBytesPerSector != 0) - { - m_bDoDirectIO = FALSE; - } - } - } - - // Only enable asynchronous writes if direct I/O is enabled. - - if (m_bDoDirectIO) - { - m_bCanDoAsync = gv_XFlmSysData.bOkToDoAsyncWrites; - } - - // Set up the file characteristics requested by caller. - - if (uiAccess & XFLM_IO_SH_DENYRW) - { - udShareMode = 0; - uiAccess &= ~XFLM_IO_SH_DENYRW; - } - else if (uiAccess & XFLM_IO_SH_DENYWR) - { - udShareMode = FILE_SHARE_READ; - uiAccess &= ~XFLM_IO_SH_DENYWR; - } - else if (uiAccess & XFLM_IO_SH_DENYNONE) - { - udShareMode = (FILE_SHARE_READ | FILE_SHARE_WRITE); - uiAccess &= ~XFLM_IO_SH_DENYNONE; - } - else - { - udShareMode = (FILE_SHARE_READ | FILE_SHARE_WRITE); - } - - // Begin setting the CreateFile flags and fields - - udAttrFlags = FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS; - if (m_bDoDirectIO) - { - udAttrFlags |= FILE_FLAG_NO_BUFFERING; - } - - if (m_bCanDoAsync) - { - udAttrFlags |= FILE_FLAG_OVERLAPPED; - } - - if (bCreateFlag) - { - if (uiAccess & XFLM_IO_EXCL) - { - udCreateMode = CREATE_NEW; - } - else - { - udCreateMode = CREATE_ALWAYS; - } - } - else - { - udCreateMode = OPEN_EXISTING; - } - - udAccessMode = GENERIC_READ | GENERIC_WRITE; - - if( (!bCreateFlag) && (uiAccess & XFLM_IO_RDONLY)) - { - udAccessMode = GENERIC_READ; - } - -Retry_Create: - - // Try to create or open the file - - if( (m_FileHandle = CreateFile( (LPCTSTR)pszFileName, udAccessMode, - udShareMode, NULL, udCreateMode, - udAttrFlags, NULL)) == INVALID_HANDLE_VALUE) - { - udErrCode = GetLastError(); - if ((udErrCode == ERROR_PATH_NOT_FOUND) && (uiAccess & XFLM_IO_CREATE_DIR)) - { - char szTemp[ F_PATH_MAX_SIZE]; - char szDirPath[ F_PATH_MAX_SIZE]; - - uiAccess &= ~XFLM_IO_CREATE_DIR; - - // Remove the file name for which we are creating the directory. - - if( RC_OK( gv_pFileSystem->pathReduce( szSaveFileName, szDirPath, szTemp))) - { - if( RC_OK( rc = gv_pFileSystem->CreateDir( szDirPath))) - { - goto Retry_Create; - } - else - { - goto Exit; - } - } - } - - rc = MapWinErrorToFlaim( udErrCode, - (RCODE)(bCreateFlag - ? (RCODE)(m_bDoDirectIO - ? (RCODE)NE_XFLM_DIRECT_CREATING_FILE - : (RCODE)NE_XFLM_CREATING_FILE) - : (RCODE)(m_bDoDirectIO - ? (RCODE)NE_XFLM_DIRECT_OPENING_FILE - : (RCODE)NE_XFLM_OPENING_FILE))); - goto Exit; - } - -Exit: - - if( RC_BAD( rc)) - { - m_FileHandle = INVALID_HANDLE_VALUE; - } - - return( rc); -} - -/**************************************************************************** -Desc: Create a file -****************************************************************************/ -RCODE XFLMAPI F_FileHdl::Create( - const char * pszFileName, - FLMUINT uiIoFlags ) -{ - RCODE rc = NE_XFLM_OK; - - flmAssert( m_bFileOpened == FALSE); - - if( m_bDeleteOnRelease) - { - // This file handle had better not been used for another file - // before. Otherwise, we will get a memory leak. - - flmAssert( m_pszFileName == NULL); - - if( RC_BAD( rc = f_alloc( F_PATH_MAX_SIZE, &m_pszFileName))) - { - goto Exit; - } - - f_strcpy( m_pszFileName, pszFileName); - } - - if( RC_BAD( rc = OpenOrCreate( pszFileName, uiIoFlags, TRUE))) - { - goto Exit; - } - - m_bFileOpened = TRUE; - m_ui64CurrentPos = 0; - m_bOpenedExclusive = (uiIoFlags & XFLM_IO_SH_DENYRW) ? TRUE : FALSE; - -Exit: - - if( RC_BAD( rc) && m_bDeleteOnRelease && m_pszFileName) - { - f_free( &m_pszFileName); - } - - return rc; -} - -/**************************************************************************** -Desc: Create a unique file name in the specified directory -****************************************************************************/ -RCODE XFLMAPI F_FileHdl::CreateUnique( - const char * pszDirName, - const char * pszFileExtension, - FLMUINT uiIoFlags) -{ - RCODE rc = NE_XFLM_OK; - char * pszTmp; - FLMBOOL bModext = TRUE; - FLMUINT uiBaseTime = 0; - FLMBYTE ucHighByte = 0; - char szFileName[ F_FILENAME_SIZE]; - char szDirPath[ F_PATH_MAX_SIZE]; - char szTmpPath[ F_PATH_MAX_SIZE]; - FLMUINT uiCount; - - szFileName[0] = '\0'; - szTmpPath[0] = '\0'; - flmAssert( m_bFileOpened == FALSE); - - if( m_bDeleteOnRelease) - { - - // This file handle had better not been used for another file - // before. Otherwise, we will get a memory leak. - - flmAssert( m_pszFileName == NULL); - - } - f_strcpy( szDirPath, pszDirName); - - /* - Search backwards replacing trailing spaces with NULLs. - */ - - pszTmp = (char *) szDirPath; - pszTmp += (f_strlen( pszTmp) - 1); - while( pszTmp >= (char *) szDirPath && (*pszTmp == 0x20)) - { - *pszTmp = 0; - pszTmp--; - } - - /* Append a backslash if one isn't already there. */ - - if (pszTmp >= (char *) szDirPath && *pszTmp != '\\') - { - pszTmp++; - *pszTmp++ = '\\'; - } - else - { - pszTmp++; - } - *pszTmp = 0; - - if ((pszFileExtension) && (f_strlen( pszFileExtension) >= 3)) - { - bModext = FALSE; - } - - uiCount = 0; - do - { - gv_pFileSystem->pathCreateUniqueName( &uiBaseTime, szFileName, pszFileExtension, - &ucHighByte, bModext); - - //need to strcpy to the buffer b/c it is uninitialized - f_strcpy( szTmpPath, szDirPath); - gv_pFileSystem->pathAppend( szTmpPath, szFileName); - if( m_pszFileName) - { - f_free( &m_pszFileName); - } - - rc = Create( szTmpPath, uiIoFlags | XFLM_IO_EXCL); - if (rc == NE_XFLM_IO_DISK_FULL) - { - (void)_DeleteFile( szTmpPath); - goto Exit; - } - if ((rc == NE_XFLM_IO_PATH_NOT_FOUND) || (rc == NE_XFLM_IO_INVALID_PASSWORD)) - { - goto Exit; - } - } while ((rc != NE_XFLM_OK) && (uiCount++ < 10)); - - /* Check if the path was created. */ - - if ((uiCount >= 10) && (rc != NE_XFLM_OK)) - { - rc = RC_SET( NE_XFLM_IO_PATH_CREATE_FAILURE); - goto Exit; - } - m_bFileOpened = TRUE; - m_bOpenedExclusive = (uiIoFlags & XFLM_IO_SH_DENYRW) ? TRUE : FALSE; - - // Created file name needs to be returned. - f_strcpy( pszDirName, szTmpPath); - -Exit: - - if( RC_BAD( rc) && m_pszFileName) - { - f_free( &m_pszFileName); - } - - return( rc); -} - -/**************************************************************************** -Desc: Open a file -****************************************************************************/ -RCODE XFLMAPI F_FileHdl::Open( - const char * pszFileName, - FLMUINT uiIoFlags) -{ - RCODE rc = NE_XFLM_OK; - - flmAssert( m_bFileOpened == FALSE); - - if( m_bDeleteOnRelease) - { - - // This file handle had better not been used for another file - // before. Otherwise, we will get a memory leak. - - flmAssert( m_pszFileName == NULL); - - if( RC_BAD( rc = f_alloc( F_PATH_MAX_SIZE, &m_pszFileName))) - { - goto Exit; - } - - f_strcpy( m_pszFileName, pszFileName); - } - - // Loop on error open conditions. - - for(;;) - { - if( RC_OK( rc = OpenOrCreate( pszFileName, uiIoFlags, FALSE))) - { - break; - } - - if( rc != NE_XFLM_IO_TOO_MANY_OPEN_FILES ) - { - goto Exit; - } - - // If for some reason we cannot open the file, then - // try to close some other file handle in the list. - - gv_XFlmSysData.pFileHdlMgr->releaseOneAvail( FALSE); - } - - m_bFileOpened = TRUE; - m_ui64CurrentPos = 0; - m_bOpenedReadOnly = (uiIoFlags & XFLM_IO_RDONLY) ? TRUE : FALSE; - m_bOpenedExclusive = (uiIoFlags & XFLM_IO_SH_DENYRW) ? TRUE : FALSE; - -Exit: - - if( RC_BAD( rc) && m_bDeleteOnRelease && m_pszFileName) - { - f_free( &m_pszFileName); - } - - return rc; -} - -/**************************************************************************** -Desc: Close a file -****************************************************************************/ -RCODE XFLMAPI F_FileHdl::Close( void) -{ - FLMBOOL bDeleteAllowed = TRUE; - RCODE rc = NE_XFLM_OK; - - if( !m_bFileOpened) - { - goto Exit; - } - - if (!CloseHandle( m_FileHandle)) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_CLOSING_FILE); - goto Exit; - } - - m_FileHandle = INVALID_HANDLE_VALUE; - m_bFileOpened = m_bOpenedReadOnly = m_bOpenedExclusive = FALSE; - - if (m_bDeleteOnRelease ) - { - flmAssert( NULL != m_pszFileName ); - - if( bDeleteAllowed) - { - (void)_DeleteFile( m_pszFileName); - } - m_bDeleteOnRelease = FALSE; - f_free( &m_pszFileName); - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Flush IO to disk -****************************************************************************/ -RCODE XFLMAPI F_FileHdl::Flush( void) -{ - RCODE rc = NE_XFLM_OK; - - if( !m_bDoDirectIO) - { - if( !FlushFileBuffers( m_FileHandle)) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_FLUSHING_FILE); - } - } - return( rc); -} - -/**************************************************************************** -Desc: Allocate an aligned buffer. -****************************************************************************/ -RCODE F_FileHdl::AllocAlignBuffer( void) -{ - RCODE rc = NE_XFLM_OK; - - // Allocate at least 64K - this will handle most read and write - // operations and will also be a multiple of the sector size most of - // the time. The calculation below rounds it up to the next sector - // boundary if it is not already on one. - - m_uiAlignedBuffSize = RoundToNextSector( 64 * 1024); - if ((m_pucAlignedBuff = (FLMBYTE *)VirtualAlloc( NULL, - (DWORD)m_uiAlignedBuffSize, - MEM_COMMIT, PAGE_READWRITE)) == NULL) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_MEM); - goto Exit; - } - - gv_XFlmSysData.pGlobalCacheMgr->incrTotalBytes( m_uiAlignedBuffSize); - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Position and do a single read operation. -****************************************************************************/ -RCODE F_FileHdl::DoOneRead( - FLMUINT64 ui64ReadOffset, - FLMUINT uiBytesToRead, - void * pvReadBuffer, - FLMUINT * puiBytesRead) -{ - RCODE rc = NE_XFLM_OK; - OVERLAPPED * pOverlapped; - LARGE_INTEGER liTmp; - - // Position the file to the specified offset. - - if (!m_bCanDoAsync) - { - liTmp.QuadPart = ui64ReadOffset; - if( !SetFilePointerEx( m_FileHandle, liTmp, NULL, FILE_BEGIN)) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_POSITIONING_IN_FILE); - goto Exit; - } - - pOverlapped = NULL; - } - else - { - if (!m_Overlapped.hEvent) - { - if ((m_Overlapped.hEvent = CreateEvent( NULL, TRUE, - FALSE, NULL)) == NULL) - { - rc = MapWinErrorToFlaim( GetLastError(), - NE_XFLM_SETTING_UP_FOR_READ); - goto Exit; - } - } - - pOverlapped = &m_Overlapped; - pOverlapped->Offset = (DWORD)(ui64ReadOffset & 0xFFFFFFFF); - pOverlapped->OffsetHigh = (DWORD)(ui64ReadOffset >> 32); - - if( !ResetEvent( pOverlapped->hEvent)) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_SETTING_UP_FOR_READ); - goto Exit; - } - } - - // Do the read - - if( !ReadFile( m_FileHandle, pvReadBuffer, uiBytesToRead, - puiBytesRead, pOverlapped)) - { - DWORD udErr = GetLastError(); - - if( udErr == ERROR_IO_PENDING && m_bCanDoAsync) - { - if( !GetOverlappedResult( m_FileHandle, - pOverlapped, puiBytesRead, TRUE)) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_READING_FILE); - goto Exit; - } - } - else - { - rc = MapWinErrorToFlaim( udErr, NE_XFLM_READING_FILE); - goto Exit; - } - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Read from a file - reads using aligned buffers and offsets - only - sector boundaries -****************************************************************************/ -RCODE F_FileHdl::DirectRead( - FLMUINT64 ui64ReadOffset, - FLMUINT uiBytesToRead, - void * pvBuffer, - FLMBOOL bBuffHasFullSectors, - FLMUINT * puiBytesReadRV) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiBytesRead; - FLMBYTE * pucReadBuffer; - FLMBYTE * pucDestBuffer; - FLMUINT uiMaxBytesToRead; - FLMBOOL bHitEOF; - - flmAssert( m_bFileOpened); - - if( puiBytesReadRV) - { - *puiBytesReadRV = 0; - } - - if( ui64ReadOffset == XFLM_IO_CURRENT_POS) - { - ui64ReadOffset = m_ui64CurrentPos; - } - - // This loop does multiple reads (if necessary) to get all of the - // data. It uses aligned buffers and reads at sector offsets. - - pucDestBuffer = (FLMBYTE *)pvBuffer; - for (;;) - { - - // See if we are using an aligned buffer. If not, allocate - // one (if not already allocated), and use it. - - if ((ui64ReadOffset & m_ui64NotOnSectorBoundMask) || - (((FLMUINT64)pucDestBuffer) & m_ui64NotOnSectorBoundMask) || - (((FLMUINT64)uiBytesToRead & m_ui64NotOnSectorBoundMask) && - (!bBuffHasFullSectors))) - { - if (!m_pucAlignedBuff) - { - if (RC_BAD( rc = AllocAlignBuffer())) - { - goto Exit; - } - } - pucReadBuffer = m_pucAlignedBuff; - - // Must read enough bytes to cover all of the sectors that - // contain the data we are trying to read. The value of - // (ui64ReadOffset & m_ui64NotOnSectorBoundMask) will give us the - // number of additional bytes that are in the sector prior to - // the read offset. We then round that up to the next sector - // to get the total number of bytes we are going to read. - - uiMaxBytesToRead = RoundToNextSector( uiBytesToRead + - (ui64ReadOffset & m_ui64NotOnSectorBoundMask)); - - // Can't read more than the aligned buffer will hold. - - if (uiMaxBytesToRead > m_uiAlignedBuffSize) - { - uiMaxBytesToRead = m_uiAlignedBuffSize; - } - } - else - { - uiMaxBytesToRead = RoundToNextSector( uiBytesToRead); - flmAssert( uiMaxBytesToRead >= uiBytesToRead); - pucReadBuffer = pucDestBuffer; - } - - bHitEOF = FALSE; - if (RC_BAD( rc = DoOneRead( TruncateToPrevSector( ui64ReadOffset), - uiMaxBytesToRead, pucReadBuffer, &uiBytesRead))) - { - goto Exit; - } - - if( uiBytesRead < uiMaxBytesToRead) - { - bHitEOF = TRUE; - } - - // If the offset we want to read from is not on a sector - // boundary, increment the read buffer pointer to the - // offset where the data we need starts and decrement the - // bytes read by the difference between the start of the - // sector and the actual read offset. - - if (ui64ReadOffset & m_ui64NotOnSectorBoundMask) - { - pucReadBuffer += (ui64ReadOffset & m_ui64NotOnSectorBoundMask); - flmAssert( uiBytesRead >= m_uiBytesPerSector); - uiBytesRead -= (ui64ReadOffset & m_ui64NotOnSectorBoundMask); - } - - // If bytes read is more than we actually need, truncate it back - // so that we only copy what we actually need. - - if( uiBytesRead > uiBytesToRead) - { - uiBytesRead = uiBytesToRead; - } - - uiBytesToRead -= uiBytesRead; - - if( puiBytesReadRV) - { - (*puiBytesReadRV) += uiBytesRead; - } - - m_ui64CurrentPos = ui64ReadOffset + uiBytesRead; - - // If using a different buffer for reading, copy the - // data read into the destination buffer. - - if (pucDestBuffer != pucReadBuffer) - { - f_memcpy( pucDestBuffer, pucReadBuffer, uiBytesRead); - } - - if (!uiBytesToRead) - { - break; - } - - // Still more to read - did we hit EOF above? - - if (bHitEOF) - { - rc = RC_SET( NE_XFLM_IO_END_OF_FILE); - break; - } - - pucDestBuffer += uiBytesRead; - ui64ReadOffset += uiBytesRead; - } - -Exit: - return( rc ); -} - -/**************************************************************************** -Desc: Read from a file -****************************************************************************/ -RCODE XFLMAPI F_FileHdl::Read( - FLMUINT64 ui64ReadOffset, - FLMUINT uiBytesToRead, - void * pvBuffer, - FLMUINT * puiBytesReadRV) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiBytesRead; - - // Do the direct IO call if enabled. - - if (m_bDoDirectIO) - { - rc = DirectRead( ui64ReadOffset, uiBytesToRead, - pvBuffer, FALSE, puiBytesReadRV); - goto Exit; - } - - // If not doing direct IO, a single read call will do. - - flmAssert( m_bFileOpened); - if( puiBytesReadRV) - { - *puiBytesReadRV = 0; - } - - if( ui64ReadOffset == XFLM_IO_CURRENT_POS) - { - ui64ReadOffset = m_ui64CurrentPos; - } - - if( RC_BAD( rc = DoOneRead( ui64ReadOffset, uiBytesToRead, - pvBuffer, &uiBytesRead))) - { - goto Exit; - } - - if( puiBytesReadRV) - { - *puiBytesReadRV = uiBytesRead; - } - - m_ui64CurrentPos = ui64ReadOffset + uiBytesRead; - - if (uiBytesRead < uiBytesToRead) - { - rc = RC_SET( NE_XFLM_IO_END_OF_FILE); - goto Exit; - } - -Exit: - return( rc ); -} - -/**************************************************************************** -Desc: Sets current position of file. -****************************************************************************/ -RCODE XFLMAPI F_FileHdl::Seek( - FLMUINT64 ui64Offset, - FLMINT iWhence, - FLMUINT64 * pui64NewOffset) -{ - RCODE rc = NE_XFLM_OK; - - switch (iWhence) - { - case XFLM_IO_SEEK_CUR: - m_ui64CurrentPos += ui64Offset; - break; - case XFLM_IO_SEEK_SET: - m_ui64CurrentPos = ui64Offset; - break; - case XFLM_IO_SEEK_END: - if( RC_BAD( rc = Size( &m_ui64CurrentPos ))) - { - goto Exit; - } - break; - default: - rc = RC_SET_AND_ASSERT( NE_XFLM_NOT_IMPLEMENTED); - goto Exit; - } - - if( pui64NewOffset) - { - *pui64NewOffset = m_ui64CurrentPos; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Return the size of the file -****************************************************************************/ -RCODE XFLMAPI F_FileHdl::Size( - FLMUINT64 * pui64Size) -{ - RCODE rc = NE_XFLM_OK; - LARGE_INTEGER liTmp; - - if( !GetFileSizeEx( m_FileHandle, &liTmp)) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_GETTING_FILE_SIZE); - goto Exit; - } - - *pui64Size = liTmp.QuadPart; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE XFLMAPI F_FileHdl::Tell( - FLMUINT64 * pui64Offset) -{ - *pui64Offset = m_ui64CurrentPos; - return( NE_XFLM_OK); -} - -/**************************************************************************** -Desc: Truncate the file to the indicated size -WARNING: Direct IO methods are calling this method. Make sure that all changes - to this method work in direct IO mode. -****************************************************************************/ -RCODE XFLMAPI F_FileHdl::Truncate( - FLMUINT64 ui64Size) -{ - RCODE rc = NE_XFLM_OK; - LARGE_INTEGER liTmp; - - flmAssert( m_bFileOpened); - - // Position the file to the nearest sector below the read offset. - - liTmp.QuadPart = ui64Size; - if( !SetFilePointerEx( m_FileHandle, liTmp, NULL, FILE_BEGIN)) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_POSITIONING_IN_FILE); - goto Exit; - } - - // Set the new file size. - - if( !SetEndOfFile( m_FileHandle)) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_TRUNCATING_FILE); - goto Exit; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Handles when a file is extended in direct IO mode. May extend the - file some more. Will always call FlushFileBuffers to ensure that - the new file size gets written out. -****************************************************************************/ -RCODE F_FileHdl::extendFile( - FLMUINT64 ui64EndOfLastWrite, // Must be on a sector boundary - FLMUINT uiMaxBytesToExtend, - FLMBOOL bFlush) -{ - RCODE rc = NE_XFLM_OK; - OVERLAPPED * pOverlapped; - FLMUINT uiTotalBytesToExtend; - FLMUINT uiBytesToWrite; - FLMUINT uiBytesWritten; - LARGE_INTEGER liTmp; - - if ((uiTotalBytesToExtend = uiMaxBytesToExtend) != 0) - { - if (ui64EndOfLastWrite > m_uiMaxAutoExtendSize) - { - uiTotalBytesToExtend = 0; - } - else - { - // Don't extend beyond maximum file size. - - if (m_uiMaxAutoExtendSize - ui64EndOfLastWrite < uiTotalBytesToExtend) - { - uiTotalBytesToExtend = m_uiMaxAutoExtendSize - ui64EndOfLastWrite; - } - - // If the extend size is not on a sector boundary, round it down. - - uiTotalBytesToExtend = TruncateToPrevSector( uiTotalBytesToExtend); - } - } - - if (uiTotalBytesToExtend) - { - // Allocate an aligned buffer if we haven't already. - - if (!m_pucAlignedBuff) - { - if (RC_BAD( rc = AllocAlignBuffer())) - { - goto Exit; - } - } - - f_memset( m_pucAlignedBuff, 0, m_uiAlignedBuffSize); - } - - // Extend the file until we run out of bytes to write. - - while (uiTotalBytesToExtend) - { - if ((uiBytesToWrite = m_uiAlignedBuffSize) > uiTotalBytesToExtend) - { - uiBytesToWrite = uiTotalBytesToExtend; - } - - if (!m_bCanDoAsync) - { - liTmp.QuadPart = ui64EndOfLastWrite; - if( !SetFilePointerEx( m_FileHandle, liTmp, NULL, FILE_BEGIN)) - { - rc = MapWinErrorToFlaim( GetLastError(), - NE_XFLM_POSITIONING_IN_FILE); - goto Exit; - } - - pOverlapped = NULL; - } - else - { - pOverlapped = &m_Overlapped; - if (!pOverlapped->hEvent) - { - if ((pOverlapped->hEvent = CreateEvent( NULL, TRUE, - FALSE, NULL)) == NULL) - { - rc = MapWinErrorToFlaim( GetLastError(), - NE_XFLM_SETTING_UP_FOR_WRITE); - goto Exit; - } - } - - pOverlapped->Offset = (DWORD)(ui64EndOfLastWrite & 0xFFFFFFFF); - pOverlapped->OffsetHigh = (DWORD)(ui64EndOfLastWrite >> 32); - - if (!ResetEvent( pOverlapped->hEvent)) - { - rc = MapWinErrorToFlaim( GetLastError(), - NE_XFLM_SETTING_UP_FOR_WRITE); - goto Exit; - } - } - - // Do the write - - if( !WriteFile( m_FileHandle, m_pucAlignedBuff, - uiBytesToWrite, &uiBytesWritten, pOverlapped)) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_WRITING_FILE); - - // Don't care if it is a disk full error, because - // extending the file is optional work. - - if( rc == NE_XFLM_IO_DISK_FULL) - { - rc = NE_XFLM_OK; - break; - } - - goto Exit; - } - - // NO more room on disk, but that's OK because we were only - // extending the file beyond where it needed to be. If that - // fails, we will just flush what we have done so far. - - if( uiBytesWritten < uiBytesToWrite) - { - break; - } - - uiTotalBytesToExtend -= uiBytesToWrite; - ui64EndOfLastWrite += uiBytesToWrite; - } - - // Flush the file buffers to ensure that the file size gets written - // out. - - if( bFlush) - { - if( !FlushFileBuffers( m_FileHandle)) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_FLUSHING_FILE); - goto Exit; - } - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Write to a file using direct IO -****************************************************************************/ -RCODE F_FileHdl::DirectWrite( - FLMUINT64 ui64WriteOffset, - FLMUINT uiBytesToWrite, - const void * pvBuffer, - F_IOBuffer * pBufferObj, - FLMBOOL bBuffHasFullSectors, - FLMBOOL bZeroFill, - FLMUINT * puiBytesWrittenRV) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiBytesRead; - FLMUINT uiBytesWritten; - FLMBYTE * pucWriteBuffer; - FLMBYTE * pucSrcBuffer; - FLMUINT uiMaxBytesToWrite; - FLMUINT64 ui64CurrFileSize; - FLMUINT uiBytesBeingOutput; - OVERLAPPED * pOverlapped; - DWORD udErr; - FLMBOOL bExtendFile = FALSE; - FLMBOOL bDoAsync = (pBufferObj != NULL) - ? TRUE - : FALSE; - FLMBOOL bDidAsync = FALSE; - FLMUINT64 ui64LastWriteOffset; - FLMUINT uiLastWriteSize; - LARGE_INTEGER liTmp; - - flmAssert( m_bFileOpened); - -#ifdef FLM_DEBUG - if (bDoAsync) - { - flmAssert( m_bCanDoAsync); - } -#endif - - if( puiBytesWrittenRV) - { - *puiBytesWrittenRV = 0; - } - - if( ui64WriteOffset == XFLM_IO_CURRENT_POS) - { - ui64WriteOffset = m_ui64CurrentPos; - } - - // Determine if the write will extend the file beyond its - // current size. If so, we will need to call FlushFileBuffers - - if( !GetFileSizeEx( m_FileHandle, &liTmp)) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_GETTING_FILE_SIZE); - goto Exit; - } - - ui64CurrFileSize = liTmp.QuadPart; - - if( ui64WriteOffset + uiBytesToWrite > ui64CurrFileSize && - m_uiExtendSize != (FLMUINT)(~0)) - { - bExtendFile = TRUE; - - if( ui64WriteOffset > ui64CurrFileSize) - { - - // Fill in the empty space. - - if (RC_BAD( rc = extendFile( ui64CurrFileSize, - RoundToNextSector( ui64WriteOffset - ui64CurrFileSize), FALSE))) - { - goto Exit; - } - } - - // Can't do asynchronous if we are going to extend the file. - - bDoAsync = FALSE; - } - - // This loop is for direct IO - must make sure we use - // aligned buffers. - - pucSrcBuffer = (FLMBYTE *)pvBuffer; - for (;;) - { - - // See if we are using an aligned buffer. If not, allocate - // one (if not already allocated), and use it. - - if ((ui64WriteOffset & m_ui64NotOnSectorBoundMask) || - (((FLMUINT)pucSrcBuffer) & m_ui64NotOnSectorBoundMask) || - ((uiBytesToWrite & m_ui64NotOnSectorBoundMask) && - (!bBuffHasFullSectors))) - { - - // Cannot be using a temporary write buffer if we are doing - // asynchronous writes! - - flmAssert( !bDoAsync || !m_bCanDoAsync); - if (!m_pucAlignedBuff) - { - if (RC_BAD( rc = AllocAlignBuffer())) - { - goto Exit; - } - } - pucWriteBuffer = m_pucAlignedBuff; - - // Must write enough bytes to cover all of the sectors that - // contain the data we are trying to write out. The value of - // (ui64WriteOffset & m_ui64NotOnSectorBoundMask) will give us the - // number of additional bytes that are in the sector prior to - // the read offset. We then round to the next sector to get the - // total number of bytes we are going to write. - - uiMaxBytesToWrite = RoundToNextSector( uiBytesToWrite + - (ui64WriteOffset & m_ui64NotOnSectorBoundMask)); - - // Can't write more than the aligned buffer will hold. - - if (uiMaxBytesToWrite > m_uiAlignedBuffSize) - { - uiMaxBytesToWrite = m_uiAlignedBuffSize; - uiBytesBeingOutput = uiMaxBytesToWrite - - (ui64WriteOffset & m_ui64NotOnSectorBoundMask); - } - else - { - uiBytesBeingOutput = uiBytesToWrite; - } - - // If the write offset is not on a sector boundary, we must - // read at least the first sector into the buffer. - - if (ui64WriteOffset & m_ui64NotOnSectorBoundMask) - { - - // Read the first sector that is to be written out. - // Read one sector's worth of data - so that we will - // preserve what is already in the sector before - // writing it back out again. - - if (RC_BAD( rc = DoOneRead( TruncateToPrevSector( ui64WriteOffset), - m_uiBytesPerSector, pucWriteBuffer, &uiBytesRead))) - { - goto Exit; - } - } - - // If we are writing more than one sector, and the last sector's - // worth of data we are writing out is only a partial sector, - // we must read in this sector as well. - - if ((uiMaxBytesToWrite > m_uiBytesPerSector) && - (uiMaxBytesToWrite > uiBytesToWrite) && - (!bBuffHasFullSectors)) - { - - // Read the last sector that is to be written out. - // Read one sector's worth of data - so that we will - // preserve what is already in the sector before - // writing it back out again. - - if (RC_BAD( rc = DoOneRead( - (TruncateToPrevSector( ui64WriteOffset)) + - (uiMaxBytesToWrite - m_uiBytesPerSector), - m_uiBytesPerSector, - (&pucWriteBuffer [uiMaxBytesToWrite - m_uiBytesPerSector]), - &uiBytesRead))) - { - if (rc == NE_XFLM_IO_END_OF_FILE) - { - rc = NE_XFLM_OK; - f_memset( &pucWriteBuffer [uiMaxBytesToWrite - m_uiBytesPerSector], - 0, m_uiBytesPerSector); - } - else - { - goto Exit; - } - } - } - - // Finally, copy the data from the source buffer into the - // write buffer. - - f_memcpy( &pucWriteBuffer[ ui64WriteOffset & m_ui64NotOnSectorBoundMask], - pucSrcBuffer, uiBytesBeingOutput); - } - else - { - uiMaxBytesToWrite = RoundToNextSector( uiBytesToWrite); - uiBytesBeingOutput = uiBytesToWrite; - pucWriteBuffer = pucSrcBuffer; - if( bZeroFill && uiMaxBytesToWrite > uiBytesToWrite) - { - f_memset( &pucWriteBuffer [uiBytesToWrite], 0, - uiMaxBytesToWrite - uiBytesToWrite); - } - } - - // Position the file to the nearest sector below the write offset. - - ui64LastWriteOffset = TruncateToPrevSector( ui64WriteOffset); - if (!m_bCanDoAsync) - { - liTmp.QuadPart = ui64LastWriteOffset; - if( !SetFilePointerEx( m_FileHandle, liTmp, NULL, FILE_BEGIN)) - { - rc = MapWinErrorToFlaim( GetLastError(), - NE_XFLM_POSITIONING_IN_FILE); - goto Exit; - } - - pOverlapped = NULL; - } - else - { - if (!pBufferObj) - { - pOverlapped = &m_Overlapped; - } - else - { - pOverlapped = pBufferObj->getOverlapped(); - pBufferObj->setFileHandle( m_FileHandle); - } - - if (!pOverlapped->hEvent) - { - if ((pOverlapped->hEvent = CreateEvent( NULL, TRUE, - FALSE, NULL)) == NULL) - { - rc = MapWinErrorToFlaim( GetLastError(), - NE_XFLM_SETTING_UP_FOR_WRITE); - goto Exit; - } - } - - pOverlapped->Offset = (DWORD)(ui64LastWriteOffset & 0xFFFFFFFF); - pOverlapped->OffsetHigh = (DWORD)(ui64LastWriteOffset >> 32); - - if (!ResetEvent( pOverlapped->hEvent)) - { - rc = MapWinErrorToFlaim( GetLastError(), - NE_XFLM_SETTING_UP_FOR_WRITE); - goto Exit; - } - } - - // Do the write - - uiLastWriteSize = uiMaxBytesToWrite; - if( !WriteFile( m_FileHandle, (LPVOID)pucWriteBuffer, - (DWORD)uiMaxBytesToWrite, &uiBytesWritten, - pOverlapped)) - { - udErr = GetLastError(); - if (udErr == ERROR_IO_PENDING && m_bCanDoAsync) - { - - // If an async structure was passed in, we better have - // been able to finish in a single write operation. - // Otherwise, we are in deep trouble because we are not - // set up to do multiple async write operations within - // a single call. - - if( bDoAsync) - { - pBufferObj->makePending(); - bDidAsync = TRUE; - break; - } - - if (!GetOverlappedResult( m_FileHandle, pOverlapped, - &uiBytesWritten, TRUE)) - { - rc = MapWinErrorToFlaim( GetLastError(), - NE_XFLM_WRITING_FILE); - goto Exit; - } - } - else - { - rc = MapWinErrorToFlaim( udErr, NE_XFLM_WRITING_FILE); - goto Exit; - } - } - - if (uiBytesWritten < uiMaxBytesToWrite) - { - rc = RC_SET( NE_XFLM_IO_DISK_FULL); - goto Exit; - } - - uiBytesToWrite -= uiBytesBeingOutput; - - if( puiBytesWrittenRV) - { - (*puiBytesWrittenRV) += uiBytesBeingOutput; - } - - m_ui64CurrentPos = ui64WriteOffset + uiBytesBeingOutput; - - if (!uiBytesToWrite) - { - break; - } - - pucSrcBuffer += uiBytesBeingOutput; - ui64WriteOffset += uiBytesBeingOutput; - } - - // See if we extended the file. If so, we may want to extend it some - // more and then also do a flush. - - if (bExtendFile) - { - // NOTE: ui64LastWriteOffset + uiLastWrite is guaranteed to be - // on a sector boundary. - - if (RC_BAD( rc = extendFile( - ui64LastWriteOffset + uiLastWriteSize, - m_uiExtendSize, TRUE))) - { - goto Exit; - } - } - -Exit: - - if( !bDidAsync && pBufferObj) - { - pBufferObj->notifyComplete( rc); - } - - return( rc ); -} - -/**************************************************************************** -Desc: Write to a file -****************************************************************************/ -RCODE XFLMAPI F_FileHdl::Write( - FLMUINT64 ui64WriteOffset, - FLMUINT uiBytesToWrite, - const void * pvBuffer, - FLMUINT * puiBytesWrittenRV) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiBytesWritten; - OVERLAPPED * pOverlapped; - DWORD udErr; - LARGE_INTEGER liTmp; - - if (m_bDoDirectIO) - { - rc = DirectWrite( ui64WriteOffset, uiBytesToWrite, pvBuffer, - NULL, FALSE, FALSE, puiBytesWrittenRV); - goto Exit; - } - - // If not doing direct IO, a single write call will do. - - flmAssert( m_bFileOpened); - - if( puiBytesWrittenRV) - { - *puiBytesWrittenRV = 0; - } - - if( ui64WriteOffset == XFLM_IO_CURRENT_POS) - { - ui64WriteOffset = m_ui64CurrentPos; - } - - // Position the file. - - if (!m_bCanDoAsync) - { - liTmp.QuadPart = ui64WriteOffset; - if( !SetFilePointerEx( m_FileHandle, liTmp, NULL, FILE_BEGIN)) - { - rc = MapWinErrorToFlaim( GetLastError(), - NE_XFLM_POSITIONING_IN_FILE); - goto Exit; - } - - pOverlapped = NULL; - } - else - { - if (!m_Overlapped.hEvent) - { - if ((m_Overlapped.hEvent = CreateEvent( NULL, TRUE, - FALSE, NULL)) == NULL) - { - rc = MapWinErrorToFlaim( GetLastError(), - NE_XFLM_SETTING_UP_FOR_WRITE); - goto Exit; - } - } - - pOverlapped = &m_Overlapped; - pOverlapped->Offset = (DWORD)(ui64WriteOffset & 0xFFFFFFFF); - pOverlapped->OffsetHigh = (DWORD)(ui64WriteOffset >> 32); - - if( !ResetEvent( pOverlapped->hEvent)) - { - rc = MapWinErrorToFlaim( GetLastError(), - NE_XFLM_SETTING_UP_FOR_WRITE); - goto Exit; - } - } - - if (!WriteFile( m_FileHandle, (LPVOID)pvBuffer, - (DWORD)uiBytesToWrite, &uiBytesWritten, - pOverlapped)) - { - udErr = GetLastError(); - if (udErr == ERROR_IO_PENDING && m_bCanDoAsync) - { - if (!GetOverlappedResult( m_FileHandle, pOverlapped, - &uiBytesWritten, TRUE)) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_WRITING_FILE); - goto Exit; - } - } - else - { - rc = MapWinErrorToFlaim( udErr, NE_XFLM_WRITING_FILE); - goto Exit; - } - } - - if( puiBytesWrittenRV) - { - *puiBytesWrittenRV = uiBytesWritten; - } - - m_ui64CurrentPos = ui64WriteOffset + uiBytesWritten; - - if (uiBytesWritten < uiBytesToWrite) - { - rc = RC_SET( NE_XFLM_IO_DISK_FULL); - goto Exit; - } - -Exit: - return( rc ); -} - -/**************************************************************************** -Desc: Deletes a file -****************************************************************************/ -FSTATIC RCODE _DeleteFile( - char * pszPath) -{ - RCODE rc = NE_XFLM_OK; - - if( DeleteFile( (LPTSTR)pszPath) == FALSE) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_IO_DELETING_FILE); - } - - return rc; -} - -#endif // #if defined( FLM_WIN) - -#if defined( FLM_WATCOM_NLM) - int gv_winDummy(void) - { - return( 0); - } -#endif diff --git a/xflaim/src/fwin.h b/xflaim/src/fwin.h deleted file mode 100644 index 8c5f1f8..0000000 --- a/xflaim/src/fwin.h +++ /dev/null @@ -1,302 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: This include file contains the class definitions for FLAIM's WIN -// FileHdl classes. -// -// Tabs: 3 -// -// Copyright (c) 1997-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: fwin.h 3109 2006-01-19 13:07:07 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#ifndef FWIN_H -#define FWIN_H - -#ifdef FLM_WIN - -RCODE MapWinErrorToFlaim( - DWORD udErrCode, - RCODE defaultRc); - -// Forward references - -class F_FileHdlPage; - -/*=========================================================================== -Class: F_FileHdl -Desc: The F_FileHdl class provides support for basic IO operations - using the WIN I/O calls. -===========================================================================*/ -class F_FileHdl : public IF_FileHdl, public XF_Base -{ -public: - F_FileHdl(); // F_FileHdl Constructor - - virtual ~F_FileHdl(); // F_FileHdl Destructor - free/close this - // file handle - - // BEGINNING OF FUNCTIONS THAT MUST BE IMPLEMENTED ON ALL PLATFORMS - - RCODE XFLMAPI Close( void); // Close a file - The destructor will call this - // This is used to obtain an error code. - - RCODE XFLMAPI Create( // Create a new file. - const char * pszFileName, // File to be created - FLMUINT uiIoFlags); // Access and Mode Flags - - RCODE XFLMAPI CreateUnique( // Create a new file (with a unique file name). - const char * pszDirName, // Directory where the file is to be created - const char * pszFileExtension, // Extension to be used on the new file. - FLMUINT uiIoFlags); // Access and Mode Flags - - RCODE XFLMAPI Open( // Initiates access to an existing file. - const char * pszFileName, // File to be opened - FLMUINT uiIoFlags); // Access and Mode Flags - - RCODE XFLMAPI Flush( void); // Flushes a file's buffers to disk - - RCODE XFLMAPI Read( // Reads a buffer of data from a file - FLMUINT64 ui64Offset, // Offset to being reading at. - FLMUINT uiLength, // Number of bytes to read - void * pvBuffer, // Buffer to place read bytes into - FLMUINT * puiBytesRead); // [out] number of bytes read - - RCODE XFLMAPI Seek( // Moves the current position in the file - FLMUINT64 ui64Offset, // Offset to seek to - FLMINT iWhence, // Location to apply sdwOffset to. - FLMUINT64 * pui64NewOffset); // [out] new file offset - - RCODE XFLMAPI Size( // Returns to size of the open file. - FLMUINT64 * pui64Size); // [out] size of the file - - RCODE XFLMAPI Tell( // Returns to current position of the file - // pointer in the open file. - FLMUINT64 * pui64Offset); // [out] current file position - - RCODE XFLMAPI Truncate( // Decreases the size of a file. - FLMUINT64 ui64Size); // Size to truncate the file to. - - RCODE XFLMAPI Write( // Writes a buffer of data to a file. - FLMUINT64 ui64Offset, // Offset to seek to. - FLMUINT uiLength, // Number of bytes to write. - const void * pvBuffer, // Buffer that contains bytes to be written - FLMUINT * puiBytesWritten); // Number of bytes written. - - // Some I/O subsystems (such as direct IO) can only read and write sectors - // (512 byte chunks). If uiOffset is not on a sector boundary or - // uiLength is not an exact multiple of a sector size, the I/O system - // would have to try to read or write a partial sector - something that - // requires extra overhead, particularly for write operations - because - // in order to write a partial sector, the I/O subsystem first has to - // read the sector in to memory before writing it out in order to - // preserve the part of the sector that was not being written to. - - // The SectorRead and SectorWrite routines are provided to allow - // the caller to tell the I/O subsystem that it is OK to do full - // sector reads or writes if it needs to, because pvBuffer is - // guaranteed to be a multiple of 512 bytes big. If the I/O - // subsystem can only do sector reads and writes, it can use the - // extra buffer space in pvBuffer. When a program calls SectorWrite - // it is also telling the I/O subsystem that it does not need to - // read a partially written sector from disk before writing it out. - // It will be OK to write whatever data is in the pvBuffer to fill out - // the sector. - - FINLINE RCODE XFLMAPI SectorRead( // Allows sector reads to be done. - FLMUINT64 ui64ReadOffset, // Offset to being reading at. - FLMUINT uiBytesToRead, // Number of bytes to read - void * pvBuffer, // Buffer to place read bytes into - FLMUINT * puiBytesReadRV) // [out] number of bytes read - { - if (m_bDoDirectIO) - { - return( DirectRead( ui64ReadOffset, uiBytesToRead, - pvBuffer, TRUE, puiBytesReadRV)); - } - else - { - return( Read( ui64ReadOffset, uiBytesToRead, pvBuffer, puiBytesReadRV)); - } - } - - FINLINE RCODE XFLMAPI SectorWrite( // Allows sector writes to be done. - FLMUINT64 ui64WriteOffset, // Offset to seek to. - FLMUINT uiBytesToWrite, // Number of bytes to write. - const void * pvBuffer, // Buffer that contains bytes to be written - FLMUINT uiBufferSize, // Actual buffer size. - void * pvBufferObj, // Buffer object for async write - FLMUINT * puiBytesWrittenRV, // Number of bytes written. - FLMBOOL bZeroFill = TRUE) // Zero fill the buffer? - { - uiBufferSize = uiBufferSize; // Parameter is not used. - if (m_bDoDirectIO) - { - return( DirectWrite( ui64WriteOffset, uiBytesToWrite, - pvBuffer, (F_IOBuffer *)pvBufferObj, TRUE, - bZeroFill, puiBytesWrittenRV)); - } - else - { - flmAssert( pvBufferObj == NULL); - return( Write( ui64WriteOffset, uiBytesToWrite, pvBuffer, - puiBytesWrittenRV)); - } - } - - FINLINE FLMBOOL XFLMAPI CanDoAsync( // Return whether or not we can do async - void) // writes. - { - return( m_bCanDoAsync); - } - - FINLINE void XFLMAPI setExtendSize( - FLMUINT uiExtendSize) - { - m_uiExtendSize = uiExtendSize; - } - - FINLINE void XFLMAPI setMaxAutoExtendSize( - FLMUINT uiMaxAutoExtendSize) - { - m_uiMaxAutoExtendSize = uiMaxAutoExtendSize; - } - - // METHODS NEEDED TO INTERACT WITH FILE HANDLE MANAGER - - FINLINE void setupFileHdl( - FLMUINT uiFileId, - FLMBOOL bDeleteOnRelease) - { - m_uiFileId = uiFileId; - m_bDeleteOnRelease = bDeleteOnRelease; - } - - FINLINE FLMUINT getFileId( void) - { - return m_uiFileId; - } - - // END OF FUNCTIONS THAT MUST BE DEFINED FOR ALL PLATFORMS - - FINLINE FLMUINT GetSectorSize( void) - { - return( m_uiBytesPerSector); - } - - FINLINE void SetBlockSize( - FLMUINT uiBlockSize) - { - m_uiBlockSize = uiBlockSize; - } - - FINLINE HANDLE getFileHandle( void) - { - return m_FileHandle; - } - -private: - - RCODE OpenOrCreate( // Open or create a file - const char * pszFileName, // Name of file to open or create. - FLMUINT uiAccess, // Access flags - FLMBOOL bCreateFlag); // Create flag - - RCODE AllocAlignBuffer( void); // Allocate an aligned buffer. - - RCODE DoOneRead( - FLMUINT64 ui64Offset, // Offset being reading at. - FLMUINT uiLength, // Number of bytes to read - void * pvBuffer, // Buffer to place read bytes into - FLMUINT * puiBytesRead); // [out] number of bytes read - - RCODE DirectRead( // Reads a buffer of data from a file - FLMUINT64 uiOffset, // Offset being reading at. - FLMUINT uiLength, // Number of bytes to read - void * pvBuffer, // Buffer to place read bytes into - FLMBOOL bBuffHasFullSectors, // Buffer is sector aligned. - FLMUINT * puiBytesRead); // [out] number of bytes read - - RCODE DirectWrite( // Writes a buffer of data from a file - FLMUINT64 uiOffset, // Offset being written to. - FLMUINT uiLength, // Number of bytes to write - const void * pvBuffer, // Buffer to write from. - F_IOBuffer * pBufferObj, // Buffer object for async writes - FLMBOOL bBuffHasFullSectors, // Buffer is sector aligned. - FLMBOOL bZeroFill, - FLMUINT * puiBytesWritten); // [out] number of bytes written - - FINLINE FLMUINT64 RoundToNextSector( - FLMUINT64 ui64Bytes) - { - return( (ui64Bytes + m_ui64NotOnSectorBoundMask) & - m_ui64GetSectorBoundMask); - } - - FINLINE FLMUINT64 TruncateToPrevSector( - FLMUINT64 ui64Offset) - { - return( ui64Offset & m_ui64GetSectorBoundMask); - } - - RCODE extendFile( - FLMUINT64 ui64EndOfLastWrite, - FLMUINT uiMaxBytesToExtend, - FLMBOOL bFlush); - - // The following are for every platform - - F_FileHdl * m_pNext; // Next file handle in list - F_FileHdl * m_pPrev; // Prev file handle in list - FLMBOOL m_bInList; // Is this file handle in a list? - FLMBOOL m_bFileOpened; // Is the file currently opened/closed. - FLMUINT m_uiAvailTime; // Time when placed in avail list. - FLMUINT m_uiFileId; // FFILE Unique File Id - FLMBOOL m_bDeleteOnRelease; // Delete this file when it is released. - FLMBOOL m_bOpenedReadOnly; // Opened the file read only - FLMBOOL m_bOpenedExclusive; // Opened the file in exclusive mode - char * m_pszFileName; // File name for this FileHdl - - // The following are for windows platform - - HANDLE m_FileHandle; // WIN file handle - FLMUINT m_uiBlockSize; // Block size, if known. - FLMUINT m_uiBytesPerSector; // Bytes per sector for this volume. - FLMUINT64 m_ui64NotOnSectorBoundMask; - FLMUINT64 m_ui64GetSectorBoundMask; - FLMBOOL m_bDoDirectIO; // TRUE = do direct file I/O - FLMUINT m_uiExtendSize; // Size to extend by if in direct mode. - FLMUINT m_uiMaxAutoExtendSize; - // Don't do additional extending - // once file reaches this size. - FLMBYTE * m_pucAlignedBuff; - // Buffer that is aligned for doing - // direct IO. - FLMUINT m_uiAlignedBuffSize; - // Size of aligned buffer. - FLMUINT64 m_ui64CurrentPos; // Current position in file - FLMBOOL m_bCanDoAsync; // Is this handle set up to do ASYNC? - OVERLAPPED m_Overlapped; // Used when NOT doing async. - -friend class F_FileHdlPage; -friend class F_FileHdlMgr; - -}; - -#endif // #ifdef FLM_WIN - -#endif // #ifndef FWIN_H diff --git a/xflaim/src/fxml.cpp b/xflaim/src/fxml.cpp index f00a62e..78f2078 100644 --- a/xflaim/src/fxml.cpp +++ b/xflaim/src/fxml.cpp @@ -25,23 +25,6 @@ #include "flaimsys.h" -// Constants - -#define FLM_XML_BASE_CHAR 0x01 -#define FLM_XML_IDEOGRAPHIC 0x02 -#define FLM_XML_COMBINING_CHAR 0x04 -#define FLM_XML_DIGIT 0x08 -#define FLM_XML_EXTENDER 0x10 -#define FLM_XML_WHITESPACE 0x20 - -// Local typedefs - -typedef struct -{ - char * pszEntity; - FLMUINT uiValue; -} CharEntity; - // Global data extern FLMUNICODE gv_uzXFLAIMNamespace[]; @@ -125,662 +108,6 @@ FSTATIC RCODE exportUniValue( FLMBOOL bEncodeSpecialChars, FLMUINT uiIndentCount); -// Function / Method Implementations - -/**************************************************************************** -Desc: Constructor -****************************************************************************/ -F_XML::F_XML() -{ - m_pCharTable = NULL; -} - -/**************************************************************************** -Desc: Destructor -****************************************************************************/ -F_XML::~F_XML() -{ - if( m_pCharTable) - { - f_free( &m_pCharTable); - } -} - -typedef struct -{ - FLMUNICODE uLowChar; - FLMUNICODE uHighChar; - FLMUINT16 ui16Flag; -} CHAR_TBL; - -static CHAR_TBL charTbl[] = -{ - { 0x0041, 0x005A, FLM_XML_BASE_CHAR}, - { 0x0061, 0x007A, FLM_XML_BASE_CHAR}, - { 0x00C0, 0x00D6, FLM_XML_BASE_CHAR}, - { 0x00D8, 0x00F6, FLM_XML_BASE_CHAR}, - { 0x00F8, 0x00FF, FLM_XML_BASE_CHAR}, - { 0x0100, 0x0131, FLM_XML_BASE_CHAR}, - { 0x0134, 0x013E, FLM_XML_BASE_CHAR}, - { 0x0141, 0x0148, FLM_XML_BASE_CHAR}, - { 0x014A, 0x017E, FLM_XML_BASE_CHAR}, - { 0x0180, 0x01C3, FLM_XML_BASE_CHAR}, - { 0x01CD, 0x01F0, FLM_XML_BASE_CHAR}, - { 0x01F4, 0x01F5, FLM_XML_BASE_CHAR}, - { 0x01FA, 0x0217, FLM_XML_BASE_CHAR}, - { 0x0250, 0x02A8, FLM_XML_BASE_CHAR}, - { 0x02BB, 0x02C1, FLM_XML_BASE_CHAR}, - { 0x0386, 0x0386, FLM_XML_BASE_CHAR}, - { 0x0388, 0x038A, FLM_XML_BASE_CHAR}, - { 0x038C, 0x038C, FLM_XML_BASE_CHAR}, - { 0x038E, 0x03A1, FLM_XML_BASE_CHAR}, - { 0x03A3, 0x03CE, FLM_XML_BASE_CHAR}, - { 0x03D0, 0x03D6, FLM_XML_BASE_CHAR}, - { 0x03DA, 0x03DA, FLM_XML_BASE_CHAR}, - { 0x03DC, 0x03DC, FLM_XML_BASE_CHAR}, - { 0x03DE, 0x03DE, FLM_XML_BASE_CHAR}, - { 0x03E0, 0x03E0, FLM_XML_BASE_CHAR}, - { 0x03E2, 0x03F3, FLM_XML_BASE_CHAR}, - { 0x0401, 0x040C, FLM_XML_BASE_CHAR}, - { 0x040E, 0x044F, FLM_XML_BASE_CHAR}, - { 0x0451, 0x045C, FLM_XML_BASE_CHAR}, - { 0x045E, 0x0481, FLM_XML_BASE_CHAR}, - { 0x0490, 0x04C4, FLM_XML_BASE_CHAR}, - { 0x04C7, 0x04C8, FLM_XML_BASE_CHAR}, - { 0x04CB, 0x04CC, FLM_XML_BASE_CHAR}, - { 0x04D0, 0x04EB, FLM_XML_BASE_CHAR}, - { 0x04EE, 0x04F5, FLM_XML_BASE_CHAR}, - { 0x04F8, 0x04F9, FLM_XML_BASE_CHAR}, - { 0x0531, 0x0556, FLM_XML_BASE_CHAR}, - { 0x0559, 0x0559, FLM_XML_BASE_CHAR}, - { 0x0561, 0x0586, FLM_XML_BASE_CHAR}, - { 0x05D0, 0x05EA, FLM_XML_BASE_CHAR}, - { 0x05F0, 0x05F2, FLM_XML_BASE_CHAR}, - { 0x0621, 0x063A, FLM_XML_BASE_CHAR}, - { 0x0641, 0x06B7, FLM_XML_BASE_CHAR}, - { 0x06BA, 0x06BE, FLM_XML_BASE_CHAR}, - { 0x06C0, 0x06CE, FLM_XML_BASE_CHAR}, - { 0x06D0, 0x06D3, FLM_XML_BASE_CHAR}, - { 0x06D5, 0x06D5, FLM_XML_BASE_CHAR}, - { 0x06E5, 0x06E6, FLM_XML_BASE_CHAR}, - { 0x0905, 0x0939, FLM_XML_BASE_CHAR}, - { 0x093D, 0x093D, FLM_XML_BASE_CHAR}, - { 0x0958, 0x0961, FLM_XML_BASE_CHAR}, - { 0x0985, 0x098C, FLM_XML_BASE_CHAR}, - { 0x098F, 0x0990, FLM_XML_BASE_CHAR}, - { 0x0993, 0x09A8, FLM_XML_BASE_CHAR}, - { 0x09AA, 0x09B0, FLM_XML_BASE_CHAR}, - { 0x09B2, 0x09B2, FLM_XML_BASE_CHAR}, - { 0x09B6, 0x09B9, FLM_XML_BASE_CHAR}, - { 0x0061, 0x007A, FLM_XML_BASE_CHAR}, - { 0x09DC, 0x09DD, FLM_XML_BASE_CHAR}, - { 0x09DF, 0x09E1, FLM_XML_BASE_CHAR}, - { 0x09F0, 0x09F1, FLM_XML_BASE_CHAR}, - { 0x0A05, 0x0A0A, FLM_XML_BASE_CHAR}, - { 0x0A0F, 0x0A10, FLM_XML_BASE_CHAR}, - { 0x0A13, 0x0A28, FLM_XML_BASE_CHAR}, - { 0x0A2A, 0x0A30, FLM_XML_BASE_CHAR}, - { 0x0A32, 0x0A33, FLM_XML_BASE_CHAR}, - { 0x0A35, 0x0A36, FLM_XML_BASE_CHAR}, - { 0x0A38, 0x0A39, FLM_XML_BASE_CHAR}, - { 0x0A59, 0x0A5C, FLM_XML_BASE_CHAR}, - { 0x0A5E, 0x0A5E, FLM_XML_BASE_CHAR}, - { 0x0A72, 0x0A74, FLM_XML_BASE_CHAR}, - { 0x0A85, 0x0A8B, FLM_XML_BASE_CHAR}, - { 0x0A8D, 0x0A8D, FLM_XML_BASE_CHAR}, - { 0x0A8F, 0x0A91, FLM_XML_BASE_CHAR}, - { 0x0A93, 0x0AA8, FLM_XML_BASE_CHAR}, - { 0x0AAA, 0x0AB0, FLM_XML_BASE_CHAR}, - { 0x0AB2, 0x0AB3, FLM_XML_BASE_CHAR}, - { 0x0AB5, 0x0AB9, FLM_XML_BASE_CHAR}, - { 0x0ABD, 0x0ABD, FLM_XML_BASE_CHAR}, - { 0x0AE0, 0x0AE0, FLM_XML_BASE_CHAR}, - { 0x0B05, 0x0B0C, FLM_XML_BASE_CHAR}, - { 0x0B0F, 0x0B10, FLM_XML_BASE_CHAR}, - { 0x0B13, 0x0B28, FLM_XML_BASE_CHAR}, - { 0x0B2A, 0x0B30, FLM_XML_BASE_CHAR}, - { 0x0B32, 0x0B33, FLM_XML_BASE_CHAR}, - { 0x0B36, 0x0B39, FLM_XML_BASE_CHAR}, - { 0x0B3D, 0x0B3D, FLM_XML_BASE_CHAR}, - { 0x0B5C, 0x0B5D, FLM_XML_BASE_CHAR}, - { 0x0B5F, 0x0B61, FLM_XML_BASE_CHAR}, - { 0x0B85, 0x0B8A, FLM_XML_BASE_CHAR}, - { 0x0B8E, 0x0B90, FLM_XML_BASE_CHAR}, - { 0x0B92, 0x0B95, FLM_XML_BASE_CHAR}, - { 0x0B99, 0x0B9A, FLM_XML_BASE_CHAR}, - { 0x0B9C, 0x0B9C, FLM_XML_BASE_CHAR}, - { 0x0B9E, 0x0B9F, FLM_XML_BASE_CHAR}, - { 0x0BA3, 0x0BA4, FLM_XML_BASE_CHAR}, - { 0x0BA8, 0x0BAA, FLM_XML_BASE_CHAR}, - { 0x0BAE, 0x0BB5, FLM_XML_BASE_CHAR}, - { 0x0BB7, 0x0BB9, FLM_XML_BASE_CHAR}, - { 0x0C05, 0x0C0C, FLM_XML_BASE_CHAR}, - { 0x0C0E, 0x0C10, FLM_XML_BASE_CHAR}, - { 0x0C12, 0x0C28, FLM_XML_BASE_CHAR}, - { 0x0C2A, 0x0C33, FLM_XML_BASE_CHAR}, - { 0x0C35, 0x0C39, FLM_XML_BASE_CHAR}, - { 0x0C60, 0x0C61, FLM_XML_BASE_CHAR}, - { 0x0C85, 0x0C8C, FLM_XML_BASE_CHAR}, - { 0x0C8E, 0x0C90, FLM_XML_BASE_CHAR}, - { 0x0C92, 0x0CA8, FLM_XML_BASE_CHAR}, - { 0x0CAA, 0x0CB3, FLM_XML_BASE_CHAR}, - { 0x0CB5, 0x0CB9, FLM_XML_BASE_CHAR}, - { 0x0CDE, 0x0CDE, FLM_XML_BASE_CHAR}, - { 0x0CE0, 0x0CE1, FLM_XML_BASE_CHAR}, - { 0x0D05, 0x0D0C, FLM_XML_BASE_CHAR}, - { 0x0D0E, 0x0D10, FLM_XML_BASE_CHAR}, - { 0x0D12, 0x0D28, FLM_XML_BASE_CHAR}, - { 0x0D2A, 0x0D39, FLM_XML_BASE_CHAR}, - { 0x0D60, 0x0D61, FLM_XML_BASE_CHAR}, - { 0x0E01, 0x0E2E, FLM_XML_BASE_CHAR}, - { 0x0E30, 0x0E30, FLM_XML_BASE_CHAR}, - { 0x0E32, 0x0E33, FLM_XML_BASE_CHAR}, - { 0x0E40, 0x0E45, FLM_XML_BASE_CHAR}, - { 0x0E81, 0x0E82, FLM_XML_BASE_CHAR}, - { 0x0E84, 0x0E84, FLM_XML_BASE_CHAR}, - { 0x0E87, 0x0E88, FLM_XML_BASE_CHAR}, - { 0x0E8A, 0x0E8A, FLM_XML_BASE_CHAR}, - { 0x0E8D, 0x0E8D, FLM_XML_BASE_CHAR}, - { 0x0E94, 0x0E97, FLM_XML_BASE_CHAR}, - { 0x0E99, 0x0E9F, FLM_XML_BASE_CHAR}, - { 0x0EA1, 0x0EA3, FLM_XML_BASE_CHAR}, - { 0x0EA5, 0x0EA5, FLM_XML_BASE_CHAR}, - { 0x0EA7, 0x0EA7, FLM_XML_BASE_CHAR}, - { 0x0EAA, 0x0EAB, FLM_XML_BASE_CHAR}, - { 0x0EAD, 0x0EAE, FLM_XML_BASE_CHAR}, - { 0x0EB0, 0x0EB0, FLM_XML_BASE_CHAR}, - { 0x0EB2, 0x0EB3, FLM_XML_BASE_CHAR}, - { 0x0EBD, 0x0EBD, FLM_XML_BASE_CHAR}, - { 0x0EC0, 0x0EC4, FLM_XML_BASE_CHAR}, - { 0x0F40, 0x0F47, FLM_XML_BASE_CHAR}, - { 0x0F49, 0x0F69, FLM_XML_BASE_CHAR}, - { 0x10A0, 0x10C5, FLM_XML_BASE_CHAR}, - { 0x10D0, 0x10F6, FLM_XML_BASE_CHAR}, - { 0x1100, 0x1100, FLM_XML_BASE_CHAR}, - { 0x1102, 0x1103, FLM_XML_BASE_CHAR}, - { 0x1105, 0x1107, FLM_XML_BASE_CHAR}, - { 0x1109, 0x1109, FLM_XML_BASE_CHAR}, - { 0x110B, 0x110C, FLM_XML_BASE_CHAR}, - { 0x110E, 0x1112, FLM_XML_BASE_CHAR}, - { 0x113C, 0x113C, FLM_XML_BASE_CHAR}, - { 0x113E, 0x113E, FLM_XML_BASE_CHAR}, - { 0x1140, 0x1140, FLM_XML_BASE_CHAR}, - { 0x114C, 0x114C, FLM_XML_BASE_CHAR}, - { 0x114E, 0x114E, FLM_XML_BASE_CHAR}, - { 0x1150, 0x1150, FLM_XML_BASE_CHAR}, - { 0x1154, 0x1155, FLM_XML_BASE_CHAR}, - { 0x1159, 0x1159, FLM_XML_BASE_CHAR}, - { 0x115F, 0x1161, FLM_XML_BASE_CHAR}, - { 0x1163, 0x1163, FLM_XML_BASE_CHAR}, - { 0x1165, 0x1165, FLM_XML_BASE_CHAR}, - { 0x1167, 0x1167, FLM_XML_BASE_CHAR}, - { 0x1169, 0x1169, FLM_XML_BASE_CHAR}, - { 0x116D, 0x116E, FLM_XML_BASE_CHAR}, - { 0x1172, 0x1173, FLM_XML_BASE_CHAR}, - { 0x1175, 0x1175, FLM_XML_BASE_CHAR}, - { 0x119E, 0x119E, FLM_XML_BASE_CHAR}, - { 0x11A8, 0x11A8, FLM_XML_BASE_CHAR}, - { 0x11AB, 0x11AB, FLM_XML_BASE_CHAR}, - { 0x11AE, 0x11AF, FLM_XML_BASE_CHAR}, - { 0x11B7, 0x11B8, FLM_XML_BASE_CHAR}, - { 0x11BA, 0x11BA, FLM_XML_BASE_CHAR}, - { 0x11BC, 0x11C2, FLM_XML_BASE_CHAR}, - { 0x11EB, 0x11EB, FLM_XML_BASE_CHAR}, - { 0x11F0, 0x11F0, FLM_XML_BASE_CHAR}, - { 0x11F9, 0x11F9, FLM_XML_BASE_CHAR}, - { 0x1E00, 0x1E9B, FLM_XML_BASE_CHAR}, - { 0x1EA0, 0x1EF9, FLM_XML_BASE_CHAR}, - { 0x1F00, 0x1F15, FLM_XML_BASE_CHAR}, - { 0x1F18, 0x1F1D, FLM_XML_BASE_CHAR}, - { 0x1F20, 0x1F45, FLM_XML_BASE_CHAR}, - { 0x1F48, 0x1F4D, FLM_XML_BASE_CHAR}, - { 0x1F50, 0x1F57, FLM_XML_BASE_CHAR}, - { 0x1F59, 0x1F59, FLM_XML_BASE_CHAR}, - { 0x1F5B, 0x1F5B, FLM_XML_BASE_CHAR}, - { 0x1F5D, 0x1F5D, FLM_XML_BASE_CHAR}, - { 0x1F5F, 0x1F7D, FLM_XML_BASE_CHAR}, - { 0x1F80, 0x1FB4, FLM_XML_BASE_CHAR}, - { 0x1FB6, 0x1FBC, FLM_XML_BASE_CHAR}, - { 0x1FBE, 0x1FBE, FLM_XML_BASE_CHAR}, - { 0x1FC2, 0x1FC4, FLM_XML_BASE_CHAR}, - { 0x1FC6, 0x1FCC, FLM_XML_BASE_CHAR}, - { 0x1FD0, 0x1FD3, FLM_XML_BASE_CHAR}, - { 0x1FD6, 0x1FDB, FLM_XML_BASE_CHAR}, - { 0x1FE0, 0x1FEC, FLM_XML_BASE_CHAR}, - { 0x1FF2, 0x1FF4, FLM_XML_BASE_CHAR}, - { 0x1FF6, 0x1FFC, FLM_XML_BASE_CHAR}, - { 0x2126, 0x2126, FLM_XML_BASE_CHAR}, - { 0x212A, 0x212B, FLM_XML_BASE_CHAR}, - { 0x212E, 0x212E, FLM_XML_BASE_CHAR}, - { 0x2180, 0x2182, FLM_XML_BASE_CHAR}, - { 0x3041, 0x3094, FLM_XML_BASE_CHAR}, - { 0x30A1, 0x30FA, FLM_XML_BASE_CHAR}, - { 0x3105, 0x312C, FLM_XML_BASE_CHAR}, - { 0xAC00, 0xD7A3, FLM_XML_BASE_CHAR}, - - { 0x4E00, 0x9FA5, FLM_XML_IDEOGRAPHIC}, - { 0x3007, 0x3007, FLM_XML_IDEOGRAPHIC}, - { 0x3021, 0x3029, FLM_XML_IDEOGRAPHIC}, - - { 0x0300, 0x0345, FLM_XML_COMBINING_CHAR}, - { 0x0360, 0x0361, FLM_XML_COMBINING_CHAR}, - { 0x0483, 0x0486, FLM_XML_COMBINING_CHAR}, - { 0x0591, 0x05A1, FLM_XML_COMBINING_CHAR}, - { 0x05A3, 0x05B9, FLM_XML_COMBINING_CHAR}, - { 0x05BB, 0x05BD, FLM_XML_COMBINING_CHAR}, - { 0x05BF, 0x05BF, FLM_XML_COMBINING_CHAR}, - { 0x05C1, 0x05C2, FLM_XML_COMBINING_CHAR}, - { 0x05C4, 0x05C4, FLM_XML_COMBINING_CHAR}, - { 0x064B, 0x0652, FLM_XML_COMBINING_CHAR}, - { 0x0670, 0x0670, FLM_XML_COMBINING_CHAR}, - { 0x06D6, 0x06DC, FLM_XML_COMBINING_CHAR}, - { 0x06DD, 0x06DF, FLM_XML_COMBINING_CHAR}, - { 0x06E0, 0x06E4, FLM_XML_COMBINING_CHAR}, - { 0x06E7, 0x06E8, FLM_XML_COMBINING_CHAR}, - { 0x06EA, 0x06ED, FLM_XML_COMBINING_CHAR}, - { 0x0901, 0x0903, FLM_XML_COMBINING_CHAR}, - { 0x093C, 0x093C, FLM_XML_COMBINING_CHAR}, - { 0x093E, 0x094C, FLM_XML_COMBINING_CHAR}, - { 0x094D, 0x094D, FLM_XML_COMBINING_CHAR}, - { 0x0951, 0x0954, FLM_XML_COMBINING_CHAR}, - { 0x0962, 0x0963, FLM_XML_COMBINING_CHAR}, - { 0x0981, 0x0983, FLM_XML_COMBINING_CHAR}, - { 0x09BC, 0x09BC, FLM_XML_COMBINING_CHAR}, - { 0x09BE, 0x09BE, FLM_XML_COMBINING_CHAR}, - { 0x09BF, 0x09BF, FLM_XML_COMBINING_CHAR}, - { 0x09C0, 0x09C4, FLM_XML_COMBINING_CHAR}, - { 0x09C7, 0x09C8, FLM_XML_COMBINING_CHAR}, - { 0x09CB, 0x09CD, FLM_XML_COMBINING_CHAR}, - { 0x09D7, 0x09D7, FLM_XML_COMBINING_CHAR}, - { 0x09E2, 0x09E3, FLM_XML_COMBINING_CHAR}, - { 0x0A02, 0x0A02, FLM_XML_COMBINING_CHAR}, - { 0x0A3C, 0x0A3C, FLM_XML_COMBINING_CHAR}, - { 0x0A3E, 0x0A3E, FLM_XML_COMBINING_CHAR}, - { 0x0A3F, 0x0A3F, FLM_XML_COMBINING_CHAR}, - { 0x0A40, 0x0A42, FLM_XML_COMBINING_CHAR}, - { 0x0A47, 0x0A48, FLM_XML_COMBINING_CHAR}, - { 0x0A4B, 0x0A4D, FLM_XML_COMBINING_CHAR}, - { 0x0A70, 0x0A71, FLM_XML_COMBINING_CHAR}, - { 0x0A81, 0x0A83, FLM_XML_COMBINING_CHAR}, - { 0x0ABC, 0x0ABC, FLM_XML_COMBINING_CHAR}, - { 0x0ABE, 0x0AC5, FLM_XML_COMBINING_CHAR}, - { 0x0AC7, 0x0AC9, FLM_XML_COMBINING_CHAR}, - { 0x0ACB, 0x0ACD, FLM_XML_COMBINING_CHAR}, - { 0x0B01, 0x0B03, FLM_XML_COMBINING_CHAR}, - { 0x0B3C, 0x0B3C, FLM_XML_COMBINING_CHAR}, - { 0x0B3E, 0x0B43, FLM_XML_COMBINING_CHAR}, - { 0x0B47, 0x0B48, FLM_XML_COMBINING_CHAR}, - { 0x0B4B, 0x0B4D, FLM_XML_COMBINING_CHAR}, - { 0x0B56, 0x0B57, FLM_XML_COMBINING_CHAR}, - { 0x0B82, 0x0B83, FLM_XML_COMBINING_CHAR}, - { 0x0BBE, 0x0BC2, FLM_XML_COMBINING_CHAR}, - { 0x0BC6, 0x0BC8, FLM_XML_COMBINING_CHAR}, - { 0x0BCA, 0x0BCD, FLM_XML_COMBINING_CHAR}, - { 0x0BD7, 0x0BD7, FLM_XML_COMBINING_CHAR}, - { 0x0C01, 0x0C03, FLM_XML_COMBINING_CHAR}, - { 0x0C3E, 0x0C44, FLM_XML_COMBINING_CHAR}, - { 0x0C46, 0x0C48, FLM_XML_COMBINING_CHAR}, - { 0x0C4A, 0x0C4D, FLM_XML_COMBINING_CHAR}, - { 0x0C55, 0x0C56, FLM_XML_COMBINING_CHAR}, - { 0x0C82, 0x0C83, FLM_XML_COMBINING_CHAR}, - { 0x0CBE, 0x0CC4, FLM_XML_COMBINING_CHAR}, - { 0x0CC6, 0x0CC8, FLM_XML_COMBINING_CHAR}, - { 0x0CCA, 0x0CCD, FLM_XML_COMBINING_CHAR}, - { 0x0CD5, 0x0CD6, FLM_XML_COMBINING_CHAR}, - { 0x0D02, 0x0D03, FLM_XML_COMBINING_CHAR}, - { 0x0D3E, 0x0D43, FLM_XML_COMBINING_CHAR}, - { 0x0D46, 0x0D48, FLM_XML_COMBINING_CHAR}, - { 0x0D4A, 0x0D4D, FLM_XML_COMBINING_CHAR}, - { 0x0D57, 0x0D57, FLM_XML_COMBINING_CHAR}, - { 0x0E31, 0x0E31, FLM_XML_COMBINING_CHAR}, - { 0x0E34, 0x0E3A, FLM_XML_COMBINING_CHAR}, - { 0x0E47, 0x0E4E, FLM_XML_COMBINING_CHAR}, - { 0x0EB1, 0x0EB1, FLM_XML_COMBINING_CHAR}, - { 0x0EB4, 0x0EB9, FLM_XML_COMBINING_CHAR}, - { 0x0EBB, 0x0EBC, FLM_XML_COMBINING_CHAR}, - { 0x0EC8, 0x0ECD, FLM_XML_COMBINING_CHAR}, - { 0x0F18, 0x0F19, FLM_XML_COMBINING_CHAR}, - { 0x0F35, 0x0F35, FLM_XML_COMBINING_CHAR}, - { 0x0F37, 0x0F37, FLM_XML_COMBINING_CHAR}, - { 0x0F39, 0x0F39, FLM_XML_COMBINING_CHAR}, - { 0x0F3E, 0x0F3E, FLM_XML_COMBINING_CHAR}, - { 0x0F3F, 0x0F3F, FLM_XML_COMBINING_CHAR}, - { 0x0F71, 0x0F84, FLM_XML_COMBINING_CHAR}, - { 0x0F86, 0x0F8B, FLM_XML_COMBINING_CHAR}, - { 0x0F90, 0x0F95, FLM_XML_COMBINING_CHAR}, - { 0x0F97, 0x0F97, FLM_XML_COMBINING_CHAR}, - { 0x0F99, 0x0FAD, FLM_XML_COMBINING_CHAR}, - { 0x0FB1, 0x0FB7, FLM_XML_COMBINING_CHAR}, - { 0x0FB9, 0x0FB9, FLM_XML_COMBINING_CHAR}, - { 0x20D0, 0x20DC, FLM_XML_COMBINING_CHAR}, - { 0x20E1, 0x20E1, FLM_XML_COMBINING_CHAR}, - { 0x302A, 0x302F, FLM_XML_COMBINING_CHAR}, - { 0x3099, 0x3099, FLM_XML_COMBINING_CHAR}, - { 0x309A, 0x309A, FLM_XML_COMBINING_CHAR}, - - { 0x0030, 0x0039, FLM_XML_DIGIT}, - { 0x0660, 0x0669, FLM_XML_DIGIT}, - { 0x06F0, 0x06F9, FLM_XML_DIGIT}, - { 0x0966, 0x096F, FLM_XML_DIGIT}, - { 0x09E6, 0x09EF, FLM_XML_DIGIT}, - { 0x0A66, 0x0A6F, FLM_XML_DIGIT}, - { 0x0AE6, 0x0AEF, FLM_XML_DIGIT}, - { 0x0B66, 0x0B6F, FLM_XML_DIGIT}, - { 0x0BE7, 0x0BEF, FLM_XML_DIGIT}, - { 0x0C66, 0x0C6F, FLM_XML_DIGIT}, - { 0x0CE6, 0x0CEF, FLM_XML_DIGIT}, - { 0x0D66, 0x0D6F, FLM_XML_DIGIT}, - { 0x0E50, 0x0E59, FLM_XML_DIGIT}, - { 0x0ED0, 0x0ED9, FLM_XML_DIGIT}, - { 0x0F20, 0x0F29, FLM_XML_DIGIT}, - - { 0x00B7, 0x00B7, FLM_XML_EXTENDER}, - { 0x02D0, 0x02D0, FLM_XML_EXTENDER}, - { 0x02D1, 0x02D1, FLM_XML_EXTENDER}, - { 0x0387, 0x0387, FLM_XML_EXTENDER}, - { 0x0640, 0x0640, FLM_XML_EXTENDER}, - { 0x0E46, 0x0E46, FLM_XML_EXTENDER}, - { 0x0EC6, 0x0EC6, FLM_XML_EXTENDER}, - { 0x3005, 0x3005, FLM_XML_EXTENDER}, - { 0x3031, 0x3035, FLM_XML_EXTENDER}, - { 0x309D, 0x309E, FLM_XML_EXTENDER}, - { 0x30FC, 0x30FE, FLM_XML_EXTENDER}, - - { 0x0009, 0x0009, FLM_XML_WHITESPACE}, - { 0x000A, 0x000A, FLM_XML_WHITESPACE}, - { 0x000D, 0x000D, FLM_XML_WHITESPACE}, - { 0x0020, 0x0020, FLM_XML_WHITESPACE}, - { 0, 0, 0} -}; - -/**************************************************************************** -Desc: Sets a character's type flag in the character lookup table -****************************************************************************/ -void F_XML::setCharFlag( - FLMUNICODE uLowChar, - FLMUNICODE uHighChar, - FLMUINT16 ui16Flag) -{ - FLMUINT uiLoop; - - flmAssert( uLowChar <= uHighChar); - - for( uiLoop = (FLMUINT)uLowChar; uiLoop <= (FLMUINT)uHighChar; uiLoop++) - { - m_pCharTable[ uiLoop].ucFlags |= (FLMBYTE)ui16Flag; - } -} - -/**************************************************************************** -Desc: Builds a character lookup table -****************************************************************************/ -RCODE F_XML::buildCharTable( void) -{ - RCODE rc = NE_XFLM_OK; - - if( m_pCharTable) - { - f_free( &m_pCharTable); - } - - if( RC_BAD( rc = f_calloc( sizeof( XMLCHAR) * 0xFFFF, &m_pCharTable))) - { - goto Exit; - } - - for (FLMUINT uiLoop = 0; charTbl[uiLoop].ui16Flag; uiLoop++) - { - setCharFlag( charTbl[uiLoop].uLowChar, - charTbl[uiLoop].uHighChar, - charTbl[uiLoop].ui16Flag); - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Returns TRUE if the character is a valid XML PubID character -****************************************************************************/ -FLMBOOL F_XML::isPubidChar( - FLMUNICODE uChar) -{ - if( uChar == FLM_UNICODE_SPACE || - uChar == FLM_UNICODE_LINEFEED || - (uChar >= FLM_UNICODE_a && uChar <= FLM_UNICODE_z) || - (uChar >= FLM_UNICODE_A && uChar <= FLM_UNICODE_Z) || - (uChar >= FLM_UNICODE_0 && uChar <= FLM_UNICODE_9) || - uChar == FLM_UNICODE_HYPHEN || - uChar == FLM_UNICODE_APOS || - uChar == FLM_UNICODE_LPAREN || - uChar == FLM_UNICODE_RPAREN || - uChar == FLM_UNICODE_PLUS || - uChar == FLM_UNICODE_COMMA || - uChar == FLM_UNICODE_PERIOD || - uChar == FLM_UNICODE_FSLASH || - uChar == FLM_UNICODE_COLON || - uChar == FLM_UNICODE_EQ || - uChar == FLM_UNICODE_QUEST || - uChar == FLM_UNICODE_SEMI || - uChar == FLM_UNICODE_BANG || - uChar == FLM_UNICODE_ASTERISK || - uChar == FLM_UNICODE_POUND || - uChar == FLM_UNICODE_ATSIGN || - uChar == FLM_UNICODE_DOLLAR || - uChar == FLM_UNICODE_UNDERSCORE || - uChar == FLM_UNICODE_PERCENT) - { - return( TRUE); - } - - return( FALSE); -} - -/**************************************************************************** -Desc: Returns TRUE if the character is a single or double quote character -****************************************************************************/ -FLMBOOL F_XML::isQuoteChar( - FLMUNICODE uChar) -{ - if( uChar == FLM_UNICODE_QUOTE || uChar == FLM_UNICODE_APOS) - { - return( TRUE); - } - - return( FALSE); -} - -/**************************************************************************** -Desc: Returns TRUE if the character is a whitespace character -****************************************************************************/ -FLMBOOL F_XML::isWhitespace( - FLMUNICODE uChar) -{ - if( (m_pCharTable[ uChar].ucFlags & FLM_XML_WHITESPACE) != 0) - { - return( TRUE); - } - - return( FALSE); -} - -/**************************************************************************** -Desc: Returns TRUE if the character is an extender character -****************************************************************************/ -FLMBOOL F_XML::isExtender( - FLMUNICODE uChar) -{ - if( (m_pCharTable[ uChar].ucFlags & FLM_XML_EXTENDER) != 0) - { - return( TRUE); - } - - return( FALSE); -} - -/**************************************************************************** -Desc: Returns TRUE if the character is a combining character -****************************************************************************/ -FLMBOOL F_XML::isCombiningChar( - FLMUNICODE uChar) -{ - if( (m_pCharTable[ uChar].ucFlags & FLM_XML_COMBINING_CHAR) != 0) - { - return( TRUE); - } - - return( FALSE); -} - -/**************************************************************************** -Desc: Returns TRUE if the character is a valid XML naming character -****************************************************************************/ -FLMBOOL F_XML::isNCNameChar( - FLMUNICODE uChar) -{ - if( isLetter( uChar) || - isDigit( uChar) || - uChar == FLM_UNICODE_PERIOD || - uChar == FLM_UNICODE_HYPHEN || - uChar == FLM_UNICODE_UNDERSCORE || - isCombiningChar( uChar) || isExtender( uChar)) - { - return( TRUE); - } - - return( FALSE); -} - -/**************************************************************************** -Desc: Returns TRUE if the character is a valid XML naming character -****************************************************************************/ -FLMBOOL F_XML::isNameChar( - FLMUNICODE uChar) -{ - if( isNCNameChar( uChar) || - uChar == FLM_UNICODE_COLON) - { - return( TRUE); - } - - return( FALSE); -} - -/**************************************************************************** -Desc: Returns TRUE if the character is an ideographic character -****************************************************************************/ -FLMBOOL F_XML::isIdeographic( - FLMUNICODE uChar) -{ - if( (m_pCharTable[ uChar].ucFlags & FLM_XML_IDEOGRAPHIC) != 0) - { - return( TRUE); - } - - return( FALSE); -} - -/**************************************************************************** -Desc: Returns TRUE if the character is a base character -****************************************************************************/ -FLMBOOL F_XML::isBaseChar( - FLMUNICODE uChar) -{ - if( (m_pCharTable[ uChar].ucFlags & FLM_XML_BASE_CHAR) != 0) - { - return( TRUE); - } - - return( FALSE); -} - -/**************************************************************************** -Desc: Returns TRUE if the character is a digit -****************************************************************************/ -FLMBOOL F_XML::isDigit( - FLMUNICODE uChar) -{ - if( (m_pCharTable[ uChar].ucFlags & FLM_XML_DIGIT) != 0) - { - return( TRUE); - } - - return( FALSE); -} - -/**************************************************************************** -Desc: Returns TRUE if the character is a letter -****************************************************************************/ -FLMBOOL F_XML::isLetter( - FLMUNICODE uChar) -{ - if( isBaseChar( uChar) || isIdeographic( uChar)) - { - return( TRUE); - } - - return( FALSE); -} - -/**************************************************************************** -Desc: Returns TRUE if the name is a valid XML name -****************************************************************************/ -FLMBOOL F_XML::isNameValid( - FLMUNICODE * puzName, - FLMBYTE * pszName) -{ - FLMBOOL bValid = FALSE; - - if( puzName) - { - FLMUNICODE * puzTmp; - - if( !isLetter( *puzName) && *puzName != FLM_UNICODE_UNDERSCORE && - *puzName != FLM_UNICODE_COLON) - { - goto Exit; - } - - puzTmp = &puzName[ 1]; - while( *puzTmp) - { - if( !isNameChar( *puzTmp)) - { - goto Exit; - } - puzTmp++; - } - } - - if( pszName) - { - FLMBYTE * pszTmp; - - if( !isLetter( *pszName) && *pszName != FLM_UNICODE_UNDERSCORE && - *pszName != FLM_UNICODE_COLON) - { - goto Exit; - } - - pszTmp = &pszName[ 1]; - while( *pszTmp) - { - if( !isNameChar( *pszTmp)) - { - goto Exit; - } - pszTmp++; - } - } - - bValid = TRUE; - -Exit: - - return( bValid); -} - /**************************************************************************** Desc: Constructor ****************************************************************************/ @@ -791,8 +118,8 @@ F_XMLImport::F_XMLImport() m_bSetup = FALSE; m_fnStatus = NULL; m_pvCallbackData = NULL; - m_tmpPool.poolInit( 4096); - m_attrPool.poolInit( 4096); + m_pTmpPool = NULL; + m_pAttrPool = NULL; m_puzCurrLineBuf = NULL; m_uiCurrLineBufMaxChars = 0; reset(); @@ -809,10 +136,21 @@ F_XMLImport::~F_XMLImport() { f_free( &m_pucValBuf); } - if (m_puzCurrLineBuf) + + if( m_puzCurrLineBuf) { f_free( &m_puzCurrLineBuf); } + + if( m_pTmpPool) + { + m_pTmpPool->Release(); + } + + if( m_pAttrPool) + { + m_pAttrPool->Release(); + } } /**************************************************************************** @@ -832,9 +170,13 @@ void F_XMLImport::reset( void) m_pDb = NULL; m_uiCollection = 0; f_memset( &m_importStats, 0, sizeof( XFLM_IMPORT_STATS)); - popNamespaces( getNamespaceCount()); - m_tmpPool.poolReset( NULL); + + if( m_pTmpPool) + { + m_pTmpPool->poolReset( NULL); + } + resetAttrList(); } @@ -852,11 +194,19 @@ RCODE F_XMLImport::setup( void) goto Exit; } - if( RC_BAD( rc = buildCharTable())) + if( RC_BAD( rc = FlmAllocPool( &m_pTmpPool))) { goto Exit; } + m_pTmpPool->poolInit( 4096); + + if( RC_BAD( rc = FlmAllocPool( &m_pAttrPool))) + { + goto Exit; + } + + m_pAttrPool->poolInit( 4096); m_bSetup = TRUE; Exit: @@ -877,7 +227,7 @@ Exit: Desc: Reads data from the input stream and builds a FLAIM record ****************************************************************************/ RCODE F_XMLImport::import( - F_IStream * pStream, + IF_IStream * pStream, F_Db * pDb, FLMUINT uiCollection, FLMUINT uiFlags, @@ -1331,7 +681,7 @@ RCODE F_XMLImport::processElement( { break; } - else if( isNameChar( peekChar())) + else if( gv_XFlmSysData.pXml->isNameChar( peekChar())) { // Unget the "<" - because processElement expect to see @@ -1392,7 +742,7 @@ RCODE F_XMLImport::processElement( { if( m_uiFlags & FLM_XML_COMPRESS_WHITESPACE_FLAG) { - if( isWhitespace( uChar)) + if( gv_XFlmSysData.pXml->isWhitespace( uChar)) { // If uiOffset is zero, this is still leading // white space, and we should ignore it. @@ -1603,7 +953,7 @@ RCODE F_XMLImport::processSTag( FLMUNICODE * puzLocal = NULL; FLMUINT uiNameId; FLMUINT uiAllocSize; - void * pvMark = m_tmpPool.poolMark(); + void * pvMark = m_pTmpPool->poolMark(); RCODE rc = NE_XFLM_OK; FLMBOOL bNamespaceDecl; FLMUINT uiSavedLineNum; @@ -1648,7 +998,7 @@ RCODE F_XMLImport::processSTag( } uiAllocSize = (f_unilen( puzTmpLocal) + 1) * sizeof( FLMUNICODE); - if( RC_BAD( rc = m_tmpPool.poolAlloc( uiAllocSize, (void **)&puzLocal))) + if( RC_BAD( rc = m_pTmpPool->poolAlloc( uiAllocSize, (void **)&puzLocal))) { goto Exit; } @@ -1661,7 +1011,7 @@ RCODE F_XMLImport::processSTag( // continues, the scratch buffer will be overwritten uiAllocSize = (f_unilen( puzTmpPrefix) + 1) * sizeof( FLMUNICODE); - if( RC_BAD( rc = m_tmpPool.poolAlloc( uiAllocSize, (void **)&puzPrefix))) + if( RC_BAD( rc = m_pTmpPool->poolAlloc( uiAllocSize, (void **)&puzPrefix))) { goto Exit; } @@ -1834,7 +1184,7 @@ Exit: pNamespace->Release(); } - m_tmpPool.poolReset( pvMark); + m_pTmpPool->poolReset( pvMark); return( rc); } @@ -1863,7 +1213,7 @@ RCODE F_XMLImport::processAttributeList( void) { goto Exit; } - if( !isNameChar( peekChar())) + if( !gv_XFlmSysData.pXml->isNameChar( peekChar())) { break; } @@ -2050,7 +1400,7 @@ RCODE F_XMLImport::processXMLDecl( void) } uChar = peekChar(); - if (!uChar || isWhitespace( uChar)) + if (!uChar || gv_XFlmSysData.pXml->isWhitespace( uChar)) { if (RC_BAD( rc = skipWhitespace( FALSE))) { @@ -2069,7 +1419,7 @@ RCODE F_XMLImport::processXMLDecl( void) goto Exit; } uChar = peekChar(); - if (!uChar || isWhitespace( uChar)) + if (!uChar || gv_XFlmSysData.pXml->isWhitespace( uChar)) { if (RC_BAD( rc = skipWhitespace( FALSE))) { @@ -2133,7 +1483,7 @@ RCODE F_XMLImport::processDocTypeDecl( void) } uChar = peekChar(); - if (!uChar || isWhitespace( uChar)) + if (!uChar || gv_XFlmSysData.pXml->isWhitespace( uChar)) { if( RC_BAD( rc = skipWhitespace( FALSE))) { @@ -2189,7 +1539,7 @@ RCODE F_XMLImport::processDocTypeDecl( void) } break; } - else if (isWhitespace( uChar)) + else if (gv_XFlmSysData.pXml->isWhitespace( uChar)) { if( RC_BAD( rc = skipWhitespace( FALSE))) { @@ -2387,7 +1737,7 @@ RCODE F_XMLImport::processAttListDecl( void) { uChar = peekChar(); - if (!uChar || isWhitespace( uChar)) + if (!uChar || gv_XFlmSysData.pXml->isWhitespace( uChar)) { if (RC_BAD( rc = skipWhitespace( FALSE))) { @@ -2481,7 +1831,7 @@ RCODE F_XMLImport::processEntityDecl( void) } uChar = peekChar(); - if( isQuoteChar( uChar)) + if( gv_XFlmSysData.pXml->isQuoteChar( uChar)) { if( RC_BAD( rc = processEntityValue())) { @@ -2513,7 +1863,7 @@ RCODE F_XMLImport::processEntityDecl( void) goto Process_GT; } - if (!isWhitespace( peekChar())) + if (!gv_XFlmSysData.pXml->isWhitespace( peekChar())) { goto Process_GT; } @@ -2927,7 +2277,7 @@ RCODE F_XMLImport::processDefaultDecl( void) goto Exit; } } - else if (isQuoteChar( uChar)) + else if (gv_XFlmSysData.pXml->isQuoteChar( uChar)) { ungetChar(); @@ -3194,7 +2544,7 @@ RCODE F_XMLImport::processMisc( void) { if( RC_BAD( rc = skipWhitespace( FALSE))) { - if( rc == NE_XFLM_IO_END_OF_FILE || rc == NE_XFLM_EOF_HIT) + if( rc == NE_FLM_IO_END_OF_FILE || rc == NE_XFLM_EOF_HIT) { rc = NE_XFLM_OK; } @@ -3356,7 +2706,7 @@ RCODE F_XMLImport::getName( uChar = getChar(); - if( !isLetter( uChar) && uChar != FLM_UNICODE_UNDERSCORE) + if( !gv_XFlmSysData.pXml->isLetter( uChar) && uChar != FLM_UNICODE_UNDERSCORE) { setErrInfo( m_uiCurrLineNum, m_uiCurrLineOffset - 1, @@ -3377,7 +2727,7 @@ RCODE F_XMLImport::getName( { break; } - if (!isNameChar( uChar)) + if (!gv_XFlmSysData.pXml->isNameChar( uChar)) { ungetChar(); break; @@ -3432,7 +2782,7 @@ RCODE F_XMLImport::getQualifiedName( uChar = getChar(); - if( !isLetter( uChar) && uChar != FLM_UNICODE_UNDERSCORE) + if( !gv_XFlmSysData.pXml->isLetter( uChar) && uChar != FLM_UNICODE_UNDERSCORE) { setErrInfo( m_uiCurrLineNum, m_uiCurrLineOffset - 1, @@ -3450,7 +2800,7 @@ RCODE F_XMLImport::getQualifiedName( { break; } - if (!isNameChar( uChar)) + if (!gv_XFlmSysData.pXml->isNameChar( uChar)) { ungetChar(); break; @@ -3532,7 +2882,7 @@ void F_XMLImport::getNmtoken( break; } - if( !isNameChar( uChar)) + if( !gv_XFlmSysData.pXml->isNameChar( uChar)) { ungetChar(); break; @@ -3962,7 +3312,7 @@ RCODE F_XMLImport::processEntityValue( void) // Caller should already have looked to make sure the // character is a quote character. - flmAssert( isQuoteChar( uQuoteChar)); + flmAssert( gv_XFlmSysData.pXml->isQuoteChar( uQuoteChar)); for( ;;) { @@ -4253,7 +3603,7 @@ RCODE F_XMLImport::processAttValue( // Must be on a single or double quote uQuoteChar = getChar(); - if (!isQuoteChar( uQuoteChar)) + if (!gv_XFlmSysData.pXml->isQuoteChar( uQuoteChar)) { setErrInfo( m_uiCurrLineNum, m_uiCurrLineOffset - 1, @@ -4335,7 +3685,7 @@ RCODE F_XMLImport::getSystemLiteral( void) uQuoteChar = getChar(); - if (!isQuoteChar( uQuoteChar)) + if (!gv_XFlmSysData.pXml->isQuoteChar( uQuoteChar)) { setErrInfo( m_uiCurrLineNum, m_uiCurrLineOffset - 1, @@ -4384,7 +3734,7 @@ RCODE F_XMLImport::getPubidLiteral( void) uQuoteChar = getChar(); - if (!isQuoteChar( uQuoteChar)) + if (!gv_XFlmSysData.pXml->isQuoteChar( uQuoteChar)) { setErrInfo( m_uiCurrLineNum, m_uiCurrLineOffset - 1, @@ -4415,7 +3765,7 @@ RCODE F_XMLImport::getPubidLiteral( void) { break; } - if( !isPubidChar( uChar)) + if( !gv_XFlmSysData.pXml->isPubidChar( uChar)) { setErrInfo( m_uiCurrLineNum, m_uiCurrLineOffset - 1, @@ -4619,7 +3969,7 @@ RCODE F_XMLImport::skipWhitespace( continue; } - if( !isWhitespace( uChar)) + if( !gv_XFlmSysData.pXml->isWhitespace( uChar)) { ungetChar(); break; @@ -5421,7 +4771,7 @@ class F_Attribute; /***************************************************************************** Desc: Keeps track of an attribute that we are going to output *****************************************************************************/ -class F_Attribute : public XF_Base +class F_Attribute : public F_Object { public: F_Attribute( @@ -5495,7 +4845,7 @@ F_Attribute::~F_Attribute() /***************************************************************************** Desc: Keeps track of an element that we are going to output *****************************************************************************/ -class F_Element : public XF_Base +class F_Element : public F_Object { public: F_Element( @@ -6728,7 +6078,7 @@ Exit: Desc: Outputs a UTF8 stream of XML, starting at the specified node. Node and all of its descendant nodes are output. *****************************************************************************/ -RCODE XFLMAPI F_Db::exportXML( +RCODE FLMAPI F_Db::exportXML( IF_DOMNode * pStartNode, IF_OStream * pOStream, eExportFormatType eFormatType) diff --git a/xflaim/src/fxml.h b/xflaim/src/fxml.h index 7b4b73a..6302e54 100644 --- a/xflaim/src/fxml.h +++ b/xflaim/src/fxml.h @@ -26,72 +26,10 @@ #ifndef FXML_H #define FXML_H -typedef struct xmlChar -{ - FLMBYTE ucFlags; -} XMLCHAR; - -class F_XML : public XF_RefCount, public virtual XF_Base -{ -public: - - F_XML(); - - ~F_XML(); - - FLMBOOL isPubidChar( - FLMUNICODE uChar); - - FLMBOOL isQuoteChar( - FLMUNICODE uChar); - - FLMBOOL isWhitespace( - FLMUNICODE uChar); - - FLMBOOL isExtender( - FLMUNICODE uChar); - - FLMBOOL isCombiningChar( - FLMUNICODE uChar); - - FLMBOOL isNameChar( - FLMUNICODE uChar); - - FLMBOOL isNCNameChar( - FLMUNICODE uChar); - - FLMBOOL isIdeographic( - FLMUNICODE uChar); - - FLMBOOL isBaseChar( - FLMUNICODE uChar); - - FLMBOOL isDigit( - FLMUNICODE uChar); - - FLMBOOL isLetter( - FLMUNICODE uChar); - - void setCharFlag( - FLMUNICODE uLowChar, - FLMUNICODE uHighChar, - FLMUINT16 ui16Flag); - - FLMBOOL isNameValid( - FLMUNICODE * puzName, - FLMBYTE * pszName); - - RCODE buildCharTable( void); - -private: - - XMLCHAR * m_pCharTable; -}; - /*============================================================================ Desc: FLAIM's XML namespace class ============================================================================*/ -class F_XMLNamespace : public XF_RefCount, public XF_Base +class F_XMLNamespace : public F_Object { public: @@ -150,7 +88,7 @@ friend class F_XMLNamespaceMgr; /*============================================================================ Desc: Namespace manager class ============================================================================*/ -class F_XMLNamespaceMgr : public XF_RefCount, public virtual XF_Base +class F_XMLNamespaceMgr : public F_Object { public: @@ -203,7 +141,7 @@ typedef RCODE (* XML_STATUS_HOOK)( /*============================================================================ Desc: FLAIM's XML import class ============================================================================*/ -class F_XMLImport: public F_XML, public F_XMLNamespaceMgr +class F_XMLImport : public F_XMLNamespaceMgr { public: @@ -216,7 +154,7 @@ public: void reset( void); RCODE import( - F_IStream * pStream, + IF_IStream * pStream, F_Db * pDb, FLMUINT uiCollection, FLMUINT uiFlags, @@ -454,7 +392,11 @@ private: { m_pFirstAttr = NULL; m_pLastAttr = NULL; - m_attrPool.poolReset( NULL); + + if( m_pAttrPool) + { + m_pAttrPool->poolReset( NULL); + } } RCODE allocAttribute( @@ -463,7 +405,7 @@ private: XML_ATTR * pAttr = NULL; RCODE rc = NE_XFLM_OK; - if( RC_BAD( rc = m_attrPool.poolCalloc( + if( RC_BAD( rc = m_pAttrPool->poolCalloc( sizeof( XML_ATTR), (void **)&pAttr))) { goto Exit; @@ -501,7 +443,7 @@ private: uiStrLen = f_unilen( puzPrefix); - if( RC_BAD( rc = m_attrPool.poolAlloc( + if( RC_BAD( rc = m_pAttrPool->poolAlloc( sizeof( FLMUNICODE) * (uiStrLen + 1), (void **)&pAttr->puzPrefix))) { goto Exit; @@ -530,7 +472,7 @@ private: uiStrLen = f_unilen( puzLocalName); - if( RC_BAD( rc = m_attrPool.poolAlloc( + if( RC_BAD( rc = m_pAttrPool->poolAlloc( sizeof( FLMUNICODE) * (uiStrLen + 1), (void **)&pAttr->puzLocalName))) { @@ -560,7 +502,7 @@ private: uiStrLen = f_unilen( puzUnicode); - if( RC_BAD( rc = m_attrPool.poolAlloc( + if( RC_BAD( rc = m_pAttrPool->poolAlloc( sizeof( FLMUNICODE) * (uiStrLen + 1), (void **)&pAttr->puzVal))) { @@ -607,7 +549,7 @@ private: #define FLM_XML_MAX_CHARS 128 FLMUNICODE m_uChars[ FLM_XML_MAX_CHARS]; FLMBOOL m_bSetup; - F_IStream * m_pStream; + IF_IStream * m_pStream; FLMBYTE * m_pucValBuf; FLMUINT m_uiValBufSize; // Number of Unicode characters FLMUINT m_uiFlags; @@ -616,13 +558,13 @@ private: XML_STATUS_HOOK m_fnStatus; void * m_pvCallbackData; XFLM_IMPORT_STATS m_importStats; - F_Pool m_tmpPool; + IF_Pool * m_pTmpPool; // Attribute management XML_ATTR * m_pFirstAttr; XML_ATTR * m_pLastAttr; - F_Pool m_attrPool; + IF_Pool * m_pAttrPool; }; #define FLM_XML_EXTEND_DICT_FLAG 0x00000001 diff --git a/xflaim/src/fxpath.cpp b/xflaim/src/fxpath.cpp index af2e849..1ef3155 100644 --- a/xflaim/src/fxpath.cpp +++ b/xflaim/src/fxpath.cpp @@ -96,7 +96,7 @@ RCODE F_XPathTokenizer::getChar( } else { - if( RC_BAD( rc = flmReadUTF8CharAsUnicode( m_pIStream, puChar))) + if( RC_BAD( rc = f_readUTF8CharAsUnicode( m_pIStream, puChar))) { if( rc != NE_XFLM_EOF_HIT) { @@ -129,7 +129,7 @@ RCODE F_XPathTokenizer::peekChar( } else { - if( RC_BAD( rc = flmReadUTF8CharAsUnicode( m_pIStream, puChar))) + if( RC_BAD( rc = f_readUTF8CharAsUnicode( m_pIStream, puChar))) { if( rc == NE_XFLM_EOF_HIT) { @@ -1626,7 +1626,7 @@ Exit: /*************************************************************************** Desc: Class for handling query validator calls ***************************************************************************/ -class XFLAIM_QueryValFunc : public IF_QueryValFunc, public XF_Base +class XFLAIM_QueryValFunc : public IF_QueryValFunc { public: @@ -1638,7 +1638,7 @@ public: { } - RCODE XFLMAPI getValue( + RCODE FLMAPI getValue( IF_Db * pDb, IF_DOMNode * pContextNode, ValIterator eValueToGet, @@ -1647,7 +1647,7 @@ public: void * pvVal, IF_DynaBuf * pDynaBuf = NULL); - RCODE XFLMAPI cloneSelf( + RCODE FLMAPI cloneSelf( IF_QueryValFunc ** ppNewObj); }; @@ -1656,7 +1656,7 @@ Desc: Get the next value for a query function. Since this is really just code to test the callback, it always returns a value whose type is boolean and whose value is true. ****************************************************************************/ -RCODE XFLMAPI XFLAIM_QueryValFunc::getValue( +RCODE FLMAPI XFLAIM_QueryValFunc::getValue( IF_Db *, // pDb, IF_DOMNode *, // pContextNode, ValIterator eValueToGet, @@ -1692,7 +1692,7 @@ Exit: /**************************************************************************** Desc: Copy self to create a new object. ****************************************************************************/ -RCODE XFLMAPI XFLAIM_QueryValFunc::cloneSelf( +RCODE FLMAPI XFLAIM_QueryValFunc::cloneSelf( IF_QueryValFunc ** ppNewObj) { @@ -2443,21 +2443,32 @@ RCODE F_XPath::parseQuery( char * pszQuery, IF_Query * pQuery) { - RCODE rc = NE_XFLM_OK; - F_BufferIStream istream; - - if( RC_BAD( rc= istream.open( (FLMBYTE *)pszQuery, f_strlen( pszQuery)))) + RCODE rc = NE_XFLM_OK; + IF_BufferIStream * pBufferStream; + + if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferStream))) { goto Exit; } - if( RC_BAD( rc = parseQuery( pDb, &istream, pQuery))) + if( RC_BAD( rc = pBufferStream->open( + (const char *)pszQuery, f_strlen( pszQuery)))) + { + goto Exit; + } + + if( RC_BAD( rc = parseQuery( pDb, pBufferStream, pQuery))) { goto Exit; } Exit: + if( pBufferStream) + { + pBufferStream->Release(); + } + return( rc); } diff --git a/xflaim/src/fxpath.h b/xflaim/src/fxpath.h index 5dc7893..eec0a31 100644 --- a/xflaim/src/fxpath.h +++ b/xflaim/src/fxpath.h @@ -119,7 +119,7 @@ typedef enum END_TOKEN // 88 } eXPathTokenType; -class F_XPathBase : public virtual XF_Base +class F_XPathBase : public F_Object { public: diff --git a/xflaim/src/inifile.cpp b/xflaim/src/inifile.cpp deleted file mode 100644 index 2475954..0000000 --- a/xflaim/src/inifile.cpp +++ /dev/null @@ -1,1082 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Class to support reading/writing/parsing .ini files -// -// Tabs: 3 -// -// Copyright (c) 2002-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: inifile.cpp 3115 2006-01-19 13:24:39 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "xflaim.h" -#include "flaimsys.h" -#include "inifile.h" - -/**************************************************************************** -Desc: -****************************************************************************/ -F_IniFile::F_IniFile() -{ - m_pFirstLine = NULL; - m_pLastLine = NULL; - m_bReady = FALSE; - m_bModified = FALSE; - m_pszFileName = NULL; - m_pFile = NULL; - m_pPool = NULL; -} - -/**************************************************************************** -Desc: -****************************************************************************/ -F_IniFile::~F_IniFile() -{ - if( m_pszFileName) - { - f_free( &m_pszFileName); - } - - if( m_pPool) - { - m_pPool->Release(); - } - - if( m_pFile) - { - m_pFile->Release(); - } -} - -/**************************************************************************** -Desc: -****************************************************************************/ -RCODE F_IniFile::Init() -{ - RCODE rc = NE_XFLM_OK; - - if( m_pPool) - { - m_pPool->Release(); - } - - if (( m_pPool = f_new F_Pool) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - - m_pPool->poolInit( 512); - m_pFirstLine = NULL; - m_pLastLine = NULL; - m_bReady = TRUE; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Read the ini file and parse its contents -****************************************************************************/ -RCODE F_IniFile::Read( - char * pszFileName - ) -{ - RCODE rc = NE_XFLM_OK; - FLMBOOL bMore = FALSE; - FLMBOOL bEOF = FALSE; -#define INITIAL_READ_BUF_SIZE 100 - FLMUINT uiReadBufSize = 0; - FLMUINT uiBytesAvail = 0; - FLMUINT uiBytesInLine = 0; - char * pszReadBuf = NULL; - FLMUINT uiLineNum = 0; - - flmAssert( m_bReady); - flmAssert( !m_pFile); - - // Open the file - - if (RC_BAD( rc = f_alloc( f_strlen( pszFileName) + 1, &m_pszFileName))) - { - goto Exit; - } - - f_strcpy( m_pszFileName, pszFileName); - - // It's not an error if the file doesn't exist. If it does exist, - // we'll read in its data. - - if( RC_BAD( gv_pFileSystem->Open( pszFileName, - XFLM_IO_RDONLY, &m_pFile))) - { - goto Exit; - } - - m_uiFileOffset = 0; - - // Read in and parse the file - - uiReadBufSize = INITIAL_READ_BUF_SIZE; - if (RC_BAD( rc = f_alloc( uiReadBufSize, &pszReadBuf))) - { - goto Exit; - } - - // Read in and parse each line in the file... - while (!bEOF) - { - uiLineNum++; - - uiBytesAvail = uiReadBufSize; - if( RC_BAD( rc = readLine( pszReadBuf, &uiBytesAvail, &bMore)) && - rc != NE_XFLM_IO_END_OF_FILE) - { - goto Exit; - } - - if (rc == NE_XFLM_IO_END_OF_FILE) - { - bEOF = TRUE; - } - - // While there are more bytes in the line, re-alloc the buffer, and do - // another read. - - uiBytesInLine = uiBytesAvail; - while( bMore) - { - uiBytesAvail = uiReadBufSize; - uiReadBufSize *= 2; - - if (RC_BAD( rc = f_realloc( uiReadBufSize, &pszReadBuf))) - { - goto Exit; - } - - if (RC_BAD( rc = readLine( pszReadBuf+uiBytesAvail, - &uiBytesAvail, &bMore)) && - (rc != NE_XFLM_IO_END_OF_FILE) ) - { - goto Exit; - } - - if( rc == NE_XFLM_IO_END_OF_FILE) - { - bEOF = TRUE; - } - uiBytesInLine += uiBytesAvail; - } - - if ( (RC_OK( rc) || (rc == NE_XFLM_IO_END_OF_FILE)) && - (uiBytesInLine > 0) ) - { - // NumBytes will be 0 if the line was blank. No need - // to call parseBuffer in this case - if (RC_BAD( rc = parseBuffer( pszReadBuf, uiBytesInLine))) - { - if (rc == NE_XFLM_SYNTAX) - { - rc = NE_XFLM_OK; - } - else - { - goto Exit; - } - } - } - } // end of while (!bEOF) - -Exit: - - // Close the file - - if( m_pFile) - { - m_pFile->Close(); - m_pFile->Release(); - m_pFile = NULL; - } - - // Free the buffer - - if (pszReadBuf) - { - f_free( &pszReadBuf); - } - - if (rc == NE_XFLM_IO_END_OF_FILE) - { - rc = NE_XFLM_OK; - } - - return rc; -} - -/**************************************************************************** -Desc: Copies the data stored in the INI_LINE structs to the ini file -****************************************************************************/ -RCODE F_IniFile::Write() -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiBytesWritten; - INI_LINE * pCurLine = NULL; - FLMBOOL uiFileOffset = 0; - - flmAssert( m_bReady); - - if (!m_bModified) - { - // Nothing needs to be written - goto Exit; - } - - // Open the file - - flmAssert( !m_pFile); - - if (RC_BAD( rc = gv_pFileSystem->Create( m_pszFileName, - XFLM_IO_RDWR, &m_pFile))) - { - goto Exit; - } - - pCurLine = m_pFirstLine; - while (pCurLine) - { - if (pCurLine->pszParamName) - { - // Output the param name - if (RC_BAD (rc = m_pFile->Write( uiFileOffset, - f_strlen( pCurLine->pszParamName), - pCurLine->pszParamName, - &uiBytesWritten))) - { - goto Exit; - } - uiFileOffset += uiBytesWritten; - - if (pCurLine->pszParamValue) - { - // Output the "=" and the value - if (RC_BAD (rc = m_pFile->Write( uiFileOffset, 1, - (void *)"=", &uiBytesWritten))) - { - goto Exit; - } - - uiFileOffset += uiBytesWritten; - - if (RC_BAD (rc = m_pFile->Write( uiFileOffset, - f_strlen( pCurLine->pszParamValue), - pCurLine->pszParamValue, - &uiBytesWritten))) - { - goto Exit; - } - uiFileOffset += uiBytesWritten; - } - } - - - if (pCurLine->pszComment) - { - // Output the comment - if (pCurLine->pszParamName) - { - if (RC_BAD (rc = m_pFile->Write( uiFileOffset, 2, - (void *)" #", &uiBytesWritten))) - { - goto Exit; - } - } - else - { - if (RC_BAD (rc = m_pFile->Write( uiFileOffset, 1, - (void *)"#", &uiBytesWritten))) - { - goto Exit; - } - } - - uiFileOffset += uiBytesWritten; - - if (RC_BAD (rc = m_pFile->Write( uiFileOffset, - f_strlen( pCurLine->pszComment), - pCurLine->pszComment, - &uiBytesWritten))) - { - goto Exit; - } - - uiFileOffset += uiBytesWritten; - - } - - // Write out a newline... - if (RC_BAD (rc = m_pFile->Write( uiFileOffset, f_strlen( "\n"), - (void *)"\n", &uiBytesWritten))) - { - goto Exit; - } - - uiFileOffset += uiBytesWritten; - - pCurLine = pCurLine->pNext; - - } // end for loop - - // The contents of disk now represent the the structs in memory, - // so reset the bModified flag - m_bModified = FALSE; - -Exit: - // Close the file - if (m_pFile) - { - m_pFile->Close(); - m_pFile->Release(); - m_pFile = NULL; - } - - return rc; -} - -/**************************************************************************** -Desc: Retrieves the value associated with the specified name from the list - of INI_STRUCTs -****************************************************************************/ -FLMBOOL F_IniFile::GetParam( - const char * pszParamName, - FLMUINT * puiParamVal) -{ - FLMBOOL bFound = FALSE; - INI_LINE * pLine = NULL; - - flmAssert( m_bReady); - - pLine = findParam( pszParamName); - if( !pLine) - { - goto Exit; - } - - if( !pLine->pszParamValue) - { - goto Exit; - } - - fromAscii( puiParamVal, pLine->pszParamValue); - bFound = TRUE; - -Exit: - - return( bFound); -} - -/**************************************************************************** -Desc: Stores a new value for the specified name (or creates a new name/value - pair) in the list of INI_STRUCTs -****************************************************************************/ -RCODE F_IniFile::SetParam( - const char * pszParamName, - FLMUINT uiParamVal) -{ - RCODE rc = NE_XFLM_OK; - INI_LINE * pLine; - - flmAssert( m_bReady); - - // If the parameter exists in the list, just store the new value. - // Othewise, create a new INI_LINE and add it to the list - - pLine = findParam( pszParamName); - if( !pLine) - { - if (RC_BAD( rc = setParamCommon( &pLine, pszParamName))) - { - goto Exit; - } - } - - if( RC_BAD( rc = toAscii( &pLine->pszParamValue, uiParamVal))) - { - goto Exit; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Retrieves the value associated with the specified name from the list - of INI_STRUCTs -****************************************************************************/ -FLMBOOL F_IniFile::GetParam( - const char * pszParamName, - FLMBOOL * pbParamVal) // Out: The value associated with name -{ - FLMBOOL bFound = FALSE; - INI_LINE * pLine = NULL; - - flmAssert( m_bReady); - - pLine = findParam( pszParamName); - - if( !pLine) - { - goto Exit; - } - - if( !pLine->pszParamValue) - { - goto Exit; - } - - fromAscii( pbParamVal, pLine->pszParamValue); - bFound = TRUE; - -Exit: - - return( bFound); -} - -/**************************************************************************** -Desc: Stores a new value for the specified name (or creates a new name/value - pair) in the list of INI_STRUCTs -****************************************************************************/ -RCODE F_IniFile::SetParam( - const char * pszParamName, - FLMBOOL bParamVal) -{ - RCODE rc = NE_XFLM_OK; - INI_LINE * pLine; - - flmAssert( m_bReady); - - // If the parameter exists in the list, just store the new value. - // Othewise, create a new INI_LINE and add it to the list - - pLine = findParam( pszParamName); - if( !pLine) - { - if (RC_BAD( rc = setParamCommon( &pLine, pszParamName))) - { - goto Exit; - } - } - - if( RC_BAD( rc = toAscii( &pLine->pszParamValue, bParamVal))) - { - goto Exit; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Retrieves the value associated with the specified name from the list - of INI_STRUCTs -****************************************************************************/ -FLMBOOL F_IniFile::GetParam( - const char * pszParamName, - char ** ppszParamVal) -{ - FLMBOOL bFound = FALSE; - INI_LINE * pLine = NULL; - - flmAssert( m_bReady); - *ppszParamVal = NULL; - - pLine = findParam( pszParamName); - - if( !pLine) - { - goto Exit; - } - - if( pLine->pszParamValue == NULL) - { - goto Exit; - } - - *ppszParamVal = pLine->pszParamValue; - bFound = TRUE; - -Exit: - - return( bFound); -} - -/**************************************************************************** -Desc: Stores a new value for the specified name (or creates a new name/value - pair) in the list of INI_STRUCTs -****************************************************************************/ -RCODE F_IniFile::SetParam( - const char * pszParamName, - const char * pszParamVal) -{ - RCODE rc = NE_XFLM_OK; - INI_LINE * pLine; - - flmAssert( m_bReady); - - // If the parameter exists in the list, just store the new value. - // Othewise, create a new INI_LINE and add it to the list - - pLine = findParam( pszParamName); - if( !pLine) - { - if( RC_BAD( rc = setParamCommon( &pLine, pszParamName))) - { - goto Exit; - } - } - - if( RC_BAD( rc = toAscii( &pLine->pszParamValue, pszParamVal))) - { - goto Exit; - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Read a line from the ini file and store it in pszBuf -****************************************************************************/ -RCODE F_IniFile::readLine( - char * pszBuf, - FLMUINT * puiBytes, - FLMBOOL * pbMore) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiBytesRead = 0; - FLMUINT uiBytesInLine = 0; - FLMUINT uiEOLBytes = 0; - FLMBOOL bEOL = FALSE; - - flmAssert( m_pFile); - - rc = m_pFile->Read( m_uiFileOffset, *puiBytes, - (FLMBYTE *)pszBuf, &uiBytesRead); - - if ( RC_OK( rc) || rc == NE_XFLM_IO_END_OF_FILE) - { - // Check to see if we got more than one line... - - while( !bEOL && (uiBytesInLine < uiBytesRead) ) - { - if( pszBuf[ uiBytesInLine] == 13 || pszBuf[ uiBytesInLine] == 10) - { - // NOTE: If we end up reading the first byte of a CR/LF pair, but - // but the second byte is read on the next call, then it will get - // counted as a new (but empty) line. We're not going to worry - // about it though, because empty lines end up getting ignored - // and this isn't likely to happen often enough to effect - // performance. - - bEOL = TRUE; - *puiBytes = uiBytesInLine; - uiEOLBytes=1; - - // Check for a CR/LF pair (or a LF/CR pair...) - - if( (uiBytesInLine + 1 < uiBytesRead) && - (pszBuf[ uiBytesInLine + 1] == 13 || - pszBuf[ uiBytesInLine + 1] == 10)) - { - uiEOLBytes++; - } - } - else - { - uiBytesInLine++; - } - } - - // Set the file position variable forward appropriately... - - m_uiFileOffset += uiBytesInLine + uiEOLBytes; - } - - // If we read in more than one line, then don't want to return - // NE_XFLM_IO_END_OF_FILE... - - if( rc == NE_XFLM_IO_END_OF_FILE && - (uiBytesInLine + uiEOLBytes) < uiBytesRead) - { - rc = NE_XFLM_OK; - } - - // Last step - update pbMore - - *pbMore = (bEOL || (uiBytesRead == 0)) - ? FALSE - : TRUE; - - return( rc); -} - -/**************************************************************************** -Desc: Parse a single line from the ini file into its name, value and comment - parts. -****************************************************************************/ -RCODE F_IniFile::parseBuffer( - char * pszBuf, - FLMUINT uiNumBytes) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiCurrentChar = 0; - char * pszNameStart = NULL; - char * pszNameEnd = NULL; - char * pszValStart = NULL; - char * pszValEnd = NULL; - char * pszCommentStart = NULL; - INI_LINE * pLine = NULL; - FLMUINT uiStrLen = 0; - - flmAssert( pszBuf); - flmAssert( uiNumBytes); - - // Start looking for the parameter name... - - while (uiCurrentChar < uiNumBytes) - { - if( !isWhiteSpace( pszBuf[uiCurrentChar])) - { - if (pszBuf[uiCurrentChar] == '#') - { - goto Comment; - } - else - { - pszNameStart = &pszBuf[uiCurrentChar]; - break; - } - } - uiCurrentChar++; - } - - // We've found a param name, now mark the end of it - // We determine the end by looking for whitespace or '=' - // or '#' - - while (uiCurrentChar < uiNumBytes) - { - if( isWhiteSpace( pszBuf[uiCurrentChar]) || - (pszBuf[uiCurrentChar] == '=') || - (pszBuf[uiCurrentChar] == '#')) - { - pszNameEnd = &pszBuf[uiCurrentChar-1]; - break; - } - - uiCurrentChar++; - } - - if( (uiCurrentChar == uiNumBytes) && - (pszNameEnd == NULL) ) - { - pszNameEnd = &pszBuf[uiCurrentChar - 1]; - } - - // Now, there may be a value part or a comment part next. If there's a - // value, it had better be preceeded by an '=' - - while( (uiCurrentChar < uiNumBytes) && - isWhiteSpace( pszBuf[uiCurrentChar]) ) - { - uiCurrentChar++; - } - - if( uiCurrentChar < uiNumBytes && pszBuf[ uiCurrentChar] == '#') - { - goto Comment; - } - - if( uiCurrentChar < uiNumBytes && pszBuf[uiCurrentChar] != '=' ) - { - rc = RC_SET( NE_XFLM_SYNTAX); - goto Exit; - } - - // Ok - at this point pszBuf[uiCurrentChar] contains an =. Skip over - // the = and any whitespace that follows. - - while( uiCurrentChar < uiNumBytes) - { - uiCurrentChar++; - if( !isWhiteSpace( pszBuf[uiCurrentChar])) - { - pszValStart = &pszBuf[uiCurrentChar]; - break; - } - } - - // Now mark the end of the value. - // We determine the end by looking for whitespace or '#' - - while( uiCurrentChar < uiNumBytes) - { - if( isWhiteSpace( pszBuf[uiCurrentChar]) || - (pszBuf[uiCurrentChar] == '#')) - { - pszValEnd = &pszBuf[uiCurrentChar-1]; - break; - } - uiCurrentChar++; - } - - if( uiCurrentChar == uiNumBytes && !pszValEnd) - { - pszValEnd = &pszBuf[uiCurrentChar-1]; - } - -Comment: - - // Check out the rest of the line to see if there's a comment - - while( uiCurrentChar < uiNumBytes) - { - if( !isWhiteSpace( pszBuf[ uiCurrentChar]) && - pszBuf[ uiCurrentChar] != '#') - { - rc = RC_SET( NE_XFLM_SYNTAX); - goto Exit; - } - else if( pszBuf[ uiCurrentChar] == '#') - { - // Comment found. Set pszCommentStart to the next char - - pszCommentStart = &pszBuf[uiCurrentChar+1]; - break; - } - uiCurrentChar++; - } - - // Done parsing. Now, assuming the line had any info in it, - // store all the strings... - - if( pszNameStart || pszCommentStart) - { - if( RC_BAD( rc = m_pPool->poolCalloc( sizeof( INI_LINE), - (void **)&pLine))) - { - goto Exit; - } - - if( pszNameStart) - { - uiStrLen = pszNameEnd - pszNameStart + 1; - if( RC_BAD( rc = m_pPool->poolAlloc( uiStrLen + 1, - (void **)&pLine->pszParamName))) - { - goto Exit; - } - - f_memcpy( pLine->pszParamName, pszNameStart, uiStrLen); - pLine->pszParamName[uiStrLen] = '\0'; - } - - if( pszValStart) - { - uiStrLen = pszValEnd - pszValStart + 1; - if( RC_BAD( rc = m_pPool->poolAlloc( uiStrLen + 1, - (void **)&pLine->pszParamValue))) - { - goto Exit; - } - - f_memcpy(pLine->pszParamValue, pszValStart, uiStrLen); - pLine->pszParamValue[uiStrLen] = '\0'; - } - - if (pszCommentStart) - { - uiStrLen = uiNumBytes-(pszCommentStart-pszBuf); - if (RC_BAD( rc = m_pPool->poolAlloc( uiStrLen + 1, - (void **)&pLine->pszComment))) - { - goto Exit; - } - - f_memcpy(pLine->pszComment, pszCommentStart, uiStrLen); - pLine->pszComment[uiStrLen] = '\0'; - } - - // Insert this struct into the linked list - - if( m_pLastLine) - { - m_pLastLine->pNext = pLine; - } - - pLine->pPrev = m_pLastLine; - pLine->pNext = NULL; - m_pLastLine = pLine; - - if( !m_pFirstLine) - { - m_pFirstLine = pLine; - } - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Search through the list of INI_STRUCTs for a particular name -****************************************************************************/ -INI_LINE * F_IniFile::findParam( - const char * pszParamName) -{ - INI_LINE * pCurLine = m_pFirstLine; - - while( pCurLine) - { - if (pCurLine->pszParamName) - { - if (f_strcmp( pszParamName, pCurLine->pszParamName) == 0) - { - return pCurLine; - } - } - - pCurLine = pCurLine->pNext; - } - - return( NULL); -} - -/**************************************************************************** -Desc: This code is common to all of the SetParam() functions -****************************************************************************/ -RCODE F_IniFile::setParamCommon( - INI_LINE ** ppLine, - const char * pszParamName) -{ - RCODE rc = NE_XFLM_OK; - INI_LINE * pLine; - - if( RC_BAD( rc = m_pPool->poolCalloc( - sizeof( INI_LINE), (void **)&pLine))) - { - goto Exit; - } - - if( m_pLastLine) - { - m_pLastLine->pNext = pLine; - } - - pLine->pPrev = m_pLastLine; - m_pLastLine = pLine; - - if( !m_pFirstLine) - { - m_pFirstLine = pLine; - } - - if( RC_BAD( rc = m_pPool->poolAlloc( f_strlen(pszParamName)+1, - (void **)&pLine->pszParamName))) - { - goto Exit; - } - - f_strcpy( pLine->pszParamName, pszParamName); - -Exit: - - if( RC_OK( rc)) - { - *ppLine = pLine; - } - - return( rc); -} - -/**************************************************************************** -Desc: All of the fromAscii() functions convert values stored in strings to - various native formats -****************************************************************************/ -void F_IniFile::fromAscii( - FLMUINT * puiVal, - const char * pszBuf) -{ - FLMUINT uiValue; - FLMBOOL bAllowHex = FALSE; - - if( *pszBuf == '0' && - (*(pszBuf + 1) == 'x' || *(pszBuf + 1) == 'X')) - { - pszBuf += 2; - bAllowHex = TRUE; - } - - uiValue = 0; - while( *pszBuf) - { - if( *pszBuf >= '0' && *pszBuf <= '9') - { - if( !bAllowHex) - { - uiValue *= 10; - } - else - { - uiValue <<= 4; - } - - uiValue += (FLMUINT)(*pszBuf - '0'); - } - else if( bAllowHex) - { - if( *pszBuf >= 'A' && *pszBuf <= 'F') - { - uiValue <<= 4; - uiValue += (FLMUINT)(*pszBuf - 'A') + 10; - } - else if( *pszBuf >= 'a' && *pszBuf <= 'f') - { - uiValue <<= 4; - uiValue += (FLMUINT)(*pszBuf - 'a') + 10; - } - else - { - break; - } - } - else - { - break; - } - pszBuf++; - } - - *puiVal = uiValue; -} - -/**************************************************************************** -Desc: All of the fromAscii() functions convert values stored in strings to - various native formats -****************************************************************************/ -void F_IniFile::fromAscii( - FLMBOOL * pbVal, - const char * pszParamValue) -{ - if( f_stricmp( pszParamValue, "true") == 0 || - f_stricmp( pszParamValue, "enabled") == 0 || - f_stricmp( pszParamValue, "on") == 0 || - f_stricmp( pszParamValue, "1") == 0) - { - *pbVal = TRUE; - } - else - { - *pbVal = FALSE; - } -} - -/**************************************************************************** -Desc: All of the toAscii() functions convert values from their native - formats to a string representation -****************************************************************************/ -RCODE F_IniFile::toAscii( - char ** ppszParamValue, - FLMUINT puiVal) -{ - RCODE rc = NE_XFLM_OK; - char szTemp[ 50]; - - f_sprintf( szTemp, "%*.*lu", sizeof(szTemp), sizeof(szTemp), puiVal); - - if( RC_BAD( rc = m_pPool->poolAlloc( f_strlen( szTemp), - (void **)ppszParamValue))) - { - goto Exit; - } - - f_strcpy( *ppszParamValue, szTemp); - m_bModified = TRUE; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: All of the toAscii() functions convert values from their native - formats to a string representation -****************************************************************************/ -RCODE F_IniFile::toAscii( - char ** ppszParamValue, - FLMBOOL bVal) -{ - RCODE rc = NE_XFLM_OK; - - if( RC_BAD( rc = m_pPool->poolAlloc( 6, (void **)ppszParamValue))) - { - goto Exit; - } - - if( bVal) - { - f_memcpy( *ppszParamValue, "TRUE ", 6); - } - else - { - f_memcpy( *ppszParamValue, "FALSE", 6); - } - - m_bModified = TRUE; - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: All of the toAscii() functions convert values from their native - formats to a string representation -****************************************************************************/ -RCODE F_IniFile::toAscii( - char ** ppszParamValue, - const char * pszVal) -{ - RCODE rc = NE_XFLM_OK; - - if( RC_BAD( rc = m_pPool->poolAlloc( f_strlen( pszVal), - (void **)ppszParamValue))) - { - goto Exit; - } - - f_strcpy( *ppszParamValue, pszVal); - m_bModified = TRUE; - -Exit: - - return( rc); -} diff --git a/xflaim/src/inifile.h b/xflaim/src/inifile.h deleted file mode 100644 index 3218fa7..0000000 --- a/xflaim/src/inifile.h +++ /dev/null @@ -1,141 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: Class to support reading/writing/parsing of .ini file -// Every line in the .ini file may have a parameter part (consisting of a -// parameter name and an optional value) and a comment part. Empty lines -// are also allowed. Parameter names don't have to have values, but a -// value must have a name. -// -// Tabs: 3 -// -// Copyright (c) 2002-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: inifile.h 3109 2006-01-19 13:07:07 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -typedef struct IniLine -{ - char * pszParamName; - char * pszParamValue; - char * pszComment; - struct IniLine * pPrev; - struct IniLine * pNext; -} INI_LINE; - -class F_IniFile : public XF_RefCount, public XF_Base -{ -public: - - F_IniFile(); - - virtual ~F_IniFile(); - - RCODE Init( void); - - RCODE Read( - char * pszFileName); - - RCODE Write( void); - - FLMBOOL GetParam( - const char * pszParamName, - FLMUINT * puiParamVal); - - RCODE SetParam( - const char * pszParamName, - FLMUINT uiParamVal); - - FLMBOOL GetParam( - const char * pszParamName, - FLMBOOL * pbParamVal); - - RCODE SetParam( - const char * pszParamName, - FLMBOOL bParamVal); - - FLMBOOL GetParam( - const char * pszParamName, - char ** ppszParamVal); - - RCODE SetParam( - const char * pszParamName, - const char * pszParamVal); - - FLMBOOL TestParam( - const char * pszParamName) - { - if( findParam( pszParamName)) - { - return( TRUE); - } - - return( FALSE); - } - -private: - - RCODE readLine( - char * pucBuf, - FLMUINT * puiBytes, - FLMBOOL * pbMore); - - RCODE parseBuffer( - char * pucBuf, - FLMUINT uiNumButes); - - INI_LINE * findParam( - const char * pszParamName); - - RCODE setParamCommon( - INI_LINE ** ppLine, - const char * pszParamName); - - void fromAscii( - FLMUINT * puiVal, - const char * pszParamValue); - - void fromAscii( - FLMBOOL * pbVal, - const char * pszParamValue); - - RCODE toAscii( - char ** ppszParamValue, - FLMUINT puiVal); - - RCODE toAscii( - char ** ppszParamValue, - FLMBOOL pbVal); - - RCODE toAscii( - char ** ppszParamValue, - const char * pszVal); - - FINLINE FLMBOOL isWhiteSpace( - FLMBYTE ucChar) - { - return( ucChar == 32 || ucChar == 9 ? TRUE : FALSE); - } - - IF_Pool * m_pPool; - IF_FileHdl * m_pFile; - char * m_pszFileName; - INI_LINE * m_pFirstLine; - INI_LINE * m_pLastLine; - FLMBOOL m_bReady; - FLMBOOL m_bModified; - FLMUINT m_uiFileOffset; -}; diff --git a/xflaim/src/kybldkey.cpp b/xflaim/src/kybldkey.cpp index d0917ca..f95cb05 100644 --- a/xflaim/src/kybldkey.cpp +++ b/xflaim/src/kybldkey.cpp @@ -191,30 +191,31 @@ FSTATIC RCODE flmAddNonTextKeyPiece( FLMUINT * puiUntilKeyLen, FLMBOOL * pbCanCompareOnKey) { - RCODE rc = NE_XFLM_OK; - FLMUINT uiFromKeyLen = 0; - FLMUINT uiUntilKeyLen = 0; - FLMBYTE * pucFromKeyLenPos = pucFromKey; - FLMBYTE * pucUntilKeyLenPos = pucUntilKey; - FLMBOOL bDataTruncated; - FLMBYTE * pucFromBuf; - FLMUINT uiFromBufLen; - FLMBYTE * pucUntilBuf; - FLMUINT uiUntilBufLen; - FLMBYTE ucFromNumberBuf [FLM_MAX_NUM_BUF_SIZE]; - FLMBYTE ucUntilNumberBuf [FLM_MAX_NUM_BUF_SIZE]; - FLMUINT uiValue; - FLMINT iValue; - FLMBOOL bNeg; - FLMUINT64 ui64Value; - FLMINT64 i64Value; - FLMUINT uiFromFlags = 0; - FLMUINT uiUntilFlags = 0; - FQVALUE * pFromValue; - FQVALUE * pUntilValue; - FLMBOOL bInclFrom; - FLMBOOL bInclUntil; - FLMBOOL bAscending = (pIcd->uiFlags & ICD_DESCENDING) ? FALSE: TRUE; + RCODE rc = NE_XFLM_OK; + FLMUINT uiFromKeyLen = 0; + FLMUINT uiUntilKeyLen = 0; + FLMBYTE * pucFromKeyLenPos = pucFromKey; + FLMBYTE * pucUntilKeyLenPos = pucUntilKey; + FLMBOOL bDataTruncated; + FLMBYTE * pucFromBuf; + FLMUINT uiFromBufLen; + FLMBYTE * pucUntilBuf; + FLMUINT uiUntilBufLen; + FLMBYTE ucFromNumberBuf [FLM_MAX_NUM_BUF_SIZE]; + FLMBYTE ucUntilNumberBuf [FLM_MAX_NUM_BUF_SIZE]; + FLMUINT uiValue; + FLMINT iValue; + FLMBOOL bNeg; + FLMUINT64 ui64Value; + FLMINT64 i64Value; + FLMUINT uiFromFlags = 0; + FLMUINT uiUntilFlags = 0; + FQVALUE * pFromValue; + FQVALUE * pUntilValue; + FLMBOOL bInclFrom; + FLMBOOL bInclUntil; + FLMBOOL bAscending = (pIcd->uiFlags & ICD_DESCENDING) ? FALSE: TRUE; + IF_BufferIStream * pBufferIStream = NULL; // Leave room for the component length @@ -225,14 +226,12 @@ FSTATIC RCODE flmAddNonTextKeyPiece( if (pIcd->uiFlags & ICD_PRESENCE) { - longToByte( (FLMUINT32)pIcd->uiDictNum, pucFromKey); + f_UINT32ToByte( (FLMUINT32)pIcd->uiDictNum, pucFromKey); uiFromKeyLen = uiUntilKeyLen = 4; f_memcpy( pucUntilKey, pucFromKey, uiUntilKeyLen); } else if (pIcd->uiFlags & ICD_METAPHONE) { - F_BufferIStream bufferIStream; - if (pPred->eOperator != XFLM_APPROX_EQ_OP || pPred->pFromValue->eValType != XFLM_UTF8_VAL) { @@ -259,8 +258,17 @@ FSTATIC RCODE flmAddNonTextKeyPiece( goto Exit; } pucFromBuf = &ucFromNumberBuf [0]; + + if( !pBufferIStream) + { + if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferIStream))) + { + goto Exit; + } + } - if (RC_BAD( rc = bufferIStream.open( pucFromBuf, uiFromBufLen))) + if (RC_BAD( rc = pBufferIStream->open( + (const char *)pucFromBuf, uiFromBufLen))) { goto Exit; } @@ -271,7 +279,7 @@ FSTATIC RCODE flmAddNonTextKeyPiece( // Pass 0 for compare rules because it is non-text if (RC_BAD( rc = KYCollateValue( pucFromKey, &uiFromKeyLen, - &bufferIStream, XFLM_NUMBER_TYPE, + pBufferIStream, XFLM_NUMBER_TYPE, pIcd->uiFlags, 0, pIcd->uiLimit, NULL, NULL, pIxd->uiLanguage, FALSE, FALSE, @@ -280,6 +288,8 @@ FSTATIC RCODE flmAddNonTextKeyPiece( goto Exit; } + pBufferIStream->close(); + if (bDataTruncated) { // This should never happen on numeric data. @@ -620,9 +630,16 @@ FSTATIC RCODE flmAddNonTextKeyPiece( } else { - F_BufferIStream bufferIStream; - - if (RC_BAD( rc = bufferIStream.open( pucFromBuf, uiFromBufLen))) + if( !pBufferIStream) + { + if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferIStream))) + { + goto Exit; + } + } + + if (RC_BAD( rc = pBufferIStream->open( + (const char *)pucFromBuf, uiFromBufLen))) { goto Exit; } @@ -633,7 +650,7 @@ FSTATIC RCODE flmAddNonTextKeyPiece( // Pass 0 for compare rules on non-text component. if (RC_BAD( rc = KYCollateValue( pucFromKey, &uiFromKeyLen, - &bufferIStream, icdGetDataType( pIcd), + pBufferIStream, icdGetDataType( pIcd), pIcd->uiFlags, 0, pIcd->uiLimit, NULL, NULL, pIxd->uiLanguage, FALSE, FALSE, @@ -641,6 +658,8 @@ FSTATIC RCODE flmAddNonTextKeyPiece( { goto Exit; } + + pBufferIStream->close(); if (bDataTruncated) { @@ -703,9 +722,16 @@ FSTATIC RCODE flmAddNonTextKeyPiece( } else { - F_BufferIStream bufferIStream; - - if (RC_BAD( rc = bufferIStream.open( pucUntilBuf, uiUntilBufLen))) + if( !pBufferIStream) + { + if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferIStream))) + { + goto Exit; + } + } + + if (RC_BAD( rc = pBufferIStream->open( + (const char *)pucUntilBuf, uiUntilBufLen))) { goto Exit; } @@ -715,7 +741,7 @@ FSTATIC RCODE flmAddNonTextKeyPiece( // Pass 0 for compare rule because it is a non-text piece. if (RC_BAD( rc = KYCollateValue( pucUntilKey, &uiUntilKeyLen, - &bufferIStream, icdGetDataType( pIcd), + pBufferIStream, icdGetDataType( pIcd), pIcd->uiFlags, 0, pIcd->uiLimit, NULL, NULL, pIxd->uiLanguage, FALSE, FALSE, @@ -723,6 +749,8 @@ FSTATIC RCODE flmAddNonTextKeyPiece( { goto Exit; } + + pBufferIStream->close(); if (bDataTruncated) { @@ -780,6 +808,11 @@ FSTATIC RCODE flmAddNonTextKeyPiece( Exit: + if( pBufferIStream) + { + pBufferIStream->Release(); + } + return( rc); } @@ -803,7 +836,7 @@ FSTATIC RCODE flmUTF8FindWildcard( for( ;;) { pucSaveVal = pucValue; - if (RC_BAD( rc = flmGetCharFromUTF8Buf( &pucValue, NULL, &uzChar))) + if (RC_BAD( rc = f_getCharFromUTF8Buf( &pucValue, NULL, &uzChar))) { goto Exit; } @@ -813,7 +846,7 @@ FSTATIC RCODE flmUTF8FindWildcard( break; } - if ((uzChar = flmConvertChar( uzChar, uiCompareRules)) == 0) + if ((uzChar = f_convertChar( uzChar, uiCompareRules)) == 0) { continue; } @@ -834,7 +867,7 @@ FSTATIC RCODE flmUTF8FindWildcard( // Skip the escaped character - if (RC_BAD( rc = flmGetCharFromUTF8Buf( &pucValue, NULL, &uzChar))) + if (RC_BAD( rc = f_getCharFromUTF8Buf( &pucValue, NULL, &uzChar))) { goto Exit; } @@ -875,7 +908,7 @@ FSTATIC RCODE flmCountCharacters( while (uiNumChars < uiMaxToCount) { - if (RC_BAD( rc = flmGetCharFromUTF8Buf( &pucValue, pucEnd, &uzChar))) + if (RC_BAD( rc = f_getCharFromUTF8Buf( &pucValue, pucEnd, &uzChar))) { goto Exit; } @@ -904,7 +937,7 @@ FSTATIC RCODE flmCountCharacters( break; } - if ((uzChar = flmConvertChar( uzChar, uiCompareRules)) == 0) + if ((uzChar = f_convertChar( uzChar, uiCompareRules)) == 0) { continue; } @@ -951,7 +984,7 @@ FSTATIC RCODE flmCountCharacters( // to count one character here. A backslash followed by any // character is only a single character. - if (RC_BAD( rc = flmGetCharFromUTF8Buf( &pucValue, pucEnd, &uzChar))) + if (RC_BAD( rc = f_getCharFromUTF8Buf( &pucValue, pucEnd, &uzChar))) { goto Exit; } @@ -1018,7 +1051,7 @@ FSTATIC RCODE flmSelectBestSubstr( // Skip past the wildcard pucTmp = &pucValue [uiWildcardPos]; - if (RC_BAD( rc = flmGetCharFromUTF8Buf( &pucTmp, pucEnd, &uzDummy))) + if (RC_BAD( rc = f_getCharFromUTF8Buf( &pucTmp, pucEnd, &uzDummy))) { goto Exit; } @@ -1048,7 +1081,7 @@ FSTATIC RCODE flmSelectBestSubstr( while (uiBestNumChars < GOOD_ENOUGH_CHARS) { pucTmp = pucCurValue; - if (RC_BAD( rc = flmGetCharFromUTF8Buf( &pucTmp, pucEnd, &uzChar))) + if (RC_BAD( rc = f_getCharFromUTF8Buf( &pucTmp, pucEnd, &uzChar))) { goto Exit; } @@ -1109,7 +1142,7 @@ FSTATIC RCODE flmSelectBestSubstr( // Skip past the wildcard pucTmp = &pucCurValue[ uiWildcardPos]; - if (RC_BAD( rc = flmGetCharFromUTF8Buf( &pucTmp, pucEnd, &uzDummy))) + if (RC_BAD( rc = f_getCharFromUTF8Buf( &pucTmp, pucEnd, &uzDummy))) { goto Exit; } @@ -1297,40 +1330,41 @@ FSTATIC RCODE flmAddTextKeyPiece( FLMUINT * puiUntilKeyLen, FLMBOOL * pbCanCompareOnKey) { - RCODE rc = NE_XFLM_OK; - FLMUINT uiFromKeyLen = 0; - FLMUINT uiUntilKeyLen = 0; - FLMBYTE * pucFromKeyLenPos = pucFromKey; - FLMBYTE * pucUntilKeyLenPos = pucUntilKey; - FLMUINT uiLanguage = pIxd->uiLanguage; - FLMUINT uiCollationLen = 0; - FLMUINT uiCharCount; - FLMUINT uiCaseLen; - FLMBOOL bOriginalCharsLost = FALSE; - FLMBOOL bIsDBCS = (uiLanguage >= FIRST_DBCS_LANG && - uiLanguage <= LAST_DBCS_LANG) + RCODE rc = NE_XFLM_OK; + FLMUINT uiFromKeyLen = 0; + FLMUINT uiUntilKeyLen = 0; + FLMBYTE * pucFromKeyLenPos = pucFromKey; + FLMBYTE * pucUntilKeyLenPos = pucUntilKey; + FLMUINT uiLanguage = pIxd->uiLanguage; + FLMUINT uiCollationLen = 0; + FLMUINT uiCharCount; + FLMUINT uiCaseLen; + FLMBOOL bOriginalCharsLost = FALSE; + FLMBOOL bIsDBCS = (uiLanguage >= FLM_FIRST_DBCS_LANG && + uiLanguage <= FLM_LAST_DBCS_LANG) ? TRUE : FALSE; - FLMBOOL bCaseInsensitive = (FLMBOOL)((pPred->uiCompareRules & + FLMBOOL bCaseInsensitive = (FLMBOOL)((pPred->uiCompareRules & XFLM_COMP_CASE_INSENSITIVE) ? TRUE : FALSE); - FLMBOOL bDoFirstSubstring = (FLMBOOL)((pIcd->uiFlags & ICD_SUBSTRING) + FLMBOOL bDoFirstSubstring = (FLMBOOL)((pIcd->uiFlags & ICD_SUBSTRING) ? TRUE : FALSE); - FLMBOOL bDoMatchBegin = FALSE; - FLMBOOL bTrailingWildcard = FALSE; - const FLMBYTE * pucFromUTF8Buf = NULL; - FLMUINT uiFromBufLen = 0; - const FLMBYTE * pucUntilUTF8Buf = NULL; - FLMUINT uiUntilBufLen = 0; - FLMUINT uiWildcardPos; - FLMBOOL bDataTruncated; - FLMUINT uiFromFlags = 0; - FLMUINT uiUntilFlags = 0; - FLMUINT uiCompareRules; - FLMBOOL bAscending = (pIcd->uiFlags & ICD_DESCENDING) ? FALSE: TRUE; + FLMBOOL bDoMatchBegin = FALSE; + FLMBOOL bTrailingWildcard = FALSE; + const FLMBYTE * pucFromUTF8Buf = NULL; + FLMUINT uiFromBufLen = 0; + const FLMBYTE * pucUntilUTF8Buf = NULL; + FLMUINT uiUntilBufLen = 0; + FLMUINT uiWildcardPos; + FLMBOOL bDataTruncated; + FLMUINT uiFromFlags = 0; + FLMUINT uiUntilFlags = 0; + FLMUINT uiCompareRules; + FLMBOOL bAscending = (pIcd->uiFlags & ICD_DESCENDING) ? FALSE: TRUE; + IF_BufferIStream * pBufferIStream = NULL; switch (pPred->eOperator) { @@ -1573,9 +1607,16 @@ FSTATIC RCODE flmAddTextKeyPiece( } else { - F_BufferIStream bufferIStream; - - if (RC_BAD( rc = bufferIStream.open( pucFromUTF8Buf, uiFromBufLen))) + if( !pBufferIStream) + { + if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferIStream))) + { + goto Exit; + } + } + + if (RC_BAD( rc = pBufferIStream->open( + (const char *)pucFromUTF8Buf, uiFromBufLen))) { goto Exit; } @@ -1586,7 +1627,7 @@ FSTATIC RCODE flmAddTextKeyPiece( uiFromKeyLen = XFLM_MAX_KEY_SIZE - 2; bDataTruncated = FALSE; if (RC_BAD( rc = KYCollateValue( pucFromKey, &uiFromKeyLen, - &bufferIStream, XFLM_TEXT_TYPE, + pBufferIStream, XFLM_TEXT_TYPE, pIcd->uiFlags | ICD_ESC_CHAR, pIcd->uiCompareRules, pIcd->uiLimit, &uiCollationLen, &uiCaseLen, @@ -1597,6 +1638,8 @@ FSTATIC RCODE flmAddTextKeyPiece( goto Exit; } + pBufferIStream->close(); + if (bDataTruncated) { *pbCanCompareOnKey = FALSE; @@ -1804,9 +1847,16 @@ FSTATIC RCODE flmAddTextKeyPiece( } else if (pucFromUTF8Buf != pucUntilUTF8Buf) { - F_BufferIStream bufferIStream; - - if (RC_BAD( rc = bufferIStream.open( pucUntilUTF8Buf, uiUntilBufLen))) + if( !pBufferIStream) + { + if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferIStream))) + { + goto Exit; + } + } + + if (RC_BAD( rc = pBufferIStream->open( + (const char *)pucUntilUTF8Buf, uiUntilBufLen))) { goto Exit; } @@ -1817,7 +1867,7 @@ FSTATIC RCODE flmAddTextKeyPiece( uiUntilKeyLen = XFLM_MAX_KEY_SIZE - 2; bDataTruncated = FALSE; if (RC_BAD( rc = KYCollateValue( pucUntilKey, &uiUntilKeyLen, - &bufferIStream, XFLM_TEXT_TYPE, + pBufferIStream, XFLM_TEXT_TYPE, pIcd->uiFlags | ICD_ESC_CHAR, pIcd->uiCompareRules, pIcd->uiLimit, &uiCollationLen, &uiCaseLen, @@ -1828,6 +1878,8 @@ FSTATIC RCODE flmAddTextKeyPiece( goto Exit; } + pBufferIStream->close(); + if (bDataTruncated) { @@ -1895,6 +1947,11 @@ FSTATIC RCODE flmAddTextKeyPiece( } Exit: + + if( pBufferIStream) + { + pBufferIStream->close(); + } return( rc); } @@ -1914,8 +1971,7 @@ RCODE flmBuildFromAndUntilKeys( FLMBYTE * pucUntilKey, FLMUINT * puiUntilKeyLen, FLMBOOL * pbDoNodeMatch, - FLMBOOL * pbCanCompareOnKey - ) + FLMBOOL * pbCanCompareOnKey) { RCODE rc = NE_XFLM_OK; ICD * pIcd = pIxd->pFirstKey; diff --git a/xflaim/src/kybuild.cpp b/xflaim/src/kybuild.cpp index 082d964..e4b4fd9 100644 --- a/xflaim/src/kybuild.cpp +++ b/xflaim/src/kybuild.cpp @@ -71,7 +71,7 @@ FSTATIC RCODE kySeeIfRepeatingSibs( FSTATIC RCODE kyFindChildNode( F_Db * pDb, - F_Pool * pPool, + IF_Pool * pPool, NODE_TRAV ** ppTrav, FLMBOOL * pbGotChild, FLMBOOL * pbHadRepeatingSib); @@ -119,12 +119,12 @@ FSTATIC RCODE kyAddIDsToKey( if (uiIDBufSize - uiIDLen >= 9) { - uiIDLen += flmEncodeSEN( ui64DocumentID, &pucIDs); + uiIDLen += f_encodeSEN( ui64DocumentID, &pucIDs); } else { pucTmpSen = &ucTmpSen [0]; - uiSenLen = flmEncodeSEN( ui64DocumentID, &pucTmpSen); + uiSenLen = f_encodeSEN( ui64DocumentID, &pucTmpSen); if (uiSenLen + uiIDLen > uiIDBufSize) { rc = RC_SET( NE_XFLM_KEY_OVERFLOW); @@ -150,12 +150,12 @@ FSTATIC RCODE kyAddIDsToKey( if (uiIDBufSize - uiIDLen >= 9) { - uiIDLen += flmEncodeSEN( ui64Id, &pucIDs); + uiIDLen += f_encodeSEN( ui64Id, &pucIDs); } else { pucTmpSen = &ucTmpSen [0]; - uiSenLen = flmEncodeSEN( ui64Id, &pucTmpSen); + uiSenLen = f_encodeSEN( ui64Id, &pucTmpSen); if (uiSenLen + uiIDLen > uiIDBufSize) { rc = RC_SET( NE_XFLM_KEY_OVERFLOW); @@ -182,12 +182,12 @@ FSTATIC RCODE kyAddIDsToKey( if (uiIDBufSize - uiIDLen >= 9) { - uiIDLen += flmEncodeSEN( ui64Id, &pucIDs); + uiIDLen += f_encodeSEN( ui64Id, &pucIDs); } else { pucTmpSen = &ucTmpSen [0]; - uiSenLen = flmEncodeSEN( ui64Id, &pucTmpSen); + uiSenLen = f_encodeSEN( ui64Id, &pucTmpSen); if (uiSenLen + uiIDLen > uiIDBufSize) { rc = RC_SET( NE_XFLM_KEY_OVERFLOW); @@ -214,12 +214,12 @@ FSTATIC RCODE kyAddIDsToKey( if (uiIDBufSize - uiIDLen >= 9) { - uiIDLen += flmEncodeSEN( ui64Id, &pucIDs); + uiIDLen += f_encodeSEN( ui64Id, &pucIDs); } else { pucTmpSen = &ucTmpSen [0]; - uiSenLen = flmEncodeSEN( ui64Id, &pucTmpSen); + uiSenLen = f_encodeSEN( ui64Id, &pucTmpSen); if (uiSenLen + uiIDLen > uiIDBufSize) { rc = RC_SET( NE_XFLM_KEY_OVERFLOW); @@ -247,7 +247,30 @@ F_OldNodeList::~F_OldNodeList() { f_free( &m_pNodeList); } - m_pool.poolFree(); + + if( m_pPool) + { + m_pPool->Release(); + } +} + +/***************************************************************************** +Desc: +*****************************************************************************/ +RCODE F_OldNodeList::setup( void) +{ + RCODE rc = NE_XFLM_OK; + + if( RC_BAD( rc = FlmAllocPool( &m_pPool))) + { + goto Exit; + } + + m_pPool->poolInit( 512); + +Exit: + + return( rc); } /***************************************************************************** @@ -455,7 +478,7 @@ RCODE F_OldNodeList::addNodeToList( // Allocate the space needed. - if (RC_BAD( rc = m_pool.poolAlloc( uiBufSize, + if (RC_BAD( rc = m_pPool->poolAlloc( uiBufSize, (void **)&m_pNodeList [uiInsertPos].pucData))) { goto Exit; @@ -485,7 +508,7 @@ RCODE F_OldNodeList::addNodeToList( // Allocate the space needed. uiBufSize = (uiChars + 1) * sizeof( FLMUNICODE); - if (RC_BAD( rc = m_pool.poolAlloc( uiBufSize, + if (RC_BAD( rc = m_pPool->poolAlloc( uiBufSize, (void **)&m_pNodeList [uiInsertPos].pucData))) { goto Exit; @@ -514,7 +537,11 @@ Desc: Release all of the nodes in the list. *****************************************************************************/ void F_OldNodeList::resetList( void) { - m_pool.poolReset( NULL); + if( m_pPool) + { + m_pPool->poolReset( NULL); + } + m_uiNodeCount = 0; } @@ -768,7 +795,7 @@ RCODE F_Db::buildData( // Output the length of the data as a SEN value pucTmpSen = &ucTmpSen [0]; - uiSENLen = flmEncodeSEN( uiDataComponentLen, &pucTmpSen); + uiSENLen = f_encodeSEN( uiDataComponentLen, &pucTmpSen); if (uiDataComponentLen + uiSENLen + uiDataLen > m_keyGenInfo.uiDataBufSize) { FLMUINT uiNewSize = uiDataComponentLen + uiSENLen + uiDataLen + 512; @@ -1102,7 +1129,6 @@ RCODE F_Db::genTextKeyComponents( RCODE rc = NE_XFLM_OK; IF_PosIStream * pIStream = NULL; FLMUINT uiNumChars; - F_BufferIStream bufferStream; FLMUINT uiStrBytes; FLMUINT uiSubstrChars; FLMUINT uiMeta; @@ -1117,6 +1143,7 @@ RCODE F_Db::genTextKeyComponents( FLMUINT uiKeyLenPos = uiKeyLen; FLMUINT uiCompareRules = pIcd->uiCompareRules; F_NodeBufferIStream nodeBufferIStream; + IF_BufferIStream * pBufferIStream = NULL; uiKeyLen += 2; uiSaveKeyLen = uiKeyLen; @@ -1126,6 +1153,11 @@ RCODE F_Db::genTextKeyComponents( goto No_Strings; } + if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferIStream))) + { + goto Exit; + } + if (RC_BAD( rc = pNode->getTextIStream( this, &nodeBufferIStream, &pIStream, &uiNumChars))) { @@ -1198,9 +1230,9 @@ No_Strings: { if (*ppucTmpBuf == NULL) { - *ppvMark = m_TempPool.poolMark(); + *ppvMark = m_pTempPool->poolMark(); *puiTmpBufSize = (FLMUINT)XFLM_MAX_KEY_SIZE + 8; - if (RC_BAD( rc = m_TempPool.poolAlloc( *puiTmpBufSize, + if (RC_BAD( rc = m_pTempPool->poolAlloc( *puiTmpBufSize, (void **)ppucTmpBuf))) { goto Exit; @@ -1223,7 +1255,8 @@ No_Strings: break; } - if (RC_BAD( rc = bufferStream.open( *ppucTmpBuf, uiStrBytes))) + if (RC_BAD( rc = pBufferIStream->open( + (const char *)*ppucTmpBuf, uiStrBytes))) { goto Exit; } @@ -1234,14 +1267,14 @@ No_Strings: uiElmLen = XFLM_MAX_KEY_SIZE - uiKeyLen; rc = KYCollateValue( &m_keyGenInfo.pucKeyBuf [uiKeyLen], &uiElmLen, - &bufferStream, XFLM_TEXT_TYPE, + pBufferIStream, XFLM_TEXT_TYPE, pIcd->uiFlags, pIcd->uiCompareRules & XFLM_COMP_CASE_INSENSITIVE, pIcd->uiLimit, NULL, NULL, m_keyGenInfo.pIxd->uiLanguage, FALSE, FALSE, &bDataTruncated, NULL); - bufferStream.close(); + pBufferIStream->close(); if( RC_BAD( rc)) { @@ -1255,7 +1288,7 @@ No_Strings: FLMBYTE ucStorageBuf[ FLM_MAX_NUM_BUF_SIZE]; FLMUINT uiStorageLen; - if( RC_BAD( rc = flmGetNextMetaphone( pIStream, &uiMeta))) + if( RC_BAD( rc = f_getNextMetaphone( pIStream, &uiMeta))) { if( rc != NE_XFLM_EOF_HIT) { @@ -1276,7 +1309,8 @@ No_Strings: goto Exit; } - if (RC_BAD( rc = bufferStream.open( ucStorageBuf, uiStorageLen))) + if (RC_BAD( rc = pBufferIStream->open( + (const char *)ucStorageBuf, uiStorageLen))) { goto Exit; } @@ -1286,13 +1320,13 @@ No_Strings: uiElmLen = XFLM_MAX_KEY_SIZE - uiKeyLen; rc = KYCollateValue( &m_keyGenInfo.pucKeyBuf [uiKeyLen], &uiElmLen, - &bufferStream, XFLM_NUMBER_TYPE, + pBufferIStream, XFLM_NUMBER_TYPE, pIcd->uiFlags, 0, pIcd->uiLimit, NULL, NULL, m_keyGenInfo.pIxd->uiLanguage, FALSE, FALSE, NULL, NULL); - bufferStream.close(); + pBufferIStream->close(); if( RC_BAD( rc)) { @@ -1306,9 +1340,9 @@ No_Strings: flmAssert( bSubstring); if (*ppucTmpBuf == NULL) { - *ppvMark = m_TempPool.poolMark(); + *ppvMark = m_pTempPool->poolMark(); *puiTmpBufSize = (FLMUINT)XFLM_MAX_KEY_SIZE + 8; - if (RC_BAD( rc = m_TempPool.poolAlloc( *puiTmpBufSize, + if (RC_BAD( rc = m_pTempPool->poolAlloc( *puiTmpBufSize, (void **)ppucTmpBuf))) { goto Exit; @@ -1336,7 +1370,8 @@ No_Strings: break; } - if (RC_BAD( rc = bufferStream.open( *ppucTmpBuf, uiStrBytes))) + if (RC_BAD( rc = pBufferIStream->open( + (const char *)*ppucTmpBuf, uiStrBytes))) { goto Exit; } @@ -1347,7 +1382,7 @@ No_Strings: uiElmLen = XFLM_MAX_KEY_SIZE - uiKeyLen; rc = KYCollateValue( &m_keyGenInfo.pucKeyBuf [uiKeyLen], &uiElmLen, - &bufferStream, XFLM_TEXT_TYPE, + pBufferIStream, XFLM_TEXT_TYPE, pIcd->uiFlags, pIcd->uiCompareRules & XFLM_COMP_CASE_INSENSITIVE, pIcd->uiLimit, @@ -1356,7 +1391,7 @@ No_Strings: bHadAtLeastOneString ? FALSE : TRUE, FALSE, &bDataTruncated, NULL); - bufferStream.close(); + pBufferIStream->close(); if( RC_BAD( rc)) { @@ -1392,6 +1427,11 @@ No_Strings: rc = RC_SET( NE_XFLM_MEM); goto Exit; } + + if( RC_BAD( rc = m_pOldNodeList->setup())) + { + goto Exit; + } } if (RC_BAD( rc = m_pOldNodeList->addNodeToList( this, pNode))) { @@ -1413,6 +1453,11 @@ No_Strings: Exit: + if( pBufferIStream) + { + pBufferIStream->Release(); + } + if (pIStream) { pIStream->Release(); @@ -1465,7 +1510,8 @@ No_Data: goto Exit; } } - longToByte( (FLMUINT32)uiNameId, &m_keyGenInfo.pucKeyBuf [uiKeyLen]); + + f_UINT32ToByte( (FLMUINT32)uiNameId, &m_keyGenInfo.pucKeyBuf [uiKeyLen]); uiKeyLen += 4; // Save the key component length. @@ -1532,6 +1578,11 @@ No_Data: rc = RC_SET( NE_XFLM_MEM); goto Exit; } + + if( RC_BAD( rc = m_pOldNodeList->setup())) + { + goto Exit; + } } if (RC_BAD( rc = m_pOldNodeList->addNodeToList( this, pNode))) @@ -1676,7 +1727,7 @@ Exit: if (pvMark) { - m_TempPool.poolReset( pvMark); + m_pTempPool->poolReset( pvMark); } // Restore the CDL table entry to point to the @@ -1759,8 +1810,8 @@ RCODE F_Db::buildKeys( m_keyGenInfo.ui64DocumentID = ui64DocumentID; m_keyGenInfo.pIxd = pIxd; - m_keyGenInfo.bIsAsia = (FLMBOOL)(pIxd->uiLanguage >= FIRST_DBCS_LANG && - pIxd->uiLanguage <= LAST_DBCS_LANG) + m_keyGenInfo.bIsAsia = (FLMBOOL)(pIxd->uiLanguage >= FLM_FIRST_DBCS_LANG && + pIxd->uiLanguage <= FLM_LAST_DBCS_LANG) ? TRUE : FALSE; m_keyGenInfo.bIsCompound = pIxd->uiNumKeyComponents > 1 ? TRUE : FALSE; @@ -1889,7 +1940,7 @@ Desc: Get a child node for current traversal node. ****************************************************************************/ FSTATIC RCODE kyFindChildNode( F_Db * pDb, - F_Pool * pPool, + IF_Pool * pPool, NODE_TRAV ** ppTrav, FLMBOOL * pbGotChild, FLMBOOL * pbHadRepeatingSib) @@ -2492,7 +2543,7 @@ RCODE F_Db::genIndexKeys( // match what we have in the index definition, then this node // is irrelevant to generating keys in this index. - if (RC_BAD( rc = m_TempPool.poolCalloc( sizeof( ANCHOR_NODE), + if (RC_BAD( rc = m_pTempPool->poolCalloc( sizeof( ANCHOR_NODE), (void **)&pAnchorNode))) { goto Exit; @@ -2560,7 +2611,7 @@ RCODE F_Db::genIndexKeys( } } - if (RC_BAD( rc = m_TempPool.poolCalloc( sizeof( ANCHOR_NODE), + if (RC_BAD( rc = m_pTempPool->poolCalloc( sizeof( ANCHOR_NODE), (void **)&pAnchorNode))) { goto Exit; @@ -2576,7 +2627,7 @@ RCODE F_Db::genIndexKeys( // Allocate a CDL table for the index. - if (RC_BAD( rc = m_TempPool.poolCalloc( sizeof( CDL_HDR) * + if (RC_BAD( rc = m_pTempPool->poolCalloc( sizeof( CDL_HDR) * pIxd->uiNumIcds, (void **)&pCdlTbl))) { goto Exit; @@ -2584,7 +2635,7 @@ RCODE F_Db::genIndexKeys( // Create a traversal node for the root node we arrived at. - if (RC_BAD( rc = m_TempPool.poolCalloc( sizeof( NODE_TRAV), + if (RC_BAD( rc = m_pTempPool->poolCalloc( sizeof( NODE_TRAV), (void **)&pTrav))) { goto Exit; @@ -2783,7 +2834,7 @@ Get_First_Attribute: } else { - if (RC_BAD( rc = m_TempPool.poolAlloc( sizeof( CDL), + if (RC_BAD( rc = m_pTempPool->poolAlloc( sizeof( CDL), (void **)&pCdl))) { goto Exit; @@ -2802,7 +2853,7 @@ Get_First_Attribute: pChildIcd = pTrav->pIcd->pFirstChild; while (pChildIcd) { - if (RC_BAD( rc = m_TempPool.poolAlloc( + if (RC_BAD( rc = m_pTempPool->poolAlloc( sizeof( CDL), (void **)&pCdl))) { goto Exit; @@ -2821,7 +2872,7 @@ Next_Node: if (pTrav->bTraverseChildren) { bInNodeSubtree = pTrav->bInNodeSubtree; - if (RC_BAD( rc = kyFindChildNode( this, &m_TempPool, + if (RC_BAD( rc = kyFindChildNode( this, m_pTempPool, &pTrav, &bGotNode, &bHadRepeatingSib))) { goto Exit; @@ -3159,7 +3210,7 @@ RCODE F_Db::updateIndexKeys( // The node may be indexed so we need to process the ICD list - pvMark = m_TempPool.poolMark(); + pvMark = m_pTempPool->poolMark(); bIsIndexed = TRUE; ui64DocumentID = pNode->getDocumentId(); @@ -3242,7 +3293,7 @@ RCODE F_Db::updateIndexKeys( Next_Index: - m_TempPool.poolReset( pvMark); + m_pTempPool->poolReset( pvMark); if ((pIcd = pIcd->pNextInChain) == NULL) { if (!bIsRoot || uiIcdDictNum == ELM_ROOT_TAG) @@ -3264,7 +3315,7 @@ Exit: if( pvMark) { - m_TempPool.poolReset( pvMark); + m_pTempPool->poolReset( pvMark); } if (pNode) diff --git a/xflaim/src/kycollat.cpp b/xflaim/src/kycollat.cpp index 27b2d19..0a6f36f 100644 --- a/xflaim/src/kycollat.cpp +++ b/xflaim/src/kycollat.cpp @@ -31,93 +31,6 @@ FSTATIC RCODE KYFormatUTF8Text( FLMUINT uiCompareRules, F_DynaBuf * pDynaBuf); -FSTATIC FLMBOOL flmAddMetaphone( - const char * pszStr, - const char * pszAltStr, - FLMBYTE * pszMeta, - FLMUINT * puiMetaOffset, - FLMBYTE * pszAltMeta, - FLMUINT * puiAltMetaOffset); - -FSTATIC void flmMetaStrToNum( - FLMBYTE * pszMeta, - FLMUINT * puiMeta); - -#ifdef FLM_DEBUG - typedef struct - { - const char * pszWord; - FLMUINT uiMeta; - FLMUINT uiAltMeta; - } METAPHONE_MAPPING; - - static METAPHONE_MAPPING gv_MetaTestTable[] = - { - { "ghislane", 0x4680, 0x4680 }, - { "ghiradelli", 0x4AC6, 0x4AC6 }, - { "hugh", 0x3000, 0x3000 }, - { "san francisco", 0xB82A, 0xB82A }, - { "van wagner", 0x2858, 0x2858 }, - { "vanwagner", 0x2858, 0x2858 }, - { "gnome", 0x8700, 0x8700 }, - { "write", 0xAC00, 0xAC00 }, - { "dumb", 0xC700, 0xC700 }, - { "caesar", 0xBBA0, 0xBBA0 }, - { "chianti", 0x58C0, 0x58C0 }, - { "michael", 0x7560, 0x7D60 }, - { "chemistry", 0x57BC, 0x57BC }, - { "chorus", 0x5AB0, 0x5AB0 }, - { "mchugh", 0x7500, 0x7500 }, - { "czerny", 0xBA80, 0xDA80 }, - { "focaccia", 0x25D0, 0x25D0 }, - { "mcclellan", 0x7566, 0x7566 }, - { "bellocchio", 0x96D0, 0x96D0 }, - { "bacchus", 0x95B0, 0x95B0 }, - { "accident", 0x15BC, 0x15BC }, - { "accede", 0x15BC, 0x15BC }, - { "succeed", 0xB5BC, 0xB5BC }, - { "bacci", 0x9D00, 0x9D00 }, - { "mac caffrey", 0x752A, 0x752A }, - { "edge", 0x1400, 0x1400 }, - { "edgar", 0x1C5A, 0x1C5A }, - { "laugh", 0x6200, 0x6200 }, - { "caugh", 0x5200, 0x5200 }, - { "cagney", 0x5580, 0x5580 }, - { "tagliaro", 0xC56A, 0xC6A0 }, - { "biaggi", 0x9400, 0x9500 }, - { "jose", 0x3B00, 0x3B00 }, - { "yankelovich", 0x1856, 0x1856 }, - { "bajador", 0x94CA, 0x93CA }, - { "cabrillo", 0x59A6, 0x59A0 }, - { "campbell", 0x5796, 0x5796 }, - { "rogier", 0xA400, 0xA4A0 }, - { "hochmeier", 0x357A, 0x357A }, - { "island", 0x168C, 0x168C }, - { "isle", 0x1600, 0x1600 }, - { "sugar", 0xD5A0, 0xB5A0 }, - { "herb", 0x3A90, 0x3A90 }, - { "mannheim", 0x7870, 0x7870 }, - { "snider", 0xB8CA, 0xD8CA }, - { "schneider", 0xD8CA, 0xB8CA }, - { "smith", 0xB700, 0xD7C0 }, - { "schmidt", 0xD7C0, 0xB7C0 }, - { "school", 0xB560, 0xB560 }, - { "schenker", 0xD85A, 0xB585 }, - { "resnais", 0xAB80, 0xAB8B }, - { "artois", 0x1AC0, 0x1ACB }, - { "celebration", 0xB69A, 0xB69A }, - { "thomas", 0xC7B0, 0xC7B0 }, - { "uomo", 0x1700, 0x1700 }, - { "womo", 0x1700, 0x2700 }, - { "arnow", 0x1A80, 0x1A82 }, - { "arnoff", 0x1A82, 0x1A82 }, - { "filipowicz", 0x269C, 0x2692 }, - { "breaux", 0x9A00, 0x9A00 }, - { "zhao", 0x4000, 0x4000 }, - { NULL, 0x0000, 0x0000 } - }; -#endif - /**************************************************************************** Desc: Build a collated key value piece. ****************************************************************************/ @@ -137,17 +50,17 @@ RCODE KYCollateValue( FLMBOOL * pbDataTruncated, FLMBOOL * pbOriginalCharsLost) { - RCODE rc = NE_XFLM_OK; - FLMUINT uiDestLen; - F_BufferIStream bufferStream; - FLMUINT uiCharLimit; - FLMUINT uiLength; - FLMBYTE * pucTmpDest; - FLMUINT uiBytesRead; - FLMBOOL bHaveData = TRUE; - FLMUNICODE uChar; - FLMBYTE ucDynaBuf[ 64]; - F_DynaBuf dynaBuf( ucDynaBuf, sizeof( ucDynaBuf)); + RCODE rc = NE_XFLM_OK; + FLMUINT uiDestLen; + IF_BufferIStream * pBufferIStream = NULL; + FLMUINT uiCharLimit; + FLMUINT uiLength; + FLMBYTE * pucTmpDest; + FLMUINT uiBytesRead; + FLMBOOL bHaveData = TRUE; + FLMUNICODE uChar; + FLMBYTE ucDynaBuf[ 64]; + F_DynaBuf dynaBuf( ucDynaBuf, sizeof( ucDynaBuf)); if (puiLuLen) { @@ -171,7 +84,7 @@ RCODE KYCollateValue( { FLMUINT64 ui64SavePosition = pIStream->getCurrPosition(); - if( RC_BAD( rc = flmReadUTF8CharAsUnicode( + if( RC_BAD( rc = f_readUTF8CharAsUnicode( pIStream, &uChar))) { if (rc == NE_XFLM_EOF_HIT) @@ -208,19 +121,26 @@ RCODE KYCollateValue( { goto Exit; } - if (RC_BAD( rc = bufferStream.open( dynaBuf.getBufferPtr(), - dynaBuf.getDataLength()))) + + if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferIStream))) { goto Exit; } - pIStream = &bufferStream; + + if (RC_BAD( rc = pBufferIStream->open( + (const char *)dynaBuf.getBufferPtr(), dynaBuf.getDataLength()))) + { + goto Exit; + } + pIStream = pBufferIStream; } uiCharLimit = uiLimit ? uiLimit : ICD_DEFAULT_LIMIT; - if( (uiLanguage >= FIRST_DBCS_LANG ) && (uiLanguage <= LAST_DBCS_LANG)) + if( (uiLanguage >= FLM_FIRST_DBCS_LANG ) && + (uiLanguage <= FLM_LAST_DBCS_LANG)) { - if( RC_BAD( rc = flmAsiaUTF8ToColText( pIStream, pucDest, &uiDestLen, + if( RC_BAD( rc = f_asiaUTF8ToColText( pIStream, pucDest, &uiDestLen, (uiCompareRules & XFLM_COMP_CASE_INSENSITIVE) ? TRUE : FALSE, @@ -336,6 +256,11 @@ RCODE KYCollateValue( Exit: + if( pBufferIStream) + { + pBufferIStream->Release(); + } + *puiDestLen = uiDestLen; return( rc); } @@ -371,7 +296,7 @@ FSTATIC RCODE KYFormatUTF8Text( for (;;) { - if (RC_BAD( rc = flmReadUTF8CharAsUnicode( pIStream, &uChar))) + if (RC_BAD( rc = f_readUTF8CharAsUnicode( pIStream, &uChar))) { if (rc == NE_XFLM_EOF_HIT) { @@ -380,7 +305,7 @@ FSTATIC RCODE KYFormatUTF8Text( } goto Exit; } - if ((uChar = flmConvertChar( uChar, uiCompareRules)) == 0) + if ((uChar = f_convertChar( uChar, uiCompareRules)) == 0) { continue; } @@ -442,7 +367,7 @@ FSTATIC RCODE KYFormatUTF8Text( if (uChar == ASCII_BACKSLASH && (uiFlags & ICD_ESC_CHAR)) { - if (RC_BAD( rc = flmReadUTF8CharAsUnicode( pIStream, &uChar))) + if (RC_BAD( rc = f_readUTF8CharAsUnicode( pIStream, &uChar))) { if (rc == NE_XFLM_EOF_HIT) { @@ -463,7 +388,7 @@ FSTATIC RCODE KYFormatUTF8Text( goto Exit; } uiSize = 3; - if (RC_BAD( rc = flmUni2UTF8( uChar, pucTmp, &uiSize))) + if (RC_BAD( rc = f_uni2UTF8( uChar, pucTmp, &uiSize))) { goto Exit; } @@ -508,1900 +433,3 @@ Exit: return( rc); } - -/**************************************************************************** -Desc: -****************************************************************************/ -FSTATIC FLMBOOL flmAddMetaphone( - const char * pszStr, - const char * pszAltStr, - FLMBYTE * pszMeta, - FLMUINT * puiMetaOffset, - FLMBYTE * pszAltMeta, - FLMUINT * puiAltMetaOffset) -{ - FLMBOOL bDone = FALSE; - - if( pszStr) - { - while( *pszStr) - { - if( *puiMetaOffset < 4) - { - pszMeta[ (*puiMetaOffset)++] = *pszStr; - } - - if( !pszAltStr && pszAltMeta && *puiAltMetaOffset < 4) - { - pszAltMeta[ (*puiAltMetaOffset)++] = *pszStr; - } - - if( *puiMetaOffset == 4 && *puiAltMetaOffset == 4) - { - bDone = TRUE; - break; - } - - pszStr++; - } - } - - if( pszAltStr) - { - while( *pszAltStr) - { - if( *puiAltMetaOffset < 4) - { - pszAltMeta[ (*puiAltMetaOffset)++] = *pszAltStr; - } - - if( *puiMetaOffset == 4 && *puiAltMetaOffset == 4) - { - bDone = TRUE; - break; - } - - pszAltStr++; - } - } - - return( bDone); -} - -/**************************************************************************** -Desc: -****************************************************************************/ -FSTATIC void flmMetaStrToNum( - FLMBYTE * pszMeta, - FLMUINT * puiMeta) -{ - FLMUINT uiMeta = 0; - FLMUINT uiOffset = 0; - - for( ;;) - { - if( *pszMeta) - { - switch( *pszMeta) - { - case '0': - break; - case 'A': - uiMeta += 1; - break; - case 'F': - uiMeta += 2; - break; - case 'H': - uiMeta += 3; - break; - case 'J': - uiMeta += 4; - break; - case 'K': - uiMeta += 5; - break; - case 'L': - uiMeta += 6; - break; - case 'M': - uiMeta += 7; - break; - case 'N': - uiMeta += 8; - break; - case 'P': - uiMeta += 9; - break; - case 'R': - uiMeta += 10; - break; - case 'S': - uiMeta += 11; - break; - case 'T': - uiMeta += 12; - break; - case 'X': - uiMeta += 13; - break; - default: - flmAssert( 0); - } - - pszMeta++; - } - - if( ++uiOffset == 4) - { - flmAssert( *pszMeta == 0); - break; - } - uiMeta <<= 4; - } - - *puiMeta = uiMeta; -} - -/**************************************************************************** -Desc: Generate the metaphone and alternate metaphone keys for a given - input string -Notes: Lawrence Philips' Metaphone Algorithm is an algorithm which returns - the rough approximation of how an English word sounds. Rather - than returning the character representation of the encoded word, - this routine returns a 16-bit numeric representation. -****************************************************************************/ -RCODE flmGetNextMetaphone( - IF_IStream * pIStream, - FLMUINT * puiMetaphone, - FLMUINT * puiAltMetaphone) -{ - RCODE rc = NE_XFLM_OK; - FLMUINT uiInputOffset = 0; - FLMUINT uiInputLen = 0; - FLMUINT uiLast; - FLMUINT uiLoop; - FLMUINT uiMetaOffset = 0; - FLMUINT uiAltMetaOffset = 0; - FLMBOOL bSlavoGermanic = FALSE; - FLMBOOL bHavePrefix = FALSE; -#define MAX_METAPHONE_INPUT_CHARS 32 - FLMUNICODE uzRealInputBuffer[ MAX_METAPHONE_INPUT_CHARS + 6]; - FLMUNICODE * uzInput = &uzRealInputBuffer [5]; - FLMUNICODE uChar; - FLMBYTE ucMeta[ 5]; - FLMBYTE ucAltMeta[ 5]; - - // Tack on five extra spaces at the beginning of the real buffer, so that we - // can safely access characters before the beginning of the string: - // i.e., the uzInput [uiInputLen - n] comparisons. NOTE: n never - // gets to be more than 5. - - for( uiLoop = 0; uiLoop < 5; uiLoop++) - { - uzRealInputBuffer [uiLoop] = FLM_UNICODE_SPACE; - } - - *puiMetaphone = 0; - - if( puiAltMetaphone) - { - *puiAltMetaphone = 0; - } - - // Get the first word from the stream - - for( ;;) - { - if( RC_BAD( rc = flmReadUTF8CharAsUnicode( - pIStream, &uChar))) - { - if (rc == NE_XFLM_EOF_HIT) - { - if( uiInputLen) - { - rc = NE_XFLM_OK; - break; - } - } - - goto Exit; - } - - if( gv_XFlmSysData.pXml->isWhitespace( uChar)) - { - if( !uiInputLen) - { - continue; - } - else - { - // Handle the special cases of "san ", "van ", "von ", - // and "mac ". Since these are common name prefixes - // handled by the metaphone algorithm, we want to continue - // getting the rest of the name. - - if( !bHavePrefix && uiInputLen == 3 && - (f_uninativencmp( uzInput, "san", 3) == 0 || - f_uninativencmp( uzInput, "van", 3) == 0 || - f_uninativencmp( uzInput, "von", 3) == 0 || - f_uninativencmp( uzInput, "mac", 3) == 0)) - { - uzInput[ uiInputLen++] = FLM_UNICODE_SPACE; - bHavePrefix = TRUE; - continue; - } - else - { - if( bHavePrefix && uiInputLen == 4) - { - // Since there wasn't anything following the "prefix", - // the trailing space needs to be removed - - uiInputLen--; - } - break; - } - } - } - - if( uiInputLen < (MAX_METAPHONE_INPUT_CHARS - 5)) - { - uzInput[ uiInputLen++] = f_unitolower( uChar); - - if( !bSlavoGermanic && - (uChar == FLM_UNICODE_w || - uChar == FLM_UNICODE_k || - (uiInputLen > 1 && uChar == FLM_UNICODE_z && - uzInput[ uiInputLen - 2] == FLM_UNICODE_c) || - (uiInputLen >= 4 && uChar == FLM_UNICODE_z && - uzInput[ uiInputLen - 2] == FLM_UNICODE_t && - uzInput[ uiInputLen - 3] == FLM_UNICODE_i && - uzInput[ uiInputLen - 4] == FLM_UNICODE_w))) - { - bSlavoGermanic = TRUE; - } - } - } - - // Tack on five extra spaces to the end of the string so that - // the algorithm below can access characters beyond the end safely. - - for( uiLoop = 0; uiLoop < 5; uiLoop++) - { - uzInput[ uiInputLen + uiLoop] = FLM_UNICODE_SPACE; - } - - uzInput[ uiInputLen + 5] = 0; - uiLast = uiInputLen - 1; - - // Skip the first letter of the following sequences when - // they are found at the beginning of the word - - if( f_uninativencmp( &uzInput[ uiInputOffset], "gn", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset], "kn", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset], "pn", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset], "wr", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset], "ps", 2) == 0) - { - uiInputOffset++; - } - else if( uzInput[ uiInputOffset] == FLM_UNICODE_x) - { - // An initial 'X' is pronounced as a 'Z' which maps to 'S' - - if( flmAddMetaphone( "S", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset++; - } - - while( uiMetaOffset < 4 || uiAltMetaOffset < 4) - { - if( uiInputOffset >= uiInputLen) - { - break; - } - - switch( uzInput[ uiInputOffset]) - { - case FLM_UNICODE_a: - case FLM_UNICODE_e: - case FLM_UNICODE_i: - case FLM_UNICODE_o: - case FLM_UNICODE_u: - case FLM_UNICODE_y: - { - if( !uiInputOffset) - { - // All initial vowels map to 'A' - - if( flmAddMetaphone( "A", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - - uiInputOffset++; - break; - } - - case FLM_UNICODE_b: - { - //"-mb", e.g", "dumb", already skipped over... - - if( flmAddMetaphone( "P", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - if( uzInput[ uiInputOffset + 1] == FLM_UNICODE_b) - { - uiInputOffset += 2; - } - else - { - uiInputOffset++; - } - break; - } - - case FLM_UNICODE_c_CEDILLA: - { - if( flmAddMetaphone( "S", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset++; - break; - } - - case FLM_UNICODE_c: - { - // Various Germanic - - if( uiInputOffset && !f_isvowel( uzInput[ uiInputOffset - 2]) && - f_uninativencmp( &uzInput[ uiInputOffset], "ach", 3) == 0 && - ((f_uninativencmp( &uzInput[ uiInputOffset + 2], "i", 1) != 0) && - ((f_uninativencmp( &uzInput[ uiInputOffset + 2], "e", 1) != 0) || - f_uninativencmp( &uzInput[ uiInputOffset - 2], "bacher", 6) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset - 2], "macher", 6) == 0))) - { - if( flmAddMetaphone( "K", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 2; - break; - } - - // Special case of "caesar" - - if( !uiInputOffset && - f_uninativencmp( &uzInput[ uiInputOffset], "caesar", 6) == 0) - { - if( flmAddMetaphone( "S", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset +=2; - break; - } - - // Italian "chianti" - - if( f_uninativencmp( &uzInput[ uiInputOffset], "chia", 4) == 0) - { - if( flmAddMetaphone( "K", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 2; - break; - } - - if( f_uninativencmp( &uzInput[ uiInputOffset], "ch", 2) == 0) - { - // Handle case of "Michael" - - if( uiInputOffset && - f_uninativencmp( &uzInput[ uiInputOffset], "chae", 4) == 0) - { - if( flmAddMetaphone( "K", "X", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset +=2; - break; - } - - // Greek roots such as "chemistry" and "chorus" - - if( !uiInputOffset && - (f_uninativencmp( &uzInput[ uiInputOffset + 1], "harac", 5) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "haris", 5) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "hor", 3) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "hym", 3) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "hia", 3) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "hem", 3) == 0) && - f_uninativencmp( &uzInput[ uiInputOffset + 1], "chore", 5) != 0) - { - if( flmAddMetaphone( "K", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 2; - break; - } - - // Germanic, Greek 'CH' -> 'KH' - - if( f_uninativencmp( &uzInput[ 0], "van ", 4) == 0 || - f_uninativencmp( &uzInput[ 0], "von ", 4) == 0 || - f_uninativencmp( &uzInput[ 0], "sch", 3) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset - 2], "orches", 6) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset - 2], "archit", 6) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset - 2], "orchid", 6) == 0 || - uzInput[ uiInputOffset + 2] == FLM_UNICODE_t || - uzInput[ uiInputOffset + 2] == FLM_UNICODE_s || - ((uzInput[ uiInputOffset - 1] == FLM_UNICODE_a || - uzInput[ uiInputOffset - 1] == FLM_UNICODE_o || - uzInput[ uiInputOffset - 1] == FLM_UNICODE_u || - uzInput[ uiInputOffset - 1] == FLM_UNICODE_e || - !uiInputOffset) && - (uzInput[ uiInputOffset + 2] == FLM_UNICODE_l || - uzInput[ uiInputOffset + 2] == FLM_UNICODE_r || - uzInput[ uiInputOffset + 2] == FLM_UNICODE_n || - uzInput[ uiInputOffset + 2] == FLM_UNICODE_m || - uzInput[ uiInputOffset + 2] == FLM_UNICODE_b || - uzInput[ uiInputOffset + 2] == FLM_UNICODE_h || - uzInput[ uiInputOffset + 2] == FLM_UNICODE_f || - uzInput[ uiInputOffset + 2] == FLM_UNICODE_v || - uzInput[ uiInputOffset + 2] == FLM_UNICODE_w || - uzInput[ uiInputOffset + 2] == FLM_UNICODE_SPACE))) - { - if( flmAddMetaphone( "K", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - if( uiInputOffset) - { - if( f_uninativencmp( &uzInput[ 0], "mc", 2) == 0) - { - // Names such as "McHugh" - - if( flmAddMetaphone( "K", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - if( flmAddMetaphone( "X", "K", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - } - else - { - if( flmAddMetaphone( "X", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - } - - uiInputOffset += 2; - break; - } - - // "czerny" - - if( f_uninativencmp( &uzInput[ uiInputOffset], "cz", 2) == 0 && - f_uninativencmp( &uzInput[ uiInputOffset - 2], "wicz", 4) != 0) - { - if( flmAddMetaphone( "S", "X", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 2; - break; - } - - if( f_uninativencmp( &uzInput[ uiInputOffset + 1], "cia", 3) == 0) - { - // Words such as "focaccia" - - if( flmAddMetaphone( "X", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 3; - break; - } - - // Double 'C', but not if in a name such as "McClellan" - - if( f_uninativencmp( &uzInput[ uiInputOffset], "cc", 2) == 0 && - !(uiInputOffset == 1 && uzInput[ 0] == FLM_UNICODE_m)) - { - // "bellocchio" but not "bacchus" - - if( (uzInput[ uiInputOffset + 2] == FLM_UNICODE_i || - uzInput[ uiInputOffset + 2] == FLM_UNICODE_e || - uzInput[ uiInputOffset + 2] == FLM_UNICODE_h) && - f_uninativencmp( &uzInput[ uiInputOffset + 2], "hu", 2) != 0) - { - // "accident", "accede", "succeed" - - if( (uiInputOffset == 1 && - uzInput[ uiInputOffset - 1] == FLM_UNICODE_a) || - f_uninativencmp( &uzInput[ uiInputOffset - 1], "uccee", 5) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset - 1], "ucces", 5) == 0) - { - if( flmAddMetaphone( "KS", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - // "bacci", "bertucci", and other Italian words - - if( flmAddMetaphone( "X", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - uiInputOffset += 3; - break; - } - else - { - // Pierce's rule - - if( flmAddMetaphone( "K", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 2; - break; - } - } - - if( f_uninativencmp( &uzInput[ uiInputOffset], "ck", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset], "cg", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset], "cq", 2) == 0) - { - if( flmAddMetaphone( "K", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 2; - break; - } - - if( f_uninativencmp( &uzInput[ uiInputOffset], "ci", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset], "ce", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset], "cy", 2) == 0) - { - // Italian vs. English - - if( f_uninativencmp( &uzInput[ uiInputOffset], "cio", 3) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset], "cie", 3) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset], "cia", 3) == 0) - { - if( flmAddMetaphone( "S", "X", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - if( flmAddMetaphone( "S", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - - uiInputOffset += 2; - break; - } - - // else - - if( flmAddMetaphone( "K", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - // Name such as "Mac Caffrey", "Mac Gregor" - - if( f_uninativencmp( &uzInput[ uiInputOffset + 1], " c", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], " q", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], " g", 2) == 0) - { - uiInputOffset += 3; - } - else - { - if( (uzInput[ uiInputOffset + 1] == FLM_UNICODE_c || - uzInput[ uiInputOffset + 1] == FLM_UNICODE_k || - uzInput[ uiInputOffset + 1] == FLM_UNICODE_q) && - !(f_uninativencmp( &uzInput[ uiInputOffset + 1], "ce", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "ci", 2) == 0)) - { - uiInputOffset += 2; - } - else - { - uiInputOffset += 1; - } - } - - break; - } - - case FLM_UNICODE_d: - { - if( f_uninativencmp( &uzInput[ uiInputOffset], "dg", 2) == 0) - { - if( uzInput[ uiInputOffset + 2] == FLM_UNICODE_i || - uzInput[ uiInputOffset + 2] == FLM_UNICODE_e || - uzInput[ uiInputOffset + 2] == FLM_UNICODE_y) - { - // "edge" - - if( flmAddMetaphone( "J", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 3; - break; - } - else - { - // "edgar" - - if( flmAddMetaphone( "TK", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 2; - break; - } - } - - if( f_uninativencmp( &uzInput[ uiInputOffset], "dt", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset], "dd", 2) == 0) - { - if( flmAddMetaphone( "T", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 2; - break; - } - - // else - - if( flmAddMetaphone( "T", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset++; - break; - } - - case FLM_UNICODE_f: - { - if( uzInput[ uiInputOffset + 1] == FLM_UNICODE_f) - { - uiInputOffset += 2; - } - else - { - uiInputOffset += 1; - } - - if( flmAddMetaphone( "F", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - break; - } - - case FLM_UNICODE_g: - { - if( uzInput[ uiInputOffset + 1] == FLM_UNICODE_h) - { - if( uiInputOffset > 0 && - !f_isvowel( uzInput[ uiInputOffset - 1])) - { - if( flmAddMetaphone( "K", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 2; - break; - } - - if( uiInputOffset < 3) - { - // "ghislane", "ghiradelli" - - if( !uiInputOffset) - { - if( uzInput[ uiInputOffset + 2] == FLM_UNICODE_i) - { - if( flmAddMetaphone( "J", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - if( flmAddMetaphone( "K", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - uiInputOffset += 2; - break; - } - } - - // Parker's rule (with some further refinements) - "hugh" - - if( (uiInputOffset && - (uzInput[ uiInputOffset - 2] == FLM_UNICODE_b || - uzInput[ uiInputOffset - 2] == FLM_UNICODE_h || - uzInput[ uiInputOffset - 2] == FLM_UNICODE_d)) || - (uiInputOffset > 2 && // "bough" - (uzInput[ uiInputOffset - 3] == FLM_UNICODE_b || - uzInput[ uiInputOffset - 3] == FLM_UNICODE_h || - uzInput[ uiInputOffset - 3] == FLM_UNICODE_d)) || - (uiInputOffset > 3 && // "broughton" - (uzInput[ uiInputOffset - 4] == FLM_UNICODE_b || - uzInput[ uiInputOffset - 4] == FLM_UNICODE_h))) - { - uiInputOffset += 2; - break; - } - else - { - // "laugh", "McLaughlin", "cough", "gough", "rough", "tough" - - if( uiInputOffset > 2 && - uzInput[ uiInputOffset - 1] == FLM_UNICODE_u && - (uzInput[ uiInputOffset - 3] == FLM_UNICODE_c || - uzInput[ uiInputOffset - 3] == FLM_UNICODE_g || - uzInput[ uiInputOffset - 3] == FLM_UNICODE_l || - uzInput[ uiInputOffset - 3] == FLM_UNICODE_r || - uzInput[ uiInputOffset - 3] == FLM_UNICODE_t)) - { - if( flmAddMetaphone( "F", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else if( uiInputOffset && uzInput[ uiInputOffset - 1] != FLM_UNICODE_i) - { - if( flmAddMetaphone( "K", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - - uiInputOffset += 2; - break; - } - } - - if( uzInput[ uiInputOffset + 1] == FLM_UNICODE_n) - { - if( uiInputOffset == 1 && f_isvowel( uzInput[ 0]) && - !bSlavoGermanic) - { - if( flmAddMetaphone( "KN", "N", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - // Not "cagney", etc. - - if( f_uninativencmp( &uzInput[ uiInputOffset + 2], "ey", 2) != 0 && - uzInput[ uiInputOffset + 1] != FLM_UNICODE_y && - !bSlavoGermanic) - { - if( flmAddMetaphone( "N", "KN", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - if( flmAddMetaphone( "KN", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - } - - uiInputOffset += 2; - break; - } - - // "tagliaro" - - if( f_uninativencmp( &uzInput[ uiInputOffset + 1], "li", 2) == 0 && - !bSlavoGermanic) - { - if( flmAddMetaphone( "KL", "L", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 2; - break; - } - - // Words starting with "ges", "gep", "gel", "gie", etc. - - if( !uiInputOffset && - (uzInput[ uiInputOffset + 1] == FLM_UNICODE_y || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "es", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "ep", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "eb", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "el", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "ey", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "ib", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "il", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "in", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "ie", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "ei", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "er", 2) == 0)) - { - if( flmAddMetaphone( "K", "J", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 2; - break; - } - - // -ger-, -gy- - - if( (f_uninativencmp( &uzInput[ uiInputOffset + 1], "er", 2) == 0 || - uzInput[ uiInputOffset + 1] == FLM_UNICODE_y) && - !(f_uninativencmp( &uzInput[ 0], "danger", 6) == 0 || - f_uninativencmp( &uzInput[ 0], "ranger", 6) == 0 || - f_uninativencmp( &uzInput[ 0], "manger", 6) == 0) && - !(uzInput[ uiInputOffset - 1] == FLM_UNICODE_e || - uzInput[ uiInputOffset - 1] == FLM_UNICODE_i) && - !(f_uninativencmp( &uzInput[ uiInputOffset - 1], "rgy", 3) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset - 1], "ogy", 3) == 0)) - { - if( flmAddMetaphone( "K", "J", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 2; - break; - } - - // Italian words such as "biaggi" - - if( uzInput[ uiInputOffset + 1] == FLM_UNICODE_e || - uzInput[ uiInputOffset + 1] == FLM_UNICODE_i || - uzInput[ uiInputOffset + 1] == FLM_UNICODE_y || - f_uninativencmp( &uzInput[ uiInputOffset - 1], "aggi", 4) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset - 1], "oggi", 4) == 0) - { - // Obvious Germanic - - if( f_uninativencmp( &uzInput[ 0], "van ", 4) == 0 || - f_uninativencmp( &uzInput[ 0], "von ", 4) == 0 || - f_uninativencmp( &uzInput[ 0], "sch", 3) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "et", 2) == 0) - { - if( flmAddMetaphone( "K", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - // Always soft if French ending - - if( f_uninativencmp( &uzInput[ uiInputOffset + 1], "ier ", 4) == 0) - { - if( flmAddMetaphone( "J", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - if( flmAddMetaphone( "J", "K", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - uiInputOffset += 2; - break; - } - } - - if( uzInput[ uiInputOffset + 1] == FLM_UNICODE_g) - { - uiInputOffset += 2; - } - else - { - uiInputOffset += 1; - } - - if( flmAddMetaphone( "K", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - break; - } - - case FLM_UNICODE_h: - { - // Only keep if first and if before a vowel or between two vowels - - if( (!uiInputOffset || f_isvowel( uzInput[ uiInputOffset - 1])) && - f_isvowel( uzInput[ uiInputOffset + 1])) - { - if( flmAddMetaphone( "H", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 2; - } - else - { - // Take care of "HH" - - uiInputOffset++; - } - break; - } - - case FLM_UNICODE_j: - { - // Obvious Spanish such as "Jose" and "San Jacinto" - - if( f_uninativencmp( &uzInput[ uiInputOffset], "jose", 4) == 0 || - f_uninativencmp( &uzInput[ 0], "san ", 4) == 0) - { - if( (!uiInputOffset && uzInput[ uiInputOffset + 4] == FLM_UNICODE_SPACE) || - f_uninativencmp( &uzInput[ 0], "san ", 4) == 0) - { - if( flmAddMetaphone( "H", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - if( flmAddMetaphone( "J", "H", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - uiInputOffset++; - break; - } - - if( !uiInputOffset && - f_uninativencmp( &uzInput[ uiInputOffset], "jose", 4) != 0) - { - // Yankelovich / Jankelowicz - - if( flmAddMetaphone( "J", "A", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - // Spanish pronunciation of words such as "bajador" - - if( f_isvowel( uzInput[ uiInputOffset - 1]) && - !bSlavoGermanic && - (uzInput[ uiInputOffset + 1] == FLM_UNICODE_a || - uzInput[ uiInputOffset + 1] == FLM_UNICODE_o)) - { - if( flmAddMetaphone( "J", "H", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - if( uiInputOffset == uiLast) - { - if( flmAddMetaphone( "J", NULL, ucMeta, &uiMetaOffset, - NULL, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - if( uzInput[ uiInputOffset + 1] != FLM_UNICODE_l && - uzInput[ uiInputOffset + 1] != FLM_UNICODE_t && - uzInput[ uiInputOffset + 1] != FLM_UNICODE_k && - uzInput[ uiInputOffset + 1] != FLM_UNICODE_s && - uzInput[ uiInputOffset + 1] != FLM_UNICODE_n && - uzInput[ uiInputOffset + 1] != FLM_UNICODE_m && - uzInput[ uiInputOffset + 1] != FLM_UNICODE_b && - uzInput[ uiInputOffset + 1] != FLM_UNICODE_z && - uzInput[ uiInputOffset - 1] != FLM_UNICODE_s && - uzInput[ uiInputOffset - 1] != FLM_UNICODE_k && - uzInput[ uiInputOffset - 1] != FLM_UNICODE_l) - { - if( flmAddMetaphone( "J", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - } - } - } - - if( uzInput[ uiInputOffset + 1] == FLM_UNICODE_j) - { - uiInputOffset += 2; - } - else - { - uiInputOffset++; - } - break; - } - - case FLM_UNICODE_k: - { - if( uzInput[ uiInputOffset + 1] == FLM_UNICODE_k) - { - uiInputOffset += 2; - } - else - { - uiInputOffset++; - } - - if( flmAddMetaphone( "K", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - break; - } - - case FLM_UNICODE_l: - { - if( uzInput[ uiInputOffset + 1] == FLM_UNICODE_l) - { - // Spanish words such as "cabrillo" and "gallegos" - - if( (uiInputOffset == (uiInputLen - 3) && - (f_uninativencmp( &uzInput[ uiInputOffset - 1], "illo", 4) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset - 1], "illa", 4) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset - 1], "alle", 4) == 0)) || - ((f_uninativencmp( &uzInput[ uiLast - 1], "as", 2) == 0 || - f_uninativencmp( &uzInput[ uiLast - 1], "os", 2) == 0 || - uzInput[ uiLast] == FLM_UNICODE_a || - uzInput[ uiLast] == FLM_UNICODE_o) && - f_uninativencmp( &uzInput[ uiInputOffset - 1], "alle", 4) == 0)) - { - if( flmAddMetaphone( "L", NULL, ucMeta, &uiMetaOffset, - NULL, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 2; - break; - } - uiInputOffset += 2; - } - else - { - uiInputOffset++; - } - - if( flmAddMetaphone( "L", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - break; - } - - case FLM_UNICODE_m: - { - if( (f_uninativencmp( &uzInput[ uiInputOffset - 1], "umb", 3) == 0 && - ((uiInputOffset + 1) == uiLast || - f_uninativencmp( &uzInput[ uiInputOffset + 2], "er", 2) == 0)) || - uzInput[ uiInputOffset + 1] == FLM_UNICODE_m) // "dumb", "thumb", etc. - { - uiInputOffset += 2; - } - else - { - uiInputOffset++; - } - - if( flmAddMetaphone( "M", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - break; - } - - case FLM_UNICODE_n: - { - if( uzInput[ uiInputOffset + 1] == FLM_UNICODE_n) - { - uiInputOffset += 2; - } - else - { - uiInputOffset++; - } - - if( flmAddMetaphone( "N", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - break; - } - - case FLM_UNICODE_n_TILDE: - { - if( flmAddMetaphone( "N", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset++; - break; - } - - case FLM_UNICODE_p: - { - if( uzInput[ uiInputOffset + 1] == FLM_UNICODE_h) - { - if( flmAddMetaphone( "F", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 2; - break; - } - - // Account for "Campbell", "raspberry", etc. - - if( uzInput[ uiInputOffset + 1] == FLM_UNICODE_p || - uzInput[ uiInputOffset + 1] == FLM_UNICODE_b) - { - uiInputOffset += 2; - } - else - { - uiInputOffset++; - } - - if( flmAddMetaphone( "P", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - break; - } - - case FLM_UNICODE_q: - { - if( uzInput[ uiInputOffset + 1] == FLM_UNICODE_q) - { - uiInputOffset += 2; - } - else - { - uiInputOffset += 1; - } - - if( flmAddMetaphone( "K", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - break; - } - - case FLM_UNICODE_r: - { - // French words such as "rogier". Excludes "Hochmeier" - - if( uiInputOffset == uiLast && - !bSlavoGermanic && - f_uninativencmp( &uzInput[ uiInputOffset - 2], "ie", 2) == 0 && - f_uninativencmp( &uzInput[ uiInputOffset - 4], "me", 2) != 0 && - f_uninativencmp( &uzInput[ uiInputOffset - 4], "ma", 2) != 0) - { - if( flmAddMetaphone( NULL, "R", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - if( flmAddMetaphone( "R", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - - if( uzInput[ uiInputOffset + 1] == FLM_UNICODE_r) - { - uiInputOffset += 2; - } - else - { - uiInputOffset++; - } - break; - } - - case FLM_UNICODE_s: - { - // Special cases of "island", "isle", "carlisle", "carlysle" - - if( f_uninativencmp( &uzInput[ uiInputOffset - 1], "isl", 3) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset - 1], "ysl", 3) == 0) - { - uiInputOffset++; - break; - } - - // Special case of 'sugar-' - - if( !uiInputOffset && - f_uninativencmp( &uzInput[ uiInputOffset], "sugar", 5) == 0) - { - if( flmAddMetaphone( "X", "S", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset++; - break; - } - - if( f_uninativencmp( &uzInput[ uiInputOffset], "sh", 2) == 0) - { - // Germanic - - if( f_uninativencmp( &uzInput[ uiInputOffset + 1], "heim", 4) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "hoek", 4) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "holm", 4) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "holz", 4) == 0) - { - if( flmAddMetaphone( "S", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - if( flmAddMetaphone( "X", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - - uiInputOffset += 2; - break; - } - - // Italian and Armenian - - if( f_uninativencmp( &uzInput[ uiInputOffset], "sio", 3) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset], "sia", 3) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset], "sian", 4) == 0) - { - if( !bSlavoGermanic) - { - if( flmAddMetaphone( "S", "X", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - if( flmAddMetaphone( "S", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - - uiInputOffset += 3; - break; - } - - // German & Anglicisations such as "Smith" matching "Schmidt" and - // "Snider" matching "Schneider" - - if( (!uiInputOffset && - (uzInput[ uiInputOffset + 1] == FLM_UNICODE_m || - uzInput[ uiInputOffset + 1] == FLM_UNICODE_n || - uzInput[ uiInputOffset + 1] == FLM_UNICODE_l || - uzInput[ uiInputOffset + 1] == FLM_UNICODE_w)) || - uzInput[ uiInputOffset + 1] == FLM_UNICODE_z) - { - if( flmAddMetaphone( "S", "X", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - if( uzInput[ uiInputOffset + 1] == FLM_UNICODE_z) - { - uiInputOffset += 2; - } - else - { - uiInputOffset++; - } - break; - } - - if( f_uninativencmp( &uzInput[ uiInputOffset], "sc", 2) == 0) - { - // Schlesinger's rule - - if( uzInput[ uiInputOffset + 2] == FLM_UNICODE_h) - { - // Words of Dutch origin such as "school" and "schooner" - - if( f_uninativencmp( &uzInput[ uiInputOffset + 3], "oo", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 3], "er", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 3], "en", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 3], "uy", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 3], "ed", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 3], "em", 2) == 0) - { - // "Schermerhorn", "Schenker" - - if( f_uninativencmp( &uzInput[ uiInputOffset + 3], "er", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 3], "en", 2) == 0) - { - if( flmAddMetaphone( "X", "SK", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - if( flmAddMetaphone( "SK", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - - uiInputOffset += 3; - break; - } - else - { - if( !uiInputOffset && !f_isvowel( uzInput[ 3]) && - uzInput[ 3] != FLM_UNICODE_w) - { - if( flmAddMetaphone( "X", "S", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - if( flmAddMetaphone( "X", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - - uiInputOffset += 3; - break; - } - } - - if( uzInput[ uiInputOffset + 2] == FLM_UNICODE_i || - uzInput[ uiInputOffset + 2] == FLM_UNICODE_e || - uzInput[ uiInputOffset + 2] == FLM_UNICODE_y) - { - if( flmAddMetaphone( "S", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 3; - break; - } - - if( flmAddMetaphone( "SK", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 3; - break; - } - - // French words such as "resnais" and "artois" - - if( uiInputOffset == uiLast && - (f_uninativencmp( &uzInput[ uiInputOffset - 2], "ai", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset - 2], "oi", 2) == 0)) - { - if( flmAddMetaphone( NULL, "S", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - if( flmAddMetaphone( "S", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - - if( uzInput[ uiInputOffset + 1] == FLM_UNICODE_s || - uzInput[ uiInputOffset + 1] == FLM_UNICODE_z) - { - uiInputOffset += 2; - } - else - { - uiInputOffset++; - } - break; - } - - case FLM_UNICODE_t: - { - if( f_uninativencmp( &uzInput[ uiInputOffset], "tion", 4) == 0) - { - if( flmAddMetaphone( "X", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 3; - break; - } - - if( f_uninativencmp( &uzInput[ uiInputOffset], "tia", 3) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset], "tch", 3) == 0) - { - if( flmAddMetaphone( "X", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 3; - break; - } - - if( f_uninativencmp( &uzInput[ uiInputOffset], "th", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset], "tth", 3) == 0) - { - // Special cases of "Thomas", "Thames", or Germanic - - if( f_uninativencmp( &uzInput[ uiInputOffset + 2], "om", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 2], "am", 2) == 0 || - f_uninativencmp( &uzInput[ 0], "van ", 4) == 0 || - f_uninativencmp( &uzInput[ 0], "von ", 4) == 0 || - f_uninativencmp( &uzInput[ 0], "sch", 3) == 0) - { - if( flmAddMetaphone( "T", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - if( flmAddMetaphone( "0", "T", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - - uiInputOffset += 2; - break; - } - - if( uzInput[ uiInputOffset + 1] == FLM_UNICODE_t || - uzInput[ uiInputOffset] == FLM_UNICODE_d) - { - uiInputOffset += 2; - } - else - { - uiInputOffset++; - } - - if( flmAddMetaphone( "T", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - break; - } - - case FLM_UNICODE_v: - { - if( uzInput[ uiInputOffset + 1] == FLM_UNICODE_v) - { - uiInputOffset += 2; - } - else - { - uiInputOffset++; - } - - if( flmAddMetaphone( "F", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - break; - } - - case FLM_UNICODE_w: - { - if( f_uninativencmp( &uzInput[ uiInputOffset], "wr", 2) == 0) - { - if( flmAddMetaphone( "R", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 2; - break; - } - - if( !uiInputOffset && - (f_isvowel( uzInput[ uiInputOffset + 1]) || - f_uninativencmp( &uzInput[ uiInputOffset], "wh", 2) == 0)) - { - // "Wasserman" should match "Vasserman" - - if( f_isvowel( uzInput[ uiInputOffset + 1])) - { - if( flmAddMetaphone( "A", "F", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - // "Uomo" should match "Womo" - - if( flmAddMetaphone( "A", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - } - - // "Arnow" should match "Arnoff" - - if( (uiInputOffset == uiLast && - f_isvowel( uzInput[ uiInputOffset - 1])) || - f_uninativencmp( &uzInput[ uiInputOffset - 1], "ewski", 5) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset - 1], "ewsky", 5) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset - 1], "owski", 5) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset - 1], "owsky", 5) == 0 || - f_uninativencmp( &uzInput[ 0], "sch", 3) == 0) - { - if( flmAddMetaphone( NULL, "F", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset++; - break; - } - - // Polish names and words such as "Filipowicz" - - if( f_uninativencmp( &uzInput[ uiInputOffset], "wicz", 4) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset], "witz", 4) == 0) - { - if( flmAddMetaphone( "TS", "FX", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset +=4; - break; - } - - // otherwise, skip the current character - - uiInputOffset++; - break; - } - - case FLM_UNICODE_x: - { - // French words such as "breaux" - - if( !(uiInputOffset == uiLast && - (f_uninativencmp( &uzInput[ uiInputOffset - 3], "iau", 3) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset - 3], "eau", 3) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset - 2], "au", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset - 2], "ou", 2) == 0))) - { - if( flmAddMetaphone( "KS", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - - if( uzInput[ uiInputOffset + 1] == FLM_UNICODE_c || - uzInput[ uiInputOffset + 1] == FLM_UNICODE_x) - { - uiInputOffset += 2; - } - else - { - uiInputOffset++; - } - break; - } - - case FLM_UNICODE_z: - { - // Chinese pinyin such as "Zhao" - - if( uzInput[ uiInputOffset + 1] == FLM_UNICODE_h) - { - if( flmAddMetaphone( "J", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - - uiInputOffset += 2; - break; - } - else - { - if( f_uninativencmp( &uzInput[ uiInputOffset + 1], "zo", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "zi", 2) == 0 || - f_uninativencmp( &uzInput[ uiInputOffset + 1], "za", 2) == 0 || - (bSlavoGermanic && uiInputOffset && - uzInput[ uiInputOffset - 1] != FLM_UNICODE_t)) - { - if( flmAddMetaphone( "S", "TS", ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - else - { - if( flmAddMetaphone( "S", NULL, ucMeta, &uiMetaOffset, - ucAltMeta, &uiAltMetaOffset)) - { - goto Done; - } - } - - if( uzInput[ uiInputOffset + 1] == FLM_UNICODE_z) - { - uiInputOffset += 2; - } - else - { - uiInputOffset++; - } - } - - break; - } - - default: - { - uiInputOffset++; - break; - } - } - } - -Done: - - ucMeta[ uiMetaOffset] = 0; - flmMetaStrToNum( ucMeta, puiMetaphone); - - if( puiAltMetaphone) - { - ucAltMeta[ uiAltMetaOffset] = 0; - flmMetaStrToNum( ucAltMeta, puiAltMetaphone); - } - -Exit: - - return( rc); -} - -/**************************************************************************** -Desc: Verifies that the metaphone routines are generating the correct - codes for a hard-coded set of words. -****************************************************************************/ -#ifdef FLM_DEBUG -RCODE flmVerifyMetaphoneRoutines( void) -{ - RCODE rc = NE_XFLM_OK; - METAPHONE_MAPPING * pMetaMap = gv_MetaTestTable; - F_BufferIStream bufferStream; - FLMUINT uiMeta; - FLMUINT uiAltMeta; - - for( ;;) - { - if( !pMetaMap->pszWord) - { - break; - } - - if( RC_BAD( rc = bufferStream.open( - (FLMBYTE *)pMetaMap->pszWord, f_strlen( pMetaMap->pszWord)))) - { - goto Exit; - } - - if( RC_BAD( rc = flmGetNextMetaphone( &bufferStream, - &uiMeta, &uiAltMeta))) - { - goto Exit; - } - - if( uiMeta != pMetaMap->uiMeta || - uiAltMeta != pMetaMap->uiAltMeta) - { - rc = RC_SET_AND_ASSERT( NE_XFLM_FAILURE); - goto Exit; - } - - bufferStream.close(); - pMetaMap++; - } - -Exit: - - flmAssert( RC_OK( rc)); - return( rc); -} -#endif diff --git a/xflaim/src/kyeword.cpp b/xflaim/src/kyeword.cpp index 009f60f..167b2a6 100644 --- a/xflaim/src/kyeword.cpp +++ b/xflaim/src/kyeword.cpp @@ -94,7 +94,7 @@ FSTATIC RCODE flmGetCharacter( for( ;;) { - if (RC_BAD( rc = flmReadUTF8CharAsUnicode( pIStream, &uChar))) + if (RC_BAD( rc = f_readUTF8CharAsUnicode( pIStream, &uChar))) { if (rc != NE_XFLM_EOF_HIT) { @@ -118,7 +118,7 @@ FSTATIC RCODE flmGetCharacter( break; } - if ((uChar = flmConvertChar( uChar, uiCompareRules)) == 0) + if ((uChar = f_convertChar( uChar, uiCompareRules)) == 0) { continue; } @@ -175,7 +175,7 @@ FSTATIC RCODE flmGetCharacter( if (pui16WPValue) { - if (!flmUnicodeToWP( uChar, pui16WPValue)) + if (!f_unicodeToWP( uChar, pui16WPValue)) { *pui16WPValue = 0; } @@ -240,7 +240,7 @@ RCODE KYSubstringParse( uiCharCnt++; uiSize = uiDestSize - uiDestOffset; - if (RC_BAD( rc = flmUni2UTF8( uChar, &pucSubstrBuf[ uiDestOffset], &uiSize))) + if (RC_BAD( rc = f_uni2UTF8( uChar, &pucSubstrBuf[ uiDestOffset], &uiSize))) { goto Exit; } @@ -328,7 +328,7 @@ RCODE KYEachWordParse( bSkippingDelim = FALSE; uiLimit--; uiSize = uiWordBufSize - uiWordLen; - if (RC_BAD( rc = flmUni2UTF8( uChar, &pucWordBuf [uiWordLen], + if (RC_BAD( rc = f_uni2UTF8( uChar, &pucWordBuf [uiWordLen], &uiSize))) { goto Exit; @@ -347,7 +347,7 @@ RCODE KYEachWordParse( break; } uiSize = uiWordBufSize - uiWordLen; - if (RC_BAD( rc = flmUni2UTF8( uChar, &pucWordBuf [uiWordLen], + if (RC_BAD( rc = f_uni2UTF8( uChar, &pucWordBuf [uiWordLen], &uiSize))) { goto Exit; diff --git a/xflaim/src/kyqsort.cpp b/xflaim/src/kyqsort.cpp index b798c11..83d7088 100644 --- a/xflaim/src/kyqsort.cpp +++ b/xflaim/src/kyqsort.cpp @@ -37,15 +37,6 @@ FSTATIC RCODE ixKeyGetNodeId( FLMUINT uiKeyComponent, FLMUINT64 * pui64NodeId); -FSTATIC RCODE ixKeyCompareUnicode( - ICD * pIcd, - FLMUINT uiLanguage, - FLMUNICODE * puzStr1, - FLMUINT uiByteLen1, - FLMUNICODE * puzStr2, - FLMUINT uiByteLen2, - FLMINT * piCompare); - FSTATIC RCODE ixKeyGetUnicode( F_Db * pDb, ICD * pIcd, @@ -128,7 +119,7 @@ FSTATIC RCODE ixKeyGetNodeId( // Skip past the document ID - if (RC_BAD( rc = flmDecodeSEN64( &pucKey, pucKeyEnd, NULL))) + if (RC_BAD( rc = f_decodeSEN64( &pucKey, pucKeyEnd, NULL))) { goto Exit; } @@ -145,7 +136,7 @@ FSTATIC RCODE ixKeyGetNodeId( // Skip the component node ID - passing a NULL for the last // parameter is cheaper than getting it out. - if (RC_BAD( rc = flmDecodeSEN64( &pucKey, pucKeyEnd, NULL))) + if (RC_BAD( rc = f_decodeSEN64( &pucKey, pucKeyEnd, NULL))) { goto Exit; } @@ -158,59 +149,7 @@ FSTATIC RCODE ixKeyGetNodeId( // Should now be positioned on the one we want, extract it. - if (RC_BAD( rc = flmDecodeSEN64( &pucKey, pucKeyEnd, pui64NodeId))) - { - goto Exit; - } - -Exit: - - return( rc); -} - -/*************************************************************************** -Desc: Compares result set entries during the finalization stage to allow - the result set to be sorted and to remove duplicates. -*****************************************************************************/ -FSTATIC RCODE ixKeyCompareUnicode( - ICD * pIcd, - FLMUINT uiLanguage, - FLMUNICODE * puzStr1, - FLMUINT uiByteLen1, - FLMUNICODE * puzStr2, - FLMUINT uiByteLen2, - FLMINT * piCompare) -{ - RCODE rc = NE_XFLM_OK; - F_BufferIStream bufferLStream; - F_BufferIStream bufferRStream; - F_CollIStream lStream; - F_CollIStream rStream; - - if (RC_BAD( rc = bufferLStream.open( (FLMBYTE *)puzStr1, uiByteLen1))) - { - goto Exit; - } - - if (RC_BAD( rc = bufferRStream.open( (FLMBYTE *)puzStr2, uiByteLen2))) - { - goto Exit; - } - - if (RC_BAD( rc = lStream.open( &bufferLStream, TRUE, uiLanguage, - pIcd->uiCompareRules, FALSE))) - { - goto Exit; - } - - if (RC_BAD( rc = rStream.open( &bufferRStream, TRUE, uiLanguage, - pIcd->uiCompareRules, FALSE))) - { - goto Exit; - } - - if (RC_BAD( rc = fqCompareCollStreams( &lStream, &rStream, FALSE, - uiLanguage, piCompare))) + if (RC_BAD( rc = f_decodeSEN64( &pucKey, pucKeyEnd, pui64NodeId))) { goto Exit; } @@ -706,12 +645,15 @@ RCODE ixKeyCompare( { goto Exit; } - if (RC_BAD( rc = ixKeyCompareUnicode( pIcd, - pIxd->uiLanguage, + + if (RC_BAD( rc = f_compareUnicodeStrings( dynaBuf1.getUnicodePtr(), dynaBuf1.getDataLength(), + FALSE, dynaBuf2.getUnicodePtr(), - dynaBuf2.getDataLength(), piCompare))) + dynaBuf2.getDataLength(), + FALSE, pIcd->uiCompareRules, + pIxd->uiLanguage, piCompare))) { goto Exit; } @@ -890,11 +832,11 @@ Test_Exclusive: // At this point, both keys should be positioned to // get the document ID. - if (RC_BAD( rc = flmDecodeSEN64( &pucKey1, pucKeyEnd1, &ui64DocId1))) + if (RC_BAD( rc = f_decodeSEN64( &pucKey1, pucKeyEnd1, &ui64DocId1))) { goto Exit; } - if (RC_BAD( rc = flmDecodeSEN64( &pucKey2, pucKeyEnd2, &ui64DocId2))) + if (RC_BAD( rc = f_decodeSEN64( &pucKey2, pucKeyEnd2, &ui64DocId2))) { goto Exit; } @@ -1066,7 +1008,7 @@ RCODE F_Db::keysCommit( if (m_bKrefSetup) { LFILE * pLFile = NULL; - IXD * pIxd; + IXD * pIxd = NULL; FLMUINT uiTotal = m_uiKrefCount; KREF_ENTRY * pKref; KREF_ENTRY ** pKrefTbl = m_pKrefTbl; diff --git a/xflaim/src/kyunlock.cpp b/xflaim/src/kyunlock.cpp index 3d4ae16..e7cbe08 100644 --- a/xflaim/src/kyunlock.cpp +++ b/xflaim/src/kyunlock.cpp @@ -59,13 +59,17 @@ RCODE F_Db::krefCntrlCheck( void) if (m_eTransType == XFLM_UPDATE_TRANS) { - m_pKrefPool = &m_pDatabase->m_krefPool; + m_pKrefPool = m_pDatabase->m_pKrefPool; + m_pKrefPool->AddRef(); + m_bReuseKrefPool = TRUE; m_pKrefPool->poolReset( NULL, TRUE); } else { - m_pKrefPool = &m_tmpKrefPool; + m_pKrefPool = m_pTmpKrefPool; + m_pKrefPool->AddRef(); + m_bReuseKrefPool = FALSE; m_pKrefPool->poolInit( DEFAULT_KREF_POOL_BLOCK_SIZE); } @@ -118,6 +122,9 @@ void F_Db::krefCntrlFree( void) { m_pKrefPool->poolFree(); } + + m_pKrefPool->Release(); + m_pKrefPool = NULL; if( m_pKrefTbl && m_uiKrefTblSize != DEFAULT_KREF_TBL_SIZE) { @@ -127,7 +134,6 @@ void F_Db::krefCntrlFree( void) m_uiKrefCount = 0; m_uiTotalKrefBytes = 0; - m_pKrefPool = NULL; m_bReuseKrefPool = FALSE; m_bKrefCompoundKey = FALSE; m_pKrefReset = NULL; diff --git a/xflaim/src/ncache.cpp b/xflaim/src/ncache.cpp index 92da600..1113a08 100644 --- a/xflaim/src/ncache.cpp +++ b/xflaim/src/ncache.cpp @@ -36,6 +36,9 @@ Desc: Constructor ****************************************************************************/ F_NodeCacheMgr::F_NodeCacheMgr() { + m_pNodeAllocator = NULL; + m_pBufAllocator = NULL; + m_pAttrItemAllocator = NULL; m_pPurgeList = NULL; m_pHeapList = NULL; m_pOldList = NULL; @@ -89,10 +92,6 @@ F_CachedNode::F_CachedNode() m_uiFlags = 0; f_memset( &m_nodeInfo, 0, sizeof( F_NODE_INFO)); - -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } /**************************************************************************** @@ -136,7 +135,7 @@ F_CachedNode::~F_CachedNode() if (m_pucData) { pucActualAlloc = getActualPointer( m_pucData); - gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.freeBuf( + gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->freeBuf( m_uiDataBufSize, &pucActualAlloc); m_pucData = NULL; } @@ -144,7 +143,7 @@ F_CachedNode::~F_CachedNode() if (m_pNodeList) { pucActualAlloc = getActualPointer( m_pNodeList); - gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.freeBuf( + gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->freeBuf( calcNodeListBufSize( m_nodeInfo.uiChildElmCount), &pucActualAlloc); m_pNodeList = NULL; @@ -162,7 +161,7 @@ F_CachedNode::~F_CachedNode() flmAssert( !m_uiTotalAttrSize); pucActualAlloc = getActualPointer( m_ppAttrList); - gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.freeBuf( + gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->freeBuf( calcAttrListBufSize( m_uiAttrCount), &pucActualAlloc); m_ppAttrList = NULL; @@ -194,10 +193,6 @@ void F_CachedNode::freePurged( void) unsetPurged(); -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif - delete this; } @@ -249,25 +244,13 @@ void F_CachedNode::freeCache( if (!bPutInPurgeList) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif delete this; } else { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif if ((m_pNextInGlobal = gv_XFlmSysData.pNodeCacheMgr->m_pPurgeList) != NULL) { -#ifdef FLM_CACHE_PROTECT - m_pNextInGlobal->unprotectCachedItem(); -#endif m_pNextInGlobal->m_pPrevInGlobal = this; -#ifdef FLM_CACHE_PROTECT - m_pNextInGlobal->protectCachedItem(); -#endif } gv_XFlmSysData.pNodeCacheMgr->m_pPurgeList = this; @@ -276,9 +259,6 @@ void F_CachedNode::freeCache( m_uiFlags &= ~(FDOM_DIRTY | FDOM_NEW); setPurged(); -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif flmAssert( !m_pPrevInGlobal); } } @@ -305,26 +285,40 @@ RCODE F_NodeCacheMgr::initCache( void) // Set up the F_CachedNode object allocator - if (RC_BAD( rc = m_nodeAllocator.setup( &m_nodeRelocator, + if( RC_BAD( rc = FlmAllocFixedAllocator( &m_pNodeAllocator))) + { + goto Exit; + } + + if (RC_BAD( rc = m_pNodeAllocator->setup( &m_nodeRelocator, gv_XFlmSysData.pGlobalCacheMgr->m_pSlabManager, - TRUE, sizeof( F_CachedNode), &m_Usage.slabUsage))) + sizeof( F_CachedNode), &m_Usage.slabUsage))) { goto Exit; } // Set up the buffer allocator for F_CachedNode objects - if (RC_BAD( rc = m_bufAllocator.setup( - gv_XFlmSysData.pGlobalCacheMgr->m_pSlabManager, FALSE, - &m_Usage.slabUsage))) + if( RC_BAD( rc = FlmAllocBufferAllocator( &m_pBufAllocator))) + { + goto Exit; + } + + if (RC_BAD( rc = m_pBufAllocator->setup( + gv_XFlmSysData.pGlobalCacheMgr->m_pSlabManager, &m_Usage.slabUsage))) { goto Exit; } // Set up the allocator for attribute items - if( RC_BAD( rc = m_attrItemAllocator.setup( &m_attrItemRelocator, - gv_XFlmSysData.pGlobalCacheMgr->m_pSlabManager, FALSE, + if( RC_BAD( rc = FlmAllocFixedAllocator( &m_pAttrItemAllocator))) + { + goto Exit; + } + + if( RC_BAD( rc = m_pAttrItemAllocator->setup( &m_attrItemRelocator, + gv_XFlmSysData.pGlobalCacheMgr->m_pSlabManager, sizeof( F_AttrItem), &m_Usage.slabUsage))) { goto Exit; @@ -404,134 +398,62 @@ void F_NodeRelocator::relocate( if (pNewNode->m_pPrevInDatabase) { -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pPrevInDatabase->unprotectCachedItem(); -#endif pNewNode->m_pPrevInDatabase->m_pNextInDatabase = pNewNode; -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pPrevInDatabase->protectCachedItem(); -#endif } if (pNewNode->m_pNextInDatabase) { -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pNextInDatabase->unprotectCachedItem(); -#endif pNewNode->m_pNextInDatabase->m_pPrevInDatabase = pNewNode; -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pNextInDatabase->protectCachedItem(); -#endif } if (pNewNode->m_pPrevInGlobal) { -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pPrevInGlobal->unprotectCachedItem(); -#endif pNewNode->m_pPrevInGlobal->m_pNextInGlobal = pNewNode; -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pPrevInGlobal->protectCachedItem(); -#endif } if (pNewNode->m_pNextInGlobal) { -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pNextInGlobal->unprotectCachedItem(); -#endif pNewNode->m_pNextInGlobal->m_pPrevInGlobal = pNewNode; -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pNextInGlobal->protectCachedItem(); -#endif } if (pNewNode->m_pPrevInBucket) { -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pPrevInBucket->unprotectCachedItem(); -#endif pNewNode->m_pPrevInBucket->m_pNextInBucket = pNewNode; -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pPrevInBucket->protectCachedItem(); -#endif } if (pNewNode->m_pNextInBucket) { -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pNextInBucket->unprotectCachedItem(); -#endif pNewNode->m_pNextInBucket->m_pPrevInBucket = pNewNode; -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pNextInBucket->protectCachedItem(); -#endif } if (pNewNode->m_pOlderVersion) { -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pOlderVersion->unprotectCachedItem(); -#endif pNewNode->m_pOlderVersion->m_pNewerVersion = pNewNode; -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pOlderVersion->protectCachedItem(); -#endif } if (pNewNode->m_pNewerVersion) { -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pNewerVersion->unprotectCachedItem(); -#endif pNewNode->m_pNewerVersion->m_pOlderVersion = pNewNode; -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pNewerVersion->protectCachedItem(); -#endif } if (pNewNode->m_pPrevInHeapList) { -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pPrevInHeapList->unprotectCachedItem(); -#endif pNewNode->m_pPrevInHeapList->m_pNextInHeapList = pNewNode; -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pPrevInHeapList->protectCachedItem(); -#endif } if (pNewNode->m_pNextInHeapList) { -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pNextInHeapList->unprotectCachedItem(); -#endif pNewNode->m_pNextInHeapList->m_pPrevInHeapList = pNewNode; -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pNextInHeapList->protectCachedItem(); -#endif } if (pNewNode->m_pPrevInOldList) { -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pPrevInOldList->unprotectCachedItem(); -#endif pNewNode->m_pPrevInOldList->m_pNextInOldList = pNewNode; -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pPrevInOldList->protectCachedItem(); -#endif } if (pNewNode->m_pNextInOldList) { -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pNextInOldList->unprotectCachedItem(); -#endif pNewNode->m_pNextInOldList->m_pPrevInOldList = pNewNode; -#ifdef FLM_CACHE_PROTECT - pNewNode->m_pNextInOldList->protectCachedItem(); -#endif } if( pDatabase) @@ -914,6 +836,23 @@ F_NodeCacheMgr::~F_NodeCacheMgr() f_free( &m_ppHashBuckets); gv_XFlmSysData.pGlobalCacheMgr->decrTotalBytes( uiTotalMemory); } + + // Free the allocators + + if (m_pNodeAllocator) + { + m_pNodeAllocator->Release(); + } + + if( m_pBufAllocator) + { + m_pBufAllocator->Release(); + } + + if( m_pAttrItemAllocator) + { + m_pAttrItemAllocator->Release(); + } } /**************************************************************************** @@ -1630,7 +1569,7 @@ RCODE F_CachedNode::resizeDataBuffer( if (!m_pucData) { pucActualAlloc = NULL; - if( RC_BAD( rc = gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.allocBuf( + if( RC_BAD( rc = gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->allocBuf( &gv_XFlmSysData.pNodeCacheMgr->m_nodeDataRelocator, uiDataBufSize, &pvThis, sizeof( void *), &pucActualAlloc, &bHeapAlloc))) @@ -1641,7 +1580,7 @@ RCODE F_CachedNode::resizeDataBuffer( else { pucActualAlloc = getActualPointer( m_pucData); - if( RC_BAD( rc = gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.reallocBuf( + if( RC_BAD( rc = gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->reallocBuf( &gv_XFlmSysData.pNodeCacheMgr->m_nodeDataRelocator, m_uiDataBufSize, uiDataBufSize, &pvThis, sizeof( void *), &pucActualAlloc, &bHeapAlloc))) @@ -1652,15 +1591,7 @@ RCODE F_CachedNode::resizeDataBuffer( flmAssert( *((F_CachedNode **)pucActualAlloc) == this); setNodeAndDataPtr( pucActualAlloc); - -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_uiDataBufSize = uiDataBufSize; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif - uiNewSize = memSize(); if (m_ui64HighTransId != FLM_MAX_UINT64) @@ -1706,20 +1637,12 @@ RCODE F_CachedNode::resizeChildElmList( FLMBYTE * pucActualAlloc; FLMBOOL bHeapAlloc = FALSE; void * pvThis = this; -#ifdef FLM_CACHE_PROTECT - FLMBOOL bProtectNode = FALSE; -#endif if( uiChildElmCount == m_nodeInfo.uiChildElmCount) { goto Exit; } -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); - bProtectNode = TRUE; -#endif - if( !bMutexAlreadyLocked) { flmAssert( nodeInUse()); @@ -1736,7 +1659,7 @@ RCODE F_CachedNode::resizeChildElmList( flmAssert( m_nodeInfo.uiChildElmCount); pucActualAlloc = getActualPointer( m_pNodeList); - gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.freeBuf( + gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->freeBuf( calcNodeListBufSize( m_nodeInfo.uiChildElmCount), &pucActualAlloc); } @@ -1745,7 +1668,7 @@ RCODE F_CachedNode::resizeChildElmList( if( !m_nodeInfo.uiChildElmCount) { pucActualAlloc = NULL; - rc = gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.allocBuf( + rc = gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->allocBuf( &gv_XFlmSysData.pNodeCacheMgr->m_nodeListRelocator, calcNodeListBufSize( uiChildElmCount), &pvThis, sizeof( void *), &pucActualAlloc, &bHeapAlloc); @@ -1753,7 +1676,7 @@ RCODE F_CachedNode::resizeChildElmList( else { pucActualAlloc = getActualPointer( m_pNodeList); - rc = gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.reallocBuf( + rc = gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->reallocBuf( &gv_XFlmSysData.pNodeCacheMgr->m_nodeListRelocator, calcNodeListBufSize( m_nodeInfo.uiChildElmCount), calcNodeListBufSize( uiChildElmCount), @@ -1812,13 +1735,6 @@ RCODE F_CachedNode::resizeChildElmList( Exit: -#ifdef FLM_CACHE_PROTECT - if( bProtectNode) - { - protectCachedItem(); - } -#endif - return( rc); } @@ -1834,20 +1750,12 @@ RCODE F_CachedNode::resizeAttrList( FLMBYTE * pucActualAlloc; FLMBOOL bHeapAlloc = FALSE; void * pvThis = this; -#ifdef FLM_CACHE_PROTECT - FLMBOOL bProtectNode = FALSE; -#endif if( uiAttrCount == m_uiAttrCount) { goto Exit; } -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); - bProtectNode = TRUE; -#endif - if( !bMutexAlreadyLocked) { flmAssert( nodeInUse()); @@ -1863,7 +1771,7 @@ RCODE F_CachedNode::resizeAttrList( flmAssert( m_uiAttrCount); pucActualAlloc = getActualPointer( m_ppAttrList); - gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.freeBuf( + gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->freeBuf( calcAttrListBufSize( m_uiAttrCount), &pucActualAlloc); } @@ -1872,7 +1780,7 @@ RCODE F_CachedNode::resizeAttrList( if( !m_uiAttrCount) { pucActualAlloc = NULL; - rc = gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.allocBuf( + rc = gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->allocBuf( &gv_XFlmSysData.pNodeCacheMgr->m_attrListRelocator, calcAttrListBufSize( uiAttrCount), &pvThis, sizeof( void *), &pucActualAlloc, &bHeapAlloc); @@ -1880,7 +1788,7 @@ RCODE F_CachedNode::resizeAttrList( else { pucActualAlloc = getActualPointer( m_ppAttrList); - rc = gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.reallocBuf( + rc = gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->reallocBuf( &gv_XFlmSysData.pNodeCacheMgr->m_attrListRelocator, calcAttrListBufSize( m_uiAttrCount), calcAttrListBufSize( uiAttrCount), @@ -1939,13 +1847,6 @@ RCODE F_CachedNode::resizeAttrList( Exit: -#ifdef FLM_CACHE_PROTECT - if( bProtectNode) - { - protectCachedItem(); - } -#endif - return( rc); } @@ -2081,10 +1982,6 @@ Start_Find: goto Exit; } -#ifdef FLM_CACHE_PROTECT - pNode->unprotectCachedItem(); -#endif - pNode->m_nodeInfo.ui64NodeId = ui64NodeId; pNode->m_nodeInfo.uiCollection = uiCollection; @@ -2142,9 +2039,6 @@ Start_Find: : pNode), rc); } pNode->decrNodeUseCount(); -#ifdef FLM_CACHE_PROTECT - pNode->protectCachedItem(); -#endif // If we did not succeed, free the F_CachedNode structure. @@ -2296,10 +2190,6 @@ RCODE F_NodeCacheMgr::createNode( goto Exit; } -#ifdef FLM_CACHE_PROTECT - pNode->unprotectCachedItem(); -#endif - pNode->m_nodeInfo.ui64NodeId = ui64NodeId; pNode->m_nodeInfo.uiCollection = uiCollection; pNode->m_uiOffsetIndex = 0; @@ -2341,10 +2231,6 @@ RCODE F_NodeCacheMgr::createNode( (*ppDOMNode)->m_pCachedNode = pNode; pNode->incrNodeUseCount(); -#ifdef FLM_CACHE_PROTECT - pNode->protectCachedItem(); -#endif - Exit: if (bMutexLocked) @@ -2367,9 +2253,6 @@ RCODE F_NodeCacheMgr::_makeWriteCopy( F_CachedNode * pNewerNode = NULL; F_CachedNode * pOlderNode = *ppCachedNode; FLMBOOL bMutexLocked = FALSE; -#ifdef FLM_CACHE_PROTECT - FLMBOOL bProtectNewerNode = FALSE; -#endif flmAssert( pOlderNode->m_ui64HighTransId == FLM_MAX_UINT64); flmAssert( !pOlderNode->m_pNewerVersion); @@ -2402,11 +2285,6 @@ RCODE F_NodeCacheMgr::_makeWriteCopy( pOlderNode->unlinkFromDatabase(); pOlderNode->linkToDatabaseAtHead( pDatabase); -#ifdef FLM_CACHE_PROTECT - pNewerNode->unprotectCachedItem(); - bProtectNewerNode = TRUE; -#endif - pNewerNode->m_pDatabase = pDatabase; pNewerNode->m_uiFlags = pOlderNode->m_uiFlags; pNewerNode->m_uiOffsetIndex = pOlderNode->m_uiOffsetIndex; @@ -2495,11 +2373,6 @@ RCODE F_NodeCacheMgr::_makeWriteCopy( *ppCachedNode = pNewerNode; pNewerNode->incrNodeUseCount(); -#ifdef FLM_CACHE_PROTECT - pNewerNode->protectCachedItem(); - bProtectNewerNode = FALSE; -#endif - // Set pNewerNode to NULL so it won't get freed at Exit pNewerNode = NULL; @@ -2947,10 +2820,6 @@ void F_CachedNode::setNodeDirty( F_Db * pDb, FLMBOOL bNew) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif - if (!nodeIsDirty()) { f_mutexLock( gv_XFlmSysData.hNodeCacheMutex); @@ -2990,10 +2859,6 @@ void F_CachedNode::setNodeDirty( { m_uiFlags |= FDOM_NEW; } - -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } /**************************************************************************** @@ -3003,10 +2868,6 @@ void F_CachedNode::unsetNodeDirtyAndNew( F_Db * pDb, FLMBOOL bMutexAlreadyLocked) { -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif - // When outputting a binary or text stream, it is possible that the // dirty flag was unset when the last buffer was output @@ -3035,10 +2896,6 @@ void F_CachedNode::unsetNodeDirtyAndNew( f_mutexUnlock( gv_XFlmSysData.hNodeCacheMutex); } } - -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } /***************************************************************************** @@ -3049,7 +2906,7 @@ FINLINE void flmAddInfoSenLen( FLMUINT64 ui64Num, FLMUINT * puiTotalOverhead) { - FLMUINT uiSenLen = flmGetSENByteCount( ui64Num); + FLMUINT uiSenLen = f_getSENByteCount( ui64Num); pInfoItem->ui64Bytes += (FLMUINT64)uiSenLen; pInfoItem->ui64Count++; @@ -3399,14 +3256,14 @@ RCODE F_CachedNode::headerToBuf( // Document ID - flmEncodeSEN( ui64DocId, &pucBuf); + f_encodeSEN( ui64DocId, &pucBuf); // Encode the base ID if it isn't equal to the document ID if( ui64BaseId != ui64DocId) { uiStorageFlags |= NSF_HAVE_BASE_ID_BIT; - flmEncodeSEN( ui64BaseId, &pucBuf); + f_encodeSEN( ui64BaseId, &pucBuf); } // Parent ID @@ -3416,18 +3273,18 @@ RCODE F_CachedNode::headerToBuf( ui64Tmp = ui64NodeId; } - flmEncodeSEN( ui64Tmp - ui64BaseId, &pucBuf); + f_encodeSEN( ui64Tmp - ui64BaseId, &pucBuf); // Name ID - flmEncodeSEN( uiNameId, &pucBuf); + f_encodeSEN( uiNameId, &pucBuf); // Prefix ID if( uiPrefixId) { uiStorageFlags |= NSF_EXT_HAVE_PREFIX_BIT; - flmEncodeSEN( uiPrefixId, &pucBuf); + f_encodeSEN( uiPrefixId, &pucBuf); } // Metavalue @@ -3435,7 +3292,7 @@ RCODE F_CachedNode::headerToBuf( if( ui64MetaValue) { uiStorageFlags |= NSF_HAVE_META_VALUE_BIT; - flmEncodeSEN( ui64MetaValue, &pucBuf); + f_encodeSEN( ui64MetaValue, &pucBuf); } // Previous and next siblings @@ -3447,14 +3304,14 @@ RCODE F_CachedNode::headerToBuf( ui64Tmp = ui64NodeId; } - flmEncodeSEN( ui64Tmp - ui64BaseId, &pucBuf); + f_encodeSEN( ui64Tmp - ui64BaseId, &pucBuf); if( (ui64Tmp = ui64NextSibId) == 0) { ui64Tmp = ui64NodeId; } - flmEncodeSEN( ui64Tmp - ui64BaseId, &pucBuf); + f_encodeSEN( ui64Tmp - ui64BaseId, &pucBuf); uiStorageFlags |= NSF_HAVE_SIBLINGS_BIT; } @@ -3464,13 +3321,13 @@ RCODE F_CachedNode::headerToBuf( { flmAssert( ui64LastChildId); - flmEncodeSEN( ui64FirstChildId - ui64BaseId, &pucBuf); - flmEncodeSEN( ui64LastChildId - ui64BaseId, &pucBuf); + f_encodeSEN( ui64FirstChildId - ui64BaseId, &pucBuf); + f_encodeSEN( ui64LastChildId - ui64BaseId, &pucBuf); uiStorageFlags |= NSF_HAVE_CHILDREN_BIT; if( uiDataChildCount) { - flmEncodeSEN( uiDataChildCount, &pucBuf); + f_encodeSEN( uiDataChildCount, &pucBuf); uiStorageFlags |= NSF_EXT_HAVE_DCHILD_COUNT_BIT; } } @@ -3484,7 +3341,7 @@ RCODE F_CachedNode::headerToBuf( // the fact that all of the child elements must have unique // name IDs. - flmEncodeSEN( m_nodeInfo.uiChildElmCount, &pucBuf); + f_encodeSEN( m_nodeInfo.uiChildElmCount, &pucBuf); } // Encryption ID @@ -3492,7 +3349,7 @@ RCODE F_CachedNode::headerToBuf( if( uiEncDefId) { uiStorageFlags |= NSF_EXT_ENCRYPTED_BIT; - flmEncodeSEN( uiEncDefId, &pucBuf); + f_encodeSEN( uiEncDefId, &pucBuf); } // Annotation ID @@ -3500,7 +3357,7 @@ RCODE F_CachedNode::headerToBuf( if( ui64AnnotationId) { uiStorageFlags |= NSF_EXT_ANNOTATION_BIT; - flmEncodeSEN( ui64AnnotationId - ui64BaseId, &pucBuf); + f_encodeSEN( ui64AnnotationId - ui64BaseId, &pucBuf); } // Output the data length if needed @@ -3509,16 +3366,16 @@ RCODE F_CachedNode::headerToBuf( (uiEncDefId || (uiFlags & FDOM_HAVE_CELM_LIST) || m_uiAttrCount)) { uiStorageFlags |= NSF_HAVE_DATA_LEN_BIT; - flmEncodeSEN( uiDataLength, &pucBuf); + f_encodeSEN( uiDataLength, &pucBuf); } // Output the storage flags (inverted SEN) - uiFlagsLen = flmGetSENByteCount( uiStorageFlags); + uiFlagsLen = f_getSENByteCount( uiStorageFlags); if( uiFlagsLen > 1) { pucTmpSEN = ucTmpSEN; - flmEncodeSEN( uiStorageFlags, &pucTmpSEN); + f_encodeSEN( uiStorageFlags, &pucTmpSEN); for( uiLoop = uiFlagsLen; uiLoop > 0; uiLoop--) { @@ -3547,7 +3404,7 @@ RCODE F_CachedNode::headerToBuf( pNodeInfo->nodeAndDataType.ui64Bytes++; pNodeInfo->nodeAndDataType.ui64Count++; - pNodeInfo->documentId.ui64Bytes += flmGetSENByteCount( ui64DocId); + pNodeInfo->documentId.ui64Bytes += f_getSENByteCount( ui64DocId); pNodeInfo->documentId.ui64Count++; uiTotalOverhead = 3; @@ -4004,7 +3861,7 @@ RCODE flmReadNodeInfo( // Get the storage flags uiStorageFlags = pucHeader[ uiHeaderStorageSize - 1]; - uiStorageFlagsLen = flmGetSENLength( (FLMBYTE)uiStorageFlags); + uiStorageFlagsLen = f_getSENLength( (FLMBYTE)uiStorageFlags); if( uiStorageFlagsLen > 1) { @@ -4015,7 +3872,7 @@ RCODE flmReadNodeInfo( } pucTmpSEN = ucTmpSEN; - if( RC_BAD( rc = flmDecodeSEN( (const FLMBYTE **)&pucTmpSEN, + if( RC_BAD( rc = f_decodeSEN( (const FLMBYTE **)&pucTmpSEN, pucTmpSEN + uiStorageFlagsLen, &uiStorageFlags))) { goto Exit; @@ -4053,7 +3910,7 @@ RCODE flmReadNodeInfo( // Document ID - if( RC_BAD( rc = flmDecodeSEN64( &pucHeader, pucHeaderEnd, + if( RC_BAD( rc = f_decodeSEN64( &pucHeader, pucHeaderEnd, &pNodeInfo->ui64DocumentId))) { goto Exit; @@ -4063,7 +3920,7 @@ RCODE flmReadNodeInfo( if( uiStorageFlags & NSF_HAVE_BASE_ID_BIT) { - if( RC_BAD( rc = flmDecodeSEN64( &pucHeader, + if( RC_BAD( rc = f_decodeSEN64( &pucHeader, pucHeaderEnd, &ui64BaseId))) { goto Exit; @@ -4076,7 +3933,7 @@ RCODE flmReadNodeInfo( // Parent ID - if( RC_BAD( rc = flmDecodeSEN64( &pucHeader, + if( RC_BAD( rc = f_decodeSEN64( &pucHeader, pucHeaderEnd, &pNodeInfo->ui64ParentId))) { goto Exit; @@ -4089,7 +3946,7 @@ RCODE flmReadNodeInfo( // Name ID - if( RC_BAD( rc = flmDecodeSEN( &pucHeader, pucHeaderEnd, + if( RC_BAD( rc = f_decodeSEN( &pucHeader, pucHeaderEnd, &pNodeInfo->uiNameId))) { goto Exit; @@ -4099,7 +3956,7 @@ RCODE flmReadNodeInfo( if( uiStorageFlags & NSF_EXT_HAVE_PREFIX_BIT) { - if( RC_BAD( rc = flmDecodeSEN( &pucHeader, pucHeaderEnd, + if( RC_BAD( rc = f_decodeSEN( &pucHeader, pucHeaderEnd, &pNodeInfo->uiPrefixId))) { goto Exit; @@ -4114,7 +3971,7 @@ RCODE flmReadNodeInfo( if( uiStorageFlags & NSF_HAVE_META_VALUE_BIT) { - if( RC_BAD( rc = flmDecodeSEN64( &pucHeader, pucHeaderEnd, + if( RC_BAD( rc = f_decodeSEN64( &pucHeader, pucHeaderEnd, &pNodeInfo->ui64MetaValue))) { goto Exit; @@ -4129,7 +3986,7 @@ RCODE flmReadNodeInfo( if( uiStorageFlags & NSF_HAVE_SIBLINGS_BIT) { - if( RC_BAD( rc = flmDecodeSEN64( &pucHeader, pucHeaderEnd, + if( RC_BAD( rc = f_decodeSEN64( &pucHeader, pucHeaderEnd, &pNodeInfo->ui64PrevSibId))) { goto Exit; @@ -4140,7 +3997,7 @@ RCODE flmReadNodeInfo( pNodeInfo->ui64PrevSibId = 0; } - if( RC_BAD( rc = flmDecodeSEN64( &pucHeader, pucHeaderEnd, + if( RC_BAD( rc = f_decodeSEN64( &pucHeader, pucHeaderEnd, &pNodeInfo->ui64NextSibId))) { goto Exit; @@ -4161,7 +4018,7 @@ RCODE flmReadNodeInfo( if( uiStorageFlags & NSF_HAVE_CHILDREN_BIT) { - if( RC_BAD( rc = flmDecodeSEN64( &pucHeader, pucHeaderEnd, + if( RC_BAD( rc = f_decodeSEN64( &pucHeader, pucHeaderEnd, &pNodeInfo->ui64FirstChildId))) { goto Exit; @@ -4169,7 +4026,7 @@ RCODE flmReadNodeInfo( pNodeInfo->ui64FirstChildId += ui64BaseId; - if( RC_BAD( rc = flmDecodeSEN64( &pucHeader, pucHeaderEnd, + if( RC_BAD( rc = f_decodeSEN64( &pucHeader, pucHeaderEnd, &pNodeInfo->ui64LastChildId))) { goto Exit; @@ -4179,7 +4036,7 @@ RCODE flmReadNodeInfo( if( uiStorageFlags & NSF_EXT_HAVE_DCHILD_COUNT_BIT) { - if( RC_BAD( rc = flmDecodeSEN( &pucHeader, pucHeaderEnd, + if( RC_BAD( rc = f_decodeSEN( &pucHeader, pucHeaderEnd, &pNodeInfo->uiDataChildCount))) { goto Exit; @@ -4226,7 +4083,7 @@ RCODE flmReadNodeInfo( // We should also enforce that no children have the same // name id. - if( RC_BAD( rc = flmDecodeSEN( &pucHeader, pucHeaderEnd, + if( RC_BAD( rc = f_decodeSEN( &pucHeader, pucHeaderEnd, &pNodeInfo->uiChildElmCount))) { goto Exit; @@ -4262,7 +4119,7 @@ RCODE flmReadNodeInfo( if( uiStorageFlags & NSF_EXT_ENCRYPTED_BIT) { - if( RC_BAD( rc = flmDecodeSEN( &pucHeader, pucHeaderEnd, + if( RC_BAD( rc = f_decodeSEN( &pucHeader, pucHeaderEnd, &pNodeInfo->uiEncDefId))) { goto Exit; @@ -4277,7 +4134,7 @@ RCODE flmReadNodeInfo( if( uiStorageFlags & NSF_EXT_ANNOTATION_BIT) { - if( RC_BAD( rc = flmDecodeSEN64( &pucHeader, pucHeaderEnd, + if( RC_BAD( rc = f_decodeSEN64( &pucHeader, pucHeaderEnd, &pNodeInfo->ui64AnnotationId))) { goto Exit; @@ -4292,7 +4149,7 @@ RCODE flmReadNodeInfo( if( uiStorageFlags & NSF_HAVE_DATA_LEN_BIT) { - if( RC_BAD( rc = flmDecodeSEN( &pucHeader, pucHeaderEnd, + if( RC_BAD( rc = f_decodeSEN( &pucHeader, pucHeaderEnd, &pNodeInfo->uiDataLength))) { goto Exit; @@ -4453,7 +4310,7 @@ RCODE F_CachedNode::readNode( uiLoop < m_nodeInfo.uiChildElmCount; uiLoop++, pElmNode++) { - if( RC_BAD( rc = flmReadSEN( pIStream, &pElmNode->uiNameId, + if( RC_BAD( rc = f_readSEN( pIStream, &pElmNode->uiNameId, &uiLen))) { goto Exit; @@ -4462,7 +4319,7 @@ RCODE F_CachedNode::readNode( pElmNode->uiNameId += uiPrevNameId; uiPrevNameId = pElmNode->uiNameId; - if( RC_BAD( rc = flmReadSEN64( pIStream, + if( RC_BAD( rc = f_readSEN64( pIStream, &pElmNode->ui64NodeId, &uiLen))) { goto Exit; @@ -4541,7 +4398,8 @@ RCODE F_CachedNode::readNode( // the node. Always align on 8 byte boundaries - just to be safe. // It is the highest alignment we support. - if( calcDataBufSize( uiStorageLength) <= MAX_CELL_SIZE || + if( calcDataBufSize( uiStorageLength) <= + gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->getMaxCellSize() || m_nodeInfo.eNodeType == ELEMENT_NODE) { if( RC_BAD( rc = resizeDataBuffer( uiStorageLength, FALSE))) @@ -4689,7 +4547,7 @@ RCODE F_CachedNode::importAttributeList( // Determine the number of attributes - if( RC_BAD( rc = flmReadSEN( pIStream, &uiAttrCount))) + if( RC_BAD( rc = f_readSEN( pIStream, &uiAttrCount))) { goto Exit; } @@ -4701,14 +4559,14 @@ RCODE F_CachedNode::importAttributeList( // Import the attributes - if( RC_BAD( rc = flmReadSEN( pIStream, &uiBaseNameId))) + if( RC_BAD( rc = f_readSEN( pIStream, &uiBaseNameId))) { goto Exit; } for( uiLoop = 0; uiLoop < uiAttrCount; uiLoop++) { - if( RC_BAD( rc = flmReadSEN( pIStream, &uiNameId))) + if( RC_BAD( rc = f_readSEN( pIStream, &uiNameId))) { goto Exit; } @@ -4725,7 +4583,7 @@ RCODE F_CachedNode::importAttributeList( goto Exit; } - if( RC_BAD( rc = flmReadSEN( pIStream, &uiStorageFlags))) + if( RC_BAD( rc = f_readSEN( pIStream, &uiStorageFlags))) { goto Exit; } @@ -4742,7 +4600,7 @@ RCODE F_CachedNode::importAttributeList( if( uiStorageFlags & ASF_HAVE_PREFIX_BIT) { - if( RC_BAD( rc = flmReadSEN( pIStream, &pAttrItem->m_uiPrefixId))) + if( RC_BAD( rc = f_readSEN( pIStream, &pAttrItem->m_uiPrefixId))) { goto Exit; } @@ -4752,7 +4610,7 @@ RCODE F_CachedNode::importAttributeList( if( uiPayloadLength == ASF_HAVE_PAYLOAD_LEN_SEN) { - if( RC_BAD( rc = flmReadSEN( pIStream, &uiPayloadLength))) + if( RC_BAD( rc = f_readSEN( pIStream, &uiPayloadLength))) { goto Exit; } @@ -4769,12 +4627,12 @@ RCODE F_CachedNode::importAttributeList( { F_ENCDEF * pEncDef; - if( RC_BAD( rc = flmReadSEN( pIStream, &pAttrItem->m_uiEncDefId))) + if( RC_BAD( rc = f_readSEN( pIStream, &pAttrItem->m_uiEncDefId))) { goto Exit; } - if( RC_BAD( rc = flmReadSEN( pIStream, + if( RC_BAD( rc = f_readSEN( pIStream, &pAttrItem->m_uiDecryptedDataLen))) { goto Exit; @@ -4918,7 +4776,7 @@ void F_AttrItem::getAttrSizeNeeded( FLMUINT uiOverhead = 0; FLMUINT uiStorageFlags; - uiNameSize = flmGetSENByteCount( m_uiNameId - uiBaseNameId); + uiNameSize = f_getSENByteCount( m_uiNameId - uiBaseNameId); uiOverhead += uiNameSize; uiStorageFlags = getAttrStorageFlags(); @@ -4927,12 +4785,12 @@ void F_AttrItem::getAttrSizeNeeded( *puiSaveStorageFlags = uiStorageFlags; } - uiFlagsSize = flmGetSENByteCount( uiStorageFlags); + uiFlagsSize = f_getSENByteCount( uiStorageFlags); uiOverhead += uiFlagsSize; if( m_uiPrefixId) { - uiPrefixSize = flmGetSENByteCount( m_uiPrefixId); + uiPrefixSize = f_getSENByteCount( m_uiPrefixId); uiOverhead += uiPrefixSize; } else @@ -4945,7 +4803,7 @@ void F_AttrItem::getAttrSizeNeeded( if( uiPayloadLength > ASF_MAX_EMBEDDED_PAYLOAD_LEN) { - uiPayloadLenSize = flmGetSENByteCount( uiPayloadLength); + uiPayloadLenSize = f_getSENByteCount( uiPayloadLength); uiOverhead += uiPayloadLenSize; } else @@ -4957,9 +4815,9 @@ void F_AttrItem::getAttrSizeNeeded( { flmAssert( uiPayloadLength); - uiEncIdSize = flmGetSENByteCount( m_uiEncDefId); + uiEncIdSize = f_getSENByteCount( m_uiEncDefId); uiOverhead += uiEncIdSize; - uiUnencLenSize = flmGetSENByteCount( m_uiDecryptedDataLen); + uiUnencLenSize = f_getSENByteCount( m_uiDecryptedDataLen); uiOverhead += uiUnencLenSize; } else @@ -5104,15 +4962,15 @@ RCODE F_CachedNode::exportAttributeList( if (pNodeInfo) { flmAssert( !pDynaBuf); - pNodeInfo->attrCount.ui64Bytes += flmGetSENByteCount( m_uiAttrCount); + pNodeInfo->attrCount.ui64Bytes += f_getSENByteCount( m_uiAttrCount); pNodeInfo->attrCount.ui64Count++; - pNodeInfo->attrBaseId.ui64Bytes += flmGetSENByteCount( uiBaseNameId); + pNodeInfo->attrBaseId.ui64Bytes += f_getSENByteCount( uiBaseNameId); pNodeInfo->attrBaseId.ui64Count++; } else { - uiSizeNeeded += flmGetSENByteCount( m_uiAttrCount); - uiSizeNeeded += flmGetSENByteCount( uiBaseNameId); + uiSizeNeeded += f_getSENByteCount( m_uiAttrCount); + uiSizeNeeded += f_getSENByteCount( uiBaseNameId); flmAssert( pDynaBuf); if( RC_BAD( rc = pDynaBuf->allocSpace( uiSizeNeeded, (void **)&pucBuf))) @@ -5123,12 +4981,12 @@ RCODE F_CachedNode::exportAttributeList( pucStart = pucBuf; pucEnd = pucStart + uiSizeNeeded; - if( RC_BAD( rc = flmEncodeSEN( m_uiAttrCount, &pucBuf, pucEnd))) + if( RC_BAD( rc = f_encodeSEN( m_uiAttrCount, &pucBuf, pucEnd))) { goto Exit; } - if( RC_BAD( rc = flmEncodeSEN( uiBaseNameId, &pucBuf, pucEnd))) + if( RC_BAD( rc = f_encodeSEN( uiBaseNameId, &pucBuf, pucEnd))) { goto Exit; } @@ -5138,7 +4996,7 @@ RCODE F_CachedNode::exportAttributeList( for (uiLoop = 0; uiLoop < m_uiAttrCount; uiLoop++) { pAttrItem = m_ppAttrList [uiLoop]; - if( RC_BAD( rc = flmEncodeSEN( pAttrItem->m_uiNameId - uiBaseNameId, + if( RC_BAD( rc = f_encodeSEN( pAttrItem->m_uiNameId - uiBaseNameId, &pucBuf, pucEnd))) { goto Exit; @@ -5151,14 +5009,14 @@ RCODE F_CachedNode::exportAttributeList( ? storageFlagsList [uiLoop] : pAttrItem->getAttrStorageFlags(); - if( RC_BAD( rc = flmEncodeSEN( uiStorageFlags, &pucBuf, pucEnd))) + if( RC_BAD( rc = f_encodeSEN( uiStorageFlags, &pucBuf, pucEnd))) { goto Exit; } if( pAttrItem->m_uiPrefixId) { - if( RC_BAD( rc = flmEncodeSEN( pAttrItem->m_uiPrefixId, + if( RC_BAD( rc = f_encodeSEN( pAttrItem->m_uiPrefixId, &pucBuf, pucEnd))) { goto Exit; @@ -5169,7 +5027,7 @@ RCODE F_CachedNode::exportAttributeList( if( uiPayloadLength > ASF_MAX_EMBEDDED_PAYLOAD_LEN) { - if( RC_BAD( rc = flmEncodeSEN( uiPayloadLength, &pucBuf, pucEnd))) + if( RC_BAD( rc = f_encodeSEN( uiPayloadLength, &pucBuf, pucEnd))) { goto Exit; } @@ -5179,13 +5037,13 @@ RCODE F_CachedNode::exportAttributeList( { flmAssert( uiPayloadLength); - if( RC_BAD( rc = flmEncodeSEN( pAttrItem->m_uiEncDefId, + if( RC_BAD( rc = f_encodeSEN( pAttrItem->m_uiEncDefId, &pucBuf, pucEnd))) { goto Exit; } - if( RC_BAD( rc = flmEncodeSEN( pAttrItem->m_uiDecryptedDataLen, + if( RC_BAD( rc = f_encodeSEN( pAttrItem->m_uiDecryptedDataLen, &pucBuf, pucEnd))) { goto Exit; @@ -5258,7 +5116,7 @@ void F_CachedNode::resetNode( void) if( m_pucData) { pucActualAlloc = getActualPointer( m_pucData); - gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.freeBuf( + gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->freeBuf( m_uiDataBufSize, &pucActualAlloc); m_pucData = NULL; m_uiDataBufSize = 0; @@ -5267,7 +5125,7 @@ void F_CachedNode::resetNode( void) if( m_pNodeList) { pucActualAlloc = getActualPointer( m_pNodeList); - gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.freeBuf( + gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->freeBuf( calcNodeListBufSize( m_nodeInfo.uiChildElmCount), &pucActualAlloc); m_pNodeList = NULL; @@ -5282,7 +5140,7 @@ void F_CachedNode::resetNode( void) delete m_ppAttrList [uiLoop]; } pucActualAlloc = getActualPointer( m_ppAttrList); - gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.freeBuf( + gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->freeBuf( calcAttrListBufSize( m_uiAttrCount), &pucActualAlloc); m_ppAttrList = NULL; m_uiAttrCount = 0; @@ -5318,24 +5176,14 @@ void * F_CachedNode::operator new( throw() #endif { - void * pvCell; - #ifndef FLM_DEBUG F_UNREFERENCED_PARM( uiSize); #endif flmAssert( uiSize == sizeof( F_CachedNode)); f_assertMutexLocked( gv_XFlmSysData.hNodeCacheMutex); - if( (pvCell = - gv_XFlmSysData.pNodeCacheMgr->m_nodeAllocator.allocCell( - &gv_XFlmSysData.pNodeCacheMgr->m_nodeRelocator)) != NULL) - { -#ifdef FLM_CACHE_PROTECT - gv_XFlmSysData.pNodeCacheMgr->m_nodeAllocator.unprotectCell( pvCell); -#endif - } - - return( pvCell); + return( gv_XFlmSysData.pNodeCacheMgr->m_pNodeAllocator->allocCell( + &gv_XFlmSysData.pNodeCacheMgr->m_nodeRelocator)); } /**************************************************************************** @@ -5396,55 +5244,18 @@ void F_CachedNode::operator delete( return; } -#ifdef FLM_CACHE_PROTECT - gv_XFlmSysData.pNodeCacheMgr->m_nodeAllocator.protectCell( ptr); -#endif - gv_XFlmSysData.pNodeCacheMgr->m_nodeAllocator.freeCell( (FLMBYTE *)ptr, FALSE); + gv_XFlmSysData.pNodeCacheMgr->m_pNodeAllocator->freeCell( (FLMBYTE *)ptr, FALSE); } /**************************************************************************** Desc: ****************************************************************************/ void F_CachedNode::operator delete[]( - void * // ptr) - ) + void *) // ptr) { flmAssert( 0); } -/**************************************************************************** -Desc: -****************************************************************************/ -#if defined( FLM_DEBUG) && !defined( __WATCOMC__) && !defined( FLM_SOLARIS) -void F_CachedNode::operator delete( - void * ptr, - const char *, // pszFileName - int // iLineNum - ) -{ - if( !ptr) - { - return; - } - - gv_XFlmSysData.pNodeCacheMgr->m_nodeAllocator.freeCell( (FLMBYTE *)ptr, FALSE); -} -#endif - -/**************************************************************************** -Desc: -****************************************************************************/ -#if defined( FLM_DEBUG) && !defined( __WATCOMC__) && !defined( FLM_SOLARIS) -void F_CachedNode::operator delete[]( - void *, // ptr, - const char *, // pszFileName - int // iLineNum - ) -{ - flmAssert( 0); -} -#endif - /**************************************************************************** Desc: ****************************************************************************/ @@ -5467,7 +5278,7 @@ F_AttrItem::~F_AttrItem() if( m_uiPayloadLen > sizeof( FLMBYTE *)) { m_pucPayload -= sizeof( F_AttrItem *); - gv_XFlmSysData.pNodeCacheMgr->m_bufAllocator.freeBuf( + gv_XFlmSysData.pNodeCacheMgr->m_pBufAllocator->freeBuf( m_uiPayloadLen + sizeof( F_AttrItem *), &m_pucPayload); } @@ -5482,24 +5293,14 @@ void * F_AttrItem::operator new( throw() #endif { - void * pvCell; - #ifndef FLM_DEBUG F_UNREFERENCED_PARM( uiSize); #endif flmAssert( uiSize == sizeof( F_AttrItem)); f_assertMutexLocked( gv_XFlmSysData.hNodeCacheMutex); - if( (pvCell = - gv_XFlmSysData.pNodeCacheMgr->m_attrItemAllocator.allocCell( - &gv_XFlmSysData.pNodeCacheMgr->m_attrItemRelocator)) != NULL) - { -#ifdef FLM_CACHE_PROTECT - gv_XFlmSysData.pNodeCacheMgr->m_nodeAllocator.unprotectCell( pvCell); -#endif - } - - return( pvCell); + return( gv_XFlmSysData.pNodeCacheMgr->m_pAttrItemAllocator->allocCell( + &gv_XFlmSysData.pNodeCacheMgr->m_attrItemRelocator)); } /**************************************************************************** @@ -5560,51 +5361,14 @@ void F_AttrItem::operator delete( return; } -#ifdef FLM_CACHE_PROTECT - gv_XFlmSysData.pNodeCacheMgr->m_attrItemAllocator.protectCell( ptr); -#endif - gv_XFlmSysData.pNodeCacheMgr->m_attrItemAllocator.freeCell( (FLMBYTE *)ptr, FALSE); + gv_XFlmSysData.pNodeCacheMgr->m_pAttrItemAllocator->freeCell( (FLMBYTE *)ptr, FALSE); } /**************************************************************************** Desc: ****************************************************************************/ void F_AttrItem::operator delete[]( - void * // ptr) - ) + void *) // ptr) { flmAssert( 0); } - -/**************************************************************************** -Desc: -****************************************************************************/ -#if defined( FLM_DEBUG) && !defined( __WATCOMC__) && !defined( FLM_SOLARIS) -void F_AttrItem::operator delete( - void * ptr, - const char *, // pszFileName - int // iLineNum - ) -{ - if( !ptr) - { - return; - } - - gv_XFlmSysData.pNodeCacheMgr->m_attrItemAllocator.freeCell( (FLMBYTE *)ptr, FALSE); -} -#endif - -/**************************************************************************** -Desc: -****************************************************************************/ -#if defined( FLM_DEBUG) && !defined( __WATCOMC__) && !defined( FLM_SOLARIS) -void F_AttrItem::operator delete[]( - void *, // ptr, - const char *, // pszFileName - int // iLineNum - ) -{ - flmAssert( 0); -} -#endif diff --git a/xflaim/src/nodeinfo.cpp b/xflaim/src/nodeinfo.cpp index 35014de..f74fa35 100644 --- a/xflaim/src/nodeinfo.cpp +++ b/xflaim/src/nodeinfo.cpp @@ -28,7 +28,7 @@ /***************************************************************************** Desc: Get node information and add it to the node information object. ******************************************************************************/ -RCODE XFLMAPI F_NodeInfo::addNodeInfo( +RCODE FLMAPI F_NodeInfo::addNodeInfo( IF_Db * ifpDb, IF_DOMNode * pNode, FLMBOOL bDoNodeSubTree, @@ -224,7 +224,7 @@ Exit: /**************************************************************************** Desc: Create an empty node info. object and return it's interface... ****************************************************************************/ -RCODE XFLMAPI F_DbSystem::createIFNodeInfo( +RCODE FLMAPI F_DbSystem::createIFNodeInfo( IF_NodeInfo ** ppNodeInfo) { RCODE rc = NE_XFLM_OK; diff --git a/xflaim/src/recover.cpp b/xflaim/src/recover.cpp index 476d6b5..ef0cedf 100644 --- a/xflaim/src/recover.cpp +++ b/xflaim/src/recover.cpp @@ -67,10 +67,10 @@ RCODE F_Db::readRollbackLog( f_timeGetTimeStamp( &StartTime); } - if (RC_BAD( rc = m_pSFileHdl->ReadBlock( uiFilePos, + if (RC_BAD( rc = m_pSFileHdl->readBlock( uiFilePos, uiBlkSize, (FLMBYTE *)pBlkHdr, &uiBytesRead))) { - if (rc == NE_XFLM_IO_END_OF_FILE) + if (rc == NE_FLM_IO_END_OF_FILE) { rc = RC_SET( NE_XFLM_INCOMPLETE_LOG); } @@ -248,7 +248,7 @@ RCODE F_Db::processBeforeImage( m_pSFileHdl->setMaxAutoExtendSize( m_pDatabase->m_uiMaxFileSize); m_pSFileHdl->setExtendSize( m_pDatabase->m_uiFileExtendSize); - rc = m_pSFileHdl->WriteBlock( uiBlkAddress, uiBlkLength, pBlkHdr, + rc = m_pSFileHdl->writeBlock( uiBlkAddress, uiBlkLength, pBlkHdr, m_pDatabase->m_uiBlockSize, NULL, &uiBytesWritten); #ifdef FLM_DBG_LOG flmDbgLogWrite( m_pDatabase, uiBlkAddress, 0, ui64TransID, @@ -290,7 +290,7 @@ RCODE F_Database::writeDbHdr( { RCODE rc = NE_XFLM_OK; FLMUINT uiBytesWritten; - F_FileHdl * pCFileHdl = NULL; + IF_FileHdl * pCFileHdl = NULL; XFLM_DB_HDR * pTmpDbHdr; F_TMSTAMP StartTime; @@ -301,7 +301,7 @@ RCODE F_Database::writeDbHdr( // header is updated because the header will generally have // been modified to point to the new things that were added. - if (RC_BAD( rc = pSFileHdl->Flush())) + if (RC_BAD( rc = pSFileHdl->flush())) { goto Exit; } @@ -354,15 +354,14 @@ RCODE F_Database::writeDbHdr( f_timeGetTimeStamp( &StartTime); } - if( RC_BAD( rc = pSFileHdl->GetFileHdl( 0, TRUE, - (IF_FileHdl **)&pCFileHdl))) + if( RC_BAD( rc = pSFileHdl->getFileHdl( 0, TRUE, &pCFileHdl))) { goto Exit; } - if( RC_BAD( rc = pCFileHdl->SectorWrite( 0, + if( RC_BAD( rc = pCFileHdl->sectorWrite( 0, uiBytesWritten, pTmpDbHdr, - pCFileHdl->GetSectorSize(), + pCFileHdl->getSectorSize(), NULL, &uiBytesWritten, FALSE))) { if (pDbStats) @@ -380,7 +379,7 @@ RCODE F_Database::writeDbHdr( // Finally, force the header to disk. - if (RC_BAD( rc = pCFileHdl->Flush())) + if (RC_BAD( rc = pCFileHdl->flush())) { goto Exit; } @@ -427,22 +426,12 @@ RCODE F_Db::physRollback( } // Allocate a buffer to be used for reading. - -#ifdef FLM_WIN - if ((pucBlk = (FLMBYTE *)VirtualAlloc( NULL, - (DWORD)m_pDatabase->m_uiBlockSize, - MEM_COMMIT, PAGE_READWRITE)) == NULL) - { - rc = MapWinErrorToFlaim( GetLastError(), NE_XFLM_MEM); - goto Exit; - } -#else - if (RC_BAD( rc = f_alloc( m_pDatabase->m_uiBlockSize, - &pucBlk))) + + if( RC_BAD( rc = f_allocAlignedBuffer( m_pDatabase->m_uiBlockSize, + (void **)&pucBlk))) { goto Exit; } -#endif // Start from beginning of log and read to EOF restoring before-image // blocks along the way. @@ -461,7 +450,7 @@ RCODE F_Db::physRollback( // Force the writes to the file. - if (RC_BAD( rc = m_pSFileHdl->Flush())) + if (RC_BAD( rc = m_pSFileHdl->flush())) { goto Exit; } @@ -473,11 +462,8 @@ Exit: if (pucBlk) { -#ifdef FLM_WIN - (void)VirtualFree( pucBlk, 0, MEM_RELEASE); -#else - f_free( &pucBlk); -#endif + f_freeAlignedBuffer( (void **)&pucBlk); } + return( rc); } diff --git a/xflaim/src/regexp.cpp b/xflaim/src/regexp.cpp deleted file mode 100644 index 5caf42c..0000000 --- a/xflaim/src/regexp.cpp +++ /dev/null @@ -1,4164 +0,0 @@ -//------------------------------------------------------------------------------ -// Desc: This is regular expression class. -// -// Tabs: 3 -// -// Copyright (c) 2004-2006 Novell, Inc. All Rights Reserved. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of version 2 of the GNU General Public -// License as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, contact Novell, Inc. -// -// To contact Novell about this file by physical or electronic mail, -// you may find current contact information at www.novell.com -// -// $Id: regexp.cpp 3116 2006-01-19 13:31:53 -0700 (Thu, 19 Jan 2006) dsanders $ -//------------------------------------------------------------------------------ - -#include "flaimsys.h" - -typedef enum -{ - EXP_LITERAL = 0, - EXP_CHAR_CLASS, - EXP_ALTERNATIVES -} eExpType; - -typedef struct BlockCharRangeTag -{ - FLMUNICODE uzLowChar; - FLMUNICODE uzHighChar; - const char * pszBlockName; -} BLOCK_CHAR_RANGE; - -BLOCK_CHAR_RANGE FlmBlockCharRanges[] = -{ - {0x0000, 0x007F, "BasicLatin"}, - {0x0080, 0x00FF, "Latin-1Supplement"}, - {0x0100, 0x017F, "LatinExtended-A"}, - {0x0180, 0x024F, "LatinExtended-B"}, - {0x0250, 0x02AF, "IPAExtensions"}, - {0x02B0, 0x02FF, "SpacingModifierLetters"}, - {0x0300, 0x036F, "CombiningDiacriticalMarks"}, - {0x0370, 0x03FF, "Greek"}, - {0x0400, 0x04FF, "Cyrillic"}, - {0x0530, 0x058F, "Armenian"}, - {0x0590, 0x05FF, "Hebrew"}, - {0x0600, 0x06FF, "Arabic"}, - {0x0700, 0x074F, "Syriac"}, - {0x0780, 0x07BF, "Thaana"}, - {0x0900, 0x097F, "Devanagari"}, - {0x0980, 0x09FF, "Bengali"}, - {0x0A00, 0x0A7F, "Gurmukhi"}, - {0x0A80, 0x0AFF, "Gujarati"}, - {0x0B00, 0x0B7F, "Oriya"}, - {0x0B80, 0x0BFF, "Tamil"}, - {0x0C00, 0x0C7F, "Telugu"}, - {0x0C80, 0x0CFF, "Kannada"}, - {0x0D00, 0x0D7F, "Malayalam"}, - {0x0D80, 0x0DFF, "Sinhala"}, - {0x0E00, 0x0E7F, "Thai"}, - {0x0E80, 0x0EFF, "Lao"}, - {0x0F00, 0x0FFF, "Tibetan"}, - {0x1000, 0x109F, "Myanmar"}, - {0x10A0, 0x10FF, "Georgian"}, - {0x1100, 0x11FF, "HangulJamo"}, - {0x1200, 0x137F, "Ethiopic"}, - {0x13A0, 0x13FF, "Cherokee"}, - {0x1400, 0x167F, "UnifiedCanadianAboriginalSyllabics"}, - {0x1680, 0x169F, "Ogham"}, - {0x16A0, 0x16FF, "Runic"}, - {0x1780, 0x17FF, "Khmer"}, - {0x1800, 0x18AF, "Mongolian"}, - {0x1E00, 0x1EFF, "LatinExtendedAdditional"}, - {0x1F00, 0x1FFF, "GreekExtended"}, - {0x2000, 0x206F, "GeneralPunctuation"}, - {0x2070, 0x209F, "SuperscriptsandSubscripts"}, - {0x20A0, 0x20CF, "CurrencySymbols"}, - {0x20D0, 0x20FF, "CombiningMarksforSymbols"}, - {0x2100, 0x214F, "LetterlikeSymbols"}, - {0x2150, 0x218F, "NumberForms"}, - {0x2190, 0x21FF, "Arrows"}, - {0x2200, 0x22FF, "MathematicalOperators"}, - {0x2300, 0x23FF, "MiscellaneousTechnical"}, - {0x2400, 0x243F, "ControlPictures"}, - {0x2440, 0x245F, "OpticalCharacterRecognition"}, - {0x2460, 0x24FF, "EnclosedAlphanumerics"}, - {0x2500, 0x257F, "BoxDrawing"}, - {0x2580, 0x259F, "BlockElements"}, - {0x25A0, 0x25FF, "GeometricShapes"}, - {0x2600, 0x26FF, "MiscellaneousSymbols"}, - {0x2700, 0x27BF, "Dingbats"}, - {0x2800, 0x28FF, "BraillePatterns"}, - {0x2E80, 0x2EFF, "CJKRadicalsSupplement"}, - {0x2F00, 0x2FDF, "KangxiRadicals"}, - {0x2FF0, 0x2FFF, "IdeographicDescriptionCharacters"}, - {0x3000, 0x303F, "CJKSymbolsandPunctuation"}, - {0x3040, 0x309F, "Hiragana"}, - {0x30A0, 0x30FF, "Katakana"}, - {0x3100, 0x312F, "Bopomofo"}, - {0x3130, 0x318F, "HangulCompatibilityJamo"}, - {0x3190, 0x319F, "Kanbun"}, - {0x31A0, 0x31BF, "BopomofoExtended"}, - {0x3200, 0x32FF, "EnclosedCJKLettersandMonths"}, - {0x3300, 0x33FF, "CJKCompatibility"}, - {0x3400, 0x4DB5, "CJKUnifiedIdeographsExtensionA"}, - {0x4E00, 0x9FFF, "CJKUnifiedIdeographs"}, - {0xA000, 0xA48F, "YiSyllables"}, - {0xA490, 0xA4CF, "YiRadicals"}, - {0xAC00, 0xD7A3, "HangulSyllables"}, - {0xD800, 0xDB7F, "HighSurrogates"}, - {0xDB80, 0xDBFF, "HighPrivateUseSurrogates"}, - {0xDC00, 0xDFFF, "LowSurrogates"}, - {0xE000, 0xF8FF, "PrivateUse"}, - {0xF900, 0xFAFF, "CJKCompatibilityIdeographs"}, - {0xFB00, 0xFB4F, "AlphabeticPresentationForms"}, - {0xFB50, 0xFDFF, "ArabicPresentationForms-A"}, - {0xFE20, 0xFE2F, "CombiningHalfMarks"}, - {0xFE30, 0xFE4F, "CJKCompatibilityForms"}, - {0xFE50, 0xFE6F, "SmallFormVariants"}, - {0xFE70, 0xFEFE, "ArabicPresentationForms-B"}, - {0xFEFF, 0xFEFF, "Specials"}, - {0xFF00, 0xFFEF, "HalfwidthandFullwidthForms"}, - {0xFFF0, 0xFFFD, "Specials"}, - {0, 0, NULL} -}; - -typedef struct CategoryCharRangeTag -{ - FLMUNICODE uzLowChar; - FLMUNICODE uzHighChar; -} CATEGORY_CHAR_RANGE; - -CATEGORY_CHAR_RANGE LuRanges[] = -{ - {0x0041, 0x005A}, - {0x00C0, 0x00DE}, - {0x0100, 0x0000}, - {0x0102, 0x0000}, - {0x0104, 0x0000}, - {0x0106, 0x0000}, - {0x0108, 0x0000}, - {0x010A, 0x0000}, - {0x010C, 0x0000}, - {0x010E, 0x0000}, - {0x0110, 0x0000}, - {0x0112, 0x0000}, - {0x0114, 0x0000}, - {0x0116, 0x0000}, - {0x0118, 0x0000}, - {0x011A, 0x0000}, - {0x011C, 0x0000}, - {0x011E, 0x0000}, - {0x0120, 0x0000}, - {0x0122, 0x0000}, - {0x0124, 0x0000}, - {0x0126, 0x0000}, - {0x0128, 0x0000}, - {0x012A, 0x0000}, - {0x012C, 0x0000}, - {0x012E, 0x0000}, - {0x0130, 0x0000}, - {0x0132, 0x0000}, - {0x0134, 0x0000}, - {0x0136, 0x0000}, - {0x0139, 0x0000}, - {0x013B, 0x0000}, - {0x013D, 0x0000}, - {0x013F, 0x0000}, - {0x0141, 0x0000}, - {0x0143, 0x0000}, - {0x0145, 0x0000}, - {0x0147, 0x0000}, - {0x014A, 0x0000}, - {0x014C, 0x0000}, - {0x014E, 0x0000}, - {0x0150, 0x0000}, - {0x0152, 0x0000}, - {0x0154, 0x0000}, - {0x0156, 0x0000}, - {0x0158, 0x0000}, - {0x015A, 0x0000}, - {0x015C, 0x0000}, - {0x015E, 0x0000}, - {0x0160, 0x0000}, - {0x0162, 0x0000}, - {0x0164, 0x0000}, - {0x0166, 0x0000}, - {0x0168, 0x0000}, - {0x016A, 0x0000}, - {0x016C, 0x0000}, - {0x016E, 0x0000}, - {0x0170, 0x0000}, - {0x0172, 0x0000}, - {0x0174, 0x0000}, - {0x0176, 0x0000}, - {0x0178, 0x0179}, - {0x017B, 0x0000}, - {0x017D, 0x0000}, - {0x0181, 0x0182}, - {0x0184, 0x0000}, - {0x0186, 0x0187}, - {0x0189, 0x018B}, - {0x018E, 0x0191}, - {0x0193, 0x0194}, - {0x0196, 0x0198}, - {0x019C, 0x019D}, - {0x019F, 0x01A0}, - {0x01A2, 0x0000}, - {0x01A4, 0x0000}, - {0x01A6, 0x01A7}, - {0x01A9, 0x01AC}, - {0x01AE, 0x01AF}, - {0x01B1, 0x01B3}, - {0x01B5, 0x0000}, - {0x01B7, 0x01B8}, - {0x01BC, 0x0000}, - {0x01C4, 0x0000}, - {0x01C7, 0x0000}, - {0x01CA, 0x0000}, - {0x01CD, 0x0000}, - {0x01CF, 0x0000}, - {0x01D1, 0x0000}, - {0x01D3, 0x0000}, - {0x01D5, 0x0000}, - {0x01D7, 0x0000}, - {0x01D9, 0x0000}, - {0x01DB, 0x0000}, - {0x01DE, 0x0000}, - {0x01E0, 0x0000}, - {0x01E2, 0x0000}, - {0x01E4, 0x0000}, - {0x01E6, 0x0000}, - {0x01E8, 0x0000}, - {0x01EA, 0x0000}, - {0x01EC, 0x0000}, - {0x01EE, 0x0000}, - {0x01F1, 0x0000}, - {0x01F4, 0x0000}, - {0x01F6, 0x01F8}, - {0x01FA, 0x0000}, - {0x01FC, 0x0000}, - {0x01FE, 0x0000}, - {0x0200, 0x0000}, - {0x0202, 0x0000}, - {0x0204, 0x0000}, - {0x0206, 0x0000}, - {0x0208, 0x0000}, - {0x020A, 0x0000}, - {0x020C, 0x0000}, - {0x020E, 0x0000}, - {0x0210, 0x0000}, - {0x0212, 0x0000}, - {0x0214, 0x0000}, - {0x0216, 0x0000}, - {0x0218, 0x0000}, - {0x021A, 0x0000}, - {0x021C, 0x0000}, - {0x021E, 0x0000}, - {0x0220, 0x0000}, - {0x0222, 0x0000}, - {0x0224, 0x0000}, - {0x0226, 0x0000}, - {0x0228, 0x0000}, - {0x022A, 0x0000}, - {0x022C, 0x0000}, - {0x022E, 0x0000}, - {0x0230, 0x0000}, - {0x0232, 0x0000}, - {0x0386, 0x0000}, - {0x0388, 0x038A}, - {0x038C, 0x0000}, - {0x038E, 0x038F}, - {0x0391, 0x03AB}, - {0x03D2, 0x03D4}, - {0x03D8, 0x0000}, - {0x03DA, 0x0000}, - {0x03DC, 0x0000}, - {0x03DE, 0x0000}, - {0x03E0, 0x0000}, - {0x03E2, 0x0000}, - {0x03E4, 0x0000}, - {0x03E6, 0x0000}, - {0x03E8, 0x0000}, - {0x03EA, 0x0000}, - {0x03EC, 0x0000}, - {0x03EE, 0x0000}, - {0x03F4, 0x0000}, - {0x03F7, 0x0000}, - {0x03F9, 0x0000}, - {0x03FA, 0x0000}, - {0x0400, 0x042F}, - {0x0460, 0x0000}, - {0x0462, 0x0000}, - {0x0464, 0x0000}, - {0x0466, 0x0000}, - {0x0468, 0x0000}, - {0x046A, 0x0000}, - {0x046C, 0x0000}, - {0x046E, 0x0000}, - {0x0470, 0x0000}, - {0x0472, 0x0000}, - {0x0474, 0x0000}, - {0x0476, 0x0000}, - {0x0478, 0x0000}, - {0x047A, 0x0000}, - {0x047C, 0x0000}, - {0x047E, 0x0000}, - {0x0480, 0x0000}, - {0x048A, 0x0000}, - {0x048C, 0x0000}, - {0x048E, 0x0000}, - {0x0490, 0x0000}, - {0x0492, 0x0000}, - {0x0494, 0x0000}, - {0x0496, 0x0000}, - {0x0498, 0x0000}, - {0x049A, 0x0000}, - {0x049C, 0x0000}, - {0x049E, 0x0000}, - {0x04A0, 0x0000}, - {0x04A2, 0x0000}, - {0x04A4, 0x0000}, - {0x04A6, 0x0000}, - {0x04A8, 0x0000}, - {0x04AA, 0x0000}, - {0x04AC, 0x0000}, - {0x04AE, 0x0000}, - {0x04B0, 0x0000}, - {0x04B2, 0x0000}, - {0x04B4, 0x0000}, - {0x04B6, 0x0000}, - {0x04B8, 0x0000}, - {0x04BA, 0x0000}, - {0x04BC, 0x0000}, - {0x04BE, 0x0000}, - {0x04C0, 0x04C1}, - {0x04C3, 0x0000}, - {0x04C5, 0x0000}, - {0x04C7, 0x0000}, - {0x04C9, 0x0000}, - {0x04CB, 0x0000}, - {0x04CD, 0x0000}, - {0x04D0, 0x0000}, - {0x04D2, 0x0000}, - {0x04D4, 0x0000}, - {0x04D6, 0x0000}, - {0x04D8, 0x0000}, - {0x04DA, 0x0000}, - {0x04DC, 0x0000}, - {0x04DE, 0x0000}, - {0x04E0, 0x0000}, - {0x04E2, 0x0000}, - {0x04E4, 0x0000}, - {0x04E6, 0x0000}, - {0x04E8, 0x0000}, - {0x04EA, 0x0000}, - {0x04EC, 0x0000}, - {0x04EE, 0x0000}, - {0x04F0, 0x0000}, - {0x04F2, 0x0000}, - {0x04F4, 0x0000}, - {0x04F8, 0x0000}, - {0x0500, 0x0000}, - {0x0502, 0x0000}, - {0x0504, 0x0000}, - {0x0506, 0x0000}, - {0x0508, 0x0000}, - {0x050A, 0x0000}, - {0x050C, 0x0000}, - {0x050E, 0x0000}, - {0x0531, 0x0556}, - {0x10A0, 0x10C5}, - {0x1E00, 0x0000}, - {0x1E02, 0x0000}, - {0x1E04, 0x0000}, - {0x1E06, 0x0000}, - {0x1E08, 0x0000}, - {0x1E0A, 0x0000}, - {0x1E0C, 0x0000}, - {0x1E0E, 0x0000}, - {0x1E10, 0x0000}, - {0x1E12, 0x0000}, - {0x1E14, 0x0000}, - {0x1E16, 0x0000}, - {0x1E18, 0x0000}, - {0x1E1A, 0x0000}, - {0x1E1C, 0x0000}, - {0x1E1E, 0x0000}, - {0x1E20, 0x0000}, - {0x1E22, 0x0000}, - {0x1E24, 0x0000}, - {0x1E26, 0x0000}, - {0x1E28, 0x0000}, - {0x1E2A, 0x0000}, - {0x1E2C, 0x0000}, - {0x1E2E, 0x0000}, - {0x1E30, 0x0000}, - {0x1E32, 0x0000}, - {0x1E34, 0x0000}, - {0x1E36, 0x0000}, - {0x1E38, 0x0000}, - {0x1E3A, 0x0000}, - {0x1E3C, 0x0000}, - {0x1E3E, 0x0000}, - {0x1E40, 0x0000}, - {0x1E42, 0x0000}, - {0x1E44, 0x0000}, - {0x1E46, 0x0000}, - {0x1E48, 0x0000}, - {0x1E4A, 0x0000}, - {0x1E4C, 0x0000}, - {0x1E4E, 0x0000}, - {0x1E50, 0x0000}, - {0x1E52, 0x0000}, - {0x1E54, 0x0000}, - {0x1E56, 0x0000}, - {0x1E58, 0x0000}, - {0x1E5A, 0x0000}, - {0x1E5C, 0x0000}, - {0x1E5E, 0x0000}, - {0x1E60, 0x0000}, - {0x1E62, 0x0000}, - {0x1E64, 0x0000}, - {0x1E66, 0x0000}, - {0x1E68, 0x0000}, - {0x1E6A, 0x0000}, - {0x1E6C, 0x0000}, - {0x1E6E, 0x0000}, - {0x1E70, 0x0000}, - {0x1E72, 0x0000}, - {0x1E74, 0x0000}, - {0x1E76, 0x0000}, - {0x1E78, 0x0000}, - {0x1E7A, 0x0000}, - {0x1E7C, 0x0000}, - {0x1E7E, 0x0000}, - {0x1E80, 0x0000}, - {0x1E82, 0x0000}, - {0x1E84, 0x0000}, - {0x1E86, 0x0000}, - {0x1E88, 0x0000}, - {0x1E8A, 0x0000}, - {0x1E8C, 0x0000}, - {0x1E8E, 0x0000}, - {0x1E90, 0x0000}, - {0x1E92, 0x0000}, - {0x1E94, 0x0000}, - {0x1EA0, 0x0000}, - {0x1EA2, 0x0000}, - {0x1EA4, 0x0000}, - {0x1EA6, 0x0000}, - {0x1EA8, 0x0000}, - {0x1EAA, 0x0000}, - {0x1EAC, 0x0000}, - {0x1EAE, 0x0000}, - {0x1EB0, 0x0000}, - {0x1EB2, 0x0000}, - {0x1EB4, 0x0000}, - {0x1EB6, 0x0000}, - {0x1EB8, 0x0000}, - {0x1EBA, 0x0000}, - {0x1EBC, 0x0000}, - {0x1EBE, 0x0000}, - {0x1EC0, 0x0000}, - {0x1EC2, 0x0000}, - {0x1EC4, 0x0000}, - {0x1EC6, 0x0000}, - {0x1EC8, 0x0000}, - {0x1ECA, 0x0000}, - {0x1ECC, 0x0000}, - {0x1ECE, 0x0000}, - {0x1ED0, 0x0000}, - {0x1ED2, 0x0000}, - {0x1ED4, 0x0000}, - {0x1ED6, 0x0000}, - {0x1ED8, 0x0000}, - {0x1EDA, 0x0000}, - {0x1EDC, 0x0000}, - {0x1EDE, 0x0000}, - {0x1EE0, 0x0000}, - {0x1EE2, 0x0000}, - {0x1EE4, 0x0000}, - {0x1EE6, 0x0000}, - {0x1EE8, 0x0000}, - {0x1EEA, 0x0000}, - {0x1EEC, 0x0000}, - {0x1EEE, 0x0000}, - {0x1EF0, 0x0000}, - {0x1EF2, 0x0000}, - {0x1EF4, 0x0000}, - {0x1EF6, 0x0000}, - {0x1EF8, 0x0000}, - {0x1F08, 0x1F0F}, - {0x1F18, 0x1F1D}, - {0x1F28, 0x1F2F}, - {0x1F38, 0x1F3F}, - {0x1F49, 0x1F4D}, - {0x1F59, 0x0000}, - {0x1F5B, 0x0000}, - {0x1F5D, 0x0000}, - {0x1F5F, 0x0000}, - {0x1F68, 0x1F6F}, - {0x1FB8, 0x1FBB}, - {0x1FC8, 0x1FCB}, - {0x1FD8, 0x1FDB}, - {0x1FE8, 0x1FEC}, - {0x1FF8, 0x1FFB}, - {0x2102, 0x0000}, - {0x2107, 0x0000}, - {0x210B, 0x210D}, - {0x2110, 0x2112}, - {0x2115, 0x0000}, - {0x2119, 0x211D}, - {0x2124, 0x0000}, - {0x2126, 0x0000}, - {0x2128, 0x0000}, - {0x212A, 0x212D}, - {0x2130, 0x2131}, - {0x2133, 0x0000}, - {0x213E, 0x213F}, - {0x2145, 0x0000}, - {0xFF21, 0xFF3A} -}; - -CATEGORY_CHAR_RANGE LlRanges[] = -{ - {0x0061, 0x007A}, - {0x00AA, 0x0000}, - {0x00B5, 0x0000}, - {0x00BA, 0x0000}, - {0x00DF, 0x0000}, - {0x00E0, 0x00FF}, - {0x0101, 0x0000}, - {0x0103, 0x0000}, - {0x0105, 0x0000}, - {0x0107, 0x0000}, - {0x0109, 0x0000}, - {0x010B, 0x0000}, - {0x010D, 0x0000}, - {0x010F, 0x0000}, - {0x0111, 0x0000}, - {0x0113, 0x0000}, - {0x0115, 0x0000}, - {0x0117, 0x0000}, - {0x0119, 0x0000}, - {0x011B, 0x0000}, - {0x011D, 0x0000}, - {0x011F, 0x0000}, - {0x0121, 0x0000}, - {0x0123, 0x0000}, - {0x0125, 0x0000}, - {0x0127, 0x0000}, - {0x0129, 0x0000}, - {0x012B, 0x0000}, - {0x012D, 0x0000}, - {0x012F, 0x0000}, - {0x0131, 0x0000}, - {0x0133, 0x0000}, - {0x0135, 0x0000}, - {0x0137, 0x0138}, - {0x013A, 0x0000}, - {0x013C, 0x0000}, - {0x013E, 0x0000}, - {0x0140, 0x0000}, - {0x0142, 0x0000}, - {0x0144, 0x0000}, - {0x0146, 0x0000}, - {0x0148, 0x0149}, - {0x014B, 0x0000}, - {0x014D, 0x0000}, - {0x014F, 0x0000}, - {0x0151, 0x0000}, - {0x0153, 0x0000}, - {0x0155, 0x0000}, - {0x0157, 0x0000}, - {0x0159, 0x0000}, - {0x015B, 0x0000}, - {0x015D, 0x0000}, - {0x015F, 0x0000}, - {0x0161, 0x0000}, - {0x0163, 0x0000}, - {0x0165, 0x0000}, - {0x0167, 0x0000}, - {0x0169, 0x0000}, - {0x016B, 0x0000}, - {0x016D, 0x0000}, - {0x016F, 0x0000}, - {0x0171, 0x0000}, - {0x0173, 0x0000}, - {0x0175, 0x0000}, - {0x0177, 0x0000}, - {0x017A, 0x0000}, - {0x017C, 0x0000}, - {0x017E, 0x017F}, - {0x0180, 0x0000}, - {0x0183, 0x0000}, - {0x0185, 0x0000}, - {0x0188, 0x0000}, - {0x018C, 0x018D}, - {0x0192, 0x0000}, - {0x0195, 0x0000}, - {0x0199, 0x019B}, - {0x019E, 0x0000}, - {0x01A1, 0x0000}, - {0x01A3, 0x0000}, - {0x01A5, 0x0000}, - {0x01A8, 0x0000}, - {0x01AA, 0x01AB}, - {0x01AD, 0x0000}, - {0x01B0, 0x0000}, - {0x01B4, 0x0000}, - {0x01B6, 0x0000}, - {0x01B9, 0x01BA}, - {0x01BD, 0x01BF}, - {0x01C6, 0x0000}, - {0x01C9, 0x0000}, - {0x01CC, 0x0000}, - {0x01CE, 0x0000}, - {0x01D2, 0x0000}, - {0x01D4, 0x0000}, - {0x01D6, 0x0000}, - {0x01D8, 0x0000}, - {0x01DA, 0x0000}, - {0x01DC, 0x01DD}, - {0x01DF, 0x0000}, - {0x01E1, 0x0000}, - {0x01E3, 0x0000}, - {0x01E5, 0x0000}, - {0x01E7, 0x0000}, - {0x01E9, 0x0000}, - {0x01EB, 0x0000}, - {0x01ED, 0x0000}, - {0x01EF, 0x0000}, - {0x01F0, 0x0000}, - {0x01F3, 0x0000}, - {0x01F5, 0x0000}, - {0x01F9, 0x0000}, - {0x01FB, 0x0000}, - {0x01FD, 0x0000}, - {0x01FF, 0x0000}, - {0x0201, 0x0000}, - {0x0203, 0x0000}, - {0x0205, 0x0000}, - {0x0207, 0x0000}, - {0x0209, 0x0000}, - {0x020B, 0x0000}, - {0x020D, 0x0000}, - {0x020F, 0x0000}, - {0x0211, 0x0000}, - {0x0213, 0x0000}, - {0x0215, 0x0000}, - {0x0217, 0x0000}, - {0x0219, 0x0000}, - {0x021B, 0x0000}, - {0x021D, 0x0000}, - {0x021F, 0x0000}, - {0x0221, 0x0000}, - {0x0223, 0x0000}, - {0x0225, 0x0000}, - {0x0227, 0x0000}, - {0x0229, 0x0000}, - {0x022B, 0x0000}, - {0x022D, 0x0000}, - {0x022F, 0x0000}, - {0x0231, 0x0000}, - {0x0233, 0x0236}, - {0x0234, 0x0000}, - {0x0250, 0x0000}, - {0x0209, 0x0000}, - {0x020B, 0x0000}, - {0x020D, 0x0000}, - {0x020F, 0x02AF}, - {0x0390, 0x0000}, - {0x03AC, 0x03CE}, - {0x03D0, 0x03D1}, - {0x03D5, 0x03D7}, - {0x03D9, 0x0000}, - {0x03DB, 0x0000}, - {0x03DD, 0x0000}, - {0x03DF, 0x0000}, - {0x03E1, 0x0000}, - {0x03E3, 0x0000}, - {0x03E5, 0x0000}, - {0x03E7, 0x0000}, - {0x03E9, 0x0000}, - {0x03EB, 0x0000}, - {0x03ED, 0x0000}, - {0x03EF, 0x03F3}, - {0x03F5, 0x0000}, - {0x03F8, 0x0000}, - {0x03FB, 0x0000}, - {0x0430, 0x045F}, - {0x0461, 0x0000}, - {0x0463, 0x0000}, - {0x0465, 0x0000}, - {0x0467, 0x0000}, - {0x0469, 0x0000}, - {0x046B, 0x0000}, - {0x046D, 0x0000}, - {0x046F, 0x0000}, - {0x0471, 0x0000}, - {0x0473, 0x0000}, - {0x0475, 0x0000}, - {0x0477, 0x0000}, - {0x0479, 0x0000}, - {0x047B, 0x0000}, - {0x047D, 0x0000}, - {0x047F, 0x0000}, - {0x0481, 0x0000}, - {0x048B, 0x0000}, - {0x048D, 0x0000}, - {0x048F, 0x0000}, - {0x0491, 0x0000}, - {0x0493, 0x0000}, - {0x0495, 0x0000}, - {0x0497, 0x0000}, - {0x0499, 0x0000}, - {0x049B, 0x0000}, - {0x049D, 0x0000}, - {0x049F, 0x0000}, - {0x04A1, 0x0000}, - {0x04A3, 0x0000}, - {0x04A5, 0x0000}, - {0x04A7, 0x0000}, - {0x04A9, 0x0000}, - {0x04AB, 0x0000}, - {0x04AD, 0x0000}, - {0x04AF, 0x0000}, - {0x04B1, 0x0000}, - {0x04B3, 0x0000}, - {0x04B5, 0x0000}, - {0x04B7, 0x0000}, - {0x04B9, 0x0000}, - {0x04BB, 0x0000}, - {0x04BD, 0x0000}, - {0x04BF, 0x0000}, - {0x04C2, 0x0000}, - {0x04C4, 0x0000}, - {0x04C6, 0x0000}, - {0x04C8, 0x0000}, - {0x04CA, 0x0000}, - {0x04CC, 0x0000}, - {0x04CE, 0x0000}, - {0x04D1, 0x0000}, - {0x04D3, 0x0000}, - {0x04D5, 0x0000}, - {0x04D7, 0x0000}, - {0x04D9, 0x0000}, - {0x04DB, 0x0000}, - {0x04DD, 0x0000}, - {0x04DF, 0x0000}, - {0x04E1, 0x0000}, - {0x04E3, 0x0000}, - {0x04E5, 0x0000}, - {0x04E7, 0x0000}, - {0x04E9, 0x0000}, - {0x04EB, 0x0000}, - {0x04ED, 0x0000}, - {0x04EF, 0x0000}, - {0x04F1, 0x0000}, - {0x04F3, 0x0000}, - {0x04F5, 0x0000}, - {0x04F9, 0x0000}, - {0x0501, 0x0000}, - {0x0503, 0x0000}, - {0x0505, 0x0000}, - {0x0507, 0x0000}, - {0x0509, 0x0000}, - {0x050B, 0x0000}, - {0x050D, 0x0000}, - {0x050F, 0x0000}, - {0x0561, 0x0587}, - {0x1D00, 0x1D2B}, - {0x1D62, 0x1D6B}, - {0x1E01, 0x0000}, - {0x1E03, 0x0000}, - {0x1E05, 0x0000}, - {0x1E07, 0x0000}, - {0x1E09, 0x0000}, - {0x1E0B, 0x0000}, - {0x1E0D, 0x0000}, - {0x1E0F, 0x0000}, - {0x1E11, 0x0000}, - {0x1E13, 0x0000}, - {0x1E15, 0x0000}, - {0x1E17, 0x0000}, - {0x1E19, 0x0000}, - {0x1E1B, 0x0000}, - {0x1E1D, 0x0000}, - {0x1E1F, 0x0000}, - {0x1E21, 0x0000}, - {0x1E23, 0x0000}, - {0x1E25, 0x0000}, - {0x1E27, 0x0000}, - {0x1E29, 0x0000}, - {0x1E2B, 0x0000}, - {0x1E2D, 0x0000}, - {0x1E2F, 0x0000}, - {0x1E31, 0x0000}, - {0x1E33, 0x0000}, - {0x1E35, 0x0000}, - {0x1E37, 0x0000}, - {0x1E39, 0x0000}, - {0x1E3B, 0x0000}, - {0x1E3D, 0x0000}, - {0x1E3F, 0x0000}, - {0x1E41, 0x0000}, - {0x1E43, 0x0000}, - {0x1E45, 0x0000}, - {0x1E47, 0x0000}, - {0x1E49, 0x0000}, - {0x1E4B, 0x0000}, - {0x1E4D, 0x0000}, - {0x1E4F, 0x0000}, - {0x1E51, 0x0000}, - {0x1E53, 0x0000}, - {0x1E55, 0x0000}, - {0x1E57, 0x0000}, - {0x1E59, 0x0000}, - {0x1E5B, 0x0000}, - {0x1E5D, 0x0000}, - {0x1E5F, 0x0000}, - {0x1E61, 0x0000}, - {0x1E63, 0x0000}, - {0x1E65, 0x0000}, - {0x1E67, 0x0000}, - {0x1E69, 0x0000}, - {0x1E6B, 0x0000}, - {0x1E6D, 0x0000}, - {0x1E6F, 0x0000}, - {0x1E71, 0x0000}, - {0x1E73, 0x0000}, - {0x1E75, 0x0000}, - {0x1E77, 0x0000}, - {0x1E79, 0x0000}, - {0x1E7B, 0x0000}, - {0x1E7D, 0x0000}, - {0x1E7F, 0x0000}, - {0x1E81, 0x0000}, - {0x1E83, 0x0000}, - {0x1E85, 0x0000}, - {0x1E87, 0x0000}, - {0x1E89, 0x0000}, - {0x1E8B, 0x0000}, - {0x1E8D, 0x0000}, - {0x1E8F, 0x0000}, - {0x1E91, 0x0000}, - {0x1E93, 0x0000}, - {0x1E95, 0x1E9B}, - {0x1EA1, 0x0000}, - {0x1EA3, 0x0000}, - {0x1EA5, 0x0000}, - {0x1EA7, 0x0000}, - {0x1EA9, 0x0000}, - {0x1EAB, 0x0000}, - {0x1EAD, 0x0000}, - {0x1EAF, 0x0000}, - {0x1EB1, 0x0000}, - {0x1EB3, 0x0000}, - {0x1EB5, 0x0000}, - {0x1EB7, 0x0000}, - {0x1EB9, 0x0000}, - {0x1EBB, 0x0000}, - {0x1EBD, 0x0000}, - {0x1EBF, 0x0000}, - {0x1EC1, 0x0000}, - {0x1EC3, 0x0000}, - {0x1EC5, 0x0000}, - {0x1EC7, 0x0000}, - {0x1EC9, 0x0000}, - {0x1ECB, 0x0000}, - {0x1ECD, 0x0000}, - {0x1ECF, 0x0000}, - {0x1ED1, 0x0000}, - {0x1ED3, 0x0000}, - {0x1ED5, 0x0000}, - {0x1ED7, 0x0000}, - {0x1ED9, 0x0000}, - {0x1EDB, 0x0000}, - {0x1EDD, 0x0000}, - {0x1EDF, 0x0000}, - {0x1EE1, 0x0000}, - {0x1EE3, 0x0000}, - {0x1EE5, 0x0000}, - {0x1EE7, 0x0000}, - {0x1EE9, 0x0000}, - {0x1EEB, 0x0000}, - {0x1EED, 0x0000}, - {0x1EEF, 0x0000}, - {0x1EF1, 0x0000}, - {0x1EF3, 0x0000}, - {0x1EF5, 0x0000}, - {0x1EF7, 0x0000}, - {0x1EF9, 0x0000}, - {0x1F00, 0x1F07}, - {0x1F10, 0x1F15}, - {0x1F20, 0x1F27}, - {0x1F30, 0x1F37}, - {0x1F40, 0x1F45}, - {0x1F50, 0x1F57}, - {0x1F60, 0x1F67}, - {0x1F70, 0x1F7D}, - {0x1F80, 0x1F87}, - {0x1F90, 0x1F97}, - {0x1FA0, 0x1FA7}, - {0x1FB0, 0x1FB7}, - {0x1FBE, 0x0000}, - {0x1FC2, 0x1FC4}, - {0x1FC6, 0x1FC7}, - {0x1FD0, 0x1FD7}, - {0x1FE0, 0x1FE7}, - {0x1FF2, 0x1FF4}, - {0x1FF6, 0x1FF7}, - {0x2071, 0x0000}, - {0x207F, 0x0000}, - {0x210A, 0x0000}, - {0x210E, 0x210F}, - {0x2113, 0x0000}, - {0x212F, 0x0000}, - {0x2134, 0x0000}, - {0x2139, 0x0000}, - {0x213D, 0x0000}, - {0x2146, 0x2149}, - {0xFB00, 0xFB06}, - {0xFB13, 0xFB17}, - {0xFF41, 0xFF5A}, - {0x1E0B, 0x0000}, - {0x1E0D, 0x0000}, - {0x1E0F, 0x0000} -}; - -CATEGORY_CHAR_RANGE LtRanges[] = -{ - {0x01C5, 0x0000}, - {0x01C8, 0x0000}, - {0x01CB, 0x0000}, - {0x01F2, 0x0000}, - {0x1F88, 0x1F8F}, - {0x1F98, 0x1F9F}, - {0x1FA8, 0x1FAF}, - {0x1FBC, 0x0000}, - {0x1FCC, 0x0000}, - {0x1FFC, 0x0000} -}; - -CATEGORY_CHAR_RANGE LmRanges[] = -{ - {0x02B0, 0x02C1}, - {0x02C6, 0x02D1}, - {0x02E0, 0x02E4}, - {0x02EE, 0x0000}, - {0x037A, 0x0000}, - {0x0559, 0x0000}, - {0x0640, 0x0000}, - {0x06E5, 0x06E6}, - {0x0E46, 0x0000}, - {0x0EC6, 0x0000}, - {0x17D7, 0x0000}, - {0x1843, 0x0000}, - {0x1D2C, 0x1D61}, - {0x3005, 0x0000}, - {0x3031, 0x3035}, - {0x303B, 0x0000}, - {0x309D, 0x309E}, - {0x30FC, 0x30FE}, - {0xFF70, 0x0000}, - {0xFF9E, 0xFF9F} -}; - -CATEGORY_CHAR_RANGE LoRanges[] = -{ - {0x01BB, 0x0000}, - {0x01C0, 0x01C3}, - {0x05D0, 0x05EA}, - {0x05F0, 0x05F2}, - {0x0621, 0x063A}, - {0x0641, 0x064A}, - {0x066E, 0x066F}, - {0x0671, 0x06D3}, - {0x06D5, 0x0000}, - {0x06EE, 0x06EF}, - {0x06FA, 0x06FC}, - {0x06FF, 0x0000}, - {0x0710, 0x0000}, - {0x0712, 0x072F}, - {0x074D, 0x074F}, - {0x0780, 0x07A5}, - {0x07B1, 0x0000}, - {0x0904, 0x0939}, - {0x093D, 0x0000}, - {0x0950, 0x0000}, - {0x0958, 0x0961}, - {0x0985, 0x098C}, - {0x098F, 0x0990}, - {0x0993, 0x09A8}, - {0x09AA, 0x09B0}, - {0x09B2, 0x0000}, - {0x09B6, 0x09B9}, - {0x09BD, 0x0000}, - {0x09DC, 0x09DD}, - {0x09DF, 0x09E1}, - {0x09F0, 0x09F1}, - {0x0A05, 0x0A0A}, - {0x0A0F, 0x0A10}, - {0x0A13, 0x0A28}, - {0x0A2A, 0x0A30}, - {0x0A32, 0x0A33}, - {0x0A35, 0x0A36}, - {0x0A38, 0x0A39}, - {0x0A59, 0x0A5C}, - {0x0A5E, 0x0000}, - {0x0A72, 0x0A74}, - {0x0A85, 0x0A8D}, - {0x0A8F, 0x0A91}, - {0x0A93, 0x0AB0}, - {0x0AB2, 0x0AB3}, - {0x0AB5, 0x0AB9}, - {0x0ABD, 0x0000}, - {0x0AD0, 0x0000}, - {0x0AE0, 0x0AE1}, - {0x0B05, 0x0B0C}, - {0x0B0F, 0x0B10}, - {0x0B13, 0x0B30}, - {0x0B32, 0x0B33}, - {0x0B35, 0x0B39}, - {0x0B3D, 0x0000}, - {0x0B5C, 0x0B5D}, - {0x0B5F, 0x0B61}, - {0x0B71, 0x0000}, - {0x0B83, 0x0000}, - {0x0B85, 0x0B8A}, - {0x0B8E, 0x0B90}, - {0x0B92, 0x0B95}, - {0x0B99, 0x0B9A}, - {0x0B9C, 0x0000}, - {0x0B9E, 0x0B9F}, - {0x0BA3, 0x0BA4}, - {0x0BA8, 0x0BAA}, - {0x0BAE, 0x0BAF}, - {0x0BB0, 0x0BB9}, - {0x0C05, 0x0C0C}, - {0x0C0E, 0x0C10}, - {0x0C12, 0x0C28}, - {0x0C2A, 0x0C33}, - {0x0C35, 0x0C39}, - {0x0C60, 0x0C61}, - {0x0C85, 0x0C8C}, - {0x0C8E, 0x0C90}, - {0x0C92, 0x0CB3}, - {0x0CB5, 0x0CB9}, - {0x0CBD, 0x0000}, - {0x0CDE, 0x0000}, - {0x0CE0, 0x0CE1}, - {0x0D05, 0x0D0C}, - {0x0D0E, 0x0D10}, - {0x0D12, 0x0D28}, - {0x0D2A, 0x0D39}, - {0x0D60, 0x0D61}, - {0x0D85, 0x0D96}, - {0x0D9A, 0x0DB1}, - {0x0DB3, 0x0DBB}, - {0x0DBD, 0x0000}, - {0x0DC0, 0x0DC6}, - {0x0E01, 0x0E30}, - {0x0E32, 0x0E33}, - {0x0E40, 0x0E45}, - {0x0E81, 0x0E82}, - {0x0E84, 0x0000}, - {0x0E87, 0x0E88}, - {0x0E8A, 0x0000}, - {0x0E8D, 0x0000}, - {0x0E94, 0x0E97}, - {0x0E99, 0x0E9F}, - {0x0EA1, 0x0EA3}, - {0x0EA5, 0x0000}, - {0x0EA7, 0x0000}, - {0x0EAA, 0x0EAB}, - {0x0EAD, 0x0EB0}, - {0x0EB2, 0x0EB3}, - {0x0EBD, 0x0000}, - {0x0EC0, 0x0EC4}, - {0x0EDC, 0x0EDD}, - {0x0F00, 0x0000}, - {0x0F40, 0x0F47}, - {0x0F49, 0x0F6A}, - {0x0F88, 0x0F8B}, - {0x1000, 0x1021}, - {0x1023, 0x1027}, - {0x1029, 0x102A}, - {0x1050, 0x1055}, - {0x10D0, 0x10F8}, - {0x1100, 0x11A2}, - {0x11A8, 0x11F9}, - {0x1200, 0x1248}, - {0x124A, 0x124D}, - {0x1250, 0x1256}, - {0x1258, 0x0000}, - {0x125A, 0x125D}, - {0x1260, 0x1286}, - {0x1288, 0x0000}, - {0x128A, 0x128D}, - {0x1290, 0x12AE}, - {0x12B0, 0x0000}, - {0x12B2, 0x12B5}, - {0x12B8, 0x12BE}, - {0x12C0, 0x0000}, - {0x12C2, 0x12C5}, - {0x12C8, 0x12CE}, - {0x12D0, 0x12D6}, - {0x12D8, 0x12EE}, - {0x12F0, 0x130E}, - {0x1310, 0x0000}, - {0x1312, 0x1315}, - {0x1318, 0x131E}, - {0x1320, 0x1346}, - {0x1348, 0x135A}, - {0x13A0, 0x13F4}, - {0x1401, 0x166C}, - {0x166F, 0x1676}, - {0x1681, 0x169A}, - {0x16A0, 0x16EA}, - {0x1700, 0x170C}, - {0x170E, 0x1711}, - {0x1720, 0x1731}, - {0x1740, 0x1751}, - {0x1760, 0x176C}, - {0x176E, 0x1770}, - {0x1780, 0x17B3}, - {0x17DC, 0x0000}, - {0x1820, 0x1842}, - {0x1844, 0x1877}, - {0x1880, 0x18A8}, - {0x1900, 0x191C}, - {0x1950, 0x196D}, - {0x1970, 0x1974}, - {0x2135, 0x2138}, - {0x3006, 0x0000}, - {0x303C, 0x0000}, - {0x3041, 0x3096}, - {0x309F, 0x0000}, - {0x30A1, 0x30FA}, - {0x30FF, 0x0000}, - {0x3105, 0x312C}, - {0x3131, 0x318E}, - {0x31A0, 0x31B7}, - {0x31F0, 0x31FF}, - {0x3400, 0x0000}, - {0x4DB5, 0x0000}, - {0x4E00, 0x0000}, - {0x9FA5, 0x0000}, - {0xA000, 0xA48C}, - {0xAC00, 0x0000}, - {0xD7A3, 0x0000}, - {0xF900, 0xFA2D}, - {0xFA30, 0xFA6A}, - {0xFB1D, 0x0000}, - {0xFB1F, 0xFB28}, - {0xFB2A, 0xFB36}, - {0xFB38, 0xFB3C}, - {0xFB3E, 0x0000}, - {0xFB40, 0xFB41}, - {0xFB43, 0xFB44}, - {0xFB46, 0xFBB1}, - {0xFBD3, 0xFD3D}, - {0xFD50, 0xFD8F}, - {0xFD92, 0xFDC7}, - {0xFDF0, 0xFDFB}, - {0xFE70, 0xFE74}, - {0xFE76, 0xFEFC}, - {0xFF66, 0xFF6F}, - {0xFF71, 0xFF9D}, - {0xFFA0, 0xFFBE}, - {0xFFC2, 0xFFC7}, - {0xFFCA, 0xFFCF}, - {0xFFD2, 0xFFD7}, - {0xFFDA, 0xFFDC} -}; - -CATEGORY_CHAR_RANGE MnRanges[] = -{ - {0x0300, 0x0357}, - {0x035D, 0x036F}, - {0x0483, 0x0486}, - {0x0591, 0x05A1}, - {0x05A3, 0x05B9}, - {0x05BB, 0x05BD}, - {0x05BF, 0x0000}, - {0x05C1, 0x05C2}, - {0x05C4, 0x0000}, - {0x0610, 0x0615}, - {0x064B, 0x0658}, - {0x0670, 0x0000}, - {0x06D6, 0x06DC}, - {0x06DF, 0x06E4}, - {0x06E7, 0x06E8}, - {0x06EA, 0x06ED}, - {0x0711, 0x0000}, - {0x0730, 0x074A}, - {0x07A6, 0x07B0}, - {0x0901, 0x0902}, - {0x093C, 0x0000}, - {0x0941, 0x0948}, - {0x094D, 0x0000}, - {0x0951, 0x0954}, - {0x0962, 0x0963}, - {0x0981, 0x0000}, - {0x09BC, 0x0000}, - {0x09C1, 0x09C4}, - {0x09CD, 0x0000}, - {0x09E2, 0x09E3}, - {0x0A01, 0x0A02}, - {0x0A3C, 0x0000}, - {0x0A41, 0x0A42}, - {0x0A47, 0x0A48}, - {0x0A4B, 0x0A4D}, - {0x0A70, 0x0A71}, - {0x0A81, 0x0A82}, - {0x0ABC, 0x0000}, - {0x0AC1, 0x0AC5}, - {0x0AC7, 0x0AC8}, - {0x0ACD, 0x0000}, - {0x0AE2, 0x0AE3}, - {0x0B01, 0x0000}, - {0x0B3C, 0x0000}, - {0x0B3F, 0x0000}, - {0x0B41, 0x0B43}, - {0x0B4D, 0x0000}, - {0x0B56, 0x0000}, - {0x0B82, 0x0000}, - {0x0BC0, 0x0000}, - {0x0BCD, 0x0000}, - {0x0C3E, 0x0C40}, - {0x0C46, 0x0C48}, - {0x0C4A, 0x0C4D}, - {0x0C55, 0x0C56}, - {0x0CBC, 0x0000}, - {0x0CBF, 0x0000}, - {0x0CC6, 0x0000}, - {0x0CCC, 0x0CCD}, - {0x0D41, 0x0D43}, - {0x0D4D, 0x0000}, - {0x0DCA, 0x0000}, - {0x0DD2, 0x0DD4}, - {0x0DD6, 0x0000}, - {0x0E31, 0x0000}, - {0x0E34, 0x0E3A}, - {0x0E47, 0x0E4E}, - {0x0EB1, 0x0000}, - {0x0EB4, 0x0EB9}, - {0x0EBB, 0x0EBC}, - {0x0EC8, 0x0ECD}, - {0x0F18, 0x0F19}, - {0x0F35, 0x0000}, - {0x0F37, 0x0000}, - {0x0F39, 0x0000}, - {0x0F71, 0x0F7E}, - {0x0F80, 0x0F84}, - {0x0F86, 0x0F87}, - {0x0F90, 0x0F97}, - {0x0F99, 0x0FBC}, - {0x0FC6, 0x0000}, - {0x102D, 0x1030}, - {0x1032, 0x0000}, - {0x1036, 0x1037}, - {0x1039, 0x0000}, - {0x1058, 0x1059}, - {0x1712, 0x1714}, - {0x1732, 0x1734}, - {0x1752, 0x1753}, - {0x1772, 0x1773}, - {0x17B7, 0x17BD}, - {0x17C6, 0x0000}, - {0x17C9, 0x17D3}, - {0x17DD, 0x0000}, - {0x180B, 0x180D}, - {0x18A9, 0x0000}, - {0x1920, 0x1922}, - {0x1927, 0x1928}, - {0x1932, 0x0000}, - {0x1939, 0x193B}, - {0x20D0, 0x20DC}, - {0x20E1, 0x0000}, - {0x20E5, 0x20EA}, - {0x302A, 0x302F}, - {0x3099, 0x309A}, - {0xFB1E, 0x0000}, - {0xFE00, 0xFE0F}, - {0xFE20, 0xFE23} -}; - -CATEGORY_CHAR_RANGE McRanges[] = -{ - {0x0903, 0x0000}, - {0x093E, 0x0940}, - {0x0949, 0x094C}, - {0x0982, 0x0983}, - {0x09BE, 0x09C0}, - {0x09C7, 0x09C8}, - {0x09CB, 0x09CC}, - {0x09D7, 0x0000}, - {0x0A03, 0x0000}, - {0x0A3E, 0x0A40}, - {0x0A83, 0x0000}, - {0x0ABE, 0x0AC0}, - {0x0AC9, 0x0000}, - {0x0ACB, 0x0ACC}, - {0x0B02, 0x0B03}, - {0x0BE3, 0x0000}, - {0x0B40, 0x0000}, - {0x0B47, 0x0B48}, - {0x0B4B, 0x0B4C}, - {0x0B57, 0x0000}, - {0x0BBE, 0x0BBF}, - {0x0BC1, 0x0BC2}, - {0x0BC6, 0x0BC8}, - {0x0BCA, 0x0BCC}, - {0x0BD7, 0x0000}, - {0x0C01, 0x0C03}, - {0x0C41, 0x0C44}, - {0x0C82, 0x0C83}, - {0x0CBE, 0x0000}, - {0x0CC0, 0x0CC4}, - {0x0CC7, 0x0CC8}, - {0x0CCA, 0x0CCB}, - {0x0CD5, 0x0CD6}, - {0x0D02, 0x0D03}, - {0x0D3E, 0x0D40}, - {0x0D46, 0x0D48}, - {0x0D4A, 0x0D4C}, - {0x0D57, 0x0000}, - {0x0D82, 0x0D83}, - {0x0DCF, 0x0DD1}, - {0x0DD8, 0x0DDF}, - {0x0DF2, 0x0DF3}, - {0x0F3E, 0x0F3F}, - {0x0F7F, 0x0000}, - {0x102C, 0x0000}, - {0x1031, 0x0000}, - {0x1038, 0x0000}, - {0x1056, 0x1057}, - {0x17B6, 0x0000}, - {0x17BE, 0x17C5}, - {0x17C7, 0x17C8}, - {0x1923, 0x1926}, - {0x1929, 0x192B}, - {0x1930, 0x1931}, - {0x1933, 0x1938} -}; - -CATEGORY_CHAR_RANGE MeRanges[] = -{ - {0x0488, 0x0489}, - {0x06DE, 0x0000}, - {0x20DD, 0x20DF}, - {0x20E0, 0x0000}, - {0x20E2, 0x20E4} -}; - -CATEGORY_CHAR_RANGE DigitRanges[] = // Part 1 of Nd category -{ - {0x0030, 0x0039}, - {0x0660, 0x0669}, - {0x06F0, 0x06F9}, - {0x0966, 0x096F}, - {0x09E6, 0x09EF}, - {0x0A66, 0x0A6F}, - {0x0AE6, 0x0AEF}, - {0x0B66, 0x0B6F}, - {0x0BE7, 0x0BEF}, - {0x0C66, 0x0C6F}, - {0x0CE6, 0x0CEF}, - {0x0D66, 0x0D6F}, - {0x0E50, 0x0E59}, - {0x0ED0, 0x0ED9}, - {0x0F20, 0x0F29} -}; - -CATEGORY_CHAR_RANGE Nd2Ranges[] = // Part 2 of Nd category -{ - {0x1040, 0x1049}, - {0x1369, 0x1371}, - {0x17E0, 0x17E9}, - {0x1810, 0x1819}, - {0x1946, 0x194F}, - {0xFF10, 0xFF19} -}; - -CATEGORY_CHAR_RANGE NlRanges[] = -{ - {0x16EE, 0x16F0}, - {0x2160, 0x2183}, - {0x3007, 0x0000}, - {0x3021, 0x3029}, - {0x3038, 0x303A} -}; - -CATEGORY_CHAR_RANGE NoRanges[] = -{ - {0x00B2, 0x00B3}, - {0x00B9, 0x0000}, - {0x00BC, 0x00BE}, - {0x09F4, 0x09F9}, - {0x0BF0, 0x0BF2}, - {0x0F2A, 0x0F33}, - {0x1372, 0x137C}, - {0x17F0, 0x17F9}, - {0x2070, 0x0000}, - {0x2074, 0x2079}, - {0x2080, 0x2089}, - {0x2153, 0x215F}, - {0x2460, 0x249B}, - {0x24EA, 0x24FF}, - {0x2776, 0x2793}, - {0x3192, 0x3195}, - {0x3220, 0x3229}, - {0x3251, 0x325F}, - {0x3280, 0x3289}, - {0x32B1, 0x32BF} -}; - -CATEGORY_CHAR_RANGE PcRanges[] = -{ - {0x005F, 0x0000}, - {0x203F, 0x2040}, - {0x2054, 0x0000}, - {0x30FB, 0x0000}, - {0xFE33, 0xFE34}, - {0xFE4D, 0xFE4F}, - {0xFF3F, 0x0000}, - {0xFF65, 0x0000} -}; - -CATEGORY_CHAR_RANGE PdRanges[] = -{ - {0x002D, 0x0000}, - {0x058A, 0x0000}, - {0x1806, 0x0000}, - {0x2010, 0x2015}, - {0x301C, 0x0000}, - {0x3030, 0x0000}, - {0x30A0, 0x0000}, - {0xFE31, 0xFE32}, - {0xFE58, 0x0000}, - {0xFE63, 0x0000}, - {0xFF0D, 0x0000} -}; - -CATEGORY_CHAR_RANGE PsRanges[] = -{ - {0x0028, 0x0000}, - {0x005B, 0x0000}, - {0x007B, 0x0000}, - {0x0F3A, 0x0000}, - {0x0F3C, 0x0000}, - {0x169B, 0x0000}, - {0x201A, 0x0000}, - {0x201E, 0x0000}, - {0x2045, 0x0000}, - {0x207D, 0x0000}, - {0x208D, 0x0000}, - {0x2329, 0x0000}, - {0x23B4, 0x0000}, - {0x2768, 0x0000}, - {0x276A, 0x0000}, - {0x276C, 0x0000}, - {0x276E, 0x0000}, - {0x2770, 0x0000}, - {0x2772, 0x0000}, - {0x2774, 0x0000}, - {0x27E6, 0x0000}, - {0x27E8, 0x0000}, - {0x27EA, 0x0000}, - {0x2983, 0x0000}, - {0x2985, 0x0000}, - {0x2987, 0x0000}, - {0x2989, 0x0000}, - {0x298B, 0x0000}, - {0x298D, 0x0000}, - {0x298F, 0x0000}, - {0x2991, 0x0000}, - {0x2993, 0x0000}, - {0x2995, 0x0000}, - {0x2997, 0x0000}, - {0x29D8, 0x0000}, - {0x29DA, 0x0000}, - {0x29FC, 0x0000}, - {0x3008, 0x0000}, - {0x300A, 0x0000}, - {0x300C, 0x0000}, - {0x300E, 0x0000}, - {0x3010, 0x0000}, - {0x3014, 0x0000}, - {0x3016, 0x0000}, - {0x3018, 0x0000}, - {0x301A, 0x0000}, - {0x301D, 0x0000}, - {0xFD3E, 0x0000}, - {0xFE35, 0x0000}, - {0xFE37, 0x0000}, - {0xFE39, 0x0000}, - {0xFE3B, 0x0000}, - {0xFE3D, 0x0000}, - {0xFE3F, 0x0000}, - {0xFE41, 0x0000}, - {0xFE43, 0x0000}, - {0xFE47, 0x0000}, - {0xFE59, 0x0000}, - {0xFE5B, 0x0000}, - {0xFE5D, 0x0000}, - {0xFF08, 0x0000}, - {0xFF3B, 0x0000}, - {0xFF5B, 0x0000}, - {0xFF5F, 0x0000}, - {0xFF62, 0x0000} -}; - -CATEGORY_CHAR_RANGE PeRanges[] = -{ - {0x0029, 0x0000}, - {0x005D, 0x0000}, - {0x007D, 0x0000}, - {0x0F3B, 0x0000}, - {0x0F3D, 0x0000}, - {0x169C, 0x0000}, - {0x2046, 0x0000}, - {0x207E, 0x0000}, - {0x208E, 0x0000}, - {0x232A, 0x0000}, - {0x23B5, 0x0000}, - {0x2769, 0x0000}, - {0x276B, 0x0000}, - {0x276D, 0x0000}, - {0x276F, 0x0000}, - {0x2771, 0x0000}, - {0x2773, 0x0000}, - {0x2775, 0x0000}, - {0x27E7, 0x0000}, - {0x27E9, 0x0000}, - {0x27EB, 0x0000}, - {0x2984, 0x0000}, - {0x2986, 0x0000}, - {0x2988, 0x0000}, - {0x298A, 0x0000}, - {0x298C, 0x0000}, - {0x298E, 0x0000}, - {0x2990, 0x0000}, - {0x2992, 0x0000}, - {0x2994, 0x0000}, - {0x2996, 0x0000}, - {0x2998, 0x0000}, - {0x29D9, 0x0000}, - {0x29DB, 0x0000}, - {0x29FD, 0x0000}, - {0x3009, 0x0000}, - {0x300B, 0x0000}, - {0x300D, 0x0000}, - {0x300F, 0x0000}, - {0x3011, 0x0000}, - {0x3015, 0x0000}, - {0x3017, 0x0000}, - {0x3019, 0x0000}, - {0x301B, 0x0000}, - {0x301E, 0x0000}, - {0x301F, 0x0000}, - {0xFD3F, 0x0000}, - {0xFE36, 0x0000}, - {0xFE38, 0x0000}, - {0xFE3A, 0x0000}, - {0xFE3C, 0x0000}, - {0xFE3E, 0x0000}, - {0xFE40, 0x0000}, - {0xFE42, 0x0000}, - {0xFE44, 0x0000}, - {0xFE48, 0x0000}, - {0xFE5A, 0x0000}, - {0xFE5C, 0x0000}, - {0xFE5E, 0x0000}, - {0xFF09, 0x0000}, - {0xFF3D, 0x0000}, - {0xFF5D, 0x0000}, - {0xFF60, 0x0000}, - {0xFF63, 0x0000} -}; - -CATEGORY_CHAR_RANGE PiRanges[] = -{ - {0x00AB, 0x0000}, - {0x2018, 0x0000}, - {0x201B, 0x201C}, - {0x201F, 0x0000}, - {0x2039, 0x0000} -}; - -CATEGORY_CHAR_RANGE PfRanges[] = -{ - {0x00BB, 0x0000}, - {0x2019, 0x0000}, - {0x201D, 0x0000}, - {0x203A, 0x0000} -}; - -CATEGORY_CHAR_RANGE PoRanges[] = -{ - {0x0021, 0x0023}, - {0x0025, 0x0027}, - {0x002A, 0x0000}, - {0x002C, 0x0000}, - {0x002E, 0x002F}, - {0x003A, 0x003B}, - {0x003F, 0x0040}, - {0x005C, 0x0000}, - {0x00A1, 0x0000}, - {0x00B7, 0x0000}, - {0x00BF, 0x0000}, - {0x037E, 0x0000}, - {0x0387, 0x0000}, - {0x055A, 0x055F}, - {0x0589, 0x0000}, - {0x05BE, 0x0000}, - {0x05C0, 0x0000}, - {0x05C3, 0x0000}, - {0x05F3, 0x05F4}, - {0x060C, 0x060D}, - {0x061B, 0x0000}, - {0x061F, 0x0000}, - {0x066A, 0x066D}, - {0x06D4, 0x0000}, - {0x0700, 0x070D}, - {0x0964, 0x0965}, - {0x0970, 0x0000}, - {0x0DF4, 0x0000}, - {0x0E4F, 0x0000}, - {0x0E5A, 0x0E5B}, - {0x0F04, 0x0F12}, - {0x0F85, 0x0000}, - {0x104A, 0x104F}, - {0x10FB, 0x0000}, - {0x1361, 0x1368}, - {0x166D, 0x166E}, - {0x16EB, 0x16ED}, - {0x1735, 0x1736}, - {0x17D4, 0x17D6}, - {0x17D8, 0x17DA}, - {0x1800, 0x1805}, - {0x1807, 0x180A}, - {0x1944, 0x1945}, - {0x2016, 0x2017}, - {0x2020, 0x2027}, - {0x2030, 0x2038}, - {0x203B, 0x203E}, - {0x2041, 0x2043}, - {0x2047, 0x2051}, - {0x2053, 0x0000}, - {0x2057, 0x0000}, - {0x23B6, 0x0000}, - {0x3001, 0x3003}, - {0x303D, 0x0000}, - {0xFE30, 0x0000}, - {0xFE45, 0xFE46}, - {0xFE49, 0xFE4C}, - {0xFE50, 0xFE52}, - {0xFE54, 0xFE57}, - {0xFE5F, 0xFE61}, - {0xFE68, 0x0000}, - {0xFE6A, 0xFE6B}, - {0xFF01, 0xFF03}, - {0xFF05, 0xFF07}, - {0xFF0A, 0x0000}, - {0xFF0C, 0x0000}, - {0xFF0E, 0xFF0F}, - {0xFF1A, 0xFF1B}, - {0xFF1F, 0xFF20}, - {0xFF3C, 0x0000}, - {0xFF61, 0x0000}, - {0xFF64, 0x0000} -}; - -CATEGORY_CHAR_RANGE ZsRanges[] = -{ - {0x0020, 0x0000}, - {0x00A0, 0x0000}, - {0x1680, 0x0000}, - {0x180E, 0x0000}, - {0x2000, 0x200B}, - {0x202F, 0x0000}, - {0x205F, 0x0000}, - {0x3000, 0x0000} -}; - -CATEGORY_CHAR_RANGE ZlRanges[] = -{ - {0x2028, 0x0000} -}; - -CATEGORY_CHAR_RANGE ZpRanges[] = -{ - {0x2029, 0x0000} -}; - -CATEGORY_CHAR_RANGE SmRanges[] = -{ - {0x002B, 0x0000}, - {0x003C, 0x003E}, - {0x007C, 0x0000}, - {0x007E, 0x0000}, - {0x00AC, 0x0000}, - {0x00B1, 0x0000}, - {0x00D7, 0x0000}, - {0x00F7, 0x0000}, - {0x03F6, 0x0000}, - {0x2044, 0x0000}, - {0x2052, 0x0000}, - {0x207A, 0x207C}, - {0x208A, 0x208C}, - {0x2140, 0x2144}, - {0x214B, 0x0000}, - {0x2190, 0x2194}, - {0x219A, 0x219B}, - {0x21A0, 0x0000}, - {0x21A3, 0x0000}, - {0x21A6, 0x0000}, - {0x21AE, 0x0000}, - {0x21CE, 0x21CF}, - {0x21D2, 0x0000}, - {0x21D4, 0x0000}, - {0x21F4, 0x21FF}, - {0x2200, 0x22FF}, - {0x2308, 0x230B}, - {0x2320, 0x2321}, - {0x237C, 0x0000}, - {0x239B, 0x23B3}, - {0x25B7, 0x0000}, - {0x25C1, 0x0000}, - {0x25F8, 0x25FF}, - {0x266F, 0x0000}, - {0x27D0, 0x27E5}, - {0x27F0, 0x27FF}, - {0x2900, 0x2982}, - {0x2999, 0x29D7}, - {0x29DC, 0x29FB}, - {0x29FE, 0x2AFF}, - {0xFB29, 0x0000}, - {0xFE62, 0x0000}, - {0xFE64, 0xFE66}, - {0xFF0B, 0x0000}, - {0xFF1C, 0xFF1E}, - {0xFF5C, 0x0000}, - {0xFF5E, 0x0000}, - {0xFFE2, 0x0000}, - {0xFFE9, 0xFFEC} -}; - -CATEGORY_CHAR_RANGE ScRanges[] = -{ - {0x0024, 0x0000}, - {0x00A2, 0x00A5}, - {0x09F2, 0x09F3}, - {0x0AF1, 0x0000}, - {0x0BF9, 0x0000}, - {0x0E3F, 0x0000}, - {0x17DB, 0x0000}, - {0x20A0, 0x20B1}, - {0xFDFC, 0x0000}, - {0xFE69, 0x0000}, - {0xFF04, 0x0000}, - {0xFFE0, 0xFFE1}, - {0xFFE5, 0xFFE6} -}; - -CATEGORY_CHAR_RANGE SkRanges[] = -{ - {0x005E, 0x0000}, - {0x0060, 0x0000}, - {0x00A8, 0x0000}, - {0x00AF, 0x0000}, - {0x00B4, 0x0000}, - {0x00B8, 0x0000}, - {0x02C2, 0x02C5}, - {0x02D2, 0x02DF}, - {0x02E5, 0x02FF}, - {0x0374, 0x0375}, - {0x0384, 0x0385}, - {0x1FBD, 0x0000}, - {0x1FBF, 0x1FC1}, - {0x1FCD, 0x1FCF}, - {0x1FDD, 0x1FDF}, - {0x1FED, 0x1FEF}, - {0x1FFD, 0x0000}, - {0x1FFE, 0x0000}, - {0x309B, 0x309C}, - {0xFF3E, 0x0000}, - {0xFF40, 0x0000}, - {0xFFE3, 0x0000} -}; - -CATEGORY_CHAR_RANGE SoRanges[] = -{ - {0x00A6, 0x00A7}, - {0x00A9, 0x0000}, - {0x00AE, 0x0000}, - {0x00B0, 0x0000}, - {0x00B6, 0x0000}, - {0x0482, 0x0000}, - {0x060E, 0x060F}, - {0x06E9, 0x0000}, - {0x06FD, 0x06FE}, - {0x09FA, 0x0000}, - {0x0B70, 0x0000}, - {0x0BF3, 0x0BFA}, - {0x0F01, 0x0F03}, - {0x0F13, 0x0F17}, - {0x0F1A, 0x0F1F}, - {0x0F34, 0x0000}, - {0x0F36, 0x0000}, - {0x0F38, 0x0000}, - {0x0FBE, 0x0FBF}, - {0x0FC0, 0x0FC5}, - {0x0FC7, 0x0FCC}, - {0x0FCF, 0x0000}, - {0x1940, 0x0000}, - {0x19E0, 0x19FF}, - {0x2100, 0x2101}, - {0x2103, 0x2106}, - {0x2108, 0x2109}, - {0x2114, 0x0000}, - {0x2116, 0x2118}, - {0x211E, 0x211F}, - {0x2120, 0x2123}, - {0x2125, 0x0000}, - {0x2127, 0x0000}, - {0x2129, 0x0000}, - {0x212E, 0x0000}, - {0x2132, 0x0000}, - {0x213A, 0x213B}, - {0x214A, 0x0000}, - {0x2195, 0x2199}, - {0x219C, 0x219F}, - {0x21A1, 0x21A2}, - {0x21A4, 0x21A5}, - {0x21A7, 0x21AD}, - {0x21AF, 0x21CD}, - {0x21D0, 0x21D1}, - {0x21D3, 0x0000}, - {0x21D5, 0x21F3}, - {0x2300, 0x2307}, - {0x230C, 0x231F}, - {0x2322, 0x2328}, - {0x232B, 0x237B}, - {0x237D, 0x239A}, - {0x23B7, 0x23D0}, - {0x2400, 0x2426}, - {0x2440, 0x244A}, - {0x249C, 0x24E9}, - {0x2500, 0x25C0}, - {0x25C2, 0x25F7}, - {0x2600, 0x2617}, - {0x2619, 0x266E}, - {0x2670, 0x267D}, - {0x2680, 0x2691}, - {0x26A0, 0x26A1}, - {0x2701, 0x2704}, - {0x2706, 0x2709}, - {0x270C, 0x2727}, - {0x2729, 0x274B}, - {0x274D, 0x0000}, - {0x274F, 0x2752}, - {0x2756, 0x0000}, - {0x2758, 0x275E}, - {0x2761, 0x2767}, - {0x2794, 0x0000}, - {0x2798, 0x27AF}, - {0x27B1, 0x27BE}, - {0x2800, 0x28FF}, - {0x2B00, 0x2B0D}, - {0x2E80, 0x2E99}, - {0x2E9B, 0x2EF3}, - {0x2F00, 0x2FD5}, - {0x2FF0, 0x2FFB}, - {0x3004, 0x0000}, - {0x3012, 0x3013}, - {0x3020, 0x0000}, - {0x3036, 0x3037}, - {0x303E, 0x303F}, - {0x3190, 0x3191}, - {0x3196, 0x319F}, - {0x3200, 0x321E}, - {0x322A, 0x3243}, - {0x3250, 0x0000}, - {0x3260, 0x327D}, - {0x327F, 0x0000}, - {0x328A, 0x32FE}, - {0x3300, 0x33FF}, - {0x4DC0, 0x4DFF}, - {0xA490, 0xA4C6}, - {0xFDFD, 0x0000}, - {0xFFE4, 0x0000}, - {0xFFE8, 0x0000}, - {0xFFED, 0xFFEE}, - {0xFFFC, 0xFFFD} -}; - -CATEGORY_CHAR_RANGE CcRanges[] = -{ - {0x0001, 0x001F}, - {0x007F, 0x009F} -}; - -CATEGORY_CHAR_RANGE CfRanges[] = -{ - {0x00AD, 0x0000}, - {0x0600, 0x0603}, - {0x06DD, 0x0000}, - {0x070F, 0x0000}, - {0x17B4, 0x17B5}, - {0x200C, 0x200F}, - {0x202A, 0x202E}, - {0x2060, 0x2063}, - {0x206A, 0x206F}, - {0xFEFF, 0x0000}, - {0xFFF9, 0xFFFB} -}; - -CATEGORY_CHAR_RANGE CoRanges[] = -{ - {0xE000, 0x0000}, - {0xF8FF, 0x0000} -}; - -CATEGORY_CHAR_RANGE * CnRanges = NULL; - -typedef struct CATEGORY_CHARS -{ - FLMUINT uiNumArrays; - FLMUINT * puiRangeArraySizes; - CATEGORY_CHAR_RANGE ** ppRangeArrays; -} CATEGORY_CHARS; - -#define LuRangeSize (sizeof( LuRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define LlRangeSize (sizeof( LlRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define LtRangeSize (sizeof( LtRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define LmRangeSize (sizeof( LmRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define LoRangeSize (sizeof( LoRanges) / sizeof( CATEGORY_CHAR_RANGE)) - -FLMUINT LCategoryRangeSizes [] = - {LuRangeSize, LlRangeSize, LtRangeSize, LmRangeSize, LoRangeSize}; - -CATEGORY_CHAR_RANGE * LCategoryRanges [] = - {LuRanges, LlRanges, LtRanges, LmRanges, LoRanges}; - -CATEGORY_CHARS LCategory = { 5, &LCategoryRangeSizes [0], &LCategoryRanges [0]}; -CATEGORY_CHARS LuCategory = { 1, &LCategoryRangeSizes [0], &LCategoryRanges [0]}; -CATEGORY_CHARS LlCategory = { 1, &LCategoryRangeSizes [1], &LCategoryRanges [1]}; -CATEGORY_CHARS LtCategory = { 1, &LCategoryRangeSizes [2], &LCategoryRanges [2]}; -CATEGORY_CHARS LmCategory = { 1, &LCategoryRangeSizes [3], &LCategoryRanges [3]}; -CATEGORY_CHARS LoCategory = { 1, &LCategoryRangeSizes [4], &LCategoryRanges [4]}; - -#define MnRangeSize (sizeof( MnRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define McRangeSize (sizeof( McRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define MeRangeSize (sizeof( MeRanges) / sizeof( CATEGORY_CHAR_RANGE)) - -FLMUINT MCategoryRangeSizes [] = {MnRangeSize, McRangeSize, MeRangeSize}; - -CATEGORY_CHAR_RANGE * MCategoryRanges[] = {MnRanges, McRanges, MeRanges}; - -CATEGORY_CHARS MCategory = { 3, &MCategoryRangeSizes [0], &MCategoryRanges [0]}; -CATEGORY_CHARS MnCategory = { 1, &MCategoryRangeSizes [0], &MCategoryRanges [0]}; -CATEGORY_CHARS McCategory = { 1, &MCategoryRangeSizes [1], &MCategoryRanges [1]}; -CATEGORY_CHARS MeCategory = { 1, &MCategoryRangeSizes [2], &MCategoryRanges [2]}; - -#define DigitRangeSize (sizeof( DigitRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define Nd2RangeSize (sizeof( Nd2Ranges) / sizeof( CATEGORY_CHAR_RANGE)) -#define NlRangeSize (sizeof( NlRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define NoRangeSize (sizeof( NoRanges) / sizeof( CATEGORY_CHAR_RANGE)) - -FLMUINT NCategoryRangeSizes [] = - {DigitRangeSize, Nd2RangeSize, NlRangeSize, NoRangeSize}; - -CATEGORY_CHAR_RANGE * NCategoryRanges[] = - {DigitRanges, Nd2Ranges, NlRanges, NoRanges}; - -CATEGORY_CHARS NCategory = { 4, &NCategoryRangeSizes [0], &NCategoryRanges [0]}; -CATEGORY_CHARS DigitCategory = { 1, &NCategoryRangeSizes [0], &NCategoryRanges [0]}; -CATEGORY_CHARS NdCategory = { 2, &NCategoryRangeSizes [0], &NCategoryRanges [0]}; -CATEGORY_CHARS Nd2Category = { 1, &NCategoryRangeSizes [1], &NCategoryRanges [1]}; -CATEGORY_CHARS NlCategory = { 1, &NCategoryRangeSizes [2], &NCategoryRanges [2]}; -CATEGORY_CHARS NoCategory = { 1, &NCategoryRangeSizes [3], &NCategoryRanges [3]}; - -#define PcRangeSize (sizeof( PcRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define PdRangeSize (sizeof( PdRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define PsRangeSize (sizeof( PsRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define PeRangeSize (sizeof( PeRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define PiRangeSize (sizeof( PiRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define PfRangeSize (sizeof( PfRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define PoRangeSize (sizeof( PoRanges) / sizeof( CATEGORY_CHAR_RANGE)) - -FLMUINT PCategoryRangeSizes [] = - {PcRangeSize, PdRangeSize, PsRangeSize, PeRangeSize, - PiRangeSize, PfRangeSize, PoRangeSize}; - -CATEGORY_CHAR_RANGE * PCategoryRanges[] = - {PcRanges, PdRanges, PsRanges, PeRanges, PiRanges, PfRanges, PoRanges}; - -CATEGORY_CHARS PCategory = { 7, &PCategoryRangeSizes [0], &PCategoryRanges [0]}; -CATEGORY_CHARS PcCategory = { 1, &PCategoryRangeSizes [0], &PCategoryRanges [0]}; -CATEGORY_CHARS PdCategory = { 1, &PCategoryRangeSizes [1], &PCategoryRanges [1]}; -CATEGORY_CHARS PsCategory = { 1, &PCategoryRangeSizes [2], &PCategoryRanges [2]}; -CATEGORY_CHARS PeCategory = { 1, &PCategoryRangeSizes [3], &PCategoryRanges [3]}; -CATEGORY_CHARS PiCategory = { 1, &PCategoryRangeSizes [4], &PCategoryRanges [4]}; -CATEGORY_CHARS PfCategory = { 1, &PCategoryRangeSizes [5], &PCategoryRanges [5]}; -CATEGORY_CHARS PoCategory = { 1, &PCategoryRangeSizes [6], &PCategoryRanges [6]}; - -#define ZsRangeSize (sizeof( ZsRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define ZlRangeSize (sizeof( ZlRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define ZpRangeSize (sizeof( ZpRanges) / sizeof( CATEGORY_CHAR_RANGE)) - -FLMUINT ZCategoryRangeSizes [] = {ZsRangeSize, ZlRangeSize, ZpRangeSize}; - -CATEGORY_CHAR_RANGE * ZCategoryRanges[] = {ZsRanges, ZlRanges, ZpRanges}; - -CATEGORY_CHARS ZCategory = { 3, &ZCategoryRangeSizes [0], &ZCategoryRanges [0]}; -CATEGORY_CHARS ZsCategory = { 1, &ZCategoryRangeSizes [0], &ZCategoryRanges [0]}; -CATEGORY_CHARS ZlCategory = { 1, &ZCategoryRangeSizes [1], &ZCategoryRanges [1]}; -CATEGORY_CHARS ZpCategory = { 1, &ZCategoryRangeSizes [2], &ZCategoryRanges [2]}; - -#define SmRangeSize (sizeof( SmRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define ScRangeSize (sizeof( ScRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define SkRangeSize (sizeof( SkRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define SoRangeSize (sizeof( SoRanges) / sizeof( CATEGORY_CHAR_RANGE)) - -FLMUINT SCategoryRangeSizes [] = {SmRangeSize, ScRangeSize, SkRangeSize, SoRangeSize}; - -CATEGORY_CHAR_RANGE * SCategoryRanges[] = {SmRanges, ScRanges, SkRanges, SoRanges}; - -CATEGORY_CHARS SCategory = { 4, &SCategoryRangeSizes [0], &SCategoryRanges [0]}; -CATEGORY_CHARS SmCategory = { 1, &SCategoryRangeSizes [0], &SCategoryRanges [0]}; -CATEGORY_CHARS ScCategory = { 1, &SCategoryRangeSizes [1], &SCategoryRanges [1]}; -CATEGORY_CHARS SkCategory = { 1, &SCategoryRangeSizes [2], &SCategoryRanges [2]}; -CATEGORY_CHARS SoCategory = { 1, &SCategoryRangeSizes [3], &SCategoryRanges [3]}; - -#define CcRangeSize (sizeof( CcRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define CfRangeSize (sizeof( CfRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define CoRangeSize (sizeof( CoRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define CnRangeSize 0 - -FLMUINT CCategoryRangeSizes [] = {CcRangeSize, CfRangeSize, CoRangeSize, CnRangeSize}; - -CATEGORY_CHAR_RANGE * CCategoryRanges[] = {CcRanges, CfRanges, CoRanges, CnRanges}; - -CATEGORY_CHARS CCategory = { 4, &CCategoryRangeSizes [0], &CCategoryRanges [0]}; -CATEGORY_CHARS CcCategory = { 1, &CCategoryRangeSizes [0], &CCategoryRanges [0]}; -CATEGORY_CHARS CfCategory = { 1, &CCategoryRangeSizes [1], &CCategoryRanges [1]}; -CATEGORY_CHARS CoCategory = { 1, &CCategoryRangeSizes [2], &CCategoryRanges [2]}; -CATEGORY_CHARS CnCategory = { 1, &CCategoryRangeSizes [3], &CCategoryRanges [3]}; - -CATEGORY_CHAR_RANGE LetterRanges [] = -{ - {0x0041, 0x005A}, - {0x0061, 0x007A}, - {0x00C0, 0x00D6}, - {0x00D8, 0x00F6}, - {0x00F8, 0x00FF}, - {0x0100, 0x0131}, - {0x0134, 0x013E}, - {0x0141, 0x0148}, - {0x014A, 0x017E}, - {0x0180, 0x01C3}, - {0x01CD, 0x01F0}, - {0x01F4, 0x01F5}, - {0x01FA, 0x0217}, - {0x0250, 0x02A8}, - {0x02BB, 0x02C1}, - {0x0386, 0x0000}, - {0x0388, 0x038A}, - {0x038C, 0x0000}, - {0x038E, 0x03A1}, - {0x03A3, 0x03CE}, - {0x03D0, 0x03D6}, - {0x03DA, 0x0000}, - {0x03DC, 0x0000}, - {0x03DE, 0x0000}, - {0x03E0, 0x0000}, - {0x03E2, 0x03F3}, - {0x0401, 0x040C}, - {0x040E, 0x044F}, - {0x0451, 0x045C}, - {0x045E, 0x0481}, - {0x0490, 0x04C4}, - {0x04C7, 0x04C8}, - {0x04CB, 0x04CC}, - {0x04D0, 0x04EB}, - {0x04EE, 0x04F5}, - {0x04F8, 0x04F9}, - {0x0531, 0x0556}, - {0x0559, 0x0000}, - {0x0561, 0x0586}, - {0x05D0, 0x05EA}, - {0x05F0, 0x05F2}, - {0x0621, 0x063A}, - {0x0641, 0x064A}, - {0x0671, 0x06B7}, - {0x06BA, 0x06BE}, - {0x06C0, 0x06CE}, - {0x06D0, 0x06D3}, - {0x06D5, 0x0000}, - {0x06E5, 0x06E6}, - {0x0905, 0x0939}, - {0x093D, 0x0000}, - {0x0958, 0x0961}, - {0x0985, 0x098C}, - {0x098F, 0x0990}, - {0x0993, 0x09A8}, - {0x09AA, 0x09B0}, - {0x09B2, 0x0000}, - {0x09B6, 0x09B9}, - {0x09DC, 0x09DD}, - {0x09DF, 0x09E1}, - {0x09F0, 0x09F1}, - {0x0A05, 0x0A0A}, - {0x0A0F, 0x0A10}, - {0x0A13, 0x0A28}, - {0x0A2A, 0x0A30}, - {0x0A32, 0x0A33}, - {0x0A35, 0x0A36}, - {0x0A38, 0x0A39}, - {0x0A59, 0x0A5C}, - {0x0A5E, 0x0000}, - {0x0A72, 0x0A74}, - {0x0A85, 0x0A8B}, - {0x0A8D, 0x0000}, - {0x0A8F, 0x0A91}, - {0x0A93, 0x0AA8}, - {0x0AAA, 0x0AB0}, - {0x0AB2, 0x0AB3}, - {0x0AB5, 0x0AB9}, - {0x0ABD, 0x0000}, - {0x0AE0, 0x0000}, - {0x0B05, 0x0B0C}, - {0x0B0F, 0x0B10}, - {0x0B13, 0x0B28}, - {0x0B2A, 0x0B30}, - {0x0B32, 0x0B33}, - {0x0B36, 0x0B39}, - {0x0B3D, 0x0000}, - {0x0B5C, 0x0B5D}, - {0x0B5F, 0x0B61}, - {0x0B85, 0x0B8A}, - {0x0B8E, 0x0B90}, - {0x0B92, 0x0B95}, - {0x0B99, 0x0B9A}, - {0x0B9C, 0x0000}, - {0x0B9E, 0x0B9F}, - {0x0BA3, 0x0BA4}, - {0x0BA8, 0x0BAA}, - {0x0BAE, 0x0BB5}, - {0x0BB7, 0x0BB9}, - {0x0C05, 0x0C0C}, - {0x0C0E, 0x0C10}, - {0x0C12, 0x0C28}, - {0x0C2A, 0x0C33}, - {0x0C35, 0x0C39}, - {0x0C60, 0x0C61}, - {0x0C85, 0x0C8C}, - {0x0C8E, 0x0C90}, - {0x0C92, 0x0CA8}, - {0x0CAA, 0x0CB3}, - {0x0CB5, 0x0CB9}, - {0x0CDE, 0x0000}, - {0x0CE0, 0x0CE1}, - {0x0D05, 0x0D0C}, - {0x0D0E, 0x0D10}, - {0x0D12, 0x0D28}, - {0x0D2A, 0x0D39}, - {0x0D60, 0x0D61}, - {0x0E01, 0x0E2E}, - {0x0E30, 0x0000}, - {0x0E32, 0x0E33}, - {0x0E40, 0x0E45}, - {0x0E81, 0x0E82}, - {0x0E84, 0x0000}, - {0x0E87, 0x0E88}, - {0x0E8A, 0x0000}, - {0x0E8D, 0x0000}, - {0x0E94, 0x0E97}, - {0x0E99, 0x0E9F}, - {0x0EA1, 0x0EA3}, - {0x0EA5, 0x0000}, - {0x0EA7, 0x0000}, - {0x0EAA, 0x0EAB}, - {0x0EAD, 0x0EAE}, - {0x0EB0, 0x0000}, - {0x0EB2, 0x0EB3}, - {0x0EBD, 0x0000}, - {0x0EC0, 0x0EC4}, - {0x0F40, 0x0F47}, - {0x0F49, 0x0F69}, - {0x10A0, 0x10C5}, - {0x10D0, 0x10F6}, - {0x1100, 0x0000}, - {0x1102, 0x1103}, - {0x1105, 0x1107}, - {0x1109, 0x0000}, - {0x110B, 0x110C}, - {0x110E, 0x1112}, - {0x113C, 0x0000}, - {0x113E, 0x0000}, - {0x1140, 0x0000}, - {0x114C, 0x0000}, - {0x114E, 0x0000}, - {0x1150, 0x0000}, - {0x1154, 0x1155}, - {0x1159, 0x0000}, - {0x115F, 0x1161}, - {0x1163, 0x0000}, - {0x1165, 0x0000}, - {0x1167, 0x0000}, - {0x1169, 0x0000}, - {0x116D, 0x116E}, - {0x1172, 0x1173}, - {0x1175, 0x0000}, - {0x119E, 0x0000}, - {0x11A8, 0x0000}, - {0x11AB, 0x0000}, - {0x11AE, 0x11AF}, - {0x11B7, 0x11B8}, - {0x11BA, 0x0000}, - {0x11BC, 0x11C2}, - {0x11EB, 0x0000}, - {0x11F0, 0x0000}, - {0x11F9, 0x0000}, - {0x1E00, 0x1E9B}, - {0x1EA0, 0x1EF9}, - {0x1F00, 0x1F15}, - {0x1F18, 0x1F1D}, - {0x1F20, 0x1F45}, - {0x1F48, 0x1F4D}, - {0x1F50, 0x1F57}, - {0x1F59, 0x0000}, - {0x1F5B, 0x0000}, - {0x1F5D, 0x0000}, - {0x1F5F, 0x1F7D}, - {0x1F80, 0x1FB4}, - {0x1FB6, 0x1FBC}, - {0x1FBE, 0x0000}, - {0x1FC2, 0x1FC4}, - {0x1FC6, 0x1FCC}, - {0x1FD0, 0x1FD3}, - {0x1FD6, 0x1FDB}, - {0x1FE0, 0x1FEC}, - {0x1FF2, 0x1FF4}, - {0x1FF6, 0x1FFC}, - {0x2126, 0x0000}, - {0x212A, 0x212B}, - {0x212E, 0x0000}, - {0x2180, 0x2182}, - {0x3007, 0x0000}, - {0x3021, 0x3029}, - {0x3041, 0x3094}, - {0x30A1, 0x30FA}, - {0x3105, 0x312C}, - {0x4E00, 0x9FA5}, - {0xAC00, 0xD7A3} -}; - -CATEGORY_CHAR_RANGE CombiningRanges [] = -{ - {0x0300, 0x0345}, - {0x0360, 0x0361}, - {0x0483, 0x0486}, - {0x0591, 0x05A1}, - {0x05A3, 0x05B9}, - {0x05BB, 0x05BD}, - {0x05BF, 0x0000}, - {0x05C1, 0x05C2}, - {0x05C4, 0x0000}, - {0x064B, 0x0652}, - {0x0670, 0x0000}, - {0x06D6, 0x06DC}, - {0x06DD, 0x06DF}, - {0x06E0, 0x06E4}, - {0x06E7, 0x06E8}, - {0x06EA, 0x06ED}, - {0x0901, 0x0903}, - {0x093C, 0x0000}, - {0x093E, 0x094C}, - {0x094D, 0x0000}, - {0x0951, 0x0954}, - {0x0962, 0x0963}, - {0x0981, 0x0983}, - {0x09BC, 0x0000}, - {0x09BE, 0x0000}, - {0x09BF, 0x0000}, - {0x09C0, 0x09C4}, - {0x09C7, 0x09C8}, - {0x09CB, 0x09CD}, - {0x09D7, 0x0000}, - {0x09E2, 0x09E3}, - {0x0A02, 0x0000}, - {0x0A3C, 0x0000}, - {0x0A3E, 0x0000}, - {0x0A3F, 0x0000}, - {0x0A40, 0x0A42}, - {0x0A47, 0x0A48}, - {0x0A4B, 0x0A4D}, - {0x0A70, 0x0A71}, - {0x0A81, 0x0A83}, - {0x0ABC, 0x0000}, - {0x0ABE, 0x0AC5}, - {0x0AC7, 0x0AC9}, - {0x0ACB, 0x0ACD}, - {0x0B01, 0x0B03}, - {0x0B3C, 0x0000}, - {0x0B3E, 0x0B43}, - {0x0B47, 0x0B48}, - {0x0B4B, 0x0B4D}, - {0x0B56, 0x0B57}, - {0x0B82, 0x0B83}, - {0x0BBE, 0x0BC2}, - {0x0BC6, 0x0BC8}, - {0x0BCA, 0x0BCD}, - {0x0BD7, 0x0000}, - {0x0C01, 0x0C03}, - {0x0C3E, 0x0C44}, - {0x0C46, 0x0C48}, - {0x0C4A, 0x0C4D}, - {0x0C55, 0x0C56}, - {0x0C82, 0x0C83}, - {0x0CBE, 0x0CC4}, - {0x0CC6, 0x0CC8}, - {0x0CCA, 0x0CCD}, - {0x0CD5, 0x0CD6}, - {0x0D02, 0x0D03}, - {0x0D3E, 0x0D43}, - {0x0D46, 0x0D48}, - {0x0D4A, 0x0D4D}, - {0x0D57, 0x0000}, - {0x0E31, 0x0000}, - {0x0E34, 0x0E3A}, - {0x0E47, 0x0E4E}, - {0x0EB1, 0x0000}, - {0x0EB4, 0x0EB9}, - {0x0EBB, 0x0EBC}, - {0x0EC8, 0x0ECD}, - {0x0F18, 0x0F19}, - {0x0F35, 0x0000}, - {0x0F37, 0x0000}, - {0x0F39, 0x0000}, - {0x0F3E, 0x0000}, - {0x0F3F, 0x0000}, - {0x0F71, 0x0F84}, - {0x0F86, 0x0F8B}, - {0x0F90, 0x0F95}, - {0x0F97, 0x0000}, - {0x0F99, 0x0FAD}, - {0x0FB1, 0x0FB7}, - {0x0FB9, 0x0000}, - {0x20D0, 0x20DC}, - {0x20E1, 0x0000}, - {0x302A, 0x302F}, - {0x3099, 0x0000}, - {0x309A, 0x0000} -}; - -CATEGORY_CHAR_RANGE ExtenderRanges [] = -{ - {0x00B7, 0x0000}, - {0x02D0, 0x0000}, - {0x02D1, 0x0000}, - {0x0387, 0x0000}, - {0x0640, 0x0000}, - {0x0E46, 0x0000}, - {0x0EC6, 0x0000}, - {0x3005, 0x0000}, - {0x3031, 0x3035}, - {0x309D, 0x309E}, - {0x30FC, 0x30FE} -}; - -#define LetterRangeSize (sizeof( LetterRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define CombiningRangeSize (sizeof( CombiningRanges) / sizeof( CATEGORY_CHAR_RANGE)) -#define ExtenderRangeSize (sizeof( ExtenderRanges) / sizeof( CATEGORY_CHAR_RANGE)) - -FLMUINT NameCharCategoryRangeSizes [] = - {LetterRangeSize, CombiningRangeSize, ExtenderRangeSize, DigitRangeSize}; - -CATEGORY_CHAR_RANGE * NameCharCategoryRanges[] = - {LetterRanges, CombiningRanges, ExtenderRanges, DigitRanges}; - -CATEGORY_CHARS NameCharCategory = { 4, &NameCharCategoryRangeSizes [0], &NameCharCategoryRanges [0]}; -CATEGORY_CHARS LetterCategory = { 1, &NameCharCategoryRangeSizes [0], &NameCharCategoryRanges [0]}; -CATEGORY_CHARS CombiningCategory = { 1, &NameCharCategoryRangeSizes [1], &NameCharCategoryRanges [1]}; -CATEGORY_CHARS ExtenderCategory = { 1, &NameCharCategoryRangeSizes [2], &NameCharCategoryRanges [2]}; - -typedef struct REGEXP_LITERAL -{ - FLMUNICODE * puzLiteral; - FLMUINT uiNumChars; -} REGEXP_LITERAL; - -typedef struct CHAR_RANGE -{ - FLMBOOL bNegatedRange; - FLMUNICODE uzLowChar; - FLMUNICODE uzHighChar; - CHAR_RANGE * pNext; - CHAR_RANGE * pPrev; -} CHAR_RANGE; - -typedef struct CHAR_LIST -{ - FLMBOOL bNegatedChars; - FLMUNICODE * puzChars; - FLMUINT uiNumChars; - CHAR_LIST * pNext; - CHAR_LIST * pPrev; -} CHAR_LIST; - -typedef struct CHAR_CATEGORY -{ - FLMBOOL bNegatedCategory; - CATEGORY_CHARS * pCategoryChars; - CHAR_CATEGORY * pNext; - CHAR_CATEGORY * pPrev; -} CHAR_CATEGORY; - -typedef struct REG_EXP * REG_EXP_p; - -typedef struct CHAR_CLASS -{ - FLMBOOL bNegatedClass; - CHAR_LIST * pFirstCharList; - CHAR_LIST * pLastCharList; - CHAR_RANGE * pFirstCharRange; - CHAR_RANGE * pLastCharRange; - CHAR_CATEGORY * pFirstCharCategory; - CHAR_CATEGORY * pLastCharCategory; - CHAR_CLASS * pFirstCharClass; - CHAR_CLASS * pLastCharClass; - CHAR_CLASS * pSubtractionClass; - CHAR_CLASS * pNext; - CHAR_CLASS * pPrev; -} CHAR_CLASS; - -typedef struct REG_EXP_BRANCH -{ - REG_EXP_p pParentExpr; - REG_EXP_p pFirstExpr; - REG_EXP_p pLastExpr; - REG_EXP_BRANCH * pNextBranch; - REG_EXP_BRANCH * pPrevBranch; -} REG_EXP_BRANCH; - -typedef struct REG_EXP_ALTERNATIVE -{ - REG_EXP_BRANCH * pFirstBranch; - REG_EXP_BRANCH * pLastBranch; -} REG_EXP_ALTERNATIVE; - -typedef struct REG_EXP -{ - eExpType eType; - FLMUINT uiMinOccurs; - FLMUINT uiMaxOccurs; - FLMBOOL bUnlimited; - FLMBOOL bQuantified; - union - { - REGEXP_LITERAL literal; - CHAR_CLASS charClass; - REG_EXP_ALTERNATIVE alternative; - } exp; - REG_EXP_BRANCH * pBranch; - REG_EXP * pNext; - REG_EXP * pPrev; -} REG_EXP; - -/***************************************************************************** -Desc: The regular expression class. -*****************************************************************************/ -class F_RegExp : public XF_Base -{ -public: - - F_RegExp(); - - ~F_RegExp(); - - RCODE setExpression( - FLMUNICODE * puzRegExp); - - FLMBOOL testString( - IF_PosIStream * pIStream); - -private: - - RCODE createRegExp( - eExpType eType, - REG_EXP ** ppExpr); - - RCODE addLiteralChar( - FLMUNICODE uzChar); - - RCODE addLiteralExpr( - FLMUNICODE * puzLiteral, - FLMUINT uiNumChars, - REG_EXP ** ppExpr); - - RCODE saveLiteral( void); - - RCODE createCharCategory( - CATEGORY_CHARS * pCategoryChars, - FLMBOOL bNegatedCategory, - CHAR_CLASS * pCharClass); - - RCODE createCharRange( - FLMUNICODE uzLowChar, - FLMUNICODE uzHighChar, - FLMBOOL bNegatedRange, - CHAR_CLASS * pCharClass); - - RCODE createCharList( - const char * pszChars, - FLMUNICODE * puzChars, - FLMUINT uiNumChars, - FLMBOOL bNegatedChars, - CHAR_CLASS * pCharClass); - - RCODE createCharClass( - FLMBOOL bNegatedClass, - CHAR_CLASS * pCharClass, - CHAR_CLASS ** ppNewCharClass); - - RCODE parseEscape( - FLMUNICODE ** ppuzRegExp, - CHAR_CLASS * pCharClass, - FLMUNICODE * puzChar); - - RCODE parseCharClass( - FLMUNICODE ** ppuzRegExp, - CHAR_CLASS * pCharClass); - - RCODE parseQuantifier( - FLMUNICODE ** ppuzRegExp); - - RCODE startAlternative( void); - - RCODE endAlternative( void); - - RCODE startNewBranch( void); - - F_Pool m_Pool; - REG_EXP_BRANCH m_topBranch; - REG_EXP_BRANCH * m_pCurrBranch; // Used only when parsing - FLMUNICODE m_uzLiteral [256]; - FLMUNICODE * m_puzLiteral; - FLMUINT m_uiMaxLiteralChars; - FLMUINT m_uiNumLiteralChars; -}; - -// Local function prototypes - -FSTATIC FLMBOOL isCategory( - CATEGORY_CHARS ** ppCategoryChars, - FLMUNICODE ** ppuzRegExp); - -FSTATIC FLMBOOL isBlock( - FLMUNICODE * puzLowChar, - FLMUNICODE * puzHighChar, - FLMUNICODE ** ppuzRegExp); - -/***************************************************************************** -Desc: Constructor -*****************************************************************************/ -F_RegExp::F_RegExp() -{ - m_Pool.poolInit( 256); - m_topBranch.pParentExpr = NULL; - m_topBranch.pNextBranch = NULL; - m_topBranch.pPrevBranch = NULL; - m_topBranch.pFirstExpr = NULL; - m_topBranch.pLastExpr = NULL; - m_pCurrBranch = &m_topBranch; - m_puzLiteral = &m_uzLiteral [0]; - m_uiMaxLiteralChars = sizeof( m_uzLiteral) / sizeof( FLMUNICODE); - m_uiNumLiteralChars = 0; -} - -/***************************************************************************** -Desc: Destructor -*****************************************************************************/ -F_RegExp::~F_RegExp() -{ - m_Pool.poolFree(); - if (m_puzLiteral != &m_uzLiteral [0]) - { - f_free( &m_puzLiteral); - } -} - -/***************************************************************************** -Desc: Skip whitespace in a string. -*****************************************************************************/ -FINLINE FLMBOOL isWhitespace( - FLMUNICODE uzChar - ) -{ - return( (uzChar == ' ' || uzChar == '\t' || - uzChar == '\n' || uzChar == '\r') ? TRUE : FALSE); -} - -/***************************************************************************** -Desc: Skip whitespace in a string. -*****************************************************************************/ -FINLINE FLMUNICODE * skipWhitespace( - FLMUNICODE * puzRegExp - ) -{ - while (isWhitespace( *puzRegExp)) - { - puzRegExp++; - } - return( puzRegExp); -} - -/***************************************************************************** -Desc: Create a new regular expression. -*****************************************************************************/ -RCODE F_RegExp::createRegExp( - eExpType eType, - REG_EXP ** ppExpr - ) -{ - RCODE rc = NE_XFLM_OK; - REG_EXP * pExpr; - - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( REG_EXP), - (void **)&pExpr))) - { - goto Exit; - } - *ppExpr = pExpr; - pExpr->eType = eType; - if ((pExpr->pPrev = m_pCurrBranch->pLastExpr) != NULL) - { - m_pCurrBranch->pLastExpr->pNext = pExpr; - } - else - { - m_pCurrBranch->pFirstExpr = pExpr; - } - m_pCurrBranch->pLastExpr = pExpr; - pExpr->pBranch = m_pCurrBranch; - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Add a literal character to our current literal buffer. -*****************************************************************************/ -RCODE F_RegExp::addLiteralChar( - FLMUNICODE uzChar - ) -{ - RCODE rc = NE_XFLM_OK; - - // See if we need to allocate a new buffer. - - if (m_uiNumLiteralChars == m_uiMaxLiteralChars) - { - FLMUNICODE * puzTmp; - FLMUINT uiNewMax = m_uiMaxLiteralChars + 128; - - if (RC_BAD( rc = f_alloc( sizeof( FLMUNICODE) * uiNewMax, - &puzTmp))) - { - goto Exit; - } - if (m_uiNumLiteralChars) - { - f_memcpy( puzTmp, m_puzLiteral, - sizeof( FLMUNICODE) * m_uiNumLiteralChars); - } - if (m_puzLiteral != &m_uzLiteral [0]) - { - f_free( &m_puzLiteral); - } - m_puzLiteral = puzTmp; - m_uiMaxLiteralChars = uiNewMax; - } - m_puzLiteral [m_uiNumLiteralChars] = uzChar; - m_uiNumLiteralChars++; - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Add a literal expression. -*****************************************************************************/ -RCODE F_RegExp::addLiteralExpr( - FLMUNICODE * puzLiteral, - FLMUINT uiNumChars, - REG_EXP ** ppExpr - ) -{ - RCODE rc = NE_XFLM_OK; - REG_EXP * pTmpExpr = 0; - - if (RC_BAD( rc = createRegExp( EXP_LITERAL, &pTmpExpr))) - { - goto Exit; - } - - if (ppExpr) - { - *ppExpr = pTmpExpr; - } - if (RC_BAD( rc = m_Pool.poolAlloc( uiNumChars * sizeof( FLMUNICODE), - (void **)&pTmpExpr->exp.literal.puzLiteral))) - { - goto Exit; - } - f_memcpy( pTmpExpr->exp.literal.puzLiteral, puzLiteral, - uiNumChars * sizeof( FLMUNICODE)); - pTmpExpr->exp.literal.uiNumChars = uiNumChars; - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Save out our current literal into our expression tree. -*****************************************************************************/ -RCODE F_RegExp::saveLiteral( void) -{ - RCODE rc = NE_XFLM_OK; - - if (m_uiNumLiteralChars) - { - if (RC_BAD( rc = addLiteralExpr( m_puzLiteral, - m_uiNumLiteralChars, NULL))) - { - goto Exit; - } - - // Zero out the literal and start over. - - m_uiNumLiteralChars = 0; - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: See if an escape sequence is a category -*****************************************************************************/ -FSTATIC FLMBOOL isCategory( - CATEGORY_CHARS ** ppCategoryChars, - FLMUNICODE ** ppuzRegExp - ) -{ - FLMBOOL bIsCategory = FALSE; - FLMUNICODE * puzRegExp = *ppuzRegExp; - - // Skip past the 'p' or 'P' - - puzRegExp++; - - // Next character better be a '{' - - if (*puzRegExp != '{') - { - goto Exit; - } - puzRegExp++; - - switch (*puzRegExp) - { - case 'L': - puzRegExp++; - switch (*puzRegExp) - { - case '}': *ppCategoryChars = &LCategory; break; - case 'u': *ppCategoryChars = &LuCategory; puzRegExp++; break; - case 'l': *ppCategoryChars = &LlCategory; puzRegExp++; break; - case 't': *ppCategoryChars = &LtCategory; puzRegExp++; break; - case 'm': *ppCategoryChars = &LmCategory; puzRegExp++; break; - case 'o': *ppCategoryChars = &LoCategory; puzRegExp++; break; - default: goto Exit; - } - break; - - case 'M': - puzRegExp++; - switch (*puzRegExp) - { - case '}': *ppCategoryChars = &MCategory; break; - case 'n': *ppCategoryChars = &MnCategory; puzRegExp++; break; - case 'c': *ppCategoryChars = &McCategory; puzRegExp++; break; - case 'e': *ppCategoryChars = &MeCategory; puzRegExp++; break; - default: goto Exit; - } - break; - - case 'N': - puzRegExp++; - switch (*puzRegExp) - { - case '}': *ppCategoryChars = &NCategory; break; - case 'd': *ppCategoryChars = &NdCategory; puzRegExp++; break; - case 'l': *ppCategoryChars = &NlCategory; puzRegExp++; break; - case 'o': *ppCategoryChars = &NoCategory; puzRegExp++; break; - default: goto Exit; - } - break; - - case 'P': - puzRegExp++; - switch (*puzRegExp) - { - case '}': *ppCategoryChars = &PCategory; break; - case 'c': *ppCategoryChars = &PcCategory; puzRegExp++; break; - case 'd': *ppCategoryChars = &PdCategory; puzRegExp++; break; - case 's': *ppCategoryChars = &PsCategory; puzRegExp++; break; - case 'e': *ppCategoryChars = &PeCategory; puzRegExp++; break; - case 'i': *ppCategoryChars = &PiCategory; puzRegExp++; break; - case 'f': *ppCategoryChars = &PfCategory; puzRegExp++; break; - case 'o': *ppCategoryChars = &PoCategory; puzRegExp++; break; - default: goto Exit; - } - break; - - case 'Z': - puzRegExp++; - switch (*puzRegExp) - { - case '}': *ppCategoryChars = &ZCategory; break; - case 's': *ppCategoryChars = &ZsCategory; puzRegExp++; break; - case 'l': *ppCategoryChars = &ZlCategory; puzRegExp++; break; - case 'p': *ppCategoryChars = &ZpCategory; puzRegExp++; break; - default: goto Exit; - } - break; - - case 'S': - puzRegExp++; - switch (*puzRegExp) - { - case '}': *ppCategoryChars = &SCategory; break; - case 'm': *ppCategoryChars = &SmCategory; puzRegExp++; break; - case 'c': *ppCategoryChars = &ScCategory; puzRegExp++; break; - case 'k': *ppCategoryChars = &SkCategory; puzRegExp++; break; - case 'o': *ppCategoryChars = &SoCategory; puzRegExp++; break; - default: goto Exit; - } - break; - - case 'C': - puzRegExp++; - switch (*puzRegExp) - { - case '}': *ppCategoryChars = &CCategory; break; - case 'c': *ppCategoryChars = &CcCategory; puzRegExp++; break; - case 'f': *ppCategoryChars = &CfCategory; puzRegExp++; break; - case 'o': *ppCategoryChars = &CoCategory; puzRegExp++; break; - case 'n': *ppCategoryChars = &CnCategory; puzRegExp++; break; - default: goto Exit; - } - break; - - default: - goto Exit; - } - - // The last letter better be a '}' - - if (*puzRegExp != '}') - { - goto Exit; - } - puzRegExp++; - bIsCategory = TRUE; - -Exit: - - // Only move the pointer forward if it is, in fact, a category - - if (bIsCategory) - { - *ppuzRegExp = puzRegExp; - } - return( bIsCategory); -} - -/***************************************************************************** -Desc: See if an escape sequence is a block range of characters -*****************************************************************************/ -FSTATIC FLMBOOL isBlock( - FLMUNICODE * puzLowChar, - FLMUNICODE * puzHighChar, - FLMUNICODE ** ppuzRegExp - ) -{ - FLMBOOL bIsBlock = FALSE; - FLMUINT uiLoop; - FLMUNICODE * puzRegExp = *ppuzRegExp; - FLMUNICODE * puzBlockName; - FLMUNICODE * puzSaveBlockName; - const char * pszBlockName; - - // Skip past the 'p' or 'P' - - puzRegExp++; - - // Next three characters better be '{Is' - - if (*puzRegExp != '{') - { - goto Exit; - } - puzRegExp++; - - if (*puzRegExp != 'I') - { - goto Exit; - } - puzRegExp++; - - if (*puzRegExp != 's') - { - goto Exit; - } - puzRegExp++; - - puzSaveBlockName = puzRegExp; - uiLoop = 0; - for (uiLoop = 0;;uiLoop++) - { - if ((pszBlockName = FlmBlockCharRanges [uiLoop].pszBlockName) == NULL) - { - goto Exit; - } - - // Compare the name - - puzBlockName = puzSaveBlockName; - while (*pszBlockName && *puzBlockName != '}') - { - if ((FLMUNICODE)(*pszBlockName) != *puzBlockName) - { - break; - } - pszBlockName++; - puzBlockName++; - } - - if (*pszBlockName == 0 && *puzBlockName == '}') - { - puzRegExp = puzBlockName + 1; - bIsBlock = TRUE; - *puzLowChar = FlmBlockCharRanges [uiLoop].uzLowChar; - *puzHighChar = FlmBlockCharRanges [uiLoop].uzLowChar; - bIsBlock = TRUE; - break; - } - } - -Exit: - - // Only move the pointer forward if it is, in fact, a category - - if (bIsBlock) - { - *ppuzRegExp = puzRegExp; - } - return( bIsBlock); -} - -/***************************************************************************** -Desc: Create a character category. -*****************************************************************************/ -RCODE F_RegExp::createCharCategory( - CATEGORY_CHARS * pCategoryChars, - FLMBOOL bNegatedCategory, - CHAR_CLASS * pCharClass - ) -{ - RCODE rc = NE_XFLM_OK; - CHAR_CATEGORY * pCharCategory; - - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( CHAR_CATEGORY), - (void **)&pCharCategory))) - { - goto Exit; - } - pCharCategory->bNegatedCategory = bNegatedCategory; - pCharCategory->pCategoryChars = pCategoryChars; - - // Link at end of list of character categories - - if ((pCharCategory->pPrev = pCharClass->pLastCharCategory) != NULL) - { - pCharCategory->pPrev->pNext = pCharCategory; - } - else - { - pCharClass->pFirstCharCategory = pCharCategory; - } - pCharClass->pLastCharCategory = pCharCategory; - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Create a character range. -*****************************************************************************/ -RCODE F_RegExp::createCharRange( - FLMUNICODE uzLowChar, - FLMUNICODE uzHighChar, - FLMBOOL bNegatedRange, - CHAR_CLASS * pCharClass - ) -{ - RCODE rc = NE_XFLM_OK; - CHAR_RANGE * pCharRange; - - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( CHAR_RANGE), - (void **)&pCharRange))) - { - goto Exit; - } - pCharRange->bNegatedRange = bNegatedRange; - pCharRange->uzLowChar = uzLowChar; - pCharRange->uzHighChar = uzHighChar; - - // Link at end of list of character ranges - - if ((pCharRange->pPrev = pCharClass->pLastCharRange) != NULL) - { - pCharRange->pPrev->pNext = pCharRange; - } - else - { - pCharClass->pFirstCharRange = pCharRange; - } - pCharClass->pLastCharRange = pCharRange; - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Create a character list. -*****************************************************************************/ -RCODE F_RegExp::createCharList( - const char * pszChars, - FLMUNICODE * puzChars, - FLMUINT uiNumChars, - FLMBOOL bNegatedChars, - CHAR_CLASS * pCharClass) -{ - RCODE rc = NE_XFLM_OK; - CHAR_LIST * pCharList; - - // Allocate the CHAR_LIST structure. - - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( CHAR_LIST), - (void **)&pCharList))) - { - goto Exit; - } - pCharList->bNegatedChars = bNegatedChars; - - // Allocate an array for the characters. - - if (RC_BAD( rc = m_Pool.poolAlloc( sizeof( FLMUNICODE) * uiNumChars, - (void **)&pCharList->puzChars))) - { - goto Exit; - } - pCharList->uiNumChars = uiNumChars; - - // Copy the characters from pszChars or puzChars into pCharList->puzChars - - if (pszChars) - { - flmAssert( !puzChars); - puzChars = pCharList->puzChars; - while (*pszChars) - { - *puzChars = (FLMUNICODE)(*pszChars); - puzChars++; - pszChars++; - } - } - else - { - f_memcpy( pCharList->puzChars, puzChars, - sizeof( FLMUNICODE) * uiNumChars); - } - - // Link at end of list of character lists - - if ((pCharList->pPrev = pCharClass->pLastCharList) != NULL) - { - pCharList->pPrev->pNext = pCharList; - } - else - { - pCharClass->pFirstCharList = pCharList; - } - pCharClass->pLastCharList = pCharList; - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Create a sub-character class -*****************************************************************************/ -RCODE F_RegExp::createCharClass( - FLMBOOL bNegatedClass, - CHAR_CLASS * pCharClass, - CHAR_CLASS ** ppNewCharClass - ) -{ - RCODE rc = NE_XFLM_OK; - CHAR_CLASS * pNewCharClass; - - // Allocate the CHAR_CLASS structure. - - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( CHAR_CLASS), - (void **)&pNewCharClass))) - { - goto Exit; - } - *ppNewCharClass = pNewCharClass; - pNewCharClass->bNegatedClass = bNegatedClass; - - // Link at end of list of character classes - - if ((pNewCharClass->pPrev = pCharClass->pLastCharClass) != NULL) - { - pNewCharClass->pPrev->pNext = pCharClass; - } - else - { - pNewCharClass->pFirstCharClass = pCharClass; - } - pCharClass->pLastCharClass = pNewCharClass; - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Parse an escape sequence. -*****************************************************************************/ -RCODE F_RegExp::parseEscape( - FLMUNICODE ** ppuzRegExp, - CHAR_CLASS * pCharClass, - FLMUNICODE * puzChar - ) -{ - RCODE rc = NE_XFLM_OK; - FLMUNICODE * puzRegExp = *ppuzRegExp; - CHAR_CLASS * pNewCharClass; - CATEGORY_CHARS * pCategoryChars; - FLMUNICODE uzLowChar; - FLMUNICODE uzHighChar; - FLMBOOL bNegated; - REG_EXP * pTmpExpr; - - *puzChar = 0; - - // Skip past the '\' - - puzRegExp++; - - switch (*puzRegExp) - { - case 'p': - case 'P': - bNegated = (*puzRegExp == 'P') ? TRUE : FALSE; - if (isCategory( &pCategoryChars, &puzRegExp)) - { - if (!pCharClass) - { - if (RC_BAD( rc = createRegExp( EXP_CHAR_CLASS, &pTmpExpr))) - { - goto Exit; - } - pCharClass = &pTmpExpr->exp.charClass; - } - if (RC_BAD( rc = createCharCategory( pCategoryChars, bNegated, - pCharClass))) - { - goto Exit; - } - } - else if (isBlock( &uzLowChar, &uzHighChar, &puzRegExp)) - { - if (!pCharClass) - { - if (RC_BAD( rc = createRegExp( EXP_CHAR_CLASS, &pTmpExpr))) - { - goto Exit; - } - pCharClass = &pTmpExpr->exp.charClass; - } - if (RC_BAD( rc = createCharRange( uzLowChar, uzHighChar, - bNegated, pCharClass))) - { - goto Exit; - } - } - else - { - - // Treat as a regular character. - - *puzChar = *puzRegExp; - puzRegExp++; - } - break; - - case 's': - case 'S': - bNegated = (*puzRegExp == 'S') ? TRUE : FALSE; - puzRegExp++; - if (!pCharClass) - { - if (RC_BAD( rc = createRegExp( EXP_CHAR_CLASS, &pTmpExpr))) - { - goto Exit; - } - pCharClass = &pTmpExpr->exp.charClass; - } - if (RC_BAD( rc = createCharList( " \t\n\r", NULL, 4, - bNegated, pCharClass))) - { - goto Exit; - } - break; - - case 'd': - case 'D': - - // The same as {Nd} category - - bNegated = (*puzRegExp == 'D') ? TRUE : FALSE; - puzRegExp++; - if (!pCharClass) - { - if (RC_BAD( rc = createRegExp( EXP_CHAR_CLASS, &pTmpExpr))) - { - goto Exit; - } - pCharClass = &pTmpExpr->exp.charClass; - } - if (RC_BAD( rc = createCharCategory( &NdCategory, - bNegated, pCharClass))) - { - goto Exit; - } - break; - - case 'w': - case 'W': - - // Create a sub-character class that excludes the - // categories {P} - punctuation, {Z} - separators, and {C} - others - // NOTE: bNegated should be set to TRUE for lowercase 'w', unlike - // others above where negated flag is TRUE for uppercase - // character. This is because we are trying to create a class - // that is everything EXCEPT the three character categories - // mentioned. In the case of 'W', it should include those - // three categories - just the opposite of 'w'. - - bNegated = (*puzRegExp == 'w') ? TRUE : FALSE; - puzRegExp++; - if (!pCharClass) - { - if (RC_BAD( rc = createRegExp( EXP_CHAR_CLASS, &pTmpExpr))) - { - goto Exit; - } - pCharClass = &pTmpExpr->exp.charClass; - } - if (RC_BAD( rc = createCharClass( bNegated, pCharClass, - &pNewCharClass))) - { - goto Exit; - } - if (RC_BAD( rc = createCharCategory( &PCategory, - FALSE, pNewCharClass))) - { - goto Exit; - } - if (RC_BAD( rc = createCharCategory( &ZCategory, - FALSE, pNewCharClass))) - { - goto Exit; - } - if (RC_BAD( rc = createCharCategory( &CCategory, - FALSE, pNewCharClass))) - { - goto Exit; - } - break; - - case 'c': - case 'C': - - // NameChar and '.', '_', '-', ':' - - bNegated = (*puzRegExp == 'C') ? TRUE : FALSE; - puzRegExp++; - if (!pCharClass) - { - if (RC_BAD( rc = createRegExp( EXP_CHAR_CLASS, &pTmpExpr))) - { - goto Exit; - } - pCharClass = &pTmpExpr->exp.charClass; - } - if (RC_BAD( rc = createCharClass( bNegated, pCharClass, &pNewCharClass))) - { - goto Exit; - } - if (RC_BAD( rc = createCharCategory( &NameCharCategory, FALSE, - pNewCharClass))) - { - goto Exit; - } - if (RC_BAD( rc = createCharList( "._-:", NULL, 4, FALSE, pNewCharClass))) - { - goto Exit; - } - break; - - case 'i': - case 'I': - - // Letter and '_', ':' - - bNegated = (*puzRegExp == 'I') ? TRUE : FALSE; - puzRegExp++; - if (!pCharClass) - { - if (RC_BAD( rc = createRegExp( EXP_CHAR_CLASS, &pTmpExpr))) - { - goto Exit; - } - pCharClass = &pTmpExpr->exp.charClass; - } - if (RC_BAD( rc = createCharClass( bNegated, pCharClass, &pNewCharClass))) - { - goto Exit; - } - if (RC_BAD( rc = createCharCategory( &LetterCategory, FALSE, - pNewCharClass))) - { - goto Exit; - } - if (RC_BAD( rc = createCharList( "_:", NULL, 2, FALSE, pNewCharClass))) - { - goto Exit; - } - break; - - case 'n': - *puzChar = 0xA; - puzRegExp++; - break; - - case 'r': - *puzChar = 0xD; - puzRegExp++; - break; - - case 't': - *puzChar = 0x9; - puzRegExp++; - break; - - default: - - *puzChar = *puzRegExp; - puzRegExp++; - break; - } - -Exit: - - *ppuzRegExp = puzRegExp; - return( rc); -} - -/***************************************************************************** -Desc: Parse a character class - [xxxxx]. -*****************************************************************************/ -RCODE F_RegExp::parseCharClass( - FLMUNICODE ** ppuzRegExp, - CHAR_CLASS * pCharClass - ) -{ - RCODE rc = NE_XFLM_OK; - FLMUNICODE * puzRegExp = *ppuzRegExp; - FLMBOOL bAtBeginning; - FLMBOOL bHaveDash; - FLMUNICODE uzChar; - - flmAssert( *puzRegExp == '['); - - // skip past the '[' - - puzRegExp++; - - // Save whatever literal expression may have built up. - - if (RC_BAD( rc = saveLiteral())) - { - goto Exit; - } - - bAtBeginning = TRUE; - bHaveDash = FALSE; - for (;;) - { - switch (*puzRegExp) - { - case 0: - rc = RC_SET( NE_XFLM_UNEXPECTED_END_OF_EXPR); - goto Exit; - - case '^': - - // This is only the negation character if it comes immediately - // after the opening '['. Otherwise, it is a regular character. - - if (bAtBeginning && !pCharClass->bNegatedClass) - { - pCharClass->bNegatedClass = TRUE; - puzRegExp++; - } - else - { - goto Save_Char; - } - break; - - case '-': - - // This is NOT a range operator if it comes immediately after - // the opening '[' or right before the closing ']'. In those - // two cases, it is a regular character. - - if (bAtBeginning || *(puzRegExp + 1) == ']') - { - goto Save_Char; - } - else if (!m_uiNumLiteralChars) - { - // The dash doesn't have a preceding character we can use - // as the beginning character of the range. - - rc = RC_SET( NE_XFLM_UNESCAPED_METACHAR); - goto Exit; - } - else - { - bHaveDash = TRUE; - puzRegExp++; - } - break; - - case '\\': - - if (RC_BAD( rc = parseEscape( &puzRegExp, pCharClass, &uzChar))) - { - goto Exit; - } - if (uzChar) - { - goto Save_Char; - } - bAtBeginning = FALSE; - - break; - - case ']': - - // If it comes right after the opening '[', or after the '^' when it - // is used as a negation (see above), it is a regular character. - // In both of those cases, bAtBeginning will still be TRUE. - // Otherwise, it is the end of the character class. - - if (bAtBeginning) - { - goto Save_Char; - } - goto End_Of_Expr; - - case '[': - - // If it comes right after a '-', it represents the beginning of - // a subtraction group. - - if (!bHaveDash) - { - goto Save_Char; - } - - // Won't be at the beginning in this case - - flmAssert( !bAtBeginning); - - // Had the dash character, toggle flag back to FALSE. - - bHaveDash = FALSE; - - // Before calling self recursively, need to clear out - // any characters we have gathered up so far. - - if (m_uiNumLiteralChars) - { - if (RC_BAD( rc = createCharList( NULL, m_puzLiteral, - m_uiNumLiteralChars, FALSE, - pCharClass))) - { - goto Exit; - } - m_uiNumLiteralChars = 0; - } - - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( CHAR_CLASS), - (void **)&pCharClass->pSubtractionClass))) - { - goto Exit; - } - if (RC_BAD( rc = parseCharClass( &puzRegExp, - pCharClass->pSubtractionClass))) - { - goto Exit; - } - - // Next character must be a ']' to end this character class - - if (*puzRegExp == ']') - { - goto End_Of_Expr; - } - rc = (RCODE)((*puzRegExp) - ? RC_SET( NE_XFLM_ILLEGAL_CLASS_SUBTRACTION) - : RC_SET( NE_XFLM_UNEXPECTED_END_OF_EXPR)); - goto Exit; - - default: - -Save_Char: - - if (!bHaveDash) - { - if (RC_BAD( rc = addLiteralChar( *puzRegExp))) - { - goto Exit; - } - } - else - { - FLMUNICODE uzLowChar; - - // Reset the bHaveDash flag. - - bHaveDash = FALSE; - - uzLowChar = m_puzLiteral [m_uiNumLiteralChars - 1]; - if (*puzRegExp < uzLowChar) - { - rc = RC_SET( NE_XFLM_ILLEGAL_CHAR_RANGE_IN_EXPR); - goto Exit; - } - - // No need to do anything if the character is equal to - // the last one. i.e., they are doing a range like A-A - - else if (*puzRegExp > uzLowChar) - { - - // Save off the characters we have gathered so far, - // except for the last one, which will be the beginning - // of our range. - - if (m_uiNumLiteralChars > 1) - { - if (RC_BAD( rc = createCharList( NULL, m_puzLiteral, - m_uiNumLiteralChars - 1, FALSE, - pCharClass))) - { - goto Exit; - } - } - - // Need to zero out number of characters so that if there - // is another dash, it will be reported as an unescaped - // metacharacter. - - m_uiNumLiteralChars = 0; - - // Create a range. - - if (RC_BAD( rc = createCharRange( uzLowChar, *puzRegExp, - FALSE, pCharClass))) - { - goto Exit; - } - } - } - bAtBeginning = FALSE; - puzRegExp++; - break; - } - } - -End_Of_Expr: - - // Keep the final set of characters we may have - // gathered. - - if (m_uiNumLiteralChars) - { - if (RC_BAD( rc = createCharList( NULL, m_puzLiteral, - m_uiNumLiteralChars, FALSE, pCharClass))) - { - goto Exit; - } - m_uiNumLiteralChars = 0; - } - - // Skip past the ']' - - puzRegExp++; - -Exit: - - *ppuzRegExp = puzRegExp; - return( rc); -} - -/***************************************************************************** -Desc: Parse a quantifier expression. - All of the following forms are allowed: - {3} - exactly 3 - {,4} - same as {0,4} - {3,} - 3 to unlimited - {3,5} - min of 3, max of 5 - + - same as {1,} - * - same as {0,} - ? - same as {0,1} -*****************************************************************************/ -RCODE F_RegExp::parseQuantifier( - FLMUNICODE ** ppuzRegExp) -{ - RCODE rc = NE_XFLM_OK; - FLMUNICODE * puzRegExp = *ppuzRegExp; - FLMUINT uiMin; - FLMUINT uiMax; - FLMBOOL bUnlimited; - REG_EXP * pTmpExpr; - - if (!m_uiNumLiteralChars && - (!m_pCurrBranch->pLastExpr || - m_pCurrBranch->pLastExpr->bQuantified)) - { - rc = RC_SET( NE_XFLM_ILLEGAL_QUANTIFIER); - goto Exit; - } - - // Skip the first character - - if (*puzRegExp == '?') - { - uiMin = 0; - uiMax = 1; - bUnlimited = FALSE; - - // Skip past the '?' - - puzRegExp++; - } - else if (*puzRegExp == '*') - { - uiMin = 0; - uiMax = 0; - bUnlimited = TRUE; - - // Skip past the '*' - - puzRegExp++; - } - else if (*puzRegExp == '+') - { - uiMin = 1; - uiMax = 0; - bUnlimited = TRUE; - - // Skip past the '+' - - puzRegExp++; - } - else - { - - // Only thing left better be a left brace - - flmAssert( *puzRegExp == '{'); - - // Skip past the left brace - - puzRegExp++; - - // Skip any white space - - puzRegExp = skipWhitespace( puzRegExp); - - // Get the first number, if any - - uiMin = 0; - while (*puzRegExp >= '0' && *puzRegExp <= '9') - { - uiMin *= 10; - uiMin += (FLMUINT)(*puzRegExp - '0'); - puzRegExp++; - } - - // Skip any whitespace that comes after the number. - - puzRegExp = skipWhitespace( puzRegExp); - - // Better have landed on a comma or right brace - - if (*puzRegExp == ',') - { - puzRegExp++; - - // Skip any whitespace that comes after the comma - - puzRegExp = skipWhitespace( puzRegExp); - } - else if (*puzRegExp == '}') - { - if (!uiMin) - { - rc = RC_SET( NE_XFLM_ILLEGAL_QUANTIFIER); - goto Exit; - } - uiMax = uiMin; - bUnlimited = FALSE; - } - else - { - rc = RC_SET( NE_XFLM_ILLEGAL_MIN_COUNT); - goto Exit; - } - - uiMax = 0; - bUnlimited = TRUE; - - // Get the next number, if any - - while (*puzRegExp >= '0' && *puzRegExp <= '9') - { - uiMax *= 10; - uiMax += (FLMUINT)(*puzRegExp - '0'); - bUnlimited = FALSE; - puzRegExp++; - } - - // Skip any whitespace that comes after the number. - - puzRegExp = skipWhitespace( puzRegExp); - - // Better have landed on a right brace - - if (*puzRegExp != '}') - { - rc = (RCODE)((*puzRegExp) - ? RC_SET( NE_XFLM_ILLEGAL_MAX_COUNT) - : RC_SET( NE_XFLM_UNEXPECTED_END_OF_EXPR)); - goto Exit; - } - - // Got the '}', see if min and max are legal. - - puzRegExp++; - if (!bUnlimited && (!uiMax || uiMax < uiMin)) - { - rc = RC_SET( NE_XFLM_ILLEGAL_MAX_COUNT); - goto Exit; - } - } - - // If we have a literal, create two expressions. First - // expression will be all but the last character of the - // literal. Second expression will be the one character - // literal with a count. - - if (m_uiNumLiteralChars) - { - if (m_uiNumLiteralChars > 1) - { - if (RC_BAD( rc = addLiteralExpr( m_puzLiteral, - m_uiNumLiteralChars - 1, NULL))) - { - goto Exit; - } - } - if (RC_BAD( rc = addLiteralExpr( - &m_puzLiteral [m_uiNumLiteralChars - 1], 1, - &pTmpExpr))) - { - goto Exit; - } - - // Zero out the literal and start over. - - m_uiNumLiteralChars = 0; - } - else - { - pTmpExpr = m_pCurrBranch->pLastExpr; - } - flmAssert( pTmpExpr); - pTmpExpr->uiMinOccurs = uiMin; - pTmpExpr->uiMaxOccurs = uiMax; - pTmpExpr->bUnlimited = bUnlimited; - pTmpExpr->bQuantified = TRUE; - -Exit: - - *ppuzRegExp = puzRegExp; - return( rc); -} - -/***************************************************************************** -Desc: Start an alternative - Called when we hit a left paren. -*****************************************************************************/ -RCODE F_RegExp::startAlternative( void) -{ - RCODE rc = NE_XFLM_OK; - REG_EXP * pTmpExpr = 0; - - // If we were gathering up a literal, save it out. - - if (RC_BAD( rc = saveLiteral())) - { - goto Exit; - } - - // Start a new alternative expression node - - if (RC_BAD( rc = createRegExp( EXP_ALTERNATIVES, &pTmpExpr))) - { - goto Exit; - } - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( REG_EXP_BRANCH), - (void **)&pTmpExpr->exp.alternative.pFirstBranch))) - { - goto Exit; - } - pTmpExpr->exp.alternative.pLastBranch = - pTmpExpr->exp.alternative.pFirstBranch; - m_pCurrBranch = pTmpExpr->exp.alternative.pFirstBranch; - m_pCurrBranch->pParentExpr = pTmpExpr; - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: End an alternative - Called when we hit a right paren. -*****************************************************************************/ -RCODE F_RegExp::endAlternative( void) -{ - RCODE rc = NE_XFLM_OK; - REG_EXP * pParentExpr; - REG_EXP * pTmpExpr; - - // If the current branch doesn't have a parent - // expression, this is an illegal unescaped right paren. - - if ((pParentExpr = m_pCurrBranch->pParentExpr) == NULL) - { - rc = RC_SET( NE_XFLM_UNESCAPED_METACHAR); - goto Exit; - } - flmAssert( pParentExpr->eType == EXP_ALTERNATIVES); - - // If we were gathering up a literal, save it out. - - if (RC_BAD( rc = saveLiteral())) - { - goto Exit; - } - - // Make sure the current branch isn't empty - - if (!m_pCurrBranch->pFirstExpr) - { - rc = RC_SET( NE_XFLM_EMPTY_BRANCH_IN_EXPR); - goto Exit; - } - - // If there is only one alternative, link these - // nodes right in where the parent expression would - // have gone. This is not strictly necessary, because - // the processor can handle only one alternative, but - // it may save processing time in the end. - - if (pParentExpr->exp.alternative.pFirstBranch == - pParentExpr->exp.alternative.pLastBranch) - { - if ((m_pCurrBranch->pFirstExpr->pPrev = pParentExpr->pPrev) != NULL) - { - pParentExpr->pPrev->pNext = m_pCurrBranch->pFirstExpr; - } - else - { - pParentExpr->pBranch->pFirstExpr = m_pCurrBranch->pFirstExpr; - } - - // Need to alter the branch pointed to by each of the - // expressions in this list. - - pTmpExpr = m_pCurrBranch->pFirstExpr; - while (pTmpExpr) - { - pTmpExpr->pBranch = pParentExpr->pBranch; - pTmpExpr = pTmpExpr->pNext; - } - pParentExpr->pBranch->pLastExpr = m_pCurrBranch->pLastExpr; - } - - // Go back to the parent branch - - m_pCurrBranch = pParentExpr->pBranch; - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Start a new branch of an alternatives list. This is called when - we hit the '|' character. -*****************************************************************************/ -RCODE F_RegExp::startNewBranch( void) -{ - RCODE rc = NE_XFLM_OK; - REG_EXP * pTmpExpr; - REG_EXP_BRANCH * pTmpBranch; - - // If we were gathering up a literal, save it out. - - if (RC_BAD( rc = saveLiteral())) - { - goto Exit; - } - - // Make sure the current branch isn't empty - - if (!m_pCurrBranch->pFirstExpr) - { - rc = RC_SET( NE_XFLM_EMPTY_BRANCH_IN_EXPR); - goto Exit; - } - - // Create a new branch to link to current branch. - - if (RC_BAD( rc = m_Pool.poolCalloc( sizeof( REG_EXP_BRANCH), - (void **)&pTmpBranch))) - { - goto Exit; - } - - // Link this branch after the current branch - - pTmpBranch->pPrevBranch = m_pCurrBranch; - m_pCurrBranch->pNextBranch = pTmpBranch; - - // If current branch has a parent, the parent should be - // an alternative, and it's last branch should now point - // to this new branch. - - if ((pTmpBranch->pParentExpr = m_pCurrBranch->pParentExpr) != NULL) - { - pTmpExpr = pTmpBranch->pParentExpr; - flmAssert( pTmpExpr->eType == EXP_ALTERNATIVES); - pTmpExpr->exp.alternative.pLastBranch = pTmpBranch; - } - - // Current branch should now become this newly created branch - - m_pCurrBranch = pTmpBranch; - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Set a regular expression. Parse the expression, turning it into - constructs that can be used to test strings more easily. -*****************************************************************************/ -RCODE F_RegExp::setExpression( - FLMUNICODE * puzRegExp - ) -{ - RCODE rc = NE_XFLM_OK; - REG_EXP * pTmpExpr = 0; - FLMUNICODE uzChar; - - while (*puzRegExp) - { - switch (*puzRegExp) - { - case '[': - if (RC_BAD( rc = createRegExp( EXP_CHAR_CLASS, &pTmpExpr))) - { - goto Exit; - } - if (RC_BAD( rc = parseCharClass( &puzRegExp, &pTmpExpr->exp.charClass))) - { - goto Exit; - } - break; - - case '\\': - if (RC_BAD( rc = parseEscape( &puzRegExp, NULL, &uzChar))) - { - goto Exit; - } - if (uzChar) - { - if (RC_BAD( rc = addLiteralChar( uzChar))) - { - goto Exit; - } - } - break; - - case '|': - if (RC_BAD( rc = startNewBranch())) - { - goto Exit; - } - - // Skip past the '|' - - puzRegExp++; - break; - - case '(': - if (RC_BAD( rc = startAlternative())) - { - goto Exit; - } - - // Skip past the '(' - - puzRegExp++; - break; - - case ')': - if (RC_BAD( rc = endAlternative())) - { - goto Exit; - } - - // Skip past the ')' - - puzRegExp++; - break; - - case '{': - case '+': - case '*': - case '?': - if (RC_BAD( rc = parseQuantifier( &puzRegExp))) - { - goto Exit; - } - break; - - case '.': - case '^': - case ']': - case '}': - rc = RC_SET( NE_XFLM_UNESCAPED_METACHAR); - goto Exit; - - default: - - // Add character to the literal expression we - // are saving up. - - if (RC_BAD( rc = addLiteralChar( *puzRegExp))) - { - goto Exit; - } - puzRegExp++; - break; - } - } - - // Output the last literal, if any - - if (RC_BAD( rc = saveLiteral())) - { - goto Exit; - } - - // Make sure we are not nested in parens. - - if (m_pCurrBranch->pParentExpr) - { - rc = RC_SET( NE_XFLM_UNEXPECTED_END_OF_EXPR); - goto Exit; - } - -Exit: - - return( rc); -} - -/***************************************************************************** -Desc: Test a string to see if it matches the regular expression. -*****************************************************************************/ -FLMBOOL F_RegExp::testString( - IF_PosIStream * // pIStream - ) -{ - return( FALSE); -} diff --git a/xflaim/src/rfl.cpp b/xflaim/src/rfl.cpp index 060a725..8ce2d6f 100644 --- a/xflaim/src/rfl.cpp +++ b/xflaim/src/rfl.cpp @@ -71,7 +71,7 @@ public: } } - RCODE XFLMAPI write( + RCODE FLMAPI write( const void * pvBuffer, FLMUINT uiBytesToWrite, FLMUINT * puiBytesWritten = NULL); @@ -79,7 +79,7 @@ public: RCODE write( IF_PosIStream * pIStream); - FINLINE RCODE XFLMAPI close( void) + FINLINE RCODE FLMAPI close( void) { if( m_pRfl) { @@ -177,7 +177,7 @@ F_Rfl::~F_Rfl() if (m_pFileHdl) { - m_pFileHdl->Close(); + m_pFileHdl->close(); m_pFileHdl->Release(); m_pFileHdl = NULL; m_pDatabase = NULL; @@ -399,11 +399,11 @@ RCODE F_Rfl::positionTo( m_pCurrentBuf->uiRflBufBytes = MOD_512( uiFileOffset); if (m_pCurrentBuf->uiRflBufBytes) { - if (RC_BAD( rc = m_pFileHdl->SectorRead( + if (RC_BAD( rc = m_pFileHdl->sectorRead( m_pCurrentBuf->uiRflFileOffset, m_pCurrentBuf->uiRflBufBytes, m_pCurrentBuf->pIOBuffer->getBuffer(), &uiBytesRead))) { - if (rc == NE_XFLM_IO_END_OF_FILE) + if (rc == NE_FLM_IO_END_OF_FILE) { rc = RC_SET( NE_XFLM_NOT_RFL); } @@ -445,7 +445,7 @@ RCODE rflGetDirAndPrefix( // Parse the database name into directory and base name - if (RC_BAD( rc = gv_pFileSystem->pathReduce( pszDbFileName, + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathReduce( pszDbFileName, szDbPath, szBaseName))) { goto Exit; @@ -471,7 +471,7 @@ RCODE rflGetDirAndPrefix( f_strcpy( szBaseName, szPrefix); f_strcat( szBaseName, ".rfl"); - gv_pFileSystem->pathAppend( pszRflDirOut, szBaseName); + gv_XFlmSysData.pFileSystem->pathAppend( pszRflDirOut, szBaseName); Exit: @@ -525,7 +525,8 @@ RCODE rflGetFileName( uiBaseNameSize = sizeof( szBaseName); rflGetBaseFileName( uiFileNum, szBaseName, &uiBaseNameSize, NULL); - if (RC_BAD( rc = gv_pFileSystem->pathAppend( pszRflFileName, szBaseName))) + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathAppend( + pszRflFileName, szBaseName))) { goto Exit; } @@ -548,7 +549,8 @@ FLMBOOL rflGetFileNum( char * pszTmp; FLMUINT uiCharCnt; - if( RC_BAD( gv_pFileSystem->pathReduce( pszRflFileName, szDir, szBaseName))) + if( RC_BAD( gv_XFlmSysData.pFileSystem->pathReduce( + pszRflFileName, szDir, szBaseName))) { goto Exit; } @@ -640,17 +642,17 @@ RCODE F_Rfl::setup( { goto Exit; } + + if( RC_BAD( rc = FlmAllocIOBufferMgr( &m_Buf1.pBufferMgr))) + { + goto Exit; + } - if( (m_Buf1.pBufferMgr = f_new F_IOBufferMgr) == NULL) + if( RC_BAD( rc = FlmAllocIOBufferMgr( &m_Buf2.pBufferMgr))) { - rc = RC_SET( NE_XFLM_MEM); - goto Exit; - } - if( (m_Buf2.pBufferMgr = f_new F_IOBufferMgr) == NULL) - { - rc = RC_SET( NE_XFLM_MEM); goto Exit; } + m_Buf1.pBufferMgr->enableKeepBuffer(); m_Buf1.pBufferMgr->setMaxBuffers( m_uiRflWriteBufs); m_Buf1.pBufferMgr->setMaxBytes( m_uiRflWriteBufs * m_uiBufferSize); @@ -741,11 +743,7 @@ RCODE F_Rfl::waitForWrites( if (RC_BAD( TempRc = f_semWait( Waiter.hESem, F_SEM_WAITFOREVER))) { -#ifdef FLM_NLM - EnterDebugger(); -#else RC_UNEXPECTED_ASSERT( TempRc); -#endif rc = TempRc; } else @@ -755,11 +753,7 @@ RCODE F_Rfl::waitForWrites( if (rc == NE_XFLM_FAILURE) { -#ifdef FLM_NLM - EnterDebugger(); -#else RC_UNEXPECTED_ASSERT( rc); -#endif } } @@ -838,20 +832,20 @@ RCODE F_Rfl::writeHeader( XFLM_SERIAL_NUM_SIZE); f_memcpy( &ucBuf [RFL_NEXT_FILE_SERIAL_NUM_POS], pucNextSerialNum, XFLM_SERIAL_NUM_SIZE); - f_strcpy( &ucBuf [RFL_KEEP_SIGNATURE_POS], + f_strcpy( (char *)&ucBuf [RFL_KEEP_SIGNATURE_POS], (char *)((bKeepSignature) ? RFL_KEEP_SIGNATURE : RFL_NOKEEP_SIGNATURE)); // Write out the header - if (RC_BAD( rc = m_pFileHdl->SectorWrite( 0L, 512, + if (RC_BAD( rc = m_pFileHdl->sectorWrite( 0L, 512, ucBuf, sizeof( ucBuf), NULL, &uiBytesWritten))) { // Remap disk full error - if (rc == NE_XFLM_IO_DISK_FULL) + if (rc == NE_FLM_IO_DISK_FULL) { rc = RC_SET( NE_XFLM_RFL_DISK_FULL); m_bRflVolumeFull = TRUE; @@ -862,11 +856,11 @@ RCODE F_Rfl::writeHeader( // Flush the file handle to ensure it is forced to disk. - if (RC_BAD( rc = m_pFileHdl->Flush())) + if (RC_BAD( rc = m_pFileHdl->flush())) { // Remap disk full error - if (rc == NE_XFLM_IO_DISK_FULL) + if (rc == NE_FLM_IO_DISK_FULL) { rc = RC_SET( NE_XFLM_RFL_DISK_FULL); m_bRflVolumeFull = TRUE; @@ -1005,8 +999,8 @@ RCODE F_Rfl::openFile( // Open the file. - if (RC_BAD( rc = gv_pFileSystem->OpenBlockFile( szRflFileName, - XFLM_IO_RDWR | XFLM_IO_SH_DENYNONE | XFLM_IO_DIRECT, + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->openBlockFile( szRflFileName, + FLM_IO_RDWR | FLM_IO_SH_DENYNONE | FLM_IO_DIRECT, 512, &m_pFileHdl))) { goto Exit; @@ -1014,10 +1008,10 @@ RCODE F_Rfl::openFile( // Read the header. - if (RC_BAD( rc = m_pFileHdl->SectorRead( 0, 512, ucBuf, + if (RC_BAD( rc = m_pFileHdl->sectorRead( 0, 512, ucBuf, &uiBytesRead))) { - if (rc == NE_XFLM_IO_END_OF_FILE) + if (rc == NE_FLM_IO_END_OF_FILE) { rc = RC_SET( NE_XFLM_NOT_RFL); } @@ -1095,7 +1089,7 @@ RCODE F_Rfl::createFile( // Delete the file if it already exists - don't care // about return code here - (void)gv_pFileSystem->Delete( szRflFileName); + (void)gv_XFlmSysData.pFileSystem->deleteFile( szRflFileName); // If DB is 4.3 or greater and we are in the same directory as // our database files, see if we need to create the @@ -1110,17 +1104,17 @@ RCODE F_Rfl::createFile( // If it already exists, don't attempt to create it. - if (RC_BAD( rc = gv_pFileSystem->Exists( m_szRflDir))) + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->doesFileExist( m_szRflDir))) { - if (rc != NE_XFLM_IO_PATH_NOT_FOUND && - rc != NE_XFLM_IO_INVALID_FILENAME) + if (rc != NE_FLM_IO_PATH_NOT_FOUND && + rc != NE_FLM_IO_INVALID_FILENAME) { goto Exit; } else { if (RC_BAD( rc = - gv_pFileSystem->CreateDir( m_szRflDir))) + gv_XFlmSysData.pFileSystem->createDir( m_szRflDir))) { goto Exit; } @@ -1131,8 +1125,8 @@ RCODE F_Rfl::createFile( // Create the file - if (RC_BAD( rc = gv_pFileSystem->CreateBlockFile( szRflFileName, - XFLM_IO_RDWR | XFLM_IO_EXCL | XFLM_IO_SH_DENYNONE | XFLM_IO_DIRECT, + if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->createBlockFile( szRflFileName, + FLM_IO_RDWR | FLM_IO_EXCL | FLM_IO_SH_DENYNONE | FLM_IO_DIRECT, 512, &m_pFileHdl))) { goto Exit; @@ -1156,7 +1150,7 @@ Exit: if (RC_BAD( rc)) { closeFile(); - (void)gv_pFileSystem->Delete( szRflFileName); + (void)gv_XFlmSysData.pFileSystem->deleteFile( szRflFileName); } return( rc); } @@ -1253,8 +1247,8 @@ RCODE F_Rfl::flush( { RCODE rc = NE_XFLM_OK; FLMUINT uiBytesWritten; - F_IOBuffer * pNewBuffer; - F_IOBuffer * pAsyncBuf = NULL; + IF_IOBuffer * pNewBuffer = NULL; + IF_IOBuffer * pAsyncBuf = NULL; FLMBYTE * pucOldBuffer; FLMUINT uiFileOffset; FLMUINT uiBufBytes; @@ -1272,7 +1266,7 @@ RCODE F_Rfl::flush( } } - if (m_uiRflWriteBufs > 1 && m_pFileHdl->CanDoAsync()) + if (m_uiRflWriteBufs > 1 && m_pFileHdl->canDoAsync()) { pAsyncBuf = pBuffer->pIOBuffer; } @@ -1308,7 +1302,7 @@ RCODE F_Rfl::flush( } } - rc = m_pFileHdl->SectorWrite( uiFileOffset, uiBufBytes, + rc = m_pFileHdl->sectorWrite( uiFileOffset, uiBufBytes, pucOldBuffer, m_uiBufferSize, pAsyncBuf, &uiBytesWritten, FALSE); @@ -1351,7 +1345,7 @@ RCODE F_Rfl::flush( { // Remap disk full error - if (rc == NE_XFLM_IO_DISK_FULL) + if (rc == NE_FLM_IO_DISK_FULL) { rc = RC_SET( NE_XFLM_RFL_DISK_FULL); m_bRflVolumeFull = TRUE; @@ -1742,12 +1736,12 @@ RCODE F_Rfl::completeTransWrites( if (m_pFileHdl) { - if (RC_BAD( tmpRc = m_pFileHdl->Flush())) + if (RC_BAD( tmpRc = m_pFileHdl->flush())) { // Remap disk full error - if (tmpRc == NE_XFLM_IO_DISK_FULL) + if (tmpRc == NE_FLM_IO_DISK_FULL) { rc = RC_SET( NE_XFLM_RFL_DISK_FULL); m_bRflVolumeFull = TRUE; @@ -1953,14 +1947,14 @@ RCODE F_Rfl::seeIfNeedNewFile( uiCurrFileEOF = ROUND_DOWN_TO_NEAREST_512( uiCurrFileEOF) + 512; } - if (RC_BAD( rc = m_pFileHdl->Truncate( uiCurrFileEOF))) + if (RC_BAD( rc = m_pFileHdl->truncate( uiCurrFileEOF))) { goto Exit; } // Close the file handle. - m_pFileHdl->Close(); + m_pFileHdl->close(); m_pFileHdl->Release(); m_pFileHdl = NULL; @@ -2100,7 +2094,7 @@ RCODE F_Rfl::finishCurrFile( else if (RC_BAD( rc = openFile( pDb->m_hWaitSem, uiTransFileNum, m_ucCurrSerialNum))) { - if (rc == NE_XFLM_IO_PATH_NOT_FOUND || rc == NE_XFLM_IO_INVALID_FILENAME) + if (rc == NE_FLM_IO_PATH_NOT_FOUND || rc == NE_FLM_IO_INVALID_FILENAME) { rc = NE_XFLM_OK; if (!bNewKeepState) @@ -2138,14 +2132,14 @@ RCODE F_Rfl::finishCurrFile( { uiTruncateSize = ROUND_DOWN_TO_NEAREST_512( uiTruncateSize) + 512; } - if (RC_BAD( rc = m_pFileHdl->Truncate( uiTruncateSize))) + if (RC_BAD( rc = m_pFileHdl->truncate( uiTruncateSize))) { goto Exit; } // Close the file handle. - m_pFileHdl->Close(); + m_pFileHdl->close(); m_pFileHdl->Release(); m_pFileHdl = NULL; @@ -2342,14 +2336,14 @@ RCODE F_Rfl::truncate( if (RC_BAD( rc = openFile( hWaitSem, uiFileNum, m_pDatabase->m_lastCommittedDbHdr.ucLastTransRflSerialNum))) { - if (rc == NE_XFLM_IO_PATH_NOT_FOUND || rc == NE_XFLM_IO_INVALID_FILENAME) + if (rc == NE_FLM_IO_PATH_NOT_FOUND || rc == NE_FLM_IO_INVALID_FILENAME) { rc = NE_XFLM_OK; } goto Exit; } - if (RC_BAD( rc = m_pFileHdl->Truncate( uiTruncateSize))) + if (RC_BAD( rc = m_pFileHdl->truncate( uiTruncateSize))) { m_bRflVolumeOk = FALSE; goto Exit; @@ -2410,7 +2404,7 @@ RCODE F_Rfl::setupTransaction( else if (RC_BAD( rc = openFile( pDb->m_hWaitSem, uiFileNum, m_ucCurrSerialNum))) { - if (rc != NE_XFLM_IO_PATH_NOT_FOUND && rc != NE_XFLM_IO_INVALID_FILENAME) + if (rc != NE_FLM_IO_PATH_NOT_FOUND && rc != NE_FLM_IO_INVALID_FILENAME) { goto Exit; } @@ -2576,7 +2570,7 @@ RCODE F_Rfl::logBeginTransaction( // Output the transaction ID. - flmEncodeSEN( pDb->m_ui64CurrTransID, &pucPacketBody); + f_encodeSEN( pDb->m_ui64CurrTransID, &pucPacketBody); // Finish the packet @@ -2768,7 +2762,7 @@ Throw_Away_Transaction: &uiFileNameSize, &bNameTruncated); if (!bNameTruncated) { - (void)gv_pFileSystem->Delete( szRflFileName); + (void)gv_XFlmSysData.pFileSystem->deleteFile( szRflFileName); } uiLowFileNum++; } @@ -2817,7 +2811,7 @@ Throw_Away_Transaction: // Output the transaction ID. - flmEncodeSEN( m_ui64CurrTransID, &pucPacketBody); + f_encodeSEN( m_ui64CurrTransID, &pucPacketBody); // Finish the packet @@ -2900,19 +2894,19 @@ RCODE F_Rfl::logBlockChainFree( // Output the maintenance document ID - flmEncodeSEN( ui64MaintDocID, &pucPacketBody); + f_encodeSEN( ui64MaintDocID, &pucPacketBody); // Output the starting block address - flmEncodeSEN( uiStartBlkAddr, &pucPacketBody); + f_encodeSEN( uiStartBlkAddr, &pucPacketBody); // Output the ending block address - flmEncodeSEN( uiEndBlkAddr, &pucPacketBody); + f_encodeSEN( uiEndBlkAddr, &pucPacketBody); // Output the block count - flmEncodeSEN( uiCount, &pucPacketBody); + f_encodeSEN( uiCount, &pucPacketBody); // Finish the packet @@ -2947,22 +2941,22 @@ RCODE F_Rfl::recovBlockChainFree( FLMUINT uiBlocksFreed; const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64MaintDocNum))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64MaintDocNum))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiStartBlkAddr))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiStartBlkAddr))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiEndBlkAddr))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiEndBlkAddr))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiCount))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiCount))) { goto Exit; } @@ -3060,7 +3054,7 @@ RCODE F_Rfl::logIndexSuspendOrResume( // Output the index number. flmAssert( uiIndexNum <= FLM_MAX_UINT16); - flmEncodeSEN( uiIndexNum, &pucPacketBody); + f_encodeSEN( uiIndexNum, &pucPacketBody); // Finish the packet @@ -3091,7 +3085,7 @@ RCODE F_Rfl::recovIndexSuspendResume( FLMUINT uiIndexNum; const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiIndexNum))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiIndexNum))) { goto Exit; } @@ -3199,11 +3193,11 @@ RCODE F_Rfl::logReduce( // Output the transaction ID. - flmEncodeSEN( pDb->m_ui64CurrTransID, &pucPacketBody); + f_encodeSEN( pDb->m_ui64CurrTransID, &pucPacketBody); // Output the count - flmEncodeSEN( uiCount, &pucPacketBody); + f_encodeSEN( uiCount, &pucPacketBody); // Finish the packet @@ -3238,7 +3232,7 @@ RCODE F_Rfl::recovReduce( FLMUINT uiCount; const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiCount))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiCount))) { goto Exit; } @@ -3335,15 +3329,15 @@ RCODE F_Rfl::logUpgrade( // Output the transaction ID - flmEncodeSEN( pDb->m_ui64CurrTransID, &pucPacketBody); + f_encodeSEN( pDb->m_ui64CurrTransID, &pucPacketBody); // Output the old database version - flmEncodeSEN( uiOldVersion, &pucPacketBody); + f_encodeSEN( uiOldVersion, &pucPacketBody); // Output the new database version - flmEncodeSEN( XFLM_CURRENT_VERSION_NUM, &pucPacketBody); + f_encodeSEN( XFLM_CURRENT_VERSION_NUM, &pucPacketBody); // Finish the packet @@ -3497,11 +3491,11 @@ RCODE F_Rfl::logEncryptionKey( // Output the transaction ID - flmEncodeSEN( pDb->m_ui64CurrTransID, &pucPacketBody); + f_encodeSEN( pDb->m_ui64CurrTransID, &pucPacketBody); // Store the length of the key - flmEncodeSEN( ui32KeyLen, &pucPacketBody); + f_encodeSEN( ui32KeyLen, &pucPacketBody); // If we were built without encryption, the key length will be zero, // so no need to store the key. @@ -3546,7 +3540,7 @@ RCODE F_Rfl::recovEncryptionKey( XFLM_DB_HDR * pUncommittedLogHdr = &m_pDatabase->m_uncommittedDbHdr; const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiDBKeyLen))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiDBKeyLen))) { goto Exit; } @@ -3608,7 +3602,7 @@ RCODE F_Rfl::recovEncryptionKey( goto Exit; } - f_memcpy( &pUncommittedLogHdr->DbKey, pucPacketBody, uiDBKeyLen); + f_memcpy( pUncommittedLogHdr->DbKey, pucPacketBody, uiDBKeyLen); pUncommittedLogHdr->ui32DbKeyLen = (FLMUINT32)uiDBKeyLen; pDb->m_bHadUpdOper = TRUE; @@ -3698,15 +3692,15 @@ RCODE F_Rfl::logEncDefKey( // Output the encryption definition ID - flmEncodeSEN( uiEncDefId, &pucPacketBody); + f_encodeSEN( uiEncDefId, &pucPacketBody); // Output the key size (number of bits) - flmEncodeSEN( uiKeySize, &pucPacketBody); + f_encodeSEN( uiKeySize, &pucPacketBody); // Output the key value length - flmEncodeSEN( uiKeyValueLen, &pucPacketBody); + f_encodeSEN( uiKeyValueLen, &pucPacketBody); // Output the key @@ -3746,17 +3740,17 @@ RCODE F_Rfl::recovEncDefKey( FLMUINT uiKeyValueLen; const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64RootId))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64RootId))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiKeySize))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiKeySize))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiKeyValueLen))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiKeyValueLen))) { goto Exit; } @@ -3892,7 +3886,7 @@ RCODE F_Rfl::logRollOverDbKey( // Output the transaction ID - flmEncodeSEN( pDb->m_ui64CurrTransID, &pucPacketBody); + f_encodeSEN( pDb->m_ui64CurrTransID, &pucPacketBody); // Finish the packet @@ -4009,11 +4003,11 @@ RCODE F_Rfl::logDocumentDone( // Output the collection number - flmEncodeSEN( uiCollection, &pucPacketBody); + f_encodeSEN( uiCollection, &pucPacketBody); // Output the document ID - flmEncodeSEN( ui64RootId, &pucPacketBody); + f_encodeSEN( ui64RootId, &pucPacketBody); // Finish the packet @@ -4045,12 +4039,12 @@ RCODE F_Rfl::recovDocumentDone( FLMUINT64 ui64RootId; const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiCollection))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiCollection))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64RootId))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64RootId))) { goto Exit; } @@ -4139,11 +4133,11 @@ RCODE F_Rfl::logNodeDelete( // Output the collection number - flmEncodeSEN( uiCollection, &pucPacketBody); + f_encodeSEN( uiCollection, &pucPacketBody); // Output the node ID - flmEncodeSEN( ui64NodeId, &pucPacketBody); + f_encodeSEN( ui64NodeId, &pucPacketBody); // Finish the packet @@ -4176,12 +4170,12 @@ RCODE F_Rfl::recovNodeDelete( F_DOMNode * pNode = NULL; const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiCollection))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiCollection))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64NodeId))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64NodeId))) { goto Exit; } @@ -4287,15 +4281,15 @@ RCODE F_Rfl::logAttributeDelete( // Output the collection number - flmEncodeSEN( uiCollection, &pucPacketBody); + f_encodeSEN( uiCollection, &pucPacketBody); // Output the element ID - flmEncodeSEN( ui64ElementId, &pucPacketBody); + f_encodeSEN( ui64ElementId, &pucPacketBody); // Output the attribute name - flmEncodeSEN( uiAttrName, &pucPacketBody); + f_encodeSEN( uiAttrName, &pucPacketBody); // Finish the packet @@ -4329,17 +4323,17 @@ RCODE F_Rfl::recovAttributeDelete( F_DOMNode * pElementNode = NULL; const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiCollection))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiCollection))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64ElementId))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64ElementId))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiAttrName))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiAttrName))) { goto Exit; } @@ -4445,15 +4439,15 @@ RCODE F_Rfl::logNodeChildrenDelete( // Output the collection number - flmEncodeSEN( uiCollection, &pucPacketBody); + f_encodeSEN( uiCollection, &pucPacketBody); // Output the node ID - flmEncodeSEN( ui64NodeId, &pucPacketBody); + f_encodeSEN( ui64NodeId, &pucPacketBody); // Output the name ID - flmEncodeSEN( uiNameId, &pucPacketBody); + f_encodeSEN( uiNameId, &pucPacketBody); // Finish the packet @@ -4487,17 +4481,17 @@ RCODE F_Rfl::recovNodeChildrenDelete( F_DOMNode * pNode = NULL; const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiCollection))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiCollection))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64NodeId))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64NodeId))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiNameId))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiNameId))) { goto Exit; } @@ -4607,19 +4601,19 @@ RCODE F_Rfl::logNodeCreate( // Output the collection number - flmEncodeSEN( uiCollection, &pucPacketBody); + f_encodeSEN( uiCollection, &pucPacketBody); // Output the reference node ID - flmEncodeSEN( ui64RefNodeId, &pucPacketBody); + f_encodeSEN( ui64RefNodeId, &pucPacketBody); // Output the name ID - flmEncodeSEN( uiNameId, &pucPacketBody); + f_encodeSEN( uiNameId, &pucPacketBody); // Output the node ID - flmEncodeSEN( ui64NodeId, &pucPacketBody); + f_encodeSEN( ui64NodeId, &pucPacketBody); // Output the node type @@ -4668,22 +4662,22 @@ RCODE F_Rfl::recovNodeCreate( IF_DOMNode * pRefNode = NULL; const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiCollection))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiCollection))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64RefNodeId))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64RefNodeId))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiNameId))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiNameId))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64ExpectedNodeId))) { goto Exit; @@ -4816,19 +4810,19 @@ RCODE F_Rfl::logAttributeCreate( // Output the collection number - flmEncodeSEN( uiCollection, &pucPacketBody); + f_encodeSEN( uiCollection, &pucPacketBody); // Output the element node ID - flmEncodeSEN( ui64ElementNodeId, &pucPacketBody); + f_encodeSEN( ui64ElementNodeId, &pucPacketBody); // Output the name ID - flmEncodeSEN( uiNameId, &pucPacketBody); + f_encodeSEN( uiNameId, &pucPacketBody); // Output the next attribute's name ID - flmEncodeSEN( uiNextAttrNameId, &pucPacketBody); + f_encodeSEN( uiNextAttrNameId, &pucPacketBody); // Finish the packet @@ -4864,22 +4858,22 @@ RCODE F_Rfl::recovAttributeCreate( IF_DOMNode * pElementNode = NULL; const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiCollection))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiCollection))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64ElementId))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64ElementId))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiAttrNameId))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiAttrNameId))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiNextAttrNameId))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiNextAttrNameId))) { goto Exit; } @@ -4986,19 +4980,19 @@ RCODE F_Rfl::logInsertBefore( // Output the collection number - flmEncodeSEN( uiCollection, &pucPacketBody); + f_encodeSEN( uiCollection, &pucPacketBody); // Output the parent ID - flmEncodeSEN( ui64Parent, &pucPacketBody); + f_encodeSEN( ui64Parent, &pucPacketBody); // Output the child ID - flmEncodeSEN( ui64Child, &pucPacketBody); + f_encodeSEN( ui64Child, &pucPacketBody); // Output the ref child ID - flmEncodeSEN( ui64RefChild, &pucPacketBody); + f_encodeSEN( ui64RefChild, &pucPacketBody); // Finish the packet @@ -5035,22 +5029,22 @@ RCODE F_Rfl::recovInsertBefore( F_DOMNode * pRefChild = NULL; const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiCollection))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiCollection))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64Parent))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64Parent))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64NewChild))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64NewChild))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64RefChild))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64RefChild))) { goto Exit; } @@ -5198,17 +5192,17 @@ RCODE F_Rfl::logEncryptedNodeUpdate( // Output the collection number - flmEncodeSEN( pCachedNode->getCollection(), &pucPacketBody); + f_encodeSEN( pCachedNode->getCollection(), &pucPacketBody); // Output the node ID - flmEncodeSEN( pCachedNode->getNodeId(), &pucPacketBody); + f_encodeSEN( pCachedNode->getNodeId(), &pucPacketBody); // Output the stream length uiDataLength = (FLMUINT)pIStream->remainingSize(); flmAssert( uiDataLength); - flmEncodeSEN( uiDataLength, &pucPacketBody); + f_encodeSEN( uiDataLength, &pucPacketBody); // Finish the packet @@ -5266,17 +5260,17 @@ RCODE F_Rfl::recovEncryptedNodeUpdate( F_DOMNode * pNode = NULL; const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiCollection))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiCollection))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64NodeId))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64NodeId))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiDataLen))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiDataLen))) { goto Exit; } @@ -5530,7 +5524,7 @@ RCODE F_Rfl::logNodeSetValue( goto Exit; } - uiSENLen = flmGetSENLength( ucSEN); + uiSENLen = f_getSENLength( ucSEN); if( uiSENLen > 1) { if( RC_BAD( rc = pIStream->read( NULL, uiSENLen - 1, NULL))) @@ -5571,19 +5565,19 @@ RCODE F_Rfl::logNodeSetValue( // Output the collection number - flmEncodeSEN( pCachedNode->getCollection(), &pucPacketBody); + f_encodeSEN( pCachedNode->getCollection(), &pucPacketBody); // Output the node ID - flmEncodeSEN( pCachedNode->getNodeId(), &pucPacketBody); + f_encodeSEN( pCachedNode->getNodeId(), &pucPacketBody); // Output the data length - flmEncodeSEN( uiDataLength, &pucPacketBody); + f_encodeSEN( uiDataLength, &pucPacketBody); // Output the data packet flag - flmEncodeSEN( bUseDataPackets ? 1 : 0, &pucPacketBody); + f_encodeSEN( bUseDataPackets ? 1 : 0, &pucPacketBody); // Output the data if we aren't using data packets @@ -5655,22 +5649,22 @@ RCODE F_Rfl::recovNodeSetValue( FLMBOOL bUseDataOnlyBlocks; const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiCollection))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiCollection))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64NodeId))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64NodeId))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiDataLen))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiDataLen))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiHaveDataPackets))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiHaveDataPackets))) { goto Exit; } @@ -5899,19 +5893,19 @@ RCODE F_Rfl::logNodeFlagsUpdate( // Output the collection number - flmEncodeSEN( uiCollection, &pucPacketBody); + f_encodeSEN( uiCollection, &pucPacketBody); // Output the node ID - flmEncodeSEN( ui64NodeId, &pucPacketBody); + f_encodeSEN( ui64NodeId, &pucPacketBody); // Output the attribute name ID - flmEncodeSEN( uiAttrNameId, &pucPacketBody); + f_encodeSEN( uiAttrNameId, &pucPacketBody); // Output the flags - flmEncodeSEN( uiFlags, &pucPacketBody); + f_encodeSEN( uiFlags, &pucPacketBody); // Output the "add" flag @@ -5952,22 +5946,22 @@ RCODE F_Rfl::recovNodeFlagsUpdate( F_DOMNode * pNode = NULL; const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiCollection))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiCollection))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64NodeId))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64NodeId))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiAttrNameId))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiAttrNameId))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiFlags))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiFlags))) { goto Exit; } @@ -6092,19 +6086,19 @@ RCODE F_Rfl::logNodeSetPrefixId( // Output the collection number - flmEncodeSEN( uiCollection, &pucPacketBody); + f_encodeSEN( uiCollection, &pucPacketBody); // Output the node ID - flmEncodeSEN( ui64NodeId, &pucPacketBody); + f_encodeSEN( ui64NodeId, &pucPacketBody); // Output the attribute name (if any) - flmEncodeSEN( uiAttrName, &pucPacketBody); + f_encodeSEN( uiAttrName, &pucPacketBody); // Output the prefix ID - flmEncodeSEN( uiPrefixId, &pucPacketBody); + f_encodeSEN( uiPrefixId, &pucPacketBody); // Finish the packet @@ -6139,22 +6133,22 @@ RCODE F_Rfl::recovNodeSetPrefixId( F_DOMNode * pNode = NULL; const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiCollection))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiCollection))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64NodeId))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64NodeId))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiAttrName))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiAttrName))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiPrefix))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiPrefix))) { goto Exit; } @@ -6272,15 +6266,15 @@ RCODE F_Rfl::logNodeSetMetaValue( // Output the collection number - flmEncodeSEN( uiCollection, &pucPacketBody); + f_encodeSEN( uiCollection, &pucPacketBody); // Output the node ID - flmEncodeSEN( ui64NodeId, &pucPacketBody); + f_encodeSEN( ui64NodeId, &pucPacketBody); // Output the meta value - flmEncodeSEN( ui64MetaValue, &pucPacketBody); + f_encodeSEN( ui64MetaValue, &pucPacketBody); // Finish the packet @@ -6314,17 +6308,17 @@ RCODE F_Rfl::recovNodeSetMetaValue( F_DOMNode * pNode = NULL; const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiCollection))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiCollection))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64NodeId))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64NodeId))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64MetaValue))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64MetaValue))) { goto Exit; } @@ -6430,11 +6424,11 @@ RCODE F_Rfl::logSetNextNodeId( // Output the collection number - flmEncodeSEN( uiCollection, &pucPacketBody); + f_encodeSEN( uiCollection, &pucPacketBody); // Output the next node ID - flmEncodeSEN( ui64NextNodeId, &pucPacketBody); + f_encodeSEN( ui64NextNodeId, &pucPacketBody); // Finish the packet @@ -6466,12 +6460,12 @@ RCODE F_Rfl::recovSetNextNodeId( FLMUINT64 ui64NextNodeId; const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiCollection))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiCollection))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64NextNodeId))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64NextNodeId))) { goto Exit; } @@ -6562,15 +6556,15 @@ RCODE F_Rfl::logNodeSetNumberValue( // Output the collection number - flmEncodeSEN( uiCollection, &pucPacketBody); + f_encodeSEN( uiCollection, &pucPacketBody); // Output the node ID - flmEncodeSEN( ui64NodeId, &pucPacketBody); + f_encodeSEN( ui64NodeId, &pucPacketBody); // Output the number - flmEncodeSEN( ui64Value, &pucPacketBody); + f_encodeSEN( ui64Value, &pucPacketBody); // Output the sign flag @@ -6610,17 +6604,17 @@ RCODE F_Rfl::recovNodeSetNumberValue( F_DOMNode * pNode = NULL; const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiCollection))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiCollection))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64NodeId))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64NodeId))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64Value))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64Value))) { goto Exit; } @@ -6757,36 +6751,36 @@ RCODE F_Rfl::logAttrSetValue( // Output the collection number - flmEncodeSEN( pCachedNode->getCollection(), &pucPacketBody); + f_encodeSEN( pCachedNode->getCollection(), &pucPacketBody); // Output the element node ID - flmEncodeSEN( pCachedNode->getNodeId(), &pucPacketBody); + f_encodeSEN( pCachedNode->getNodeId(), &pucPacketBody); // Output the name ID - flmEncodeSEN( uiAttrName, &pucPacketBody); + f_encodeSEN( uiAttrName, &pucPacketBody); // Output the encryption definition ID - flmEncodeSEN( pAttrItem->m_uiEncDefId, &pucPacketBody); + f_encodeSEN( pAttrItem->m_uiEncDefId, &pucPacketBody); // Output the initialization vector length and the // decrypted data length if( pAttrItem->m_uiEncDefId) { - flmEncodeSEN( pAttrItem->m_uiIVLen, &pucPacketBody); - flmEncodeSEN( pAttrItem->m_uiDecryptedDataLen, &pucPacketBody); + f_encodeSEN( pAttrItem->m_uiIVLen, &pucPacketBody); + f_encodeSEN( pAttrItem->m_uiDecryptedDataLen, &pucPacketBody); } // Output the payload length - flmEncodeSEN( uiPayloadLen, &pucPacketBody); + f_encodeSEN( uiPayloadLen, &pucPacketBody); // Output the data packet flag - flmEncodeSEN( bUseDataPackets ? 1 : 0, &pucPacketBody); + f_encodeSEN( bUseDataPackets ? 1 : 0, &pucPacketBody); // Output the data if we aren't using data packets @@ -6831,68 +6825,68 @@ Exit: Desc: *********************************************************************/ RCODE F_Rfl::recovAttrSetValue( - F_Db * pDb, - const FLMBYTE * pucPacketBody, - FLMUINT uiPacketBodyLen, - eRestoreAction * peAction) + F_Db * pDb, + const FLMBYTE * pucPacketBody, + FLMUINT uiPacketBodyLen, + eRestoreAction * peAction) { - RCODE rc = NE_XFLM_OK; - FLMUINT uiCollection; - FLMUINT uiAttrNameId; - FLMUINT uiEncDefId; - FLMUINT uiPayloadLen; - FLMUINT uiDecryptedDataLen = 0; - FLMUINT uiIVLen = 0; - FLMUINT uiHaveDataPackets; - FLMUINT uiTmp; - FLMUINT64 ui64ElementId; - FLMBYTE * pucData = NULL; - const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; - FLMBYTE ucIV[ 16]; - F_DOMNode * pElementNode = NULL; - F_AttrElmInfo defInfo; - F_BufferIStream bufferIStream; + RCODE rc = NE_XFLM_OK; + FLMUINT uiCollection; + FLMUINT uiAttrNameId; + FLMUINT uiEncDefId; + FLMUINT uiPayloadLen; + FLMUINT uiDecryptedDataLen = 0; + FLMUINT uiIVLen = 0; + FLMUINT uiHaveDataPackets; + FLMUINT uiTmp; + FLMUINT64 ui64ElementId; + FLMBYTE * pucData = NULL; + const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; + FLMBYTE ucIV[ 16]; + F_DOMNode * pElementNode = NULL; + F_AttrElmInfo defInfo; + IF_BufferIStream * pBufferIStream = NULL; - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiCollection))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiCollection))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64ElementId))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64ElementId))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiAttrNameId))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiAttrNameId))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiEncDefId))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiEncDefId))) { goto Exit; } if( uiEncDefId) { - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiIVLen))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiIVLen))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiDecryptedDataLen))) { goto Exit; } } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiPayloadLen))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiPayloadLen))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiHaveDataPackets))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiHaveDataPackets))) { goto Exit; } @@ -6945,9 +6939,15 @@ RCODE F_Rfl::recovAttrSetValue( goto Exit; } + if( RC_BAD( rc = FlmAllocBufferIStream( &pBufferIStream))) + { + goto Exit; + } + if( !uiHaveDataPackets) { - if( RC_BAD( rc = bufferIStream.open( pucPacketBody, uiPayloadLen))) + if( RC_BAD( rc = pBufferIStream->open( + (const char *)pucPacketBody, uiPayloadLen))) { goto Exit; } @@ -6959,7 +6959,8 @@ RCODE F_Rfl::recovAttrSetValue( FLMUINT uiDataPacketBodyLen; const FLMBYTE * pucDataPacketBody; - if( RC_BAD( rc = bufferIStream.open( NULL, uiPayloadLen, &pucData))) + if( RC_BAD( rc = pBufferIStream->open( NULL, uiPayloadLen, + (char **)&pucData))) { goto Exit; } @@ -6998,7 +6999,7 @@ RCODE F_Rfl::recovAttrSetValue( if( uiEncDefId) { - if( RC_BAD( rc = bufferIStream.read( ucIV, uiIVLen, NULL))) + if( RC_BAD( rc = pBufferIStream->read( ucIV, uiIVLen, NULL))) { goto Exit; } @@ -7006,28 +7007,28 @@ RCODE F_Rfl::recovAttrSetValue( flmAssert( pucData); if( RC_BAD( rc = pDb->decryptData( - uiEncDefId, ucIV, pucData, (FLMUINT)bufferIStream.remainingSize(), - pucData, (FLMUINT)bufferIStream.remainingSize()))) + uiEncDefId, ucIV, pucData, (FLMUINT)pBufferIStream->remainingSize(), + pucData, (FLMUINT)pBufferIStream->remainingSize()))) { goto Exit; } - bufferIStream.truncate( - (FLMUINT)(bufferIStream.getCurrPosition() + uiDecryptedDataLen)); + pBufferIStream->truncate( + (FLMUINT)(pBufferIStream->getCurrPosition() + uiDecryptedDataLen)); } switch( defInfo.getDataType()) { case XFLM_TEXT_TYPE: { - FLMUINT uiTextLength = (FLMUINT)bufferIStream.remainingSize(); + FLMUINT uiTextLength = (FLMUINT)pBufferIStream->remainingSize(); const FLMBYTE * pucTmp; - pucTmp = bufferIStream.getBufferAtCurrentOffset(); + pucTmp = pBufferIStream->getBufferAtCurrentOffset(); // Skip the leading SEN - uiTmp = flmGetSENLength( pucTmp[ 0]); + uiTmp = f_getSENLength( pucTmp[ 0]); if( uiTmp > uiTextLength) { @@ -7050,8 +7051,8 @@ RCODE F_Rfl::recovAttrSetValue( case XFLM_BINARY_TYPE: { if( RC_BAD( rc = pElementNode->setAttributeValueBinary( - pDb, uiAttrNameId, bufferIStream.getBufferAtCurrentOffset(), - (FLMUINT)bufferIStream.remainingSize()))) + pDb, uiAttrNameId, pBufferIStream->getBufferAtCurrentOffset(), + (FLMUINT)pBufferIStream->remainingSize()))) { goto Exit; } @@ -7064,7 +7065,7 @@ RCODE F_Rfl::recovAttrSetValue( FLMUINT64 ui64Value; FLMBOOL bNeg; - if( RC_BAD( rc = flmReadStorageAsNumber( &bufferIStream, + if( RC_BAD( rc = flmReadStorageAsNumber( pBufferIStream, XFLM_NUMBER_TYPE, &ui64Value, &bNeg))) { goto Exit; @@ -7099,6 +7100,11 @@ RCODE F_Rfl::recovAttrSetValue( Exit: + if( pBufferIStream) + { + pBufferIStream->Release(); + } + if( pElementNode) { pElementNode->Release(); @@ -7162,15 +7168,15 @@ RCODE F_Rfl::logNodeClearValue( // Output the collection number - flmEncodeSEN( uiCollection, &pucPacketBody); + f_encodeSEN( uiCollection, &pucPacketBody); // Output the node ID - flmEncodeSEN( ui64NodeId, &pucPacketBody); + f_encodeSEN( ui64NodeId, &pucPacketBody); // Output the attribute name (if any) - flmEncodeSEN( uiAttrName, &pucPacketBody); + f_encodeSEN( uiAttrName, &pucPacketBody); // Finish the packet @@ -7204,17 +7210,17 @@ RCODE F_Rfl::recovNodeClearValue( F_DOMNode * pNode = NULL; const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen; - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiCollection))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiCollection))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, pucEnd, &ui64NodeId))) + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64NodeId))) { goto Exit; } - if( RC_BAD( rc = flmDecodeSEN( &pucPacketBody, pucEnd, &uiAttrName))) + if( RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiAttrName))) { goto Exit; } @@ -7290,7 +7296,7 @@ Exit: /******************************************************************** Desc: *********************************************************************/ -RCODE XFLMAPI F_RflOStream::write( +RCODE FLMAPI F_RflOStream::write( const void * pvBuffer, FLMUINT uiBytesToWrite, FLMUINT * puiBytesWritten) @@ -7582,7 +7588,7 @@ RCODE F_Rfl::readPacket( &(m_pCurrentBuf->pIOBuffer->getBuffer()[ m_pCurrentBuf->uiRflBufBytes]), &uiBytesRead))) { - if( rc == NE_XFLM_IO_END_OF_FILE) + if( rc == NE_FLM_IO_END_OF_FILE) { rc = NE_XFLM_OK; } @@ -7667,11 +7673,11 @@ RCODE F_Rfl::readPacket( // Read to get the entire packet. - if( RC_BAD( rc = m_pFileHdl->SectorRead( m_pCurrentBuf->uiRflFileOffset, + if( RC_BAD( rc = m_pFileHdl->sectorRead( m_pCurrentBuf->uiRflFileOffset, uiReadLen, m_pCurrentBuf->pIOBuffer->getBuffer(), &uiBytesRead))) { - if( rc == NE_XFLM_IO_END_OF_FILE) + if( rc == NE_FLM_IO_END_OF_FILE) { rc = NE_XFLM_OK; } @@ -7739,7 +7745,7 @@ Get_Next_File: if( m_pCurrentBuf->uiCurrFileNum == m_uiLastRecoverFileNum) { - rc = RC_SET( NE_XFLM_END); + rc = RC_SET( NE_XFLM_RFL_END); goto Exit; } else if( (m_pCurrentBuf->uiCurrFileNum + 1 ) == @@ -7753,7 +7759,7 @@ Get_Next_File: // fully at the time of the server crash. m_pCurrentBuf->uiCurrFileNum = m_uiLastRecoverFileNum; - rc = RC_SET( NE_XFLM_END); + rc = RC_SET( NE_XFLM_RFL_END); goto Exit; } @@ -7762,9 +7768,9 @@ Get_Next_File: if( RC_BAD( rc = openFile( pDb->m_hWaitSem, m_pCurrentBuf->uiCurrFileNum + 1, m_ucNextSerialNum))) { - if( rc == NE_XFLM_IO_PATH_NOT_FOUND) + if( rc == NE_FLM_IO_PATH_NOT_FOUND) { - rc = RC_SET( NE_XFLM_END); + rc = RC_SET( NE_XFLM_RFL_END); } goto Exit; @@ -7803,9 +7809,9 @@ Get_Next_File: if( RC_BAD( rc = m_pRestore->openRflFile( m_pCurrentBuf->uiCurrFileNum + 1))) { - if( rc == NE_XFLM_IO_PATH_NOT_FOUND) + if( rc == NE_FLM_IO_PATH_NOT_FOUND) { - rc = RC_SET( NE_XFLM_END); + rc = RC_SET( NE_XFLM_RFL_END); } goto Exit; @@ -7903,7 +7909,7 @@ Get_Next_File: // point, we had better not be doing a restore. flmAssert( m_pRestore == NULL && !bForceNextFile); - rc = RC_SET( NE_XFLM_END); + rc = RC_SET( NE_XFLM_RFL_END); goto Exit; } } @@ -7973,7 +7979,7 @@ Get_Next_File: goto Exit; } - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucPacketBodyEnd, &m_ui64CurrTransID))) { goto Exit; @@ -8006,7 +8012,7 @@ Get_Next_File: { FLMUINT64 ui64Tmp; - if( RC_BAD( rc = flmDecodeSEN64( &pucPacketBody, + if( RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucPacketBodyEnd, &ui64Tmp))) { goto Exit; @@ -8193,7 +8199,7 @@ Retry_Open: flmAssert( uiStartFileNum); if( RC_BAD( rc = m_pRestore->openRflFile( uiStartFileNum))) { - if( rc == NE_XFLM_IO_PATH_NOT_FOUND) + if( rc == NE_FLM_IO_PATH_NOT_FOUND) { // Need to set m_pCurrentBuf->uiCurrFileNum in case the first // call to openRflFile fails. This will cause the code at the @@ -8402,7 +8408,7 @@ Retry_Open: if( RC_BAD( rc)) { - if( rc == NE_XFLM_END) + if( rc == NE_XFLM_RFL_END) { if( !m_pRestore) { @@ -9129,7 +9135,7 @@ Exit: /**************************************************************************** Desc: Returns the name of an RFL file given its number ****************************************************************************/ -void XFLMAPI F_Db::getRflFileName( +void FLMAPI F_Db::getRflFileName( FLMUINT uiFileNum, FLMBOOL bBaseOnly, char * pszFileName, diff --git a/xflaim/src/rfl.h b/xflaim/src/rfl.h index 921d228..2fef584 100644 --- a/xflaim/src/rfl.h +++ b/xflaim/src/rfl.h @@ -130,8 +130,8 @@ typedef struct RflWaiterTag typedef struct { - F_IOBufferMgr * pBufferMgr; // Write buffer manager - F_IOBuffer * pIOBuffer; + IF_IOBufferMgr * pBufferMgr; // Write buffer manager + IF_IOBuffer * pIOBuffer; FLMUINT uiCurrFileNum; // Current file number. FLMUINT uiRflBufBytes; // Number of bytes currently in the // pIOBuffer. Always points to @@ -156,7 +156,7 @@ typedef struct Desc: This class handles all of the roll-forward logging for FLAIM. There is one of these objects allocated per F_Database. **************************************************************************/ -class F_Rfl : public XF_RefCount, public XF_Base +class F_Rfl : public F_Object { public: @@ -435,7 +435,7 @@ public: } if (m_pFileHdl) { - m_pFileHdl->Close(); + m_pFileHdl->close(); m_pFileHdl->Release(); m_pFileHdl = NULL; m_pCurrentBuf->uiCurrFileNum = 0; diff --git a/xflaim/src/scache.cpp b/xflaim/src/scache.cpp index 5817c18..5a2d57b 100644 --- a/xflaim/src/scache.cpp +++ b/xflaim/src/scache.cpp @@ -33,7 +33,7 @@ FSTATIC void ScaNotify( RCODE NotifyRc); FSTATIC void scaWriteComplete( - F_IOBuffer * pIOBuffer); + IF_IOBuffer * pIOBuffer); #ifdef SCACHE_LINK_CHECKING FSTATIC void scaVerify( @@ -64,7 +64,7 @@ FINLINE FLMINT scaCompare( Desc: Compare two cache blocks during a sort to determine which one has lower address. *****************************************************************************/ -FINLINE FLMINT scaSortCompare( +FINLINE FLMINT FLMAPI scaSortCompare( void * pvBuffer, FLMUINT uiPos1, FLMUINT uiPos2) @@ -76,7 +76,7 @@ FINLINE FLMINT scaSortCompare( /*************************************************************************** Desc: Swap two entries in cache table during sort. *****************************************************************************/ -FINLINE void scaSortSwap( +FINLINE void FLMAPI scaSortSwap( void * pvBuffer, FLMUINT uiPos1, FLMUINT uiPos2) @@ -109,19 +109,9 @@ void F_CachedBlock::linkToLogList( void) goto Exit; } -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif - if ((m_pNextInReplaceList = m_pDatabase->m_pFirstInLogList) != NULL) { -#ifdef FLM_CACHE_PROTECT - m_pNextInReplaceList->unprotectCachedItem(); -#endif m_pNextInReplaceList->m_pPrevInReplaceList = this; -#ifdef FLM_CACHE_PROTECT - m_pNextInReplaceList->protectCachedItem(); -#endif } else { @@ -130,11 +120,6 @@ void F_CachedBlock::linkToLogList( void) setFlags( CA_IN_FILE_LOG_LIST); m_pPrevInReplaceList = NULL; - -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif - m_pDatabase->m_pFirstInLogList = this; m_pDatabase->m_uiLogListCount++; @@ -155,13 +140,7 @@ void F_CachedBlock::unlinkFromLogList( void) if (m_pNextInReplaceList) { -#ifdef FLM_CACHE_PROTECT - m_pNextInReplaceList->unprotectCachedItem(); -#endif m_pNextInReplaceList->m_pPrevInReplaceList = m_pPrevInReplaceList; -#ifdef FLM_CACHE_PROTECT - m_pNextInReplaceList->protectCachedItem(); -#endif } else { @@ -170,29 +149,16 @@ void F_CachedBlock::unlinkFromLogList( void) if (m_pPrevInReplaceList) { -#ifdef FLM_CACHE_PROTECT - m_pPrevInReplaceList->unprotectCachedItem(); -#endif m_pPrevInReplaceList->m_pNextInReplaceList = m_pNextInReplaceList; -#ifdef FLM_CACHE_PROTECT - m_pPrevInReplaceList->protectCachedItem(); -#endif } else { m_pDatabase->m_pFirstInLogList = m_pNextInReplaceList; } -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_pNextInReplaceList = NULL; m_pPrevInReplaceList = NULL; clearFlags( CA_IN_FILE_LOG_LIST); -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif - m_pDatabase->m_uiLogListCount--; } @@ -216,29 +182,16 @@ void F_CachedBlock::linkToNewList( void) { flmAssert( scaCompare( m_pDatabase->m_pLastInNewList, this) < 0); -#ifdef FLM_CACHE_PROTECT - m_pPrevInReplaceList->unprotectCachedItem(); -#endif m_pPrevInReplaceList->m_pNextInReplaceList = this; -#ifdef FLM_CACHE_PROTECT - m_pPrevInReplaceList->protectCachedItem(); -#endif } else { m_pDatabase->m_pFirstInNewList = this; } -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_pNextInReplaceList = NULL; m_pDatabase->m_pLastInNewList = this; setFlags( CA_IN_NEW_LIST); -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif - m_pDatabase->m_uiNewCount++; } @@ -255,13 +208,7 @@ void F_CachedBlock::unlinkFromNewList( void) if (m_pNextInReplaceList) { -#ifdef FLM_CACHE_PROTECT - m_pNextInReplaceList->unprotectCachedItem(); -#endif m_pNextInReplaceList->m_pPrevInReplaceList = m_pPrevInReplaceList; -#ifdef FLM_CACHE_PROTECT - m_pNextInReplaceList->protectCachedItem(); -#endif } else { @@ -270,29 +217,16 @@ void F_CachedBlock::unlinkFromNewList( void) if (m_pPrevInReplaceList) { -#ifdef FLM_CACHE_PROTECT - m_pPrevInReplaceList->unprotectCachedItem(); -#endif m_pPrevInReplaceList->m_pNextInReplaceList = m_pNextInReplaceList; -#ifdef FLM_CACHE_PROTECT - m_pPrevInReplaceList->protectCachedItem(); -#endif } else { m_pDatabase->m_pFirstInNewList = m_pNextInReplaceList; } -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_pNextInReplaceList = NULL; m_pPrevInReplaceList = NULL; clearFlags( CA_IN_NEW_LIST); -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif - m_pDatabase->m_uiNewCount--; } @@ -308,13 +242,7 @@ void F_CachedBlock::unlinkFromReplaceList( void) if( m_pNextInReplaceList) { -#ifdef FLM_CACHE_PROTECT - m_pNextInReplaceList->unprotectCachedItem(); -#endif m_pNextInReplaceList->m_pPrevInReplaceList = m_pPrevInReplaceList; -#ifdef FLM_CACHE_PROTECT - m_pNextInReplaceList->protectCachedItem(); -#endif } else { @@ -323,27 +251,15 @@ void F_CachedBlock::unlinkFromReplaceList( void) if( m_pPrevInReplaceList) { -#ifdef FLM_CACHE_PROTECT - m_pPrevInReplaceList->unprotectCachedItem(); -#endif m_pPrevInReplaceList->m_pNextInReplaceList = m_pNextInReplaceList; -#ifdef FLM_CACHE_PROTECT - m_pPrevInReplaceList->protectCachedItem(); -#endif } else { gv_XFlmSysData.pBlockCacheMgr->m_pMRUReplace = m_pNextInReplaceList; } -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_pNextInReplaceList = NULL; m_pPrevInReplaceList = NULL; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif flmAssert( gv_XFlmSysData.pBlockCacheMgr->m_uiReplaceableCount); gv_XFlmSysData.pBlockCacheMgr->m_uiReplaceableCount--; @@ -451,21 +367,12 @@ void F_CachedBlock::linkToDatabase( F_Database * pDatabase) { flmAssert( !m_pDatabase); -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif if (m_ui16Flags & CA_WRITE_PENDING) { if ((m_pNextInDatabase = pDatabase->m_pPendingWriteList) != NULL) { -#ifdef FLM_CACHE_PROTECT - m_pNextInDatabase->unprotectCachedItem(); -#endif m_pNextInDatabase->m_pPrevInDatabase = this; -#ifdef FLM_CACHE_PROTECT - m_pNextInDatabase->protectCachedItem(); -#endif } pDatabase->m_pPendingWriteList = this; @@ -500,24 +407,12 @@ void F_CachedBlock::linkToDatabase( if ((m_pNextInDatabase = pNextSCache) != NULL) { -#ifdef FLM_CACHE_PROTECT - pNextSCache->unprotectCachedItem(); -#endif pNextSCache->m_pPrevInDatabase = this; -#ifdef FLM_CACHE_PROTECT - pNextSCache->protectCachedItem(); -#endif } if ((m_pPrevInDatabase = pPrevSCache) != NULL) { -#ifdef FLM_CACHE_PROTECT - pPrevSCache->unprotectCachedItem(); -#endif pPrevSCache->m_pNextInDatabase = this; -#ifdef FLM_CACHE_PROTECT - pPrevSCache->protectCachedItem(); -#endif } else { @@ -526,9 +421,6 @@ void F_CachedBlock::linkToDatabase( } m_pDatabase = pDatabase; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } /**************************************************************************** @@ -538,21 +430,12 @@ Desc: Unlink a cache block from its F_Database object. This routine assumes void F_CachedBlock::unlinkFromDatabase( void) { flmAssert( m_pDatabase); -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif if (m_ui16Flags & CA_IN_WRITE_PENDING_LIST) { if (m_pPrevInDatabase) { -#ifdef FLM_CACHE_PROTECT - m_pPrevInDatabase->unprotectCachedItem(); -#endif m_pPrevInDatabase->m_pNextInDatabase = m_pNextInDatabase; -#ifdef FLM_CACHE_PROTECT - m_pPrevInDatabase->protectCachedItem(); -#endif } else { @@ -561,13 +444,7 @@ void F_CachedBlock::unlinkFromDatabase( void) if (m_pNextInDatabase) { -#ifdef FLM_CACHE_PROTECT - m_pNextInDatabase->unprotectCachedItem(); -#endif m_pNextInDatabase->m_pPrevInDatabase = m_pPrevInDatabase; -#ifdef FLM_CACHE_PROTECT - m_pNextInDatabase->protectCachedItem(); -#endif } clearFlags( CA_IN_WRITE_PENDING_LIST); @@ -591,24 +468,12 @@ void F_CachedBlock::unlinkFromDatabase( void) if (m_pNextInDatabase) { -#ifdef FLM_CACHE_PROTECT - m_pNextInDatabase->unprotectCachedItem(); -#endif m_pNextInDatabase->m_pPrevInDatabase = m_pPrevInDatabase; -#ifdef FLM_CACHE_PROTECT - m_pNextInDatabase->protectCachedItem(); -#endif } if (m_pPrevInDatabase) { -#ifdef FLM_CACHE_PROTECT - m_pPrevInDatabase->unprotectCachedItem(); -#endif m_pPrevInDatabase->m_pNextInDatabase = m_pNextInDatabase; -#ifdef FLM_CACHE_PROTECT - m_pPrevInDatabase->protectCachedItem(); -#endif } else { @@ -620,9 +485,6 @@ void F_CachedBlock::unlinkFromDatabase( void) } m_pDatabase = NULL; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } /**************************************************************************** @@ -650,28 +512,16 @@ void F_CachedBlock::linkToFreeList( if ((m_pNextInDatabase = gv_XFlmSysData.pBlockCacheMgr->m_pFirstFree) != NULL) { -#ifdef FLM_CACHE_PROTECT - m_pNextInDatabase->unprotectCachedItem(); -#endif m_pNextInDatabase->m_pPrevInDatabase = this; -#ifdef FLM_CACHE_PROTECT - m_pNextInDatabase->protectCachedItem(); -#endif } else { gv_XFlmSysData.pBlockCacheMgr->m_pLastFree = this; } -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_pPrevInDatabase = NULL; m_uiBlkAddress = uiFreeTime; m_ui16Flags = CA_FREE; -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif gv_XFlmSysData.pBlockCacheMgr->m_pFirstFree = this; gv_XFlmSysData.pBlockCacheMgr->m_uiFreeBytes += memSize(); @@ -691,13 +541,7 @@ void F_CachedBlock::unlinkFromFreeList( void) if( m_pNextInDatabase) { -#ifdef FLM_CACHE_PROTECT - m_pNextInDatabase->unprotectCachedItem(); -#endif m_pNextInDatabase->m_pPrevInDatabase = m_pPrevInDatabase; -#ifdef FLM_CACHE_PROTECT - m_pNextInDatabase->protectCachedItem(); -#endif } else { @@ -706,29 +550,17 @@ void F_CachedBlock::unlinkFromFreeList( void) if( m_pPrevInDatabase) { -#ifdef FLM_CACHE_PROTECT - m_pPrevInDatabase->unprotectCachedItem(); -#endif m_pPrevInDatabase->m_pNextInDatabase = m_pNextInDatabase; -#ifdef FLM_CACHE_PROTECT - m_pPrevInDatabase->protectCachedItem(); -#endif } else { gv_XFlmSysData.pBlockCacheMgr->m_pFirstFree = m_pNextInDatabase; } -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); -#endif m_pNextInDatabase = NULL; m_pPrevInDatabase = NULL; m_ui16Flags &= ~CA_FREE; flmAssert( !m_ui16Flags); -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif flmAssert( gv_XFlmSysData.pBlockCacheMgr->m_uiFreeBytes >= uiSize); gv_XFlmSysData.pBlockCacheMgr->m_uiFreeBytes -= uiSize; @@ -935,9 +767,6 @@ void F_CachedBlock::unlinkCache( FLMBOOL bFreeIt, RCODE NotifyRc) { -#ifdef FLM_CACHE_PROTECT - FLMBOOL bProtectItem = FALSE; -#endif #ifdef FLM_DEBUG SCACHE_USE * pUse; #endif @@ -954,11 +783,6 @@ void F_CachedBlock::unlinkCache( } #endif -#ifdef FLM_CACHE_PROTECT - unprotectCachedItem(); - bProtectItem = TRUE; -#endif - unlinkFromGlobalList(); #ifdef FLM_DBG_LOG @@ -990,15 +814,8 @@ void F_CachedBlock::unlinkCache( (CA_WRITE_TO_LOG | CA_DIRTY | CA_WAS_DIRTY | CA_IN_FILE_LOG_LIST | CA_IN_NEW_LIST))); } -#endif -#ifdef FLM_CACHE_PROTECT - m_pNextInVersionList->unprotectCachedItem(); #endif m_pNextInVersionList->m_pPrevInVersionList = NULL; -#ifdef FLM_CACHE_PROTECT - m_pNextInVersionList->protectCachedItem(); -#endif - m_pNextInVersionList->linkToHashBucket( ppSCacheBucket); m_pNextInVersionList->verifyCache( 2100); m_pNextInVersionList = NULL; @@ -1009,15 +826,9 @@ void F_CachedBlock::unlinkCache( verifyCache( 2000); savePrevBlkAddress(); -#ifdef FLM_CACHE_PROTECT - m_pPrevInVersionList->unprotectCachedItem(); -#endif m_pPrevInVersionList->m_pNextInVersionList = m_pNextInVersionList; -#ifdef FLM_CACHE_PROTECT - m_pPrevInVersionList->protectCachedItem(); -#endif - m_pPrevInVersionList->verifyCache( 2200); + if (m_pNextInVersionList) { // Older version better not be dirty or not yet logged. @@ -1028,15 +839,8 @@ void F_CachedBlock::unlinkCache( flmAssert( !(m_pNextInVersionList->m_ui16Flags & (CA_WRITE_TO_LOG | CA_DIRTY | CA_WAS_DIRTY))); } -#endif -#ifdef FLM_CACHE_PROTECT - m_pNextInVersionList->unprotectCachedItem(); #endif m_pNextInVersionList->m_pPrevInVersionList = m_pPrevInVersionList; -#ifdef FLM_CACHE_PROTECT - m_pNextInVersionList->protectCachedItem(); -#endif - m_pNextInVersionList->verifyCache( 2300); } @@ -1103,18 +907,8 @@ void F_CachedBlock::unlinkCache( } #endif -#ifdef FLM_CACHE_PROTECT - bProtectItem = FALSE; -#endif delete this; } - -#ifdef FLM_CACHE_PROTECT - if( bProtectItem) - { - protectCachedItem(); - } -#endif } /**************************************************************************** @@ -1166,15 +960,8 @@ void F_Database::unlinkTransLogBlocks( void) // Perhaps we don't really need to set these pointers to NULL, // but it helps keep things clean. -#ifdef FLM_CACHE_PROTECT - pSCache->unprotectCachedItem(); -#endif pSCache->m_pNextInHashBucket = NULL; pSCache->m_pPrevInHashBucket = NULL; -#ifdef FLM_CACHE_PROTECT - pSCache->protectCachedItem(); -#endif - pSCache = pNextSCache; } m_pTransLogList = NULL; @@ -1226,13 +1013,7 @@ void F_CachedBlock::unlinkFromTransLogList( void) if (m_pPrevInHashBucket) { -#ifdef FLM_CACHE_PROTECT - m_pPrevInHashBucket->unprotectCachedItem(); -#endif m_pPrevInHashBucket->m_pNextInHashBucket = m_pNextInHashBucket; -#ifdef FLM_CACHE_PROTECT - m_pPrevInHashBucket->protectCachedItem(); -#endif } else { @@ -1241,13 +1022,7 @@ void F_CachedBlock::unlinkFromTransLogList( void) if (m_pNextInHashBucket) { -#ifdef FLM_CACHE_PROTECT - m_pNextInHashBucket->unprotectCachedItem(); -#endif m_pNextInHashBucket->m_pPrevInHashBucket = m_pPrevInHashBucket; -#ifdef FLM_CACHE_PROTECT - m_pNextInHashBucket->protectCachedItem(); -#endif } m_pNextInHashBucket = NULL; @@ -1436,7 +1211,7 @@ RCODE F_Database::flushLogBlocks( #endif m_uiCurrLogWriteOffset = 0; - bDoAsync = (gv_XFlmSysData.bOkToDoAsyncWrites && pSFileHdl->CanDoAsync()) + bDoAsync = (gv_XFlmSysData.bOkToDoAsyncWrites && pSFileHdl->canDoAsync()) ? TRUE : FALSE; @@ -2068,14 +1843,14 @@ Exit: Desc: This routine is called whenever a write of a dirty block completes. ****************************************************************************/ FSTATIC void scaWriteComplete( - F_IOBuffer * pIOBuffer) + IF_IOBuffer * pIOBuffer) { RCODE rc = pIOBuffer->getCompletionCode(); FLMUINT uiNumBlocks = pIOBuffer->getBufferSize() / pIOBuffer->getBlockSize(); F_CachedBlock * pSCache; F_Database * pDatabase; - XFLM_DB_STATS * pDbStats = pIOBuffer->getDbStats(); + XFLM_DB_STATS * pDbStats = (XFLM_DB_STATS *)pIOBuffer->getStats(); FLMUINT uiMilliPerBlock = 0; FLMUINT uiExtraMilli = 0; @@ -2675,10 +2450,6 @@ F_CachedBlock::F_CachedBlock( m_uiChecksum = 0; m_pUseList = NULL; #endif - -#ifdef FLM_CACHE_PROTECT - protectCachedItem(); -#endif } /**************************************************************************** @@ -3034,7 +2805,7 @@ RCODE F_Database::readTheBlock( f_timeGetTimeStamp( &StartTime); } - if (RC_BAD( rc = pDb->m_pSFileHdl->ReadBlock( uiFilePos, + if (RC_BAD( rc = pDb->m_pSFileHdl->readBlock( uiFilePos, m_uiBlockSize, pBlkHdr, &uiBytesRead))) { if (pDbStats) @@ -3042,7 +2813,7 @@ RCODE F_Database::readTheBlock( pDbStats->uiReadErrors++; } - if (rc == NE_XFLM_IO_END_OF_FILE) + if (rc == NE_FLM_IO_END_OF_FILE) { // Should only be possible when reading a root block, @@ -3964,14 +3735,7 @@ Do_Free_Pass: (pSCache->m_pNextInVersionList->m_ui16Flags & CA_DIRTY)) { pResetDirty = pSCache->m_pNextInVersionList; - -#ifdef FLM_CACHE_PROTECT - pResetDirty->unprotectCachedItem(); -#endif pResetDirty->m_ui16Flags &= ~CA_DIRTY; -#ifdef FLM_CACHE_PROTECT - pResetDirty->protectCachedItem(); -#endif } #endif @@ -3980,13 +3744,7 @@ Do_Free_Pass: #ifdef FLM_DEBUG if( pResetDirty) { -#ifdef FLM_CACHE_PROTECT - pResetDirty->unprotectCachedItem(); -#endif pResetDirty->m_ui16Flags |= CA_DIRTY; -#ifdef FLM_CACHE_PROTECT - pResetDirty->protectCachedItem(); -#endif } #endif pSCache = pNextSCache; @@ -4012,19 +3770,18 @@ Desc: Write an IO buffer to disk. RCODE F_Database::writeContiguousBlocks( XFLM_DB_STATS * pDbStats, F_SuperFileHdl * pSFileHdl, - F_IOBuffer * pIOBuffer, + IF_IOBuffer * pIOBuffer, FLMUINT uiBlkAddress, FLMBOOL bDoAsync) { RCODE rc = NE_XFLM_OK; FLMBYTE * pucWriteBuffer; - F_IOBuffer * pAsyncBuffer; + IF_IOBuffer * pAsyncBuffer; FLMUINT uiBytesWritten; FLMUINT uiWriteLen; pucWriteBuffer = pIOBuffer->getBuffer(); -#if defined( FLM_NLM) || defined( FLM_WIN) if (!bDoAsync) { pAsyncBuffer = NULL; @@ -4033,10 +3790,6 @@ RCODE F_Database::writeContiguousBlocks( { pAsyncBuffer = pIOBuffer; } -#else - F_UNREFERENCED_PARM( bDoAsync); - pAsyncBuffer = NULL; -#endif // Determine how many bytes to write @@ -4047,10 +3800,10 @@ RCODE F_Database::writeContiguousBlocks( pIOBuffer->startTimer( pDbStats); // NOTE: No guarantee that pIOBuffer will still be around - // after the call to WriteBlock, unless we are doing + // after the call to writeBlock, unless we are doing // non-asynchronous write. - rc = pSFileHdl->WriteBlock( uiBlkAddress, uiWriteLen, + rc = pSFileHdl->writeBlock( uiBlkAddress, uiWriteLen, pucWriteBuffer, pIOBuffer->getBufferSize(), pAsyncBuffer, &uiBytesWritten); if (!pAsyncBuffer) @@ -4066,6 +3819,7 @@ RCODE F_Database::writeContiguousBlocks( pDbStats->bHaveStats = TRUE; pDbStats->uiWriteErrors++; } + goto Exit; } @@ -4141,8 +3895,8 @@ RCODE F_Database::writeSortedBlocks( FLMUINT uiContiguousBlocks = 0; FLMUINT uiNumSortedBlocksProcessed; FLMUINT uiBlockCount; - F_CachedBlock * ppContiguousBlocks [MAX_BUFFER_BLOCKS]; - FLMBOOL bBlockDirty [MAX_BUFFER_BLOCKS]; + F_CachedBlock * ppContiguousBlocks[ FLM_MAX_IO_BUFFER_BLOCKS]; + FLMBOOL bBlockDirty[ FLM_MAX_IO_BUFFER_BLOCKS]; FLMUINT uiOffset; FLMUINT uiTmpOffset; FLMUINT uiLoop; @@ -4150,7 +3904,7 @@ RCODE F_Database::writeSortedBlocks( FLMUINT uiCopyLen; FLMBOOL bForceCheckpoint = *pbForceCheckpoint; F_CachedBlock * pSCache; - F_IOBuffer * pIOBuffer = NULL; + IF_IOBuffer * pIOBuffer = NULL; FLMBYTE * pucBuffer; uiOffset = 0; @@ -4202,7 +3956,7 @@ Add_Contiguous_Block: ppContiguousBlocks [uiContiguousBlocks] = pSCache; bBlockDirty [uiContiguousBlocks++] = TRUE; uiNumSortedBlocksProcessed++; - if (uiContiguousBlocks == MAX_BUFFER_BLOCKS) + if (uiContiguousBlocks == FLM_MAX_IO_BUFFER_BLOCKS) { break; } @@ -4248,7 +4002,7 @@ Add_Contiguous_Block: // request, don't try to fill it. if (uiContiguousBlocks + uiGap / m_uiBlockSize + 1 > - MAX_BUFFER_BLOCKS) + FLM_MAX_IO_BUFFER_BLOCKS) { break; } @@ -4541,7 +4295,7 @@ RCODE F_Database::flushDirtyBlocks( // See if we can do async IO. - bDoAsync = (gv_XFlmSysData.bOkToDoAsyncWrites && pSFileHdl->CanDoAsync()) + bDoAsync = (gv_XFlmSysData.bOkToDoAsyncWrites && pSFileHdl->canDoAsync()) ? TRUE : FALSE; @@ -4818,7 +4572,7 @@ RCODE F_Database::reduceDirtyCache( // See if we can do async IO. bDoAsync = (gv_XFlmSysData.bOkToDoAsyncWrites && - pSFileHdl->CanDoAsync()) + pSFileHdl->canDoAsync()) ? TRUE : FALSE; @@ -4985,7 +4739,7 @@ RCODE F_Database::reduceNewBlocks( // See if we can do async IO. - bDoAsync = (gv_XFlmSysData.bOkToDoAsyncWrites && pSFileHdl->CanDoAsync()) + bDoAsync = (gv_XFlmSysData.bOkToDoAsyncWrites && pSFileHdl->canDoAsync()) ? TRUE : FALSE; @@ -5245,14 +4999,8 @@ void F_Database::releaseLogBlocks( void) // Perhaps we don't really need to set these pointers to NULL, // but it helps keep things clean. -#ifdef FLM_CACHE_PROTECT - pSCache->unprotectCachedItem(); -#endif pSCache->m_pNextInHashBucket = NULL; pSCache->m_pPrevInHashBucket = NULL; -#ifdef FLM_CACHE_PROTECT - pSCache->protectCachedItem(); -#endif // If the block is no longer needed by a read transaction, // and it does not need to be logged for the checkpoint, @@ -5576,8 +5324,8 @@ RCODE F_Database::createBlock( RCODE rc = NE_XFLM_OK; FLMUINT uiBlkAddress; F_BLK_HDR * pBlkHdr; - F_CachedBlock * pSCache; - F_CachedBlock * pOldSCache; + F_CachedBlock * pSCache = NULL; + F_CachedBlock * pOldSCache = NULL; FLMBOOL bMutexLocked = FALSE; FLMBOOL bLocalCacheAllocation = FALSE; FLMUINT uiOldLogicalEOF; @@ -5621,7 +5369,7 @@ RCODE F_Database::createBlock( goto Exit; } - if (RC_BAD( rc = pDb->m_pSFileHdl->CreateFile( uiFileNumber))) + if (RC_BAD( rc = pDb->m_pSFileHdl->createFile( uiFileNumber))) { goto Exit; } @@ -5635,7 +5383,7 @@ RCODE F_Database::createBlock( if( !gv_XFlmSysData.pGlobalCacheMgr->cacheOverLimit()) { - gv_XFlmSysData.pBlockCacheMgr->m_blockAllocator.lockMutex(); + gv_XFlmSysData.pBlockCacheMgr->m_pBlockAllocator->lockMutex(); if( (pSCache = new( uiBlockSize, TRUE) F_CachedBlock( uiBlockSize)) == NULL) { @@ -5643,14 +5391,8 @@ RCODE F_Database::createBlock( goto Exit; } -#ifdef FLM_CACHE_PROTECT - pSCache->unprotectCachedItem(); -#endif pSCache->m_uiUseCount++; -#ifdef FLM_CACHE_PROTECT - pSCache->protectCachedItem(); -#endif - gv_XFlmSysData.pBlockCacheMgr->m_blockAllocator.unlockMutex(); + gv_XFlmSysData.pBlockCacheMgr->m_pBlockAllocator->unlockMutex(); bLocalCacheAllocation = TRUE; } @@ -5708,13 +5450,7 @@ RCODE F_Database::createBlock( // Set use count to one so the block cannot be replaced. -#ifdef FLM_CACHE_PROTECT - pSCache->unprotectCachedItem(); -#endif pSCache->m_uiUseCount--; -#ifdef FLM_CACHE_PROTECT - pSCache->protectCachedItem(); -#endif pSCache->useForThread( 0); } else @@ -5935,7 +5671,7 @@ RCODE F_Database::logPhysBlk( RCODE rc = NE_XFLM_OK; F_CachedBlock * pSCache = *ppSCacheRV; F_BLK_HDR * pBlkHdr = pSCache->m_pBlkHdr; - F_CachedBlock * pNewSCache; + F_CachedBlock * pNewSCache = NULL; FLMBOOL bLockedMutex = FALSE; FLMBOOL bLocalCacheAllocation = FALSE; FLMUINT uiBlockSize = getBlockSize(); @@ -6012,7 +5748,7 @@ RCODE F_Database::logPhysBlk( if( !gv_XFlmSysData.pGlobalCacheMgr->cacheOverLimit()) { - gv_XFlmSysData.pBlockCacheMgr->m_blockAllocator.lockMutex(); + gv_XFlmSysData.pBlockCacheMgr->m_pBlockAllocator->lockMutex(); if( (pNewSCache = new( uiBlockSize, TRUE) F_CachedBlock( uiBlockSize)) == NULL) { @@ -6020,26 +5756,14 @@ RCODE F_Database::logPhysBlk( goto Exit; } -#ifdef FLM_CACHE_PROTECT - pNewSCache->unprotectCachedItem(); -#endif pNewSCache->m_uiUseCount++; -#ifdef FLM_CACHE_PROTECT - pNewSCache->protectCachedItem(); -#endif - gv_XFlmSysData.pBlockCacheMgr->m_blockAllocator.unlockMutex(); + gv_XFlmSysData.pBlockCacheMgr->m_pBlockAllocator->unlockMutex(); bLocalCacheAllocation = TRUE; // Copy the old block's data into this one. pBlkHdr = pNewSCache->m_pBlkHdr; -#ifdef FLM_CACHE_PROTECT - pNewSCache->unprotectCachedItem(); -#endif f_memcpy( pBlkHdr, pSCache->m_pBlkHdr, m_uiBlockSize); -#ifdef FLM_CACHE_PROTECT - pNewSCache->protectCachedItem(); -#endif } f_mutexLock( gv_XFlmSysData.hBlockCacheMutex); @@ -6060,13 +5784,7 @@ RCODE F_Database::logPhysBlk( // Set use count to one so the block cannot be replaced. -#ifdef FLM_CACHE_PROTECT - pNewSCache->unprotectCachedItem(); -#endif pNewSCache->m_uiUseCount--; -#ifdef FLM_CACHE_PROTECT - pNewSCache->protectCachedItem(); -#endif pNewSCache->useForThread( 0); } else @@ -6080,13 +5798,7 @@ RCODE F_Database::logPhysBlk( // Copy the old block's data into this one. pBlkHdr = pNewSCache->m_pBlkHdr; -#ifdef FLM_CACHE_PROTECT - pNewSCache->unprotectCachedItem(); -#endif f_memcpy( pBlkHdr, pSCache->m_pBlkHdr, m_uiBlockSize); -#ifdef FLM_CACHE_PROTECT - pNewSCache->protectCachedItem(); -#endif } #ifdef FLM_DEBUG @@ -6208,13 +5920,7 @@ RCODE F_Database::logPhysBlk( pSCache->m_pPrevInHashBucket = NULL; if ((pSCache->m_pNextInHashBucket = m_pTransLogList) != NULL) { -#ifdef FLM_CACHE_PROTECT - pSCache->m_pNextInHashBucket->unprotectCachedItem(); -#endif pSCache->m_pNextInHashBucket->m_pPrevInHashBucket = pSCache; -#ifdef FLM_CACHE_PROTECT - pSCache->m_pNextInHashBucket->protectCachedItem(); -#endif } m_pTransLogList = pSCache; @@ -6277,6 +5983,7 @@ Desc: Constructor for block cache manager. ****************************************************************************/ F_BlockCacheMgr::F_BlockCacheMgr() { + m_pBlockAllocator = NULL; m_pMRUReplace = NULL; m_pLRUReplace = NULL; m_pFirstFree = NULL; @@ -6363,8 +6070,13 @@ RCODE F_BlockCacheMgr::initCache( void) uiBlockSizes[ uiLoop] = 0; - if (RC_BAD( rc = m_blockAllocator.setup( - gv_XFlmSysData.pGlobalCacheMgr->m_pSlabManager, TRUE, uiBlockSizes, + if( RC_BAD( rc = FlmAllocMultiAllocator( &m_pBlockAllocator))) + { + goto Exit; + } + + if (RC_BAD( rc = m_pBlockAllocator->setup( + gv_XFlmSysData.pGlobalCacheMgr->m_pSlabManager, uiBlockSizes, &m_Usage.slabUsage))) { goto Exit; @@ -6709,6 +6421,12 @@ F_BlockCacheMgr::~F_BlockCacheMgr() gv_XFlmSysData.pGlobalCacheMgr->decrTotalBytes( f_msize( m_ppHashBuckets)); f_free( &m_ppHashBuckets); } + + if( m_pBlockAllocator) + { + m_pBlockAllocator->Release(); + } + flmAssert( !m_MRUList.m_pMRUItem && !m_MRUList.m_pLRUItem); } @@ -6920,8 +6638,8 @@ RCODE F_Database::finishCheckpoint( ? TRUE : FALSE; - FLM_SECS_TO_TIMER_UNITS( 300, ui5MinutesTime); - FLM_SECS_TO_TIMER_UNITS( 30, ui30SecTime); + ui5MinutesTime = FLM_SECS_TO_TIMER_UNITS( 300); + ui30SecTime = FLM_SECS_TO_TIMER_UNITS( 30); if (m_pCPInfo && bMustTruncate) { @@ -6986,7 +6704,7 @@ RCODE F_Database::finishCheckpoint( if ((pLogMsg = flmBeginLogMessage( XFLM_GENERAL_MESSAGE)) != NULL) { uiElapTime = FLM_ELAPSED_TIME( uiTime, uiFirstDbInactiveTime); - FLM_TIMER_UNITS_TO_SECS( uiElapTime, uiFirstDbInactiveSecs); + uiFirstDbInactiveSecs = FLM_TIMER_UNITS_TO_SECS( uiElapTime); f_sprintf( szMsgBuf, "Killed transaction %I64u." @@ -6996,7 +6714,7 @@ RCODE F_Database::finishCheckpoint( (unsigned)uiFirstDbThreadId, (unsigned)uiFirstDbInactiveSecs); - pLogMsg->changeColor( XFLM_YELLOW, XFLM_BLACK); + pLogMsg->changeColor( FLM_YELLOW, FLM_BLACK); pLogMsg->appendString( szMsgBuf); flmEndLogMessage( &pLogMsg); } @@ -7030,7 +6748,7 @@ RCODE F_Database::finishCheckpoint( if ((pLogMsg = flmBeginLogMessage( XFLM_GENERAL_MESSAGE)) != NULL) { uiElapTime = FLM_ELAPSED_TIME( uiTime, uiFirstDbInactiveTime); - FLM_TIMER_UNITS_TO_SECS( uiElapTime, uiFirstDbInactiveSecs); + uiFirstDbInactiveSecs = FLM_TIMER_UNITS_TO_SECS( uiElapTime); f_sprintf( szMsgBuf, "Waiting for transaction %I64u to complete." @@ -7040,7 +6758,7 @@ RCODE F_Database::finishCheckpoint( (unsigned)uiFirstDbThreadId, (unsigned)uiFirstDbInactiveSecs); - pLogMsg->changeColor( XFLM_YELLOW, XFLM_BLACK); + pLogMsg->changeColor( FLM_YELLOW, FLM_BLACK); pLogMsg->appendString( szMsgBuf); flmEndLogMessage( &pLogMsg); } @@ -7217,14 +6935,14 @@ RCODE F_Database::finishCheckpoint( if (uiHighLogFileNumber) { - (void)pSFileHdl->TruncateFiles( + (void)pSFileHdl->truncateFiles( FIRST_LOG_BLOCK_FILE_NUMBER, uiHighLogFileNumber); } - if (RC_OK( pSFileHdl->GetFileHdl( 0, TRUE, &pCFileHdl))) + if (RC_OK( pSFileHdl->getFileHdl( 0, TRUE, &pCFileHdl))) { - (void)pCFileHdl->Truncate( LOG_THRESHOLD_SIZE); + (void)pCFileHdl->truncate( LOG_THRESHOLD_SIZE); } } @@ -7285,10 +7003,11 @@ RCODE F_Database::finishCheckpoint( { break; } - if (RC_BAD( TempRc = gv_pFileSystem->Delete( szLogFilePath))) + if (RC_BAD( TempRc = gv_XFlmSysData.pFileSystem->deleteFile( + szLogFilePath))) { - if (TempRc != NE_XFLM_IO_PATH_NOT_FOUND && - TempRc != NE_XFLM_IO_INVALID_FILENAME) + if (TempRc != NE_FLM_IO_PATH_NOT_FOUND && + TempRc != NE_FLM_IO_INVALID_FILENAME) { break; } @@ -7332,7 +7051,7 @@ RCODE F_Database::finishCheckpoint( if (bDoTruncate) { - if (RC_BAD( rc = pSFileHdl->TruncateFile( + if (RC_BAD( rc = pSFileHdl->truncateFile( (FLMUINT)pCommittedDbHdr->ui32LogicalEOF))) { goto Exit; @@ -7367,7 +7086,7 @@ RCODE F_Database::finishCheckpoint( // Get elapsed time in milliseconds - only calculate a new maximum if // we did at least a half second worth of writing. - FLM_TIMER_UNITS_TO_MILLI( uiCPElapsedTime, uiElapsedMilli); + uiElapsedMilli = FLM_TIMER_UNITS_TO_MILLI( uiCPElapsedTime); if (uiElapsedMilli >= 500) { @@ -7376,7 +7095,7 @@ RCODE F_Database::finishCheckpoint( // to that. If calculated maximum is zero, we will not change // the current maximum. - FLM_SECS_TO_TIMER_UNITS( 15, ui15Seconds); + ui15Seconds = FLM_SECS_TO_TIMER_UNITS( 15); uiMaximum = (FLMUINT)(((FLMUINT64)uiTotalToWrite * (FLMUINT64)ui15Seconds) / (FLMUINT64)uiCPElapsedTime); @@ -7602,112 +7321,52 @@ void F_BlockRelocator::relocate( if( pNewSCache->m_pPrevInDatabase) { -#ifdef FLM_CACHE_PROTECT - pNewSCache->m_pPrevInDatabase->unprotectCachedItem(); -#endif pNewSCache->m_pPrevInDatabase->m_pNextInDatabase = pNewSCache; -#ifdef FLM_CACHE_PROTECT - pNewSCache->m_pPrevInDatabase->protectCachedItem(); -#endif } if( pNewSCache->m_pNextInDatabase) { -#ifdef FLM_CACHE_PROTECT - pNewSCache->m_pNextInDatabase->unprotectCachedItem(); -#endif pNewSCache->m_pNextInDatabase->m_pPrevInDatabase = pNewSCache; -#ifdef FLM_CACHE_PROTECT - pNewSCache->m_pNextInDatabase->protectCachedItem(); -#endif } if( pNewSCache->m_pPrevInGlobal) { -#ifdef FLM_CACHE_PROTECT - pNewSCache->m_pPrevInGlobal->unprotectCachedItem(); -#endif pNewSCache->m_pPrevInGlobal->m_pNextInGlobal = pNewSCache; -#ifdef FLM_CACHE_PROTECT - pNewSCache->m_pPrevInGlobal->protectCachedItem(); -#endif } if( pNewSCache->m_pNextInGlobal) { -#ifdef FLM_CACHE_PROTECT - pNewSCache->m_pNextInGlobal->unprotectCachedItem(); -#endif pNewSCache->m_pNextInGlobal->m_pPrevInGlobal = pNewSCache; -#ifdef FLM_CACHE_PROTECT - pNewSCache->m_pNextInGlobal->protectCachedItem(); -#endif } if( pNewSCache->m_pPrevInReplaceList) { -#ifdef FLM_CACHE_PROTECT - pNewSCache->m_pPrevInReplaceList->unprotectCachedItem(); -#endif pNewSCache->m_pPrevInReplaceList->m_pNextInReplaceList = pNewSCache; -#ifdef FLM_CACHE_PROTECT - pNewSCache->m_pPrevInReplaceList->protectCachedItem(); -#endif } if( pNewSCache->m_pNextInReplaceList) { -#ifdef FLM_CACHE_PROTECT - pNewSCache->m_pNextInReplaceList->unprotectCachedItem(); -#endif pNewSCache->m_pNextInReplaceList->m_pPrevInReplaceList = pNewSCache; -#ifdef FLM_CACHE_PROTECT - pNewSCache->m_pNextInReplaceList->protectCachedItem(); -#endif } if( pNewSCache->m_pPrevInHashBucket) { -#ifdef FLM_CACHE_PROTECT - pNewSCache->m_pPrevInHashBucket->unprotectCachedItem(); -#endif pNewSCache->m_pPrevInHashBucket->m_pNextInHashBucket = pNewSCache; -#ifdef FLM_CACHE_PROTECT - pNewSCache->m_pPrevInHashBucket->protectCachedItem(); -#endif } if( pNewSCache->m_pNextInHashBucket) { -#ifdef FLM_CACHE_PROTECT - pNewSCache->m_pNextInHashBucket->unprotectCachedItem(); -#endif pNewSCache->m_pNextInHashBucket->m_pPrevInHashBucket = pNewSCache; -#ifdef FLM_CACHE_PROTECT - pNewSCache->m_pNextInHashBucket->protectCachedItem(); -#endif } if( pNewSCache->m_pPrevInVersionList) { -#ifdef FLM_CACHE_PROTECT - pNewSCache->m_pPrevInVersionList->unprotectCachedItem(); -#endif pNewSCache->m_pPrevInVersionList->m_pNextInVersionList = pNewSCache; -#ifdef FLM_CACHE_PROTECT - pNewSCache->m_pPrevInVersionList->protectCachedItem(); -#endif } if( pNewSCache->m_pNextInVersionList) { -#ifdef FLM_CACHE_PROTECT - pNewSCache->m_pNextInVersionList->unprotectCachedItem(); -#endif pNewSCache->m_pNextInVersionList->m_pPrevInVersionList = pNewSCache; -#ifdef FLM_CACHE_PROTECT - pNewSCache->m_pNextInVersionList->protectCachedItem(); -#endif } if( pDatabase) @@ -8184,17 +7843,13 @@ void * F_CachedBlock::operator new( void * pvPtr; flmAssert( uiSize == sizeof( F_CachedBlock)); - if( RC_BAD( gv_XFlmSysData.pBlockCacheMgr->m_blockAllocator.allocBuf( + if( RC_BAD( gv_XFlmSysData.pBlockCacheMgr->m_pBlockAllocator->allocBuf( &gv_XFlmSysData.pBlockCacheMgr->m_blockRelocator, uiSize + uiBlockSize, (FLMBYTE **)&pvPtr, bAllocMutexLocked))) { pvPtr = NULL; } -#ifdef FLM_CACHE_PROTECT - gv_XFlmSysData.pBlockCacheMgr->m_blockAllocator.unprotectBuffer( - pvPtr, bAllocMutexLocked); -#endif return( pvPtr); } @@ -8270,10 +7925,7 @@ void F_CachedBlock::operator delete( return; } -#ifdef FLM_CACHE_PROTECT - gv_XFlmSysData.pBlockCacheMgr->m_blockAllocator.protectBuffer( ptr); -#endif - gv_XFlmSysData.pBlockCacheMgr->m_blockAllocator.freeBuf( (FLMBYTE **)&ptr); + gv_XFlmSysData.pBlockCacheMgr->m_pBlockAllocator->freeBuf( (FLMBYTE **)&ptr); } /**************************************************************************** @@ -8284,72 +7936,3 @@ void F_CachedBlock::operator delete[]( { flmAssert( 0); } - -/**************************************************************************** -Desc: -****************************************************************************/ -#if !defined( __WATCOMC__) && !defined( FLM_SOLARIS) -void F_CachedBlock::operator delete( - void *, // ptr - FLMSIZET, // uiSize, - const char *, // pszFileName, - int) // iLine -{ - flmAssert( 0); -} -#endif - -/**************************************************************************** -Desc: -****************************************************************************/ -#if !defined( __WATCOMC__) && !defined( FLM_SOLARIS) -void F_CachedBlock::operator delete( - void * ptr, - const char *, // pszFileName - int) // iLineNum -{ - if( !ptr) - { - return; - } - -#ifdef FLM_CACHE_PROTECT - gv_XFlmSysData.pBlockCacheMgr->m_blockAllocator.protectBuffer( ptr); -#endif - gv_XFlmSysData.pBlockCacheMgr->m_blockAllocator.freeBuf( (FLMBYTE **)&ptr); -} -#endif - -/**************************************************************************** -Desc: -****************************************************************************/ -#if !defined( __WATCOMC__) && !defined( FLM_SOLARIS) -void F_CachedBlock::operator delete( - void * ptr, - FLMUINT, // uiBlockSize, - FLMBOOL) // bAllocMutexLocked) -{ - if( !ptr) - { - return; - } - -#ifdef FLM_CACHE_PROTECT - gv_XFlmSysData.pBlockCacheMgr->m_blockAllocator.protectBuffer( ptr); -#endif - gv_XFlmSysData.pBlockCacheMgr->m_blockAllocator.freeBuf( (FLMBYTE **)&ptr); -} -#endif - -/**************************************************************************** -Desc: -****************************************************************************/ -#if !defined( __WATCOMC__) && !defined( FLM_SOLARIS) -void F_CachedBlock::operator delete[]( - void *, // ptr, - const char *, // pszFileName - int) // iLineNum -{ - flmAssert( 0); -} -#endif diff --git a/xflaim/src/translog.cpp b/xflaim/src/translog.cpp index 438a6df..877b78d 100644 --- a/xflaim/src/translog.cpp +++ b/xflaim/src/translog.cpp @@ -26,7 +26,7 @@ #include "flaimsys.h" FSTATIC void lgWriteComplete( - F_IOBuffer * pIOBuffer); + IF_IOBuffer * pIOBuffer); #ifdef FLM_DBG_LOG /**************************************************************************** @@ -70,8 +70,7 @@ Desc: This is the callback routine that is called when a disk write is completed. ****************************************************************************/ FSTATIC void lgWriteComplete( - F_IOBuffer * pIOBuffer - ) + IF_IOBuffer * pIOBuffer) { F_Database * pDatabase = (F_Database *)pIOBuffer->getCompletionCallbackData( 0); @@ -80,7 +79,7 @@ FSTATIC void lgWriteComplete( FLMUINT uiLength = pIOBuffer->getBufferSize(); char * pszEvent; #endif - XFLM_DB_STATS * pDbStats = pIOBuffer->getDbStats(); + XFLM_DB_STATS * pDbStats = (XFLM_DB_STATS *)pIOBuffer->getStats(); #ifdef FLM_DBG_LOG pszEvent = (char *)(RC_OK( pIOBuffer->getCompletionCode()) @@ -112,9 +111,8 @@ RCODE F_Database::lgFlushLogBuffer( { RCODE rc = NE_XFLM_OK; FLMUINT uiBytesWritten; - F_IOBuffer * pAsyncBuffer; + IF_IOBuffer * pAsyncBuffer; -#if defined( FLM_NLM) || defined( FLM_WIN) if (!bDoAsync) { pAsyncBuffer = NULL; @@ -123,10 +121,6 @@ RCODE F_Database::lgFlushLogBuffer( { pAsyncBuffer = m_pCurrLogBuffer; } -#else - F_UNREFERENCED_PARM( bDoAsync); - pAsyncBuffer = NULL; -#endif if (pDbStats) { @@ -145,7 +139,7 @@ RCODE F_Database::lgFlushLogBuffer( // after the call to WriteBlock, unless we are doing // non-asynchronous write. - rc = pSFileHdl->WriteBlock( m_uiCurrLogBlkAddr, + rc = pSFileHdl->writeBlock( m_uiCurrLogBlkAddr, m_uiCurrLogWriteOffset, m_pCurrLogBuffer->getBuffer(), m_pCurrLogBuffer->getBufferSize(), @@ -227,7 +221,7 @@ RCODE F_Database::lgOutputBlock( goto Exit; } - if (RC_BAD( rc = pSFileHdl->CreateFile( uiFileNumber ))) + if (RC_BAD( rc = pSFileHdl->createFile( uiFileNumber ))) { goto Exit; } diff --git a/xflaim/src/xflaim.h b/xflaim/src/xflaim.h index 1c74056..7de3e30 100644 --- a/xflaim/src/xflaim.h +++ b/xflaim/src/xflaim.h @@ -26,466 +26,60 @@ #ifndef XFLAIM_H #define XFLAIM_H - #ifndef FLM_PLATFORM_CONFIGURED - #define FLM_PLATFORM_CONFIGURED - - // Determine the build platform - - #undef FLM_WIN - #undef FLM_NLM - #undef FLM_UNIX - #undef FLM_AIX - #undef FLM_LINUX - #undef FLM_SOLARIS - #undef FLM_SPARC - #undef FLM_HPUX - #undef FLM_OSX - #undef FLM_BIG_ENDIAN - #undef FLM_PPC - #undef FLM_STRICT_ALIGNMENT - #undef FLM_S390 - #undef FLM_IA64 - #undef FLM_GNUC - - #if defined( __GNUC__) - #define FLM_GNUC - #endif - - #if defined( __NETWARE__) || defined( NLM) || defined( N_PLAT_NLM) - #define FLM_NLM - #define FLM_OSTYPE_STR "NetWare" - #if defined( __WATCOMC__) - #define FLM_WATCOM_NLM - #elif defined( __MWERKS__) - #define FLM_MWERKS_NLM - #endif - #elif defined( _WIN64) - #define FLM_WIN - #define FLM_OSTYPE_STR "Windows" - #ifndef FLM_64BIT - #define FLM_64BIT - #endif - #define FLM_STRICT_ALIGNMENT - #elif defined( _WIN32) - #define FLM_WIN - #define FLM_OSTYPE_STR "Windows" - #elif defined( _AIX) - #define FLM_AIX - #define FLM_OSTYPE_STR "AIX" - #define FLM_UNIX - #define FLM_BIG_ENDIAN - #define FLM_STRICT_ALIGNMENT - #elif defined( linux) - #define FLM_LINUX - #define FLM_OSTYPE_STR "Linux" - #define FLM_UNIX - #if defined( __PPC__) || defined( __ppc__) - #define FLM_PPC - #define FLM_BIG_ENDIAN - #define FLM_STRICT_ALIGNMENT - #elif defined( __s390__) - #define FLM_S390 - #define FLM_BIG_ENDIAN - #define FLM_STRICT_ALIGNMENT - #elif defined( __s390x__) - #define FLM_S390 - #ifndef FLM_64BIT - #define FLM_64BIT - #endif - #define FLM_BIG_ENDIAN - #define FLM_STRICT_ALIGNMENT - #elif defined( __ia64__) - #define FLM_IA64 - #ifndef FLM_64BIT - #define FLM_64BIT - #endif - #define FLM_STRICT_ALIGNMENT - #endif - #elif defined( sun) - #define FLM_SOLARIS - #define FLM_OSTYPE_STR "Solaris" - #define FLM_UNIX - #define FLM_STRICT_ALIGNMENT - #if defined( sparc) || defined( __sparc) || defined( __sparc__) - #define FLM_SPARC - #define FLM_BIG_ENDIAN - #endif - #elif defined( __hpux) || defined( hpux) - #define FLM_HPUX - #define FLM_OSTYPE_STR "HPUX" - #define FLM_UNIX - #define FLM_BIG_ENDIAN - #define FLM_STRICT_ALIGNMENT - #elif defined( __APPLE__) - #define FLM_OSX - #define FLM_OSTYPE_STR "OSX" - #define FLM_UNIX - #if (defined( __ppc__) || defined( __ppc64__)) - #define FLM_PPC - #define FLM_BIG_ENDIAN - #define FLM_STRICT_ALIGNMENT - #endif - #else - #error Platform architecture is undefined. - #endif - - #if !defined( FLM_64BIT) && !defined( FLM_32BIT) - #if defined( FLM_UNIX) - #if defined( __x86_64__) || defined( _LP64) || \ - defined( __LP64__) || defined( __sparcv9) - #define FLM_64BIT - #endif - #endif - #endif - - #if !defined( FLM_64BIT) - #define FLM_32BIT - #elif defined( FLM_32BIT) - #error Cannot define both FLM_32BIT and FLM_64BIT - #endif - - // Debug or release build? - - #ifndef FLM_DEBUG - #if defined( DEBUG) || (defined( PRECHECKIN) && PRECHECKIN != 0) - #define FLM_DEBUG - #endif - #endif - - // Alignment - - #if defined( FLM_UNIX) || defined( FLM_64BIT) - #define FLM_ALLOC_ALIGN 0x0007 - #define FLM_ALIGN_SIZE 8 - #elif defined( FLM_WIN) || defined( FLM_NLM) - #define FLM_ALLOC_ALIGN 0x0003 - #define FLM_ALIGN_SIZE 4 - #else - #error Platform not supported - #endif - - // Basic type definitions - - #if defined( FLM_UNIX) - typedef unsigned long FLMUINT; - typedef long FLMINT; - typedef unsigned char FLMBYTE; - typedef unsigned short FLMUNICODE; - - typedef unsigned long long FLMUINT64; - typedef unsigned int FLMUINT32; - typedef unsigned short FLMUINT16; - typedef unsigned char FLMUINT8; - typedef long long FLMINT64; - typedef int FLMINT32; - typedef short FLMINT16; - typedef signed char FLMINT8; - - #if defined( FLM_64BIT) || defined( FLM_OSX) || \ - defined( FLM_S390) || defined( FLM_HPUX) || defined( FLM_AIX) - typedef unsigned long FLMSIZET; - #else - typedef unsigned FLMSIZET; - #endif - #else - - #if defined( FLM_WIN) - - #if defined( FLM_64BIT) - typedef unsigned __int64 FLMUINT; - typedef __int64 FLMINT; - typedef unsigned __int64 FLMSIZET; - typedef unsigned int FLMUINT32; - #elif _MSC_VER >= 1300 - typedef unsigned long __w64 FLMUINT; - typedef long __w64 FLMINT; - typedef unsigned int FLMUINT32; - typedef __w64 unsigned int FLMSIZET; - #else - typedef unsigned long FLMUINT; - typedef long FLMINT; - typedef unsigned int FLMUINT32; - typedef __w64 unsigned int FLMSIZET; - #endif - - #elif defined( FLM_NLM) - - typedef unsigned long int FLMUINT; - typedef long int FLMINT; - typedef unsigned long int FLMUINT32; - typedef unsigned FLMSIZET; - #else - #error Platform not supported - #endif - - typedef unsigned char FLMBYTE; - typedef unsigned short int FLMUNICODE; - - typedef unsigned short int FLMUINT16; - typedef unsigned char FLMUINT8; - typedef signed int FLMINT32; - typedef signed short int FLMINT16; - typedef signed char FLMINT8; - - #if defined( __MWERKS__) - typedef unsigned long long FLMUINT64; - typedef long long FLMINT64; - #else - typedef unsigned __int64 FLMUINT64; - typedef __int64 FLMINT64; - #endif - - #endif - - #if defined( FLM_WIN) || defined( FLM_NLM) - #define FLMATOMIC volatile long - #else - #define FLMATOMIC volatile int - #endif - - typedef FLMINT RCODE; - typedef FLMINT FLMBOOL; - - #define F_FILENAME_SIZE 256 - #define F_PATH_MAX_SIZE 256 - - #define FLM_MAX_UINT ((FLMUINT)(-1L)) - #define FLM_MAX_INT ((FLMINT)(((FLMUINT)(-1L)) >> 1)) - #define FLM_MIN_INT ((FLMINT)((((FLMUINT)(-1L)) >> 1) + 1)) - #define FLM_MAX_UINT32 ((FLMUINT32)(0xFFFFFFFFL)) - #define FLM_MAX_INT32 ((FLMINT32)(0x7FFFFFFFL)) - #define FLM_MIN_INT32 ((FLMINT32)(0x80000000L)) - #define FLM_MAX_UINT16 ((FLMUINT16)(0xFFFF)) - #define FLM_MAX_INT16 ((FLMINT16)(0x7FFF)) - #define FLM_MIN_INT16 ((FLMINT16)(0x8000)) - #define FLM_MAX_UINT8 ((FLMUINT8)0xFF) - - #if( _MSC_VER >= 1200) && (_MSC_VER < 1300) - #define FLM_MAX_UINT64 ((FLMUINT64)(0xFFFFFFFFFFFFFFFFL)) - #define FLM_MAX_INT64 ((FLMINT64)(0x7FFFFFFFFFFFFFFFL)) - #define FLM_MIN_INT64 ((FLMINT64)(0x8000000000000000L)) - #else - #define FLM_MAX_UINT64 ((FLMUINT64)(0xFFFFFFFFFFFFFFFFLL)) - #define FLM_MAX_INT64 ((FLMINT64)(0x7FFFFFFFFFFFFFFFLL)) - #define FLM_MIN_INT64 ((FLMINT64)(0x8000000000000000LL)) - #endif - - #endif - - // xpcselany keeps MS compilers from complaining about multiple definitions - - #if defined(_MSC_VER) - #define xpcselany __declspec(selectany) - #else - #define xpcselany - #endif - - typedef struct - { - FLMUINT32 l; - FLMUINT16 w1; - FLMUINT16 w2; - FLMUINT8 b[ 8]; - } XFLM_GUID; - - #define RXFLMIID const XFLM_GUID & - #define RXFLMCLSID const XFLM_GUID & - #define XFLMGUID XFLM_GUID - #define XFLMCLSID XFLM_GUID - - // XFLM_DEFINE_GUID may be used to define or declare a GUID - // #define XFLM_INIT_GUID before including this header file when - // you want to define the guid, all other inclusions will only declare - // the guid, not define it. - - #if !defined( PCOM_INIT_GUID) - #define XFLM_DEFINE_GUID( name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - extern const XFLMGUID name - #else - #define XFLM_DEFINE_GUID( name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - extern const xpcselany XFLMGUID name \ - = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } - #endif - - #define XFLMEXTC extern "C" - - #if defined( FLM_WIN) - #define XFLMAPI __stdcall - #define XFLMEXP __declspec(dllexport) - #ifdef FLM_DEBUG - #define FINLINE inline - #else - #define FINLINE __forceinline - #endif - #elif defined( FLM_NLM) - #define XFLMAPI __stdcall - #define XFLMEXP XFLMEXTC - #define FINLINE inline - #elif defined( FLM_UNIX) - #define XFLMAPI - #define XFLMEXP XFLMEXTC - #define FINLINE inline - #else - #error Platform not supported - #endif - - // xflmnovtbl keeps MS compilers from generating vtables for interfaces - - #ifdef _MSC_VER - #define xflmnovtbl __declspec( novtable) - #else - #define xflmnovtbl - #endif - - #define xflminterface struct xflmnovtbl - - XFLM_DEFINE_GUID( Internal_IID_XFLMIUnknown, 0x00000000, 0x0000, 0x0000, - 0xC0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x46); - - xflminterface XFLMIUnknown - { - virtual ~XFLMIUnknown() - { - } - - virtual RCODE XFLMAPI QueryInterface( - RXFLMIID riid, - void ** ppv) = 0; - - virtual FLMINT XFLMAPI AddRef( void) = 0; - - virtual FLMINT XFLMAPI Release( void) = 0; - }; - - // XFLMIClassFactory - // uuid: 00000001-0000-0000-C000-000000000046 (same as MSCOM IClassFactory) - - XFLM_DEFINE_GUID( Internal_IID_XFLMIClassFactory, 0x00000001, 0x0000, 0x0000, - 0xC0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x46); - - xflminterface XFLMIClassFactory : public XFLMIUnknown - { - virtual RCODE XFLMAPI CreateInstance( - XFLMIUnknown * piuouter, - RXFLMIID riid, - void ** ppv) = 0; - - virtual RCODE XFLMAPI LockServer( - bool lockf) = 0; - }; + #include "ftk.h" /**************************************************************************** Forward References ****************************************************************************/ - xflminterface IF_Backup; - xflminterface IF_DataVector; - xflminterface IF_Db; - xflminterface IF_DbInfo; - xflminterface IF_DirHdl; - xflminterface IF_DOMNode; - xflminterface IF_FileHdl; - xflminterface IF_FileSystem; - xflminterface IF_IStream; - xflminterface IF_PosIStream; - xflminterface IF_ResultSet; - xflminterface IF_Query; - xflminterface IF_ThreadInfo; - xflminterface IF_Pool; - xflminterface IF_DynaBuf; - xflminterface IF_NodeInfo; - xflminterface IF_BTreeInfo; + flminterface IF_Backup; + flminterface IF_DataVector; + flminterface IF_Db; + flminterface IF_DbInfo; + flminterface IF_DirHdl; + flminterface IF_DOMNode; + flminterface IF_FileHdl; + flminterface IF_FileSystem; + flminterface IF_IStream; + flminterface IF_PosIStream; + flminterface IF_ResultSet; + flminterface IF_Query; + flminterface IF_ThreadInfo; + flminterface IF_Pool; + flminterface IF_DynaBuf; + flminterface IF_NodeInfo; + flminterface IF_BTreeInfo; // These are interfaces that need to be implemented by // applications. XFlaim uses them to report status or to do // callbacks of various kinds. - xflminterface IF_OStream; - xflminterface IF_BackupClient; - xflminterface IF_BackupStatus; - xflminterface IF_CommitClient; - xflminterface IF_DbCheckStatus; - xflminterface IF_DbCopyStatus; - xflminterface IF_DbRebuildStatus; - xflminterface IF_DbRenameStatus; - xflminterface IF_DeleteStatus; - xflminterface IF_EventClient; - xflminterface IF_IxClient; - xflminterface IF_IxStatus; - xflminterface IF_LockInfoClient; - xflminterface IF_LoggerClient; - xflminterface IF_LogMessageClient; - xflminterface IF_OperandComparer; - xflminterface IF_RestoreClient; - xflminterface IF_RestoreStatus; - xflminterface IF_ResultSetSortStatus; - xflminterface IF_ResultSetCompare; - xflminterface IF_QueryStatus; - xflminterface IF_QueryValidator; - xflminterface IF_QueryValFunc; - xflminterface IF_QueryNodeSource; - xflminterface IF_UpgradeClient; - xflminterface IF_BTreeInfoStatus; + flminterface IF_OStream; + flminterface IF_BackupClient; + flminterface IF_BackupStatus; + flminterface IF_CommitClient; + flminterface IF_DbCheckStatus; + flminterface IF_DbCopyStatus; + flminterface IF_DbRebuildStatus; + flminterface IF_DbRenameStatus; + flminterface IF_DeleteStatus; + flminterface IF_EventClient; + flminterface IF_IxClient; + flminterface IF_IxStatus; + flminterface IF_LockInfoClient; + flminterface IF_LoggerClient; + flminterface IF_LogMessageClient; + flminterface IF_OperandComparer; + flminterface IF_RestoreClient; + flminterface IF_RestoreStatus; + flminterface IF_ResultSetSortStatus; + flminterface IF_ResultSetCompare; + flminterface IF_QueryStatus; + flminterface IF_QueryValidator; + flminterface IF_QueryValFunc; + flminterface IF_QueryNodeSource; + flminterface IF_UpgradeClient; + flminterface IF_BTreeInfoStatus; - /**************************************************************************** - CROSS PLATFORM DEFINITIONS - ****************************************************************************/ - - #ifndef NULL - #define NULL 0 - #endif - - #ifndef TRUE - #define TRUE 1 - #endif - - #ifndef FALSE - #define FALSE 0 - #endif - - // Language definitions - to get rid of testing "US" or multiple bytes - // will define needed languages as a number with backward conversions. - // Keep these defines synchronized with the table in wps6cmpc.c - - #define XFLM_US_LANG 0 // English, United States - #define XFLM_AF_LANG 1 // Afrikaans - #define XFLM_AR_LANG 2 // Arabic - #define XFLM_CA_LANG 3 // Catalan - #define XFLM_HR_LANG 4 // Croatian - #define XFLM_CZ_LANG 5 // Czech - #define XFLM_DK_LANG 6 // Danish - #define XFLM_NL_LANG 7 // Dutch - #define XFLM_OZ_LANG 8 // English, Australia - #define XFLM_CE_LANG 9 // English, Canada - #define XFLM_UK_LANG 10 // English, United Kingdom - #define XFLM_FA_LANG 11 // Farsi - #define XFLM_SU_LANG 12 // Finnish - #define XFLM_CF_LANG 13 // French, Canada - #define XFLM_FR_LANG 14 // French, France - #define XFLM_GA_LANG 15 // Galician - #define XFLM_DE_LANG 16 // German, Germany - #define XFLM_SD_LANG 17 // German, Switzerland - #define XFLM_GR_LANG 18 // Greek - #define XFLM_HE_LANG 19 // Hebrew - #define XFLM_HU_LANG 20 // Hungarian - #define XFLM_IS_LANG 21 // Icelandic - #define XFLM_IT_LANG 22 // Italian - #define XFLM_NO_LANG 23 // Norwegian - #define XFLM_PL_LANG 24 // Polish - #define XFLM_BR_LANG 25 // Portuguese, Brazil - #define XFLM_PO_LANG 26 // Portuguese, Portugal - #define XFLM_RU_LANG 27 // Russian - #define XFLM_SL_LANG 28 // Slovak - #define XFLM_ES_LANG 29 // Spanish - #define XFLM_SV_LANG 30 // Swedish - #define XFLM_YK_LANG 31 // Ukrainian - #define XFLM_UR_LANG 32 // Urdu - #define XFLM_TK_LANG 33 // Turkey - #define XFLM_JP_LANG 34 // Japanese - #define XFLM_KO_LANG 35 // Korean - #define XFLM_CT_LANG 36 // Chinese-Traditional - #define XFLM_CS_LANG 37 // Chinese-Simplified - #define XFLM_LA_LANG 38 // another Asian language - /**************************************************************************** Desc: This structure is used as a parameter to dbCreate to specify the create options for a database. It is also optionally returned @@ -494,25 +88,22 @@ typedef struct { FLMUINT uiBlockSize; - #define XFLM_DEFAULT_BLKSIZ 4096 - - FLMUINT uiVersionNum; // Database version number - #define XFLM_VER_5_12 512 - #define XFLM_CURRENT_VERSION_NUM XFLM_VER_5_12 - #define XFLM_CURRENT_VER_STR "5.12" - - FLMUINT uiMinRflFileSize; // Minimum bytes per RFL file + #define XFLM_DEFAULT_BLKSIZ 4096 + FLMUINT uiVersionNum; + #define XFLM_VER_5_12 512 + #define XFLM_CURRENT_VERSION_NUM XFLM_VER_5_12 + #define XFLM_CURRENT_VER_STR "5.12" + FLMUINT uiMinRflFileSize; #define XFLM_DEFAULT_MIN_RFL_FILE_SIZE ((FLMUINT)100 * (FLMUINT)1024 * (FLMUINT)1024) - FLMUINT uiMaxRflFileSize; // Maximum bytes per RFL file - #define XFLM_DEFAULT_MAX_RFL_FILE_SIZE XFLM_MAXIMUM_FILE_SIZE - FLMBOOL bKeepRflFiles; // Keep RFL files? + FLMUINT uiMaxRflFileSize; + #define XFLM_DEFAULT_MAX_RFL_FILE_SIZE FLM_MAXIMUM_FILE_SIZE + FLMBOOL bKeepRflFiles; #define XFLM_DEFAULT_KEEP_RFL_FILES_FLAG FALSE - FLMBOOL bLogAbortedTransToRfl; // Log aborted transactions to RFL? + FLMBOOL bLogAbortedTransToRfl; #define XFLM_DEFAULT_LOG_ABORTED_TRANS_FLAG FALSE FLMUINT uiDefaultLanguage; - #define XFLM_DEFAULT_LANG (XFLM_US_LANG) - + #define XFLM_DEFAULT_LANG (FLM_US_LANG) } XFLM_CREATE_OPTS, F_CREATE_OPTS; typedef enum @@ -610,7 +201,7 @@ // that its copy of these items inside the FDB structure are current. FLMBYTE szSignature[ 8]; // Contains the string "FLAIMDB" - #define XFLM_DB_SIGNATURE "FLAIMDB" + #define XFLM_DB_SIGNATURE "FLAIMDB" FLMUINT8 ui8IsLittleEndian; // Non-zero if DB is little-endian #ifdef FLM_BIG_ENDIAN #define XFLM_NATIVE_IS_LITTLE_ENDIAN 0 @@ -737,26 +328,6 @@ #define XFLM_DB_HDR_DbKey 256 } XFLM_DB_HDR; - /**************************************************************************** - Desc: IO Flags - ****************************************************************************/ - #define XFLM_IO_CURRENT_POS FLM_MAX_UINT64 - - #define XFLM_IO_RDONLY 0x0001 - #define XFLM_IO_RDWR 0x0002 - #define XFLM_IO_EXCL 0x0004 - #define XFLM_IO_CREATE_DIR 0x0008 - #define XFLM_IO_SH_DENYRW 0x0010 - #define XFLM_IO_SH_DENYWR 0x0020 - #define XFLM_IO_SH_DENYNONE 0x0040 - #define XFLM_IO_DIRECT 0x0080 - - // File Positioning Definitions - - #define XFLM_IO_SEEK_SET 0 // Beginning of File - #define XFLM_IO_SEEK_CUR 1 // Current File Pointer Position - #define XFLM_IO_SEEK_END 2 // End of File - // uiFlags values for keyRetrieve() method #define XFLM_INCL 0x0010 @@ -777,10 +348,6 @@ #define XFLM_SKIP_DOM_LINK_CHECK 0x0200 // Used only in dbCheck. #define XFLM_ALLOW_LIMITED_MODE 0x0400 - // Maximum file size - - #define XFLM_MAXIMUM_FILE_SIZE 0xFFFC0000 - // Maximum key size #define XFLM_MAX_KEY_SIZE 1024 @@ -954,28 +521,6 @@ XFLM_NUM_MESSAGE_TYPES } eLogMessageType; - typedef enum - { - XFLM_CURRENT_COLOR, - XFLM_BLACK, - XFLM_BLUE, - XFLM_GREEN, - XFLM_CYAN, - XFLM_RED, - XFLM_PURPLE, - XFLM_BROWN, - XFLM_LIGHTGRAY, - XFLM_DARKGRAY, - XFLM_LIGHTBLUE, - XFLM_LIGHTGREEN, - XFLM_LIGHTCYAN, - XFLM_LIGHTRED, - XFLM_LIGHTPURPLE, - XFLM_YELLOW, - XFLM_WHITE, - XFLM_NUM_COLORS - } eColorType; - typedef struct { FLMBOOL bRunning; @@ -994,14 +539,6 @@ FLMUINT uiWaitTruncateTime; } XFLM_CHECKPOINT_INFO; - typedef struct - { - FLMUINT64 ui64Slabs; - FLMUINT64 ui64SlabBytes; - FLMUINT64 ui64AllocatedCells; - FLMUINT64 ui64FreeCells; - } XFLM_SLAB_USAGE; - typedef struct { FLMUINT uiByteCount; @@ -1012,7 +549,7 @@ FLMUINT uiCacheHitLooks; FLMUINT uiCacheFaults; FLMUINT uiCacheFaultLooks; - XFLM_SLAB_USAGE slabUsage; + FLM_SLAB_USAGE slabUsage; } XFLM_CACHE_USAGE; typedef struct @@ -1336,25 +873,25 @@ // Comparison rules for strings - #define XFLM_COMP_CASE_INSENSITIVE 0x0001 - #define XFLM_COMP_COMPRESS_WHITESPACE 0x0002 + #define XFLM_COMP_CASE_INSENSITIVE FLM_COMP_CASE_INSENSITIVE + #define XFLM_COMP_COMPRESS_WHITESPACE FLM_COMP_COMPRESS_WHITESPACE // Compress consecutive spaces to single space - #define XFLM_COMP_NO_WHITESPACE 0x0004 + #define XFLM_COMP_NO_WHITESPACE FLM_COMP_NO_WHITESPACE // Ignore all whitespace. This and // COMP_COMPRESS_WHITESPACE cannot be used // together. - #define XFLM_COMP_NO_UNDERSCORES 0x0008 + #define XFLM_COMP_NO_UNDERSCORES FLM_COMP_NO_UNDERSCORES // Convert underscores to whitespace. NOTE: This // should be applied before COMP_COMPRESS_WHITESPACE // or COMP_NO_WHITESPACE - #define XFLM_COMP_NO_DASHES 0x0010 + #define XFLM_COMP_NO_DASHES FLM_COMP_NO_DASHES // Remove all dashes - #define XFLM_COMP_WHITESPACE_AS_SPACE 0x0020 + #define XFLM_COMP_WHITESPACE_AS_SPACE FLM_COMP_WHITESPACE_AS_SPACE // Convert tab, NL, and CR characters // to space - #define XFLM_COMP_IGNORE_LEADING_SPACE 0x0040 + #define XFLM_COMP_IGNORE_LEADING_SPACE FLM_COMP_IGNORE_LEADING_SPACE // Ignore leading space characters - #define XFLM_COMP_IGNORE_TRAILING_SPACE 0x0080 + #define XFLM_COMP_IGNORE_TRAILING_SPACE FLM_COMP_IGNORE_TRAILING_SPACE // Ignore trailing space characters typedef enum @@ -1705,65 +1242,6 @@ #define XFLM_INI_MAX_DIRTY_CACHE "maxdirtycache" #define XFLM_INI_LOW_DIRTY_CACHE "lowdirtycache" - /**************************************************************************** - Desc: Reference Counting class - ****************************************************************************/ - class XF_RefCount - { - public: - - XF_RefCount() - { - m_refCnt = 1; - } - - virtual ~XF_RefCount() - { - } - - virtual FINLINE FLMUINT getRefCount( void) - { - return( m_refCnt); - } - - virtual FINLINE FLMINT XFLMAPI AddRef( void) - { - return( ++m_refCnt); - } - - virtual FINLINE FLMINT XFLMAPI Release( void) - { - FLMINT iRefCnt = --m_refCnt; - - if( !iRefCnt) - { - delete this; - } - - return( iRefCnt); - } - - protected: - - FLMATOMIC m_refCnt; - }; - - // Class ID for the F_DbSystemFactory class (which is defined in fcompub.h). - // We don't need a separate interface definition because it implements the - // well-known PCIClassFactory interface. - - // {EBF905EE-43F1-45e1-A477-6C459AF26F76} - XFLM_DEFINE_GUID( Internal_CLSID_F_DbSystemFactory, 0xebf905ee, 0x43f1, - 0x45e1, 0xa4, 0x77, 0x6c, 0x45, 0x9a, 0xf2, 0x6f, 0x76); - - #define CLSID_F_DbSystemFactory (s_guid &)(Internal_CLSID_F_DbSystemFactory) - - // {B3A01545-F5F9-4618-AC6E-5FD606BF8F92} - XFLM_DEFINE_GUID(Internal_IID_IF_DbSystem, 0xb3a01545, 0xf5f9, 0x4618, - 0xac, 0x6e, 0x5f, 0xd6, 0x6, 0xbf, 0x8f, 0x92); - - #define IID_IF_DbSystem (s_guid &)(Internal_IID_IF_DbSystem) - // Defaults for certain other settable items in the IF_DbSystem #define XFLM_DEFAULT_MAX_CP_INTERVAL 180 @@ -1795,7 +1273,7 @@ * intermittently or throughout the life of the database system. The class id for * this interface is CLSID_F_DbSystemFactory and the interface id is IID_IF_DbSystem. */ - xflminterface IF_DbSystem : public XFLMIUnknown + flminterface IF_DbSystem : public F_Object { /** * @brief Initializes the database system object. @@ -1805,9 +1283,9 @@ * method is called, there must be a corresponding call to exit. The database engine * will only shut down on the last call to exit. */ - virtual RCODE XFLMAPI init( void) = 0; + virtual RCODE FLMAPI init( void) = 0; - virtual RCODE XFLMAPI updateIniFile( + virtual RCODE FLMAPI updateIniFile( const char * pszParamName, const char * pszValue) = 0; @@ -1817,7 +1295,7 @@ * The exit method is used to shutdown the database system engine. This routine allows * itself to be called multiple times, even before init is called or if the call to init fails. */ - virtual void XFLMAPI exit() = 0; + virtual void FLMAPI exit() = 0; /** * @brief Return an IF_FileSystem object for performing file system operations. @@ -1828,7 +1306,7 @@ * @param ppFileSystem A pointer to a file system object that can * be used to perform various operations on files. */ - virtual void XFLMAPI getFileSystem( + virtual void FLMAPI getFileSystem( IF_FileSystem ** ppFileSystem) = 0; /** @@ -1862,7 +1340,7 @@ * @param ppDb A pointer to a database object that references the newly created database. * @return RCODE */ - virtual RCODE XFLMAPI dbCreate( + virtual RCODE FLMAPI dbCreate( const char * pszDbFileName, const char * pszDataDir, const char * pszRflDir, @@ -1891,7 +1369,7 @@ * @param ppDb A pointer to a database object that references the newly created database. * @return RCODE */ - virtual RCODE XFLMAPI dbOpen( + virtual RCODE FLMAPI dbOpen( const char * pszDbFileName, const char * pszDataDir, const char * pszRflDir, @@ -1943,7 +1421,7 @@ * @param pui64NodesDiscardedDocs The total number of documents that couldn't be recovered. * @return RCODE */ - virtual RCODE XFLMAPI dbRebuild( + virtual RCODE FLMAPI dbRebuild( const char * pszSourceDbPath, const char * pszSourceDataDir, const char * pszDestDbPath, @@ -1984,7 +1462,7 @@ * a B-tree, number of keys, etc. Methods of the IF_DbInfo object provide for retrieval of this information. * @return RCODE */ - virtual RCODE XFLMAPI dbCheck( + virtual RCODE FLMAPI dbCheck( const char * pszDbFileName, const char * pszDataDir, const char * pszRflDir, @@ -2030,7 +1508,7 @@ * methods of that interface. Those methods may be called by dbCopy to report copy progress. * @return RCODE */ - virtual RCODE XFLMAPI dbCopy( + virtual RCODE FLMAPI dbCopy( const char * pszSrcDbName, const char * pszSrcDataDir, const char * pszSrcRflDir, @@ -2070,7 +1548,7 @@ * interface and implements the pure virtual methods of that interface. * @return RCODE */ - virtual RCODE XFLMAPI dbRename( + virtual RCODE FLMAPI dbRename( const char * pszDbName, const char * pszDataDir, const char * pszRflDir, @@ -2098,7 +1576,7 @@ * @param bRemoveRflFiles A flag that indicate whether or not the RFL file(s) should be removed as well. * @return RCODE */ - virtual RCODE XFLMAPI dbRemove( + virtual RCODE FLMAPI dbRemove( const char * pszDbName, const char * pszDataDir, const char * pszRflDir, @@ -2134,7 +1612,7 @@ * The application is responsible for implementing this object. * @return RCODE */ - virtual RCODE XFLMAPI dbRestore( + virtual RCODE FLMAPI dbRestore( const char * pszDbPath, const char * pszDataDir, const char * pszRflDir, @@ -2167,7 +1645,7 @@ * @param ppDb A new database object. * @return RCODE */ - virtual RCODE XFLMAPI dbDup( + virtual RCODE FLMAPI dbDup( IF_Db * pDb, IF_Db ** ppDb) = 0; @@ -2180,7 +1658,7 @@ * @param rc The RCODE to be translated. * @return const char * */ - virtual const char * XFLMAPI errorString( + virtual const char * FLMAPI errorString( RCODE rc) = 0; /** @@ -2192,7 +1670,7 @@ * @param iErrCode The error code to be translated. * @return const char * */ - virtual const char * XFLMAPI checkErrorToStr( + virtual const char * FLMAPI checkErrorToStr( FLMINT iCheckErrorCode) = 0; /** @@ -2207,7 +1685,7 @@ * @param ppIStream The input stream object used to read the data in. * @return RCODE */ - virtual RCODE XFLMAPI openBufferIStream( + virtual RCODE FLMAPI openBufferIStream( const char * pucBuffer, FLMUINT uiLength, IF_PosIStream ** ppIStream) = 0; @@ -2223,7 +1701,7 @@ * @param ppIStream The input stream object used to read the data in. * @return RCODE */ - virtual RCODE XFLMAPI openFileIStream( + virtual RCODE FLMAPI openFileIStream( const char * pszPath, IF_PosIStream ** ppIStream) = 0; @@ -2235,7 +1713,7 @@ * more files to read from. File names start with pszBaseName, then * pszBaseName.00000001, pszBaseName.00000002, etc. The extension is a hex number. */ - virtual RCODE XFLMAPI openMultiFileIStream( + virtual RCODE FLMAPI openMultiFileIStream( const char * pszDirectory, const char * pszBaseName, IF_IStream ** ppIStream) = 0; @@ -2249,7 +1727,7 @@ * until pIStream has no more data to return. This method allows any input stream * to be turned into a buffered stream. */ - virtual RCODE XFLMAPI openBufferedIStream( + virtual RCODE FLMAPI openBufferedIStream( IF_IStream * pIStream, FLMUINT uiBufferSize, IF_IStream ** ppIStream) = 0; @@ -2260,7 +1738,7 @@ * When (*ppIStream)->read() is called, it will read and uncompress data from * pIStream. */ - virtual RCODE XFLMAPI openUncompressingIStream( + virtual RCODE FLMAPI openUncompressingIStream( IF_IStream * pIStream, IF_IStream ** ppIStream) = 0; @@ -2272,7 +1750,7 @@ * Data is written out to the specified file. The file may be created, overwritten, or * appended to, depending on iAccessFlags. */ - virtual RCODE XFLMAPI openFileOStream( + virtual RCODE FLMAPI openFileOStream( const char * pszFileName, FLMBOOL bTruncateIfExists, IF_OStream ** ppOStream) = 0; @@ -2285,7 +1763,7 @@ * be created by appending a suffix with an incrementing HEX number. The * bOverwrite flag indicates whether to overwrite files that already exist. */ - virtual RCODE XFLMAPI openMultiFileOStream( + virtual RCODE FLMAPI openMultiFileOStream( const char * pszDirectory, const char * pszBaseName, FLMUINT uiMaxFileSize, @@ -2295,7 +1773,7 @@ /** * @brief Remove a multi-file stream */ - virtual RCODE XFLMAPI removeMultiFileStream( + virtual RCODE FLMAPI removeMultiFileStream( const char * pszDirectory, const char * pszBaseName) = 0; @@ -2305,7 +1783,7 @@ * As data is written to *ppOStream, it is buffered before ultimately being * written to pOStream. */ - virtual RCODE XFLMAPI openBufferedOStream( + virtual RCODE FLMAPI openBufferedOStream( IF_OStream * pOStream, FLMUINT uiBufferSize, IF_OStream ** ppOStream) = 0; @@ -2316,7 +1794,7 @@ * As data is written to *ppOStream, it is compressed before ultimately being * written to pOStream. */ - virtual RCODE XFLMAPI openCompressingOStream( + virtual RCODE FLMAPI openCompressingOStream( IF_OStream * pOStream, IF_OStream ** ppOStream) = 0; @@ -2324,7 +1802,7 @@ * @brief All data is read from the input stream (pIStream) and written * to the output stream (pOStream). This goes until pIStream returns EOF. */ - virtual RCODE XFLMAPI writeToOStream( + virtual RCODE FLMAPI writeToOStream( IF_IStream * pIStream, IF_OStream * pOStream) = 0; @@ -2340,7 +1818,7 @@ * @param ppEncodedStream The stream object used to read the encoded data. * @return RCODE */ - virtual RCODE XFLMAPI openBase64Encoder( + virtual RCODE FLMAPI openBase64Encoder( IF_IStream * pInputStream, FLMBOOL bInsertLineBreaks, IF_IStream ** ppEncodedStream) = 0; @@ -2355,7 +1833,7 @@ * @param ppDecodedStream The stream object used to read the decoded data. * @return RCODE */ - virtual RCODE XFLMAPI openBase64Decoder( + virtual RCODE FLMAPI openBase64Decoder( IF_IStream * pInputStream, IF_IStream ** ppDecodedStream) = 0; @@ -2368,7 +1846,7 @@ * @param ifppDV The IF_DataVector object. * @return RCODE */ - virtual RCODE XFLMAPI createIFDataVector( + virtual RCODE FLMAPI createIFDataVector( IF_DataVector ** ifppDV) = 0; /** @@ -2379,7 +1857,7 @@ * @param ifppResultSet The IF_ResultSet object. * @return RCODE */ - virtual RCODE XFLMAPI createIFResultSet( + virtual RCODE FLMAPI createIFResultSet( IF_ResultSet ** ifppResultSet) = 0; /** @@ -2390,7 +1868,7 @@ * @param ifppQuery The IF_Query object. * @return RCODE */ - virtual RCODE XFLMAPI createIFQuery( + virtual RCODE FLMAPI createIFQuery( IF_Query ** ifppQuery) = 0; /** @@ -2403,7 +1881,7 @@ * @param ppMem Pointer to the pointer of the memory to be freed. When the memory is * successfully freed, the pointer will be set to NULL */ - virtual void XFLMAPI freeMem( + virtual void FLMAPI freeMem( void ** ppMem) = 0; // Various configuration routines @@ -2427,7 +1905,7 @@ * That calculated number becomes the effective maximum to adjust to. * @return RCODE */ - virtual RCODE XFLMAPI setDynamicMemoryLimit( + virtual RCODE FLMAPI setDynamicMemoryLimit( FLMUINT uiCacheAdjustPercent, FLMUINT uiCacheAdjustMin, FLMUINT uiCacheAdjustMax, @@ -2463,7 +1941,7 @@ * starts up, rather than allow it to grow as needed. The default value to FALSE. * @return RCODE */ - virtual RCODE XFLMAPI setHardMemoryLimit( + virtual RCODE FLMAPI setHardMemoryLimit( FLMUINT uiPercent, FLMBOOL bPercentOfAvail, FLMUINT uiMin, @@ -2479,7 +1957,7 @@ * * @return FLMBOOL TRUE=supported or FALSE=not supported. */ - virtual FLMBOOL XFLMAPI getDynamicCacheSupported( void) = 0; + virtual FLMBOOL FLMAPI getDynamicCacheSupported( void) = 0; /** * @brief Query the database system for information regarding the current cache usage. @@ -2488,7 +1966,7 @@ * * @param pCacheInfo The cache info structure. */ - virtual void XFLMAPI getCacheInfo( + virtual void FLMAPI getCacheInfo( XFLM_CACHE_INFO * pCacheInfo) = 0; /** @@ -2499,7 +1977,7 @@ * * @param bDebug A boolean to indicate whether to enable or disable cache debug mode. */ - virtual void XFLMAPI enableCacheDebug( + virtual void FLMAPI enableCacheDebug( FLMBOOL bDebug) = 0; /** @@ -2509,7 +1987,7 @@ * * @return FLMBOOL True or False */ - virtual FLMBOOL XFLMAPI cacheDebugEnabled( void) = 0; + virtual FLMBOOL FLMAPI cacheDebugEnabled( void) = 0; /** * @brief Close all file handles (descriptors) that have not been used for a specified @@ -2524,68 +2002,29 @@ * (descriptors), regardless of how long they have been unused. * @return RCODE */ - virtual RCODE XFLMAPI closeUnusedFiles( + virtual RCODE FLMAPI closeUnusedFiles( FLMUINT uiSeconds) = 0; - /** - * @brief Set the threshold for the number of file handles (descriptors) that can be - * opened by the database system. - * - * This is a method to set the maximum number of file handles (descriptors) that can - * be kept open by the database system. - * - * @param uiThreshold The number of file handles (descriptors) that can be open at any - * one time. The default threshold is 65535. IMPORTANT NOTE: It is possible for the - * database system to temporarily have more file handles (descriptors) open than the - * specified threshold. It does this when all available file handles (descriptors) - * are in use and it needs to open a file to perform database work. However, as soon as - * it can, the database system will close file handles (descriptors) until it comes back - * down below the specified threshold. - */ - virtual void XFLMAPI setOpenThreshold( - FLMUINT uiThreshold) = 0; - - /** - * @brief Get the threshold for the number of file handles that can be opened by the - * database system. - * - * This method returns the threshold for the number of file handles (descriptors) that - * can be held open by the database system. - * - * @return FLMUINT The open threshold. - */ - virtual FLMUINT XFLMAPI getOpenThreshold( void) = 0; - - /** - * @brief Get the number of files that are currently open in the database system. - * - * This method returns the number of file handles (descriptors) that are currently - * open in the database system. - * - * @return FLMUINT The open file count - */ - virtual FLMUINT XFLMAPI getOpenFileCount( void) = 0; - /** * @brief Start the collection of statistics on the database system. * * This method starts the collection of statistics on the database system. */ - virtual void XFLMAPI startStats( void) = 0; + virtual void FLMAPI startStats( void) = 0; /** * @brief Stop the collection of statistics on the database system. * * This method stops the collection of statistics on the database system. */ - virtual void XFLMAPI stopStats( void) = 0; + virtual void FLMAPI stopStats( void) = 0; /** * @brief Reset the statistics counters on the database system. * * This method resets the statistics counters on the database system. */ - virtual void XFLMAPI resetStats( void) = 0; + virtual void FLMAPI resetStats( void) = 0; /** * @brief Retrieve the statistics from the database system. @@ -2595,7 +2034,7 @@ * @param pFlmStats The structure where statistics are returned. * @return RCODE */ - virtual RCODE XFLMAPI getStats( + virtual RCODE FLMAPI getStats( XFLM_STATS * pFlmStats) = 0; /** @@ -2607,7 +2046,7 @@ * * @param pFlmStats The statistics structure whose memory allocations are to be freed. */ - virtual void XFLMAPI freeStats( + virtual void FLMAPI freeStats( XFLM_STATS * pFlmStats) = 0; /** @@ -2618,19 +2057,19 @@ * @param pszPath The temporary directory path. * @return RCODE */ - virtual RCODE XFLMAPI setTempDir( + virtual RCODE FLMAPI setTempDir( const char * pszPath) = 0; /** * @brief Get the directory where temporary files are created. * * This method returns the directory name where temporary files are created. - * If no temporary directory is set, this function returns NE_XFLM_IO_PATH_NOT_FOUND. + * If no temporary directory is set, this function returns NE_FLM_IO_PATH_NOT_FOUND. * * @param pszPath The temporary directory path is returned here. * @return RCODE */ - virtual RCODE XFLMAPI getTempDir( + virtual RCODE FLMAPI getTempDir( char * pszPath) = 0; /** @@ -2667,7 +2106,7 @@ * active. If an update transaction is active and runs for a long time, the time * between completed checkpoints could exceed the time specified in this method. */ - virtual void XFLMAPI setCheckpointInterval( + virtual void FLMAPI setCheckpointInterval( FLMUINT uiSeconds) = 0; /** @@ -2676,7 +2115,7 @@ * This method returns the current checkpoint interval. * @return FLMUINT The current checkpoint interval (seconds). */ - virtual FLMUINT XFLMAPI getCheckpointInterval( void) = 0; + virtual FLMUINT FLMAPI getCheckpointInterval( void) = 0; /** * @brief Set the time interval for dynamically adjusting the cache limit. @@ -2685,7 +2124,7 @@ * * @param uiSeconds The time interval for dynamically adjusting the cache limit. */ - virtual void XFLMAPI setCacheAdjustInterval( + virtual void FLMAPI setCacheAdjustInterval( FLMUINT uiSeconds) = 0; /** @@ -2695,7 +2134,7 @@ * * @return FLMUINT The curernt cache adjust interval (seconds). */ - virtual FLMUINT XFLMAPI getCacheAdjustInterval( void) = 0; + virtual FLMUINT FLMAPI getCacheAdjustInterval( void) = 0; /** * @brief Set the time interval for dynamically cleaning out old cache blocks from block cache. @@ -2704,7 +2143,7 @@ * * @param uiSeconds The time interval for dynamically cleaning out old cache blocks. */ - virtual void XFLMAPI setCacheCleanupInterval( + virtual void FLMAPI setCacheCleanupInterval( FLMUINT uiSeconds) = 0; /** @@ -2714,7 +2153,7 @@ * * @return FLMUINT The current cache cleanup inerval (seconds). */ - virtual FLMUINT XFLMAPI getCacheCleanupInterval( void) = 0; + virtual FLMUINT FLMAPI getCacheCleanupInterval( void) = 0; /** * @brief Set time interval for cleaning up unused resources (such as file handles). @@ -2723,7 +2162,7 @@ * * @param uiSeconds The time interval for cleaning up unused resources (such as file handles). */ - virtual void XFLMAPI setUnusedCleanupInterval( + virtual void FLMAPI setUnusedCleanupInterval( FLMUINT uiSeconds) = 0; /** @@ -2733,7 +2172,7 @@ * * @return FLMUINT The current unused cleanup interval (seconds). */ - virtual FLMUINT XFLMAPI getUnusedCleanupInterval( void) = 0; + virtual FLMUINT FLMAPI getUnusedCleanupInterval( void) = 0; /** * @brief Set maximum time for a resource (such as a file handle) to be unused before it is cleaned up. @@ -2744,7 +2183,7 @@ * @param uiSeconds The maximum time for a resource (such as a file handle) to be unused before it is * cleaned up. */ - virtual void XFLMAPI setMaxUnusedTime( + virtual void FLMAPI setMaxUnusedTime( FLMUINT uiSeconds) = 0; /** @@ -2755,14 +2194,14 @@ * * @return FLMUINT The current maximum unused time (seconds). */ - virtual FLMUINT XFLMAPI getMaxUnusedTime( void) = 0; + virtual FLMUINT FLMAPI getMaxUnusedTime( void) = 0; /** * @brief Set the logger client. * * @param pLogger Pointer to the logger client object. */ - virtual void XFLMAPI setLogger( + virtual void FLMAPI setLogger( IF_LoggerClient * pLogger) = 0; /** @@ -2771,7 +2210,7 @@ * @param bEnable A boolean flag. When TRUE, Extended Server Memory is enabled. * When FALSE, Extended Server Memory is disabled. */ - virtual void XFLMAPI enableExtendedServerMemory( + virtual void FLMAPI enableExtendedServerMemory( FLMBOOL bEnable) = 0; /** @@ -2779,7 +2218,7 @@ * * @return FLMBOOL True if enabled, otherwise False. */ - virtual FLMBOOL XFLMAPI extendedServerMemoryEnabled( void) = 0; + virtual FLMBOOL FLMAPI extendedServerMemoryEnabled( void) = 0; /** * @brief Deactivate open database objects, forcing the database(s) to eventually be closed. @@ -2797,7 +2236,7 @@ * (as specified by the pszDbFileName parameter). See the XFlaim Concepts/Database Files for * a discussion on the different database files. */ - virtual void XFLMAPI deactivateOpenDb( + virtual void FLMAPI deactivateOpenDb( const char * pszDatabasePath, const char * pszDataFilePath) = 0; @@ -2808,7 +2247,7 @@ * * @param uiMaxToSave The maximum number of queries to save. */ - virtual void XFLMAPI setQuerySaveMax( + virtual void FLMAPI setQuerySaveMax( FLMUINT uiMaxToSave) = 0; /** @@ -2818,7 +2257,7 @@ * * @return FLMUINT The maximum number of queries to save. */ - virtual FLMUINT XFLMAPI getQuerySaveMax( void) = 0; + virtual FLMUINT FLMAPI getQuerySaveMax( void) = 0; /** * @brief Set the minimum and maximum dirty cache limits. @@ -2849,7 +2288,7 @@ * @param uiMaxDirty The maximum amount (in bytes) of dirty cache allowed. * @param uiLowDirty The low threshold (in bytes) for dirty cache. */ - virtual void XFLMAPI setDirtyCacheLimits( + virtual void FLMAPI setDirtyCacheLimits( FLMUINT uiMaxDirty, FLMUINT uiLowDirty) = 0; @@ -2861,7 +2300,7 @@ * @param puiMaxDirty The maximum number of dirty blocks allowed in the cache. * @param puiLowDirty The low threshold for the number of dirty blocks in cache. */ - virtual void XFLMAPI getDirtyCacheLimits( + virtual void FLMAPI getDirtyCacheLimits( FLMUINT * puiMaxDirty, FLMUINT * puiLowDirty) = 0; @@ -2876,7 +2315,7 @@ * * @return RCODE */ - virtual RCODE XFLMAPI getThreadInfo( + virtual RCODE FLMAPI getThreadInfo( IF_ThreadInfo ** ifppThreadInfo) = 0; /** @@ -2889,7 +2328,7 @@ * * @return RCODE */ - virtual RCODE XFLMAPI registerForEvent( + virtual RCODE FLMAPI registerForEvent( eEventCategory eCategory, IF_EventClient * ifpEventClient) = 0; @@ -2905,7 +2344,7 @@ * registered for an event, XFlaim can know exactly which object to * deregister. */ - virtual void XFLMAPI deregisterForEvent( + virtual void FLMAPI deregisterForEvent( eEventCategory eCategory, IF_EventClient * ifpEventClient) = 0; @@ -2922,7 +2361,7 @@ * * @return RCODE */ - virtual RCODE XFLMAPI getNextMetaphone( + virtual RCODE FLMAPI getNextMetaphone( IF_IStream * ifpIStream, FLMUINT * puiMetaphone, FLMUINT * puiAltMetaphone = NULL) = 0; @@ -2930,13 +2369,13 @@ /** * @brief Return an IF_Pool object for memory allocations */ - virtual RCODE XFLMAPI createMemoryPool( + virtual RCODE FLMAPI createMemoryPool( IF_Pool ** ppPool) = 0; /** * @brief Compares two UTF-8 strings */ - virtual RCODE XFLMAPI compareUTF8Strings( + virtual RCODE FLMAPI compareUTF8Strings( const FLMBYTE * pucLString, FLMUINT uiLStrBytes, FLMBOOL bLeftWild, @@ -2950,7 +2389,7 @@ /** * @brief Compares two Unicode strings */ - virtual RCODE XFLMAPI compareUnicodeStrings( + virtual RCODE FLMAPI compareUnicodeStrings( const FLMUNICODE * puzLString, FLMUINT uiLStrBytes, FLMBOOL bLeftWild, @@ -2961,26 +2400,26 @@ FLMUINT uiLanguage, FLMINT * piResult) = 0; - virtual RCODE XFLMAPI utf8IsSubStr( + virtual RCODE FLMAPI utf8IsSubStr( const FLMBYTE * pszString, const FLMBYTE * pszSubString, FLMUINT uiCompareRules, FLMUINT uiLanguage, FLMBOOL * pbExists) = 0; - virtual FLMBOOL XFLMAPI uniIsUpper( + virtual FLMBOOL FLMAPI uniIsUpper( FLMUNICODE uzChar) = 0; - virtual FLMBOOL XFLMAPI uniIsLower( + virtual FLMBOOL FLMAPI uniIsLower( FLMUNICODE uzChar) = 0; - virtual FLMBOOL XFLMAPI uniIsAlpha( + virtual FLMBOOL FLMAPI uniIsAlpha( FLMUNICODE uzChar) = 0; - virtual FLMBOOL XFLMAPI uniIsDecimalDigit( + virtual FLMBOOL FLMAPI uniIsDecimalDigit( FLMUNICODE uzChar) = 0; - virtual FLMUNICODE XFLMAPI uniToLower( + virtual FLMUNICODE FLMAPI uniToLower( FLMUNICODE uzChar) = 0; // When the nextUCS2Char method is called, the UCS-2 version of the character @@ -2990,12 +2429,12 @@ // Note: Remember to keep a copy of the pointer to the start of the // string, because whatever is passed in as ppszUTF8 will be modified. - virtual RCODE XFLMAPI nextUCS2Char( + virtual RCODE FLMAPI nextUCS2Char( const FLMBYTE ** ppszUTF8, const FLMBYTE * pszEndOfUTF8String, FLMUNICODE * puzChar) = 0; - virtual RCODE XFLMAPI numUCS2Chars( + virtual RCODE FLMAPI numUCS2Chars( const FLMBYTE * pszUTF8, FLMUINT * puiNumChars) = 0; @@ -3007,7 +2446,7 @@ * * @return RCODE */ - virtual RCODE XFLMAPI waitToClose( + virtual RCODE FLMAPI waitToClose( const char * pszDbFileName) = 0; /** @@ -3018,7 +2457,7 @@ * @param ifppNodeInfo The IF_NodeInfo object. * @return RCODE */ - virtual RCODE XFLMAPI createIFNodeInfo( + virtual RCODE FLMAPI createIFNodeInfo( IF_NodeInfo ** ifppNodeInfo) = 0; /** @@ -3029,7 +2468,7 @@ * @param ifppBTreeInfo The IF_BTreeInfo object. * @return RCODE */ - virtual RCODE XFLMAPI createIFBTreeInfo( + virtual RCODE FLMAPI createIFBTreeInfo( IF_BTreeInfo ** ifppBTreeInfo) = 0; /** @@ -3042,7 +2481,7 @@ * * @return RCODE */ - virtual RCODE XFLMAPI clearCache( + virtual RCODE FLMAPI clearCache( IF_Db * pDb) = 0; }; @@ -3059,45 +2498,45 @@ * using COM. * -------------------------------------------------------------------- */ - XFLMEXP RCODE XFLMAPI FlmAllocDbSystem( + FLMEXP RCODE FLMAPI FlmAllocDbSystem( IF_DbSystem ** ppDbSystem); /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_Db : public XF_RefCount + flminterface IF_Db : public F_Object { - virtual RCODE XFLMAPI transBegin( + virtual RCODE FLMAPI transBegin( eDbTransType eTransType, FLMUINT uiMaxLockWait = XFLM_NO_TIMEOUT, FLMUINT uiFlags = 0, XFLM_DB_HDR * pDbHeader = NULL) = 0; - virtual RCODE XFLMAPI transBegin( + virtual RCODE FLMAPI transBegin( IF_Db * pDb) = 0; - virtual RCODE XFLMAPI transCommit( + virtual RCODE FLMAPI transCommit( FLMBOOL * pbEmpty = NULL) = 0; - virtual RCODE XFLMAPI transAbort( void) = 0; + virtual RCODE FLMAPI transAbort( void) = 0; - virtual eDbTransType XFLMAPI getTransType( void) = 0; + virtual eDbTransType FLMAPI getTransType( void) = 0; - virtual RCODE XFLMAPI doCheckpoint( + virtual RCODE FLMAPI doCheckpoint( FLMUINT uiTimeout) = 0; - virtual RCODE XFLMAPI dbLock( + virtual RCODE FLMAPI dbLock( eDbLockType eLockType, FLMINT iPriority, FLMUINT uiTimeout) = 0; - virtual RCODE XFLMAPI dbUnlock( void) = 0; + virtual RCODE FLMAPI dbUnlock( void) = 0; - virtual RCODE XFLMAPI getLockType( + virtual RCODE FLMAPI getLockType( eDbLockType * peLockType, FLMBOOL * pbImplicit) = 0; - virtual RCODE XFLMAPI getLockInfo( + virtual RCODE FLMAPI getLockInfo( FLMINT iPriority, eDbLockType * peCurrLockType, FLMUINT * puiThreadId, @@ -3105,204 +2544,204 @@ FLMUINT * puiNumSharedQueued, FLMUINT * puiPriorityCount) = 0; - virtual RCODE XFLMAPI indexStatus( + virtual RCODE FLMAPI indexStatus( FLMUINT uiIndexNum, XFLM_INDEX_STATUS * pIndexStatus) = 0; - virtual RCODE XFLMAPI indexGetNext( + virtual RCODE FLMAPI indexGetNext( FLMUINT * puiIndexNum) = 0; - virtual RCODE XFLMAPI indexSuspend( + virtual RCODE FLMAPI indexSuspend( FLMUINT uiIndexNum) = 0; - virtual RCODE XFLMAPI indexResume( + virtual RCODE FLMAPI indexResume( FLMUINT uiIndexNum) = 0; - virtual RCODE XFLMAPI keyRetrieve( + virtual RCODE FLMAPI keyRetrieve( FLMUINT uiIndex, IF_DataVector * pSearchKey, FLMUINT uiFlags, IF_DataVector * pFoundKey) = 0; - virtual RCODE XFLMAPI enableEncryption( void) = 0; + virtual RCODE FLMAPI enableEncryption( void) = 0; - virtual RCODE XFLMAPI wrapKey( + virtual RCODE FLMAPI wrapKey( const char * pszPassword = NULL) = 0; - virtual RCODE XFLMAPI rollOverDbKey( void) = 0; + virtual RCODE FLMAPI rollOverDbKey( void) = 0; - virtual RCODE XFLMAPI changeItemState( + virtual RCODE FLMAPI changeItemState( FLMUINT uiDictType, FLMUINT uiDictNum, const char * pszState) = 0; - virtual RCODE XFLMAPI reduceSize( + virtual RCODE FLMAPI reduceSize( FLMUINT uiCount, FLMUINT * puiCount) = 0; - virtual RCODE XFLMAPI upgrade( + virtual RCODE FLMAPI upgrade( IF_UpgradeClient * pUpgradeClient) = 0; - virtual RCODE XFLMAPI createRootElement( + virtual RCODE FLMAPI createRootElement( FLMUINT uiCollection, FLMUINT uiNameId, IF_DOMNode ** ppElementNode, FLMUINT64 * pui64NodeId = NULL) = 0; - virtual RCODE XFLMAPI createDocument( + virtual RCODE FLMAPI createDocument( FLMUINT uiCollection, IF_DOMNode ** ppDocumentNode, FLMUINT64 * pui64NodeId = NULL) = 0; - virtual RCODE XFLMAPI getFirstDocument( + virtual RCODE FLMAPI getFirstDocument( FLMUINT uiCollection, IF_DOMNode ** ppDocumentNode) = 0; - virtual RCODE XFLMAPI getLastDocument( + virtual RCODE FLMAPI getLastDocument( FLMUINT uiCollection, IF_DOMNode ** ppDocumentNode) = 0; - virtual RCODE XFLMAPI getDocument( + virtual RCODE FLMAPI getDocument( FLMUINT uiCollection, FLMUINT uiFlags, FLMUINT64 ui64DocumentId, IF_DOMNode ** ppDocumentNode) = 0; - virtual RCODE XFLMAPI documentDone( + virtual RCODE FLMAPI documentDone( FLMUINT uiCollection, FLMUINT64 ui64RootId) = 0; - virtual RCODE XFLMAPI documentDone( + virtual RCODE FLMAPI documentDone( IF_DOMNode * pDocNode) = 0; - virtual RCODE XFLMAPI createElementDef( + virtual RCODE FLMAPI createElementDef( const char * pszNamespaceURI, const char * pszElementName, FLMUINT uiDataType, FLMUINT * puiElementNameId = NULL, IF_DOMNode ** ppDocumentNode = NULL) = 0; - virtual RCODE XFLMAPI createElementDef( + virtual RCODE FLMAPI createElementDef( const FLMUNICODE * puzNamespaceURI, const FLMUNICODE * puzElementName, FLMUINT uiDataType, FLMUINT * puiElementNameId = NULL, IF_DOMNode ** ppDocumentNode = NULL) = 0; - virtual RCODE XFLMAPI createUniqueElmDef( + virtual RCODE FLMAPI createUniqueElmDef( const char * pszNamespaceURI, const char * pszElementName, FLMUINT * puiElementNameId = NULL, IF_DOMNode ** ppDocumentNode = NULL) = 0; - virtual RCODE XFLMAPI createUniqueElmDef( + virtual RCODE FLMAPI createUniqueElmDef( const FLMUNICODE * puzNamespaceURI, const FLMUNICODE * puzElementName, FLMUINT * puiElementNameId = NULL, IF_DOMNode ** ppDocumentNode = NULL) = 0; - virtual RCODE XFLMAPI getElementNameId( + virtual RCODE FLMAPI getElementNameId( const char * pszNamespaceURI, const char * pszElementName, FLMUINT * puiElementNameId) = 0; - virtual RCODE XFLMAPI getElementNameId( + virtual RCODE FLMAPI getElementNameId( const FLMUNICODE * puzNamespaceURI, const FLMUNICODE * puzElementName, FLMUINT * puiElementNameId) = 0; - virtual RCODE XFLMAPI createAttributeDef( + virtual RCODE FLMAPI createAttributeDef( const char * pszNamespaceURI, const char * pszAttributeName, FLMUINT uiDataType, FLMUINT * puiAttributeNameId, IF_DOMNode ** ppDocumentNode = NULL) = 0; - virtual RCODE XFLMAPI createAttributeDef( + virtual RCODE FLMAPI createAttributeDef( const FLMUNICODE * puzNamespaceURI, const FLMUNICODE * puzAttributeName, FLMUINT uiDataType, FLMUINT * puiAttributeNameId, IF_DOMNode ** ppDocumentNode = NULL) = 0; - virtual RCODE XFLMAPI getAttributeNameId( + virtual RCODE FLMAPI getAttributeNameId( const char * pszNamespaceURI, const char * pszAttributeName, FLMUINT * puiAttributeNameId) = 0; - virtual RCODE XFLMAPI getAttributeNameId( + virtual RCODE FLMAPI getAttributeNameId( const FLMUNICODE * puzNamespaceURI, const FLMUNICODE * puzAttributeName, FLMUINT * puiAttributeNameId) = 0; - virtual RCODE XFLMAPI createPrefixDef( + virtual RCODE FLMAPI createPrefixDef( const char * pszPrefixName, FLMUINT * puiPrefixNumber) = 0; - virtual RCODE XFLMAPI createPrefixDef( + virtual RCODE FLMAPI createPrefixDef( const FLMUNICODE * puzPrefixName, FLMUINT * puiPrefixNumber) = 0; - virtual RCODE XFLMAPI getPrefixId( + virtual RCODE FLMAPI getPrefixId( const char * pszPrefixName, FLMUINT * puiPrefixNumber) = 0; - virtual RCODE XFLMAPI getPrefixId( + virtual RCODE FLMAPI getPrefixId( const FLMUNICODE * puzPrefixName, FLMUINT * puiPrefixNumber) = 0; - virtual RCODE XFLMAPI createEncDef( + virtual RCODE FLMAPI createEncDef( const char * pszEncType, const char * pszEncName, FLMUINT uiKeySize, FLMUINT * puiEncDefNumber) = 0; - virtual RCODE XFLMAPI createEncDef( + virtual RCODE FLMAPI createEncDef( const FLMUNICODE * puzEncType, const FLMUNICODE * puzEncName, FLMUINT uiKeySize, FLMUINT * puiEncDefNumber) = 0; - virtual RCODE XFLMAPI getEncDefId( + virtual RCODE FLMAPI getEncDefId( const char * pszEncDefName, FLMUINT * puiPrefixNumber) = 0; - virtual RCODE XFLMAPI getEncDefId( + virtual RCODE FLMAPI getEncDefId( const FLMUNICODE * puzEncDefName, FLMUINT * puiEncDefNumber) = 0; - virtual RCODE XFLMAPI createCollectionDef( + virtual RCODE FLMAPI createCollectionDef( const char * pszCollectionName, FLMUINT * puiCollectionNumber, FLMUINT uiEncNumber = 0) = 0; - virtual RCODE XFLMAPI createCollectionDef( + virtual RCODE FLMAPI createCollectionDef( const FLMUNICODE * puzCollectionName, FLMUINT * puiCollectionNumber, FLMUINT uiEncNumber = 0) = 0; - virtual RCODE XFLMAPI getCollectionNumber( + virtual RCODE FLMAPI getCollectionNumber( const char * pszCollectionName, FLMUINT * puiCollectionNumber) = 0; - virtual RCODE XFLMAPI getCollectionNumber( + virtual RCODE FLMAPI getCollectionNumber( const FLMUNICODE * puzCollectionName, FLMUINT * puiCollectionNumber) = 0; - virtual RCODE XFLMAPI getIndexNumber( + virtual RCODE FLMAPI getIndexNumber( const char * pszIndexName, FLMUINT * puiIndexNumber) = 0; - virtual RCODE XFLMAPI getIndexNumber( + virtual RCODE FLMAPI getIndexNumber( const FLMUNICODE * puzIndexName, FLMUINT * puiIndexNumber) = 0; - virtual RCODE XFLMAPI getDictionaryDef( + virtual RCODE FLMAPI getDictionaryDef( FLMUINT uiDictType, FLMUINT uiDictNumber, IF_DOMNode ** ppDocumentNode) = 0; - virtual RCODE XFLMAPI getDictionaryName( + virtual RCODE FLMAPI getDictionaryName( FLMUINT uiDictType, FLMUINT uiDictNumber, char * pszName, @@ -3310,7 +2749,7 @@ char * pszNamespace = NULL, FLMUINT * puiNamespaceBufSize = NULL) = 0; - virtual RCODE XFLMAPI getDictionaryName( + virtual RCODE FLMAPI getDictionaryName( FLMUINT uiDictType, FLMUINT uiDictNumber, FLMUNICODE * puzName, @@ -3318,176 +2757,176 @@ FLMUNICODE * puzNamespace = NULL, FLMUINT * puiNamespaceBufSize = NULL) = 0; - virtual RCODE XFLMAPI getNode( + virtual RCODE FLMAPI getNode( FLMUINT uiCollection, FLMUINT64 ui64NodeId, IF_DOMNode ** ppNode) = 0; - virtual RCODE XFLMAPI getAttribute( + virtual RCODE FLMAPI getAttribute( FLMUINT uiCollection, FLMUINT64 ui64ElementNodeId, FLMUINT uiAttrNameId, IF_DOMNode ** ppNode) = 0; - virtual RCODE XFLMAPI getDataType( + virtual RCODE FLMAPI getDataType( FLMUINT uiDictType, FLMUINT uiNameId, FLMUINT * puiDataType) = 0; - virtual RCODE XFLMAPI backupBegin( + virtual RCODE FLMAPI backupBegin( eDbBackupType eBackupType, eDbTransType eTransType, FLMUINT uiMaxLockWait, IF_Backup ** ppBackup) = 0; - virtual void XFLMAPI getRflFileName( + virtual void FLMAPI getRflFileName( FLMUINT uiFileNum, FLMBOOL bBaseOnly, char * pszFileName, FLMUINT * puiFileNameBufSize, FLMBOOL * pbNameTruncated = NULL) = 0; - virtual RCODE XFLMAPI import( + virtual RCODE FLMAPI import( IF_IStream * pIStream, FLMUINT uiCollection, IF_DOMNode * pNodeToLinkTo = NULL, eNodeInsertLoc eInsertLoc = XFLM_LAST_CHILD, XFLM_IMPORT_STATS * pImportStats = NULL) = 0; - virtual RCODE XFLMAPI importDocument( + virtual RCODE FLMAPI importDocument( IF_IStream * ifpStream, FLMUINT uiCollection, IF_DOMNode ** ppDocumentNode = NULL, XFLM_IMPORT_STATS * pImportStats = NULL) = 0; - virtual RCODE XFLMAPI exportXML( + virtual RCODE FLMAPI exportXML( IF_DOMNode * pStartNode, IF_OStream * pOStream, eExportFormatType eFormat = XFLM_EXPORT_INDENT) = 0; - virtual RCODE XFLMAPI setNextNodeId( + virtual RCODE FLMAPI setNextNodeId( FLMUINT uiCollection, FLMUINT64 ui64NextNodeId) = 0; - virtual RCODE XFLMAPI setNextDictNum( + virtual RCODE FLMAPI setNextDictNum( FLMUINT uiDictType, FLMUINT uiDictNumber) = 0; // Configuration "set" and "get" methods - virtual RCODE XFLMAPI setRflKeepFilesFlag( + virtual RCODE FLMAPI setRflKeepFilesFlag( FLMBOOL bKeep) = 0; - virtual RCODE XFLMAPI getRflKeepFlag( + virtual RCODE FLMAPI getRflKeepFlag( FLMBOOL * pbKeep) = 0; - virtual RCODE XFLMAPI setRflDir( + virtual RCODE FLMAPI setRflDir( const char * pszNewRflDir) = 0; - virtual void XFLMAPI getRflDir( + virtual void FLMAPI getRflDir( char * pszRflDir) = 0; - virtual RCODE XFLMAPI getRflFileNum( + virtual RCODE FLMAPI getRflFileNum( FLMUINT * puiRflFileNum) = 0; - virtual RCODE XFLMAPI getHighestNotUsedRflFileNum( + virtual RCODE FLMAPI getHighestNotUsedRflFileNum( FLMUINT * puiHighestNotUsedRflFileNum) = 0; - virtual RCODE XFLMAPI setRflFileSizeLimits( + virtual RCODE FLMAPI setRflFileSizeLimits( FLMUINT uiMinRflSize, FLMUINT uiMaxRflSize) = 0; - virtual RCODE XFLMAPI getRflFileSizeLimits( + virtual RCODE FLMAPI getRflFileSizeLimits( FLMUINT * puiRflMinFileSize, FLMUINT * puiRflMaxFileSize) = 0; - virtual RCODE XFLMAPI rflRollToNextFile( void) = 0; + virtual RCODE FLMAPI rflRollToNextFile( void) = 0; - virtual RCODE XFLMAPI setKeepAbortedTransInRflFlag( + virtual RCODE FLMAPI setKeepAbortedTransInRflFlag( FLMBOOL bKeep) = 0; - virtual RCODE XFLMAPI getKeepAbortedTransInRflFlag( + virtual RCODE FLMAPI getKeepAbortedTransInRflFlag( FLMBOOL * pbKeep) = 0; - virtual RCODE XFLMAPI setAutoTurnOffKeepRflFlag( + virtual RCODE FLMAPI setAutoTurnOffKeepRflFlag( FLMBOOL bAutoTurnOff) = 0; - virtual RCODE XFLMAPI getAutoTurnOffKeepRflFlag( + virtual RCODE FLMAPI getAutoTurnOffKeepRflFlag( FLMBOOL * pbAutoTurnOff) = 0; - virtual void XFLMAPI setFileExtendSize( + virtual void FLMAPI setFileExtendSize( FLMUINT uiFileExtendSize) = 0; - virtual FLMUINT XFLMAPI getFileExtendSize( void) = 0; + virtual FLMUINT FLMAPI getFileExtendSize( void) = 0; - virtual void XFLMAPI setAppData( + virtual void FLMAPI setAppData( void * pvAppData) = 0; - virtual void * XFLMAPI getAppData( void) = 0; + virtual void * FLMAPI getAppData( void) = 0; - virtual void XFLMAPI setDeleteStatusObject( + virtual void FLMAPI setDeleteStatusObject( IF_DeleteStatus * pDeleteStatus) = 0; - virtual void XFLMAPI setCommitClientObject( + virtual void FLMAPI setCommitClientObject( IF_CommitClient * pCommitClient) = 0; - virtual void XFLMAPI setIndexingClientObject( + virtual void FLMAPI setIndexingClientObject( IF_IxClient * pIxClient) = 0; - virtual void XFLMAPI setIndexingStatusObject( + virtual void FLMAPI setIndexingStatusObject( IF_IxStatus * pIxStatus) = 0; // Configuration information getting methods - virtual FLMUINT XFLMAPI getDbVersion( void) = 0; + virtual FLMUINT FLMAPI getDbVersion( void) = 0; - virtual FLMUINT XFLMAPI getBlockSize( void) = 0; + virtual FLMUINT FLMAPI getBlockSize( void) = 0; - virtual FLMUINT XFLMAPI getDefaultLanguage( void) = 0; + virtual FLMUINT FLMAPI getDefaultLanguage( void) = 0; - virtual FLMUINT64 XFLMAPI getTransID( void) = 0; + virtual FLMUINT64 FLMAPI getTransID( void) = 0; - virtual void XFLMAPI getCheckpointInfo( + virtual void FLMAPI getCheckpointInfo( XFLM_CHECKPOINT_INFO * pCheckpointInfo) = 0; - virtual RCODE XFLMAPI getDbControlFileName( + virtual RCODE FLMAPI getDbControlFileName( char * pszControlFileName, FLMUINT uiControlFileBufSize) = 0; - virtual RCODE XFLMAPI getLockWaiters( + virtual RCODE FLMAPI getLockWaiters( IF_LockInfoClient * pLockInfo) = 0; - virtual RCODE XFLMAPI getLastBackupTransID( + virtual RCODE FLMAPI getLastBackupTransID( FLMUINT64 * pui64LastBackupTransID) = 0; - virtual RCODE XFLMAPI getBlocksChangedSinceBackup( + virtual RCODE FLMAPI getBlocksChangedSinceBackup( FLMUINT * puiBlocksChangedSinceBackup) = 0; - virtual RCODE XFLMAPI getNextIncBackupSequenceNum( + virtual RCODE FLMAPI getNextIncBackupSequenceNum( FLMUINT * puiNextIncBackupSequenceNum) = 0; - virtual void XFLMAPI getSerialNumber( + virtual void FLMAPI getSerialNumber( char * pucSerialNumber) = 0; - virtual RCODE XFLMAPI getDiskSpaceUsage( + virtual RCODE FLMAPI getDiskSpaceUsage( FLMUINT64 * pui64DataSize, FLMUINT64 * pui64RollbackSize, FLMUINT64 * pui64RflSize) = 0; - virtual RCODE XFLMAPI getMustCloseRC( void) = 0; + virtual RCODE FLMAPI getMustCloseRC( void) = 0; - virtual RCODE XFLMAPI getAbortRC( void) = 0; + virtual RCODE FLMAPI getAbortRC( void) = 0; - virtual void XFLMAPI setMustAbortTrans( + virtual void FLMAPI setMustAbortTrans( RCODE rc) = 0; }; /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_DOMNode : public XF_RefCount + flminterface IF_DOMNode : public F_Object { - virtual RCODE XFLMAPI createNode( + virtual RCODE FLMAPI createNode( IF_Db * pDb, eDomNodeType eNodeType, FLMUINT uiNameId, @@ -3495,146 +2934,146 @@ IF_DOMNode ** ppNewNode, FLMUINT64 * pui64NodeId = NULL) = 0; - virtual RCODE XFLMAPI createChildElement( + virtual RCODE FLMAPI createChildElement( IF_Db * pDb, FLMUINT uiChildElementNameId, eNodeInsertLoc eLocation, IF_DOMNode ** ppNewChildElementNode, FLMUINT64 * pui64NodeId = NULL) = 0; - virtual RCODE XFLMAPI deleteNode( + virtual RCODE FLMAPI deleteNode( IF_Db * pDb) = 0; - virtual RCODE XFLMAPI deleteChildren( + virtual RCODE FLMAPI deleteChildren( IF_Db * pDb, FLMUINT uiNameId = 0) = 0; - virtual RCODE XFLMAPI createAttribute( + virtual RCODE FLMAPI createAttribute( IF_Db * pDb, FLMUINT uiAttrNameId, IF_DOMNode ** ppAttrNode) = 0; - virtual RCODE XFLMAPI getFirstAttribute( + virtual RCODE FLMAPI getFirstAttribute( IF_Db * pDb, IF_DOMNode ** ppAttrNode) = 0; - virtual RCODE XFLMAPI getLastAttribute( + virtual RCODE FLMAPI getLastAttribute( IF_Db * pDb, IF_DOMNode ** ppAttrNode) = 0; - virtual RCODE XFLMAPI getAttribute( + virtual RCODE FLMAPI getAttribute( IF_Db * pDb, FLMUINT uiAttrNameId, IF_DOMNode ** ppAttrNode) = 0; - virtual RCODE XFLMAPI deleteAttribute( + virtual RCODE FLMAPI deleteAttribute( IF_Db * pDb, FLMUINT uiAttrNameId) = 0; - virtual RCODE XFLMAPI hasAttribute( + virtual RCODE FLMAPI hasAttribute( IF_Db * pDb, FLMUINT uiAttrNameId, IF_DOMNode ** ppAttrNode = NULL) = 0; - virtual RCODE XFLMAPI hasAttributes( + virtual RCODE FLMAPI hasAttributes( IF_Db * pDb, FLMBOOL * pbHasAttrs) = 0; - virtual RCODE XFLMAPI hasNextSibling( + virtual RCODE FLMAPI hasNextSibling( IF_Db * pDb, FLMBOOL * pbHasNextSibling) = 0; - virtual RCODE XFLMAPI hasPreviousSibling( + virtual RCODE FLMAPI hasPreviousSibling( IF_Db * pDb, FLMBOOL * pbHasPreviousSibling) = 0; - virtual RCODE XFLMAPI hasChildren( + virtual RCODE FLMAPI hasChildren( IF_Db * pDb, FLMBOOL * pbHasChildren) = 0; - virtual RCODE XFLMAPI isNamespaceDecl( + virtual RCODE FLMAPI isNamespaceDecl( IF_Db * pDb, FLMBOOL * pbIsNamespaceDecl) = 0; - virtual eDomNodeType XFLMAPI getNodeType( void) = 0; + virtual eDomNodeType FLMAPI getNodeType( void) = 0; - virtual RCODE XFLMAPI getNodeId( + virtual RCODE FLMAPI getNodeId( IF_Db * pDb, FLMUINT64 * pui64NodeId) = 0; - virtual RCODE XFLMAPI getParentId( + virtual RCODE FLMAPI getParentId( IF_Db * pDb, FLMUINT64 * pui64ParentId) = 0; - virtual RCODE XFLMAPI getDocumentId( + virtual RCODE FLMAPI getDocumentId( IF_Db * pDb, FLMUINT64 * pui64DocumentId) = 0; - virtual RCODE XFLMAPI getPrevSibId( + virtual RCODE FLMAPI getPrevSibId( IF_Db * pDb, FLMUINT64 * pui64PrevSibId) = 0; - virtual RCODE XFLMAPI getNextSibId( + virtual RCODE FLMAPI getNextSibId( IF_Db * pDb, FLMUINT64 * pui64NextSibId) = 0; - virtual RCODE XFLMAPI getFirstChildId( + virtual RCODE FLMAPI getFirstChildId( IF_Db * pDb, FLMUINT64 * pui64FirstChildId) = 0; - virtual RCODE XFLMAPI getLastChildId( + virtual RCODE FLMAPI getLastChildId( IF_Db * pDb, FLMUINT64 * pui64LastChildId) = 0; - virtual RCODE XFLMAPI getNameId( + virtual RCODE FLMAPI getNameId( IF_Db * pDb, FLMUINT * puiNameId) = 0; - virtual RCODE XFLMAPI getEncDefId( + virtual RCODE FLMAPI getEncDefId( IF_Db * pDb, FLMUINT * puiEncDefId) = 0; - virtual RCODE XFLMAPI getDataType( + virtual RCODE FLMAPI getDataType( IF_Db * pDb, FLMUINT * puiDataType) = 0; - virtual RCODE XFLMAPI getDataLength( + virtual RCODE FLMAPI getDataLength( IF_Db * pDb, FLMUINT * puiLength) = 0; - virtual RCODE XFLMAPI getUINT32( + virtual RCODE FLMAPI getUINT32( IF_Db * pDb, FLMUINT32 * pui32Value) = 0; - virtual RCODE XFLMAPI getUINT( + virtual RCODE FLMAPI getUINT( IF_Db * pDb, FLMUINT * puiValue) = 0; - virtual RCODE XFLMAPI getUINT64( + virtual RCODE FLMAPI getUINT64( IF_Db * pDb, FLMUINT64 * pui64Value) = 0; - virtual RCODE XFLMAPI getINT32( + virtual RCODE FLMAPI getINT32( IF_Db * pDb, FLMINT32 * pi32Value) = 0; - virtual RCODE XFLMAPI getINT( + virtual RCODE FLMAPI getINT( IF_Db * pDb, FLMINT * piValue) = 0; - virtual RCODE XFLMAPI getINT64( + virtual RCODE FLMAPI getINT64( IF_Db * pDb, FLMINT64 * pi64Value) = 0; - virtual RCODE XFLMAPI getMetaValue( + virtual RCODE FLMAPI getMetaValue( IF_Db * pDb, FLMUINT64 * pui64Value) = 0; - virtual RCODE XFLMAPI getUnicodeChars( + virtual RCODE FLMAPI getUnicodeChars( IF_Db * pDb, FLMUINT * puiNumChars) = 0; - virtual RCODE XFLMAPI getUnicode( + virtual RCODE FLMAPI getUnicode( IF_Db * pDb, FLMUNICODE * puzValueBuffer, FLMUINT uiBufferSize, @@ -3643,15 +3082,15 @@ FLMUINT * puiCharsReturned = NULL, FLMUINT * puiBufferBytesUsed = NULL) = 0; - virtual RCODE XFLMAPI getUnicode( + virtual RCODE FLMAPI getUnicode( IF_Db * pDb, FLMUNICODE ** ppuzUnicodeValue) = 0; - virtual RCODE XFLMAPI getUnicode( + virtual RCODE FLMAPI getUnicode( IF_Db * pDb, IF_DynaBuf * pDynaBuf) = 0; - virtual RCODE XFLMAPI getUTF8( + virtual RCODE FLMAPI getUTF8( IF_Db * pDb, FLMBYTE * pucValueBuffer, FLMUINT uiBufferSize, @@ -3660,81 +3099,81 @@ FLMUINT * puiCharsReturned = NULL, FLMUINT * puiBufferBytesUsed = NULL) = 0; - virtual RCODE XFLMAPI getUTF8( + virtual RCODE FLMAPI getUTF8( IF_Db * pDb, FLMBYTE ** ppszUTF8Value) = 0; - virtual RCODE XFLMAPI getUTF8( + virtual RCODE FLMAPI getUTF8( IF_Db * pDb, IF_DynaBuf * pDynaBuf) = 0; - virtual RCODE XFLMAPI getBinary( + virtual RCODE FLMAPI getBinary( IF_Db * pDb, void * pvValue, FLMUINT uiByteOffset, FLMUINT uiBytesRequested, FLMUINT * puiBytesReturned) = 0; - virtual RCODE XFLMAPI getBinary( + virtual RCODE FLMAPI getBinary( IF_Db * pDb, IF_DynaBuf * pBuffer) = 0; - virtual RCODE XFLMAPI getAttributeValueUINT32( + virtual RCODE FLMAPI getAttributeValueUINT32( IF_Db * pDb, FLMUINT uiAttrNameId, FLMUINT32 * pui32Num) = 0; - virtual RCODE XFLMAPI getAttributeValueUINT32( + virtual RCODE FLMAPI getAttributeValueUINT32( IF_Db * pDb, FLMUINT uiAttrNameId, FLMUINT32 * pui32Num, FLMUINT32 ui32NotFoundDefault) = 0; - virtual RCODE XFLMAPI getAttributeValueUINT( + virtual RCODE FLMAPI getAttributeValueUINT( IF_Db * pDb, FLMUINT uiAttrNameId, FLMUINT * puiNum) = 0; - virtual RCODE XFLMAPI getAttributeValueUINT( + virtual RCODE FLMAPI getAttributeValueUINT( IF_Db * pDb, FLMUINT uiAttrNameId, FLMUINT * puiNum, FLMUINT uiNotFoundDefault) = 0; - virtual RCODE XFLMAPI getAttributeValueUINT64( + virtual RCODE FLMAPI getAttributeValueUINT64( IF_Db * pDb, FLMUINT uiAttrNameId, FLMUINT64 * pui64Num) = 0; - virtual RCODE XFLMAPI getAttributeValueUINT64( + virtual RCODE FLMAPI getAttributeValueUINT64( IF_Db * pDb, FLMUINT uiAttrNameId, FLMUINT64 * pui64Num, FLMUINT64 ui64NotFoundDefault) = 0; - virtual RCODE XFLMAPI getAttributeValueINT( + virtual RCODE FLMAPI getAttributeValueINT( IF_Db * pDb, FLMUINT uiAttrNameId, FLMINT * piNum) = 0; - virtual RCODE XFLMAPI getAttributeValueINT( + virtual RCODE FLMAPI getAttributeValueINT( IF_Db * pDb, FLMUINT uiAttrNameId, FLMINT * piNum, FLMINT iNotFoundDefault) = 0; - virtual RCODE XFLMAPI getAttributeValueINT64( + virtual RCODE FLMAPI getAttributeValueINT64( IF_Db * pDb, FLMUINT uiAttrNameId, FLMINT64 * pi64Num) = 0; - virtual RCODE XFLMAPI getAttributeValueINT64( + virtual RCODE FLMAPI getAttributeValueINT64( IF_Db * pDb, FLMUINT uiAttrNameId, FLMINT64 * pi64Num, FLMINT64 i64NotFoundDefault) = 0; - virtual RCODE XFLMAPI getAttributeValueUnicode( + virtual RCODE FLMAPI getAttributeValueUnicode( IF_Db * pDb, FLMUINT uiAttrNameId, FLMUNICODE * puzValueBuffer, @@ -3742,17 +3181,17 @@ FLMUINT * puiCharsReturned = NULL, FLMUINT * puiBufferBytesUsed = NULL) = 0; - virtual RCODE XFLMAPI getAttributeValueUnicode( + virtual RCODE FLMAPI getAttributeValueUnicode( IF_Db * pDb, FLMUINT uiAttrNameId, FLMUNICODE ** ppuzValueBuffer) = 0; - virtual RCODE XFLMAPI getAttributeValueUnicode( + virtual RCODE FLMAPI getAttributeValueUnicode( IF_Db * pDb, FLMUINT uiAttrNameId, IF_DynaBuf * pDynaBuf) = 0; - virtual RCODE XFLMAPI getAttributeValueUTF8( + virtual RCODE FLMAPI getAttributeValueUTF8( IF_Db * pDb, FLMUINT uiAttrNameId, FLMBYTE * pucValueBuffer, @@ -3760,285 +3199,285 @@ FLMUINT * puiCharsReturned = NULL, FLMUINT * puiBufferBytesUsed = NULL) = 0; - virtual RCODE XFLMAPI getAttributeValueUTF8( + virtual RCODE FLMAPI getAttributeValueUTF8( IF_Db * pDb, FLMUINT uiAttrNameId, FLMBYTE ** ppszValueBuffer) = 0; - virtual RCODE XFLMAPI getAttributeValueUTF8( + virtual RCODE FLMAPI getAttributeValueUTF8( IF_Db * pDb, FLMUINT uiAttrNameId, IF_DynaBuf * pDynaBuf) = 0; - virtual RCODE XFLMAPI getAttributeValueBinary( + virtual RCODE FLMAPI getAttributeValueBinary( IF_Db * pDb, FLMUINT uiAttrNameId, void * pvValueBuffer, FLMUINT uiBufferSize, FLMUINT * puiValueLength) = 0; - virtual RCODE XFLMAPI getAttributeValueBinary( + virtual RCODE FLMAPI getAttributeValueBinary( IF_Db * pDb, FLMUINT uiAttrNameId, IF_DynaBuf * pDynaBuf) = 0; - virtual RCODE XFLMAPI setUINT( + virtual RCODE FLMAPI setUINT( IF_Db * pDb, FLMUINT uiValue, FLMUINT uiEncDefId = 0) = 0; - virtual RCODE XFLMAPI setUINT64( + virtual RCODE FLMAPI setUINT64( IF_Db * pDb, FLMUINT64 ui64Value, FLMUINT uiEncDefId = 0) = 0; - virtual RCODE XFLMAPI setINT( + virtual RCODE FLMAPI setINT( IF_Db * pDb, FLMINT iValue, FLMUINT uiEncDefId = 0) = 0; - virtual RCODE XFLMAPI setINT64( + virtual RCODE FLMAPI setINT64( IF_Db * pDb, FLMINT64 i64Value, FLMUINT uiEncDefId = 0) = 0; - virtual RCODE XFLMAPI setMetaValue( + virtual RCODE FLMAPI setMetaValue( IF_Db * pDb, FLMUINT64 ui64Value) = 0; - virtual RCODE XFLMAPI setUnicode( + virtual RCODE FLMAPI setUnicode( IF_Db * pDb, const FLMUNICODE * puzValue, FLMUINT uiValueLength = 0, FLMBOOL bLast = TRUE, FLMUINT uiEncDefId = 0) = 0; - virtual RCODE XFLMAPI setUTF8( + virtual RCODE FLMAPI setUTF8( IF_Db * pDb, const FLMBYTE * pszValue, FLMUINT uiValueLength = 0, FLMBOOL bLast = TRUE, FLMUINT uiEncDefId = 0) = 0; - virtual RCODE XFLMAPI setBinary( + virtual RCODE FLMAPI setBinary( IF_Db * pDb, const void * pvValue, FLMUINT uiValueLength, FLMBOOL bLast = TRUE, FLMUINT uiEncDefId = 0) = 0; - virtual RCODE XFLMAPI setAttributeValueUINT( + virtual RCODE FLMAPI setAttributeValueUINT( IF_Db * pDb, FLMUINT uiAttrNameId, FLMUINT uiValue, FLMUINT uiEncDefId = 0) = 0; - virtual RCODE XFLMAPI setAttributeValueUINT64( + virtual RCODE FLMAPI setAttributeValueUINT64( IF_Db * pDb, FLMUINT uiAttrNameId, FLMUINT64 ui64Value, FLMUINT uiEncDefId = 0) = 0; - virtual RCODE XFLMAPI setAttributeValueINT( + virtual RCODE FLMAPI setAttributeValueINT( IF_Db * pDb, FLMUINT uiAttrNameId, FLMINT iValue, FLMUINT uiEncDefId = 0) = 0; - virtual RCODE XFLMAPI setAttributeValueINT64( + virtual RCODE FLMAPI setAttributeValueINT64( IF_Db * pDb, FLMUINT uiAttrNameId, FLMINT64 i64Value, FLMUINT uiEncDefId = 0) = 0; - virtual RCODE XFLMAPI setAttributeValueUnicode( + virtual RCODE FLMAPI setAttributeValueUnicode( IF_Db * pDb, FLMUINT uiAttrNameId, const FLMUNICODE * puzValue, FLMUINT uiEncDefId = 0) = 0; - virtual RCODE XFLMAPI setAttributeValueUTF8( + virtual RCODE FLMAPI setAttributeValueUTF8( IF_Db * pDb, FLMUINT uiAttrNameId, const FLMBYTE * pucValue, FLMUINT uiLength = 0, FLMUINT uiEncDefId = 0) = 0; - virtual RCODE XFLMAPI setAttributeValueBinary( + virtual RCODE FLMAPI setAttributeValueBinary( IF_Db * pDb, FLMUINT uiAttrNameId, const void * pvValue, FLMUINT uiLength, FLMUINT uiEncDefId = 0) = 0; - virtual RCODE XFLMAPI getDocumentNode( + virtual RCODE FLMAPI getDocumentNode( IF_Db * pDb, IF_DOMNode ** ppDocument) = 0; - virtual RCODE XFLMAPI getNextDocument( + virtual RCODE FLMAPI getNextDocument( IF_Db * pDb, IF_DOMNode ** ppNextDocument) = 0; - virtual RCODE XFLMAPI getPreviousDocument( + virtual RCODE FLMAPI getPreviousDocument( IF_Db * pDb, IF_DOMNode ** ppPrevDocument) = 0; - virtual RCODE XFLMAPI getParentNode( + virtual RCODE FLMAPI getParentNode( IF_Db * pDb, IF_DOMNode ** ppParent) = 0; - virtual RCODE XFLMAPI getFirstChild( + virtual RCODE FLMAPI getFirstChild( IF_Db * pDb, IF_DOMNode ** ppFirstChild) = 0; - virtual RCODE XFLMAPI getLastChild( + virtual RCODE FLMAPI getLastChild( IF_Db * pDb, IF_DOMNode ** ppLastChild) = 0; - virtual RCODE XFLMAPI getNextSibling( + virtual RCODE FLMAPI getNextSibling( IF_Db * pDb, IF_DOMNode ** ppNextSibling) = 0; - virtual RCODE XFLMAPI getPreviousSibling( + virtual RCODE FLMAPI getPreviousSibling( IF_Db * pDb, IF_DOMNode ** ppPrevSibling) = 0; - virtual RCODE XFLMAPI getChild( + virtual RCODE FLMAPI getChild( IF_Db * pDb, eDomNodeType eNodeType, IF_DOMNode ** ppChild) = 0; - virtual RCODE XFLMAPI getChildElement( + virtual RCODE FLMAPI getChildElement( IF_Db * pDb, FLMUINT uiElementNameId, IF_DOMNode ** ppChild, FLMUINT uiFlags = 0) = 0; - virtual RCODE XFLMAPI getSiblingElement( + virtual RCODE FLMAPI getSiblingElement( IF_Db * pDb, FLMUINT uiElementNameId, FLMBOOL bNext, IF_DOMNode ** ppSibling) = 0; - virtual RCODE XFLMAPI getAncestorElement( + virtual RCODE FLMAPI getAncestorElement( IF_Db * pDb, FLMUINT uiElementNameId, IF_DOMNode ** ppAncestor) = 0; - virtual RCODE XFLMAPI getDescendantElement( + virtual RCODE FLMAPI getDescendantElement( IF_Db * pDb, FLMUINT uiElementNameId, IF_DOMNode ** ppDescendant) = 0; - virtual RCODE XFLMAPI insertBefore( + virtual RCODE FLMAPI insertBefore( IF_Db * pDb, IF_DOMNode * pNewChild, IF_DOMNode * pRefChild) = 0; - virtual RCODE XFLMAPI getPrefix( + virtual RCODE FLMAPI getPrefix( IF_Db * pDb, FLMUNICODE * puzPrefixBuffer, FLMUINT uiBufferSize, FLMUINT * puiCharsReturned = NULL) = 0; - virtual RCODE XFLMAPI getPrefix( + virtual RCODE FLMAPI getPrefix( IF_Db * pDb, char * pszPrefixBuffer, FLMUINT uiBufferSize, FLMUINT * puiCharsReturned = NULL) = 0; - virtual RCODE XFLMAPI getPrefixId( + virtual RCODE FLMAPI getPrefixId( IF_Db * pDb, FLMUINT * puiPrefixId) = 0; - virtual RCODE XFLMAPI setPrefix( + virtual RCODE FLMAPI setPrefix( IF_Db * pDb, const FLMUNICODE * puzPrefix) = 0; - virtual RCODE XFLMAPI setPrefix( + virtual RCODE FLMAPI setPrefix( IF_Db * pDb, const char * pszPrefix) = 0; - virtual RCODE XFLMAPI setPrefixId( + virtual RCODE FLMAPI setPrefixId( IF_Db * pDb, FLMUINT uiPrefixId) = 0; - virtual RCODE XFLMAPI getNamespaceURI( + virtual RCODE FLMAPI getNamespaceURI( IF_Db * pDb, FLMUNICODE * puzNamespaceURIBuffer, FLMUINT uiBufferSize, FLMUINT * puiCharsReturned = NULL) = 0; - virtual RCODE XFLMAPI getNamespaceURI( + virtual RCODE FLMAPI getNamespaceURI( IF_Db * pDb, char * pszNamespaceURIBuffer, FLMUINT uiBufferSize, FLMUINT * puiCharsReturned = NULL) = 0; - virtual RCODE XFLMAPI getLocalName( + virtual RCODE FLMAPI getLocalName( IF_Db * pDb, FLMUNICODE * puzLocalNameBuffer, FLMUINT uiBufferSize, FLMUINT * puiCharsReturned = NULL) = 0; - virtual RCODE XFLMAPI getLocalName( + virtual RCODE FLMAPI getLocalName( IF_Db * pDb, char * pszLocalNameBuffer, FLMUINT uiBufferSize, FLMUINT * puiCharsReturned = NULL) = 0; - virtual RCODE XFLMAPI getQualifiedName( + virtual RCODE FLMAPI getQualifiedName( IF_Db * pDb, FLMUNICODE * puzQualifiedNameBuffer, FLMUINT uiBufferSize, FLMUINT * puiCharsReturned = NULL) = 0; - virtual RCODE XFLMAPI getQualifiedName( + virtual RCODE FLMAPI getQualifiedName( IF_Db * pDb, char * pszQualifiedNameBuffer, FLMUINT uiBufferSize, FLMUINT * puiCharsReturned = NULL) = 0; - virtual RCODE XFLMAPI getCollection( + virtual RCODE FLMAPI getCollection( IF_Db * pDb, FLMUINT * puiCollection) = 0; - virtual RCODE XFLMAPI createAnnotation( + virtual RCODE FLMAPI createAnnotation( IF_Db * pDb, IF_DOMNode ** ppAnnotation, FLMUINT64 * pui64NodeId = NULL) = 0; - virtual RCODE XFLMAPI getAnnotation( + virtual RCODE FLMAPI getAnnotation( IF_Db * pDb, IF_DOMNode ** ppAnnotation) = 0; - virtual RCODE XFLMAPI getAnnotationId( + virtual RCODE FLMAPI getAnnotationId( IF_Db * pDb, FLMUINT64 * pui64AnnotationId) = 0; - virtual RCODE XFLMAPI hasAnnotation( + virtual RCODE FLMAPI hasAnnotation( IF_Db * pDb, FLMBOOL * pbHasAnnotation) = 0; - virtual RCODE XFLMAPI getIStream( + virtual RCODE FLMAPI getIStream( IF_Db * pDb, IF_PosIStream ** ppIStream, FLMUINT * puiDataType = NULL, FLMUINT * puiDataLength = NULL) = 0; - virtual RCODE XFLMAPI getTextIStream( + virtual RCODE FLMAPI getTextIStream( IF_Db * pDb, IF_PosIStream ** ppIStream, FLMUINT * puiNumChars = NULL) = 0; - virtual FLMUINT XFLMAPI compareNode( + virtual FLMUINT FLMAPI compareNode( IF_DOMNode * pNode, IF_Db * pDb1, IF_Db * pDb2, char * pszErrBuff, FLMUINT uiErrBuffLen) = 0; - virtual RCODE XFLMAPI isDataLocalToNode( + virtual RCODE FLMAPI isDataLocalToNode( IF_Db * pDb, FLMBOOL * pbDataIsLocal) = 0; }; @@ -4046,137 +3485,137 @@ /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_DataVector : public XF_RefCount + flminterface IF_DataVector : public F_Object { - virtual void XFLMAPI setDocumentID( + virtual void FLMAPI setDocumentID( FLMUINT64 ui64DocumentID) = 0; - virtual RCODE XFLMAPI setID( + virtual RCODE FLMAPI setID( FLMUINT uiElementNumber, FLMUINT64 ui64ID) = 0; - virtual RCODE XFLMAPI setNameId( + virtual RCODE FLMAPI setNameId( FLMUINT uiElementNumber, FLMUINT uiNameId, FLMBOOL bIsAttr, FLMBOOL bIsData) = 0; - virtual RCODE XFLMAPI setINT( + virtual RCODE FLMAPI setINT( FLMUINT uiElementNumber, FLMINT iNum) = 0; - virtual RCODE XFLMAPI setINT64( + virtual RCODE FLMAPI setINT64( FLMUINT uiElementNumber, FLMINT64 i64Num) = 0; - virtual RCODE XFLMAPI setUINT( + virtual RCODE FLMAPI setUINT( FLMUINT uiElementNumber, FLMUINT uiNum) = 0; - virtual RCODE XFLMAPI setUINT64( + virtual RCODE FLMAPI setUINT64( FLMUINT uiElementNumber, FLMUINT64 ui64Num) = 0; - virtual RCODE XFLMAPI setUnicode( + virtual RCODE FLMAPI setUnicode( FLMUINT uiElementNumber, const FLMUNICODE * puzUnicode) = 0; - virtual RCODE XFLMAPI setUTF8( + virtual RCODE FLMAPI setUTF8( FLMUINT uiElementNumber, const FLMBYTE * pszUtf8, FLMUINT uiBytesInBuffer = 0) = 0; - virtual RCODE XFLMAPI setBinary( + virtual RCODE FLMAPI setBinary( FLMUINT uiElementNumber, const void * pvBinary, FLMUINT uiBinaryLen) = 0; - virtual void XFLMAPI setRightTruncated( + virtual void FLMAPI setRightTruncated( FLMUINT uiElementNumber) = 0; - virtual void XFLMAPI setLeftTruncated( + virtual void FLMAPI setLeftTruncated( FLMUINT uiElementNumber) = 0; - virtual void XFLMAPI clearRightTruncated( + virtual void FLMAPI clearRightTruncated( FLMUINT uiElementNumber) = 0; - virtual void XFLMAPI clearLeftTruncated( + virtual void FLMAPI clearLeftTruncated( FLMUINT uiElementNumber) = 0; - virtual FLMBOOL XFLMAPI isRightTruncated( + virtual FLMBOOL FLMAPI isRightTruncated( FLMUINT uiElementNumber) = 0; - virtual FLMBOOL XFLMAPI isLeftTruncated( + virtual FLMBOOL FLMAPI isLeftTruncated( FLMUINT uiElementNumber) = 0; - virtual FLMUINT64 XFLMAPI getDocumentID( void) = 0; + virtual FLMUINT64 FLMAPI getDocumentID( void) = 0; - virtual FLMUINT64 XFLMAPI getID( + virtual FLMUINT64 FLMAPI getID( FLMUINT uiElementNumber) = 0; - virtual FLMUINT XFLMAPI getNameId( + virtual FLMUINT FLMAPI getNameId( FLMUINT uiElementNumber) = 0; - virtual FLMBOOL XFLMAPI isAttr( + virtual FLMBOOL FLMAPI isAttr( FLMUINT uiElementNumber) = 0; - virtual FLMBOOL XFLMAPI isDataComponent( + virtual FLMBOOL FLMAPI isDataComponent( FLMUINT uiElementNumber) = 0; - virtual FLMBOOL XFLMAPI isKeyComponent( + virtual FLMBOOL FLMAPI isKeyComponent( FLMUINT uiElementNumber) = 0; - virtual FLMUINT XFLMAPI getDataLength( + virtual FLMUINT FLMAPI getDataLength( FLMUINT uiElementNumber) = 0; - virtual FLMUINT XFLMAPI getDataType( + virtual FLMUINT FLMAPI getDataType( FLMUINT uiElementNumber) = 0; - virtual RCODE XFLMAPI getUTF8Ptr( + virtual RCODE FLMAPI getUTF8Ptr( FLMUINT uiElementNumber, const FLMBYTE ** ppszUTF8, FLMUINT * puiBufLen) = 0; - virtual RCODE XFLMAPI getINT( + virtual RCODE FLMAPI getINT( FLMUINT uiElementNumber, FLMINT * piNum) = 0; - virtual RCODE XFLMAPI getINT64( + virtual RCODE FLMAPI getINT64( FLMUINT uiElementNumber, FLMINT64 * pi64Num) = 0; - virtual RCODE XFLMAPI getUINT( + virtual RCODE FLMAPI getUINT( FLMUINT uiElementNumber, FLMUINT * puiNum) = 0; - virtual RCODE XFLMAPI getUINT64( + virtual RCODE FLMAPI getUINT64( FLMUINT uiElementNumber, FLMUINT64 * pui64Num) = 0; - virtual RCODE XFLMAPI getUnicode( + virtual RCODE FLMAPI getUnicode( FLMUINT uiElementNumber, FLMUNICODE ** ppuzUnicode) = 0; - virtual RCODE XFLMAPI getUnicode( + virtual RCODE FLMAPI getUnicode( FLMUINT uiElementNumber, FLMUNICODE * puzUnicode, FLMUINT * puiBufLen) = 0; - virtual RCODE XFLMAPI getUnicode( + virtual RCODE FLMAPI getUnicode( FLMUINT uiElementNumber, IF_DynaBuf * pBuffer) = 0; - virtual RCODE XFLMAPI getUTF8( + virtual RCODE FLMAPI getUTF8( FLMUINT uiElementNumber, FLMBYTE * pszUTF8, FLMUINT * puiBufLen) = 0; - virtual RCODE XFLMAPI getBinary( + virtual RCODE FLMAPI getBinary( FLMUINT uiElementNumber, void * pvBuffer, FLMUINT * puiBufferLen) = 0; - virtual RCODE XFLMAPI outputKey( + virtual RCODE FLMAPI outputKey( IF_Db * pDb, FLMUINT uiIndexNum, FLMUINT uiMatchFlags, @@ -4184,20 +3623,20 @@ FLMUINT uiKeyBufSize, FLMUINT * puiKeyLen) = 0; - virtual RCODE XFLMAPI outputData( + virtual RCODE FLMAPI outputData( IF_Db * pDb, FLMUINT uiIndexNum, FLMBYTE * pucDataBuf, FLMUINT uiDataBufSize, FLMUINT * puiDataLen) = 0; - virtual RCODE XFLMAPI inputKey( + virtual RCODE FLMAPI inputKey( IF_Db * pDb, FLMUINT uiIndexNum, const FLMBYTE * pucKey, FLMUINT uiKeyLen) = 0; - virtual RCODE XFLMAPI inputData( + virtual RCODE FLMAPI inputData( IF_Db * pDb, FLMUINT uiIndexNum, const FLMBYTE * pucData, @@ -4205,107 +3644,31 @@ // Miscellaneous methods - virtual void XFLMAPI reset( void) = 0; + virtual void FLMAPI reset( void) = 0; - virtual const void * XFLMAPI getDataPtr( + virtual const void * FLMAPI getDataPtr( FLMUINT uiElementNumber) = 0; }; /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_Backup : public XF_RefCount + flminterface IF_Backup : public F_Object { - virtual FLMUINT64 XFLMAPI getBackupTransId( void) = 0; + virtual FLMUINT64 FLMAPI getBackupTransId( void) = 0; - virtual FLMUINT64 XFLMAPI getLastBackupTransId( void) = 0; + virtual FLMUINT64 FLMAPI getLastBackupTransId( void) = 0; - virtual RCODE XFLMAPI backup( + virtual RCODE FLMAPI backup( const char * pszBackupPath, const char * pszPassword, IF_BackupClient * ifpClient, IF_BackupStatus * ifpStatus, FLMUINT * puiIncSeqNum) = 0; - virtual RCODE XFLMAPI endBackup( void) = 0; + virtual RCODE FLMAPI endBackup( void) = 0; }; - /**************************************************************************** - Desc: - ****************************************************************************/ - xflminterface IF_ThreadInfo : public XF_RefCount - { - virtual FLMUINT XFLMAPI getNumThreads( void) = 0; - - virtual void XFLMAPI getThreadInfo( - FLMUINT uiThreadNum, - FLMUINT * puiThreadId, - FLMUINT * puiThreadGroup, - FLMUINT * puiAppId, - FLMUINT * puiStartTime, - const char ** ppszThreadName, - const char ** ppszThreadStatus) = 0; - }; - - /**************************************************************************** - Desc: - ****************************************************************************/ - xflminterface IF_IStream : public XF_RefCount - { - /** - * @brief Reads data from the input stream. - * - */ - virtual RCODE XFLMAPI read( - void * pvBuffer, - FLMUINT uiBytesToRead, - FLMUINT * puiBytesRead = NULL) = 0; - - /** - * @brief Close the input stream. - * - */ - virtual RCODE XFLMAPI close( void) = 0; - }; - - /**************************************************************************** - Desc: - ****************************************************************************/ - xflminterface IF_PosIStream : public IF_IStream - { - virtual FLMUINT64 XFLMAPI totalSize( void) = 0; - - virtual FLMUINT64 XFLMAPI remainingSize( void) = 0; - - virtual RCODE XFLMAPI positionTo( - FLMUINT64 ui64Position) = 0; - - virtual FLMUINT64 XFLMAPI getCurrPosition( void) = 0; - }; - - - /**************************************************************************** - Desc: - ****************************************************************************/ - xflminterface IF_OStream : public XF_RefCount - { - /** - * @brief Writes data to the output stream. - * - */ - virtual RCODE XFLMAPI write( - const void * pvBuffer, - FLMUINT uiBytesToWrite, - FLMUINT * puiBytesWritten = NULL) = 0; - - /** - * @brief Close the output stream. - * - */ - virtual RCODE XFLMAPI close( void) = 0; - }; - - // Note: Any interfaces ending in Client or Status are interfaces // that XFlaim does not provide implementations of. They exist to // allow XFlaim to pass data back to the client. Interfaces ending in @@ -4316,9 +3679,9 @@ /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_BackupClient : public XF_RefCount + flminterface IF_BackupClient : public F_Object { - virtual RCODE XFLMAPI WriteData( + virtual RCODE FLMAPI WriteData( const void * pvBuffer, FLMUINT uiBytesToWrite) = 0; }; @@ -4326,9 +3689,9 @@ /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_BackupStatus : public XF_RefCount + flminterface IF_BackupStatus : public F_Object { - virtual RCODE XFLMAPI backupStatus( + virtual RCODE FLMAPI backupStatus( FLMUINT64 ui64BytesToDo, FLMUINT64 ui64BytesDone) = 0; }; @@ -4336,18 +3699,18 @@ /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_CommitClient : public XF_RefCount + flminterface IF_CommitClient : public F_Object { - virtual void XFLMAPI commit( + virtual void FLMAPI commit( IF_Db * pDb) = 0; }; /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_EventClient : public XF_RefCount + flminterface IF_EventClient : public F_Object { - virtual void XFLMAPI catchEvent( + virtual void FLMAPI catchEvent( eEventType eEvent, IF_Db * pDb, FLMUINT uiThreadId, @@ -4360,9 +3723,9 @@ /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_IxClient : public XF_RefCount + flminterface IF_IxClient : public F_Object { - virtual RCODE XFLMAPI doIndexing( + virtual RCODE FLMAPI doIndexing( IF_Db * pDb, FLMUINT uiIndexNum, FLMUINT uiCollectionNum, @@ -4372,12 +3735,12 @@ /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_LockInfoClient : public XF_RefCount + flminterface IF_LockInfoClient : public F_Object { - virtual FLMBOOL XFLMAPI setLockCount( // Return TRUE to continue, FALSE to stop + virtual FLMBOOL FLMAPI setLockCount( // Return TRUE to continue, FALSE to stop FLMUINT uiTotalLocks) = 0; - virtual FLMBOOL XFLMAPI addLockInfo( // Return TRUE to continue, FALSE to stop + virtual FLMBOOL FLMAPI addLockInfo( // Return TRUE to continue, FALSE to stop FLMUINT uiLockNum, // Position in queue (0 = lock holder, // 1 ... n = lock waiter) FLMUINT uiThreadID, // Thread ID of the lock holder/waiter @@ -4391,73 +3754,39 @@ /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_LoggerClient : public XF_RefCount + flminterface IF_RestoreStatus : public F_Object { - virtual IF_LogMessageClient * XFLMAPI beginMessage( - eLogMessageType eMsgType) = 0; - }; - - /**************************************************************************** - Desc: - ****************************************************************************/ - xflminterface IF_LogMessageClient : public XF_RefCount - { - virtual void XFLMAPI changeColor( - eColorType eForeColor, - eColorType eBackColor) = 0; - - virtual void XFLMAPI appendString( - const char * pszStr) = 0; - - virtual void XFLMAPI newline( void) = 0; - - virtual void XFLMAPI endMessage( void) = 0; - - virtual void XFLMAPI pushForegroundColor( void) = 0; - - virtual void XFLMAPI popForegroundColor( void) = 0; - - virtual void XFLMAPI pushBackgroundColor( void) = 0; - - virtual void XFLMAPI popBackgroundColor( void) = 0; - }; - - /**************************************************************************** - Desc: - ****************************************************************************/ - xflminterface IF_RestoreStatus : public XF_RefCount - { - virtual RCODE XFLMAPI reportProgress( + virtual RCODE FLMAPI reportProgress( eRestoreAction * peAction, FLMUINT64 ui64BytesToDo, FLMUINT64 ui64BytesDone) = 0; - virtual RCODE XFLMAPI reportError( + virtual RCODE FLMAPI reportError( eRestoreAction * peAction, RCODE rcErr) = 0; - virtual RCODE XFLMAPI reportOpenRflFile( + virtual RCODE FLMAPI reportOpenRflFile( eRestoreAction * peAction, FLMUINT uiFileNum) = 0; - virtual RCODE XFLMAPI reportRflRead( + virtual RCODE FLMAPI reportRflRead( eRestoreAction * peAction, FLMUINT uiFileNum, FLMUINT uiBytesRead) = 0; - virtual RCODE XFLMAPI reportBeginTrans( + virtual RCODE FLMAPI reportBeginTrans( eRestoreAction * peAction, FLMUINT64 ui64TransId) = 0; - virtual RCODE XFLMAPI reportCommitTrans( + virtual RCODE FLMAPI reportCommitTrans( eRestoreAction * peAction, FLMUINT64 ui64TransId) = 0; - virtual RCODE XFLMAPI reportAbortTrans( + virtual RCODE FLMAPI reportAbortTrans( eRestoreAction * peAction, FLMUINT64 ui64TransId) = 0; - virtual RCODE XFLMAPI reportBlockChainFree( + virtual RCODE FLMAPI reportBlockChainFree( eRestoreAction * peAction, FLMUINT64 ui64TransId, FLMUINT64 ui64MaintDocNum, @@ -4465,66 +3794,66 @@ FLMUINT uiEndBlkAddr, FLMUINT uiCount) = 0; - virtual RCODE XFLMAPI reportIndexSuspend( + virtual RCODE FLMAPI reportIndexSuspend( eRestoreAction * peAction, FLMUINT64 ui64TransId, FLMUINT uiIndexNum) = 0; - virtual RCODE XFLMAPI reportIndexResume( + virtual RCODE FLMAPI reportIndexResume( eRestoreAction * peAction, FLMUINT64 ui64TransId, FLMUINT uiIndexNum) = 0; - virtual RCODE XFLMAPI reportReduce( + virtual RCODE FLMAPI reportReduce( eRestoreAction * peAction, FLMUINT64 ui64TransId, FLMUINT uiCount) = 0; - virtual RCODE XFLMAPI reportUpgrade( + virtual RCODE FLMAPI reportUpgrade( eRestoreAction * peAction, FLMUINT64 ui64TransId, FLMUINT uiOldDbVersion, FLMUINT uiNewDbVersion) = 0; - virtual RCODE XFLMAPI reportEnableEncryption( + virtual RCODE FLMAPI reportEnableEncryption( eRestoreAction * peAction, FLMUINT64 ui64TransId) = 0; - virtual RCODE XFLMAPI reportWrapKey( + virtual RCODE FLMAPI reportWrapKey( eRestoreAction * peAction, FLMUINT64 ui64TransId) = 0; - virtual RCODE XFLMAPI reportRollOverDbKey( + virtual RCODE FLMAPI reportRollOverDbKey( eRestoreAction * peAction, FLMUINT64 ui64TransId) = 0; - virtual RCODE XFLMAPI reportDocumentDone( + virtual RCODE FLMAPI reportDocumentDone( eRestoreAction * peAction, FLMUINT64 ui64TransId, FLMUINT uiCollection, FLMUINT64 ui64DocumentId) = 0; - virtual RCODE XFLMAPI reportNodeDelete( + virtual RCODE FLMAPI reportNodeDelete( eRestoreAction * peAction, FLMUINT64 ui64TransId, FLMUINT uiCollection, FLMUINT64 ui64NodeId) = 0; - virtual RCODE XFLMAPI reportAttributeDelete( + virtual RCODE FLMAPI reportAttributeDelete( eRestoreAction * peAction, FLMUINT64 ui64TransId, FLMUINT uiCollection, FLMUINT64 ui64ElementId, FLMUINT uiAttrNameId) = 0; - virtual RCODE XFLMAPI reportNodeChildrenDelete( + virtual RCODE FLMAPI reportNodeChildrenDelete( eRestoreAction * peAction, FLMUINT64 ui64TransId, FLMUINT uiCollection, FLMUINT64 ui64ParentNodeId, FLMUINT uiNameId) = 0; - virtual RCODE XFLMAPI reportNodeCreate( + virtual RCODE FLMAPI reportNodeCreate( eRestoreAction * peAction, FLMUINT64 ui64TransId, FLMUINT uiCollection, @@ -4533,7 +3862,7 @@ FLMUINT uiNameId, eNodeInsertLoc eLocation) = 0; - virtual RCODE XFLMAPI reportInsertBefore( + virtual RCODE FLMAPI reportInsertBefore( eRestoreAction * peAction, FLMUINT64 ui64TransId, FLMUINT uiCollection, @@ -4541,26 +3870,26 @@ FLMUINT64 ui64NewChildNodeId, FLMUINT64 ui64RefChildNodeId) = 0; - virtual RCODE XFLMAPI reportNodeUpdate( + virtual RCODE FLMAPI reportNodeUpdate( eRestoreAction * peAction, FLMUINT64 ui64TransId, FLMUINT uiCollection, FLMUINT64 ui64NodeId) = 0; - virtual RCODE XFLMAPI reportNodeSetValue( + virtual RCODE FLMAPI reportNodeSetValue( eRestoreAction * peAction, FLMUINT64 ui64TransId, FLMUINT uiCollection, FLMUINT64 ui64NodeId) = 0; - virtual RCODE XFLMAPI reportAttributeSetValue( + virtual RCODE FLMAPI reportAttributeSetValue( eRestoreAction * peAction, FLMUINT64 ui64TransId, FLMUINT uiCollection, FLMUINT64 ui64ElementNodeId, FLMUINT uiAttrNameId) = 0; - virtual RCODE XFLMAPI reportNodeFlagsUpdate( + virtual RCODE FLMAPI reportNodeFlagsUpdate( eRestoreAction * peAction, FLMUINT64 ui64TransId, FLMUINT uiCollection, @@ -4568,7 +3897,7 @@ FLMUINT uiFlags, FLMBOOL bAdd) = 0; - virtual RCODE XFLMAPI reportNodeSetPrefixId( + virtual RCODE FLMAPI reportNodeSetPrefixId( eRestoreAction * peAction, FLMUINT64 ui64TransId, FLMUINT uiCollection, @@ -4576,14 +3905,14 @@ FLMUINT uiAttrNameId, FLMUINT uiPrefixId) = 0; - virtual RCODE XFLMAPI reportNodeSetMetaValue( + virtual RCODE FLMAPI reportNodeSetMetaValue( eRestoreAction * peAction, FLMUINT64 ui64TransId, FLMUINT uiCollection, FLMUINT64 ui64NodeId, FLMUINT64 ui64MetaValue) = 0; - virtual RCODE XFLMAPI reportSetNextNodeId( + virtual RCODE FLMAPI reportSetNextNodeId( eRestoreAction * peAction, FLMUINT64 ui64TransId, FLMUINT uiCollection, @@ -4593,52 +3922,40 @@ /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_RestoreClient : public XF_RefCount + flminterface IF_RestoreClient : public F_Object { - virtual RCODE XFLMAPI openBackupSet( void) = 0; + virtual RCODE FLMAPI openBackupSet( void) = 0; - virtual RCODE XFLMAPI openRflFile( // Open an RFL file + virtual RCODE FLMAPI openRflFile( // Open an RFL file FLMUINT uiFileNum) = 0; - virtual RCODE XFLMAPI openIncFile( // Open an incremental backup file + virtual RCODE FLMAPI openIncFile( // Open an incremental backup file FLMUINT uiFileNum) = 0; - virtual RCODE XFLMAPI read( + virtual RCODE FLMAPI read( FLMUINT uiLength, // Number of bytes to read void * pvBuffer, // Buffer to place read bytes into FLMUINT * puiBytesRead) = 0; // [out] Number of bytes read - virtual RCODE XFLMAPI close( void) = 0; // Close the current file + virtual RCODE FLMAPI close( void) = 0; // Close the current file - virtual RCODE XFLMAPI abortFile( void) = 0; // Abort processing the file + virtual RCODE FLMAPI abortFile( void) = 0; // Abort processing the file // and close file handles, etc. }; /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_UpgradeClient : public XF_RefCount + flminterface IF_UpgradeClient : public F_Object { }; /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_DeleteStatus : public XF_RefCount + flminterface IF_DbCopyStatus : public F_Object { - virtual RCODE XFLMAPI reportDelete( - FLMUINT uiIndexOrCollectionNum, - FLMBOOL bIsIndex, - FLMUINT uiBlocksDeleted, - FLMUINT uiBlockSize) = 0; - }; - - /**************************************************************************** - Desc: - ****************************************************************************/ - xflminterface IF_DbCopyStatus : public XF_RefCount - { - virtual RCODE XFLMAPI dbCopyStatus( + virtual RCODE FLMAPI dbCopyStatus( FLMUINT64 ui64BytesToCopy, FLMUINT64 ui64BytesCopied, FLMBOOL bNewSrcFile, @@ -4649,24 +3966,24 @@ /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_DbRebuildStatus : public XF_RefCount + flminterface IF_DbRebuildStatus : public F_Object { - virtual RCODE XFLMAPI reportRebuild( + virtual RCODE FLMAPI reportRebuild( XFLM_REBUILD_INFO * pRebuild) = 0; - virtual RCODE XFLMAPI reportRebuildErr( + virtual RCODE FLMAPI reportRebuildErr( XFLM_CORRUPT_INFO * pCorruptInfo) = 0; }; /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_DbCheckStatus : public XF_RefCount + flminterface IF_DbCheckStatus : public F_Object { - virtual RCODE XFLMAPI reportProgress( + virtual RCODE FLMAPI reportProgress( XFLM_PROGRESS_CHECK_INFO * pProgCheck) = 0; - virtual RCODE XFLMAPI reportCheckErr( + virtual RCODE FLMAPI reportCheckErr( XFLM_CORRUPT_INFO * pCorruptInfo, FLMBOOL * pbFix) = 0; // [OUT] - If the client sets this to true, then XFlaim will @@ -4680,9 +3997,9 @@ /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_DbRenameStatus : public XF_RefCount + flminterface IF_DbRenameStatus : public F_Object { - virtual RCODE XFLMAPI dbRenameStatus( + virtual RCODE FLMAPI dbRenameStatus( const char * pszSrcFileName, const char * pszDstFileName) = 0; }; @@ -4690,270 +4007,47 @@ /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_IxStatus : public XF_RefCount + flminterface IF_IxStatus : public F_Object { - virtual RCODE XFLMAPI reportIndex( + virtual RCODE FLMAPI reportIndex( FLMUINT64 ui64LastDocumentId) = 0; }; /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_FileSystem : public XF_RefCount + flminterface IF_DbInfo : public F_Object { - virtual RCODE XFLMAPI Create( - const char * pszFileName, - FLMUINT uiIoFlags, - IF_FileHdl ** ppFileHdl) = 0; - - virtual RCODE XFLMAPI CreateBlockFile( - const char * pszFileName, - FLMUINT uiIoFlags, - FLMUINT uiBlockSize, - IF_FileHdl ** ppFileHdl) = 0; - - virtual RCODE XFLMAPI CreateUnique( - const char * pszDirName, - const char * pszFileExtension, - FLMUINT uiIoFlags, - IF_FileHdl ** ppFileHdl) = 0; - - virtual RCODE XFLMAPI Open( - const char * pszFileName, - FLMUINT uiIoFlags, - IF_FileHdl ** ppFileHdl) = 0; - - virtual RCODE XFLMAPI OpenBlockFile( - const char * pszFileName, - FLMUINT uiIoFlags, - FLMUINT uiBlockSize, - IF_FileHdl ** ppFileHdl) = 0; - - virtual RCODE XFLMAPI OpenDir( - const char * pszDirName, - const char * pszPattern, - IF_DirHdl ** ppDirHdl) = 0; - - virtual RCODE XFLMAPI CreateDir( - const char * pszDirName) = 0; - - virtual RCODE XFLMAPI RemoveDir( - const char * pszDirName, - FLMBOOL bClear = FALSE) = 0; - - virtual RCODE XFLMAPI Exists( - const char * pszFileName) = 0; - - virtual FLMBOOL XFLMAPI IsDir( - const char * pszFileName) = 0; - - virtual RCODE XFLMAPI GetTimeStamp( - const char * pszFileName, - FLMUINT * puiTimeStamp) = 0; - - virtual RCODE XFLMAPI Delete( - const char * pszFileName) = 0; - - virtual RCODE XFLMAPI Copy( - const char * pszSrcFileName, - const char * pszDestFileName, - FLMBOOL bOverwrite, - FLMUINT64 * pui64BytesCopied) = 0; - - virtual RCODE XFLMAPI Rename( - const char * pszFileName, - const char * pszNewFileName) = 0; - - virtual RCODE XFLMAPI GetSectorSize( - const char * pszFileName, - FLMUINT * puiSectorSize) = 0; - - virtual void XFLMAPI pathParse( - const char * pszPath, - char * pszServer, - char * pszVolume, - char * pszDirPath, - char * pszFileName) = 0; - - virtual RCODE XFLMAPI pathReduce( - const char * pszSourcePath, - char * pszDestPath, - char * pszString) = 0; - - virtual RCODE XFLMAPI pathAppend( - char * pszPath, - const char * pszPathComponent) = 0; - - virtual RCODE XFLMAPI pathToStorageString( - const char * pPath, - char * pszString) = 0; - - virtual void XFLMAPI pathCreateUniqueName( - FLMUINT * puiTime, - char * pFileName, - const char * pFileExt, - FLMBYTE * pHighChars, - FLMBOOL bModext) = 0; - - virtual FLMBOOL XFLMAPI doesFileMatch( - const char * pszFileName, - const char * pszTemplate) = 0; - }; - - /**************************************************************************** - Desc: - ****************************************************************************/ - xflminterface IF_FileHdl : public XF_RefCount - { - virtual RCODE XFLMAPI Close( void) = 0; - - virtual RCODE XFLMAPI Create( - const char * pszFileName, - FLMUINT uiIoFlags) = 0; - - virtual RCODE XFLMAPI CreateUnique( - const char * pszDirName, - const char * pszFileExtension, - FLMUINT uiIoFlags) = 0; - - virtual RCODE XFLMAPI Open( - const char * pszFileName, - FLMUINT uiIoFlags) = 0; - - virtual RCODE XFLMAPI Flush( void) = 0; - - virtual RCODE XFLMAPI Read( - FLMUINT64 ui64Offset, - FLMUINT uiLength, - void * pvBuffer, - FLMUINT * puiBytesRead) = 0; - - virtual RCODE XFLMAPI Seek( - FLMUINT64 ui64Offset, - FLMINT iWhence, - FLMUINT64 * pui64NewOffset) = 0; - - virtual RCODE XFLMAPI Size( - FLMUINT64 * pui64Size) = 0; - - virtual RCODE XFLMAPI Tell( - FLMUINT64 * pui64Offset) = 0; - - virtual RCODE XFLMAPI Truncate( - FLMUINT64 ui64Size) = 0; - - virtual RCODE XFLMAPI Write( - FLMUINT64 ui64Offset, - FLMUINT uiLength, - const void * pvBuffer, - FLMUINT * puiBytesWritten) = 0; - - // Some I/O subsystems (such as direct IO) can only read and write sectors - // (512 byte chunks). If uiOffset is not on a sector boundary or - // uiLength is not an exact multiple of a sector size, the I/O system - // would have to try to read or write a partial sector - something that - // requires extra overhead, particularly for write operations - because - // in order to write a partial sector, the I/O subsystem first has to - // read the sector in to memory before writing it out in order to - // preserve the part of the sector that was not being written to. - - // The SectorRead and SectorWrite routines are provided to allow - // the caller to tell the I/O subsystem that it is OK to do full - // sector reads or writes if it needs to, because pvBuffer is - // guaranteed to be a multiple of 512 bytes big. If the I/O - // subsystem can only do sector reads and writes, it can use the - // extra buffer space in pvBuffer. When a program calls SectorWrite - // it is also telling the I/O subsystem that it does not need to - // read a partially written sector from disk before writing it out. - // It will be OK to write whatever data is in the pvBuffer to fill out - // the sector. - - virtual RCODE XFLMAPI SectorRead( - FLMUINT64 ui64ReadOffset, - FLMUINT uiBytesToRead, - void * pvBuffer, - FLMUINT * puiBytesReadRV) = 0; - - virtual RCODE XFLMAPI SectorWrite( - FLMUINT64 ui64WriteOffset, - FLMUINT uiBytesToWrite, - const void * pvBuffer, - FLMUINT uiBufferSize, - void * pvBufferObj, - FLMUINT * puiBytesWrittenRV, - FLMBOOL bZeroFill = TRUE) = 0; - - virtual FLMBOOL XFLMAPI CanDoAsync( void) = 0; - - virtual void XFLMAPI setExtendSize( - FLMUINT uiExtendSize) = 0; - - virtual void XFLMAPI setMaxAutoExtendSize( - FLMUINT uiMaxAutoExtendSize) = 0; - }; - - /**************************************************************************** - Desc: - ****************************************************************************/ - xflminterface IF_DirHdl : public XF_RefCount - { - virtual RCODE XFLMAPI Next( void) = 0; - - virtual const char * XFLMAPI CurrentItemName( void) = 0; - - virtual void XFLMAPI CurrentItemPath( - char * pszPath) = 0; - - virtual FLMUINT64 XFLMAPI CurrentItemSize( void) = 0; - - virtual FLMBOOL XFLMAPI CurrentItemIsDir( void) = 0; - - virtual RCODE XFLMAPI OpenDir( - const char * pszDirName, - const char * pszPattern) = 0; - - virtual RCODE XFLMAPI CreateDir( - const char * pDirName) = 0; - - virtual RCODE XFLMAPI RemoveDir( - const char * pDirPath) = 0; - }; - - /**************************************************************************** - Desc: - ****************************************************************************/ - xflminterface IF_DbInfo : public XF_RefCount - { - virtual FLMUINT XFLMAPI getNumCollections( void) = 0; + virtual FLMUINT FLMAPI getNumCollections( void) = 0; - virtual FLMUINT XFLMAPI getNumIndexes( void) = 0; + virtual FLMUINT FLMAPI getNumIndexes( void) = 0; - virtual FLMUINT XFLMAPI getNumLogicalFiles( void) = 0; + virtual FLMUINT FLMAPI getNumLogicalFiles( void) = 0; - virtual FLMUINT64 XFLMAPI getFileSize( void) = 0; + virtual FLMUINT64 FLMAPI getFileSize( void) = 0; - virtual const XFLM_DB_HDR * XFLMAPI getDbHdr( void) = 0; + virtual const XFLM_DB_HDR * FLMAPI getDbHdr( void) = 0; - virtual void XFLMAPI getAvailBlockStats( + virtual void FLMAPI getAvailBlockStats( FLMUINT64 * pui64BytesUsed, FLMUINT * puiBlockCount, FLMINT * piLastError, FLMUINT * puiNumErrors) = 0; - virtual void XFLMAPI getLFHBlockStats( + virtual void FLMAPI getLFHBlockStats( FLMUINT64 * pui64BytesUsed, FLMUINT * puiBlockCount, FLMINT * piLastError, FLMUINT * puiNumErrors) = 0; - virtual void XFLMAPI getBTreeInfo( + virtual void FLMAPI getBTreeInfo( FLMUINT uiNthLogicalFile, FLMUINT * puiLfNum, eLFileType * peLfType, FLMUINT * puiRootBlkAddress, FLMUINT * puiNumLevels) = 0; - virtual void XFLMAPI getBTreeBlockStats( + virtual void FLMAPI getBTreeBlockStats( FLMUINT uiNthLogicalFile, FLMUINT uiLevel, FLMUINT64 * pui64KeyCount, @@ -4969,123 +4063,20 @@ /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_ResultSetCompare : public XF_RefCount + flminterface IF_QueryStatus : public F_Object { - virtual RCODE XFLMAPI compare( - const void * pvData1, - FLMUINT uiLength1, - const void * pvData2, - FLMUINT uiLength2, - FLMINT * piCompare) = 0; - }; - - /**************************************************************************** - Desc: - ****************************************************************************/ - xflminterface IF_ResultSetSortStatus : public XF_RefCount - { - virtual RCODE XFLMAPI reportSortStatus( - FLMUINT64 ui64EstTotalUnits, - FLMUINT64 ui64UnitsDone) = 0; - }; - - /**************************************************************************** - Desc: - ****************************************************************************/ - xflminterface IF_ResultSet : public XF_RefCount - { - virtual RCODE XFLMAPI setupResultSet( - const char * pszPath, - IF_ResultSetCompare * pCompare, - FLMUINT uiEntrySize, - FLMBOOL bDropDuplicates = TRUE, - FLMBOOL bEntriesInOrder = FALSE, - const char * pszFileName = NULL) = 0; - - virtual void XFLMAPI setSortStatus( - IF_ResultSetSortStatus * pSortStatus) = 0; - - virtual FLMUINT64 XFLMAPI getTotalEntries( void) = 0; - - // Methods for building a result set. - - virtual RCODE XFLMAPI addEntry( - const void * pvEntry, - FLMUINT uiEntryLength = 0) = 0; - - virtual RCODE XFLMAPI finalizeResultSet( - FLMUINT64 * pui64TotalEntries = NULL) = 0; - - // Methods for reading entries from a result set - - virtual RCODE XFLMAPI getFirst( - void * pvEntryBuffer, - FLMUINT uiBufferLength = 0, - FLMUINT * puiEntryLength = NULL) = 0; - - virtual RCODE XFLMAPI getNext( - void * pvEntryBuffer, - FLMUINT uiBufferLength = 0, - FLMUINT * puiEntryLength = NULL) = 0; - - virtual RCODE XFLMAPI getLast( - void * pvEntryBuffer, - FLMUINT uiBufferLength = 0, - FLMUINT * puiEntryLength = NULL) = 0; - - virtual RCODE XFLMAPI getPrev( - void * pvEntryBuffer, - FLMUINT uiBufferLength = 0, - FLMUINT * puiEntryLength = NULL) = 0; - - virtual RCODE XFLMAPI getCurrent( - void * pvEntryBuffer, - FLMUINT uiBufferLength = 0, - FLMUINT * puiEntryLength = NULL) = 0; - - virtual RCODE XFLMAPI findMatch( - const void * pvMatchEntry, - void * pvFoundEntry) = 0; - - virtual RCODE XFLMAPI findMatch( - const void * pvMatchEntry, - FLMUINT uiMatchEntryLength, - void * pvFoundEntry, - FLMUINT * puiFoundEntryLength) = 0; - - virtual RCODE XFLMAPI modifyCurrent( - const void * pvEntry, - FLMUINT uiEntryLength = 0) = 0; - - virtual FLMUINT64 XFLMAPI getPosition( void) = 0; - - virtual RCODE XFLMAPI setPosition( - FLMUINT64 ui64Position) = 0; - - virtual RCODE XFLMAPI resetResultSet( - FLMBOOL bDelete = TRUE) = 0; - - virtual RCODE XFLMAPI flushToFile( void) = 0; - - }; - - /**************************************************************************** - Desc: - ****************************************************************************/ - xflminterface IF_QueryStatus : public XF_RefCount - { - virtual RCODE XFLMAPI queryStatus( + virtual RCODE FLMAPI queryStatus( XFLM_OPT_INFO * pOptInfo) = 0; - virtual RCODE XFLMAPI newSource( + virtual RCODE FLMAPI newSource( XFLM_OPT_INFO * pOptInfo) = 0; - virtual RCODE XFLMAPI resultSetStatus( + virtual RCODE FLMAPI resultSetStatus( FLMUINT64 ui64TotalDocsRead, FLMUINT64 ui64TotalDocsPassed, FLMBOOL bCanRetrieveDocs) = 0; - virtual RCODE XFLMAPI resultSetComplete( + virtual RCODE FLMAPI resultSetComplete( FLMUINT64 ui64TotalDocsRead, FLMUINT64 ui64TotalDocsPassed) = 0; }; @@ -5093,9 +4084,9 @@ /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_QueryValidator : public XF_RefCount + flminterface IF_QueryValidator : public F_Object { - virtual RCODE XFLMAPI validateNode( + virtual RCODE FLMAPI validateNode( IF_Db * pDb, IF_DOMNode * pNode, FLMBOOL * pbPassed) = 0; @@ -5104,14 +4095,14 @@ /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_QueryValFunc : public XF_RefCount + flminterface IF_QueryValFunc : public F_Object { // NOTE: pDynaBuf should only be used when returning XFLM_UTF8_VAL or // XFLM_BINARY_VAL. pvVal should be used for all other types. // If there are no more values, return NE_XFLM_EOF_HIT or // NE_XFLM_BOF_HIT, depending on eValueToGet. - virtual RCODE XFLMAPI getValue( + virtual RCODE FLMAPI getValue( IF_Db * pDb, IF_DOMNode * pContextNode, ValIterator eValueToGet, @@ -5120,7 +4111,7 @@ void * pvVal, IF_DynaBuf * pDynaBuf = NULL) = 0; - virtual RCODE XFLMAPI cloneSelf( + virtual RCODE FLMAPI cloneSelf( IF_QueryValFunc ** ppNewObj) = 0; }; @@ -5129,14 +4120,14 @@ XFLAIM uses to allow an application to embed a node source inside an XPATH component. ============================================================================*/ - xflminterface IF_QueryNodeSource : public XF_RefCount + flminterface IF_QueryNodeSource : public F_Object { public: // Method that returns the search cost of this object in providing // nodes for a query. - virtual RCODE XFLMAPI searchCost( + virtual RCODE FLMAPI searchCost( IF_Db * pDb, FLMBOOL bNotted, FLMUINT * puiCost, @@ -5144,7 +4135,7 @@ // Position to and return the first node that satisfies the predicate. - virtual RCODE XFLMAPI getFirst( + virtual RCODE FLMAPI getFirst( IF_Db * pDb, IF_DOMNode * pContextNode, IF_DOMNode ** ppNode, @@ -5153,7 +4144,7 @@ // Position to and return the last node that satisfies the predicate. - virtual RCODE XFLMAPI getLast( + virtual RCODE FLMAPI getLast( IF_Db * pDb, IF_DOMNode * pContextNode, IF_DOMNode ** ppNode, @@ -5164,7 +4155,7 @@ // If no prior positioning has been done, // position to and return the first node. - virtual RCODE XFLMAPI getNext( + virtual RCODE FLMAPI getNext( IF_Db * pDb, IF_DOMNode * pContextNode, IF_DOMNode ** ppNode, @@ -5175,7 +4166,7 @@ // If no prior positioning has been done, // position to and return the last node. - virtual RCODE XFLMAPI getPrev( + virtual RCODE FLMAPI getPrev( IF_Db * pDb, IF_DOMNode * pContextNode, IF_DOMNode ** ppNode, @@ -5184,16 +4175,16 @@ // Return index being used, 0 if none. - virtual RCODE XFLMAPI getIndex( + virtual RCODE FLMAPI getIndex( IF_Db * pDb, FLMUINT * puiIndex, FLMBOOL * pbHaveMultiple) = 0; - virtual RCODE XFLMAPI getOptInfoCount( + virtual RCODE FLMAPI getOptInfoCount( IF_Db * pDb, FLMUINT * puiOptInfoCount) = 0; - virtual RCODE XFLMAPI getOptInfo( + virtual RCODE FLMAPI getOptInfo( IF_Db * pDb, XFLM_OPT_INFO * pOptInfoArray, FLMUINT uiNumOptInfoStructsToGet) = 0; @@ -5212,9 +4203,9 @@ /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_OperandComparer : public XF_RefCount + flminterface IF_OperandComparer : public F_Object { - virtual RCODE XFLMAPI compare( + virtual RCODE FLMAPI compare( IF_PosIStream * pLeftOperandStream, IF_PosIStream * pRightOperandStream, FLMINT * piCompare) = 0; @@ -5225,119 +4216,119 @@ /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_Query : public XF_RefCount + flminterface IF_Query : public F_Object { - virtual RCODE XFLMAPI setLanguage( + virtual RCODE FLMAPI setLanguage( FLMUINT uiLanguage) = 0; - virtual RCODE XFLMAPI setCollection( + virtual RCODE FLMAPI setCollection( FLMUINT uiCollection) = 0; - virtual RCODE XFLMAPI setupQueryExpr( + virtual RCODE FLMAPI setupQueryExpr( IF_Db * pDb, const FLMUNICODE * puzQuery) = 0; - virtual RCODE XFLMAPI setupQueryExpr( + virtual RCODE FLMAPI setupQueryExpr( IF_Db * pDb, const char * pszQueryExpr) = 0; - virtual RCODE XFLMAPI copyCriteria( + virtual RCODE FLMAPI copyCriteria( IF_Query * pSrcQuery) = 0; - virtual RCODE XFLMAPI addXPathComponent( + virtual RCODE FLMAPI addXPathComponent( eXPathAxisTypes eXPathAxis, eDomNodeType eNodeType, FLMUINT uiNameId, IF_QueryNodeSource * pNodeSource = NULL) = 0; - virtual RCODE XFLMAPI addOperator( + virtual RCODE FLMAPI addOperator( eQueryOperators eOperator, FLMUINT uiCompareRules = 0, IF_OperandComparer * pOpComparer = NULL) = 0; - virtual RCODE XFLMAPI addUnicodeValue( + virtual RCODE FLMAPI addUnicodeValue( const FLMUNICODE * puzVal) = 0; - virtual RCODE XFLMAPI addUTF8Value( + virtual RCODE FLMAPI addUTF8Value( const char * pszVal, FLMUINT uiUTF8Len = 0) = 0; - virtual RCODE XFLMAPI addBinaryValue( + virtual RCODE FLMAPI addBinaryValue( const void * pvVal, FLMUINT uiValLen) = 0; - virtual RCODE XFLMAPI addUINTValue( + virtual RCODE FLMAPI addUINTValue( FLMUINT uiVal) = 0; - virtual RCODE XFLMAPI addINTValue( + virtual RCODE FLMAPI addINTValue( FLMINT iVal) = 0; - virtual RCODE XFLMAPI addUINT64Value( + virtual RCODE FLMAPI addUINT64Value( FLMUINT64 ui64Val) = 0; - virtual RCODE XFLMAPI addINT64Value( + virtual RCODE FLMAPI addINT64Value( FLMINT64 i64Val) = 0; - virtual RCODE XFLMAPI addBoolean( + virtual RCODE FLMAPI addBoolean( FLMBOOL bVal, FLMBOOL bUnknown = FALSE) = 0; - virtual RCODE XFLMAPI addFunction( + virtual RCODE FLMAPI addFunction( eQueryFunctions eFunction) = 0; - virtual RCODE XFLMAPI addFunction( + virtual RCODE FLMAPI addFunction( IF_QueryValFunc * pFuncObj, FLMBOOL bHasXPathExpr) = 0; - virtual RCODE XFLMAPI getFirst( + virtual RCODE FLMAPI getFirst( IF_Db * pDb, IF_DOMNode ** ppNode, FLMUINT uiTimeLimit = 0) = 0; // milliseconds - virtual RCODE XFLMAPI getLast( + virtual RCODE FLMAPI getLast( IF_Db * pDb, IF_DOMNode ** ppNode, FLMUINT uiTimeLimit = 0) = 0; // milliseconds - virtual RCODE XFLMAPI getNext( + virtual RCODE FLMAPI getNext( IF_Db * pDb, IF_DOMNode ** ppNode, FLMUINT uiTimeLimit = 0, // milliseconds FLMUINT uiNumToSkip = 0, FLMUINT * puiNumSkipped = NULL) = 0; - virtual RCODE XFLMAPI getPrev( + virtual RCODE FLMAPI getPrev( IF_Db * pDb, IF_DOMNode ** ppNode, FLMUINT uiTimeLimit = 0, // milliseconds FLMUINT uiNumToSkip = 0, FLMUINT * puiNumSkipped = NULL) = 0; - virtual RCODE XFLMAPI getCurrent( + virtual RCODE FLMAPI getCurrent( IF_Db * pDb, IF_DOMNode ** ppNode) = 0; - virtual void XFLMAPI resetQuery( void) = 0; + virtual void FLMAPI resetQuery( void) = 0; - virtual RCODE XFLMAPI getStatsAndOptInfo( + virtual RCODE FLMAPI getStatsAndOptInfo( FLMUINT * puiNumOptInfos, XFLM_OPT_INFO ** ppOptInfo) = 0; - virtual void XFLMAPI freeStatsAndOptInfo( + virtual void FLMAPI freeStatsAndOptInfo( XFLM_OPT_INFO ** ppOptInfo) = 0; - virtual void XFLMAPI setDupHandling( + virtual void FLMAPI setDupHandling( FLMBOOL bRemoveDups) = 0; - virtual RCODE XFLMAPI setIndex( + virtual RCODE FLMAPI setIndex( FLMUINT uiIndex) = 0; - virtual RCODE XFLMAPI getIndex( + virtual RCODE FLMAPI getIndex( IF_Db * pDb, FLMUINT * puiIndex, FLMBOOL * pbHaveMultiple) = 0; - virtual RCODE XFLMAPI addSortKey( + virtual RCODE FLMAPI addSortKey( void * pvSortKeyContext, FLMBOOL bChildToContext, FLMBOOL bElement, @@ -5349,32 +4340,32 @@ FLMBOOL bSortMissingHigh, void ** ppvContext) = 0; - virtual RCODE XFLMAPI enablePositioning( void) = 0; + virtual RCODE FLMAPI enablePositioning( void) = 0; - virtual RCODE XFLMAPI positionTo( + virtual RCODE FLMAPI positionTo( IF_Db * pDb, IF_DOMNode ** ppNode, FLMUINT uiTimeLimit, FLMUINT uiPosition) = 0; - virtual RCODE XFLMAPI positionTo( + virtual RCODE FLMAPI positionTo( IF_Db * pDb, IF_DOMNode ** ppNode, FLMUINT uiTimeLimit, IF_DataVector * pSearchKey, FLMUINT uiFlags) = 0; - virtual RCODE XFLMAPI getPosition( + virtual RCODE FLMAPI getPosition( IF_Db * pDb, FLMUINT * puiPosition) = 0; - virtual RCODE XFLMAPI buildResultSet( + virtual RCODE FLMAPI buildResultSet( IF_Db * pDb, FLMUINT uiTimeLimit) = 0; - virtual void XFLMAPI stopBuildingResultSet( void) = 0; + virtual void FLMAPI stopBuildingResultSet( void) = 0; - virtual RCODE XFLMAPI getCounts( + virtual RCODE FLMAPI getCounts( IF_Db * pDb, FLMUINT uiTimeLimit, FLMBOOL bPartialCountOk, @@ -5383,62 +4374,15 @@ FLMUINT * puiPositionableToCount, FLMBOOL * pbDoneBuildingResultSet = NULL) = 0; - virtual void XFLMAPI enableResultSetEncryption( void) = 0; + virtual void FLMAPI enableResultSetEncryption( void) = 0; - virtual void XFLMAPI setQueryStatusObject( + virtual void FLMAPI setQueryStatusObject( IF_QueryStatus * pQueryStatus) = 0; - virtual void XFLMAPI setQueryValidatorObject( + virtual void FLMAPI setQueryValidatorObject( IF_QueryValidator * pQueryValidator) = 0; }; - /**************************************************************************** - Desc: Pool memory allocator - ****************************************************************************/ - xflminterface IF_Pool : public XF_RefCount - { - virtual void poolInit( - FLMUINT uiBlockSize) = 0; - - virtual RCODE poolAlloc( - FLMUINT uiSize, - void ** ppvPtr) = 0; - - virtual RCODE poolCalloc( - FLMUINT uiSize, - void ** ppvPtr) = 0; - - virtual void poolFree( void) = 0; - - virtual void poolReset( - void * pvMark, - FLMBOOL bReduceFirstBlock = FALSE) = 0; - - virtual void * poolMark( void) = 0; - - virtual FLMUINT getBlockSize( void) = 0; - - virtual FLMUINT getBytesAllocated( void) = 0; - }; - - /**************************************************************************** - Desc: Dynamic buffer - ****************************************************************************/ - xflminterface IF_DynaBuf : public XF_RefCount - { - virtual void truncateData( - FLMUINT uiSize) = 0; - - virtual RCODE appendData( - const void * pvData, - FLMUINT uiSize) = 0; - - virtual RCODE allocSpace( - FLMUINT uiSize, - void ** ppvAlloc) = 0; - }; - - typedef struct XFLM_NODE_INFO_ITEM { FLMUINT64 ui64Count; @@ -5497,19 +4441,19 @@ /**************************************************************************** Desc: Node Info. Gatherer ****************************************************************************/ - xflminterface IF_NodeInfo : public XF_RefCount + flminterface IF_NodeInfo : public F_Object { - virtual void XFLMAPI clearNodeInfo( void) = 0; + virtual void FLMAPI clearNodeInfo( void) = 0; - virtual RCODE XFLMAPI addNodeInfo( + virtual RCODE FLMAPI addNodeInfo( IF_Db * pDb, IF_DOMNode * pNode, FLMBOOL bDoSubTree, FLMBOOL bDoSelf = TRUE) = 0; - virtual FLMUINT64 XFLMAPI getTotalNodeCount( void) = 0; + virtual FLMUINT64 FLMAPI getTotalNodeCount( void) = 0; - virtual void XFLMAPI getNodeInfo( + virtual void FLMAPI getNodeInfo( XFLM_NODE_INFO * pNodeInfo) = 0; }; @@ -5550,9 +4494,9 @@ /**************************************************************************** Desc: ****************************************************************************/ - xflminterface IF_BTreeInfoStatus : public XF_RefCount + flminterface IF_BTreeInfoStatus : public F_Object { - virtual RCODE XFLMAPI infoStatus( + virtual RCODE FLMAPI infoStatus( FLMUINT uiCurrLfNum, FLMBOOL bIsCollection, char * pszCurrLfName, @@ -5565,42 +4509,42 @@ /**************************************************************************** Desc: BTree Info. Gatherer ****************************************************************************/ - xflminterface IF_BTreeInfo : public XF_RefCount + flminterface IF_BTreeInfo : public F_Object { - virtual void XFLMAPI clearBTreeInfo( void) = 0; + virtual void FLMAPI clearBTreeInfo( void) = 0; - virtual RCODE XFLMAPI collectIndexInfo( + virtual RCODE FLMAPI collectIndexInfo( IF_Db * pDb, FLMUINT uiIndexNum, IF_BTreeInfoStatus * pInfoStatus) = 0; - virtual RCODE XFLMAPI collectCollectionInfo( + virtual RCODE FLMAPI collectCollectionInfo( IF_Db * pDb, FLMUINT uiCollectionNum, IF_BTreeInfoStatus * pInfoStatus) = 0; - virtual FLMUINT XFLMAPI getNumIndexes( void) = 0; + virtual FLMUINT FLMAPI getNumIndexes( void) = 0; - virtual FLMUINT XFLMAPI getNumCollections( void) = 0; + virtual FLMUINT FLMAPI getNumCollections( void) = 0; - virtual FLMBOOL XFLMAPI getIndexInfo( + virtual FLMBOOL FLMAPI getIndexInfo( FLMUINT uiNthIndex, FLMUINT * puiIndexNum, char ** ppszIndexName, FLMUINT * puiNumLevels) = 0; - virtual FLMBOOL XFLMAPI getCollectionInfo( + virtual FLMBOOL FLMAPI getCollectionInfo( FLMUINT uiNthCollection, FLMUINT * puiCollectionNum, char ** ppszCollectionName, FLMUINT * puiNumLevels) = 0; - virtual FLMBOOL XFLMAPI getIndexLevelInfo( + virtual FLMBOOL FLMAPI getIndexLevelInfo( FLMUINT uiNthIndex, FLMUINT uiBTreeLevel, XFLM_BTREE_LEVEL_INFO * pLevelInfo) = 0; - virtual FLMBOOL XFLMAPI getCollectionLevelInfo( + virtual FLMBOOL FLMAPI getCollectionLevelInfo( FLMUINT uiNthCollection, FLMUINT uiBTreeLevel, XFLM_BTREE_LEVEL_INFO * pLevelInfo) = 0; @@ -5609,218 +4553,202 @@ /**************************************************************************** Desc: Status and return codes ****************************************************************************/ - #ifndef RC_OK - #define RC_OK( rc) ((rc) == 0) - #endif - - #ifndef RC_BAD - #define RC_BAD( rc) ((rc) != 0) - #endif #define XFLM_ERROR_BASE(e) ((RCODE)((int)(0x81050000+(e)))) - /**************************************************************************** - Desc: General FLAIM errors - ****************************************************************************/ - #define NE_XFLM_OK 0 + #define NE_XFLM_NOT_IMPLEMENTED NE_FLM_NOT_IMPLEMENTED + #define NE_XFLM_MEM NE_FLM_MEM + #define NE_XFLM_INVALID_PARM NE_FLM_INVALID_PARM + #define NE_XFLM_TIMEOUT NE_FLM_TIMEOUT + #define NE_XFLM_NOT_FOUND NE_FLM_NOT_FOUND + #define NE_XFLM_EXISTS NE_FLM_EXISTS + #define NE_XFLM_USER_ABORT NE_FLM_USER_ABORT + #define NE_XFLM_FAILURE NE_FLM_FAILURE + #define NE_XFLM_BOF_HIT NE_FLM_BOF_HIT + #define NE_XFLM_EOF_HIT NE_FLM_EOF_HIT + #define NE_XFLM_CONV_BAD_DIGIT NE_FLM_CONV_BAD_DIGIT + #define NE_XFLM_CONV_DEST_OVERFLOW NE_FLM_CONV_DEST_OVERFLOW + #define NE_XFLM_CONV_ILLEGAL NE_FLM_CONV_ILLEGAL + #define NE_XFLM_CONV_NULL_SRC NE_FLM_CONV_NULL_SRC + #define NE_XFLM_CONV_NUM_OVERFLOW NE_FLM_CONV_NUM_OVERFLOW + #define NE_XFLM_CONV_NUM_UNDERFLOW NE_FLM_CONV_NUM_UNDERFLOW + #define NE_XFLM_SYNTAX NE_FLM_SYNTAX + #define NE_XFLM_UNSUPPORTED_FEATURE NE_FLM_UNSUPPORTED_FEATURE + #define NE_XFLM_FILE_EXISTS NE_FLM_FILE_EXISTS + #define NE_XFLM_COULD_NOT_CREATE_SEMAPHORE NE_FLM_COULD_NOT_CREATE_SEMAPHORE + #define NE_XFLM_BAD_UTF8 NE_FLM_BAD_UTF8 + #define NE_XFLM_ERROR_WAITING_ON_SEMPAHORE NE_FLM_ERROR_WAITING_ON_SEMPAHORE + #define NE_XFLM_BAD_PLATFORM_FORMAT NE_FLM_BAD_PLATFORM_FORMAT + #define NE_XFLM_BAD_SEN NE_FLM_BAD_SEN + #define NE_XFLM_UNSUPPORTED_INTERFACE NE_FLM_UNSUPPORTED_INTERFACE + #define NE_XFLM_BAD_RCODE_TABLE NE_FLM_BAD_RCODE_TABLE + #define NE_XFLM_BUFFER_OVERFLOW NE_FLM_BUFFER_OVERFLOW + #define NE_XFLM_INVALID_XML NE_FLM_INVALID_XML + #define NE_XFLM_ILLEGAL_FLAG NE_FLM_ILLEGAL_FLAG + #define NE_XFLM_ILLEGAL_OP NE_FLM_ILLEGAL_OP + #define NE_XFLM_COULD_NOT_START_THREAD NE_FLM_COULD_NOT_START_THREAD + #define NE_XFLM_BAD_BASE64_ENCODING NE_FLM_BAD_BASE64_ENCODING + #define NE_XFLM_STREAM_EXISTS NE_FLM_STREAM_EXISTS + #define NE_XFLM_MULTIPLE_MATCHES NE_FLM_MULTIPLE_MATCHES + #define NE_XFLM_NOT_UNIQUE NE_FLM_NOT_UNIQUE + #define NE_XFLM_BTREE_ERROR NE_FLM_BTREE_ERROR + #define NE_XFLM_BTREE_KEY_SIZE NE_FLM_BTREE_KEY_SIZE + #define NE_XFLM_BTREE_FULL NE_FLM_BTREE_FULL + #define NE_XFLM_BTREE_BAD_STATE NE_FLM_BTREE_BAD_STATE + #define NE_XFLM_COULD_NOT_CREATE_MUTEX NE_FLM_COULD_NOT_CREATE_MUTEX + #define NE_XFLM_DATA_ERROR NE_FLM_DATA_ERROR + #define NE_XFLM_BAD_DATA_TYPE NE_FLM_BAD_DATA_TYPE + #define NE_XFLM_READ_ONLY NE_FLM_READ_ONLY + #define NE_XFLM_KEY_OVERFLOW NE_FLM_KEY_OVERFLOW + #define NE_XFLM_UNEXPECTED_END_OF_INPUT NE_FLM_UNEXPECTED_END_OF_INPUT + #define NE_XFLM_IO_PATH_NOT_FOUND NE_FLM_IO_PATH_NOT_FOUND + #define NE_XFLM_IO_END_OF_FILE NE_FLM_IO_END_OF_FILE + #define NE_XFLM_IO_NO_MORE_FILES NE_FLM_IO_NO_MORE_FILES - #define NE_XFLM_FIRST_COMMON_ERROR XFLM_ERROR_BASE( 0x0000) // NOTE: This is not an error code - do not document it - #define NE_XFLM_NOT_IMPLEMENTED XFLM_ERROR_BASE( 0x0001) // NE_NOT_IMPLEMENTED - Attempt was made to use a feature that is not implemented. - #define NE_XFLM_MEM XFLM_ERROR_BASE( 0x0002) // NE_INSUFFICIENT_MEMORY - Attempt to allocate memory failed. - #define NE_XFLM_INVALID_PARM XFLM_ERROR_BASE( 0x0005) // NE_INVALID_PARAMETER - Invalid parameter passed into a function. - #define NE_XFLM_TIMEOUT XFLM_ERROR_BASE( 0x0009) // NE_WAIT_TIMEOUT - Database operation timed out (usually a query operation). - #define NE_XFLM_NOT_FOUND XFLM_ERROR_BASE( 0x000A) // NE_OBJECT_NOT_FOUND - An object was not found. - #define NE_XFLM_EXISTS XFLM_ERROR_BASE( 0x000C) // NE_OBJECT_ALREADY_EXISTS - Object already exists. - #define NE_XFLM_USER_ABORT XFLM_ERROR_BASE( 0x0010) // NE_CALLBACK_CANCELLED - User or application aborted (canceled) the operation - #define NE_XFLM_FAILURE XFLM_ERROR_BASE( 0x0011) // NE_RECOVERABLE_FAILURE - Internal failure. - #define NE_XFLM_LAST_COMMON_ERROR XFLM_ERROR_BASE( 0x0012) // NOTE: This is not an error code - do not document. + /**************************************************************************** + Desc: General XFLAIM errors + ****************************************************************************/ + #define NE_XFLM_OK NE_FLM_OK #define NE_XFLM_FIRST_GENERAL_ERROR XFLM_ERROR_BASE( 0x0100) // NOTE: This is not an error code - do not document - #define NE_XFLM_BOF_HIT XFLM_ERROR_BASE( 0x0101) // Beginning of results encountered. This error is may be returned when reading query results in reverse order (from last to first). - #define NE_XFLM_EOF_HIT XFLM_ERROR_BASE( 0x0102) // End of results encountered. This error may be returned when reading query results in forward order (first to last). - #define NE_XFLM_END XFLM_ERROR_BASE( 0x0103) // End of roll-forward log packets encountered. NOTE: This error code should never be returned to an application. - #define NE_XFLM_BAD_PREFIX XFLM_ERROR_BASE( 0x0104) // Invalid XLM namespace prefix specified. Either a prefix name or number that was specified was not defined. - #define NE_XFLM_ATTRIBUTE_PURGED XFLM_ERROR_BASE( 0x0105) // XML attribute cannot be used - it is being deleted from the database. - #define NE_XFLM_BAD_COLLECTION XFLM_ERROR_BASE( 0x0106) // Invalid collection number specified. Collection is not defined. - #define NE_XFLM_DATABASE_LOCK_REQ_TIMEOUT XFLM_ERROR_BASE( 0x0107) // Request to lock the database timed out. - #define NE_XFLM_ILLEGAL_DATA_COMPONENT XFLM_ERROR_BASE( 0x0108) // Cannot use ELM_ROOT_TAG as a data component in an index. - #define NE_XFLM_BAD_DATA_TYPE XFLM_ERROR_BASE( 0x0109) // Attempt to set/get data on an XML element or attribute using a data type that is incompatible with the data type specified in the dictionary. - #define NE_XFLM_MUST_INDEX_ON_PRESENCE XFLM_ERROR_BASE( 0x010A) // When using ELM_ROOT_TAG in an index component, must specify PRESENCE indexing only. - #define NE_XFLM_BAD_IX XFLM_ERROR_BASE( 0x010B) // Invalid index number specified. Index is not defined. - #define NE_XFLM_BACKUP_ACTIVE XFLM_ERROR_BASE( 0x010C) // Operation could not be performed because a backup is currently in progress. - #define NE_XFLM_SERIAL_NUM_MISMATCH XFLM_ERROR_BASE( 0x010D) // Serial number on backup file does not match the serial number that is expected. - #define NE_XFLM_BAD_RFL_DB_SERIAL_NUM XFLM_ERROR_BASE( 0x010E) // Bad database serial number in roll-forward log file header. - #define NE_XFLM_BTREE_ERROR XFLM_ERROR_BASE( 0x010F) // A B-Tree in the database is bad. - #define NE_XFLM_BTREE_FULL XFLM_ERROR_BASE( 0x0110) // A B-tree in the database is full, or a b-tree being used for a temporary result set is full. - #define NE_XFLM_BAD_RFL_FILE_NUMBER XFLM_ERROR_BASE( 0x0111) // Bad roll-forward log file number in roll-forward log file header. - #define NE_XFLM_CANNOT_DEL_ELEMENT XFLM_ERROR_BASE( 0x0112) // Cannot delete an XML element definition in the dictionary because it is in use. - #define NE_XFLM_CANNOT_MOD_DATA_TYPE XFLM_ERROR_BASE( 0x0113) // Cannot modify the data type for an XML element or attribute definition in the dictionary. - #define NE_XFLM_CANNOT_INDEX_DATA_TYPE XFLM_ERROR_BASE( 0x0114) // Data type of XML element or attribute is not one that can be indexed. - #define NE_XFLM_CONV_BAD_DIGIT XFLM_ERROR_BASE( 0x0115) // Non-numeric digit found in text to numeric conversion. - #define NE_XFLM_CONV_DEST_OVERFLOW XFLM_ERROR_BASE( 0x0116) // Destination buffer not large enough to hold data. - #define NE_XFLM_CONV_ILLEGAL XFLM_ERROR_BASE( 0x0117) // Attempt to convert between data types is an unsupported conversion. - #define NE_XFLM_CONV_NULL_SRC XFLM_ERROR_BASE( 0x0118) // Data source cannot be NULL when doing data conversion. - #define NE_XFLM_CONV_NUM_OVERFLOW XFLM_ERROR_BASE( 0x0119) // Numeric overflow (> upper bound) converting to numeric type. - #define NE_XFLM_CONV_NUM_UNDERFLOW XFLM_ERROR_BASE( 0x011A) // Numeric underflow (< lower bound) converting to numeric type. - #define NE_XFLM_BAD_ELEMENT_NUM XFLM_ERROR_BASE( 0x011B) // Bad element number specified - element not defined in dictionary. - #define NE_XFLM_BAD_ATTRIBUTE_NUM XFLM_ERROR_BASE( 0x011C) // Bad attribute number specified - attribute not defined in dictionary. - #define NE_XFLM_BAD_ENCDEF_NUM XFLM_ERROR_BASE( 0x011D) // Bad encryption number specified - encryption definition not defined in dictionary. - #define NE_XFLM_DATA_ERROR XFLM_ERROR_BASE( 0x011E) // Encountered data in the database that was corrupted. - #define NE_XFLM_INVALID_FILE_SEQUENCE XFLM_ERROR_BASE( 0x011F) // Incremental backup file number provided during a restore is invalid. - #define NE_XFLM_ILLEGAL_OP XFLM_ERROR_BASE( 0x0120) // Attempt to perform an illegal operation. - #define NE_XFLM_DUPLICATE_ELEMENT_NUM XFLM_ERROR_BASE( 0x0121) // Element number specified in element definition is already in use. - #define NE_XFLM_ILLEGAL_TRANS_TYPE XFLM_ERROR_BASE( 0x0122) // Illegal transaction type specified for transaction begin operation. - #define NE_XFLM_UNSUPPORTED_VERSION XFLM_ERROR_BASE( 0x0123) // Version of database found in database header is not supported. - #define NE_XFLM_ILLEGAL_TRANS_OP XFLM_ERROR_BASE( 0x0124) // Illegal operation for transaction type. - #define NE_XFLM_INCOMPLETE_LOG XFLM_ERROR_BASE( 0x0125) // Incomplete rollback log. - #define NE_XFLM_ILLEGAL_INDEX_DEF XFLM_ERROR_BASE( 0x0126) // Index definition document is illegal - does not conform to the expected form of an index definition document. - #define NE_XFLM_ILLEGAL_INDEX_ON XFLM_ERROR_BASE( 0x0127) // The "IndexOn" attribute of an index definition has an illegal value. - #define NE_XFLM_ILLEGAL_STATE_CHANGE XFLM_ERROR_BASE( 0x0128) // Attempted an illegal state change on an element or attribute definition. - #define NE_XFLM_BAD_RFL_SERIAL_NUM XFLM_ERROR_BASE( 0x0129) // Serial number in roll-forward log file header does not match expected serial number. - #define NE_XFLM_NEWER_FLAIM XFLM_ERROR_BASE( 0x012A) // Running old code on a newer version of database. Newer code must be used. - #define NE_XFLM_CANNOT_MOD_ELEMENT_STATE XFLM_ERROR_BASE( 0x012B) // Attempted to change state of a predefined element definition. - #define NE_XFLM_CANNOT_MOD_ATTRIBUTE_STATE XFLM_ERROR_BASE( 0x012C) // Attempted to change state of a predefined attribute definition. - #define NE_XFLM_NO_MORE_ELEMENT_NUMS XFLM_ERROR_BASE( 0x012D) // The highest element number has already been used, cannot create more element definitions. - #define NE_XFLM_NO_TRANS_ACTIVE XFLM_ERROR_BASE( 0x012E) // Operation must be performed inside a database transaction. - #define NE_XFLM_NOT_UNIQUE XFLM_ERROR_BASE( 0x012F) // Attempt was made to insert a key into a b-tree that was already in the b-tree. - #define NE_XFLM_NOT_FLAIM XFLM_ERROR_BASE( 0x0130) // The file specified is not a FLAIM database. - #define NE_XFLM_OLD_VIEW XFLM_ERROR_BASE( 0x0131) // Unable to maintain read transaction's view of the database. - #define NE_XFLM_SHARED_LOCK XFLM_ERROR_BASE( 0x0132) // Attempted to perform an operation on the database that requires exclusive access, but cannot because there is a shared lock. - #define NE_XFLM_SYNTAX XFLM_ERROR_BASE( 0x0133) // Syntax error while parsing XML or query. - #define NE_XFLM_TRANS_ACTIVE XFLM_ERROR_BASE( 0x0134) // Operation cannot be performed while a transaction is active. - #define NE_XFLM_RFL_TRANS_GAP XFLM_ERROR_BASE( 0x0135) // A gap was found in the transaction sequence in the roll-forward log. - #define NE_XFLM_BAD_COLLATED_KEY XFLM_ERROR_BASE( 0x0136) // Something in collated key is bad. - #define NE_XFLM_UNSUPPORTED_FEATURE XFLM_ERROR_BASE( 0x0137) // Attempting to use a feature for which full support has been disabled. - #define NE_XFLM_MUST_DELETE_INDEXES XFLM_ERROR_BASE( 0x0138) // Attempting to delete a collection that has indexes defined for it. Associated indexes must be deleted before the collection can be deleted. - #define NE_XFLM_RFL_INCOMPLETE XFLM_ERROR_BASE( 0x0139) // Roll-forward log file is incomplete. - #define NE_XFLM_CANNOT_RESTORE_RFL_FILES XFLM_ERROR_BASE( 0x013A) // Cannot restore roll-forward log files - not using multiple roll-forward log files. - #define NE_XFLM_INCONSISTENT_BACKUP XFLM_ERROR_BASE( 0x013B) // A problem (corruption, etc.) was detected in a backup set. - #define NE_XFLM_BLOCK_CRC XFLM_ERROR_BASE( 0x013C) // CRC for database block was invalid. May indicate problems in reading from or writing to disk. - #define NE_XFLM_ABORT_TRANS XFLM_ERROR_BASE( 0x013D) // Attempted operation after a critical error - transaction should be aborted. - #define NE_XFLM_NOT_RFL XFLM_ERROR_BASE( 0x013E) // File was not a roll-forward log file as expected. - #define NE_XFLM_BAD_RFL_PACKET XFLM_ERROR_BASE( 0x013F) // Roll-forward log file packet was bad. - #define NE_XFLM_DATA_PATH_MISMATCH XFLM_ERROR_BASE( 0x0140) // Bad data path specified to open database. Does not match data path specified for prior opens of the database. - #define NE_XFLM_STREAM_EXISTS XFLM_ERROR_BASE( 0x0141) // Attempt to create stream, but the file(s) already exists. - #define NE_XFLM_FILE_EXISTS XFLM_ERROR_BASE( 0x0142) // Attempt to create a database, but the file already exists. - #define NE_XFLM_COULD_NOT_CREATE_SEMAPHORE XFLM_ERROR_BASE( 0x0143) // Could not create a semaphore. - #define NE_XFLM_MUST_CLOSE_DATABASE XFLM_ERROR_BASE( 0x0144) // Database must be closed due to a critical error. - #define NE_XFLM_INVALID_ENCKEY_CRC XFLM_ERROR_BASE( 0x0145) // Encryption key CRC could not be verified. - #define NE_XFLM_BAD_UTF8 XFLM_ERROR_BASE( 0x0146) // An invalid byte sequence was found in a UTF-8 string - #define NE_XFLM_COULD_NOT_CREATE_MUTEX XFLM_ERROR_BASE( 0x0147) // Could not create a mutex. - #define NE_XFLM_ERROR_WAITING_ON_SEMPAHORE XFLM_ERROR_BASE( 0x0148) // Error occurred while waiting on a sempahore. - #define NE_XFLM_BAD_PLATFORM_FORMAT XFLM_ERROR_BASE( 0x0149) // Cannot support platform format. NOTE: No need to document this one, it is strictly internal. - #define NE_XFLM_HDR_CRC XFLM_ERROR_BASE( 0x014A) // Database header has a bad CRC. - #define NE_XFLM_NO_NAME_TABLE XFLM_ERROR_BASE( 0x014B) // No name table was set up for the database. - #define NE_XFLM_MULTIPLE_MATCHES XFLM_ERROR_BASE( 0x014C) // Multiple entries match the name in the name table. Need to pass a namespace to disambiguate. - #define NE_XFLM_UNALLOWED_UPGRADE XFLM_ERROR_BASE( 0x014D) // Cannot upgrade database from one version to another. - #define NE_XFLM_BTREE_BAD_STATE XFLM_ERROR_BASE( 0x014E) // Btree function called before proper setup steps taken. - #define NE_XFLM_DUPLICATE_ATTRIBUTE_NUM XFLM_ERROR_BASE( 0x014F) // Attribute number specified in attribute definition is already in use. - #define NE_XFLM_DUPLICATE_INDEX_NUM XFLM_ERROR_BASE( 0x0150) // Index number specified in index definition is already in use. - #define NE_XFLM_DUPLICATE_COLLECTION_NUM XFLM_ERROR_BASE( 0x0151) // Collection number specified in collection definition is already in use. - #define NE_XFLM_DUPLICATE_ELEMENT_NAME XFLM_ERROR_BASE( 0x0152) // Element name+namespace specified in element definition is already in use. - #define NE_XFLM_DUPLICATE_ATTRIBUTE_NAME XFLM_ERROR_BASE( 0x0153) // Attribute name+namespace specified in attribute definition is already in use. - #define NE_XFLM_DUPLICATE_INDEX_NAME XFLM_ERROR_BASE( 0x0154) // Index name specified in index definition is already in use. - #define NE_XFLM_DUPLICATE_COLLECTION_NAME XFLM_ERROR_BASE( 0x0155) // Collection name specified in collection definition is already in use. - #define NE_XFLM_ELEMENT_PURGED XFLM_ERROR_BASE( 0x0156) // XML element cannot be used - it is deleted from the database. - #define NE_XFLM_TOO_MANY_OPEN_DATABASES XFLM_ERROR_BASE( 0x0157) // Too many open databases, cannot open another one. - #define NE_XFLM_DATABASE_OPEN XFLM_ERROR_BASE( 0x0158) // Operation cannot be performed because the database is currently open. - #define NE_XFLM_CACHE_ERROR XFLM_ERROR_BASE( 0x0159) // Cached database block has been compromised while in cache. - #define NE_XFLM_BTREE_KEY_SIZE XFLM_ERROR_BASE( 0x015A) // Key too large to insert/lookup in a b-tree. - #define NE_XFLM_DB_FULL XFLM_ERROR_BASE( 0x015B) // Database is full, cannot create more blocks. - #define NE_XFLM_QUERY_SYNTAX XFLM_ERROR_BASE( 0x015C) // Query expression had improper syntax. - #define NE_XFLM_COULD_NOT_START_THREAD XFLM_ERROR_BASE( 0x015D) // Error occurred while attempting to start a thread. - #define NE_XFLM_INDEX_OFFLINE XFLM_ERROR_BASE( 0x015E) // Index is offline, cannot be used in a query. - #define NE_XFLM_RFL_DISK_FULL XFLM_ERROR_BASE( 0x015F) // Disk which contains roll-forward log is full. - #define NE_XFLM_MUST_WAIT_CHECKPOINT XFLM_ERROR_BASE( 0x0160) // Must wait for a checkpoint before starting transaction - due to disk problems - usually in disk containing roll-forward log files. - #define NE_XFLM_MISSING_ENC_ALGORITHM XFLM_ERROR_BASE( 0x0161) // Encryption definition is missing an encryption algorithm. - #define NE_XFLM_INVALID_ENC_ALGORITHM XFLM_ERROR_BASE( 0x0162) // Invalid encryption algorithm specified in encryption definition. - #define NE_XFLM_INVALID_ENC_KEY_SIZE XFLM_ERROR_BASE( 0x0163) // Invalid key size specified in encryption definition. - #define NE_XFLM_ILLEGAL_DATA_TYPE XFLM_ERROR_BASE( 0x0164) // Data type specified for XML element or attribute definition is illegal. - #define NE_XFLM_ILLEGAL_STATE XFLM_ERROR_BASE( 0x0165) // State specified for index definition or XML element or attribute definition is illegal. - #define NE_XFLM_ILLEGAL_ELEMENT_NAME XFLM_ERROR_BASE( 0x0166) // XML element name specified in element definition is illegal. - #define NE_XFLM_ILLEGAL_ATTRIBUTE_NAME XFLM_ERROR_BASE( 0x0167) // XML attribute name specified in attribute definition is illegal. - #define NE_XFLM_ILLEGAL_COLLECTION_NAME XFLM_ERROR_BASE( 0x0168) // Collection name specified in collection definition is illegal. - #define NE_XFLM_ILLEGAL_INDEX_NAME XFLM_ERROR_BASE( 0x0169) // Index name specified is illegal - #define NE_XFLM_ILLEGAL_ELEMENT_NUMBER XFLM_ERROR_BASE( 0x016A) // Element number specified in element definition or index definition is illegal. - #define NE_XFLM_ILLEGAL_ATTRIBUTE_NUMBER XFLM_ERROR_BASE( 0x016B) // Attribute number specified in attribute definition or index definition is illegal. - #define NE_XFLM_ILLEGAL_COLLECTION_NUMBER XFLM_ERROR_BASE( 0x016C) // Collection number specified in collection definition or index definition is illegal. - #define NE_XFLM_ILLEGAL_INDEX_NUMBER XFLM_ERROR_BASE( 0x016D) // Index number specified in index definition is illegal. - #define NE_XFLM_ILLEGAL_ENCDEF_NUMBER XFLM_ERROR_BASE( 0x016E) // Encryption definition number specified in encryption definition is illegal. - #define NE_XFLM_COLLECTION_NAME_MISMATCH XFLM_ERROR_BASE( 0x016F) // Collection name and number specified in index definition do not correspond to each other. - #define NE_XFLM_ELEMENT_NAME_MISMATCH XFLM_ERROR_BASE( 0x0170) // Element name+namespace and number specified in index definition do not correspond to each other. - #define NE_XFLM_ATTRIBUTE_NAME_MISMATCH XFLM_ERROR_BASE( 0x0171) // Attribute name+namespace and number specified in index definition do not correspond to each other. - #define NE_XFLM_INVALID_COMPARE_RULE XFLM_ERROR_BASE( 0x0172) // Invalid comparison rule specified in index definition. - #define NE_XFLM_DUPLICATE_KEY_COMPONENT XFLM_ERROR_BASE( 0x0173) // Duplicate key component number specified in index definition. - #define NE_XFLM_DUPLICATE_DATA_COMPONENT XFLM_ERROR_BASE( 0x0174) // Duplicate data component number specified in index definition. - #define NE_XFLM_MISSING_KEY_COMPONENT XFLM_ERROR_BASE( 0x0175) // Index definition is missing a key component. - #define NE_XFLM_MISSING_DATA_COMPONENT XFLM_ERROR_BASE( 0x0176) // Index definition is missing a data component. - #define NE_XFLM_INVALID_INDEX_OPTION XFLM_ERROR_BASE( 0x0177) // Invalid index option specified on index definition. - #define NE_XFLM_NO_MORE_ATTRIBUTE_NUMS XFLM_ERROR_BASE( 0x0178) // The highest attribute number has already been used, cannot create more. - #define NE_XFLM_MISSING_ELEMENT_NAME XFLM_ERROR_BASE( 0x0179) // Missing element name in XML element definition. - #define NE_XFLM_MISSING_ATTRIBUTE_NAME XFLM_ERROR_BASE( 0x017A) // Missing attribute name in XML attribute definition. - #define NE_XFLM_MISSING_ELEMENT_NUMBER XFLM_ERROR_BASE( 0x017B) // Missing element number in XML element definition. - #define NE_XFLM_MISSING_ATTRIBUTE_NUMBER XFLM_ERROR_BASE( 0x017C) // Missing attribute number from XML attribute definition. - #define NE_XFLM_MISSING_INDEX_NAME XFLM_ERROR_BASE( 0x017D) // Missing index name in index definition. - #define NE_XFLM_MISSING_INDEX_NUMBER XFLM_ERROR_BASE( 0x017E) // Missing index number in index definition. - #define NE_XFLM_MISSING_COLLECTION_NAME XFLM_ERROR_BASE( 0x017F) // Missing collection name in collection definition. - #define NE_XFLM_MISSING_COLLECTION_NUMBER XFLM_ERROR_BASE( 0x0180) // Missing collection number in collection definition. - #define NE_XFLM_BAD_SEN XFLM_ERROR_BASE( 0x0181) // Invalid simple encoded number. - #define NE_XFLM_MISSING_ENCDEF_NAME XFLM_ERROR_BASE( 0x0182) // Missing encryption definition name in encryption definition. - #define NE_XFLM_MISSING_ENCDEF_NUMBER XFLM_ERROR_BASE( 0x0183) // Missing encryption definition number in encryption definition. - #define NE_XFLM_NO_MORE_INDEX_NUMS XFLM_ERROR_BASE( 0x0184) // The highest index number has already been used, cannot create more. - #define NE_XFLM_NO_MORE_COLLECTION_NUMS XFLM_ERROR_BASE( 0x0185) // The highest collection number has already been used, cannot create more. - #define NE_XFLM_CANNOT_DEL_ATTRIBUTE XFLM_ERROR_BASE( 0x0186) // Cannot delete an XML attribute definition because it is in use. - #define NE_XFLM_TOO_MANY_PENDING_NODES XFLM_ERROR_BASE( 0x0187) // Too many documents in the pending document list. - #define NE_XFLM_UNSUPPORTED_INTERFACE XFLM_ERROR_BASE( 0x0188) // Requested COM interface is not supported. - #define NE_XFLM_BAD_USE_OF_ELM_ROOT_TAG XFLM_ERROR_BASE( 0x0189) // ELM_ROOT_TAG, if used, must be the sole root component of an index definition. - #define NE_XFLM_DUP_SIBLING_IX_COMPONENTS XFLM_ERROR_BASE( 0x018A) // Sibling components in an index definition cannot have the same XML element or attribute number. - #define NE_XFLM_RFL_FILE_NOT_FOUND XFLM_ERROR_BASE( 0x018B) // Could not open a roll-forward log file - was not found in the roll-forward log directory. - #define NE_XFLM_BAD_RCODE_TABLE XFLM_ERROR_BASE( 0x018C) // The error code tables are incorrect. NOTE: This is an internal error that does not need to be documented. - #define NE_XFLM_ILLEGAL_KEY_COMPONENT_NUM XFLM_ERROR_BASE( 0x018D) // Key component of zero in index definition is not allowed. - #define NE_XFLM_ILLEGAL_DATA_COMPONENT_NUM XFLM_ERROR_BASE( 0x018E) // Data component of zero in index definition is not allowed. - #define NE_XFLM_CLASS_NOT_AVAILABLE XFLM_ERROR_BASE( 0x018F) // Requested COM class is not available. - #define NE_XFLM_BUFFER_OVERFLOW XFLM_ERROR_BASE( 0x0190) // Buffer overflow. - #define NE_XFLM_ILLEGAL_PREFIX_NUMBER XFLM_ERROR_BASE( 0x0191) // Prefix number specified in prefix definition is illegal. - #define NE_XFLM_MISSING_PREFIX_NAME XFLM_ERROR_BASE( 0x0192) // Missing prefix name in prefix definition. - #define NE_XFLM_MISSING_PREFIX_NUMBER XFLM_ERROR_BASE( 0x0193) // Missing prefix number in prefix definition. - #define NE_XFLM_UNDEFINED_ELEMENT_NAME XFLM_ERROR_BASE( 0x0194) // XML element name+namespace that was specified in index definition or XML document is not defined in dictionary. - #define NE_XFLM_UNDEFINED_ATTRIBUTE_NAME XFLM_ERROR_BASE( 0x0195) // XML attribute name+namespace that was specified in index definition or XML document is not defined in dictionary. - #define NE_XFLM_DUPLICATE_PREFIX_NAME XFLM_ERROR_BASE( 0x0196) // Prefix name specified in prefix definition is already in use. - #define NE_XFLM_KEY_OVERFLOW XFLM_ERROR_BASE( 0x0197) // Generated index key too large. - #define NE_XFLM_UNESCAPED_METACHAR XFLM_ERROR_BASE( 0x0198) // Unescaped metacharacter in regular expression. - #define NE_XFLM_ILLEGAL_QUANTIFIER XFLM_ERROR_BASE( 0x0199) // Illegal quantifier in regular expression. - #define NE_XFLM_UNEXPECTED_END_OF_EXPR XFLM_ERROR_BASE( 0x019A) // Unexpected end of regular expression. - #define NE_XFLM_ILLEGAL_MIN_COUNT XFLM_ERROR_BASE( 0x019B) // Illegal minimum count in regular expression quantifier. - #define NE_XFLM_ILLEGAL_MAX_COUNT XFLM_ERROR_BASE( 0x019C) // Illegal maximum count in regular expression quantifier. - #define NE_XFLM_EMPTY_BRANCH_IN_EXPR XFLM_ERROR_BASE( 0x019D) // Illegal empty branch in a regular expression. - #define NE_XFLM_ILLEGAL_RPAREN_IN_EXPR XFLM_ERROR_BASE( 0x019E) // Illegal right paren in a regular expression. - #define NE_XFLM_ILLEGAL_CLASS_SUBTRACTION XFLM_ERROR_BASE( 0x019F) // Illegal class subtraction in regular expression. - #define NE_XFLM_ILLEGAL_CHAR_RANGE_IN_EXPR XFLM_ERROR_BASE( 0x01A0) // Illegal character range in regular expression. - #define NE_XFLM_BAD_BASE64_ENCODING XFLM_ERROR_BASE( 0x01A1) // Illegal character(s) found in a base64 stream. - #define NE_XFLM_NAMESPACE_NOT_ALLOWED XFLM_ERROR_BASE( 0x01A2) // Cannot define a namespace for XML attributes whose name begins with "xmlns:" or that is equal to "xmlns" - #define NE_XFLM_INVALID_NAMESPACE_DECL XFLM_ERROR_BASE( 0x01A3) // Name for namespace declaration attribute must be "xmlns" or begin with "xmlns:" - #define NE_XFLM_ILLEGAL_NAMESPACE_DECL_DATATYPE XFLM_ERROR_BASE( 0x01A4) // Data type for XML attributes that are namespace declarations must be text. - #define NE_XFLM_UNEXPECTED_END_OF_INPUT XFLM_ERROR_BASE( 0x01A5) // Encountered unexpected end of input when parsing XPATH expression. - #define NE_XFLM_NO_MORE_PREFIX_NUMS XFLM_ERROR_BASE( 0x01A6) // The highest prefix number has already been used, cannot create more. - #define NE_XFLM_NO_MORE_ENCDEF_NUMS XFLM_ERROR_BASE( 0x01A7) // The highest encryption definition number has already been used, cannot create more. - #define NE_XFLM_COLLECTION_OFFLINE XFLM_ERROR_BASE( 0x01A8) // Collection is encrypted, cannot be accessed while in operating in limited mode. - #define NE_XFLM_INVALID_XML XFLM_ERROR_BASE( 0x01A9) // Invalid XML encountered while parsing document. - #define NE_XFLM_READ_ONLY XFLM_ERROR_BASE( 0x01AA) // Item is read-only and cannot be updated. - #define NE_XFLM_DELETE_NOT_ALLOWED XFLM_ERROR_BASE( 0x01AB) // Item cannot be deleted. - #define NE_XFLM_RESET_NEEDED XFLM_ERROR_BASE( 0x01AC) // Used during check operations to indicate we need to reset the view. NOTE: This is an internal error code and should not be documented. - #define NE_XFLM_ILLEGAL_REQUIRED_VALUE XFLM_ERROR_BASE( 0x01AD) // An illegal value was specified for the "Required" attribute in an index definition. - #define NE_XFLM_ILLEGAL_INDEX_COMPONENT XFLM_ERROR_BASE( 0x01AE) // A leaf index component in an index definition was not marked as a data component or key component. - #define NE_XFLM_ILLEGAL_UNIQUE_SUB_ELEMENT_VALUE XFLM_ERROR_BASE( 0x01AF) // Illegal value for the "UniqueSubElements" attribute in an element definition. - #define NE_XFLM_DATA_TYPE_MUST_BE_NO_DATA XFLM_ERROR_BASE( 0x01B0) // Data type for an element definition with UniqueSubElements="yes" must be nodata. - #define NE_XFLM_ILLEGAL_FLAG XFLM_ERROR_BASE( 0x01B1) // Illegal flag passed to getChildElement method. Must be zero for elements that can have non-unique child elements. - #define NE_XFLM_CANNOT_SET_REQUIRED XFLM_ERROR_BASE( 0x01B2) // Cannot set the "Required" attribute on a non-key index component in index definition. - #define NE_XFLM_CANNOT_SET_LIMIT XFLM_ERROR_BASE( 0x01B3) // Cannot set the "Limit" attribute on a non-key index component in index definition. - #define NE_XFLM_CANNOT_SET_INDEX_ON XFLM_ERROR_BASE( 0x01B4) // Cannot set the "IndexOn" attribute on a non-key index component in index definition. - #define NE_XFLM_CANNOT_SET_COMPARE_RULES XFLM_ERROR_BASE( 0x01B5) // Cannot set the "CompareRules" on a non-key index component in index definition. - #define NE_XFLM_INPUT_PENDING XFLM_ERROR_BASE( 0x01B6) // Attempt to set a value while an input stream is still open. - #define NE_XFLM_INVALID_NODE_TYPE XFLM_ERROR_BASE( 0x01B7) // Bad node type - #define NE_XFLM_INVALID_CHILD_ELM_NODE_ID XFLM_ERROR_BASE( 0x01B8) // Attempt to insert a unique child element that has a lower node ID than the parent element - #define NE_XFLM_LAST_GENERAL_ERROR XFLM_ERROR_BASE( 0x01B9) // NOTE: This is not an error code - do not document + #define NE_XFLM_BAD_PREFIX XFLM_ERROR_BASE( 0x0101) // Invalid XLM namespace prefix specified. Either a prefix name or number that was specified was not defined. + #define NE_XFLM_ATTRIBUTE_PURGED XFLM_ERROR_BASE( 0x0102) // XML attribute cannot be used - it is being deleted from the database. + #define NE_XFLM_BAD_COLLECTION XFLM_ERROR_BASE( 0x0103) // Invalid collection number specified. Collection is not defined. + #define NE_XFLM_DATABASE_LOCK_REQ_TIMEOUT XFLM_ERROR_BASE( 0x0104) // Request to lock the database timed out. + #define NE_XFLM_ILLEGAL_DATA_COMPONENT XFLM_ERROR_BASE( 0x0105) // Cannot use ELM_ROOT_TAG as a data component in an index. + #define NE_XFLM_MUST_INDEX_ON_PRESENCE XFLM_ERROR_BASE( 0x0106) // When using ELM_ROOT_TAG in an index component, must specify PRESENCE indexing only. + #define NE_XFLM_BAD_IX XFLM_ERROR_BASE( 0x0107) // Invalid index number specified. Index is not defined. + #define NE_XFLM_BACKUP_ACTIVE XFLM_ERROR_BASE( 0x0108) // Operation could not be performed because a backup is currently in progress. + #define NE_XFLM_SERIAL_NUM_MISMATCH XFLM_ERROR_BASE( 0x0109) // Serial number on backup file does not match the serial number that is expected. + #define NE_XFLM_BAD_RFL_DB_SERIAL_NUM XFLM_ERROR_BASE( 0x010A) // Bad database serial number in roll-forward log file header. + #define NE_XFLM_BAD_RFL_FILE_NUMBER XFLM_ERROR_BASE( 0x010B) // Bad roll-forward log file number in roll-forward log file header. + #define NE_XFLM_CANNOT_DEL_ELEMENT XFLM_ERROR_BASE( 0x010C) // Cannot delete an XML element definition in the dictionary because it is in use. + #define NE_XFLM_CANNOT_MOD_DATA_TYPE XFLM_ERROR_BASE( 0x010D) // Cannot modify the data type for an XML element or attribute definition in the dictionary. + #define NE_XFLM_CANNOT_INDEX_DATA_TYPE XFLM_ERROR_BASE( 0x010E) // Data type of XML element or attribute is not one that can be indexed. + #define NE_XFLM_BAD_ELEMENT_NUM XFLM_ERROR_BASE( 0x010F) // Bad element number specified - element not defined in dictionary. + #define NE_XFLM_BAD_ATTRIBUTE_NUM XFLM_ERROR_BASE( 0x0110) // Bad attribute number specified - attribute not defined in dictionary. + #define NE_XFLM_BAD_ENCDEF_NUM XFLM_ERROR_BASE( 0x0111) // Bad encryption number specified - encryption definition not defined in dictionary. + #define NE_XFLM_INVALID_FILE_SEQUENCE XFLM_ERROR_BASE( 0x0112) // Incremental backup file number provided during a restore is invalid. + #define NE_XFLM_DUPLICATE_ELEMENT_NUM XFLM_ERROR_BASE( 0x0113) // Element number specified in element definition is already in use. + #define NE_XFLM_ILLEGAL_TRANS_TYPE XFLM_ERROR_BASE( 0x0114) // Illegal transaction type specified for transaction begin operation. + #define NE_XFLM_UNSUPPORTED_VERSION XFLM_ERROR_BASE( 0x0115) // Version of database found in database header is not supported. + #define NE_XFLM_ILLEGAL_TRANS_OP XFLM_ERROR_BASE( 0x0116) // Illegal operation for transaction type. + #define NE_XFLM_INCOMPLETE_LOG XFLM_ERROR_BASE( 0x0117) // Incomplete rollback log. + #define NE_XFLM_ILLEGAL_INDEX_DEF XFLM_ERROR_BASE( 0x0118) // Index definition document is illegal - does not conform to the expected form of an index definition document. + #define NE_XFLM_ILLEGAL_INDEX_ON XFLM_ERROR_BASE( 0x0119) // The "IndexOn" attribute of an index definition has an illegal value. + #define NE_XFLM_ILLEGAL_STATE_CHANGE XFLM_ERROR_BASE( 0x011A) // Attempted an illegal state change on an element or attribute definition. + #define NE_XFLM_BAD_RFL_SERIAL_NUM XFLM_ERROR_BASE( 0x011B) // Serial number in roll-forward log file header does not match expected serial number. + #define NE_XFLM_NEWER_FLAIM XFLM_ERROR_BASE( 0x011C) // Running old code on a newer version of database. Newer code must be used. + #define NE_XFLM_CANNOT_MOD_ELEMENT_STATE XFLM_ERROR_BASE( 0x011D) // Attempted to change state of a predefined element definition. + #define NE_XFLM_CANNOT_MOD_ATTRIBUTE_STATE XFLM_ERROR_BASE( 0x011E) // Attempted to change state of a predefined attribute definition. + #define NE_XFLM_NO_MORE_ELEMENT_NUMS XFLM_ERROR_BASE( 0x011F) // The highest element number has already been used, cannot create more element definitions. + #define NE_XFLM_NO_TRANS_ACTIVE XFLM_ERROR_BASE( 0x0120) // Operation must be performed inside a database transaction. + #define NE_XFLM_NOT_FLAIM XFLM_ERROR_BASE( 0x0121) // The file specified is not a FLAIM database. + #define NE_XFLM_OLD_VIEW XFLM_ERROR_BASE( 0x0122) // Unable to maintain read transaction's view of the database. + #define NE_XFLM_SHARED_LOCK XFLM_ERROR_BASE( 0x0123) // Attempted to perform an operation on the database that requires exclusive access, but cannot because there is a shared lock. + #define NE_XFLM_TRANS_ACTIVE XFLM_ERROR_BASE( 0x0124) // Operation cannot be performed while a transaction is active. + #define NE_XFLM_RFL_TRANS_GAP XFLM_ERROR_BASE( 0x0125) // A gap was found in the transaction sequence in the roll-forward log. + #define NE_XFLM_BAD_COLLATED_KEY XFLM_ERROR_BASE( 0x0126) // Something in collated key is bad. + #define NE_XFLM_MUST_DELETE_INDEXES XFLM_ERROR_BASE( 0x0127) // Attempting to delete a collection that has indexes defined for it. Associated indexes must be deleted before the collection can be deleted. + #define NE_XFLM_RFL_INCOMPLETE XFLM_ERROR_BASE( 0x0128) // Roll-forward log file is incomplete. + #define NE_XFLM_CANNOT_RESTORE_RFL_FILES XFLM_ERROR_BASE( 0x0129) // Cannot restore roll-forward log files - not using multiple roll-forward log files. + #define NE_XFLM_INCONSISTENT_BACKUP XFLM_ERROR_BASE( 0x012A) // A problem (corruption, etc.) was detected in a backup set. + #define NE_XFLM_BLOCK_CRC XFLM_ERROR_BASE( 0x012B) // CRC for database block was invalid. May indicate problems in reading from or writing to disk. + #define NE_XFLM_ABORT_TRANS XFLM_ERROR_BASE( 0x012C) // Attempted operation after a critical error - transaction should be aborted. + #define NE_XFLM_NOT_RFL XFLM_ERROR_BASE( 0x012D) // File was not a roll-forward log file as expected. + #define NE_XFLM_BAD_RFL_PACKET XFLM_ERROR_BASE( 0x012E) // Roll-forward log file packet was bad. + #define NE_XFLM_DATA_PATH_MISMATCH XFLM_ERROR_BASE( 0x012F) // Bad data path specified to open database. Does not match data path specified for prior opens of the database. + #define NE_XFLM_MUST_CLOSE_DATABASE XFLM_ERROR_BASE( 0x0130) // Database must be closed due to a critical error. + #define NE_XFLM_INVALID_ENCKEY_CRC XFLM_ERROR_BASE( 0x0131) // Encryption key CRC could not be verified. + #define NE_XFLM_HDR_CRC XFLM_ERROR_BASE( 0x0132) // Database header has a bad CRC. + #define NE_XFLM_NO_NAME_TABLE XFLM_ERROR_BASE( 0x0133) // No name table was set up for the database. + #define NE_XFLM_UNALLOWED_UPGRADE XFLM_ERROR_BASE( 0x0134) // Cannot upgrade database from one version to another. + #define NE_XFLM_DUPLICATE_ATTRIBUTE_NUM XFLM_ERROR_BASE( 0x0135) // Attribute number specified in attribute definition is already in use. + #define NE_XFLM_DUPLICATE_INDEX_NUM XFLM_ERROR_BASE( 0x0136) // Index number specified in index definition is already in use. + #define NE_XFLM_DUPLICATE_COLLECTION_NUM XFLM_ERROR_BASE( 0x0137) // Collection number specified in collection definition is already in use. + #define NE_XFLM_DUPLICATE_ELEMENT_NAME XFLM_ERROR_BASE( 0x0138) // Element name+namespace specified in element definition is already in use. + #define NE_XFLM_DUPLICATE_ATTRIBUTE_NAME XFLM_ERROR_BASE( 0x0139) // Attribute name+namespace specified in attribute definition is already in use. + #define NE_XFLM_DUPLICATE_INDEX_NAME XFLM_ERROR_BASE( 0x013A) // Index name specified in index definition is already in use. + #define NE_XFLM_DUPLICATE_COLLECTION_NAME XFLM_ERROR_BASE( 0x013B) // Collection name specified in collection definition is already in use. + #define NE_XFLM_ELEMENT_PURGED XFLM_ERROR_BASE( 0x013C) // XML element cannot be used - it is deleted from the database. + #define NE_XFLM_TOO_MANY_OPEN_DATABASES XFLM_ERROR_BASE( 0x013D) // Too many open databases, cannot open another one. + #define NE_XFLM_DATABASE_OPEN XFLM_ERROR_BASE( 0x013E) // Operation cannot be performed because the database is currently open. + #define NE_XFLM_CACHE_ERROR XFLM_ERROR_BASE( 0x013F) // Cached database block has been compromised while in cache. + #define NE_XFLM_DB_FULL XFLM_ERROR_BASE( 0x0140) // Database is full, cannot create more blocks. + #define NE_XFLM_QUERY_SYNTAX XFLM_ERROR_BASE( 0x0141) // Query expression had improper syntax. + #define NE_XFLM_INDEX_OFFLINE XFLM_ERROR_BASE( 0x0142) // Index is offline, cannot be used in a query. + #define NE_XFLM_RFL_DISK_FULL XFLM_ERROR_BASE( 0x0143) // Disk which contains roll-forward log is full. + #define NE_XFLM_MUST_WAIT_CHECKPOINT XFLM_ERROR_BASE( 0x0144) // Must wait for a checkpoint before starting transaction - due to disk problems - usually in disk containing roll-forward log files. + #define NE_XFLM_MISSING_ENC_ALGORITHM XFLM_ERROR_BASE( 0x0145) // Encryption definition is missing an encryption algorithm. + #define NE_XFLM_INVALID_ENC_ALGORITHM XFLM_ERROR_BASE( 0x0146) // Invalid encryption algorithm specified in encryption definition. + #define NE_XFLM_INVALID_ENC_KEY_SIZE XFLM_ERROR_BASE( 0x0147) // Invalid key size specified in encryption definition. + #define NE_XFLM_ILLEGAL_DATA_TYPE XFLM_ERROR_BASE( 0x0148) // Data type specified for XML element or attribute definition is illegal. + #define NE_XFLM_ILLEGAL_STATE XFLM_ERROR_BASE( 0x0149) // State specified for index definition or XML element or attribute definition is illegal. + #define NE_XFLM_ILLEGAL_ELEMENT_NAME XFLM_ERROR_BASE( 0x014A) // XML element name specified in element definition is illegal. + #define NE_XFLM_ILLEGAL_ATTRIBUTE_NAME XFLM_ERROR_BASE( 0x014B) // XML attribute name specified in attribute definition is illegal. + #define NE_XFLM_ILLEGAL_COLLECTION_NAME XFLM_ERROR_BASE( 0x014C) // Collection name specified in collection definition is illegal. + #define NE_XFLM_ILLEGAL_INDEX_NAME XFLM_ERROR_BASE( 0x014D) // Index name specified is illegal + #define NE_XFLM_ILLEGAL_ELEMENT_NUMBER XFLM_ERROR_BASE( 0x014E) // Element number specified in element definition or index definition is illegal. + #define NE_XFLM_ILLEGAL_ATTRIBUTE_NUMBER XFLM_ERROR_BASE( 0x014F) // Attribute number specified in attribute definition or index definition is illegal. + #define NE_XFLM_ILLEGAL_COLLECTION_NUMBER XFLM_ERROR_BASE( 0x0150) // Collection number specified in collection definition or index definition is illegal. + #define NE_XFLM_ILLEGAL_INDEX_NUMBER XFLM_ERROR_BASE( 0x0151) // Index number specified in index definition is illegal. + #define NE_XFLM_ILLEGAL_ENCDEF_NUMBER XFLM_ERROR_BASE( 0x0152) // Encryption definition number specified in encryption definition is illegal. + #define NE_XFLM_COLLECTION_NAME_MISMATCH XFLM_ERROR_BASE( 0x0153) // Collection name and number specified in index definition do not correspond to each other. + #define NE_XFLM_ELEMENT_NAME_MISMATCH XFLM_ERROR_BASE( 0x0154) // Element name+namespace and number specified in index definition do not correspond to each other. + #define NE_XFLM_ATTRIBUTE_NAME_MISMATCH XFLM_ERROR_BASE( 0x0155) // Attribute name+namespace and number specified in index definition do not correspond to each other. + #define NE_XFLM_INVALID_COMPARE_RULE XFLM_ERROR_BASE( 0x0156) // Invalid comparison rule specified in index definition. + #define NE_XFLM_DUPLICATE_KEY_COMPONENT XFLM_ERROR_BASE( 0x0157) // Duplicate key component number specified in index definition. + #define NE_XFLM_DUPLICATE_DATA_COMPONENT XFLM_ERROR_BASE( 0x0158) // Duplicate data component number specified in index definition. + #define NE_XFLM_MISSING_KEY_COMPONENT XFLM_ERROR_BASE( 0x0159) // Index definition is missing a key component. + #define NE_XFLM_MISSING_DATA_COMPONENT XFLM_ERROR_BASE( 0x015A) // Index definition is missing a data component. + #define NE_XFLM_INVALID_INDEX_OPTION XFLM_ERROR_BASE( 0x015B) // Invalid index option specified on index definition. + #define NE_XFLM_NO_MORE_ATTRIBUTE_NUMS XFLM_ERROR_BASE( 0x015C) // The highest attribute number has already been used, cannot create more. + #define NE_XFLM_MISSING_ELEMENT_NAME XFLM_ERROR_BASE( 0x015D) // Missing element name in XML element definition. + #define NE_XFLM_MISSING_ATTRIBUTE_NAME XFLM_ERROR_BASE( 0x015E) // Missing attribute name in XML attribute definition. + #define NE_XFLM_MISSING_ELEMENT_NUMBER XFLM_ERROR_BASE( 0x015F) // Missing element number in XML element definition. + #define NE_XFLM_MISSING_ATTRIBUTE_NUMBER XFLM_ERROR_BASE( 0x0160) // Missing attribute number from XML attribute definition. + #define NE_XFLM_MISSING_INDEX_NAME XFLM_ERROR_BASE( 0x0161) // Missing index name in index definition. + #define NE_XFLM_MISSING_INDEX_NUMBER XFLM_ERROR_BASE( 0x0162) // Missing index number in index definition. + #define NE_XFLM_MISSING_COLLECTION_NAME XFLM_ERROR_BASE( 0x0163) // Missing collection name in collection definition. + #define NE_XFLM_MISSING_COLLECTION_NUMBER XFLM_ERROR_BASE( 0x0164) // Missing collection number in collection definition. + #define NE_XFLM_MISSING_ENCDEF_NAME XFLM_ERROR_BASE( 0x0165) // Missing encryption definition name in encryption definition. + #define NE_XFLM_MISSING_ENCDEF_NUMBER XFLM_ERROR_BASE( 0x0166) // Missing encryption definition number in encryption definition. + #define NE_XFLM_NO_MORE_INDEX_NUMS XFLM_ERROR_BASE( 0x0167) // The highest index number has already been used, cannot create more. + #define NE_XFLM_NO_MORE_COLLECTION_NUMS XFLM_ERROR_BASE( 0x0168) // The highest collection number has already been used, cannot create more. + #define NE_XFLM_CANNOT_DEL_ATTRIBUTE XFLM_ERROR_BASE( 0x0169) // Cannot delete an XML attribute definition because it is in use. + #define NE_XFLM_TOO_MANY_PENDING_NODES XFLM_ERROR_BASE( 0x016A) // Too many documents in the pending document list. + #define NE_XFLM_BAD_USE_OF_ELM_ROOT_TAG XFLM_ERROR_BASE( 0x016B) // ELM_ROOT_TAG, if used, must be the sole root component of an index definition. + #define NE_XFLM_DUP_SIBLING_IX_COMPONENTS XFLM_ERROR_BASE( 0x016C) // Sibling components in an index definition cannot have the same XML element or attribute number. + #define NE_XFLM_RFL_FILE_NOT_FOUND XFLM_ERROR_BASE( 0x016D) // Could not open a roll-forward log file - was not found in the roll-forward log directory. + #define NE_XFLM_ILLEGAL_KEY_COMPONENT_NUM XFLM_ERROR_BASE( 0x016E) // Key component of zero in index definition is not allowed. + #define NE_XFLM_ILLEGAL_DATA_COMPONENT_NUM XFLM_ERROR_BASE( 0x016F) // Data component of zero in index definition is not allowed. + #define NE_XFLM_ILLEGAL_PREFIX_NUMBER XFLM_ERROR_BASE( 0x0170) // Prefix number specified in prefix definition is illegal. + #define NE_XFLM_MISSING_PREFIX_NAME XFLM_ERROR_BASE( 0x0171) // Missing prefix name in prefix definition. + #define NE_XFLM_MISSING_PREFIX_NUMBER XFLM_ERROR_BASE( 0x0172) // Missing prefix number in prefix definition. + #define NE_XFLM_UNDEFINED_ELEMENT_NAME XFLM_ERROR_BASE( 0x0173) // XML element name+namespace that was specified in index definition or XML document is not defined in dictionary. + #define NE_XFLM_UNDEFINED_ATTRIBUTE_NAME XFLM_ERROR_BASE( 0x0174) // XML attribute name+namespace that was specified in index definition or XML document is not defined in dictionary. + #define NE_XFLM_DUPLICATE_PREFIX_NAME XFLM_ERROR_BASE( 0x0175) // Prefix name specified in prefix definition is already in use. + #define NE_XFLM_NAMESPACE_NOT_ALLOWED XFLM_ERROR_BASE( 0x0176) // Cannot define a namespace for XML attributes whose name begins with "xmlns:" or that is equal to "xmlns" + #define NE_XFLM_INVALID_NAMESPACE_DECL XFLM_ERROR_BASE( 0x0177) // Name for namespace declaration attribute must be "xmlns" or begin with "xmlns:" + #define NE_XFLM_ILLEGAL_NAMESPACE_DECL_DATATYPE XFLM_ERROR_BASE( 0x0178) // Data type for XML attributes that are namespace declarations must be text. + #define NE_XFLM_NO_MORE_PREFIX_NUMS XFLM_ERROR_BASE( 0x0179) // The highest prefix number has already been used, cannot create more. + #define NE_XFLM_NO_MORE_ENCDEF_NUMS XFLM_ERROR_BASE( 0x017A) // The highest encryption definition number has already been used, cannot create more. + #define NE_XFLM_COLLECTION_OFFLINE XFLM_ERROR_BASE( 0x017B) // Collection is encrypted, cannot be accessed while in operating in limited mode. + #define NE_XFLM_DELETE_NOT_ALLOWED XFLM_ERROR_BASE( 0x017C) // Item cannot be deleted. + #define NE_XFLM_RESET_NEEDED XFLM_ERROR_BASE( 0x017D) // Used during check operations to indicate we need to reset the view. NOTE: This is an internal error code and should not be documented. + #define NE_XFLM_ILLEGAL_REQUIRED_VALUE XFLM_ERROR_BASE( 0x017E) // An illegal value was specified for the "Required" attribute in an index definition. + #define NE_XFLM_ILLEGAL_INDEX_COMPONENT XFLM_ERROR_BASE( 0x017F) // A leaf index component in an index definition was not marked as a data component or key component. + #define NE_XFLM_ILLEGAL_UNIQUE_SUB_ELEMENT_VALUE XFLM_ERROR_BASE( 0x0180) // Illegal value for the "UniqueSubElements" attribute in an element definition. + #define NE_XFLM_DATA_TYPE_MUST_BE_NO_DATA XFLM_ERROR_BASE( 0x0181) // Data type for an element definition with UniqueSubElements="yes" must be nodata. + #define NE_XFLM_CANNOT_SET_REQUIRED XFLM_ERROR_BASE( 0x0182) // Cannot set the "Required" attribute on a non-key index component in index definition. + #define NE_XFLM_CANNOT_SET_LIMIT XFLM_ERROR_BASE( 0x0183) // Cannot set the "Limit" attribute on a non-key index component in index definition. + #define NE_XFLM_CANNOT_SET_INDEX_ON XFLM_ERROR_BASE( 0x0184) // Cannot set the "IndexOn" attribute on a non-key index component in index definition. + #define NE_XFLM_CANNOT_SET_COMPARE_RULES XFLM_ERROR_BASE( 0x0185) // Cannot set the "CompareRules" on a non-key index component in index definition. + #define NE_XFLM_INPUT_PENDING XFLM_ERROR_BASE( 0x0186) // Attempt to set a value while an input stream is still open. + #define NE_XFLM_INVALID_NODE_TYPE XFLM_ERROR_BASE( 0x0187) // Bad node type + #define NE_XFLM_INVALID_CHILD_ELM_NODE_ID XFLM_ERROR_BASE( 0x0188) // Attempt to insert a unique child element that has a lower node ID than the parent element + #define NE_XFLM_RFL_END XFLM_ERROR_BASE( 0x0189) // Hit the end of the RFL + #define NE_XFLM_LAST_GENERAL_ERROR XFLM_ERROR_BASE( 0x018A) // NOTE: This is not an error code - do not document /**************************************************************************** Desc: DOM Errors @@ -5836,162 +4764,81 @@ #define NE_XFLM_DOM_DUPLICATE_ELEMENT XFLM_ERROR_BASE( 0x1107) // Node already has a child element with the given name id - this node's child nodes must all be unique. #define NE_XFLM_LAST_DOM_ERROR XFLM_ERROR_BASE( 0x1108) // NOTE: This is not an error code - do not document - /**************************************************************************** - Desc: I/O Errors - ****************************************************************************/ - - #define NE_XFLM_FIRST_IO_ERROR XFLM_ERROR_BASE( 0x2100) // NOTE: This is not an error code - do not document - #define NE_XFLM_IO_ACCESS_DENIED XFLM_ERROR_BASE( 0x2101) // Access to file is denied. Caller is not allowed access to a file. - #define NE_XFLM_IO_BAD_FILE_HANDLE XFLM_ERROR_BASE( 0x2102) // Bad file handle or file descriptor. - #define NE_XFLM_IO_COPY_ERR XFLM_ERROR_BASE( 0x2103) // Error occurred while copying a file. - #define NE_XFLM_IO_DISK_FULL XFLM_ERROR_BASE( 0x2104) // Disk full. - #define NE_XFLM_IO_END_OF_FILE XFLM_ERROR_BASE( 0x2105) // End of file reached while reading from the file. - #define NE_XFLM_IO_OPEN_ERR XFLM_ERROR_BASE( 0x2106) // Error while opening the file. - #define NE_XFLM_IO_SEEK_ERR XFLM_ERROR_BASE( 0x2107) // Error occurred while positioning (seeking) within a file. - #define NE_XFLM_IO_DIRECTORY_ERR XFLM_ERROR_BASE( 0x2108) // Error occurred while accessing or deleting a directory. - #define NE_XFLM_IO_PATH_NOT_FOUND XFLM_ERROR_BASE( 0x2109) // File not found. - #define NE_XFLM_IO_TOO_MANY_OPEN_FILES XFLM_ERROR_BASE( 0x210A) // Too many files open. - #define NE_XFLM_IO_PATH_TOO_LONG XFLM_ERROR_BASE( 0x210B) // File name too long. - #define NE_XFLM_IO_NO_MORE_FILES XFLM_ERROR_BASE( 0x210C) // No more files in directory. - #define NE_XFLM_IO_DELETING_FILE XFLM_ERROR_BASE( 0x210D) // Error occurred while deleting a file. - #define NE_XFLM_IO_FILE_LOCK_ERR XFLM_ERROR_BASE( 0x210E) // Error attempting to acquire a byte-range lock on a file. - #define NE_XFLM_IO_FILE_UNLOCK_ERR XFLM_ERROR_BASE( 0x210F) // Error attempting to release a byte-range lock on a file. - #define NE_XFLM_IO_PATH_CREATE_FAILURE XFLM_ERROR_BASE( 0x2110) // Error occurred while attempting to create a directory or sub-directory. - #define NE_XFLM_IO_RENAME_FAILURE XFLM_ERROR_BASE( 0x2111) // Error occurred while renaming a file. - #define NE_XFLM_IO_INVALID_PASSWORD XFLM_ERROR_BASE( 0x2112) // Invalid file password. - #define NE_XFLM_SETTING_UP_FOR_READ XFLM_ERROR_BASE( 0x2113) // Error occurred while setting up to perform a file read operation. - #define NE_XFLM_SETTING_UP_FOR_WRITE XFLM_ERROR_BASE( 0x2114) // Error occurred while setting up to perform a file write operation. - #define NE_XFLM_IO_CANNOT_REDUCE_PATH XFLM_ERROR_BASE( 0x2115) // Cannot reduce file name into more components. - #define NE_XFLM_INITIALIZING_IO_SYSTEM XFLM_ERROR_BASE( 0x2116) // Error occurred while setting up to access the file system. - #define NE_XFLM_FLUSHING_FILE XFLM_ERROR_BASE( 0x2117) // Error occurred while flushing file data buffers to disk. - #define NE_XFLM_IO_INVALID_FILENAME XFLM_ERROR_BASE( 0x2118) // Invalid file name. - #define NE_XFLM_IO_CONNECT_ERROR XFLM_ERROR_BASE( 0x2119) // Error connecting to a remote network resource. - #define NE_XFLM_OPENING_FILE XFLM_ERROR_BASE( 0x211A) // Unexpected error occurred while opening a file. - #define NE_XFLM_DIRECT_OPENING_FILE XFLM_ERROR_BASE( 0x211B) // Unexpected error occurred while opening a file in direct access mode. - #define NE_XFLM_CREATING_FILE XFLM_ERROR_BASE( 0x211C) // Unexpected error occurred while creating a file. - #define NE_XFLM_DIRECT_CREATING_FILE XFLM_ERROR_BASE( 0x211D) // Unexpected error occurred while creating a file in direct access mode. - #define NE_XFLM_READING_FILE XFLM_ERROR_BASE( 0x211E) // Unexpected error occurred while reading a file. - #define NE_XFLM_DIRECT_READING_FILE XFLM_ERROR_BASE( 0x211F) // Unexpected error occurred while reading a file in direct access mode. - #define NE_XFLM_WRITING_FILE XFLM_ERROR_BASE( 0x2120) // Unexpected error occurred while writing to a file. - #define NE_XFLM_DIRECT_WRITING_FILE XFLM_ERROR_BASE( 0x2121) // Unexpected error occurred while writing a file in direct access mode. - #define NE_XFLM_POSITIONING_IN_FILE XFLM_ERROR_BASE( 0x2122) // Unexpected error occurred while positioning within a file. - #define NE_XFLM_GETTING_FILE_SIZE XFLM_ERROR_BASE( 0x2123) // Unexpected error occurred while getting a file's size. - #define NE_XFLM_TRUNCATING_FILE XFLM_ERROR_BASE( 0x2124) // Unexpected error occurred while truncating a file. - #define NE_XFLM_PARSING_FILE_NAME XFLM_ERROR_BASE( 0x2125) // Unexpected error occurred while parsing a file's name. - #define NE_XFLM_CLOSING_FILE XFLM_ERROR_BASE( 0x2126) // Unexpected error occurred while closing a file. - #define NE_XFLM_GETTING_FILE_INFO XFLM_ERROR_BASE( 0x2127) // Unexpected error occurred while getting information about a file. - #define NE_XFLM_EXPANDING_FILE XFLM_ERROR_BASE( 0x2128) // Unexpected error occurred while expanding a file. - #define NE_XFLM_CHECKING_FILE_EXISTENCE XFLM_ERROR_BASE( 0x2129) // Unexpected error occurred while checking to see if a file exists. - #define NE_XFLM_RENAMING_FILE XFLM_ERROR_BASE( 0x212A) // Unexpected error occurred while renaming a file. - #define NE_XFLM_SETTING_FILE_INFO XFLM_ERROR_BASE( 0x212B) // Unexpected error occurred while setting a file's information. - #define NE_XFLM_LAST_IO_ERROR XFLM_ERROR_BASE( 0x212C) // NOTE: This is not an error code - do not document - - /**************************************************************************** - Desc: Network Errors - ****************************************************************************/ - - #define NE_XFLM_FIRST_NET_ERROR XFLM_ERROR_BASE( 0x3100) // NOTE: This is not an error code - do not document - #define NE_XFLM_NOIP_ADDR XFLM_ERROR_BASE( 0x3101) // IP address not found - #define NE_XFLM_SOCKET_FAIL XFLM_ERROR_BASE( 0x3102) // IP socket failure - #define NE_XFLM_CONNECT_FAIL XFLM_ERROR_BASE( 0x3103) // TCP/IP connection failure - #define NE_XFLM_BIND_FAIL XFLM_ERROR_BASE( 0x3104) // The TCP/IP services on your system may not be configured or installed. If this POA is not to run Client/Server, use the /notcpip startup switch or disable TCP/IP through the NWADMIN snapin - #define NE_XFLM_LISTEN_FAIL XFLM_ERROR_BASE( 0x3105) // TCP/IP listen failed - #define NE_XFLM_ACCEPT_FAIL XFLM_ERROR_BASE( 0x3106) // TCP/IP accept failed - #define NE_XFLM_SELECT_ERR XFLM_ERROR_BASE( 0x3107) // TCP/IP select failed - #define NE_XFLM_SOCKET_SET_OPT_FAIL XFLM_ERROR_BASE( 0x3108) // TCP/IP socket operation failed - #define NE_XFLM_SOCKET_DISCONNECT XFLM_ERROR_BASE( 0x3109) // TCP/IP disconnected - #define NE_XFLM_SOCKET_READ_FAIL XFLM_ERROR_BASE( 0x310A) // TCP/IP read failed - #define NE_XFLM_SOCKET_WRITE_FAIL XFLM_ERROR_BASE( 0x310B) // TCP/IP write failed - #define NE_XFLM_SOCKET_READ_TIMEOUT XFLM_ERROR_BASE( 0x310C) // TCP/IP read timeout - #define NE_XFLM_SOCKET_WRITE_TIMEOUT XFLM_ERROR_BASE( 0x310D) // TCP/IP write timeout - #define NE_XFLM_SOCKET_ALREADY_CLOSED XFLM_ERROR_BASE( 0x310E) // Connection already closed - #define NE_XFLM_LAST_NET_ERROR XFLM_ERROR_BASE( 0x310F) // NOTE: This is not an error code - do not document - /**************************************************************************** Desc: Query Errors ****************************************************************************/ - #define NE_XFLM_FIRST_QUERY_ERROR XFLM_ERROR_BASE( 0x4100) // NOTE: This is not an error code - do not document - #define NE_XFLM_Q_UNMATCHED_RPAREN XFLM_ERROR_BASE( 0x4101) // Query setup error: Unmatched right paren. - #define NE_XFLM_Q_UNEXPECTED_LPAREN XFLM_ERROR_BASE( 0x4102) // Query setup error: Unexpected left paren. - #define NE_XFLM_Q_UNEXPECTED_RPAREN XFLM_ERROR_BASE( 0x4103) // Query setup error: Unexpected right paren. - #define NE_XFLM_Q_EXPECTING_OPERAND XFLM_ERROR_BASE( 0x4104) // Query setup error: Expecting an operand. - #define NE_XFLM_Q_EXPECTING_OPERATOR XFLM_ERROR_BASE( 0x4105) // Query setup error: Expecting an operator. - #define NE_XFLM_Q_UNEXPECTED_COMMA XFLM_ERROR_BASE( 0x4106) // Query setup error: Unexpected comma. - #define NE_XFLM_Q_EXPECTING_LPAREN XFLM_ERROR_BASE( 0x4107) // Query setup error: Expecting a left paren. - #define NE_XFLM_Q_UNEXPECTED_VALUE XFLM_ERROR_BASE( 0x4108) // Query setup error: Unexpected value. - #define NE_XFLM_Q_INVALID_NUM_FUNC_ARGS XFLM_ERROR_BASE( 0x4109) // Query setup error: Invalid number of arguments for a function. - #define NE_XFLM_Q_UNEXPECTED_XPATH_COMPONENT XFLM_ERROR_BASE( 0x410A) // Query setup error: Unexpected XPATH componenent. - #define NE_XFLM_Q_ILLEGAL_LBRACKET XFLM_ERROR_BASE( 0x410B) // Query setup error: Illegal left bracket ([). - #define NE_XFLM_Q_ILLEGAL_RBRACKET XFLM_ERROR_BASE( 0x410C) // Query setup error: Illegal right bracket (]). - #define NE_XFLM_Q_ILLEGAL_OPERAND XFLM_ERROR_BASE( 0x410D) // Query setup error: Operand for some operator is not valid for that operator type. - #define NE_XFLM_Q_ALREADY_OPTIMIZED XFLM_ERROR_BASE( 0x410E) // Operation is illegal, cannot change certain things after query has been optimized. - #define NE_XFLM_Q_MISMATCHED_DB XFLM_ERROR_BASE( 0x410F) // Database handle passed in does not match database associated with query. - #define NE_XFLM_Q_ILLEGAL_OPERATOR XFLM_ERROR_BASE( 0x4110) // Illegal operator - cannot pass this operator into the addOperator method. - #define NE_XFLM_Q_ILLEGAL_COMPARE_RULES XFLM_ERROR_BASE( 0x4111) // Illegal combination of comparison rules passed to addOperator method. - #define NE_XFLM_Q_INCOMPLETE_QUERY_EXPR XFLM_ERROR_BASE( 0x4112) // Query setup error: Query expression is incomplete. - #define NE_XFLM_Q_NOT_POSITIONED XFLM_ERROR_BASE( 0x4113) // Query not positioned due to previous error, cannot call getNext, getPrev, or getCurrent - #define NE_XFLM_Q_INVALID_NODE_ID_VALUE XFLM_ERROR_BASE( 0x4114) // Query setup error: Invalid type of value constant used for node id value comparison. - #define NE_XFLM_Q_INVALID_META_DATA_TYPE XFLM_ERROR_BASE( 0x4115) // Query setup error: Invalid meta data type specified. - #define NE_XFLM_Q_NEW_EXPR_NOT_ALLOWED XFLM_ERROR_BASE( 0x4116) // Query setup error: Cannot add an expression to an XPATH component after having added an expression that tests context position. - #define NE_XFLM_Q_INVALID_CONTEXT_POS XFLM_ERROR_BASE( 0x4117) // Invalid context position value encountered - must be a positive number. - #define NE_XFLM_Q_INVALID_FUNC_ARG XFLM_ERROR_BASE( 0x4118) // Query setup error: Parameter to user-defined functions must be a single XPATH only. - #define NE_XFLM_Q_EXPECTING_RPAREN XFLM_ERROR_BASE( 0x4119) // Query setup error: Expecting right paren. - #define NE_XFLM_Q_TOO_LATE_TO_ADD_SORT_KEYS XFLM_ERROR_BASE( 0x411A) // Query setup error: Cannot add sort keys after having called getFirst, getLast, getNext, or getPrev. - #define NE_XFLM_Q_INVALID_SORT_KEY_COMPONENT XFLM_ERROR_BASE( 0x411B) // Query setup error: Invalid sort key component number specified in query. - #define NE_XFLM_Q_DUPLICATE_SORT_KEY_COMPONENT XFLM_ERROR_BASE( 0x411C) // Query setup error: Duplicate sort key component number specified in query. - #define NE_XFLM_Q_MISSING_SORT_KEY_COMPONENT XFLM_ERROR_BASE( 0x411D) // Query setup error: Missing sort key component number in sort keys that were specified for query. - #define NE_XFLM_Q_NO_SORT_KEY_COMPONENTS_SPECIFIED XFLM_ERROR_BASE( 0x411E) // Query setup error: addSortKeys was called, but no sort key components were specified. - #define NE_XFLM_Q_SORT_KEY_CONTEXT_MUST_BE_ELEMENT XFLM_ERROR_BASE( 0x411F) // Query setup error: A sort key context cannot be an XML attribute. - #define NE_XFLM_Q_INVALID_ELEMENT_NUM_IN_SORT_KEYS XFLM_ERROR_BASE( 0x4120) // Query setup error: The XML element number specified for a sort key in a query is invalid - no element definition in the dictionary. - #define NE_XFLM_Q_INVALID_ATTR_NUM_IN_SORT_KEYS XFLM_ERROR_BASE( 0x4121) // Query setup error: The XML attribute number specified for a sort key in a query is invalid - no attribute definition in the dictionary. - #define NE_XFLM_Q_NON_POSITIONABLE_QUERY XFLM_ERROR_BASE( 0x4122) // Attempt is being made to position in a query that is not positionable. - #define NE_XFLM_Q_INVALID_POSITION XFLM_ERROR_BASE( 0x4123) // Attempt is being made to position to an invalid position in the result set. - #define NE_XFLM_LAST_QUERY_ERROR XFLM_ERROR_BASE( 0x4124) // NOTE: This is not an error code - do not document - - /**************************************************************************** - Desc: Stream Errors - ****************************************************************************/ - - #define NE_XFLM_FIRST_STREAM_ERROR XFLM_ERROR_BASE( 0x6100) // NOTE: This is not an error code - do not document - #define NE_XFLM_STREAM_DECOMPRESS_ERROR XFLM_ERROR_BASE( 0x6101) // Error decompressing data stream. - #define NE_XFLM_STREAM_NOT_COMPRESSED XFLM_ERROR_BASE( 0x6102) // Attempting to decompress a data stream that is not compressed. - #define NE_XFLM_STREAM_TOO_MANY_FILES XFLM_ERROR_BASE( 0x6103) // Too many files in input stream. - #define NE_XFLM_LAST_STREAM_ERROR XFLM_ERROR_BASE( 0x6104) // NOTE: This is not an error code - do not document + #define NE_XFLM_FIRST_QUERY_ERROR XFLM_ERROR_BASE( 0x2100) // NOTE: This is not an error code - do not document + #define NE_XFLM_Q_UNMATCHED_RPAREN XFLM_ERROR_BASE( 0x2101) // Query setup error: Unmatched right paren. + #define NE_XFLM_Q_UNEXPECTED_LPAREN XFLM_ERROR_BASE( 0x2102) // Query setup error: Unexpected left paren. + #define NE_XFLM_Q_UNEXPECTED_RPAREN XFLM_ERROR_BASE( 0x2103) // Query setup error: Unexpected right paren. + #define NE_XFLM_Q_EXPECTING_OPERAND XFLM_ERROR_BASE( 0x2104) // Query setup error: Expecting an operand. + #define NE_XFLM_Q_EXPECTING_OPERATOR XFLM_ERROR_BASE( 0x2105) // Query setup error: Expecting an operator. + #define NE_XFLM_Q_UNEXPECTED_COMMA XFLM_ERROR_BASE( 0x2106) // Query setup error: Unexpected comma. + #define NE_XFLM_Q_EXPECTING_LPAREN XFLM_ERROR_BASE( 0x2107) // Query setup error: Expecting a left paren. + #define NE_XFLM_Q_UNEXPECTED_VALUE XFLM_ERROR_BASE( 0x2108) // Query setup error: Unexpected value. + #define NE_XFLM_Q_INVALID_NUM_FUNC_ARGS XFLM_ERROR_BASE( 0x2109) // Query setup error: Invalid number of arguments for a function. + #define NE_XFLM_Q_UNEXPECTED_XPATH_COMPONENT XFLM_ERROR_BASE( 0x210A) // Query setup error: Unexpected XPATH componenent. + #define NE_XFLM_Q_ILLEGAL_LBRACKET XFLM_ERROR_BASE( 0x210B) // Query setup error: Illegal left bracket ([). + #define NE_XFLM_Q_ILLEGAL_RBRACKET XFLM_ERROR_BASE( 0x210C) // Query setup error: Illegal right bracket (]). + #define NE_XFLM_Q_ILLEGAL_OPERAND XFLM_ERROR_BASE( 0x210D) // Query setup error: Operand for some operator is not valid for that operator type. + #define NE_XFLM_Q_ALREADY_OPTIMIZED XFLM_ERROR_BASE( 0x210E) // Operation is illegal, cannot change certain things after query has been optimized. + #define NE_XFLM_Q_MISMATCHED_DB XFLM_ERROR_BASE( 0x210F) // Database handle passed in does not match database associated with query. + #define NE_XFLM_Q_ILLEGAL_OPERATOR XFLM_ERROR_BASE( 0x2110) // Illegal operator - cannot pass this operator into the addOperator method. + #define NE_XFLM_Q_ILLEGAL_COMPARE_RULES XFLM_ERROR_BASE( 0x2111) // Illegal combination of comparison rules passed to addOperator method. + #define NE_XFLM_Q_INCOMPLETE_QUERY_EXPR XFLM_ERROR_BASE( 0x2112) // Query setup error: Query expression is incomplete. + #define NE_XFLM_Q_NOT_POSITIONED XFLM_ERROR_BASE( 0x2113) // Query not positioned due to previous error, cannot call getNext, getPrev, or getCurrent + #define NE_XFLM_Q_INVALID_NODE_ID_VALUE XFLM_ERROR_BASE( 0x2114) // Query setup error: Invalid type of value constant used for node id value comparison. + #define NE_XFLM_Q_INVALID_META_DATA_TYPE XFLM_ERROR_BASE( 0x2115) // Query setup error: Invalid meta data type specified. + #define NE_XFLM_Q_NEW_EXPR_NOT_ALLOWED XFLM_ERROR_BASE( 0x2116) // Query setup error: Cannot add an expression to an XPATH component after having added an expression that tests context position. + #define NE_XFLM_Q_INVALID_CONTEXT_POS XFLM_ERROR_BASE( 0x2117) // Invalid context position value encountered - must be a positive number. + #define NE_XFLM_Q_INVALID_FUNC_ARG XFLM_ERROR_BASE( 0x2118) // Query setup error: Parameter to user-defined functions must be a single XPATH only. + #define NE_XFLM_Q_EXPECTING_RPAREN XFLM_ERROR_BASE( 0x2119) // Query setup error: Expecting right paren. + #define NE_XFLM_Q_TOO_LATE_TO_ADD_SORT_KEYS XFLM_ERROR_BASE( 0x211A) // Query setup error: Cannot add sort keys after having called getFirst, getLast, getNext, or getPrev. + #define NE_XFLM_Q_INVALID_SORT_KEY_COMPONENT XFLM_ERROR_BASE( 0x211B) // Query setup error: Invalid sort key component number specified in query. + #define NE_XFLM_Q_DUPLICATE_SORT_KEY_COMPONENT XFLM_ERROR_BASE( 0x211C) // Query setup error: Duplicate sort key component number specified in query. + #define NE_XFLM_Q_MISSING_SORT_KEY_COMPONENT XFLM_ERROR_BASE( 0x211D) // Query setup error: Missing sort key component number in sort keys that were specified for query. + #define NE_XFLM_Q_NO_SORT_KEY_COMPONENTS_SPECIFIED XFLM_ERROR_BASE( 0x211E) // Query setup error: addSortKeys was called, but no sort key components were specified. + #define NE_XFLM_Q_SORT_KEY_CONTEXT_MUST_BE_ELEMENT XFLM_ERROR_BASE( 0x211F) // Query setup error: A sort key context cannot be an XML attribute. + #define NE_XFLM_Q_INVALID_ELEMENT_NUM_IN_SORT_KEYS XFLM_ERROR_BASE( 0x2120) // Query setup error: The XML element number specified for a sort key in a query is invalid - no element definition in the dictionary. + #define NE_XFLM_Q_INVALID_ATTR_NUM_IN_SORT_KEYS XFLM_ERROR_BASE( 0x2121) // Query setup error: The XML attribute number specified for a sort key in a query is invalid - no attribute definition in the dictionary. + #define NE_XFLM_Q_NON_POSITIONABLE_QUERY XFLM_ERROR_BASE( 0x2122) // Attempt is being made to position in a query that is not positionable. + #define NE_XFLM_Q_INVALID_POSITION XFLM_ERROR_BASE( 0x2123) // Attempt is being made to position to an invalid position in the result set. + #define NE_XFLM_LAST_QUERY_ERROR XFLM_ERROR_BASE( 0x2124) // NOTE: This is not an error code - do not document /**************************************************************************** Desc: NICI / Encryption Errors ****************************************************************************/ - #define NE_XFLM_FIRST_NICI_ERROR XFLM_ERROR_BASE( 0x7100) // NOTE: This is not an error code - do not document - #define NE_XFLM_NICI_CONTEXT XFLM_ERROR_BASE( 0x7101) // Error occurred while creating NICI context for encryption/decryption. - #define NE_XFLM_NICI_ATTRIBUTE_VALUE XFLM_ERROR_BASE( 0x7102) // Error occurred while accessing an attribute on a NICI encryption key. - #define NE_XFLM_NICI_BAD_ATTRIBUTE XFLM_ERROR_BASE( 0x7103) // Value retrieved from an attribute on a NICI encryption key was bad. - #define NE_XFLM_NICI_WRAPKEY_FAILED XFLM_ERROR_BASE( 0x7104) // Error occurred while wrapping a NICI encryption key in another NICI encryption key. - #define NE_XFLM_NICI_UNWRAPKEY_FAILED XFLM_ERROR_BASE( 0x7105) // Error occurred while unwrapping a NICI encryption key that is wrapped in another NICI encryption key. - #define NE_XFLM_NICI_INVALID_ALGORITHM XFLM_ERROR_BASE( 0x7106) // Attempt to use invalid NICI encryption algorithm. - #define NE_XFLM_NICI_GENKEY_FAILED XFLM_ERROR_BASE( 0x7107) // Error occurred while attempting to generate a NICI encryption key. - #define NE_XFLM_NICI_BAD_RANDOM XFLM_ERROR_BASE( 0x7108) // Error occurred while generating random data using NICI. - #define NE_XFLM_PBE_ENCRYPT_FAILED XFLM_ERROR_BASE( 0x7109) // Error occurred while attempting to wrap a NICI encryption key in a password. - #define NE_XFLM_PBE_DECRYPT_FAILED XFLM_ERROR_BASE( 0x710A) // Error occurred while attempting to unwrap a NICI encryption key that was previously wrapped in a password. - #define NE_XFLM_DIGEST_INIT_FAILED XFLM_ERROR_BASE( 0x710B) // Error occurred while attempting to initialize the NICI digest functionality. - #define NE_XFLM_DIGEST_FAILED XFLM_ERROR_BASE( 0x710C) // Error occurred while attempting to create a NICI digest. - #define NE_XFLM_INJECT_KEY_FAILED XFLM_ERROR_BASE( 0x710D) // Error occurred while attempting to inject an encryption key into NICI. - #define NE_XFLM_NICI_FIND_INIT XFLM_ERROR_BASE( 0x710E) // Error occurred while attempting to initialize NICI to find information on a NICI encryption key. - #define NE_XFLM_NICI_FIND_OBJECT XFLM_ERROR_BASE( 0x710F) // Error occurred while attempting to find information on a NICI encryption key. - #define NE_XFLM_NICI_KEY_NOT_FOUND XFLM_ERROR_BASE( 0x7110) // Could not find the NICI encryption key or information on the NICI encryption key. - #define NE_XFLM_NICI_ENC_INIT_FAILED XFLM_ERROR_BASE( 0x7111) // Error occurred while initializing NICI to encrypt data. - #define NE_XFLM_NICI_ENCRYPT_FAILED XFLM_ERROR_BASE( 0x7112) // Error occurred while encrypting data. - #define NE_XFLM_NICI_DECRYPT_INIT_FAILED XFLM_ERROR_BASE( 0x7113) // Error occurred while initializing NICI to decrypt data. - #define NE_XFLM_NICI_DECRYPT_FAILED XFLM_ERROR_BASE( 0x7114) // Error occurred while decrypting data. - #define NE_XFLM_NICI_WRAPKEY_NOT_FOUND XFLM_ERROR_BASE( 0x7115) // Could not find the NICI encryption key used to wrap another NICI encryption key. - #define NE_XFLM_NOT_EXPECTING_PASSWORD XFLM_ERROR_BASE( 0x7116) // Password supplied when none was expected. - #define NE_XFLM_EXPECTING_PASSWORD XFLM_ERROR_BASE( 0x7117) // No password supplied when one was required. - #define NE_XFLM_EXTRACT_KEY_FAILED XFLM_ERROR_BASE( 0x7118) // Error occurred while attempting to extract a NICI encryption key. - #define NE_XFLM_NICI_INIT_FAILED XFLM_ERROR_BASE( 0x7119) // Error occurred while initializing NICI. - #define NE_XFLM_BAD_ENCKEY_SIZE XFLM_ERROR_BASE( 0x711A) // Bad encryption key size found in roll-forward log packet. - #define NE_XFLM_ENCRYPTION_UNAVAILABLE XFLM_ERROR_BASE( 0x711B) // Attempt was made to encrypt data when NICI is unavailable. - #define NE_XFLM_LAST_NICI_ERROR XFLM_ERROR_BASE( 0x711C) // NOTE: This is not an error code - do not document + #define NE_XFLM_FIRST_NICI_ERROR XFLM_ERROR_BASE( 0x3100) // NOTE: This is not an error code - do not document + #define NE_XFLM_NICI_CONTEXT XFLM_ERROR_BASE( 0x3101) // Error occurred while creating NICI context for encryption/decryption. + #define NE_XFLM_NICI_ATTRIBUTE_VALUE XFLM_ERROR_BASE( 0x3102) // Error occurred while accessing an attribute on a NICI encryption key. + #define NE_XFLM_NICI_BAD_ATTRIBUTE XFLM_ERROR_BASE( 0x3103) // Value retrieved from an attribute on a NICI encryption key was bad. + #define NE_XFLM_NICI_WRAPKEY_FAILED XFLM_ERROR_BASE( 0x3104) // Error occurred while wrapping a NICI encryption key in another NICI encryption key. + #define NE_XFLM_NICI_UNWRAPKEY_FAILED XFLM_ERROR_BASE( 0x3105) // Error occurred while unwrapping a NICI encryption key that is wrapped in another NICI encryption key. + #define NE_XFLM_NICI_INVALID_ALGORITHM XFLM_ERROR_BASE( 0x3106) // Attempt to use invalid NICI encryption algorithm. + #define NE_XFLM_NICI_GENKEY_FAILED XFLM_ERROR_BASE( 0x3107) // Error occurred while attempting to generate a NICI encryption key. + #define NE_XFLM_NICI_BAD_RANDOM XFLM_ERROR_BASE( 0x3108) // Error occurred while generating random data using NICI. + #define NE_XFLM_PBE_ENCRYPT_FAILED XFLM_ERROR_BASE( 0x3109) // Error occurred while attempting to wrap a NICI encryption key in a password. + #define NE_XFLM_PBE_DECRYPT_FAILED XFLM_ERROR_BASE( 0x310A) // Error occurred while attempting to unwrap a NICI encryption key that was previously wrapped in a password. + #define NE_XFLM_DIGEST_INIT_FAILED XFLM_ERROR_BASE( 0x310B) // Error occurred while attempting to initialize the NICI digest functionality. + #define NE_XFLM_DIGEST_FAILED XFLM_ERROR_BASE( 0x310C) // Error occurred while attempting to create a NICI digest. + #define NE_XFLM_INJECT_KEY_FAILED XFLM_ERROR_BASE( 0x310D) // Error occurred while attempting to inject an encryption key into NICI. + #define NE_XFLM_NICI_FIND_INIT XFLM_ERROR_BASE( 0x310E) // Error occurred while attempting to initialize NICI to find information on a NICI encryption key. + #define NE_XFLM_NICI_FIND_OBJECT XFLM_ERROR_BASE( 0x310F) // Error occurred while attempting to find information on a NICI encryption key. + #define NE_XFLM_NICI_KEY_NOT_FOUND XFLM_ERROR_BASE( 0x3110) // Could not find the NICI encryption key or information on the NICI encryption key. + #define NE_XFLM_NICI_ENC_INIT_FAILED XFLM_ERROR_BASE( 0x3111) // Error occurred while initializing NICI to encrypt data. + #define NE_XFLM_NICI_ENCRYPT_FAILED XFLM_ERROR_BASE( 0x3112) // Error occurred while encrypting data. + #define NE_XFLM_NICI_DECRYPT_INIT_FAILED XFLM_ERROR_BASE( 0x3113) // Error occurred while initializing NICI to decrypt data. + #define NE_XFLM_NICI_DECRYPT_FAILED XFLM_ERROR_BASE( 0x3114) // Error occurred while decrypting data. + #define NE_XFLM_NICI_WRAPKEY_NOT_FOUND XFLM_ERROR_BASE( 0x3115) // Could not find the NICI encryption key used to wrap another NICI encryption key. + #define NE_XFLM_NOT_EXPECTING_PASSWORD XFLM_ERROR_BASE( 0x3116) // Password supplied when none was expected. + #define NE_XFLM_EXPECTING_PASSWORD XFLM_ERROR_BASE( 0x3117) // No password supplied when one was required. + #define NE_XFLM_EXTRACT_KEY_FAILED XFLM_ERROR_BASE( 0x3118) // Error occurred while attempting to extract a NICI encryption key. + #define NE_XFLM_NICI_INIT_FAILED XFLM_ERROR_BASE( 0x3119) // Error occurred while initializing NICI. + #define NE_XFLM_BAD_ENCKEY_SIZE XFLM_ERROR_BASE( 0x311A) // Bad encryption key size found in roll-forward log packet. + #define NE_XFLM_ENCRYPTION_UNAVAILABLE XFLM_ERROR_BASE( 0x311B) // Attempt was made to encrypt data when NICI is unavailable. + #define NE_XFLM_LAST_NICI_ERROR XFLM_ERROR_BASE( 0x311C) // NOTE: This is not an error code - do not document /**************************************************************************** Dictionary Document Definitions - below are comments that document valid