summaryrefslogtreecommitdiff
path: root/src/utils/xb_dumpdbt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/xb_dumpdbt.cpp')
-rwxr-xr-xsrc/utils/xb_dumpdbt.cpp54
1 files changed, 38 insertions, 16 deletions
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;
}