Added various methods for settings to DbSystem class in C#. Also changed Languages enum to be a uint instead of an int. Also added compareStrings method to DbSystem class. Also added unit tests for settings and compare strings.

git-svn-id: https://svn.code.sf.net/p/flaim/code/trunk@911 0109f412-320b-0410-ab79-c3e0c5ffbbe6
This commit is contained in:
dsandersoremutah
2006-09-26 17:39:38 +00:00
parent 74a4222187
commit cb3c761e2a
9 changed files with 1367 additions and 7 deletions

View File

@@ -0,0 +1,154 @@
//------------------------------------------------------------------------------
// Desc: Settings tests
//
// Tabs: 3
//
// Copyright (c) 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$
//------------------------------------------------------------------------------
using System;
using System.IO;
using System.Runtime.InteropServices;
using xflaim;
namespace cstest
{
//--------------------------------------------------------------------------
// String comparison tests.
//--------------------------------------------------------------------------
public class CompareStringTests : Tester
{
private bool compareStrTest(
string sLeftStr,
bool bLeftWild,
string sRightStr,
bool bRightWild,
CompareFlags compareFlags,
bool bExpectedEqual,
DbSystem dbSystem)
{
int iCmp;
beginTest( "Compare Strings, Str1: \"" + sLeftStr +
"\", Str2: \"" + sRightStr + "\"");
try
{
iCmp = dbSystem.compareStrings( sLeftStr, bLeftWild,
sRightStr, bRightWild, compareFlags,
Languages.FLM_US_LANG);
}
catch (XFlaimException ex)
{
endTest( false, ex, "calling compareStrings");
return( false);
}
if ((bExpectedEqual && iCmp != 0) ||
(!bExpectedEqual && iCmp == 0))
{
endTest( false, false);
System.Console.WriteLine( "Expected Equal [{0}] != Result [{1}]",
bExpectedEqual, iCmp);
System.Console.WriteLine( "Compare Flags: {0}", compareFlags);
System.Console.WriteLine( "Left Wild: {0}", bLeftWild);
System.Console.WriteLine( "Right Wild: {0}", bRightWild);
}
endTest( false, true);
return( true);
}
public bool compareStringTests(
DbSystem dbSystem)
{
if (!compareStrTest( "ABC", false, "abc", false, CompareFlags.FLM_COMP_CASE_INSENSITIVE, true, dbSystem))
{
return( false);
}
if (!compareStrTest( "ABC", false, "abc", false, 0, false, dbSystem))
{
return( false);
}
if (!compareStrTest( "ab cd", false, "ab cd", false, CompareFlags.FLM_COMP_COMPRESS_WHITESPACE, true, dbSystem))
{
return( false);
}
if (!compareStrTest( " ab cd", false, "ab cd", false, CompareFlags.FLM_COMP_COMPRESS_WHITESPACE, false, dbSystem))
{
return( false);
}
if (!compareStrTest( " ab cd", false, "ab cd", false,
CompareFlags.FLM_COMP_COMPRESS_WHITESPACE | CompareFlags.FLM_COMP_IGNORE_LEADING_SPACE,
true, dbSystem))
{
return( false);
}
if (!compareStrTest( " ab cd", false, " ab cd", false,
CompareFlags.FLM_COMP_COMPRESS_WHITESPACE | CompareFlags.FLM_COMP_IGNORE_LEADING_SPACE,
true, dbSystem))
{
return( false);
}
if (!compareStrTest( " ab cd ", false, " ab cd", false,
CompareFlags.FLM_COMP_COMPRESS_WHITESPACE | CompareFlags.FLM_COMP_IGNORE_LEADING_SPACE,
false, dbSystem))
{
return( false);
}
if (!compareStrTest( " ab cd ", false, " ab cd", false,
CompareFlags.FLM_COMP_COMPRESS_WHITESPACE |
CompareFlags.FLM_COMP_IGNORE_LEADING_SPACE |
CompareFlags.FLM_COMP_IGNORE_TRAILING_SPACE,
true, dbSystem))
{
return( false);
}
if (!compareStrTest( " ab cd ", false, " ab cd ", false,
CompareFlags.FLM_COMP_COMPRESS_WHITESPACE |
CompareFlags.FLM_COMP_IGNORE_LEADING_SPACE |
CompareFlags.FLM_COMP_IGNORE_TRAILING_SPACE,
true, dbSystem))
{
return( false);
}
if (!compareStrTest( "801-224-8888", false, "8012248888", false,
CompareFlags.FLM_COMP_NO_DASHES,
true, dbSystem))
{
return( false);
}
if (!compareStrTest( "801_224_8888", false, "801 224 8888", false,
CompareFlags.FLM_COMP_NO_UNDERSCORES,
true, dbSystem))
{
return( false);
}
if (!compareStrTest( "801_224_8888", false, "801 224 8888", false,
CompareFlags.FLM_COMP_NO_UNDERSCORES | CompareFlags.FLM_COMP_COMPRESS_WHITESPACE,
true, dbSystem))
{
return( false);
}
return( true);
}
}
}

View File

@@ -59,7 +59,7 @@ namespace cstest
createOpts.uiMaxRflFileSize = 20000000;
createOpts.bKeepRflFiles = 1;
createOpts.bLogAbortedTransToRfl = 1;
createOpts.uiDefaultLanguage = (uint)Languages.FLM_DE_LANG;
createOpts.eDefaultLanguage = Languages.FLM_DE_LANG;
db = dbSystem.dbCreate( sDbName, null, null, null, null, createOpts);
}
catch (XFlaimException ex)

View File

@@ -94,7 +94,7 @@ namespace cstest
createOpts.uiMaxRflFileSize = 20000000;
createOpts.bKeepRflFiles = 1;
createOpts.bLogAbortedTransToRfl = 1;
createOpts.uiDefaultLanguage = (uint)Languages.FLM_DE_LANG;
createOpts.eDefaultLanguage = Languages.FLM_DE_LANG;
try
{
dbSystem.dbRebuild( sSrcDbName, null, sDestDbName, null, null,

View File

@@ -0,0 +1,386 @@
//------------------------------------------------------------------------------
// Desc: Settings tests
//
// Tabs: 3
//
// Copyright (c) 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$
//------------------------------------------------------------------------------
using System;
using System.IO;
using System.Runtime.InteropServices;
using xflaim;
namespace cstest
{
//--------------------------------------------------------------------------
// Settings tests.
//--------------------------------------------------------------------------
public class SettingsTests : Tester
{
private bool setTempDirTest(
DbSystem dbSystem)
{
string sSetDir = "abc/def/efg";
string sGetDir;
System.IO.Directory.CreateDirectory( sSetDir);
beginTest( "Set Temporary Directory");
try
{
dbSystem.setTempDir( sSetDir);
}
catch (XFlaimException ex)
{
endTest( false, ex, "calling setTempDir");
return( false);
}
try
{
sGetDir = dbSystem.getTempDir();
}
catch (XFlaimException ex)
{
endTest( false, ex, "calling getTempDir");
return( false);
}
if (sSetDir != sGetDir)
{
endTest( false, false);
System.Console.WriteLine( "GetDir != SetDir");
System.Console.WriteLine( "GetDir = [{0}], setDir = [{1}]", sGetDir, sSetDir);
}
endTest( false, true);
return( true);
}
private bool setCheckpointIntervalTest(
DbSystem dbSystem)
{
uint uiSetValue = 130;
uint uiGetValue;
beginTest( "Set Checkpoint Interval");
try
{
dbSystem.setCheckpointInterval( uiSetValue);
}
catch (XFlaimException ex)
{
endTest( false, ex, "calling setCheckpointInterval");
return( false);
}
try
{
uiGetValue = dbSystem.getCheckpointInterval();
}
catch (XFlaimException ex)
{
endTest( false, ex, "calling getCheckpointInterval");
return( false);
}
if (uiSetValue != uiGetValue)
{
endTest( false, false);
System.Console.WriteLine( "GetValue [{0}] != SetValue [{1}]",
uiGetValue, uiSetValue);
}
endTest( false, true);
return( true);
}
private bool setCacheAdjustIntervalTest(
DbSystem dbSystem)
{
uint uiSetValue = 37;
uint uiGetValue;
beginTest( "Set Cache Adjust Interval");
try
{
dbSystem.setCacheAdjustInterval( uiSetValue);
}
catch (XFlaimException ex)
{
endTest( false, ex, "calling setCacheAdjustInterval");
return( false);
}
try
{
uiGetValue = dbSystem.getCacheAdjustInterval();
}
catch (XFlaimException ex)
{
endTest( false, ex, "calling getCacheAdjustInterval");
return( false);
}
if (uiSetValue != uiGetValue)
{
endTest( false, false);
System.Console.WriteLine( "GetValue [{0}] != SetValue [{1}]",
uiGetValue, uiSetValue);
}
endTest( false, true);
return( true);
}
private bool setCacheCleanupIntervalTest(
DbSystem dbSystem)
{
uint uiSetValue = 33;
uint uiGetValue;
beginTest( "Set Cache Cleanup Interval");
try
{
dbSystem.setCacheCleanupInterval( uiSetValue);
}
catch (XFlaimException ex)
{
endTest( false, ex, "calling setCacheCleanupInterval");
return( false);
}
try
{
uiGetValue = dbSystem.getCacheCleanupInterval();
}
catch (XFlaimException ex)
{
endTest( false, ex, "calling getCacheCleanupInterval");
return( false);
}
if (uiSetValue != uiGetValue)
{
endTest( false, false);
System.Console.WriteLine( "GetValue [{0}] != SetValue [{1}]",
uiGetValue, uiSetValue);
}
endTest( false, true);
return( true);
}
private bool setUnusedCleanupIntervalTest(
DbSystem dbSystem)
{
uint uiSetValue = 31;
uint uiGetValue;
beginTest( "Set Unused Cleanup Interval");
try
{
dbSystem.setUnusedCleanupInterval( uiSetValue);
}
catch (XFlaimException ex)
{
endTest( false, ex, "calling setUnusedCleanupInterval");
return( false);
}
try
{
uiGetValue = dbSystem.getUnusedCleanupInterval();
}
catch (XFlaimException ex)
{
endTest( false, ex, "calling getUnusedCleanupInterval");
return( false);
}
if (uiSetValue != uiGetValue)
{
endTest( false, false);
System.Console.WriteLine( "GetValue [{0}] != SetValue [{1}]",
uiGetValue, uiSetValue);
}
endTest( false, true);
return( true);
}
private bool setMaxUnusedTimeTest(
DbSystem dbSystem)
{
uint uiSetValue = 117;
uint uiGetValue;
beginTest( "Set Max Unused Time");
try
{
dbSystem.setMaxUnusedTime( uiSetValue);
}
catch (XFlaimException ex)
{
endTest( false, ex, "calling setMaxUnusedTime");
return( false);
}
try
{
uiGetValue = dbSystem.getMaxUnusedTime();
}
catch (XFlaimException ex)
{
endTest( false, ex, "calling getMaxUnusedTime");
return( false);
}
if (uiSetValue != uiGetValue)
{
endTest( false, false);
System.Console.WriteLine( "GetValue [{0}] != SetValue [{1}]",
uiGetValue, uiSetValue);
}
endTest( false, true);
return( true);
}
private bool setQuerySaveMaxTest(
DbSystem dbSystem)
{
uint uiSetValue = 117;
uint uiGetValue;
beginTest( "Set Query Save Max");
try
{
dbSystem.setQuerySaveMax( uiSetValue);
}
catch (XFlaimException ex)
{
endTest( false, ex, "calling setQuerySaveMax");
return( false);
}
try
{
uiGetValue = dbSystem.getQuerySaveMax();
}
catch (XFlaimException ex)
{
endTest( false, ex, "calling getQuerySaveMax");
return( false);
}
if (uiSetValue != uiGetValue)
{
endTest( false, false);
System.Console.WriteLine( "GetValue [{0}] != SetValue [{1}]",
uiGetValue, uiSetValue);
}
endTest( false, true);
return( true);
}
private bool setDirtyCacheLimitsTest(
DbSystem dbSystem)
{
ulong ulSetMaxDirty = 117000000;
ulong ulGetMaxDirty;
ulong ulSetLowDirty = 37000000;
ulong ulGetLowDirty;
beginTest( "Set Dirty Cache Limits");
try
{
dbSystem.setDirtyCacheLimits( ulSetMaxDirty, ulSetLowDirty);
}
catch (XFlaimException ex)
{
endTest( false, ex, "calling setDirtyCacheLimits");
return( false);
}
try
{
dbSystem.getDirtyCacheLimits( out ulGetMaxDirty, out ulGetLowDirty);
}
catch (XFlaimException ex)
{
endTest( false, ex, "calling getDirtyCacheLimits");
return( false);
}
if (ulSetMaxDirty != ulGetMaxDirty || ulSetLowDirty != ulGetLowDirty)
{
endTest( false, false);
if (ulSetMaxDirty != ulGetMaxDirty)
{
System.Console.WriteLine( "GetMaxDirty [{0}] != SetMaxDirty [{1}]",
ulGetMaxDirty, ulSetMaxDirty);
}
if (ulSetLowDirty != ulGetLowDirty)
{
System.Console.WriteLine( "GetLowDirty [{0}] != SetLowDirty [{1}]",
ulGetLowDirty, ulSetLowDirty);
}
}
endTest( false, true);
return( true);
}
public bool settingsTests(
DbSystem dbSystem)
{
if (!setTempDirTest( dbSystem))
{
return( false);
}
if (!setCheckpointIntervalTest( dbSystem))
{
return( false);
}
if (!setCacheAdjustIntervalTest( dbSystem))
{
return( false);
}
if (!setCacheCleanupIntervalTest( dbSystem))
{
return( false);
}
if (!setUnusedCleanupIntervalTest( dbSystem))
{
return( false);
}
if (!setMaxUnusedTimeTest( dbSystem))
{
return( false);
}
if (!setQuerySaveMaxTest( dbSystem))
{
return( false);
}
if (!setDirtyCacheLimitsTest( dbSystem))
{
return( false);
}
return( true);
}
}
}

View File

@@ -38,7 +38,7 @@ namespace cstest
public void beginTest(
string sTestName)
{
System.Console.Write( "{0} ...", sTestName);
System.Console.Write( "{0} ... ", sTestName);
}
//--------------------------------------------------------------------------
@@ -161,6 +161,7 @@ namespace cstest
DbSystem dbSystem = new DbSystem();
#if false
// Database create test
CreateDbTest createDb = new CreateDbTest();
@@ -300,6 +301,24 @@ namespace cstest
{
return;
}
#endif
// Various settings tests
SettingsTests settingsTests = new SettingsTests();
if (!settingsTests.settingsTests( dbSystem))
{
return;
}
// Various string comparison tests
CompareStringTests compareStringTests = new CompareStringTests();
if (!compareStringTests.compareStringTests( dbSystem))
{
return;
}
}
}
}

View File

@@ -1673,3 +1673,254 @@ Exit:
*pui64Stats = (FLMUINT64)((FLMUINT)pStats);
return( rc);
}
/****************************************************************************
Desc:
****************************************************************************/
FLMEXTC FLMEXP RCODE FLMAPI xflaim_DbSystem_setTempDir(
FLMUINT64 ui64This,
const char * pszTempDir)
{
IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This);
return( pDbSystem->setTempDir( pszTempDir));
}
/****************************************************************************
Desc:
****************************************************************************/
FLMEXTC FLMEXP RCODE FLMAPI xflaim_DbSystem_getTempDir(
FLMUINT64 ui64This,
char ** ppszTempDir)
{
RCODE rc = NE_XFLM_OK;
IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This);
char szPath [F_PATH_MAX_SIZE];
FLMUINT uiLen;
if (RC_BAD( rc = pDbSystem->getTempDir( szPath)))
{
goto Exit;
}
uiLen = f_strlen( szPath) + 1;
if (RC_BAD( rc = f_alloc( uiLen, ppszTempDir)))
{
goto Exit;
}
f_memcpy( *ppszTempDir, szPath, uiLen);
Exit:
return( rc);
}
/****************************************************************************
Desc:
****************************************************************************/
FLMEXTC FLMEXP void FLMAPI xflaim_DbSystem_setCheckpointInterval(
FLMUINT64 ui64This,
FLMUINT32 ui32Seconds)
{
IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This);
pDbSystem->setCheckpointInterval( (FLMUINT)ui32Seconds);
}
/****************************************************************************
Desc:
****************************************************************************/
FLMEXTC FLMEXP FLMUINT32 FLMAPI xflaim_DbSystem_getCheckpointInterval(
FLMUINT64 ui64This)
{
IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This);
return( (FLMUINT32)pDbSystem->getCheckpointInterval());
}
/****************************************************************************
Desc:
****************************************************************************/
FLMEXTC FLMEXP void FLMAPI xflaim_DbSystem_setCacheAdjustInterval(
FLMUINT64 ui64This,
FLMUINT32 ui32Seconds)
{
IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This);
pDbSystem->setCacheAdjustInterval( (FLMUINT)ui32Seconds);
}
/****************************************************************************
Desc:
****************************************************************************/
FLMEXTC FLMEXP FLMUINT32 FLMAPI xflaim_DbSystem_getCacheAdjustInterval(
FLMUINT64 ui64This)
{
IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This);
return( (FLMUINT32)pDbSystem->getCacheAdjustInterval());
}
/****************************************************************************
Desc:
****************************************************************************/
FLMEXTC FLMEXP void FLMAPI xflaim_DbSystem_setCacheCleanupInterval(
FLMUINT64 ui64This,
FLMUINT32 ui32Seconds)
{
IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This);
pDbSystem->setCacheCleanupInterval( (FLMUINT)ui32Seconds);
}
/****************************************************************************
Desc:
****************************************************************************/
FLMEXTC FLMEXP FLMUINT32 FLMAPI xflaim_DbSystem_getCacheCleanupInterval(
FLMUINT64 ui64This)
{
IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This);
return( (FLMUINT32)pDbSystem->getCacheCleanupInterval());
}
/****************************************************************************
Desc:
****************************************************************************/
FLMEXTC FLMEXP void FLMAPI xflaim_DbSystem_setUnusedCleanupInterval(
FLMUINT64 ui64This,
FLMUINT32 ui32Seconds)
{
IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This);
pDbSystem->setUnusedCleanupInterval( (FLMUINT)ui32Seconds);
}
/****************************************************************************
Desc:
****************************************************************************/
FLMEXTC FLMEXP FLMUINT32 FLMAPI xflaim_DbSystem_getUnusedCleanupInterval(
FLMUINT64 ui64This)
{
IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This);
return( (FLMUINT32)pDbSystem->getUnusedCleanupInterval());
}
/****************************************************************************
Desc:
****************************************************************************/
FLMEXTC FLMEXP void FLMAPI xflaim_DbSystem_setMaxUnusedTime(
FLMUINT64 ui64This,
FLMUINT32 ui32Seconds)
{
IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This);
pDbSystem->setMaxUnusedTime( (FLMUINT)ui32Seconds);
}
/****************************************************************************
Desc:
****************************************************************************/
FLMEXTC FLMEXP FLMUINT32 FLMAPI xflaim_DbSystem_getMaxUnusedTime(
FLMUINT64 ui64This)
{
IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This);
return( (FLMUINT32)pDbSystem->getMaxUnusedTime());
}
/****************************************************************************
Desc:
****************************************************************************/
FLMEXTC FLMEXP void FLMAPI xflaim_DbSystem_deactivateOpenDb(
FLMUINT64 ui64This,
const char * pszDbFileName,
const char * pszDataDir)
{
IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This);
pDbSystem->deactivateOpenDb( pszDbFileName, pszDataDir);
}
/****************************************************************************
Desc:
****************************************************************************/
FLMEXTC FLMEXP void FLMAPI xflaim_DbSystem_setQuerySaveMax(
FLMUINT64 ui64This,
FLMUINT32 ui32MaxToSave)
{
IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This);
pDbSystem->setQuerySaveMax( (FLMUINT)ui32MaxToSave);
}
/****************************************************************************
Desc:
****************************************************************************/
FLMEXTC FLMEXP FLMUINT32 FLMAPI xflaim_DbSystem_getQuerySaveMax(
FLMUINT64 ui64This)
{
IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This);
return( (FLMUINT32)pDbSystem->getQuerySaveMax());
}
/****************************************************************************
Desc:
****************************************************************************/
FLMEXTC FLMEXP void FLMAPI xflaim_DbSystem_setDirtyCacheLimits(
FLMUINT64 ui64This,
FLMUINT64 ui64MaxDirty,
FLMUINT64 ui64LowDirty)
{
IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This);
pDbSystem->setDirtyCacheLimits( (FLMUINT)ui64MaxDirty, (FLMUINT)ui64LowDirty);
}
/****************************************************************************
Desc:
****************************************************************************/
FLMEXTC FLMEXP void FLMAPI xflaim_DbSystem_getDirtyCacheLimits(
FLMUINT64 ui64This,
FLMUINT64 * pui64MaxDirty,
FLMUINT64 * pui64LowDirty)
{
IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This);
FLMUINT uiMaxDirty;
FLMUINT uiLowDirty;
pDbSystem->getDirtyCacheLimits( &uiMaxDirty, &uiLowDirty);
*pui64MaxDirty = (FLMUINT64)uiMaxDirty;
*pui64LowDirty = (FLMUINT64)uiLowDirty;
}
/****************************************************************************
Desc:
****************************************************************************/
FLMEXTC FLMEXP RCODE FLMAPI xflaim_DbSystem_compareStrings(
FLMUINT64 ui64This,
const FLMUNICODE * puzLeftString,
FLMBOOL bLeftWild,
const FLMUNICODE * puzRightString,
FLMBOOL bRightWild,
FLMUINT32 ui32CompareRules,
FLMUINT32 ui32Language,
FLMINT32 * pi32Result)
{
RCODE rc = NE_XFLM_OK;
IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This);
FLMINT iResult;
if (RC_BAD( rc = pDbSystem->compareUnicodeStrings(
puzLeftString, f_unilen( puzLeftString) * 2, bLeftWild,
puzRightString, f_unilen( puzRightString) * 2, bRightWild,
(FLMUINT)ui32CompareRules, (FLMUINT)ui32Language,
&iResult)))
{
goto Exit;
}
*pi32Result = (FLMINT32)iResult;
Exit:
return( rc);
}

View File

@@ -41,9 +41,11 @@ namespace xflaim
}
/// <summary>
/// Valid languages
/// Valid languages.
/// IMPORTANT NOTE: These need to be kept in sync with the definitions
/// in ftk.h.
/// </summary>
public enum Languages : int
public enum Languages : uint
{
/// <summary>English, United States</summary>
FLM_US_LANG = 0,
@@ -183,7 +185,7 @@ namespace xflaim
/// <summary>
/// Default language for the database. Should be one of <see cref="Languages"/>
/// </summary>
public uint uiDefaultLanguage;
public Languages eDefaultLanguage;
}
/// <remarks>
@@ -2150,5 +2152,495 @@ namespace xflaim
ulong pDbSystem,
out ulong ppDbSystemStats);
//-----------------------------------------------------------------------------
// setTempDir
//-----------------------------------------------------------------------------
/// <summary>
/// Set the directory where temporary files are to be created.
/// </summary>
/// <param name="sTempDir">
/// Name of temporary directory.
/// </param>
public void setTempDir(
string sTempDir)
{
RCODE rc;
if ((rc = xflaim_DbSystem_setTempDir( m_pDbSystem, sTempDir)) != 0)
{
throw new XFlaimException( rc);
}
}
[DllImport("xflaim")]
private static extern RCODE xflaim_DbSystem_setTempDir(
ulong pDbSystem,
[MarshalAs(UnmanagedType.LPStr), In]
string sTempDir);
//-----------------------------------------------------------------------------
// getTempDir
//-----------------------------------------------------------------------------
/// <summary>
/// Get the directory where temporary files are to be created.
/// </summary>
/// <returns>
/// Name of temporary directory.
/// </returns>
public string getTempDir()
{
RCODE rc;
IntPtr pszTempDir;
string sTempDir;
if ((rc = xflaim_DbSystem_getTempDir( m_pDbSystem, out pszTempDir)) != 0)
{
throw new XFlaimException( rc);
}
sTempDir = Marshal.PtrToStringAnsi( pszTempDir);
freeUnmanagedMem( pszTempDir);
return( sTempDir);
}
[DllImport("xflaim")]
private static extern RCODE xflaim_DbSystem_getTempDir(
ulong pDbSystem,
out IntPtr psTempDir);
//-----------------------------------------------------------------------------
// setCheckpointInterval
//-----------------------------------------------------------------------------
/// <summary>
/// Set the checkpoint interval. The checkpoint interval is the maximum number
/// of seconds that XFLAIM will allow to go by before a checkpoint is forced.
/// Note that XFLAIM attempt to complete a checkpoint as often as possible.
/// However, if many update transctions are being performed one after the other
/// with no break, it is possible that XFLAIM will not be able to complete
/// a checkpoint. If the checkpoint interval is exceeded without a checkpoint
/// being done, XFLAIM will hold off updaters until a checkpoint can be
/// completed. This is what is known as a "forced" checkpoint.
/// </summary>
/// <param name="uiSeconds">
/// Checkpoint interval, in seconds.
/// </param>
public void setCheckpointInterval(
uint uiSeconds)
{
xflaim_DbSystem_setCheckpointInterval( m_pDbSystem, uiSeconds);
}
[DllImport("xflaim")]
private static extern void xflaim_DbSystem_setCheckpointInterval(
ulong pDbSystem,
uint uiSeconds);
//-----------------------------------------------------------------------------
// getCheckpointInterval
//-----------------------------------------------------------------------------
/// <summary>
/// Get the current checkpoint interval.
/// </summary>
/// <returns>
/// Returns current checkpoint interval, in seconds.
/// </returns>
public uint getCheckpointInterval()
{
return( xflaim_DbSystem_getCheckpointInterval( m_pDbSystem));
}
[DllImport("xflaim")]
private static extern uint xflaim_DbSystem_getCheckpointInterval(
ulong pDbSystem);
//-----------------------------------------------------------------------------
// setCacheAdjustInterval
//-----------------------------------------------------------------------------
/// <summary>
/// Set the cache adjust interval. The cache adjust interval is only used
/// when the application has set a dynamic cache limit (see the
/// setDynamicCacheLimit API). It specifies how often XFLAIM should calculate
/// a new cache limit.
/// </summary>
/// <param name="uiSeconds">
/// Specifies the number of seconds between times when XFLAIM
/// recalculates a new cache limit.
/// </param>
public void setCacheAdjustInterval(
uint uiSeconds)
{
xflaim_DbSystem_setCacheAdjustInterval( m_pDbSystem, uiSeconds);
}
[DllImport("xflaim")]
private static extern void xflaim_DbSystem_setCacheAdjustInterval(
ulong pDbSystem,
uint uiSeconds);
//-----------------------------------------------------------------------------
// getCacheAdjustInterval
//-----------------------------------------------------------------------------
/// <summary>
/// Get the current cache adjust interval.
/// </summary>
/// <returns>
/// Returns the current cache adjust interval, in seconds.
/// </returns>
public uint getCacheAdjustInterval()
{
return( xflaim_DbSystem_getCacheAdjustInterval( m_pDbSystem));
}
[DllImport("xflaim")]
private static extern uint xflaim_DbSystem_getCacheAdjustInterval(
ulong pDbSystem);
//-----------------------------------------------------------------------------
// setCacheCleanupInterval
//-----------------------------------------------------------------------------
/// <summary>
/// Set the current cache cleanup interval. XFLAIM has a background thread
/// that periodically wakes up and removes "old" objects from cache. Old
/// objects are objects that are prior versions of current objects. During
/// a cleanup cycle, XFLAIM determines which of these objects are never going
/// to be needed again and removes them from cache.
/// </summary>
/// <param name="uiSeconds">
/// Specifies the number of seconds between times when XFLAIM
/// cleans up "old" objects in cache.
/// </param>
public void setCacheCleanupInterval(
uint uiSeconds)
{
xflaim_DbSystem_setCacheCleanupInterval( m_pDbSystem, uiSeconds);
}
[DllImport("xflaim")]
private static extern void xflaim_DbSystem_setCacheCleanupInterval(
ulong pDbSystem,
uint uiSeconds);
//-----------------------------------------------------------------------------
// getCacheCleanupInterval
//-----------------------------------------------------------------------------
/// <summary>
/// Get the current cache cleanup interval.
/// </summary>
/// <returns>
/// Returns the current cache cleanup interval, in seconds.
/// </returns>
public uint getCacheCleanupInterval()
{
return( xflaim_DbSystem_getCacheCleanupInterval( m_pDbSystem));
}
[DllImport("xflaim")]
private static extern uint xflaim_DbSystem_getCacheCleanupInterval(
ulong pDbSystem);
//-----------------------------------------------------------------------------
// setUnusedCleanupInterval
//-----------------------------------------------------------------------------
/// <summary>
/// Set the current unused cleanup interval. XFLAIM has a background thread
/// that periodically wakes up and removes objects that have not been in use
/// for a certain amount of time (as specified by the setMaxUnusedTime method).
/// This includes file descriptors and other in-memory objects that XFLAIM
/// may have been holding on to in case they are reused. It does NOT include
/// blocks in block cache or nodes in node cache.
/// </summary>
/// <param name="uiSeconds">
/// Specifies the number of seconds between times when XFLAIM
/// cleans up "unused" objects in cache.
/// </param>
public void setUnusedCleanupInterval(
uint uiSeconds)
{
xflaim_DbSystem_setUnusedCleanupInterval( m_pDbSystem, uiSeconds);
}
[DllImport("xflaim")]
private static extern void xflaim_DbSystem_setUnusedCleanupInterval(
ulong pDbSystem,
uint uiSeconds);
//-----------------------------------------------------------------------------
// getUnusedCleanupInterval
//-----------------------------------------------------------------------------
/// <summary>
/// Get the current unused cleanup interval.
/// </summary>
/// <returns>
/// Returns the current unused cleanup interval, in seconds.
/// </returns>
public uint getUnusedCleanupInterval()
{
return( xflaim_DbSystem_getUnusedCleanupInterval( m_pDbSystem));
}
[DllImport("xflaim")]
private static extern uint xflaim_DbSystem_getUnusedCleanupInterval(
ulong pDbSystem);
//-----------------------------------------------------------------------------
// setMaxUnusedTime
//-----------------------------------------------------------------------------
/// <summary>
/// Set the maximum unused time limit. XFLAIM has a background thread
/// that periodically wakes up and removes objects that have not been in
/// for a certain amount of time. This includes file descriptors and
/// other in-memory objects that XFLAIM may have been holding on to in case
/// they are reused. This method allows an application to specify a timeout
/// value that determines the maximum time an object may be "unused" before
/// it is cleaned up.
/// </summary>
/// <param name="uiSeconds">
/// Specifies the time limit (in seconds) for objects to be
/// "unused" before they are cleaned up.
/// </param>
public void setMaxUnusedTime(
uint uiSeconds)
{
xflaim_DbSystem_setMaxUnusedTime( m_pDbSystem, uiSeconds);
}
[DllImport("xflaim")]
private static extern void xflaim_DbSystem_setMaxUnusedTime(
ulong pDbSystem,
uint uiSeconds);
//-----------------------------------------------------------------------------
// getMaxUnusedTime
//-----------------------------------------------------------------------------
/// <summary>
/// Get the maximum unused time limit.
/// </summary>
/// <returns>
/// Returns the maximum unused time limit, in seconds.
/// </returns>
public uint getMaxUnusedTime()
{
return( xflaim_DbSystem_getMaxUnusedTime( m_pDbSystem));
}
[DllImport("xflaim")]
private static extern uint xflaim_DbSystem_getMaxUnusedTime(
ulong pDbSystem);
//-----------------------------------------------------------------------------
// deactivateOpenDb
//-----------------------------------------------------------------------------
/// <summary>
/// Deactivate an open database. This method allows an application to force
/// a particular database to be closed by all threads.
/// </summary>
/// <param name="sDbFileName">
/// The name of the control file of the database to.
/// deactivate. For more explanation see documentation for
/// <see cref="dbCreate"/>.
/// </param>
/// <param name="sDataDir">
/// The data file directory. See <see cref="dbCreate"/> for more information.
/// </param>
public void deactivateOpenDb(
string sDbFileName,
string sDataDir)
{
xflaim_DbSystem_deactivateOpenDb( m_pDbSystem, sDbFileName, sDataDir);
}
[DllImport("xflaim")]
private static extern void xflaim_DbSystem_deactivateOpenDb(
ulong pDbSystem,
[MarshalAs(UnmanagedType.LPStr), In]
string sDbFileName,
[MarshalAs(UnmanagedType.LPStr), In]
string sDataDir);
//-----------------------------------------------------------------------------
// setQuerySaveMax
//-----------------------------------------------------------------------------
/// <summary>
/// Set maximum number of queries to save statistics and information on. NOTE:
/// If the <see cref="startStats"/> method is called, the maximum is set to 20 until
/// <see cref="stopStats"/> is called - unless a non-zero value has already been set.
/// </summary>
/// <param name="uiMaxToSave">
/// The maximum number of queries to save information on. The
/// last N queries that were executed will be saved.
/// </param>
public void setQuerySaveMax(
uint uiMaxToSave)
{
xflaim_DbSystem_setQuerySaveMax( m_pDbSystem, uiMaxToSave);
}
[DllImport("xflaim")]
private static extern void xflaim_DbSystem_setQuerySaveMax(
ulong pDbSystem,
uint uiMaxToSave);
//-----------------------------------------------------------------------------
// getQuerySaveMax
//-----------------------------------------------------------------------------
/// <summary>
/// Get maximum number of queries to save statistics and information on.
/// </summary>
/// <returns>
/// Returns the maximum number of queries to save information on.
/// </returns>
public uint getQuerySaveMax()
{
return( xflaim_DbSystem_getQuerySaveMax( m_pDbSystem));
}
[DllImport("xflaim")]
private static extern uint xflaim_DbSystem_getQuerySaveMax(
ulong pDbSystem);
//-----------------------------------------------------------------------------
// setDirtyCacheLimits
//-----------------------------------------------------------------------------
/// <summary>
/// Set dirty cache limits.
/// </summary>
/// <param name="ulMaxDirty">
/// This is the maximum amount of cache (in bytes) that the system
/// should allow to be dirty. Once the maximum is exceeded, XFLAIM will
/// attempt to write out dirty blocks until the dirty cache is less than or
/// equal to the value specified by ulLowDirty.
/// </param>
/// <param name="ulLowDirty">
/// This number is the low threshhold for dirty cache. It is
/// a hysteresis value. Once dirty cache exceeds the value specified by
/// the ulMaxDirty parameter, XFLAIM will write out dirty blocks until the
/// dirty cache is once again less than or equal to this number.
/// </param>
public void setDirtyCacheLimits(
ulong ulMaxDirty,
ulong ulLowDirty)
{
xflaim_DbSystem_setDirtyCacheLimits( m_pDbSystem, ulMaxDirty, ulLowDirty);
}
[DllImport("xflaim")]
private static extern void xflaim_DbSystem_setDirtyCacheLimits(
ulong pDbSystem,
ulong ulMaxDirty,
ulong ulLowDirty);
//-----------------------------------------------------------------------------
// getDirtyCacheLimits
//-----------------------------------------------------------------------------
/// <summary>
/// Get dirty cache limits.
/// </summary>
/// <param name="ulMaxDirty">
/// Returns the maximum dirty cache limit.
/// </param>
/// <param name="ulLowDirty">
/// Returns the low dirty cache limit.
/// </param>
public void getDirtyCacheLimits(
out ulong ulMaxDirty,
out ulong ulLowDirty)
{
xflaim_DbSystem_getDirtyCacheLimits( m_pDbSystem, out ulMaxDirty, out ulLowDirty);
}
[DllImport("xflaim")]
private static extern void xflaim_DbSystem_getDirtyCacheLimits(
ulong pDbSystem,
out ulong pulMaxDirty,
out ulong pulLowDirty);
//-----------------------------------------------------------------------------
// compareStrings
//-----------------------------------------------------------------------------
/// <summary>
/// Compare two strings.
/// </summary>
/// <param name="sLeftString">
/// This is the string on the left side of the comparison operation.
/// </param>
/// <param name="bLeftWild">
/// This flag, if true, specifies that wildcard characters
/// found in sLeftString should be treated as wildcard characters instead of
/// literal characters to compare. If false, the wildcard character (*) is
/// treated like a normal character.
/// </param>
/// <param name="sRightString">
/// This is the string on the right side of the comparison operation.
/// </param>
/// <param name="bRightWild">
/// This flag, if true, specifies that wildcard characters
/// found in sRightString should be treated as wildcard characters instead of
/// literal characters to compare. If false, the wildcard character (*) is
/// treated like a normal character.
/// </param>
/// <param name="eCompareFlags">
/// Flags for doing string comparisons. Should be logical ORs of the members
/// of <see cref="CompareFlags"/>.
/// </param>
/// <param name="eLanguage">
/// Language to use for doing collation of strings.
/// </param>
/// <returns>
/// Returns a value indicating whether sLeftString is less than, equal to,
/// or greater than sRightString. A value of -1 means sLeftString &lt; sRightString.
/// A value of 0 means the strings are equal. A value of 1 means that
/// sLeftString &gt; sRightString.
/// </returns>
public int compareStrings(
string sLeftString,
bool bLeftWild,
string sRightString,
bool bRightWild,
CompareFlags eCompareFlags,
Languages eLanguage)
{
RCODE rc;
int iResult;
if ((rc = xflaim_DbSystem_compareStrings( m_pDbSystem,
sLeftString, (int)(bLeftWild ? 1 : 0),
sRightString, (int)(bRightWild ? 1 : 0),
eCompareFlags, eLanguage, out iResult)) != 0)
{
throw new XFlaimException( rc);
}
return( iResult);
}
[DllImport("xflaim")]
private static extern RCODE xflaim_DbSystem_compareStrings(
ulong pDbSystem,
[MarshalAs(UnmanagedType.LPWStr), In]
string sLeftString,
int bLeftWild,
[MarshalAs(UnmanagedType.LPWStr), In]
string sRightString,
int bRightWild,
CompareFlags eCompareRules,
Languages eLanguage,
out int piResult);
}
}

View File

@@ -0,0 +1,58 @@
//------------------------------------------------------------------------------
// Desc: Db Check Status
//
// Tabs: 3
//
// Copyright (c) 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$
//------------------------------------------------------------------------------
using System;
using System.Runtime.InteropServices;
namespace xflaim
{
/// <summary>
/// Flags for comparing strings.
/// IMPORTANT NOTE: This needs to be kept in sync with the definitions in ftk.h
/// </summary>
[Flags]
public enum CompareFlags : uint
{
/// <summary>Do case sensitive comparison.</summary>
FLM_COMP_CASE_INSENSITIVE = 0x0001,
/// <summary>Compare multiple whitespace characters as a single space.</summary>
FLM_COMP_COMPRESS_WHITESPACE = 0x0002,
/// <summary>Ignore all whitespace during comparison.</summary>
FLM_COMP_NO_WHITESPACE = 0x0004,
/// <summary>Ignore all underscore characters during comparison.</summary>
FLM_COMP_NO_UNDERSCORES = 0x0008,
/// <summary>Ignore all dash characters during comparison.</summary>
FLM_COMP_NO_DASHES = 0x0010,
/// <summary>Treat newlines and tabs as spaces during comparison.</summary>
FLM_COMP_WHITESPACE_AS_SPACE = 0x0020,
/// <summary>Ignore leading space characters during comparison.</summary>
FLM_COMP_IGNORE_LEADING_SPACE = 0x0040,
/// <summary>Ignore trailing space characters during comparison.</summary>
FLM_COMP_IGNORE_TRAILING_SPACE = 0x0080,
/// <summary>Compare wild cards</summary>
FLM_COMP_WILD = 0x0100
}
}

View File

@@ -3252,7 +3252,7 @@ JNIEXPORT jstring JNICALL Java_xflaim_DbSystem__1getTempDir(
char szPath [F_PATH_MAX_SIZE];
jstring jPath = NULL;
if (RC_BAD( rc = THIS_DBSYS()->setTempDir( szPath)))
if (RC_BAD( rc = THIS_DBSYS()->getTempDir( szPath)))
{
ThrowError( rc, pEnv);
goto Exit;