summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2023-03-11 18:15:37 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2023-03-11 18:15:37 +0100
commitdd70ff8bf32c2d7ed365004b1770058265db1978 (patch)
tree084788d142d86c4dc38f5c48606523b4040596e6 /src/utils
parent517ad9d4b6eae320b708d03a9340a22893b0cab7 (diff)
New upstream version 4.1.0upstream/4.1.0
Diffstat (limited to 'src/utils')
-rwxr-xr-xsrc/utils/xb_cfg_check.cpp84
-rwxr-xr-xsrc/utils/xb_copydbf.cpp78
-rwxr-xr-xsrc/utils/xb_dbfutil.cpp453
-rwxr-xr-xsrc/utils/xb_deletall.cpp54
-rwxr-xr-xsrc/utils/xb_dumpdbt.cpp54
-rwxr-xr-xsrc/utils/xb_dumphdr.cpp45
-rwxr-xr-xsrc/utils/xb_dumpix.cpp56
-rwxr-xr-xsrc/utils/xb_dumprecs.cpp60
-rwxr-xr-xsrc/utils/xb_execsql.cpp2
-rwxr-xr-xsrc/utils/xb_pack.cpp54
-rwxr-xr-xsrc/utils/xb_tblinfo.cpp105
-rwxr-xr-xsrc/utils/xb_undelall.cpp53
-rwxr-xr-xsrc/utils/xb_zap.cpp52
13 files changed, 633 insertions, 517 deletions
diff --git a/src/utils/xb_cfg_check.cpp b/src/utils/xb_cfg_check.cpp
index 25ca46c..5489c51 100755
--- a/src/utils/xb_cfg_check.cpp
+++ b/src/utils/xb_cfg_check.cpp
@@ -1,3 +1,19 @@
+/* xb_cfg_check.cpp
+
+XBase64 Software Library
+
+Copyright (c) 1997,2003,2014,2019,2023 Gary A Kunkel
+
+The xb64 software library is covered under
+the terms of the GPL Version 3, 2007 license.
+
+Email Contact:
+
+ xb64-devel@lists.sourceforge.net
+ xb64-users@lists.sourceforge.net
+
+*/
+
#include <stdio.h>
#include <stdlib.h>
@@ -23,7 +39,7 @@ int main()
fprintf( stdout, "CMAKE C FLAGS = [%s]\n", CMAKE_C_FLAGS );
fprintf( stdout, "CMAKE C FLAGS DEBUG = [%s]\n", CMAKE_C_FLAGS_DEBUG );
fprintf( stdout, "CMAKE C FLAGS RELEASE = [%s]\n", CMAKE_C_FLAGS_RELEASE );
-
+
#ifdef XB_PLATFORM_32
fprintf( stdout, "XB_PLATFORM_32 = [TRUE]\n" );
@@ -124,13 +140,13 @@ int main()
fprintf( stdout, "XB_INDEX_SUPPORT = [OFF]\n" );
#endif
- #ifdef XB_INDEX_SUPPORT
+ #ifdef XB_NDX_SUPPORT
fprintf( stdout, "XB_NDX_SUPPORT = [ON]\n" );
#else
fprintf( stdout, "XB_NDX_SUPPORT = [OFF]\n" );
#endif
- #ifdef XB_INDEX_SUPPORT
+ #ifdef XB_MDX_SUPPORT
fprintf( stdout, "XB_MDX_SUPPORT = [ON]\n" );
#else
fprintf( stdout, "XB_MDX_SUPPORT = [OFF]\n" );
@@ -142,6 +158,24 @@ int main()
fprintf( stdout, "XB_SQL_SUPPORT = [OFF]\n" );
#endif
+ #ifdef XB_INF_SUPPORT
+ fprintf( stdout, "XB_INF_SUPPORT = [ON]\n" );
+ #else
+ fprintf( stdout, "XB_INF_SUPPORT = [OFF]\n" );
+ #endif
+
+ #ifdef XB_FILTER_SUPPORT
+ fprintf( stdout, "XB_FILTER_SUPPORT = [ON]\n" );
+ #else
+ fprintf( stdout, "XB_FILTER_SUPPORT = [OFF]\n" );
+ #endif
+
+ #ifdef XB_BLOCKREAD_SUPPORT
+ fprintf( stdout, "XB_BLOCKREAD_SUPPORT = [ON]\n" );
+ #else
+ fprintf( stdout, "XB_BLOCKREAD_SUPPORT = [OFF]\n" );
+ #endif
+
fprintf( stdout, "\nDirectories:\n" );
fprintf( stdout, "HOME_DIRECTORY = [%s]\n", CMAKE_HOME_DIRECTORY );
@@ -159,32 +193,32 @@ int main()
fprintf( stdout, "Field sizes:\n" );
fprintf( stdout, "SIZEOF_VOID_P = [%s]\n", CMAKE_SIZEOF_VOID_P );
- fprintf( stdout, "sizeof(char *) = [%ld]\n", sizeof( char *));
- fprintf( stdout, "sizeof(int) = [%ld]\n", sizeof( int ));
- fprintf( stdout, "sizeof(long) = [%ld]\n", sizeof( long ));
- fprintf( stdout, "sizeof(char) = [%ld]\n", sizeof( char ));
+ fprintf( stdout, "sizeof(char *) = [%zd]\n", sizeof( char *));
+ fprintf( stdout, "sizeof(int) = [%zd]\n", sizeof( int ));
+ fprintf( stdout, "sizeof(long) = [%zd]\n", sizeof( long ));
+ fprintf( stdout, "sizeof(char) = [%zd]\n", sizeof( char ));
#ifdef HAVE_WCHAR_H
- fprintf( stdout, "sizeof(wchar_t) = [%ld]\n", sizeof( wchar_t ));
+ fprintf( stdout, "sizeof(wchar_t) = [%zd]\n", sizeof( wchar_t ));
#endif
#ifdef HAVE_WINDOWS_H
- fprintf( stdout, "sizeof(DWORD) = [%ld]\n", sizeof( DWORD ));
- #endif
-
- fprintf( stdout, "sizeof(double) = [%ld]\n", sizeof( double ));
- fprintf( stdout, "sizeof(float) = [%ld]\n", sizeof( float ));
- fprintf( stdout, "sizeof(size_t) = [%ld]\n", sizeof( size_t ));
- fprintf( stdout, "sizeof(off_t) = [%ld]\n\n", sizeof( off_t ));
-
- fprintf( stdout, "sizeof(xbBool) = [%ld]\n", sizeof( xbBool ));
- fprintf( stdout, "sizeof(xbInt16) = [%ld]\n", sizeof( xbInt16 ));
- fprintf( stdout, "sizeof(xbUInt16) = [%ld]\n", sizeof( xbUInt16 ));
- fprintf( stdout, "sizeof(xbInt32) = [%ld]\n", sizeof( xbInt32 ));
- fprintf( stdout, "sizeof(xbUInt32) = [%ld]\n", sizeof( xbUInt32 ));
- fprintf( stdout, "sizeof(xbInt64) = [%ld]\n", sizeof( xbInt64 ));
- fprintf( stdout, "sizeof(xbUInt64) = [%ld]\n", sizeof( xbUInt64 ));
- fprintf( stdout, "sizeof(xbFloat) = [%lu]\n", sizeof( xbFloat ));
- fprintf( stdout, "sizeof(xbDouble) = [%lu]\n", sizeof( xbDouble ));
+ fprintf( stdout, "sizeof(DWORD) = [%zd]\n", sizeof( DWORD ));
+ #endif
+
+ fprintf( stdout, "sizeof(double) = [%zd]\n", sizeof( double ));
+ fprintf( stdout, "sizeof(float) = [%zd]\n", sizeof( float ));
+ fprintf( stdout, "sizeof(size_t) = [%zd]\n", sizeof( size_t ));
+ fprintf( stdout, "sizeof(off_t) = [%zd]\n\n", sizeof( off_t ));
+
+ fprintf( stdout, "sizeof(xbBool) = [%zd]\n", sizeof( xbBool ));
+ fprintf( stdout, "sizeof(xbInt16) = [%zd]\n", sizeof( xbInt16 ));
+ fprintf( stdout, "sizeof(xbUInt16) = [%zd]\n", sizeof( xbUInt16 ));
+ fprintf( stdout, "sizeof(xbInt32) = [%zd]\n", sizeof( xbInt32 ));
+ fprintf( stdout, "sizeof(xbUInt32) = [%zd]\n", sizeof( xbUInt32 ));
+ fprintf( stdout, "sizeof(xbInt64) = [%zd]\n", sizeof( xbInt64 ));
+ fprintf( stdout, "sizeof(xbUInt64) = [%zd]\n", sizeof( xbUInt64 ));
+ fprintf( stdout, "sizeof(xbFloat) = [%zu]\n", sizeof( xbFloat ));
+ fprintf( stdout, "sizeof(xbDouble) = [%zu]\n", sizeof( xbDouble ));
fprintf( stdout, "\nHeader files:\n" );
diff --git a/src/utils/xb_copydbf.cpp b/src/utils/xb_copydbf.cpp
index 1f88eb9..2466b1b 100755
--- a/src/utils/xb_copydbf.cpp
+++ b/src/utils/xb_copydbf.cpp
@@ -2,7 +2,7 @@
XBase64 Software Library
-Copyright (c) 1997,2003,2014,2019 Gary A Kunkel
+Copyright (c) 1997,2003,2014,2019,2023 Gary A Kunkel
The xb64 software library is covered under
the terms of the GPL Version 3, 2007 license.
@@ -17,42 +17,80 @@ Email Contact:
#include <xbase.h>
using namespace xb;
-int main(int ac,char** av)
+
+void PrintHelp();
+void PrintHelp(){
+ std::cout << "Usage: xb_copydbf [-h] [-?] [--help] [-v] [--version] -s source.DBF -t target.DBF" << std::endl << std::endl;
+ std::cout << "This program copies the structure of a table defined in source.DBF to target.DBF. Data and indices are not included.";
+ std::cout << std::endl << std::endl;
+}
+void PrintVersion();
+void PrintVersion(){
+ std::cout << "Xbase64 Version: " << xbase_VERSION_MAJOR << "." << xbase_VERSION_MINOR << "." << xbase_VERSION_PATCH << std::endl;
+}
+
+
+int main(int argc, char *argv[])
{
- if (3 != ac) {
- std::cout <<
- "\nUsage: xb_copydbf filename1 filename2\n"
- "This program copies the structure of one dbf file to another\n";
+
+ xbXBase x;
+ xbInt16 iRc;
+ xbDbf *dSrc = NULL;
+ xbDbf *dTrg = NULL;
+
+ xbString sParm;
+ xbString sSrcDbf;
+ xbString sTrgDbf;
+
+ if (argc < 2 || x.GetCmdLineOpt( argc, argv, "-h", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "-?", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "--help", sParm )){
+ PrintHelp();
+ return 1;
+ }
+
+ if ( x.GetCmdLineOpt( argc, argv, "-v", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "--version", sParm )){
+ PrintVersion();
return 1;
}
- char* sFileName = av[1];
- char* tFileName = av[2];
+ if( !x.GetCmdLineOpt( argc, argv, "-s", sSrcDbf ) || sSrcDbf == "" ){
+ PrintHelp();
+ return 1;
+ }
- xbXBase x;
- xbInt16 iRc;
- xbDbf *MyFile = NULL;
- xbDbf *MyNewFile = NULL;
+ if( !x.GetCmdLineOpt( argc, argv, "-t", sTrgDbf ) || sTrgDbf == "" ){
+ PrintHelp();
+ return 1;
+ }
#ifdef XB_LOGGING_SUPPORT
x.EnableMsgLogging();
xbString sMsg;
- sMsg.Sprintf( "Program [%s] initializing...", av[0] );
+ sMsg.Sprintf( "Program [%s] initializing...", argv[0] );
x.WriteLogMessage( sMsg );
#endif
- if(( iRc = x.OpenHighestVersion( sFileName, "", &MyFile )) != XB_NO_ERROR ){
- std::cout << "Could not open file iRc = " << iRc << " file = " << sFileName << std::endl;
+ if(( iRc = x.OpenHighestVersion( sSrcDbf, "", &dSrc )) != XB_NO_ERROR ){
+ std::cout << "Could not open file iRc = " << iRc << " file = " << sSrcDbf.Str() << std::endl;
x.DisplayError( iRc );
- return 0;
+ return 1;
}
- if(( iRc = MyFile->CopyDbfStructure( MyNewFile, tFileName, tFileName, XB_DONTOVERLAY, XB_SINGLE_USER )) != XB_NO_ERROR ){
- std::cout << "Could not copy file " << tFileName << " Error = " << iRc << "\n";
- return 3;
+ #ifdef XB_DBF4_SUPPORT
+ dTrg = new xbDbf4( &x );
+ #else
+ dTrg = new xbDbf3( &x );
+ #endif
+
+ if(( iRc = dSrc->CopyDbfStructure( dTrg, sTrgDbf, sTrgDbf, XB_DONTOVERLAY, XB_SINGLE_USER )) != XB_NO_ERROR ){
+ std::cout << "Could not copy file " << sTrgDbf.Str() << " Error = " << iRc << "\n";
+ x.DisplayError( iRc );
+ return 1;
}
- MyFile->Close();
+ x.CloseAllTables();
return 0;
}
diff --git a/src/utils/xb_dbfutil.cpp b/src/utils/xb_dbfutil.cpp
index 9c04fe3..e50495e 100755
--- a/src/utils/xb_dbfutil.cpp
+++ b/src/utils/xb_dbfutil.cpp
@@ -2,7 +2,7 @@
XBase64 Software Library
-Copyright (c) 1997,2003,2014,2021 Gary A Kunkel
+Copyright (c) 1997,2003,2014,2021,2022,2023 Gary A Kunkel
The xb64 software library is covered under
the terms of the GPL Version 3, 2007 license.
@@ -29,11 +29,13 @@ using namespace xb;
///@cond DOXYOFF
class xbUtil{
public:
- xbUtil();
+ xbUtil( xbXBase *x );
~xbUtil();
xbDbf *GetTablePtr( const char * cTitle );
void DisplayActiveTable() const;
+ void Help();
+
// menus
xbInt16 GetOption();
xbInt32 GetLong();
@@ -215,8 +217,8 @@ class xbUtil{
private:
- xbXBase x;
- xbDbf * dActiveTable;
+ xbXBase *x;
+ xbDbf *dActiveTable;
#ifdef XB_EXPRESSION_SUPPORT
xbExp *exp;
@@ -233,18 +235,19 @@ class xbUtil{
};
/*************************************************************************************/
-xbUtil::xbUtil()
+xbUtil::xbUtil( xbXBase *x )
{
+ this->x = x;
dActiveTable = NULL;
- x.EnableMsgLogging();
- x.SetLogSize( 10000000L );
+ x->EnableMsgLogging();
+ x->SetLogSize( 10000000L );
#ifdef XB_EXPRESSION_SUPPORT
exp = NULL;
#endif
#ifdef XB_SQL_SUPPORT
- sql = new xbSql( &x );
+ sql = new xbSql( x );
#endif // XB_SQL_SUPPORT
#ifdef XB_FILTER_SUPPORT
@@ -256,7 +259,7 @@ xbUtil::xbUtil()
/*************************************************************************************/
xbUtil::~xbUtil(){
- x.CloseAllTables();
+ x->CloseAllTables();
if( dActiveTable )
delete dActiveTable;
@@ -272,6 +275,17 @@ xbUtil::~xbUtil(){
#endif // XB_FILTER_SUPPORT
}
+
+/*************************************************************************************/
+void xbUtil::Help(){
+ std::cout << "Program xb_dbfutil provides a menu driven application for accessing" << std::endl;
+ std::cout << "the xbase64 library functions." << std::endl << std::endl;
+ std::cout << "Menu choices can be selected directly with out accessing the given menus" << std::endl;
+ std::cout << "by entering a '=' followed by the menu choices. For example, entering '=3.4'" << std::endl;
+ std::cout << "would be the same as going to menu #3 and entering a 4, which is the sequence" << std::endl;
+ std::cout << "for opening a file." << std::endl;
+}
+
/*************************************************************************************/
#ifdef XB_NDXINF_SUPPORT
@@ -294,7 +308,7 @@ void xbUtil::AddInfFileData()
std::cout << "Enter NDX index file name (FILENAME.NDX)" << std::endl;
std::cin.getline( cBuf, 128 );
xbInt16 iRc = dActiveTable->AssociateIndex( "NDX", cBuf, 0 );
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::DeleteInfFileData()
@@ -303,7 +317,7 @@ void xbUtil::DeleteInfFileData()
std::cout << "Enter NDX index file name (FILENAME.NDX)" << std::endl;
std::cin.getline( cBuf, 128 );
xbInt16 iRc = dActiveTable->AssociateIndex( "NDX", cBuf, 1 );
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::InfFileHelp()
@@ -329,7 +343,7 @@ void xbUtil::LockIndices(){
return;
}
xbInt16 iRc = dActiveTable->LockIndices( XB_LOCK );
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::UnlockIndices(){
@@ -343,7 +357,7 @@ void xbUtil::UnlockIndices(){
return;
}
xbInt16 iRc = dActiveTable->LockIndices( XB_UNLOCK );
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
#endif // XB_LOCKING_SUPPORT
@@ -381,11 +395,11 @@ void xbUtil::ParseExpression( xbInt16 iOption ){
exp = NULL;
}
- exp = new xbExp( &x, dActiveTable );
+ exp = new xbExp( x, dActiveTable );
iRc = exp->ParseExpression( sExpression );
if( iOption == 0 )
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
/*************************************************************************************/
@@ -404,7 +418,7 @@ void xbUtil::ProcessParsedExpression( xbInt16 iOption ){
xbInt16 iRc = exp->ProcessExpression();
if( iRc != XB_NO_ERROR ){
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
return;
}
@@ -496,7 +510,7 @@ void xbUtil::IsLeapYear(){
#ifdef XB_SQL_SUPPORT
void xbUtil::ExecSqlNonQuery(){
- xbSql sql( &x );
+ xbSql sql( x );
std::cout << "ExecSqlNonQuery\n";
char sSql[2048];
@@ -504,7 +518,7 @@ void xbUtil::ExecSqlNonQuery(){
std::cin.getline( sSql, 2048 );
xbInt16 iRc = sql.ExecuteNonQuery( sSql );
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::ExecSqlQuery(){
@@ -681,7 +695,7 @@ void xbUtil::LockDbf(){
xbInt16 iRc;
std::cout << std::endl << "Lock Table" << std::endl;
iRc = dActiveTable->LockTable( XB_LOCK );
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::LockAppend(){
@@ -696,7 +710,7 @@ void xbUtil::LockAppend(){
xbInt16 iRc;
std::cout << std::endl << "Lock Append" << std::endl;
iRc = dActiveTable->LockAppend( XB_LOCK );
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::UnlockAppend(){
@@ -711,7 +725,7 @@ void xbUtil::UnlockAppend(){
xbInt16 iRc;
std::cout << std::endl << "Unlock Append" << std::endl;
iRc = dActiveTable->LockAppend( XB_UNLOCK );
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
#ifdef XB_MEMO_SUPPORT
void xbUtil::LockMemo(){
@@ -726,7 +740,7 @@ void xbUtil::LockMemo(){
xbInt16 iRc;
std::cout << std::endl << "Lock Memo" << std::endl;
iRc = dActiveTable->LockMemo( XB_LOCK );
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::UnlockMemo(){
@@ -741,7 +755,7 @@ void xbUtil::UnlockMemo(){
xbInt16 iRc;
std::cout << std::endl << "Unlock Memo" << std::endl;
iRc = dActiveTable->LockMemo( XB_UNLOCK );
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
#endif
@@ -760,8 +774,10 @@ void xbUtil::LockRecord(){
char cBuf[15];
std::cin.getline( cBuf, 15 );
- iRc = dActiveTable->LockRecord( XB_LOCK, atol( cBuf ));
- x.DisplayError( iRc );
+ //iRc = dActiveTable->LockRecord( XB_LOCK, atol( cBuf ));
+ iRc = dActiveTable->LockRecord( XB_LOCK, strtoul( cBuf, NULL, 0 ));
+
+ x->DisplayError( iRc );
}
void xbUtil::UnlockRecord(){
@@ -779,8 +795,9 @@ void xbUtil::UnlockRecord(){
char cBuf[15];
std::cin.getline( cBuf, 15 );
- iRc = dActiveTable->LockRecord( XB_UNLOCK, atol( cBuf ));
- x.DisplayError( iRc );
+ //iRc = dActiveTable->LockRecord( XB_UNLOCK, atol( cBuf ));
+ iRc = dActiveTable->LockRecord( XB_UNLOCK, strtoul( cBuf, NULL, 0 ));
+ x->DisplayError( iRc );
}
void xbUtil::UnlockDbf(){
@@ -796,7 +813,7 @@ void xbUtil::UnlockDbf(){
xbInt16 iRc;
std::cout << std::endl << "Unlock Table" << std::endl;
iRc = dActiveTable->LockTable( XB_UNLOCK );
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::UnlockHeader(){
@@ -812,7 +829,7 @@ void xbUtil::UnlockHeader(){
xbInt16 iRc;
std::cout << std::endl << "Unlock Table Header" << std::endl;
iRc = dActiveTable->LockHeader( XB_UNLOCK );
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::LockHeader(){
@@ -826,7 +843,7 @@ void xbUtil::LockHeader(){
xbInt16 iRc;
std::cout << std::endl << "Lock Table Header" << std::endl;
iRc = dActiveTable->LockHeader( XB_LOCK );
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
#ifdef XB_DEBUG_SUPPORT
@@ -860,7 +877,7 @@ void xbUtil::xbFileLock(){
s1 = cBufLen;
s1.CvtLongLong( llLen );
xbInt16 iRc = dActiveTable->xbLock( XB_LOCK, llSpos, (size_t) llLen );
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::xbFileUnlock(){
@@ -884,7 +901,7 @@ void xbUtil::xbFileUnlock(){
}
xbInt16 iRc;
iRc = dActiveTable->xbLock( XB_UNLOCK, atol( cBufOffset ), (size_t) atol( cBufLen ));
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
#endif
@@ -968,7 +985,7 @@ void xbUtil::UpdateFieldData(){
std::cin.getline( cFldData, 256 );
if(( rc = dActiveTable->PutField( cFldName, cFldData )) != XB_NO_ERROR ){
- x.DisplayError( rc );
+ x->DisplayError( rc );
return;
}
std::cout << "Success" << std::endl;
@@ -999,9 +1016,10 @@ void xbUtil::ShowMemoFieldData(){
std::cout << "Record number not entered" << std::endl;
return;
}
- ulRecNo = atol( cBuf );
+ //ulRecNo = atol( cBuf );
+ ulRecNo = strtoul( cBuf, NULL, 0 );
if(( rc = dActiveTable->GetRecord( ulRecNo )) != XB_NO_ERROR ){
- x.DisplayError( rc );
+ x->DisplayError( rc );
return;
}
}
@@ -1009,12 +1027,12 @@ void xbUtil::ShowMemoFieldData(){
std::cin.getline( cFldName, 40 );
if(( rc = dActiveTable->GetMemoField( cFldName, sMemoData )) != XB_NO_ERROR ){
std::cout << "rc = " << rc << std::endl;
- x.DisplayError( rc );
+ x->DisplayError( rc );
return;
}
if(( rc = dActiveTable->GetMemoFieldLen( cFldName, ulFldLen )) != XB_NO_ERROR ){
std::cout << "rc = " << rc << std::endl;
- x.DisplayError( rc );
+ x->DisplayError( rc );
return;
}
std::cout << sMemoData.Str() << std::endl;
@@ -1047,9 +1065,10 @@ void xbUtil::UpdateMemoFieldData(){
std::cout << "Record number not entered" << std::endl;
return;
}
- ulRecNo = atol( cBuf );
+ //ulRecNo = atol( cBuf );
+ ulRecNo = strtoul( cBuf, NULL, 0 );
if(( rc = dActiveTable->GetRecord( ulRecNo )) != XB_NO_ERROR ){
- x.DisplayError( rc );
+ x->DisplayError( rc );
return;
}
}
@@ -1059,13 +1078,13 @@ void xbUtil::UpdateMemoFieldData(){
std::cin.getline( cMemoData, 2048 );
if(( rc = dActiveTable->UpdateMemoField( cFldName, cMemoData )) != XB_NO_ERROR ){
std::cout << "rc = " << rc << std::endl;
- x.DisplayError( rc );
+ x->DisplayError( rc );
return;
}
if(( rc = dActiveTable->PutRecord( dActiveTable->GetCurRecNo())) != XB_NO_ERROR ){
std::cout << "rc = " << rc << std::endl;
- x.DisplayError( rc );
+ x->DisplayError( rc );
return;
}
}
@@ -1098,9 +1117,10 @@ void xbUtil::DeleteMemoField(){
std::cout << "Record number not entered" << std::endl;
return;
}
- ulRecNo = atol( cBuf );
+ //ulRecNo = atol( cBuf );
+ ulRecNo = strtoul( cBuf, NULL, 0 );
if(( rc = dActiveTable->GetRecord( ulRecNo )) != XB_NO_ERROR ){
- x.DisplayError( rc );
+ x->DisplayError( rc );
return;
}
}
@@ -1108,12 +1128,12 @@ void xbUtil::DeleteMemoField(){
std::cin.getline( cFldName, 40 );
if(( rc = dActiveTable->UpdateMemoField( cFldName, "" )) != XB_NO_ERROR ){
std::cout << "rc = " << rc << std::endl;
- x.DisplayError( rc );
+ x->DisplayError( rc );
return;
}
if(( rc = dActiveTable->PutRecord( dActiveTable->GetCurRecNo())) != XB_NO_ERROR ){
std::cout << "rc = " << rc << std::endl;
- x.DisplayError( rc );
+ x->DisplayError( rc );
return;
}
}
@@ -1123,13 +1143,13 @@ void xbUtil::SelectActiveTable(){
char cBuf[15];
xbInt16 iLineNo;
- if( x.GetOpenTableCount() == 0 ){
+ if( x->GetOpenTableCount() == 0 ){
std::cout << "No open tables" << std::endl;
std::cout << "Use menu option =3.4 to open a table" << std::endl;
return;
}
- x.DisplayTableList();
+ x->DisplayTableList();
std::cout << std::endl << "Enter line number:" << std::endl;
std::cin.getline( cBuf, 15 );
if( strlen( cBuf ) == 0 ){
@@ -1137,7 +1157,7 @@ void xbUtil::SelectActiveTable(){
return;
}
iLineNo = atoi( cBuf );
- dActiveTable = x.GetDbfPtr( iLineNo );
+ dActiveTable = x->GetDbfPtr( iLineNo );
}
/*************************************************************************************/
@@ -1157,7 +1177,7 @@ void xbUtil::CommitRecord(){
if(( rc = dActiveTable->Commit()) == XB_NO_ERROR )
std::cout << "Success" << std::endl;
else
- x.DisplayError( rc );
+ x->DisplayError( rc );
}
/*************************************************************************************/
void xbUtil::AbortRecord(){
@@ -1176,14 +1196,14 @@ void xbUtil::AbortRecord(){
if(( rc = dActiveTable->Abort()) == XB_NO_ERROR )
std::cout << "Success" << std::endl;
else
- x.DisplayError( rc );
+ x->DisplayError( rc );
}
/*************************************************************************************/
void xbUtil::DumpRecord(){
char cBuf[15];
xbInt16 rc;
- xbUInt32 lRecNo;
+ xbUInt32 ulRecNo;
if( !dActiveTable )
dActiveTable = GetTablePtr( " - select table" );
if( !dActiveTable ){
@@ -1199,9 +1219,10 @@ void xbUtil::DumpRecord(){
std::cout << "Record number not entered" << std::endl;
return;
}
- lRecNo = atol( cBuf );
- if(( rc = dActiveTable->GetRecord( lRecNo )) != XB_NO_ERROR ){
- x.DisplayError( rc );
+ //lRecNo = atol( cBuf );
+ ulRecNo = strtoul( cBuf, NULL, 0 );
+ if(( rc = dActiveTable->GetRecord( ulRecNo )) != XB_NO_ERROR ){
+ x->DisplayError( rc );
return;
}
}
@@ -1209,7 +1230,7 @@ void xbUtil::DumpRecord(){
if(( rc = dActiveTable->DumpRecord( dActiveTable->GetCurRecNo(), 2 )) == XB_NO_ERROR )
std::cout << "Success" << std::endl;
else
- x.DisplayError( rc );
+ x->DisplayError( rc );
}
/*************************************************************************************/
void xbUtil::GetFirstRecord(){
@@ -1227,7 +1248,7 @@ void xbUtil::GetFirstRecord(){
if(( iRc = dActiveTable->GetFirstRecord()) == XB_NO_ERROR )
dActiveTable->DumpRecord( dActiveTable->GetCurRecNo(), 2);
else
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
/*************************************************************************************/
void xbUtil::GetNextRecord(){
@@ -1242,7 +1263,7 @@ void xbUtil::GetNextRecord(){
if(( iRc = dActiveTable->GetNextRecord()) == XB_NO_ERROR )
dActiveTable->DumpRecord( dActiveTable->GetCurRecNo(), 2);
else
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
/*************************************************************************************/
void xbUtil::GetPrevRecord(){
@@ -1257,7 +1278,7 @@ void xbUtil::GetPrevRecord(){
if(( iRc = dActiveTable->GetPrevRecord()) == XB_NO_ERROR )
dActiveTable->DumpRecord( dActiveTable->GetCurRecNo(), 2);
else
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
/*************************************************************************************/
void xbUtil::GetLastRecord(){
@@ -1274,15 +1295,15 @@ void xbUtil::GetLastRecord(){
if(( iRc = dActiveTable->GetLastRecord()) == XB_NO_ERROR )
dActiveTable->DumpRecord( dActiveTable->GetCurRecNo(),2);
else
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
/*************************************************************************************/
void xbUtil::UndeleteRecord(){
- char cBuf[15];
- xbInt16 rc;
- xbUInt32 lRecNo;
+ char cBuf[15];
+ xbInt16 rc;
+ xbUInt32 ulRecNo;
if( !dActiveTable )
dActiveTable = GetTablePtr( " - select table" );
@@ -1292,7 +1313,6 @@ void xbUtil::UndeleteRecord(){
return;
}
DisplayActiveTable();
-
if( dActiveTable->GetCurRecNo() == 0 ){
std::cout << "Enter Record number" << std::endl;
std::cin.getline( cBuf, 15 );
@@ -1300,29 +1320,30 @@ void xbUtil::UndeleteRecord(){
std::cout << "Record number not entered" << std::endl;
return;
}
- lRecNo = atol( cBuf );
- if(( rc = dActiveTable->GetRecord( lRecNo )) != XB_NO_ERROR ){
- x.DisplayError( rc );
+ //lRecNo = atol( cBuf );
+ ulRecNo = strtoul( cBuf, NULL, 0 );
+ if(( rc = dActiveTable->GetRecord( ulRecNo )) != XB_NO_ERROR ){
+ x->DisplayError( rc );
return;
}
}
-
if(( dActiveTable->RecordDeleted()) == xbFalse )
std::cout << "Record is not flagged for deletion" << std::endl;
else{
if(( rc = dActiveTable->UndeleteRecord()) == XB_NO_ERROR )
std::cout << "Success" << std::endl;
else
- x.DisplayError( rc );
+ x->DisplayError( rc );
}
}
/*************************************************************************************/
void xbUtil::DeleteRecord(){
- char cBuf[15];
- xbInt16 rc;
- xbUInt32 lRecNo;
+ char cBuf[15];
+ xbInt16 rc;
+ xbUInt32 ulRecNo;
+
if( !dActiveTable )
dActiveTable = GetTablePtr( " - select table" );
if( !dActiveTable ){
@@ -1337,9 +1358,11 @@ void xbUtil::DeleteRecord(){
std::cout << "Record number not entered" << std::endl;
return;
}
- lRecNo = atol( cBuf );
- if(( rc = dActiveTable->GetRecord( lRecNo )) != XB_NO_ERROR ){
- x.DisplayError( rc );
+ //ulRecNo = atol( cBuf );
+
+ ulRecNo = strtoul( cBuf, NULL, 0 );
+ if(( rc = dActiveTable->GetRecord( ulRecNo )) != XB_NO_ERROR ){
+ x->DisplayError( rc );
return;
}
}
@@ -1350,16 +1373,16 @@ void xbUtil::DeleteRecord(){
if(( rc = dActiveTable->DeleteRecord()) == XB_NO_ERROR )
std::cout << "Success" << std::endl;
else
- x.DisplayError( rc );
+ x->DisplayError( rc );
}
}
/*************************************************************************************/
void xbUtil::PutRecord(){
- char cBuf[15];
- xbInt16 rc;
- xbUInt32 lRecNo;
+ char cBuf[15];
+ xbInt16 rc;
+ xbUInt32 ulRecNo;
if( !dActiveTable )
dActiveTable = GetTablePtr( " - select table" );
@@ -1376,11 +1399,12 @@ void xbUtil::PutRecord(){
std::cout << "Record number not entered" << std::endl;
return;
}
- lRecNo = atol( cBuf );
- if(( rc = dActiveTable->PutRecord( lRecNo )) == XB_NO_ERROR )
+ //lRecNo = atol( cBuf );
+ ulRecNo = strtoul( cBuf, NULL, 0 );
+ if(( rc = dActiveTable->PutRecord( ulRecNo )) == XB_NO_ERROR )
std::cout << "Success" << std::endl;
else
- x.DisplayError( rc );
+ x->DisplayError( rc );
}
/*************************************************************************************/
@@ -1396,7 +1420,7 @@ void xbUtil::AppendRecord(){
if(( rc = dActiveTable->AppendRecord()) == XB_NO_ERROR )
std::cout << "Success" << std::endl;
else
- x.DisplayError( rc );
+ x->DisplayError( rc );
}
/*************************************************************************************/
@@ -1412,7 +1436,7 @@ void xbUtil::BlankRecord(){
if(( rc = dActiveTable->BlankRecord()) == XB_NO_ERROR )
std::cout << "Success" << std::endl;
else
- x.DisplayError( rc );
+ x->DisplayError( rc );
}
/*************************************************************************************/
@@ -1449,16 +1473,14 @@ void xbUtil::RenameTable(){
dActiveTable = NULL;
std::cout << "Table closed. Reopen if needed.\n";
}
-
-
}
/*************************************************************************************/
void xbUtil::GetRecord(){
- char cBuf[15];
- xbInt16 iRc;
- xbUInt32 lRecNo;
+ char cBuf[15];
+ xbInt16 iRc;
+ xbUInt32 ulRecNo;
if( !dActiveTable )
dActiveTable = GetTablePtr( " - select table" );
@@ -1476,11 +1498,12 @@ void xbUtil::GetRecord(){
std::cout << "Record number not entered" << std::endl;
return;
}
- lRecNo = atol( cBuf );
- if(( iRc = dActiveTable->GetRecord( lRecNo )) == XB_NO_ERROR )
+ //lRecNo = atol( cBuf );
+ ulRecNo = strtoul( cBuf, NULL, 0 );
+ if(( iRc = dActiveTable->GetRecord( ulRecNo )) == XB_NO_ERROR )
dActiveTable->DumpRecord( dActiveTable->GetCurRecNo(), 2);
else
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
/*************************************************************************************/
void xbUtil::DisplayActiveTable() const{
@@ -1513,7 +1536,7 @@ void xbUtil::DisplayActiveTable() const{
xbDbf * xbUtil::GetTablePtr( const char * cTitle ){
xbDbf *d;
- xbInt16 iOpenTableCnt = x.GetOpenTableCount();
+ xbInt16 iOpenTableCnt = x->GetOpenTableCount();
char cBuf[15];
xbInt16 iLineNo;
@@ -1521,10 +1544,10 @@ xbDbf * xbUtil::GetTablePtr( const char * cTitle ){
std::cout << "No open tables" << std::endl;
return NULL;
} else if( iOpenTableCnt == 1 ){
- d = x.GetDbfPtr( 1 );
+ d = x->GetDbfPtr( 1 );
} else {
std::cout << "Select file/table " << cTitle << std::endl;
- x.DisplayTableList();
+ x->DisplayTableList();
std::cout << std::endl << "Enter line number:" << std::endl;
memset( cBuf, 0x00, 15 );
std::cin.getline( cBuf, 15 );
@@ -1537,7 +1560,7 @@ xbDbf * xbUtil::GetTablePtr( const char * cTitle ){
std::cout << "Invalid selection. Valid line numbers are 1 through " << iOpenTableCnt << std::endl;
return NULL;
}
- d = x.GetDbfPtr( iLineNo );
+ d = x->GetDbfPtr( iLineNo );
}
return d;
}
@@ -1551,7 +1574,7 @@ void xbUtil::UpdateTableAutoCommit(){
std::cout << " If unsure, leave the option turned on at the DBMS level (default)" << std::endl;
std::cout << " and don't over ride the setting at the table level" << std::endl << std::endl;
std::cout << " -1 ==> Use DBMS setting which is currently [";
- if( x.GetDefaultAutoCommit() )
+ if( x->GetDefaultAutoCommit() )
std::cout << "ON]" << std::endl;
else
std::cout << "OFF]" << std::endl;
@@ -1584,7 +1607,7 @@ void xbUtil::CopyDbfStructure(){
xbDbf *d;
xbInt16 rc;
char filename[128];
- xbFile f( &x );
+ xbFile f( x );
xbDbf *dNewTable;
d = GetTablePtr( "" );
@@ -1592,14 +1615,14 @@ void xbUtil::CopyDbfStructure(){
if( d->GetVersion() == 3 ){
#ifdef XB_DBF3_SUPPORT
- dNewTable = new xbDbf3( &x );
+ dNewTable = new xbDbf3( x );
#else
std::cout << "Dbase III file support not build into library. See XB_DBF3_SUPPORT" << std::endl;
return;
#endif
} else if( d->GetVersion() == 4 ){
#ifdef XB_DBF4_SUPPORT
- dNewTable = new xbDbf4( &x );
+ dNewTable = new xbDbf4( x );
#else
std::cout << "Dbase IV file support not build into library. See XB_DBF4_SUPPORT" << std::endl;
return;
@@ -1622,13 +1645,13 @@ void xbUtil::CopyDbfStructure(){
}
if(( rc = d->CopyDbfStructure( dNewTable, filename, filename, 0, XB_MULTI_USER )) != XB_NO_ERROR ){
std::cout << "Error " << rc << " creating new file" << std::endl;
- x.DisplayError( rc );
+ x->DisplayError( rc );
return;
}
std::cout << "Table " << f.GetFqFileName().Str() << " created" << std::endl;
if(( rc = dNewTable->Close()) != XB_NO_ERROR ){
std::cout << "Error " << rc << " closing new file" << std::endl;
- x.DisplayError( rc );
+ x->DisplayError( rc );
return;
}
}
@@ -1649,7 +1672,7 @@ void xbUtil::ZapTable(){
if( iRc == XB_NO_ERROR )
std::cout << "Table Zapped (all rows deleted)" << std::endl;
else
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
/*************************************************************************************/
void xbUtil::Pack(){
@@ -1666,7 +1689,7 @@ void xbUtil::Pack(){
if( iRc == XB_NO_ERROR )
std::cout << "Table Packed" << std::endl;
else
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
/*************************************************************************************/
void xbUtil::DisplayTableStats(){
@@ -1699,7 +1722,7 @@ void xbUtil::DisplayTableStats(){
// DBMS settings
if( d->GetAutoCommit( 0 ) == -1 ){
std::cout << "Table Auto Commit = [Use DBMS Setting]" << std::endl;
- if( x.GetDefaultAutoCommit() )
+ if( x->GetDefaultAutoCommit() )
std::cout << "DBMS Auto Commit = [ON]" << std::endl;
else
std::cout << "DBMS Auto Commit = [OFF]" << std::endl;
@@ -1714,24 +1737,24 @@ void xbUtil::DisplayTableStats(){
/*************************************************************************************/
void xbUtil::CloseAllTables(){
- xbInt16 sOpenTableCnt = x.GetOpenTableCount();
+ xbInt16 sOpenTableCnt = x->GetOpenTableCount();
xbInt16 rc;
if( sOpenTableCnt == 0 ){
std::cout << "No open tables" << std::endl;
return;
}
- rc = x.CloseAllTables();
+ rc = x->CloseAllTables();
if( rc == XB_NO_ERROR )
std::cout << "All open tables closed" << std::endl;
else
- x.DisplayError( rc );
+ x->DisplayError( rc );
dActiveTable = NULL;
}
/*************************************************************************************/
void xbUtil::Close(){
xbDbf *d;
-// xbInt16 sOpenTableCnt = x.GetOpenTableCount();
+// xbInt16 sOpenTableCnt = x->GetOpenTableCount();
d = GetTablePtr( "to close" );
if( d ){
@@ -1746,7 +1769,7 @@ void xbUtil::Close(){
/*************************************************************************************/
void xbUtil::Open(){
xbInt16 rc;
- xbFile f( &x );
+ xbFile f( x );
xbDbf *dTable;
char filename[128];
unsigned char cFileTypeByte;
@@ -1766,18 +1789,18 @@ void xbUtil::Open(){
}
if(( rc = f.GetXbaseFileTypeByte( f.GetFqFileName(), cFileTypeByte )) != XB_NO_ERROR ){
std::cout << "Could not open file or determine file type rc = " << rc << " file = " << filename << std::endl;
- x.DisplayError( rc );
+ x->DisplayError( rc );
return;
}
std:: cout << "File Type Byte ";
- x.BitDump( cFileTypeByte );
+ x->BitDump( cFileTypeByte );
std::cout << "\n";
std::cout << "Table Type = [" << f.DetermineXbaseTableVersion( cFileTypeByte ) << "]\n";
std::cout << "Memo Type = [" << f.DetermineXbaseMemoVersion( cFileTypeByte ) << "]\n";
if( f.DetermineXbaseTableVersion( cFileTypeByte ) == 4 ){
#ifdef XB_DBF4_SUPPORT
- dTable = new xbDbf4( &x );
+ dTable = new xbDbf4( x );
#else
std::cout << "Dbase IV file support not build into library. See XB_DBF4_SUPPORT" << std::endl;
return;
@@ -1785,21 +1808,21 @@ void xbUtil::Open(){
} else if( f.DetermineXbaseTableVersion( cFileTypeByte ) == 3 ){
#ifdef XB_DBF3_SUPPORT
- dTable = new xbDbf3( &x );
+ dTable = new xbDbf3( x );
#else
std::cout << "Dbase III file support not build into library. See XB_DBF3_SUPPORT" << std::endl;
return;
#endif
} else {
std::cout << "Unsupported file type file = " << filename << " type = ";
- x.BitDump( cFileTypeByte );
+ x->BitDump( cFileTypeByte );
std::cout << std::endl;
return;
}
if(( rc = dTable->Open( filename )) != 0 ){
std::cout << "Could not open file rc = " << rc << " file = " << filename << std::endl;
- x.DisplayError( rc );
+ x->DisplayError( rc );
return;
}
@@ -1821,9 +1844,9 @@ void xbUtil::UpdateDefaultLockRetries(){
std::cout << "Default Lock Retry Count not updated" << std::endl;
return;
} else {
- x.SetDefaultLockRetries( atoi( cBuf ));
+ x->SetDefaultLockRetries( atoi( cBuf ));
std::cout << "Default Lock Retry Count updated to ["
- << x.GetDefaultLockRetries() << "]" << std::endl;
+ << x->GetDefaultLockRetries() << "]" << std::endl;
}
}
@@ -1835,9 +1858,9 @@ void xbUtil::UpdateDefaultLockWait(){
std::cout << "Default Lock Wait Time not updated" << std::endl;
return;
} else {
- x.SetDefaultLockWait( atoi( cBuf ));
+ x->SetDefaultLockWait( atoi( cBuf ));
std::cout << "Default Lock Wait Time updated to ["
- << x.GetDefaultLockWait() << "]" << std::endl;
+ << x->GetDefaultLockWait() << "]" << std::endl;
}
}
@@ -1854,38 +1877,38 @@ void xbUtil::UpdateDefaultLockFlavor(){
std::cout << "Default Lock Flavor not updated" << std::endl;
return;
} else {
- x.SetDefaultLockFlavor( atoi( cBuf ));
+ x->SetDefaultLockFlavor( atoi( cBuf ));
std::cout << "Default Lock Flavor updated to ["
- << x.GetDefaultLockFlavor() << "]" << std::endl;
+ << x->GetDefaultLockFlavor() << "]" << std::endl;
}
}
void xbUtil::ToggleDefaultAutoLock(){
- if( x.GetDefaultAutoLock()){
- x.DisableDefaultAutoLock();
- x.WriteLogMessage( "xb_dbfutil - Default Auto Lock disabled" );
+ if( x->GetDefaultAutoLock()){
+ x->DisableDefaultAutoLock();
+ x->WriteLogMessage( "xb_dbfutil - Default Auto Lock disabled" );
std::cout << "Default Auto Lock disabled" << std::endl;
} else {
- x.EnableDefaultAutoLock();
- x.WriteLogMessage( "xb_dbfutil - Default Auto Lock enabled" );
+ x->EnableDefaultAutoLock();
+ x->WriteLogMessage( "xb_dbfutil - Default Auto Lock enabled" );
std::cout << "Default Auto Lock enabled" << std::endl;
}
}
void xbUtil::ToggleMultiUserMode(){
- if( x.GetMultiUser()){
- x.SetMultiUser( xbFalse );
- x.WriteLogMessage( "xb_dbfutil - Multi user mode disabled" );
+ if( x->GetMultiUser()){
+ x->SetMultiUser( xbFalse );
+ x->WriteLogMessage( "xb_dbfutil - Multi user mode disabled" );
std::cout << "Multi user mode disabled" << std::endl;
} else {
- x.SetMultiUser( xbTrue );
- x.WriteLogMessage( "xb_dbfutil - Multu user mode enabled" );
+ x->SetMultiUser( xbTrue );
+ x->WriteLogMessage( "xb_dbfutil - Multu user mode enabled" );
std::cout << "Multi user mode enabled" << std::endl;
}
}
#endif
/*************************************************************************************/
void xbUtil::ListFilesInDataDirectory(){
- std::cout << "List files for [" << x.GetDataDirectory().Str() << "]" << std::endl << std::endl;
+ std::cout << "List files for [" << x->GetDataDirectory().Str() << "]" << std::endl << std::endl;
xbString s1;
xbInt16 iCnt = 0;
@@ -1894,7 +1917,7 @@ void xbUtil::ListFilesInDataDirectory(){
WIN32_FIND_DATA fData;
HANDLE hFile;
- xbString sSearchPath = x.GetDataDirectory();
+ xbString sSearchPath = x->GetDataDirectory();
xbUInt32 l = sSearchPath.Len();
char cPathSeperator = sSearchPath.GetPathSeparator();
char cLastChar = sSearchPath.GetCharacter( l );
@@ -1926,7 +1949,7 @@ void xbUtil::ListFilesInDataDirectory(){
DIR *dir;
struct dirent *ent;
- if(( dir = opendir( x.GetDataDirectory() )) != NULL ){
+ if(( dir = opendir( x->GetDataDirectory() )) != NULL ){
while(( ent = readdir( dir )) != NULL ){
s1 = ent->d_name;
if( s1 != "." && s1 != ".." ){
@@ -1947,20 +1970,20 @@ void xbUtil::UpdateLogDirectory(){
char cNewDir[256];
cNewDir[0] = 0x00;
std::cout << std::endl << "Update Log Directory" << std::endl;
- std::cout << "Current Log File Directory = [" << x.GetLogDirectory().Str() << "]" << std::endl;
+ std::cout << "Current Log File Directory = [" << x->GetLogDirectory().Str() << "]" << std::endl;
std::cout << "Enter '1' to erase the Log File Directory" << std::endl;
- std::cout << "Enter '2' to change Log File Directory to [" << x.GetDefaultLogDirectory().Str() << "]" << std::endl;
+ std::cout << "Enter '2' to change Log File Directory to [" << x->GetLogDirectory().Str() << "]" << std::endl;
std::cout << "Enter new log directory. Enter for no updates." << std::endl;
std::cin.getline( cNewDir, 256 );
if( strlen( cNewDir ) > 0 ){
if( cNewDir[0] == '1' )
- x.SetLogDirectory( "" );
+ x->SetLogDirectory( "" );
else if( cNewDir[0] == '2' )
- x.SetLogDirectory( x.GetDefaultLogDirectory());
+ x->SetLogDirectory( x->GetLogDirectory());
else
- x.SetLogDirectory( cNewDir );
+ x->SetLogDirectory( cNewDir );
- std::cout << "Log File Directory is [" << x.GetLogDirectory().Str() << "]" << std::endl;
+ std::cout << "Log File Directory is [" << x->GetLogDirectory().Str() << "]" << std::endl;
}
else
std::cout << "Log Directory not updated" << std::endl;
@@ -1971,51 +1994,51 @@ void xbUtil::UpdateLogFileName(){
cNewFile[0] = 0x00;
std::cout << std::endl << "Update Log File Name" << std::endl;
- std::cout << "Current Log File Name = [" << x.GetLogFileName().Str() << "]" << std::endl;
- std::cout << "Enter '1' to change change Log File Name to default [" << x.GetDefaultLogFileName().Str() << "]" << std::endl;
+ std::cout << "Current Log File Name = [" << x->GetLogFileName().Str() << "]" << std::endl;
+ std::cout << "Enter '1' to change change Log File Name to default [" << x->GetLogFileName().Str() << "]" << std::endl;
std::cout << "Enter new Log File Name" << std::endl;
std::cin.getline( cNewFile, 256 );
if( strlen( cNewFile ) > 0 ){
if( cNewFile[0] == '1' )
- x.SetLogFileName( x.GetDefaultLogFileName());
+ x->SetLogFileName( x->GetLogFileName());
else
- x.SetLogFileName( cNewFile );
+ x->SetLogFileName( cNewFile );
- std::cout << "Log File Name is [" << x.GetLogFileName().Str() << "]" << std::endl;
+ std::cout << "Log File Name is [" << x->GetLogFileName().Str() << "]" << std::endl;
} else
std::cout << "Log File Name not updated" << std::endl;
}
/*************************************************************************************/
void xbUtil::WriteLogMessage(){
- if( x.GetLogStatus()) {
+ if( x->GetLogStatus()) {
char cMsg[256];
std::cout << "Enter a message to write to the log file (256 byte max)" << std::endl;
std::cin.getline( cMsg, 256 );
- x.WriteLogMessage( cMsg );
+ x->WriteLogMessage( cMsg );
} else
std::cout << "Logging disabled" << std::endl;
}
/*************************************************************************************/
void xbUtil::ToggleLoggingStatus(){
- if( x.GetLogStatus()){
- x.DisableMsgLogging();
- x.WriteLogMessage( "xb_dbfutil - Logging disabled" );
+ if( x->GetLogStatus()){
+ x->DisableMsgLogging();
+ x->WriteLogMessage( "xb_dbfutil - Logging disabled" );
std::cout << "Logging disabled" << std::endl;
} else {
- x.EnableMsgLogging();
- x.WriteLogMessage( "xb_dbfutil - Logging enabled" );
+ x->EnableMsgLogging();
+ x->WriteLogMessage( "xb_dbfutil - Logging enabled" );
std::cout << "Logging enabled" << std::endl;
}
}
/*************************************************************************************/
void xbUtil::ToggleDefaultAutoCommit(){
- if( x.GetDefaultAutoCommit()){
- x.SetDefaultAutoCommit( xbFalse );
- x.WriteLogMessage( "xb_dbfutil - Default Auto Commit disabled" );
+ if( x->GetDefaultAutoCommit()){
+ x->SetDefaultAutoCommit( xbFalse );
+ x->WriteLogMessage( "xb_dbfutil - Default Auto Commit disabled" );
std::cout << "Default Auto Commit disabled" << std::endl;
} else {
- x.SetDefaultAutoCommit( xbTrue );
- x.WriteLogMessage( "xb_dbfutil - Default Auto Commit enabled" );
+ x->SetDefaultAutoCommit( xbTrue );
+ x->WriteLogMessage( "xb_dbfutil - Default Auto Commit enabled" );
std::cout << "Default Auto Commit enabled" << std::endl;
}
}
@@ -2024,19 +2047,19 @@ void xbUtil::UpdateDataDirectory(){
char cNewDir[256];
cNewDir[0] = 0x00;
std::cout << std::endl << "Update Default Data Directory" << std::endl;
- std::cout << "Current Default Data Directory = [" << x.GetDataDirectory().Str() << "]" << std::endl;
+ std::cout << "Current Default Data Directory = [" << x->GetDataDirectory().Str() << "]" << std::endl;
std::cout << "Enter '1' to erase the Default Data Directory" << std::endl;
std::cout << "Enter '2' to change Default Data Directory to [" << PROJECT_DATA_DIR << "]" << std::endl;
std::cout << "Enter new directory" << std::endl;
std::cin.getline( cNewDir, 256 );
if( strlen( cNewDir ) > 0 ){
if( cNewDir[0] == '1' )
- x.SetDataDirectory( "" );
+ x->SetDataDirectory( "" );
else if( cNewDir[0] == '2' )
- x.SetDataDirectory( PROJECT_DATA_DIR );
+ x->SetDataDirectory( PROJECT_DATA_DIR );
else
- x.SetDataDirectory( cNewDir );
- std::cout << "Default Data Directory is [" << x.GetDataDirectory().Str() << "]" << std::endl;
+ x->SetDataDirectory( cNewDir );
+ std::cout << "Default Data Directory is [" << x->GetDataDirectory().Str() << "]" << std::endl;
}
else
std::cout << "Default Data Directory not updated" << std::endl;
@@ -2044,20 +2067,20 @@ void xbUtil::UpdateDataDirectory(){
/*************************************************************************************/
void xbUtil::ListSystemSettings(){
std::cout << std::endl << "List System Settings" << std::endl;
- std::cout << "Default Data Directory = [" << x.GetDataDirectory().Str() << "]" << std::endl;
-// std::cout << "Default File Version = [" << x.GetDefaultFileVersion() << "]" << std::endl;
+ std::cout << "Default Data Directory = [" << x->GetDataDirectory().Str() << "]" << std::endl;
+// std::cout << "Default File Version = [" << x->GetDefaultFileVersion() << "]" << std::endl;
#ifdef XB_LOCKING_SUPPORT
std::cout << "Default Auto Locking = [";
- if( x.GetDefaultAutoLock())
+ if( x->GetDefaultAutoLock())
std::cout << "ON]" << std::endl;
else
std::cout << "OFF]" << std::endl;
- std::cout << "Default Lock Retries = [" << x.GetDefaultLockRetries() << "]" << std::endl;
- std::cout << "Default Lock Wait Time = [" << x.GetDefaultLockWait() << "] (millisecs)" << std::endl;
+ std::cout << "Default Lock Retries = [" << x->GetDefaultLockRetries() << "]" << std::endl;
+ std::cout << "Default Lock Wait Time = [" << x->GetDefaultLockWait() << "] (millisecs)" << std::endl;
std::cout << "Default Lock Flavor = [";
- switch (x.GetDefaultLockFlavor()){
+ switch (x->GetDefaultLockFlavor()){
case 1:
std::cout << "Dbase]" << std::endl;
break;
@@ -2075,26 +2098,26 @@ void xbUtil::ListSystemSettings(){
break;
}
#endif
- std::cout << "Default Log Directory = [" << x.GetDefaultLogDirectory().Str() << "]" << std::endl;
- std::cout << "Default Logfile Name = [" << x.GetDefaultLogFileName().Str() << "]" << std::endl;
+ std::cout << "Log Directory = [" << x->GetLogDirectory().Str() << "]" << std::endl;
+ std::cout << "Logfile Name = [" << x->GetLogFileName().Str() << "]" << std::endl;
std::cout << "Default Auto Commit = [";
- if( x.GetDefaultAutoCommit())
+ if( x->GetDefaultAutoCommit())
std::cout << "ON]" << std::endl;
else
std::cout << "OFF]" << std::endl;
std::cout << "Logging Status = [";
- if( x.GetLogStatus())
+ if( x->GetLogStatus())
std::cout << "ON]" << std::endl;
else
std::cout << "OFF]" << std::endl;
std::cout << "Endian Type = [";
- if( x.GetEndianType() == 'L' )
+ if( x->GetEndianType() == 'L' )
std::cout << "Little Endian]" << std::endl;
else
std::cout << "Big Endian]" << std::endl;
- if( x.GetMultiUser())
+ if( x->GetMultiUser())
std::cout << "Multi User Mode = [ON]";
else
std::cout << "Multi User Mode = [OFF]";
@@ -2109,7 +2132,9 @@ void xbUtil::ProcessOption( const xbString &sOption ){
else if( sOption == "=0.99" )
// exit right now, now cleanup or termination of anything
exit(0);
- else if( sOption == "=2" )
+ else if( sOption == "=1" )
+ Help();
+ else if( sOption == "=2" )
SystemMenu();
else if( sOption == "=2.1" )
ListSystemSettings();
@@ -2144,7 +2169,7 @@ void xbUtil::ProcessOption( const xbString &sOption ){
else if( sOption == "=3.2" )
UpdateDataDirectory();
else if( sOption == "=3.3" )
- x.DisplayTableList();
+ x->DisplayTableList();
else if( sOption == "=3.4" )
Open();
else if( sOption == "=3.5" )
@@ -2808,7 +2833,7 @@ void xbUtil::FileMenu()
case 0: break;
case 1: ListFilesInDataDirectory(); break;
case 2: UpdateDataDirectory(); break;
- case 3: x.DisplayTableList(); break;
+ case 3: x->DisplayTableList(); break;
case 4: Open(); break;
case 5: Close(); break;
case 6: CloseAllTables(); break;
@@ -2963,6 +2988,7 @@ void xbUtil::MainMenu()
option = GetOption();
switch( option ){
case 0: break;
+ case 1: Help(); break;
case 2: SystemMenu(); break;
case 3: FileMenu(); break;
case 4: RecordMenu(); break;
@@ -3114,7 +3140,7 @@ void xbUtil::OpenIndex(){
xbString sIxFileName = cBuf;
iRc = dActiveTable->OpenIndex( sIxType, sIxFileName );
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::CloseIndexFile(){
@@ -3141,7 +3167,7 @@ void xbUtil::CloseIndexFile(){
}
xbInt16 iRc = dActiveTable->CloseIndexFile( pIx );
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::CreateIndexTag(){
@@ -3227,7 +3253,7 @@ void xbUtil::CreateIndexTag(){
void *vpTag;
xbInt16 iRc = dActiveTable->CreateTag( sIxType, sIxName, sKeyExpression, sFilter, iDescending, iUnique, 0, &pIx, &vpTag );
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::GetFirstKey(){
@@ -3252,7 +3278,7 @@ void xbUtil::GetFirstKey(){
if( iRc == XB_NO_ERROR )
dActiveTable->DumpRecord( dActiveTable->GetCurRecNo(), 2);
else
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::GetNextKey(){
@@ -3277,7 +3303,7 @@ void xbUtil::GetNextKey(){
if( iRc == XB_NO_ERROR )
dActiveTable->DumpRecord( dActiveTable->GetCurRecNo(), 2);
else
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::GetPrevKey(){
@@ -3303,7 +3329,7 @@ void xbUtil::GetPrevKey(){
if( iRc == XB_NO_ERROR )
dActiveTable->DumpRecord( dActiveTable->GetCurRecNo(), 2);
else
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::GetLastKey(){
@@ -3328,7 +3354,7 @@ void xbUtil::GetLastKey(){
if( iRc == XB_NO_ERROR )
dActiveTable->DumpRecord( dActiveTable->GetCurRecNo(), 2);
else
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::FindKey(){
@@ -3387,7 +3413,7 @@ void xbUtil::FindKey(){
if( iRc == XB_NO_ERROR )
dActiveTable->DumpRecord( dActiveTable->GetCurRecNo(), 2);
else
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::CheckIntegrity(){
@@ -3410,7 +3436,7 @@ void xbUtil::CheckIntegrity(){
void *vpCurTag = dActiveTable->GetCurTag();
xbInt16 iRc = pIx->CheckTagIntegrity( vpCurTag, 2 );
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::Reindex(){
@@ -3433,7 +3459,7 @@ void xbUtil::Reindex(){
}
void *vpCurTag = dActiveTable->GetCurTag();
xbInt16 iRc = pIx->Reindex( &vpCurTag );
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::DeleteTag(){
@@ -3455,7 +3481,7 @@ void xbUtil::DeleteTag(){
}
void *vpCurTag = dActiveTable->GetCurTag();
xbInt16 iRc = dActiveTable->DeleteTag( dActiveTable->GetCurIxType(), pIx->GetTagName( vpCurTag ));
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::AssociateNonProdIx(){
@@ -3494,7 +3520,7 @@ void xbUtil::DumpRecsByIx( xbInt16 iOpt ){
std::cout << "1 - 1 line per record" << std::endl;
xbInt16 iDispFmt = GetOption();
- x.WriteLogMessage( "--------- Dump Recs By Index -------------", iDispOpt );
+ x->WriteLogMessage( "--------- Dump Recs By Index -------------", iDispOpt );
void *vpCurTag = dActiveTable->GetCurTag();
xbUInt32 lRecCnt = 0;
xbInt16 iRc = 0;
@@ -3509,7 +3535,7 @@ void xbUtil::DumpRecsByIx( xbInt16 iOpt ){
lRecCnt++;
}
} else {
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
} else if( iOpt == 1 ) {
iRc = pIx->GetLastKey( vpCurTag, 1 );
@@ -3668,10 +3694,10 @@ void xbUtil::SetFilter()
if( filt )
delete filt;
- filt = new xbFilter( &x, dActiveTable );
+ filt = new xbFilter( dActiveTable );
xbInt16 iRc = filt->Set( s );
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::GetFirstFilterRec()
@@ -3689,7 +3715,7 @@ void xbUtil::GetFirstFilterRec()
if(( iRc = filt->GetFirstRecord()) == XB_NO_ERROR )
dActiveTable->DumpRecord( dActiveTable->GetCurRecNo(), 2);
else
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::GetNextFilterRec()
@@ -3706,7 +3732,7 @@ void xbUtil::GetNextFilterRec()
if(( iRc = filt->GetNextRecord()) == XB_NO_ERROR )
dActiveTable->DumpRecord( dActiveTable->GetCurRecNo(), 2);
else
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::GetPrevFilterRec()
@@ -3723,7 +3749,7 @@ void xbUtil::GetPrevFilterRec()
if(( iRc = filt->GetPrevRecord()) == XB_NO_ERROR )
dActiveTable->DumpRecord( dActiveTable->GetCurRecNo(), 2);
else
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
void xbUtil::GetLastFilterRec()
@@ -3740,17 +3766,46 @@ void xbUtil::GetLastFilterRec()
if(( iRc = filt->GetLastRecord()) == XB_NO_ERROR )
dActiveTable->DumpRecord( dActiveTable->GetCurRecNo(), 2);
else
- x.DisplayError( iRc );
+ x->DisplayError( iRc );
}
#endif // XB_FILTER_SUPPORT
///@endcond DOXYOFF
+
+/*************************************************************************************/
+void PrintHelp();
+void PrintHelp(){
+ std::cout << "Usage: xb_dbfutil [-h] [-?] [--help] [-v] [--version]" << std::endl << std::endl;
+ std::cout << "This program provides a menu driven tool for accissing the functionality og the xbase64 library" << std::endl;
+ std::cout << "and provides access to DBF, MDX, NDX and MDT xbase formatted data files." << std::endl << std::endl;
+}
+void PrintVersion();
+void PrintVersion(){
+ std::cout << "Xbase64 Version: " << xbase_VERSION_MAJOR << "." << xbase_VERSION_MINOR << "." << xbase_VERSION_PATCH << std::endl;
+}
/*************************************************************************************/
-int main(int, char**)
+int main(int argc, char *argv[] )
{
- std::cout << "xb_dbfutil initializing" << std::endl;
- xbUtil u;
+
+ // std::cout << "xb_dbfutil initializing" << std::endl;
+ xbXBase x;
+
+ xbString sParm;
+ if (x.GetCmdLineOpt( argc, argv, "-h", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "-?", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "--help", sParm )){
+ PrintHelp();
+ return 1;
+ }
+
+ if ( x.GetCmdLineOpt( argc, argv, "-v", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "--version", sParm )){
+ PrintVersion();
+ return 1;
+ }
+
+ xbUtil u( &x );
u.MainMenu();
return 0;
}
diff --git a/src/utils/xb_deletall.cpp b/src/utils/xb_deletall.cpp
index 720710f..3a8f6e4 100755
--- a/src/utils/xb_deletall.cpp
+++ b/src/utils/xb_deletall.cpp
@@ -2,7 +2,7 @@
XBase64 Software Library
-Copyright (c) 1997,2003,2014,2017,2019 Gary A Kunkel
+Copyright (c) 1997,2003,2014,2017,2019,2023 Gary A Kunkel
The xb64 software library is covered under
the terms of the GPL Version 3, 2007 license.
@@ -24,32 +24,62 @@ This program sets the delete flag on all records in a dbf file
using namespace xb;
-int main(int ac,char** av)
+
+
+void PrintHelp();
+void PrintHelp(){
+ std::cout << "Usage: xb_deleteall [-h] [-?] [--help] [-v] [--version] -i myfile" << std::endl << std::endl;
+ std::cout << "This program flags all the records in a DBF table for deletion. To physically remove the deleted records, see program xb_pack.";
+ std::cout << std::endl << std::endl;
+}
+void PrintVersion();
+void PrintVersion(){
+ std::cout << "Xbase64 Version: " << xbase_VERSION_MAJOR << "." << xbase_VERSION_MINOR << "." << xbase_VERSION_PATCH << std::endl;
+}
+
+
+int main(int argc, char *argv[])
{
+
xbXBase x;
xbDbf *MyFile = NULL;
xbFile f( &x );
xbInt16 iRc = 0;
- if (ac <= 1) {
- std::cout << "\nUsage: xb_deletall filename...\n";
+ xbString sParm;
+
+ if (argc < 2 || x.GetCmdLineOpt( argc, argv, "-h", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "-?", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "--help", sParm )){
+ PrintHelp();
+ return 1;
+ }
+
+ if ( x.GetCmdLineOpt( argc, argv, "-v", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "--version", sParm )){
+ PrintVersion();
+ return 1;
+ }
+
+ if( !x.GetCmdLineOpt( argc, argv, "-i", sParm ) || sParm == "" ){
+ PrintHelp();
return 1;
}
- if(( iRc = x.OpenHighestVersion( av[1], "", &MyFile )) != XB_NO_ERROR ){
- std::cout << "Could not open file iRc = " << iRc << " file = " << av[1] << std::endl;
+ if(( iRc = x.OpenHighestVersion( sParm.Str(), "", &MyFile )) != XB_NO_ERROR ){
+ std::cout << "Could not open file RC = " << iRc << " file = " << sParm.Str() << std::endl;
x.DisplayError( iRc );
- return 0;
+ return 1;
}
iRc = MyFile->DeleteAllRecords();
if( iRc != XB_NO_ERROR ) {
- std::cout << "Error Deleting all records - database ==> " << av[1] << "\n";
- std::cout << " Return Code = " << iRc;
+ std::cout << "Error Deleting all records - database ==> " << sParm.Str() << "\n";
+ std::cout << "Return Code = " << iRc;
+ x.DisplayError( iRc );
+ return 1;
}
MyFile->Close();
- std::cout << "\nDone...\n\n";
-
+ delete MyFile;
return 0;
-
} \ No newline at end of file
diff --git a/src/utils/xb_dumpdbt.cpp b/src/utils/xb_dumpdbt.cpp
index bc95ab7..05b7209 100755
--- a/src/utils/xb_dumpdbt.cpp
+++ b/src/utils/xb_dumpdbt.cpp
@@ -2,7 +2,7 @@
XBase64 Software Library
-Copyright (c) 1997,2003,2014,2017 Gary A Kunkel
+Copyright (c) 1997,2003,2014,2017,2023 Gary A Kunkel
The xb64 software library is covered under
the terms of the GPL Version 3, 2007 license.
@@ -16,16 +16,25 @@ Email Contact:
#include <xbase.h>
-
using namespace xb;
-int main( int ac, char **av )
-{
+void PrintHelp();
+void PrintHelp(){
+ std::cout << "Usage: xb_dumpdbt [-h] [-?] [--help] [-v] [--version] -i filename.DBF" << std::endl << std::endl;
+ std::cout << "This program dumps memo record data from an xbase formatted DBT file to stdout." << std::endl << std::endl;
+}
+void PrintVersion();
+void PrintVersion(){
+ std::cout << "Xbase64 Version: " << xbase_VERSION_MAJOR << "." << xbase_VERSION_MINOR << "." << xbase_VERSION_PATCH << std::endl;
+}
+
+int main(int argc, char *argv[] )
+{
-#ifdef XB_MEMO_SUPPORT
- xbXBase x;
+ #ifdef XB_MEMO_SUPPORT
+ xbXBase x;
xbInt16 iRc;
char cFieldType;
xbDbf *MyFile = NULL;
@@ -34,19 +43,33 @@ int main( int ac, char **av )
xbInt32 lBlockPtr;
xbString sMemoFldData;
- if( ac <= 1 ){
- std::cout << "\nUsage: dumpdbt filename...\n";
+ xbString sParm;
+ if (argc < 2 || x.GetCmdLineOpt( argc, argv, "-h", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "-?", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "--help", sParm )){
+ PrintHelp();
+ return 1;
+ }
+
+ if ( x.GetCmdLineOpt( argc, argv, "-v", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "--version", sParm )){
+ PrintVersion();
return 1;
}
- if(( iRc = x.OpenHighestVersion( av[1], "", &MyFile )) != XB_NO_ERROR ){
- std::cout << "Could not open file iRc = " << iRc << " file = " << av[1] << std::endl;
+ if( !x.GetCmdLineOpt( argc, argv, "-i", sParm ) || sParm == "" ){
+ PrintHelp();
+ return 1;
+ }
+
+ if(( iRc = x.OpenHighestVersion( sParm.Str(), "", &MyFile )) != XB_NO_ERROR ){
+ std::cout << "Could not open file iRc = " << iRc << " file = " << sParm.Str() << std::endl;
x.DisplayError( iRc );
- return 0;
+ return 1;
}
if( MyFile->GetMemoFieldCnt() == 0 ) {
- std::cout << "No memo fields exist in " << av[1] << std::endl;
+ std::cout << "No memo fields exist in " << sParm.Str() << std::endl;
} else {
xbUInt32 ulRecCnt = 0;
@@ -78,10 +101,9 @@ int main( int ac, char **av )
MyFile->Close();
delete MyFile;
}
-
-#else
- std::cout << "\nXB_MEMO_SUPPORT is OFF\n";
-#endif
+ #else
+ std::cout << "\nXB_MEMO_SUPPORT is OFF\n";
+ #endif
return 0;
}
diff --git a/src/utils/xb_dumphdr.cpp b/src/utils/xb_dumphdr.cpp
deleted file mode 100755
index 267f4c5..0000000
--- a/src/utils/xb_dumphdr.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/* xb_dumphdr.cpp
-
-XBase64 Software Library
-
-Copyright (c) 1997,2003,2014 Gary A Kunkel
-
-The xb64 software library is covered under
-the terms of the GPL Version 3, 2007 license.
-
-Email Contact:
-
- xb64-devel@lists.sourceforge.net
- xb64-users@lists.sourceforge.net
-
-*/
-
-
-#include <xbase.h>
-
-using namespace xb;
-
-int main( int ac, char ** av ){
-
-
- xbInt16 iRc;
- xbXBase x;
- xbDbf *MyFile = NULL;
-
- if( ac <= 1 ) {
- std::cout << "\nUsage: xb_dumphdr filename...\n";
- return 1;
- }
-
- if(( iRc = x.OpenHighestVersion( av[1], "", &MyFile )) != XB_NO_ERROR ){
- std::cout << "Could not open file iRc = " << iRc << " file = " << av[1] << std::endl;
- x.DisplayError( iRc );
- return 0;
- }
-
- MyFile->DumpHeader( 4 );
- MyFile->Close();
- delete MyFile;
-
- return 0;
-}
diff --git a/src/utils/xb_dumpix.cpp b/src/utils/xb_dumpix.cpp
deleted file mode 100755
index afd8764..0000000
--- a/src/utils/xb_dumpix.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/* xb_dumpix.cpp
-
-XBase64 Software Library
-
-Copyright (c) 1997,2003,2014 Gary A Kunkel
-
-The xb64 software library is covered under
-the terms of the GPL Version 3, 2007 license.
-
-Email Contact:
-
- xb64-devel@lists.sourceforge.net
- xb64-users@lists.sourceforge.net
-
-*/
-
-
-// This program dumps an index file's internal data blocks.
-// This program is for index development and debugging purposes
-
-
-#include <xbase.h>
-
-using namespace xb;
-
-int main( int ac, char ** av ){
-
-
- xbInt16 iRc;
- xbXBase x;
- xbDbf *MyFile = NULL;
- x.EnableMsgLogging();
- x.SetLogSize( 1000000L );
-
- if( ac <= 1 ) {
- std::cout << "\nUsage: xb_dumphdr filename...\n";
- return 1;
- }
- if(( iRc = x.OpenHighestVersion( av[1], "", &MyFile )) != XB_NO_ERROR ){
- std::cout << "Could not open file iRc = " << iRc << " file = " << av[1] << std::endl;
- x.DisplayError( iRc );
- return 0;
- }
- xbIx *pIx = MyFile->GetCurIx();
- if( pIx ){
- // pIx->DumpHeader( 2, 3 );
- pIx->DumpTagBlocks( 2 );
- } else {
- std::cout << av[1] << "No current index found" << std::endl;
- }
-
- MyFile->Close();
- delete MyFile;
-
- return 0;
-}
diff --git a/src/utils/xb_dumprecs.cpp b/src/utils/xb_dumprecs.cpp
index 0a85f45..cf6e33c 100755
--- a/src/utils/xb_dumprecs.cpp
+++ b/src/utils/xb_dumprecs.cpp
@@ -2,7 +2,7 @@
XBase64 Software Library
-Copyright (c) 1997,2003,2014,2019 Gary A Kunkel
+Copyright (c) 1997,2003,2014,2019,2023 Gary A Kunkel
The xb64 software library is covered under
the terms of the GPL Version 3, 2007 license.
@@ -17,27 +17,57 @@ Email Contact:
#include <xbase.h>
using namespace xb;
-int main(int ac,char** av)
+void PrintHelp();
+void PrintHelp(){
+ std::cout << "Usage: xb_dumprecs [-h] [-?] [--help] [-v] [--version] -i filename.DBF" << std::endl << std::endl;
+ std::cout << "This program dumps data records in an xbase formatted DBF file to stdout in csv format." << std::endl;
+ std::cout << "Memo data (variable length) is not included in this export. See program xb_dumpdpt for memo data." << std::endl << std::endl;
+}
+void PrintVersion();
+void PrintVersion(){
+ std::cout << "Xbase64 Version: " << xbase_VERSION_MAJOR << "." << xbase_VERSION_MINOR << "." << xbase_VERSION_PATCH << std::endl;
+}
+
+int main(int argc, char *argv[] )
{
xbXBase x;
+
+
xbInt16 iRc;
x.EnableMsgLogging();
x.SetLogSize( 1000000L );
-// xbUInt32 ulRecCnt = 0;
- if (ac <= 1) {
- std::cout << "Usage: xb_dumprecs filename..." << std::endl;
+ xbString sParm;
+ if (argc < 2 || x.GetCmdLineOpt( argc, argv, "-h", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "-?", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "--help", sParm )){
+ PrintHelp();
+ return 1;
+ }
+
+ if ( x.GetCmdLineOpt( argc, argv, "-v", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "--version", sParm )){
+ PrintVersion();
+ return 1;
+ }
+
+ if( !x.GetCmdLineOpt( argc, argv, "-i", sParm ) || sParm == "" ){
+ PrintHelp();
return 1;
}
xbDbf *MyFile = NULL;
- if(( iRc = x.OpenHighestVersion( av[1], "", &MyFile )) != XB_NO_ERROR ){
- std::cout << "Could not open file iRc = " << iRc << " file = " << av[1] << std::endl;
+ if(( iRc = x.OpenHighestVersion( sParm.Str(), "", &MyFile )) != XB_NO_ERROR ){
+ std::cout << "Could not open file RC = " << iRc << " file = " << sParm.Str() << std::endl;
x.DisplayError( iRc );
- return 0;
+ return 1;
}
-// std::cout << "Processing file sequentially from beginning..." << std::endl;
+ // std::cout << "Processing file sequentially from beginning..." << std::endl;
+
+ #ifdef XB_BLOCKREAD_SUPPORT
+ MyFile->EnableBlockReadProcessing();
+ #endif
xbUInt32 j = 0;
xbUInt32 ulRecCnt = 0;
@@ -48,15 +78,21 @@ int main(int ac,char** av)
return iRc;
while( j < ulRecCnt ){
if( j == 0 )
- iRc = MyFile->DumpRecord(++j, 2, 2 );
+ iRc = MyFile->DumpRecord(++j, 2, 2 ); // header + data
else
- iRc = MyFile->DumpRecord(++j, 2, 1 );
+ iRc = MyFile->DumpRecord(++j, 2, 1 ); // data only
if( iRc != XB_NO_ERROR ){
x.DisplayError( iRc );
return 1;
}
}
-// std::cout << j << " Records written to logile" << std::endl;
+ std::cout << j << " Records processed." << std::endl;
+
+ #ifdef XB_BLOCKREAD_SUPPORT
+ MyFile->DisableBlockReadProcessing();
+ #endif
+
MyFile->Close();
+
return 0;
}
diff --git a/src/utils/xb_execsql.cpp b/src/utils/xb_execsql.cpp
index d474593..daa6b6e 100755
--- a/src/utils/xb_execsql.cpp
+++ b/src/utils/xb_execsql.cpp
@@ -2,7 +2,7 @@
XBase64 Software Library
-Copyright (c) 1997,2003,2014 Gary A Kunkel
+Copyright (c) 1997,2003,2014,2023 Gary A Kunkel
The xb64 software library is covered under
the terms of the GPL Version 3, 2007 license.
diff --git a/src/utils/xb_pack.cpp b/src/utils/xb_pack.cpp
index ccec5a3..0cbba7e 100755
--- a/src/utils/xb_pack.cpp
+++ b/src/utils/xb_pack.cpp
@@ -2,7 +2,7 @@
XBase64 Software Library
-Copyright (c) 1997,2003,2014,2017 Gary A Kunkel
+Copyright (c) 1997,2003,2014,2017,2023 Gary A Kunkel
The xb64 software library is covered under
the terms of the GPL Version 3, 2007 license.
@@ -17,33 +17,59 @@ Email Contact:
#include <xbase.h>
using namespace xb;
-int main(int ac,char** av)
-{
- if (ac <= 1) {
- std::cout <<
- "\nUsage: xb_pack filename...\n"
- "\nThis program does automatically reindexes any open NDX or MDX indexes.";
- return 1;
- }
+void PrintHelp();
+void PrintHelp(){
+ std::cout << "Usage: xb_pack [-h] [-?] [--help] [-v] [--version] -i filename.DBF" << std::endl << std::endl;
+ std::cout << "This program removes data records that are flagged for deletion in a DBF file and rebuilds indices." << std::endl << std::endl;
+}
+void PrintVersion();
+void PrintVersion(){
+ std::cout << "Xbase64 Version: " << xbase_VERSION_MAJOR << "." << xbase_VERSION_MINOR << "." << xbase_VERSION_PATCH << std::endl;
+}
+int main(int argc, char *argv[] )
+{
xbXBase x;
xbInt16 iRc;
xbDbf * MyFile = NULL;
- if(( iRc = x.OpenHighestVersion( av[1], "", &MyFile )) != XB_NO_ERROR ){
- std::cout << "Could not open file iRc = " << iRc << " file = " << av[1] << std::endl;
+
+ xbString sParm;
+ if (argc < 2 || x.GetCmdLineOpt( argc, argv, "-h", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "-?", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "--help", sParm )){
+ PrintHelp();
+ return 1;
+ }
+
+ if ( x.GetCmdLineOpt( argc, argv, "-v", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "--version", sParm )){
+ PrintVersion();
+ return 1;
+ }
+
+ if( !x.GetCmdLineOpt( argc, argv, "-i", sParm ) || sParm == "" ){
+ PrintHelp();
+ return 1;
+ }
+
+ if(( iRc = x.OpenHighestVersion( sParm.Str(), "", &MyFile )) != XB_NO_ERROR ){
+ std::cout << "Could not open file iRc = " << iRc << " file = " << sParm.Str() << std::endl;
x.DisplayError( iRc );
- return 0;
+ return 1;
}
if(( iRc = MyFile->Pack()) != XB_NO_ERROR ) {
- std::cout << "\nError packing DBF database ==> " << av[1] << std::endl;
+ std::cout << "\nError packing DBF database ==> " << sParm.Str() << std::endl;
std::cout << " Return Code = " << iRc << std::endl;
+ return 1;
}
#ifdef XB_INDEX_SUPPORT
if(( iRc = MyFile->Reindex( 1 )) != XB_NO_ERROR ) {
- std::cout << "\nError reindexing DBF database ==> " << av[1] << std::endl;
+ std::cout << "\nError reindexing DBF database ==> " << sParm.Str() << std::endl;
std::cout << " Return Code = " << iRc << std::endl;
+ x.DisplayError( iRc );
+ return 1;
}
#endif // XB_INDEX_SUPPORT
diff --git a/src/utils/xb_tblinfo.cpp b/src/utils/xb_tblinfo.cpp
index 6b88403..241642a 100755
--- a/src/utils/xb_tblinfo.cpp
+++ b/src/utils/xb_tblinfo.cpp
@@ -1,8 +1,8 @@
-/* xb_dumpmdx.cpp
+/* xb_tblinfo.cpp
XBase64 Software Library
-Copyright (c) 1997,2003,2014,2021 Gary A Kunkel
+Copyright (c) 1997,2003,2014,2021,2023 Gary A Kunkel
The xb64 software library is covered under
the terms of the GPL Version 3, 2007 license.
@@ -19,85 +19,86 @@ Email Contact:
using namespace xb;
-int main( int ac, char ** av ){
+
+void PrintHelp();
+void PrintHelp(){
+ std::cout << "Usage: xb_tblinfo [-h] [-?] [--help] [-v] [--version] -i filename.DBF" << std::endl << std::endl;
+ std::cout << "This program dumps table definition information from a DBF file and associated indices." << std::endl << std::endl;
+}
+void PrintVersion();
+void PrintVersion(){
+ std::cout << "Xbase64 Version: " << xbase_VERSION_MAJOR << "." << xbase_VERSION_MINOR << "." << xbase_VERSION_PATCH << std::endl;
+}
+
+int main(int argc, char *argv[] ){
xbXBase x;
- xbBool bHdr = xbFalse;
xbInt16 iRc;
xbString sTagName;
xbDbf *MyFile = NULL;
- #ifdef XB_MDX_SUPPORT
- #ifdef XB_DEBUG_SUPPORT
- xbBool bMdxFound = xbFalse;
- #endif // XB_DEBUG_SUPPORT
- #endif // XB_MDX_SUPPORT
-
-
x.EnableMsgLogging();
x.SetLogSize( 1000000L );
-
- if( ac <= 1 ) {
- std::cout << "\nUsage: xb_dumpmdx filename.DBF -h -tTAGNAME...\n";
- std::cout << "-h dump mdx file header (default)\n";
- std::cout << "-tTAGNAME where TAGNAME is the name of a tag for extract\n";
+ xbString sParm;
+ if (argc < 2 || x.GetCmdLineOpt( argc, argv, "-h", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "-?", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "--help", sParm )){
+ PrintHelp();
return 1;
}
- if( ac > 2 ){
- for( int i = 1; i< ac; i++ ){
- if( strstr( av[i], "-h" ))
- bHdr = xbTrue;
- else if( strstr( av[i], "-t" ))
- sTagName.Set( av[i]+2 );
- }
+ if ( x.GetCmdLineOpt( argc, argv, "-v", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "--version", sParm )){
+ PrintVersion();
+ return 1;
}
- if( bHdr == xbFalse && sTagName == "" )
- bHdr = xbTrue;
-
-
- // std::cout << "Hdr = " << bHdr << std::endl;
- if( sTagName != "" )
- std::cout << "Tag = " << sTagName.Str() << std::endl;
+ if( !x.GetCmdLineOpt( argc, argv, "-i", sParm ) || sParm == "" ){
+ PrintHelp();
+ return 1;
+ }
- if(( iRc = x.OpenHighestVersion( av[1], "", &MyFile )) != XB_NO_ERROR ){
- std::cout << "Could not open file iRc = " << iRc << " file = " << av[1] << std::endl;
+ if(( iRc = x.OpenHighestVersion( sParm.Str(), "", &MyFile )) != XB_NO_ERROR ){
+ std::cout << "Could not open file iRc = " << iRc << " file = " << sParm.Str() << std::endl;
x.DisplayError( iRc );
- return 0;
+ return 1;
}
MyFile->DumpHeader( 4 );
- #ifdef XB_MDX_SUPPORT
- // for each mdx file, dump the header
- xbIxList *ixl = MyFile->GetIxList();
- xbIx *ixp;
+
+
+ #ifdef XB_INDEX_SUPPORT
+ xbIxList *ixl;
+ xbIx *ixp;
xbString sFileType;
+
+ #ifdef XB_MDX_SUPPORT
+ ixl = MyFile->GetIxList();
while( ixl ){
ixp = ixl->ix;
ixp->GetFileType( sFileType );
-
- #ifdef XB_DEBUG_SUPPORT
- if( sFileType == "MDX" ){
- bMdxFound = xbTrue;
- if( bHdr ){
- ixp->DumpHeader( 1, 3 );
- }
- }
- #endif // XB_DEBUG_SUPPORT
+ if( sFileType == "MDX" )
+ ixp->DumpHeader( 1, 3 );
ixl = ixl->next;
}
-
- #ifdef XB_DEBUG_SUPPORT
- if( !bMdxFound )
- std::cout << "No MDX index for file." << std::endl;
- #endif // XB_DEBUG_SUPPORT
#endif // XB_MDX_SUPPORT
+ #ifdef XB_NDX_SUPPORT
+ ixl = MyFile->GetIxList();
+ while( ixl ){
+ ixp = ixl->ix;
+ ixp->GetFileType( sFileType );
+ if( sFileType == "NDX" )
+ ixp->DumpHeader( 1, 3 );
+ ixl = ixl->next;
+ }
+ #endif // XB_NDX_SUPPORT
+
+ #endif // XB_INDEX_SUPPORT
+
MyFile->Close();
delete MyFile;
-
return 0;
}
diff --git a/src/utils/xb_undelall.cpp b/src/utils/xb_undelall.cpp
index 4f1af12..5fb1323 100755
--- a/src/utils/xb_undelall.cpp
+++ b/src/utils/xb_undelall.cpp
@@ -1,8 +1,8 @@
-/* xb_deletall.cpp
+/* xb_undelall.cpp
XBase64 Software Library
-Copyright (c) 1997,2003,2014,2017 Gary A Kunkel
+Copyright (c) 1997,2003,2014,2017,2023 Gary A Kunkel
The xb64 software library is covered under
the terms of the GPL Version 3, 2007 license.
@@ -13,8 +13,7 @@ Email Contact:
xb64-users@lists.sourceforge.net
-
-This program sets the delete flag on all records in a dbf file
+This program removes the delete flag on all records flagged for deletion in a DBF file
*/
@@ -24,32 +23,60 @@ This program sets the delete flag on all records in a dbf file
using namespace xb;
-int main(int ac,char** av)
+
+
+void PrintHelp();
+void PrintHelp(){
+ std::cout << "Usage: xb_undelall [-h] [-?] [--help] [-v] [--version] -i myfile" << std::endl << std::endl;
+ std::cout << "This program removes the deletion flags all the records in a DBF table that are flagged for deletion.";
+ std::cout << std::endl << std::endl;
+}
+void PrintVersion();
+void PrintVersion(){
+ std::cout << "Xbase64 Version: " << xbase_VERSION_MAJOR << "." << xbase_VERSION_MINOR << "." << xbase_VERSION_PATCH << std::endl;
+}
+
+
+int main(int argc, char *argv[])
{
xbXBase x;
xbDbf *MyFile = NULL;
xbInt16 iRc = 0;
- if (ac <= 1) {
- std::cout << "\nUsage: xb_deletall filename...\n";
+ xbString sParm;
+
+ if (argc < 2 || x.GetCmdLineOpt( argc, argv, "-h", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "-?", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "--help", sParm )){
+ PrintHelp();
+ return 1;
+ }
+
+ if ( x.GetCmdLineOpt( argc, argv, "-v", sParm ) ||
+ x.GetCmdLineOpt( argc, argv, "--version", sParm )){
+ PrintVersion();
return 1;
}
- if(( iRc = x.OpenHighestVersion( av[1], "", &MyFile )) != XB_NO_ERROR ){
- std::cout << "Could not open file iRc = " << iRc << " file = " << av[1] << std::endl;
+ if( !x.GetCmdLineOpt( argc, argv, "-i", sParm ) || sParm == "" ){
+ PrintHelp();
+ return 1;
+ }
+
+ if(( iRc = x.OpenHighestVersion( sParm.Str(), "", &MyFile )) != XB_NO_ERROR ){
+ std::cout << "Could not open file RC = " << iRc << " file = " << sParm.Str() << std::endl;
x.DisplayError( iRc );
- return 0;
+ return 1;
}
iRc = MyFile->UndeleteAllRecords();
if( iRc != XB_NO_ERROR ) {
- std::cout << "Error Undeleting all records - database ==> " << av[1] << "\n";
+ std::cout << "Error Undeleting all records - database ==> " << sParm.Str() << "\n";
std::cout << " Return Code = " << iRc;
+ return 1;
}
MyFile->Close();
delete MyFile;
- std::cout << "\nDone...\n\n";
-
return 0;
} \ No newline at end of file
diff --git a/src/utils/xb_zap.cpp b/src/utils/xb_zap.cpp
deleted file mode 100755
index 4660cd8..0000000
--- a/src/utils/xb_zap.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/* xb_zap.cpp
-
-XBase64 Software Library
-
-Copyright (c) 1997,2003,2014,2017 Gary A Kunkel
-
-The xb64 software library is covered under
-the terms of the GPL Version 3, 2007 license.
-
-Email Contact:
-
- xb64-devel@lists.sourceforge.net
- xb64-users@lists.sourceforge.net
-
-*/
-
-#include <xbase.h>
-using namespace xb;
-
-int main(int ac,char** av)
-{
- if (ac <= 1) {
- std::cout <<
- "\nUsage: zap filename...\n"
- "\nThis program does not automatically reindex any indices."
- "\nUse the reindex program to reindex any indexes associated"
- "\nwith the database, or build your own program which executes "
- "\nthe PackDatabase() method after opening all the index files "
- "\nassociated with the database.\n\n"
- ;
- return 1;
- }
-
- xbXBase x;
- xbInt16 iRc;
- xbDbf *MyFile = NULL;
-
- if(( iRc = x.OpenHighestVersion( av[1], "", &MyFile )) != XB_NO_ERROR ){
- std::cout << "Could not open file " << av[1] << std::endl;
- return iRc;
- }
-
- if(( iRc = MyFile->Zap()) != XB_NO_ERROR ) {
- std::cout << "\nError packing DBF database ==> " << av[1] << std::endl;
- std::cout << " Return Code = " << iRc << std::endl;
- }
- MyFile->Close();
- delete MyFile;
-
- std::cout << "\nZap Database complete..." << std::endl;
- return 0;
-}