diff --git a/xflaim/Makefile b/xflaim/Makefile index 9111462..e57ff85 100644 --- a/xflaim/Makefile +++ b/xflaim/Makefile @@ -789,9 +789,9 @@ endif xflaim_jni_jar = $(java_output_dir)/xflaimjni.jar xflaim_jar_manifest = $(java_output_dir)/xflaimjni.mf -xflaim_csharp_assembly = $(csharp_output_dir)/$(lib_prefix)$(project_name)_csharp$(shared_lib_suffix) -xflaim_csharp_assembly_xml = $(csharp_output_dir)/$(lib_prefix)$(project_name)_csharp.xml -cstest_exe = $(cstest_output_dir)/cstest$(exe_suffix) +xflaim_csharp_assembly = $(csharp_output_dir)/xflaim_csharp.dll +xflaim_csharp_assembly_xml = $(csharp_output_dir)/xflaim_csharp.xml +cstest_exe = $(cstest_output_dir)/cstest.exe util_dir = $(target_path)/util test_dir = $(target_path)/test @@ -823,6 +823,12 @@ ccflags = clrflags = noclrflags = cs_flags = /nologo /warn:4 /warnaserror+ +ifeq ($(target_build_type),debug) + cs_flags += /debug+ /debug:full /define:FLM_DEBUG +else + cs_flags += /optimized+ +endif + ccdefs = ifeq ($(target_word_size),64) @@ -855,10 +861,8 @@ ifdef win_target ccflags += /Ob1 /Od /Wp64 noclrflags += /RTC1 ccdefs += FLM_DEBUG - cs_flags += /debug+ /debug:full /define:FLM_DEBUG else ccflags += /O2 - cs_flags += /optimized+ endif # Linker switches @@ -996,6 +1000,7 @@ ifdef unix_target endif ifeq ($(target_os_family),linux) + csharp_compiler := mcs # Must support 64 bit file sizes - even for 32 bit builds. diff --git a/xflaim/csharp/cstest/cstest.cs b/xflaim/csharp/cstest/cstest.cs index b68fe25..3c17db0 100644 --- a/xflaim/csharp/cstest/cstest.cs +++ b/xflaim/csharp/cstest/cstest.cs @@ -85,181 +85,182 @@ namespace cstest //-------------------------------------------------------------------------- // Create database test //-------------------------------------------------------------------------- - static bool createDbTest( - DbSystem dbSystem) - { - Db db = null; - RCODE rc; - - beginTest( "Create Database Test (" + CREATE_DB_NAME + ")"); - - for (;;) - { - rc = RCODE.NE_XFLM_OK; - try - { - CREATE_OPTS createOpts = new CREATE_OPTS(); - - createOpts.uiBlockSize = 8192; - createOpts.uiVersionNum = (uint)DBVersions.XFLM_CURRENT_VERSION_NUM; - createOpts.uiMinRflFileSize = 2000000; - createOpts.uiMaxRflFileSize = 20000000; - createOpts.bKeepRflFiles = 1; - createOpts.bLogAbortedTransToRfl = 1; - createOpts.uiDefaultLanguage = (uint)Languages.FLM_DE_LANG; - db = dbSystem.dbCreate( CREATE_DB_NAME, null, null, null, null, createOpts); - } - catch (XFlaimException ex) - { - rc = ex.getRCode(); - - if (rc != RCODE.NE_XFLM_FILE_EXISTS) - { - endTest( ex, "creating database"); - return( false); - } - } - if (rc == RCODE.NE_XFLM_OK) - { - break; - } - - // rc better be NE_XFLM_FILE_EXISTS - try to delete the file - - try - { - dbSystem.dbRemove( CREATE_DB_NAME, null, null, true); - } - catch (XFlaimException ex) - { - endTest( ex, "removing database"); - return( false); - } - } - if (db != null) - { - db.close(); - db = null; - } - endTest( true); - return( true); - } - + static bool createDbTest( + DbSystem dbSystem) + { + Db db = null; + RCODE rc; + + beginTest( "Create Database Test (" + CREATE_DB_NAME + ")"); + + for (;;) + { + rc = RCODE.NE_XFLM_OK; + try + { + CREATE_OPTS createOpts = new CREATE_OPTS(); + + createOpts.uiBlockSize = 8192; + createOpts.uiVersionNum = (uint)DBVersions.XFLM_CURRENT_VERSION_NUM; + createOpts.uiMinRflFileSize = 2000000; + createOpts.uiMaxRflFileSize = 20000000; + createOpts.bKeepRflFiles = 1; + createOpts.bLogAbortedTransToRfl = 1; + createOpts.uiDefaultLanguage = (uint)Languages.FLM_DE_LANG; + db = dbSystem.dbCreate( CREATE_DB_NAME, null, null, null, null, createOpts); + } + catch (XFlaimException ex) + { + rc = ex.getRCode(); + + if (rc != RCODE.NE_XFLM_FILE_EXISTS) + { + endTest( ex, "creating database"); + return( false); + } + } + if (rc == RCODE.NE_XFLM_OK) + { + break; + } + + // rc better be NE_XFLM_FILE_EXISTS - try to delete the file + + try + { + dbSystem.dbRemove( CREATE_DB_NAME, null, null, true); + } + catch (XFlaimException ex) + { + endTest( ex, "removing database"); + return( false); + } + } + if (db != null) + { + db.close(); + db = null; + } + endTest( true); + return( true); + } + //-------------------------------------------------------------------------- // Open database test. //-------------------------------------------------------------------------- - static bool openDbTest( - DbSystem dbSystem) - { - Db db = null; - - beginTest( "Open Database Test (" + CREATE_DB_NAME + ")"); - - try - { - db = dbSystem.dbOpen( CREATE_DB_NAME, null, null, null, false); - } - catch (XFlaimException ex) - { - endTest( ex, "opening database"); - return( false); - } - if (db != null) - { - db.close(); - db = null; - } - endTest( true); - return( true); - } - + static bool openDbTest( + DbSystem dbSystem) + { + Db db = null; + + beginTest( "Open Database Test (" + CREATE_DB_NAME + ")"); + + try + { + db = dbSystem.dbOpen( CREATE_DB_NAME, null, null, null, false); + } + catch (XFlaimException ex) + { + endTest( ex, "opening database"); + return( false); + } + if (db != null) + { + db.close(); + db = null; + } + endTest( true); + return( true); + } + //-------------------------------------------------------------------------- // Copy database test. //-------------------------------------------------------------------------- - static bool copyDbTest( - DbSystem dbSystem) - { - - // Try copying the database - - MyDbCopyStatus copyStatus = new MyDbCopyStatus(); - - beginTest( "Copy Database Test (" + CREATE_DB_NAME + " --> " + COPY_DB_NAME + ")"); - try - { - dbSystem.dbCopy( CREATE_DB_NAME, null, null, COPY_DB_NAME, null, null, copyStatus); - } - catch (XFlaimException ex) - { - endTest( ex, "copying database"); - return( false); - } - endTest( true); - return( true); - } - + static bool copyDbTest( + DbSystem dbSystem) + { + + // Try copying the database + + MyDbCopyStatus copyStatus = new MyDbCopyStatus(); + + beginTest( "Copy Database Test (" + CREATE_DB_NAME + " --> " + COPY_DB_NAME + ")"); + try + { + dbSystem.dbCopy( CREATE_DB_NAME, null, null, COPY_DB_NAME, null, null, copyStatus); + } + catch (XFlaimException ex) + { + endTest( ex, "copying database"); + return( false); + } + endTest( true); + return( true); + } + //-------------------------------------------------------------------------- // Remove database test. //-------------------------------------------------------------------------- - static bool removeDbTest( - DbSystem dbSystem, - string sDbName) - { - beginTest( "Remove Database Test (" + sDbName + ")"); - try - { - dbSystem.dbRemove( sDbName, null, null, true); - } - catch (XFlaimException ex) - { - endTest( ex, "removing database"); - return( false); - } - endTest( true); - return( true); - } - + static bool removeDbTest( + DbSystem dbSystem, + string sDbName) + { + beginTest( "Remove Database Test (" + sDbName + ")"); + try + { + dbSystem.dbRemove( sDbName, null, null, true); + } + catch (XFlaimException ex) + { + endTest( ex, "removing database"); + return( false); + } + endTest( true); + return( true); + } + //-------------------------------------------------------------------------- // Main for tester program //-------------------------------------------------------------------------- - static void Main() - { - DbSystem dbSystem = new DbSystem(); - - // Database create test - - if (!createDbTest( dbSystem)) - { - return; - } - - // Database open test - - if (!openDbTest( dbSystem)) - { - return; - } - - // Database copy test - - if (!copyDbTest( dbSystem)) - { - return; - } - - // Database remove test - - if (!removeDbTest( dbSystem, CREATE_DB_NAME)) - { - return; - } - if (!removeDbTest( dbSystem, COPY_DB_NAME)) - { - return; - } - } + static void Main() + { + DbSystem dbSystem = new DbSystem(); + + // Database create test + + if (!createDbTest( dbSystem)) + { + return; + } + + // Database open test + + if (!openDbTest( dbSystem)) + { + return; + } + + // Database copy test + + if (!copyDbTest( dbSystem)) + { + return; + } + + // Database remove test + + if (!removeDbTest( dbSystem, CREATE_DB_NAME)) + { + return; + } + if (!removeDbTest( dbSystem, COPY_DB_NAME)) + { + return; + } + } } + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public class MyDbCopyStatus : DbCopyStatus { public RCODE dbCopyStatus( @@ -277,3 +278,4 @@ namespace cstest } } } + diff --git a/xflaim/csharp/xflaim/Db.cpp b/xflaim/csharp/xflaim/Db.cpp index 5942a79..24ee973 100644 --- a/xflaim/csharp/xflaim/Db.cpp +++ b/xflaim/csharp/xflaim/Db.cpp @@ -25,8 +25,6 @@ #include "xflaim.h" -#pragma unmanaged - /**************************************************************************** Desc: ****************************************************************************/ diff --git a/xflaim/csharp/xflaim/Db.cs b/xflaim/csharp/xflaim/Db.cs index 6f52641..4660a47 100644 --- a/xflaim/csharp/xflaim/Db.cs +++ b/xflaim/csharp/xflaim/Db.cs @@ -28,24 +28,24 @@ using System.Runtime.InteropServices; namespace xflaim { - /// - /// The Db class provides a number of methods that allow C# - /// applications to access an XFLAIM database. A Db object - /// is obtained by calling or - /// - /// + /// + /// The Db class provides a number of methods that allow C# + /// applications to access an XFLAIM database. A Db object + /// is obtained by calling or + /// + /// public class Db { - /// - /// Db constructor. - /// - /// - /// Reference to an IF_Db object. - /// - /// - /// DbSystem object that this Db object is associated with. - /// + /// + /// Db constructor. + /// + /// + /// Reference to an IF_Db object. + /// + /// + /// DbSystem object that this Db object is associated with. + /// public Db( ulong cs_dbRef, DbSystem dbSystem) @@ -63,18 +63,27 @@ namespace xflaim } m_dbSystem = dbSystem; + + // Must call something inside of DbSystem. Otherwise, the + // m_dbSystem object gets a compiler warning on linux because + // it is not used anywhere. Other than that, there is really + // no need to make the following call. + if (m_dbSystem.getRef() == 0) + { + throw new XFlaimException( "Invalid DbSystem.getRef()"); + } } - /// - /// Destructor. - /// + /// + /// Destructor. + /// ~Db() { close(); } - /// - /// Close this database. + /// + /// Close this database. /// public void close() { @@ -93,12 +102,12 @@ namespace xflaim // PRIVATE METHODS THAT ARE IMPLEMENTED IN C AND C++ - [DllImport("xflaim")] - private static extern int xflaim_Db_Release( - ulong ui64This); - - /// - /// Reference to C++ IF_Db object. + [DllImport("xflaim")] + private static extern int xflaim_Db_Release( + ulong ui64This); + + /// + /// Reference to C++ IF_Db object. /// public ulong m_this; private DbSystem m_dbSystem; diff --git a/xflaim/csharp/xflaim/DbCopyStatus.cs b/xflaim/csharp/xflaim/DbCopyStatus.cs index 9788990..61644a3 100644 --- a/xflaim/csharp/xflaim/DbCopyStatus.cs +++ b/xflaim/csharp/xflaim/DbCopyStatus.cs @@ -29,35 +29,35 @@ using System.Runtime.InteropServices; namespace xflaim { - /// + /// /// This interface allows XFlaim to periodically pass information back to the /// client about the status of an ongoing database copy operation. The /// implementor may do anything it wants with the information, such as write - /// it to a log file or display it on the screen. + /// it to a log file or display it on the screen. /// public interface DbCopyStatus { - /// + /// /// The operation calls this method periodically to - /// inform the implementation object about the status of the copy operation. - /// - /// - /// The total number of bytes that the operation - /// will ultimately copy. - /// - /// - /// The number of bytes that the operation has - /// copied so far. - /// - /// - /// The name of the file that is currently being copied. This is only passed - /// when the source file name is changed. Otherwise, it will be null. - /// - /// - /// The name of the current destination file. This is only passed when the - /// destination file name is changed. Otherwise, it will be null. - /// + /// inform the implementation object about the status of the copy operation. + /// + /// + /// The total number of bytes that the operation + /// will ultimately copy. + /// + /// + /// The number of bytes that the operation has + /// copied so far. + /// + /// + /// The name of the file that is currently being copied. This is only passed + /// when the source file name is changed. Otherwise, it will be null. + /// + /// + /// The name of the current destination file. This is only passed when the + /// destination file name is changed. Otherwise, it will be null. + /// /// /// If the implementation object returns anything but RCODE.NE_XFLM_OK /// the operation will abort and throw an diff --git a/xflaim/csharp/xflaim/DbSystem.cpp b/xflaim/csharp/xflaim/DbSystem.cpp index 3bf0f02..1deebc9 100644 --- a/xflaim/csharp/xflaim/DbSystem.cpp +++ b/xflaim/csharp/xflaim/DbSystem.cpp @@ -145,7 +145,6 @@ typedef enum } eRestoreClientAction; typedef RCODE (FLMAPI * RESTORE_CLIENT)( - void * pvObj, eRestoreClientAction eAction, FLMUINT uiFileNum, FLMUINT uiBytesRequested, @@ -160,10 +159,8 @@ class CS_RestoreClient : public IF_RestoreClient public: CS_RestoreClient( - void * pvObj, RESTORE_CLIENT fnRestoreClient) { - m_pvObj = pvObj; m_fnRestoreClient = fnRestoreClient; } @@ -173,19 +170,19 @@ public: RCODE FLMAPI openBackupSet( void) { - return( m_fnRestoreClient( m_pvObj, RESTORE_OPEN_BACKUP_SET, 0, 0, NULL, NULL)); + return( m_fnRestoreClient( RESTORE_OPEN_BACKUP_SET, 0, 0, NULL, NULL)); } RCODE FLMAPI openRflFile( FLMUINT uiFileNum) { - return( m_fnRestoreClient( m_pvObj, RESTORE_OPEN_RFL_FILE, uiFileNum, 0, NULL, NULL)); + return( m_fnRestoreClient( RESTORE_OPEN_RFL_FILE, uiFileNum, 0, NULL, NULL)); } RCODE FLMAPI openIncFile( FLMUINT uiFileNum) { - return( m_fnRestoreClient( m_pvObj, RESTORE_OPEN_INC_FILE, uiFileNum, 0, NULL, NULL)); + return( m_fnRestoreClient( RESTORE_OPEN_INC_FILE, uiFileNum, 0, NULL, NULL)); } RCODE FLMAPI read( @@ -193,24 +190,23 @@ public: void * pvBuffer, FLMUINT * puiBytesRead) { - return( m_fnRestoreClient( m_pvObj, RESTORE_READ, 0, uiBytesRequested, + return( m_fnRestoreClient( RESTORE_READ, 0, uiBytesRequested, pvBuffer, puiBytesRead)); } RCODE FLMAPI close( void) { - return( m_fnRestoreClient( m_pvObj, RESTORE_CLOSE, 0, 0, NULL, NULL)); + return( m_fnRestoreClient( RESTORE_CLOSE, 0, 0, NULL, NULL)); } RCODE FLMAPI abortFile( void) { - return( m_fnRestoreClient( m_pvObj, RESTORE_ABORT_FILE, 0, 0, NULL, NULL)); + return( m_fnRestoreClient( RESTORE_ABORT_FILE, 0, 0, NULL, NULL)); } private: - void * m_pvObj; RESTORE_CLIENT m_fnRestoreClient; }; @@ -248,7 +244,6 @@ typedef enum } eRestoreStatusAction; typedef RCODE (FLMAPI * RESTORE_STATUS)( - void * pvObj, eRestoreStatusAction eAction, eRestoreAction * peRestoreAction, FLMUINT64 ui64TransId, @@ -268,10 +263,8 @@ class CS_RestoreStatus : public IF_RestoreStatus public: CS_RestoreStatus( - void * pvObj, RESTORE_STATUS fnRestoreStatus) { - m_pvObj = pvObj; m_fnRestoreStatus = fnRestoreStatus; } @@ -284,7 +277,7 @@ public: FLMUINT64 ui64BytesToDo, FLMUINT64 ui64BytesDone) { - return( m_fnRestoreStatus( m_pvObj, REPORT_PROGRESS, peAction, 0, + return( m_fnRestoreStatus( REPORT_PROGRESS, peAction, 0, ui64BytesToDo, ui64BytesDone, 0, 0, 0, 0, 0)); } @@ -293,7 +286,7 @@ public: eRestoreAction * peAction, RCODE rcErr) { - return( m_fnRestoreStatus( m_pvObj, REPORT_ERROR, peAction, 0, + return( m_fnRestoreStatus( REPORT_ERROR, peAction, 0, 0, 0, 0, (FLMUINT)rcErr, 0, 0, 0)); } @@ -302,7 +295,7 @@ public: eRestoreAction * peAction, FLMUINT uiFileNum) { - return( m_fnRestoreStatus( m_pvObj, REPORT_OPEN_RFL_FILE, peAction, 0, + return( m_fnRestoreStatus( REPORT_OPEN_RFL_FILE, peAction, 0, 0, 0, 0, uiFileNum, 0, 0, 0)); } @@ -312,7 +305,7 @@ public: FLMUINT uiFileNum, FLMUINT uiBytesRead) { - return( m_fnRestoreStatus( m_pvObj, REPORT_RFL_READ, peAction, 0, + return( m_fnRestoreStatus( REPORT_RFL_READ, peAction, 0, 0, 0, 0, uiFileNum, uiBytesRead, 0, 0)); } @@ -321,7 +314,7 @@ public: eRestoreAction * peAction, FLMUINT64 ui64TransId) { - return( m_fnRestoreStatus( m_pvObj, REPORT_BEGIN_TRANS, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_BEGIN_TRANS, peAction, ui64TransId, 0, 0, 0, 0, 0, 0, 0)); } @@ -330,7 +323,7 @@ public: eRestoreAction * peAction, FLMUINT64 ui64TransId) { - return( m_fnRestoreStatus( m_pvObj, REPORT_COMMIT_TRANS, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_COMMIT_TRANS, peAction, ui64TransId, 0, 0, 0, 0, 0, 0, 0)); } @@ -339,7 +332,7 @@ public: eRestoreAction * peAction, FLMUINT64 ui64TransId) { - return( m_fnRestoreStatus( m_pvObj, REPORT_ABORT_TRANS, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_ABORT_TRANS, peAction, ui64TransId, 0, 0, 0, 0, 0, 0, 0)); } @@ -352,7 +345,7 @@ public: FLMUINT uiEndBlkAddr, FLMUINT uiCount) { - return( m_fnRestoreStatus( m_pvObj, REPORT_BLOCK_CHAIN_FREE, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_BLOCK_CHAIN_FREE, peAction, ui64TransId, ui64MaintDocNum, 0, 0, uiStartBlkAddr, uiEndBlkAddr, uiCount, 0)); } @@ -362,7 +355,7 @@ public: FLMUINT64 ui64TransId, FLMUINT uiIndexNum) { - return( m_fnRestoreStatus( m_pvObj, REPORT_INDEX_SUSPEND, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_INDEX_SUSPEND, peAction, ui64TransId, 0, 0, 0, uiIndexNum, 0, 0, 0)); } @@ -372,7 +365,7 @@ public: FLMUINT64 ui64TransId, FLMUINT uiIndexNum) { - return( m_fnRestoreStatus( m_pvObj, REPORT_INDEX_RESUME, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_INDEX_RESUME, peAction, ui64TransId, 0, 0, 0, uiIndexNum, 0, 0, 0)); } @@ -382,7 +375,7 @@ public: FLMUINT64 ui64TransId, FLMUINT uiCount) { - return( m_fnRestoreStatus( m_pvObj, REPORT_REDUCE, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_REDUCE, peAction, ui64TransId, 0, 0, 0, uiCount, 0, 0, 0)); } @@ -393,7 +386,7 @@ public: FLMUINT uiOldDbVersion, FLMUINT uiNewDbVersion) { - return( m_fnRestoreStatus( m_pvObj, REPORT_UPGRADE, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_UPGRADE, peAction, ui64TransId, 0, 0, 0, uiOldDbVersion, uiNewDbVersion, 0, 0)); } @@ -402,7 +395,7 @@ public: eRestoreAction * peAction, FLMUINT64 ui64TransId) { - return( m_fnRestoreStatus( m_pvObj, REPORT_ENABLE_ENCRYPTION, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_ENABLE_ENCRYPTION, peAction, ui64TransId, 0, 0, 0, 0, 0, 0, 0)); } @@ -411,7 +404,7 @@ public: eRestoreAction * peAction, FLMUINT64 ui64TransId) { - return( m_fnRestoreStatus( m_pvObj, REPORT_WRAP_KEY, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_WRAP_KEY, peAction, ui64TransId, 0, 0, 0, 0, 0, 0, 0)); } @@ -420,7 +413,7 @@ public: eRestoreAction * peAction, FLMUINT64 ui64TransId) { - return( m_fnRestoreStatus( m_pvObj, REPORT_ROLL_OVER_DB_KEY, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_ROLL_OVER_DB_KEY, peAction, ui64TransId, 0, 0, 0, 0, 0, 0, 0)); } @@ -431,7 +424,7 @@ public: FLMUINT uiCollection, FLMUINT64 ui64DocumentId) { - return( m_fnRestoreStatus( m_pvObj, REPORT_DOCUMENT_DONE, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_DOCUMENT_DONE, peAction, ui64TransId, ui64DocumentId, 0, 0, uiCollection, 0, 0, 0)); } @@ -442,7 +435,7 @@ public: FLMUINT uiCollection, FLMUINT64 ui64NodeId) { - return( m_fnRestoreStatus( m_pvObj, REPORT_NODE_DELETE, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_NODE_DELETE, peAction, ui64TransId, ui64NodeId, 0, 0, uiCollection, 0, 0, 0)); } @@ -454,7 +447,7 @@ public: FLMUINT64 ui64ElementId, FLMUINT uiAttrNameId) { - return( m_fnRestoreStatus( m_pvObj, REPORT_ATTRIBUTE_DELETE, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_ATTRIBUTE_DELETE, peAction, ui64TransId, ui64ElementId, 0, 0, uiCollection, uiAttrNameId, 0, 0)); } @@ -466,7 +459,7 @@ public: FLMUINT64 ui64ParentNodeId, FLMUINT uiNameId) { - return( m_fnRestoreStatus( m_pvObj, REPORT_NODE_CHILDREN_DELETE, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_NODE_CHILDREN_DELETE, peAction, ui64TransId, ui64ParentNodeId, 0, 0, uiCollection, uiNameId, 0, 0)); } @@ -480,7 +473,7 @@ public: FLMUINT uiNameId, eNodeInsertLoc eLocation) { - return( m_fnRestoreStatus( m_pvObj, REPORT_NODE_CREATE, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_NODE_CREATE, peAction, ui64TransId, ui64RefNodeId, 0, 0, uiCollection, (FLMUINT)eNodeType, uiNameId, (FLMUINT)eLocation)); } @@ -493,7 +486,7 @@ public: FLMUINT64 ui64NewChildNodeId, FLMUINT64 ui64RefChildNodeId) { - return( m_fnRestoreStatus( m_pvObj, REPORT_INSERT_BEFORE, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_INSERT_BEFORE, peAction, ui64TransId, ui64ParentNodeId, ui64NewChildNodeId, ui64RefChildNodeId, uiCollection, 0, 0, 0)); } @@ -504,7 +497,7 @@ public: FLMUINT uiCollection, FLMUINT64 ui64NodeId) { - return( m_fnRestoreStatus( m_pvObj, REPORT_NODE_UPDATE, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_NODE_UPDATE, peAction, ui64TransId, ui64NodeId, 0, 0, uiCollection, 0, 0, 0)); } @@ -515,7 +508,7 @@ public: FLMUINT uiCollection, FLMUINT64 ui64NodeId) { - return( m_fnRestoreStatus( m_pvObj, REPORT_NODE_SET_VALUE, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_NODE_SET_VALUE, peAction, ui64TransId, ui64NodeId, 0, 0, uiCollection, 0, 0, 0)); } @@ -527,7 +520,7 @@ public: FLMUINT64 ui64ElementNodeId, FLMUINT uiAttrNameId) { - return( m_fnRestoreStatus( m_pvObj, REPORT_ATTRIBUTE_SET_VALUE, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_ATTRIBUTE_SET_VALUE, peAction, ui64TransId, ui64ElementNodeId, 0, 0, uiCollection, uiAttrNameId, 0, 0)); } @@ -540,7 +533,7 @@ public: FLMUINT uiFlags, FLMBOOL bAdd) { - return( m_fnRestoreStatus( m_pvObj, REPORT_NODE_FLAGS_UPDATE, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_NODE_FLAGS_UPDATE, peAction, ui64TransId, ui64NodeId, 0, 0, uiCollection, uiFlags, (FLMUINT)bAdd, 0)); } @@ -553,7 +546,7 @@ public: FLMUINT uiAttrNameId, FLMUINT uiPrefixId) { - return( m_fnRestoreStatus( m_pvObj, REPORT_NODE_SET_PREFIX_ID, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_NODE_SET_PREFIX_ID, peAction, ui64TransId, ui64NodeId, 0, 0, uiCollection, uiAttrNameId, uiPrefixId, 0)); } @@ -565,7 +558,7 @@ public: FLMUINT64 ui64NodeId, FLMUINT64 ui64MetaValue) { - return( m_fnRestoreStatus( m_pvObj, REPORT_NODE_SET_META_VALUE, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_NODE_SET_META_VALUE, peAction, ui64TransId, ui64NodeId, ui64MetaValue, 0, uiCollection, 0, 0, 0)); } @@ -576,7 +569,7 @@ public: FLMUINT uiCollection, FLMUINT64 ui64NextNodeId) { - return( m_fnRestoreStatus( m_pvObj, REPORT_SET_NEXT_NODE_ID, peAction, ui64TransId, + return( m_fnRestoreStatus( REPORT_SET_NEXT_NODE_ID, peAction, ui64TransId, ui64NextNodeId, 0, 0, uiCollection, 0, 0, 0)); } @@ -584,7 +577,6 @@ public: private: - void * m_pvObj; RESTORE_STATUS m_fnRestoreStatus; }; @@ -598,9 +590,7 @@ FLMEXTC FLMEXP RCODE FLMAPI xflaim_DbSystem_dbRestore( const char * pszRflDir, const char * pszBackupPath, const char * pszPassword, - void * pvRestoreClientObj, RESTORE_CLIENT fnRestoreClient, - void * pvRestoreStatusObj, RESTORE_STATUS fnRestoreStatus) { RCODE rc = NE_XFLM_OK; @@ -608,17 +598,17 @@ FLMEXTC FLMEXP RCODE FLMAPI xflaim_DbSystem_dbRestore( IF_RestoreClient * pRestoreClient = NULL; IF_RestoreStatus * pRestoreStatus = NULL; - if (pvRestoreClientObj) + if (fnRestoreClient) { - if ((pRestoreClient = f_new CS_RestoreClient( pvRestoreClientObj, fnRestoreClient)) == NULL) + if ((pRestoreClient = f_new CS_RestoreClient( fnRestoreClient)) == NULL) { rc = RC_SET( NE_XFLM_MEM); goto Exit; } } - if (pvRestoreStatusObj) + if (fnRestoreStatus) { - if ((pRestoreStatus = f_new CS_RestoreStatus( pvRestoreStatusObj, fnRestoreStatus)) == NULL) + if ((pRestoreStatus = f_new CS_RestoreStatus( fnRestoreStatus)) == NULL) { rc = RC_SET( NE_XFLM_MEM); goto Exit; @@ -646,7 +636,6 @@ Exit: } typedef RCODE (FLMAPI * DB_COPY_STATUS)( - void * pvObj, FLMUINT64 ui64BytesToCopy, FLMUINT64 ui64BytesCopied, FLMBOOL bNewSrcFile, @@ -661,10 +650,8 @@ class CS_DbCopyStatus : public IF_DbCopyStatus public: CS_DbCopyStatus( - void * pvObj, DB_COPY_STATUS fnCopyStatus) { - m_pvObj = pvObj; m_fnCopyStatus = fnCopyStatus; } @@ -679,13 +666,12 @@ public: const char * pszSrcFileName, const char * pszDestFileName) { - return( m_fnCopyStatus( m_pvObj, ui64BytesToCopy, ui64BytesCopied, - bNewSrcFile, pszSrcFileName, pszDestFileName)); + return( m_fnCopyStatus( ui64BytesToCopy, ui64BytesCopied, bNewSrcFile, + pszSrcFileName, pszDestFileName)); } private: - void * m_pvObj; DB_COPY_STATUS m_fnCopyStatus; }; @@ -701,16 +687,15 @@ FLMEXTC FLMEXP RCODE FLMAPI xflaim_DbSystem_dbCopy( const char * pszDestDbName, const char * pszDestDataDir, const char * pszDestRflDir, - void * pvObj, DB_COPY_STATUS fnCopyStatus) { RCODE rc = NE_XFLM_OK; IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This); IF_DbCopyStatus * pDbCopyStatus = NULL; - if (pvObj) + if (fnCopyStatus) { - if ((pDbCopyStatus = f_new CS_DbCopyStatus( pvObj, fnCopyStatus)) == NULL) + if ((pDbCopyStatus = f_new CS_DbCopyStatus( fnCopyStatus)) == NULL) { rc = RC_SET( NE_XFLM_MEM); goto Exit; diff --git a/xflaim/csharp/xflaim/DbSystem.cs b/xflaim/csharp/xflaim/DbSystem.cs index b498f2e..ddb7758 100644 --- a/xflaim/csharp/xflaim/DbSystem.cs +++ b/xflaim/csharp/xflaim/DbSystem.cs @@ -29,100 +29,100 @@ using System.Runtime.InteropServices; namespace xflaim { - /// - /// Valid database versions + /// + /// Valid database versions /// public enum DBVersions { - /// Version 5.12 + /// Version 5.12 XFLM_VER_5_12 = 512, - /// Current database version number + /// Current database version number XFLM_CURRENT_VERSION_NUM = XFLM_VER_5_12 } - /// - /// Valid languages + /// + /// Valid languages /// public enum Languages { - /// English, United States - FLM_US_LANG = 0, - /// Afrikaans - FLM_AF_LANG = 1, - /// Arabic - FLM_AR_LANG = 2, - /// Catalan - FLM_CA_LANG = 3, - /// Croatian - FLM_HR_LANG = 4, - /// Czech - FLM_CZ_LANG = 5, - /// Danish - FLM_DK_LANG = 6, - /// Dutch - FLM_NL_LANG = 7, - /// English, Australia - FLM_OZ_LANG = 8, - /// English, Canada - FLM_CE_LANG = 9, - /// English, United Kingdom - FLM_UK_LANG = 10, - /// Farsi - FLM_FA_LANG = 11, - /// Finnish - FLM_SU_LANG = 12, - /// French, Canada - FLM_CF_LANG = 13, - /// French, France - FLM_FR_LANG = 14, - /// Galician - FLM_GA_LANG = 15, - /// German, Germany - FLM_DE_LANG = 16, - /// German, Switzerland - FLM_SD_LANG = 17, - /// Greek - FLM_GR_LANG = 18, - /// Hebrew - FLM_HE_LANG = 19, - /// Hungarian - FLM_HU_LANG = 20, - /// Icelandic - FLM_IS_LANG = 21, - /// Italian - FLM_IT_LANG = 22, - /// Norwegian - FLM_NO_LANG = 23, - /// Polish - FLM_PL_LANG = 24, - /// Portuguese, Brazil - FLM_BR_LANG = 25, - /// Portuguese, Portugal - FLM_PO_LANG = 26, - /// Russian - FLM_RU_LANG = 27, - /// Slovak - FLM_SL_LANG = 28, - /// Spanish - FLM_ES_LANG = 29, - /// Swedish - FLM_SV_LANG = 30, - /// Ukrainian - FLM_YK_LANG = 31, - /// Urdu - FLM_UR_LANG = 32, - /// Turkey - FLM_TK_LANG = 33, - /// Japanese - FLM_JP_LANG = 34, - /// Korean - FLM_KO_LANG = 35, - /// Chinese-Traditional - FLM_CT_LANG = 36, - /// Chinese-Simplified - FLM_CS_LANG = 37, - /// another Asian language - FLM_LA_LANG = 38 + /// English, United States + FLM_US_LANG = 0, + /// Afrikaans + FLM_AF_LANG = 1, + /// Arabic + FLM_AR_LANG = 2, + /// Catalan + FLM_CA_LANG = 3, + /// Croatian + FLM_HR_LANG = 4, + /// Czech + FLM_CZ_LANG = 5, + /// Danish + FLM_DK_LANG = 6, + /// Dutch + FLM_NL_LANG = 7, + /// English, Australia + FLM_OZ_LANG = 8, + /// English, Canada + FLM_CE_LANG = 9, + /// English, United Kingdom + FLM_UK_LANG = 10, + /// Farsi + FLM_FA_LANG = 11, + /// Finnish + FLM_SU_LANG = 12, + /// French, Canada + FLM_CF_LANG = 13, + /// French, France + FLM_FR_LANG = 14, + /// Galician + FLM_GA_LANG = 15, + /// German, Germany + FLM_DE_LANG = 16, + /// German, Switzerland + FLM_SD_LANG = 17, + /// Greek + FLM_GR_LANG = 18, + /// Hebrew + FLM_HE_LANG = 19, + /// Hungarian + FLM_HU_LANG = 20, + /// Icelandic + FLM_IS_LANG = 21, + /// Italian + FLM_IT_LANG = 22, + /// Norwegian + FLM_NO_LANG = 23, + /// Polish + FLM_PL_LANG = 24, + /// Portuguese, Brazil + FLM_BR_LANG = 25, + /// Portuguese, Portugal + FLM_PO_LANG = 26, + /// Russian + FLM_RU_LANG = 27, + /// Slovak + FLM_SL_LANG = 28, + /// Spanish + FLM_ES_LANG = 29, + /// Swedish + FLM_SV_LANG = 30, + /// Ukrainian + FLM_YK_LANG = 31, + /// Urdu + FLM_UR_LANG = 32, + /// Turkey + FLM_TK_LANG = 33, + /// Japanese + FLM_JP_LANG = 34, + /// Korean + FLM_KO_LANG = 35, + /// Chinese-Traditional + FLM_CT_LANG = 36, + /// Chinese-Simplified + FLM_CS_LANG = 37, + /// another Asian language + FLM_LA_LANG = 38 } /// @@ -132,52 +132,52 @@ namespace xflaim public class CREATE_OPTS { - /// - /// Block size, may be 4096 or 8192. + /// + /// Block size, may be 4096 or 8192. /// public uint uiBlockSize; - /// - /// Database version number. Should be one of . + /// + /// Database version number. Should be one of . /// public uint uiVersionNum; - /// - /// Minimum Roll-forward log file size. + /// + /// Minimum Roll-forward log file size. /// public uint uiMinRflFileSize; - /// - /// Maximum Roll-forward log file size. + /// + /// Maximum Roll-forward log file size. /// public uint uiMaxRflFileSize; - /// - /// Flag indicating whether roll-forward log files should - /// be kept or reused. + /// + /// Flag indicating whether roll-forward log files should + /// be kept or reused. /// public int bKeepRflFiles; - /// - /// Flag indicating whether aborted transactions should be - /// logged to the roll-forward log. + /// + /// Flag indicating whether aborted transactions should be + /// logged to the roll-forward log. /// public int bLogAbortedTransToRfl; - /// - /// Default language for the database. Should be one of + /// + /// Default language for the database. Should be one of /// public uint uiDefaultLanguage; } - /// - /// XFLAIM Exception class. - /// + /// + /// XFLAIM Exception class. + /// public class XFlaimException : Exception { - /// - /// XFLAIM Exception that returns an RCODE. - /// + /// + /// XFLAIM Exception that returns an RCODE. + /// /// The error code that occurred. public XFlaimException( int iRcode) @@ -186,9 +186,9 @@ namespace xflaim m_message = null; } - /// - /// XFLAIM Exception that returns a message. - /// + /// + /// XFLAIM Exception that returns a message. + /// /// Message explaining cause of exception. public XFlaimException( string message) @@ -198,23 +198,23 @@ namespace xflaim } - /// - /// Returns the error code that caused the exception to be thrown. - /// - /// - /// The error code that caused the exception. If zero is returned - /// there is no message associated with this exception. Instead, - /// the application should call to get - /// the message that explains the cause of the exception. - /// + /// + /// Returns the error code that caused the exception to be thrown. + /// + /// + /// The error code that caused the exception. If zero is returned + /// there is no message associated with this exception. Instead, + /// the application should call to get + /// the message that explains the cause of the exception. + /// public RCODE getRCode() { return m_rc; } - /// - /// Returns the string that explains the cause of the exception. - /// + /// + /// Returns the string that explains the cause of the exception. + /// /// /// The string that explains the cause of the exception. If null /// is returned, there is no message associated with this exception. @@ -230,16 +230,16 @@ namespace xflaim private RCODE m_rc; } - /// - /// The DbSystem class provides a number of methods that allow C# - /// applications to access the XFlaim development environment. - /// + /// + /// The DbSystem class provides a number of methods that allow C# + /// applications to access the XFlaim development environment. + /// public class DbSystem { - /// - /// DbSystem constructor. - /// + /// + /// DbSystem constructor. + /// public DbSystem() { int rc = 0; @@ -250,18 +250,27 @@ namespace xflaim } } - /// - /// DbSystem destructor. - /// + /// + /// DbSystem destructor. + /// ~DbSystem() { xflaim_DbSystem_Release( m_this); m_this = 0; - } + } + + /// + /// Called by class to silence compiler warning. + /// Has no other important use! + /// + public ulong getRef() + { + return m_this; + } - /// - /// Creates a new XFlaim database. - /// + /// + /// Creates a new XFlaim database. + /// /// /// This is the name of the control file for the database. /// The control file is the primary database name. It may include a full @@ -327,9 +336,9 @@ namespace xflaim return( db); } - /// - /// Creates a new XFlaim database. - /// + /// + /// Creates a new XFlaim database. + /// /// /// See documentation on . /// @@ -373,19 +382,19 @@ namespace xflaim return( db); } - /// - /// Removes (deletes) an XFlaim database. - /// + /// + /// Removes (deletes) an XFlaim database. + /// /// /// The name of the control file of the database to delete. - /// For more information see - /// - /// - /// The data file directory. For more information see . - /// - /// + /// For more information see + /// + /// + /// The data file directory. For more information see . + /// + /// /// The roll-forward log file directory. For more information see . - /// + /// /// /// If true, the roll forward log files will be deleted. /// @@ -404,39 +413,39 @@ namespace xflaim } } - /// + /// /// Restores a previously backed up database. The parameter /// and the parameter are mutually exclusive. If the /// parameter is null, then the backup data will be read from - /// . If is non-null, - /// is ignored. - /// - /// - /// The name of the control file of the database to restore. - /// - /// - /// The data file directory. For more information see . - /// - /// - /// The roll-forward log file directory. For more information see . - /// - /// + /// . If is non-null, + /// is ignored. + /// + /// + /// The name of the control file of the database to restore. + /// + /// + /// The data file directory. For more information see . + /// + /// + /// The roll-forward log file directory. For more information see . + /// + /// /// The path to the backup files. This may be null. If /// non-null, it specifies the directory where the backup files which are /// to be restored are found. If null, the parameter must be - /// non-null. - /// - /// + /// non-null. + /// + /// /// Password for the backup. If non-null, the database key in /// the backup was wrapped in a password instead of the local NICI storage /// key. This allows the database to be restored to a different machine if /// desired. If null, the database can only be restored to the same machine - /// where it originally existed. - /// - /// + /// where it originally existed. + /// + /// /// An object implementing the interface. This may be null. If - /// non-null, it is an object that knows how to get the backup data. - /// + /// non-null, it is an object that knows how to get the backup data. + /// /// /// An object implementing interface. This may be null. If /// non-null, it is a callback object whose methods will be called to report @@ -452,18 +461,24 @@ namespace xflaim RestoreStatus restoreStatus) { int rc; - RestoreStatusCallback fnRestoreStatus; - RestoreClientCallback fnRestoreClient; - - fnRestoreClient = (restoreClient != null) - ? new RestoreClientCallback( funcRestoreClient) - : null; - fnRestoreStatus = (restoreStatus != null) - ? new RestoreStatusCallback( funcRestoreStatus) - : null; + RestoreClientDelegate restoreClientDelegate = null; + RestoreClientCallback fnRestoreClient = null; + RestoreStatusDelegate restoreStatusDelegate = null; + RestoreStatusCallback fnRestoreStatus = null; + + if (restoreClient != null) + { + restoreClientDelegate = new RestoreClientDelegate( restoreClient); + fnRestoreClient = new RestoreClientCallback( restoreClientDelegate.funcRestoreClient); + } + if (restoreStatus != null) + { + restoreStatusDelegate = new RestoreStatusDelegate( restoreStatus); + fnRestoreStatus = new RestoreStatusCallback( restoreStatusDelegate.funcRestoreStatus); + } if ((rc = xflaim_DbSystem_dbRestore( m_this, sDbPath, sDataDir, sRflDir, sBackupPath, - sPassword, restoreClient, fnRestoreClient, restoreStatus, fnRestoreStatus)) != 0) + sPassword, fnRestoreClient, fnRestoreStatus)) != 0) { throw new XFlaimException( rc); } @@ -481,37 +496,50 @@ namespace xflaim } private delegate RCODE RestoreClientCallback( - RestoreClient restoreClient, RestoreClientAction eAction, uint uiFileNum, uint uiBytesRequested, IntPtr pvBuffer, ref uint puiBytesRead); - - private RCODE funcRestoreClient( - RestoreClient restoreClient, - RestoreClientAction eAction, - uint uiFileNum, - uint uiBytesRequested, - IntPtr pvBuffer, - ref uint uiBytesRead) + + private class RestoreClientDelegate { - switch (eAction) + public RestoreClientDelegate( + RestoreClient restoreClient) { - case RestoreClientAction.RESTORE_OPEN_BACKUP_SET: - return( restoreClient.openBackupSet()); - case RestoreClientAction.RESTORE_OPEN_RFL_FILE: - return( restoreClient.openRflFile( uiFileNum)); - case RestoreClientAction.RESTORE_OPEN_INC_FILE: - return( restoreClient.openIncFile( uiFileNum)); - case RestoreClientAction.RESTORE_READ: - return( restoreClient.read( uiBytesRequested, pvBuffer, ref uiBytesRead)); - case RestoreClientAction.RESTORE_CLOSE: - return( restoreClient.close()); - case RestoreClientAction.RESTORE_ABORT_FILE: - return( restoreClient.abortFile()); + m_restoreClient = restoreClient; } - return( RCODE.NE_XFLM_INVALID_PARM); + + ~RestoreClientDelegate() + { + } + + public RCODE funcRestoreClient( + RestoreClientAction eAction, + uint uiFileNum, + uint uiBytesRequested, + IntPtr pvBuffer, + ref uint uiBytesRead) + { + switch (eAction) + { + case RestoreClientAction.RESTORE_OPEN_BACKUP_SET: + return( m_restoreClient.openBackupSet()); + case RestoreClientAction.RESTORE_OPEN_RFL_FILE: + return( m_restoreClient.openRflFile( uiFileNum)); + case RestoreClientAction.RESTORE_OPEN_INC_FILE: + return( m_restoreClient.openIncFile( uiFileNum)); + case RestoreClientAction.RESTORE_READ: + return( m_restoreClient.read( uiBytesRequested, pvBuffer, ref uiBytesRead)); + case RestoreClientAction.RESTORE_CLOSE: + return( m_restoreClient.close()); + case RestoreClientAction.RESTORE_ABORT_FILE: + return( m_restoreClient.abortFile()); + } + return( RCODE.NE_XFLM_INVALID_PARM); + } + + private RestoreClient m_restoreClient; } // WARNING NOTE: Any changes to this enum should also be reflected in DbSystem.cpp @@ -546,9 +574,8 @@ namespace xflaim REPORT_DOCUMENT_DONE = 27, REPORT_ROLL_OVER_DB_KEY = 28 } - + private delegate RCODE RestoreStatusCallback( - RestoreStatus restoreStatus, RestoreStatusAction eAction, ref RestoreAction eRestoreAction, ulong ulTransId, @@ -560,115 +587,150 @@ namespace xflaim uint uiShortNum3, uint uiShortNum4); - private RCODE funcRestoreStatus( - RestoreStatus restoreStatus, - RestoreStatusAction eAction, - ref RestoreAction eRestoreAction, - ulong ulTransId, - ulong ulLongNum1, - ulong ulLongNum2, - ulong ulLongNum3, - uint uiShortNum1, - uint uiShortNum2, - uint uiShortNum3, - uint uiShortNum4) + private class RestoreStatusDelegate { - switch (eAction) + public RestoreStatusDelegate( + RestoreStatus restoreStatus) { - case RestoreStatusAction.REPORT_PROGRESS: - return( restoreStatus.reportProgress( ref eRestoreAction, ulLongNum1, ulLongNum2)); - case RestoreStatusAction.REPORT_ERROR: - return( restoreStatus.reportError( ref eRestoreAction, (RCODE)uiShortNum1)); - case RestoreStatusAction.REPORT_BEGIN_TRANS: - return( restoreStatus.reportBeginTrans( ref eRestoreAction, ulTransId)); - case RestoreStatusAction.REPORT_COMMIT_TRANS: - return( restoreStatus.reportCommitTrans( ref eRestoreAction, ulTransId)); - case RestoreStatusAction.REPORT_ABORT_TRANS: - return( restoreStatus.reportAbortTrans( ref eRestoreAction, ulTransId)); - case RestoreStatusAction.REPORT_BLOCK_CHAIN_FREE: - return( restoreStatus.reportBlockChainFree( ref eRestoreAction, ulTransId, ulLongNum1, - uiShortNum1, uiShortNum2, uiShortNum3)); - case RestoreStatusAction.REPORT_INDEX_SUSPEND: - return( restoreStatus.reportIndexSuspend( ref eRestoreAction, ulTransId, uiShortNum1)); - case RestoreStatusAction.REPORT_INDEX_RESUME: - return( restoreStatus.reportIndexResume( ref eRestoreAction, ulTransId, uiShortNum1)); - case RestoreStatusAction.REPORT_REDUCE: - return( restoreStatus.reportReduce( ref eRestoreAction, ulTransId, uiShortNum1)); - case RestoreStatusAction.REPORT_UPGRADE: - return( restoreStatus.reportUpgrade( ref eRestoreAction, ulTransId, uiShortNum1, uiShortNum2)); - case RestoreStatusAction.REPORT_OPEN_RFL_FILE: - return( restoreStatus.reportOpenRflFile( ref eRestoreAction, uiShortNum1)); - case RestoreStatusAction.REPORT_RFL_READ: - return( restoreStatus.reportRflRead( ref eRestoreAction, uiShortNum1, uiShortNum2)); - case RestoreStatusAction.REPORT_ENABLE_ENCRYPTION: - return( restoreStatus.reportEnableEncryption( ref eRestoreAction, ulTransId)); - case RestoreStatusAction.REPORT_WRAP_KEY: - return( restoreStatus.reportWrapKey( ref eRestoreAction, ulTransId)); - case RestoreStatusAction.REPORT_SET_NEXT_NODE_ID: - return( restoreStatus.reportSetNextNodeId( ref eRestoreAction, ulTransId, uiShortNum1, ulLongNum1)); - case RestoreStatusAction.REPORT_NODE_SET_META_VALUE: - return( restoreStatus.reportNodeSetMetaValue( ref eRestoreAction, ulTransId, uiShortNum1, - ulLongNum1, ulLongNum2)); - case RestoreStatusAction.REPORT_NODE_SET_PREFIX_ID: - return( restoreStatus.reportNodeSetPrefixId( ref eRestoreAction, ulTransId, uiShortNum1, - ulLongNum1, uiShortNum2, uiShortNum3)); - case RestoreStatusAction.REPORT_NODE_FLAGS_UPDATE: - return( restoreStatus.reportNodeFlagsUpdate( ref eRestoreAction, ulTransId, uiShortNum1, - ulLongNum1, uiShortNum2, (bool)(uiShortNum3 != 0 ? true : false))); - case RestoreStatusAction.REPORT_ATTRIBUTE_SET_VALUE: - return( restoreStatus.reportAttributeSetValue( ref eRestoreAction, ulTransId, uiShortNum1, - ulLongNum1, uiShortNum2)); - case RestoreStatusAction.REPORT_NODE_SET_VALUE: - return( restoreStatus.reportNodeSetValue( ref eRestoreAction, ulTransId, uiShortNum1, ulLongNum1)); - case RestoreStatusAction.REPORT_NODE_UPDATE: - return( restoreStatus.reportNodeUpdate( ref eRestoreAction, ulTransId, uiShortNum1, ulLongNum1)); - case RestoreStatusAction.REPORT_INSERT_BEFORE: - return( restoreStatus.reportInsertBefore( ref eRestoreAction, ulTransId, uiShortNum1, ulLongNum1, - ulLongNum2, ulLongNum3)); - case RestoreStatusAction.REPORT_NODE_CREATE: - return( restoreStatus.reportNodeCreate( ref eRestoreAction, ulTransId, uiShortNum1, ulLongNum1, - (eDomNodeType)uiShortNum2, uiShortNum3, (eNodeInsertLoc)uiShortNum4)); - case RestoreStatusAction.REPORT_NODE_CHILDREN_DELETE: - return( restoreStatus.reportNodeChildrenDelete( ref eRestoreAction, ulTransId, uiShortNum1, - ulLongNum1, uiShortNum2)); - case RestoreStatusAction.REPORT_ATTRIBUTE_DELETE: - return( restoreStatus.reportAttributeDelete( ref eRestoreAction, ulTransId, uiShortNum1, ulLongNum1, - uiShortNum2)); - case RestoreStatusAction.REPORT_NODE_DELETE: - return( restoreStatus.reportNodeDelete( ref eRestoreAction, ulTransId, uiShortNum1, ulLongNum1)); - case RestoreStatusAction.REPORT_DOCUMENT_DONE: - return( restoreStatus.reportDocumentDone( ref eRestoreAction, ulTransId, uiShortNum1, ulLongNum1)); - case RestoreStatusAction.REPORT_ROLL_OVER_DB_KEY: - return( restoreStatus.reportRollOverDbKey( ref eRestoreAction, ulTransId)); + m_restoreStatus = restoreStatus; } - return( RCODE.NE_XFLM_INVALID_PARM); + + ~RestoreStatusDelegate() + { + } + + public RCODE funcRestoreStatus( + RestoreStatusAction eAction, + ref RestoreAction eRestoreAction, + ulong ulTransId, + ulong ulLongNum1, + ulong ulLongNum2, + ulong ulLongNum3, + uint uiShortNum1, + uint uiShortNum2, + uint uiShortNum3, + uint uiShortNum4) + { + switch (eAction) + { + case RestoreStatusAction.REPORT_PROGRESS: + return( m_restoreStatus.reportProgress( ref eRestoreAction, + ulLongNum1, ulLongNum2)); + case RestoreStatusAction.REPORT_ERROR: + return( m_restoreStatus.reportError( ref eRestoreAction, + (RCODE)uiShortNum1)); + case RestoreStatusAction.REPORT_BEGIN_TRANS: + return( m_restoreStatus.reportBeginTrans( ref eRestoreAction, + ulTransId)); + case RestoreStatusAction.REPORT_COMMIT_TRANS: + return( m_restoreStatus.reportCommitTrans( ref eRestoreAction, + ulTransId)); + case RestoreStatusAction.REPORT_ABORT_TRANS: + return( m_restoreStatus.reportAbortTrans( ref eRestoreAction, + ulTransId)); + case RestoreStatusAction.REPORT_BLOCK_CHAIN_FREE: + return( m_restoreStatus.reportBlockChainFree( ref eRestoreAction, + ulTransId, ulLongNum1, uiShortNum1, uiShortNum2, uiShortNum3)); + case RestoreStatusAction.REPORT_INDEX_SUSPEND: + return( m_restoreStatus.reportIndexSuspend( ref eRestoreAction, + ulTransId, uiShortNum1)); + case RestoreStatusAction.REPORT_INDEX_RESUME: + return( m_restoreStatus.reportIndexResume( ref eRestoreAction, + ulTransId, uiShortNum1)); + case RestoreStatusAction.REPORT_REDUCE: + return( m_restoreStatus.reportReduce( ref eRestoreAction, + ulTransId, uiShortNum1)); + case RestoreStatusAction.REPORT_UPGRADE: + return( m_restoreStatus.reportUpgrade( ref eRestoreAction, + ulTransId, uiShortNum1, uiShortNum2)); + case RestoreStatusAction.REPORT_OPEN_RFL_FILE: + return( m_restoreStatus.reportOpenRflFile( ref eRestoreAction, + uiShortNum1)); + case RestoreStatusAction.REPORT_RFL_READ: + return( m_restoreStatus.reportRflRead( ref eRestoreAction, + uiShortNum1, uiShortNum2)); + case RestoreStatusAction.REPORT_ENABLE_ENCRYPTION: + return( m_restoreStatus.reportEnableEncryption( ref eRestoreAction, + ulTransId)); + case RestoreStatusAction.REPORT_WRAP_KEY: + return( m_restoreStatus.reportWrapKey( ref eRestoreAction, + ulTransId)); + case RestoreStatusAction.REPORT_SET_NEXT_NODE_ID: + return( m_restoreStatus.reportSetNextNodeId( ref eRestoreAction, + ulTransId, uiShortNum1, ulLongNum1)); + case RestoreStatusAction.REPORT_NODE_SET_META_VALUE: + return( m_restoreStatus.reportNodeSetMetaValue( ref eRestoreAction, + ulTransId, uiShortNum1, ulLongNum1, ulLongNum2)); + case RestoreStatusAction.REPORT_NODE_SET_PREFIX_ID: + return( m_restoreStatus.reportNodeSetPrefixId( ref eRestoreAction, + ulTransId, uiShortNum1, ulLongNum1, uiShortNum2, uiShortNum3)); + case RestoreStatusAction.REPORT_NODE_FLAGS_UPDATE: + return( m_restoreStatus.reportNodeFlagsUpdate( ref eRestoreAction, + ulTransId, uiShortNum1, ulLongNum1, uiShortNum2, + (bool)(uiShortNum3 != 0 ? true : false))); + case RestoreStatusAction.REPORT_ATTRIBUTE_SET_VALUE: + return( m_restoreStatus.reportAttributeSetValue( ref eRestoreAction, + ulTransId, uiShortNum1, ulLongNum1, uiShortNum2)); + case RestoreStatusAction.REPORT_NODE_SET_VALUE: + return( m_restoreStatus.reportNodeSetValue( ref eRestoreAction, + ulTransId, uiShortNum1, ulLongNum1)); + case RestoreStatusAction.REPORT_NODE_UPDATE: + return( m_restoreStatus.reportNodeUpdate( ref eRestoreAction, + ulTransId, uiShortNum1, ulLongNum1)); + case RestoreStatusAction.REPORT_INSERT_BEFORE: + return( m_restoreStatus.reportInsertBefore( ref eRestoreAction, + ulTransId, uiShortNum1, ulLongNum1, ulLongNum2, ulLongNum3)); + case RestoreStatusAction.REPORT_NODE_CREATE: + return( m_restoreStatus.reportNodeCreate( ref eRestoreAction, + ulTransId, uiShortNum1, ulLongNum1, + (eDomNodeType)uiShortNum2, uiShortNum3, (eNodeInsertLoc)uiShortNum4)); + case RestoreStatusAction.REPORT_NODE_CHILDREN_DELETE: + return( m_restoreStatus.reportNodeChildrenDelete( ref eRestoreAction, + ulTransId, uiShortNum1, ulLongNum1, uiShortNum2)); + case RestoreStatusAction.REPORT_ATTRIBUTE_DELETE: + return( m_restoreStatus.reportAttributeDelete( ref eRestoreAction, + ulTransId, uiShortNum1, ulLongNum1, uiShortNum2)); + case RestoreStatusAction.REPORT_NODE_DELETE: + return( m_restoreStatus.reportNodeDelete( ref eRestoreAction, + ulTransId, uiShortNum1, ulLongNum1)); + case RestoreStatusAction.REPORT_DOCUMENT_DONE: + return( m_restoreStatus.reportDocumentDone( ref eRestoreAction, + ulTransId, uiShortNum1, ulLongNum1)); + case RestoreStatusAction.REPORT_ROLL_OVER_DB_KEY: + return( m_restoreStatus.reportRollOverDbKey( ref eRestoreAction, + ulTransId)); + } + return( RCODE.NE_XFLM_INVALID_PARM); + } + + private RestoreStatus m_restoreStatus; } - /// - /// Makes a copy of an existing database. - /// - /// + /// + /// Makes a copy of an existing database. + /// + /// /// The name of the control file of the database to be copied. - /// - /// - /// The directory where the data files for the source - /// database are stored. See for more information. - /// - /// + /// + /// + /// The directory where the data files for the source + /// database are stored. See for more information. + /// + /// /// The directory where the RFL files for the source - /// database are stored. See for more information. - /// - /// - /// The name of the control file that is to be created for the destination database. - /// - /// - /// The directory where the data files for the destination database will be stored. - /// See for more information. - /// - /// - /// The directory where the RFL files for the destination database will be stored. - /// See for more information. - /// + /// database are stored. See for more information. + /// + /// + /// The name of the control file that is to be created for the destination database. + /// + /// + /// The directory where the data files for the destination database will be stored. + /// See for more information. + /// + /// + /// The directory where the RFL files for the destination database will be stored. + /// See for more information. + /// /// /// If non-null this is an object that implements the /// interface. It is a callback object that is used to report copy progress. @@ -683,54 +745,75 @@ namespace xflaim DbCopyStatus copyStatus) { int rc; - DbCopyStatusCallback fnDbCopyStatus = new DbCopyStatusCallback( funcDbCopyStatus); + DbCopyStatusDelegate dbCopyStatus = null; + DbCopyStatusCallback fnDbCopyStatus = null; + if (copyStatus != null) + { + dbCopyStatus = new DbCopyStatusDelegate( copyStatus); + fnDbCopyStatus = new DbCopyStatusCallback( dbCopyStatus.funcDbCopyStatus); + } if ((rc = xflaim_DbSystem_dbCopy( m_this, sSrcDbName, sSrcDataDir, sSrcRflDir, - sDestDbName, sDestDataDir, sDestRflDir, copyStatus, fnDbCopyStatus)) != 0) + sDestDbName, sDestDataDir, sDestRflDir, fnDbCopyStatus)) != 0) { throw new XFlaimException( rc); } } private delegate RCODE DbCopyStatusCallback( - DbCopyStatus copyStatus, ulong ulBytesToCopy, ulong ulBytesCopied, int bNewSrcFile, IntPtr pszSrcFileName, IntPtr pszDestFileName); - private static RCODE funcDbCopyStatus( - DbCopyStatus copyStatus, - ulong ulBytesToCopy, - ulong ulBytesCopied, - int bNewSrcFile, - IntPtr pszSrcFileName, - IntPtr pszDestFileName) + private class DbCopyStatusDelegate { - string sSrcFileName = null; - string sDestFileName = null; - - if (bNewSrcFile != 0) + public DbCopyStatusDelegate( + DbCopyStatus dbCopyStatus) { - sSrcFileName = Marshal.PtrToStringAnsi( pszSrcFileName); - sDestFileName = Marshal.PtrToStringAnsi( pszDestFileName); + m_dbCopyStatus = dbCopyStatus; } - return( copyStatus.dbCopyStatus( ulBytesToCopy, ulBytesCopied, - sSrcFileName, sDestFileName)); + + ~DbCopyStatusDelegate() + { + } + + public RCODE funcDbCopyStatus( + ulong ulBytesToCopy, + ulong ulBytesCopied, + int bNewSrcFile, + IntPtr pszSrcFileName, + IntPtr pszDestFileName) + { + RCODE rc = RCODE.NE_XFLM_OK; + string sSrcFileName = null; + string sDestFileName = null; + + if (bNewSrcFile != 0) + { + sSrcFileName = Marshal.PtrToStringAnsi( pszSrcFileName); + sDestFileName = Marshal.PtrToStringAnsi( pszDestFileName); + } + rc = m_dbCopyStatus.dbCopyStatus( ulBytesToCopy, ulBytesCopied, + sSrcFileName, sDestFileName); + return( rc); + } + + private DbCopyStatus m_dbCopyStatus; } // PRIVATE METHODS THAT ARE IMPLEMENTED IN C AND C++ - [DllImport("xflaim")] - private static extern int xflaim_DbSystem_createDbSystem( - out ulong pulDbSystemRef); + [DllImport("xflaim")] + private static extern int xflaim_DbSystem_createDbSystem( + out ulong pulDbSystemRef); - [DllImport("xflaim")] - private static extern int xflaim_DbSystem_Release( - ulong ulThis); + [DllImport("xflaim")] + private static extern int xflaim_DbSystem_Release( + ulong ulThis); - [DllImport("xflaim",CharSet=CharSet.Ansi)] + [DllImport("xflaim",CharSet=CharSet.Ansi)] private static extern int xflaim_DbSystem_dbCreate( ulong ulThis, [MarshalAs(UnmanagedType.LPStr)] string pszDbFileName, @@ -741,7 +824,7 @@ namespace xflaim CREATE_OPTS pCreateOpts, out ulong pulDbRef); - [DllImport("xflaim",CharSet=CharSet.Ansi)] + [DllImport("xflaim",CharSet=CharSet.Ansi)] private static extern int xflaim_DbSystem_dbOpen( ulong ulThis, [MarshalAs(UnmanagedType.LPStr)] string pszDbFileName, @@ -751,7 +834,7 @@ namespace xflaim int bAllowLimited, out ulong pulDbRef); - [DllImport("xflaim",CharSet=CharSet.Ansi)] + [DllImport("xflaim",CharSet=CharSet.Ansi)] private static extern int xflaim_DbSystem_dbRemove( ulong ulThis, [MarshalAs(UnmanagedType.LPStr)] string pszDbFileName, @@ -759,7 +842,7 @@ namespace xflaim [MarshalAs(UnmanagedType.LPStr)] string pszRflDir, int bRemoveRflFiles); - [DllImport("xflaim",CharSet=CharSet.Ansi)] + [DllImport("xflaim",CharSet=CharSet.Ansi)] private static extern int xflaim_DbSystem_dbRestore( ulong ulThis, [MarshalAs(UnmanagedType.LPStr)] string pszDbFileName, @@ -767,12 +850,10 @@ namespace xflaim [MarshalAs(UnmanagedType.LPStr)] string pszRflDir, [MarshalAs(UnmanagedType.LPStr)] string pszBackupPath, [MarshalAs(UnmanagedType.LPStr)] string pszPassword, - RestoreClient restoreClient, RestoreClientCallback fnRestoreClient, - RestoreStatus restoreStatus, RestoreStatusCallback fnRestoreStatus); - [DllImport("xflaim",CharSet=CharSet.Ansi)] + [DllImport("xflaim",CharSet=CharSet.Ansi)] private static extern int xflaim_DbSystem_dbCopy( ulong ulThis, [MarshalAs(UnmanagedType.LPStr)] string pszSrcDbName, @@ -781,7 +862,6 @@ namespace xflaim [MarshalAs(UnmanagedType.LPStr)] string pszDestDbName, [MarshalAs(UnmanagedType.LPStr)] string pszDestDataDir, [MarshalAs(UnmanagedType.LPStr)] string pszDestRflDir, - DbCopyStatus copyStatus, DbCopyStatusCallback fnDbCopyStatus); private ulong m_this;