summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Danilov <mdanilov@luxoft.com>2018-02-16 16:20:29 +0800
committerMaxim Danilov <mdanilov@luxoft.com>2018-02-16 16:20:29 +0800
commitd1f47ac656d965884ab15437ed366905eee908cc (patch)
tree785b7d9023ad3db36c7841593d24d659d9b1615d
parent61bfcb12eaef514aaf4fc20457e9f48b1b349d58 (diff)
downloadpersistence-client-library-d1f47ac656d965884ab15437ed366905eee908cc.tar.gz
Fixed: persistence_db_viewer does not show content of big databases
Added .gitignore
-rw-r--r--.gitignore99
-rw-r--r--tools/persistence_db_viewer.c68
2 files changed, 129 insertions, 38 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..19ca9e1
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,99 @@
+# Autotools.gitignore
+
+# http://www.gnu.org/software/automake
+
+Makefile.in
+/ar-lib
+/mdate-sh
+/py-compile
+/test-driver
+/ylwrap
+
+# http://www.gnu.org/software/autoconf
+
+/autom4te.cache
+/autoscan.log
+/autoscan-*.log
+/aclocal.m4
+/compile
+/config.guess
+/config.h.in
+/config.sub
+/configure
+/configure.scan
+/depcomp
+/install-sh
+/missing
+/stamp-h1
+
+# https://www.gnu.org/software/libtool/
+
+/ltmain.sh
+
+# http://www.gnu.org/software/texinfo
+
+/texinfo.tex
+
+# http://www.gnu.org/software/m4/
+
+m4/libtool.m4
+m4/ltoptions.m4
+m4/ltsugar.m4
+m4/ltversion.m4
+m4/lt~obsolete.m4
+autom4te.cache
+
+# C.gitignore
+
+# Prerequisites
+*.d
+
+# Object files
+*.o
+*.ko
+*.obj
+*.elf
+
+# Linker output
+*.ilk
+*.map
+*.exp
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Libraries
+*.lib
+*.a
+*.la
+*.lo
+
+# Shared objects (inc. Windows DLLs)
+*.dll
+*.so
+*.so.*
+*.dylib
+
+# Executables
+*.exe
+*.out
+*.app
+*.i*86
+*.x86_64
+*.hex
+
+# Debug files
+*.dSYM/
+*.su
+*.idb
+*.pdb
+
+# Kernel Module Compile Results
+*.mod*
+*.cmd
+.tmp_versions/
+modules.order
+Module.symvers
+Mkfile.old
+dkms.conf
diff --git a/tools/persistence_db_viewer.c b/tools/persistence_db_viewer.c
index 27b2c9d..40ab828 100644
--- a/tools/persistence_db_viewer.c
+++ b/tools/persistence_db_viewer.c
@@ -8,11 +8,10 @@
* Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
* with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
******************************************************************************/
- /**
+/**
* @file persistence_db_viewer.c
* @ingroup Persistence client library tools
* @author Ingo Huerner
-
*
* @see
*/
@@ -60,21 +59,21 @@ typedef enum dbType_
unsigned int gDbMaskArray[] = {
- dbTypeNone,
- dbTypeCached,
- dbTypeWriteThrough,
- dbTypeDefault,
- dbTypeConfDefault,
- dbTypeRCT
+ dbTypeNone,
+ dbTypeCached,
+ dbTypeWriteThrough,
+ dbTypeDefault,
+ dbTypeConfDefault,
+ dbTypeRCT
};
const char* gDbNameArray[] = {
- "none",
- "cached",
- "wt",
- "default",
- "confDefault",
- "RCT"
+ "none",
+ "cached",
+ "wt",
+ "default",
+ "confDefault",
+ "RCT"
};
@@ -102,7 +101,7 @@ void printDBcontent(const char* appname, dbType type)
int handle = 0, listSize = 0, ret = 0;
char* resourceList = NULL;
- char filename[512] = {0};
+ char filename[512] = { 0 };
static const char* nameTemplate = "/Data/mnt-c/%s/%s";
static const char* cache = "cached.itz";
@@ -111,8 +110,6 @@ void printDBcontent(const char* appname, dbType type)
static const char* confDef = "configurable-default-data.itz";
static const size_t bufSize = 8192;
- memset(filename, 0, 512-1);
-
printf("---------------------------------------------------------------------\n");
if(type == dbTypeCached)
{
@@ -145,10 +142,10 @@ void printDBcontent(const char* appname, dbType type)
if(handle >= 0)
{
listSize = persComDbGetSizeKeysList(handle);
- if(listSize > 0 && listSize < 2048)
+ if(listSize > 0)
{
- resourceList = (char*)malloc((size_t)listSize+4);
- memset(resourceList, 0, (size_t)listSize+4-1);
+ resourceList = (char*)malloc((size_t)listSize);
+ memset(resourceList, 0, (size_t)listSize);
if(resourceList != NULL)
{
@@ -164,7 +161,7 @@ void printDBcontent(const char* appname, dbType type)
if(resourceList[i] == '\0')
{
numResources++;
- resourceStartIdx[++idx] = i+1;
+ resourceStartIdx[++idx] = i + 1;
}
}
@@ -172,9 +169,11 @@ void printDBcontent(const char* appname, dbType type)
for(i = 0; i < numResources; ++i)
{
- memset(buffer, 0, sizeof(buffer));
printf("Key[%d]: %s\n", i, &resourceList[resourceStartIdx[i]]);
+
+ memset(buffer, 0, sizeof(buffer));
persComDbReadKey(handle, &resourceList[resourceStartIdx[i]], buffer, (int)sizeof(buffer));
+
printf(" value: %s\n\n", buffer);
}
}
@@ -200,7 +199,6 @@ void printDBcontent(const char* appname, dbType type)
-
void printRCTcontent(const char* appname, int full)
{
int handle = -1, listSize = 0, ret = 0;
@@ -217,29 +215,25 @@ void printRCTcontent(const char* appname, int full)
if(handle >= 0)
{
listSize = persComRctGetSizeResourcesList(handle);
- if(listSize > 0 && listSize < 2048)
+ if(listSize > 0)
{
- resourceList = (char*)malloc((size_t)listSize+4);
- memset(resourceList, 0, (size_t)listSize+4-1);
+ resourceList = (char*)malloc((size_t)listSize);
+ memset(resourceList, 0, (size_t)listSize);
if(resourceList != NULL)
{
- int i = 0, idx = 1, numResources = 0;
- int resourceStartIdx[256] = {0};
-
- memset(resourceStartIdx, 0, 256-1);
ret = persComRctGetResourcesList(handle, resourceList, listSize);
-
if(ret != 0)
{
- resourceStartIdx[idx] = 0; // initial start
+ int i = 0, idx = 0, numResources = 0;
+ int resourceStartIdx[256] = { 0 };
- for(i=1; i<listSize; i++ )
+ for(i = 1; i < listSize; ++i)
{
if(resourceList[i] == '\0')
{
numResources++;
- resourceStartIdx[idx++] = i+1;
+ resourceStartIdx[++idx] = i + 1;
}
}
@@ -247,7 +241,7 @@ void printRCTcontent(const char* appname, int full)
printf("RCT keys [%d]: %s \n", numResources, filename);
printf("---------------------------------------------------------------------\n");
- for(i=0; i<numResources; i++)
+ for(i = 0; i < numResources; ++i)
{
PersistenceConfigurationKey_s psConfig_out;
printf("RCT[%d] : \"%s\"\n", i, &resourceList[resourceStartIdx[i]]);
@@ -395,6 +389,7 @@ void printAvailableApplication(const char* thePath)
}
+
int main(int argc, char *argv[])
{
int ret = 0, opt = 0, printAllAppsContent = -1, listAllApps = -1;
@@ -457,13 +452,11 @@ int main(int argc, char *argv[])
printAppManual();
}
-
if(listAllApps == 1)
{
printAvailableApplication(persPath);
}
-
if(printAllAppsContent == 1)
{
printAllApplicationDBs(persPath, dbTypeAccum);
@@ -473,7 +466,6 @@ int main(int argc, char *argv[])
printSingleApplicationDBs(singleAppName, persPath, dbTypeAccum);
}
-
// unregister debug log and trace
DLT_UNREGISTER_APP();