diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2023-08-14 19:45:36 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2023-08-14 19:45:36 +0200 |
commit | bfa452a375ea0a0a3f95304a69186936567e5263 (patch) | |
tree | aade062a143c1afcc4ea06ee27905ffc34a9217b /src/tests/xb_test_lock2.cpp | |
parent | dd70ff8bf32c2d7ed365004b1770058265db1978 (diff) |
New upstream version 4.1.4
Diffstat (limited to 'src/tests/xb_test_lock2.cpp')
-rwxr-xr-x | src/tests/xb_test_lock2.cpp | 207 |
1 files changed, 0 insertions, 207 deletions
diff --git a/src/tests/xb_test_lock2.cpp b/src/tests/xb_test_lock2.cpp deleted file mode 100755 index d5534ec..0000000 --- a/src/tests/xb_test_lock2.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/* xb_test_lock2.cpp - -XBase Software Library - -Copyright (c) 1997,2003,2014,2022,2023 Gary A Kunkel - -The xb64 software library is covered under the terms of the GPL Version 3, 2007 license. - -Email Contact: - - XDB-devel@lists.sourceforge.net - XDB-users@lists.sourceforge.net - -*/ - -// This program tests the locking functions -// This program is the child process that is called if used -// in an environment that supports the CreateProcess library function (ie Windows) - -// usage: xb_test_lock QUITE|NORMAL|VERBOSE - - - -#include "xbase.h" - -using namespace xb; - -#include "tstfuncs.cpp" - -/****************************************************************/ -int main( int argCnt, char **av ) -{ - xbInt16 iRc = 0; - xbInt16 iRc2; - xbInt16 po = 1; /* print option */ - /* 0 - QUIET */ - /* 1 - NORMAL */ - /* 2 - VERBOSE */ - - xbBool bDone = xbFalse; -// xbInt16 iErrorStop = 0; - xbString sLockFile = "locktest.txt"; - xbString sLockCmd; - xbString sResult; - xbInt32 iChildLoop = 0; - - xbXBase x; - xbDbf * MyFile; - - xbBool bTblOpen = xbFalse; - - if( argCnt > 1 ) { - if( av[1][0] == 'Q' ) - po = 0; - else if( av[1][0] == 'V' ) - po = 2; - } - - #ifdef XB_LOGGING_SUPPORT - x.SetLogDirectory( PROJECT_LOG_DIR ); - xbString sLogFileName = x.GetLogFqFileName().Str(); - sLogFileName.Resize( sLogFileName.Len() - 3 ); - sLogFileName += "_l2.txt"; - x.SetLogFileName( sLogFileName ); - x.EnableMsgLogging(); - if( po > 0 ){ - std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; - } - xbString sMsg; - sMsg.Sprintf( "Program [%s] initializing...", av[0] ); - x.WriteLogMessage( sMsg ); - #endif - - x.SetDataDirectory( PROJECT_DATA_DIR ); - InitTime(); - - #ifdef XB_DBF4_SUPPORT - MyFile = new xbDbf4( &x ); /* version 4 dbf file */ - #else - MyFile = new xbDbf3( &x ); /* version 3 dbf file */ - #endif - - x.xbSleep( 250 ); - while( !bDone ){ - iRc2 = GetCmd( x, sLockFile, sLockCmd, 'C', po ); - - #ifdef XB_LOGGING_SUPPORT - if( sLockCmd != "OK" && sLockCmd != "FAIL" ){ - sMsg.Sprintf( "Program [%s] Child task retrieved command=[%s] RC=[%d]", av[0], sLockCmd.Str(), iRc2 ); - x.WriteLogMessage( sMsg ); - } - #endif - - if( iRc2 == 0 ){ - - if( sLockCmd == "OK" || sLockCmd == "FAIL" ) - x.xbSleep( 250 ); - - else if( sLockCmd == "EXIT" ){ - bDone = xbTrue; - - } else if( sLockCmd == "START" && bTblOpen ){ - // came back before the parent task could process the result - x.xbSleep( 250 ); - - } else { - - if( sLockCmd == "START" ){ - - // begin the process - iRc2 = MyFile->Open( "LockTest.DBF" ); - if( iRc2 != XB_NO_ERROR ){ - sResult = "FAIL"; - } else { - sResult = "OK"; - bTblOpen = xbTrue; - } - - } else if( sLockCmd == "TL" ){ - // table lock - if(( iRc2 = MyFile->LockTable( XB_LOCK )) != XB_NO_ERROR ) - sResult = "FAIL"; - else - sResult = "OK"; - - } else if( sLockCmd == "TU" ){ - // table unlock - if(( iRc2 = MyFile->LockTable( XB_UNLOCK )) != XB_NO_ERROR ) - sResult = "FAIL"; - else - sResult = "OK"; - - } else if( sLockCmd == "RL" ){ - // record lock - if(( iRc2 = MyFile->LockRecord( XB_LOCK, 1 )) != XB_NO_ERROR ) - sResult = "FAIL"; - else - sResult = "OK"; - - - } else if( sLockCmd == "RU" ){ - // record unlock - if(( iRc2 = MyFile->LockRecord( XB_UNLOCK, 1 )) != XB_NO_ERROR ) - sResult = "FAIL"; - else - sResult = "OK"; - - } else if( sLockCmd == "ML" ){ - // memo lock - #ifdef XB_MEMO_SUPPORT - if(( iRc2 = MyFile->LockMemo( XB_LOCK )) != XB_NO_ERROR ) - sResult = "FAIL"; - else - sResult = "OK"; - #else - sLockCmd = "OK"; - #endif - - } else if( sLockCmd == "MU" ){ - // memo unlock - #ifdef XB_MEMO_SUPPORT - if(( iRc2 = MyFile->LockMemo( XB_UNLOCK )) != XB_NO_ERROR ) - sResult = "FAIL"; - else - sResult = "OK"; - #else - sLockCmd = "OK"; - #endif - } - #ifdef XB_LOGGING_SUPPORT - sMsg.Sprintf( "Program [%s] Child task [%s] Result [%s] RC = [%d]", av[0], sLockCmd.Str(), sResult.Str(), iRc2 ); - x.WriteLogMessage( sMsg ); - #endif - SetCmd( x, sLockFile, sResult, 'C', po ); - } - } else { - iRc = iRc2; - bDone = xbTrue; - } - - // std::cout << "clc [" << iChildLoop++ << "][" << bDone << "][" << sLockCmd << "]\n"; - x.xbSleep( 250 ); - if( iChildLoop > 10 ) - bDone = xbTrue; - } - MyFile->Close(); - delete MyFile; - if( po > 0 ) - std::cout << "Exiting child\n"; - - remove( sLockFile ); - #ifdef XB_LOGGING_SUPPORT - sMsg.Sprintf( "Program [%s] Child task terminating", av[0] ); - x.WriteLogMessage( sMsg ); - #endif - - if( po > 0 || iRc < 0 ) - fprintf( stdout, "Total Errors = %d\n", iRc * -1 ); - - #ifdef XB_LOGGING_SUPPORT - sMsg.Sprintf( "Program [%s] terminating with [%d] errors...", av[0], iRc * -1 ); - x.WriteLogMessage( sMsg ); - #endif - - ExitProcess( iRc ); -} - |