diff options
author | geronimo <geronimo013@gmx.de> | 2012-08-04 11:10:44 +0200 |
---|---|---|
committer | geronimo <geronimo013@gmx.de> | 2012-08-04 11:10:44 +0200 |
commit | e8175c7b23047fefd52f85afe05e2864b2a9bba8 (patch) | |
tree | 8dab4e287545805d173a6c8e297c1798a1a01599 /libs | |
parent | c7d67f443bdfe842c2e356d4edbe345338e3e08d (diff) | |
download | cmp-e8175c7b23047fefd52f85afe05e2864b2a9bba8.tar.gz cmp-e8175c7b23047fefd52f85afe05e2864b2a9bba8.tar.bz2 |
created new icons to enable visual feedback on mediatype selection, changed json-parser and enabled virtual mediatype usage
Diffstat (limited to 'libs')
-rw-r--r-- | libs/IO/src/CommandReader.cc | 12 | ||||
-rw-r--r-- | libs/mediaScan/src/Audio.cc | 2 | ||||
-rw-r--r-- | libs/mediaScan/src/DVDImage.cc | 2 | ||||
-rw-r--r-- | libs/mediaScan/src/LegacyVdrRecording.cc | 2 | ||||
-rw-r--r-- | libs/mediaScan/src/Movie.cc | 2 | ||||
-rw-r--r-- | libs/mediaScan/src/Picture.cc | 2 | ||||
-rw-r--r-- | libs/mediaScan/src/VdrRecording.cc | 2 | ||||
-rw-r--r-- | libs/networking/src/HTTPServer.cc | 2 | ||||
-rw-r--r-- | libs/util/include/StringBuilder.h | 7 | ||||
-rw-r--r-- | libs/util/src/JSonWriter.cc | 5 | ||||
-rw-r--r-- | libs/util/src/StringBuilder.cc | 50 |
11 files changed, 71 insertions, 17 deletions
diff --git a/libs/IO/src/CommandReader.cc b/libs/IO/src/CommandReader.cc index 0bc6109..accd79f 100644 --- a/libs/IO/src/CommandReader.cc +++ b/libs/IO/src/CommandReader.cc @@ -51,17 +51,10 @@ void cCommandReader::Close(void) int status = 0; if (!fdMax) fdMax = getdtablesize(); - if (fd > 0 && fd < fdMax) { - close(fd); - isyslog("closed fd #%d", fd); - } + if (fd > 0 && fd < fdMax) close(fd); fd = -1; - if (pid != waitpid(pid, &status, 0)) { + if (pid != waitpid(pid, &status, 0)) esyslog("ERROR: failed to wait for child #%d - error #%d", pid, errno); - } - else { - isyslog("child exit status: %d", WEXITSTATUS(status)); - } pid = -1; } @@ -110,7 +103,6 @@ bool cCommandReader::Open(void) esyslog("ERROR: failed to close write end from parent side!"); exit(-1); } - isyslog("child process #%d started ... fd %d", pid, child2Parent[FDRead]); fd = child2Parent[FDRead]; return true; } diff --git a/libs/mediaScan/src/Audio.cc b/libs/mediaScan/src/Audio.cc index 9420db6..62e9379 100644 --- a/libs/mediaScan/src/Audio.cc +++ b/libs/mediaScan/src/Audio.cc @@ -24,6 +24,7 @@ */ #include <Audio.h> #include <StringBuilder.h> +#include <Logging.h> #include <stddef.h> #include <string.h> #include <util.h> @@ -74,6 +75,7 @@ void cAudio::AddMeta(cMediainfoReader::InfoEntry* Entry) void cAudio::EnableDeepScan(bool DoScan) { deepScanEnabled = DoScan; + isyslog("cAudio::enableDeepScan(%s)", deepScanEnabled ? "true" : "false"); } const char *cAudio::ContentType(const char* Extension) diff --git a/libs/mediaScan/src/DVDImage.cc b/libs/mediaScan/src/DVDImage.cc index 0ddcdac..1a78581 100644 --- a/libs/mediaScan/src/DVDImage.cc +++ b/libs/mediaScan/src/DVDImage.cc @@ -23,6 +23,7 @@ * -------------------------------------------------------------- */ #include <DVDImage.h> +#include <Logging.h> #include <string.h> #include <stdlib.h> #include <stdio.h> @@ -55,6 +56,7 @@ size_t cDVDImage::Size(void) const void cDVDImage::EnableDeepScan(bool DoScan) { deepScanEnabled = DoScan; + isyslog("cDVDImage::enableDeepScan(%s)", deepScanEnabled ? "true" : "false"); } bool cDVDImage::NeedsFurtherScan(void) const diff --git a/libs/mediaScan/src/LegacyVdrRecording.cc b/libs/mediaScan/src/LegacyVdrRecording.cc index 2b4d7af..b12d693 100644 --- a/libs/mediaScan/src/LegacyVdrRecording.cc +++ b/libs/mediaScan/src/LegacyVdrRecording.cc @@ -25,6 +25,7 @@ #include <LegacyVdrRecording.h> #include <StringBuilder.h> #include <File.h> +#include <Logging.h> #include <string.h> #include <stdlib.h> #include <stdio.h> @@ -53,6 +54,7 @@ cLegacyVdrRecording::~cLegacyVdrRecording() void cLegacyVdrRecording::EnableDeepScan(bool DoScan) { deepScanEnabled = DoScan; + isyslog("cLegacyVdrRecording::enableDeepScan(%s)", deepScanEnabled ? "true" : "false"); } bool cLegacyVdrRecording::NeedsFurtherScan(void) const diff --git a/libs/mediaScan/src/Movie.cc b/libs/mediaScan/src/Movie.cc index 19fc629..7194f54 100644 --- a/libs/mediaScan/src/Movie.cc +++ b/libs/mediaScan/src/Movie.cc @@ -23,6 +23,7 @@ * -------------------------------------------------------------- */ #include <Movie.h> +#include <Logging.h> #include <stddef.h> #include <string.h> #include <util.h> @@ -82,6 +83,7 @@ void cMovie::AddMeta(cMediainfoReader::InfoEntry *Entry) void cMovie::EnableDeepScan(bool DoScan) { deepScanEnabled = DoScan; + isyslog("cMovie::enableDeepScan(%s)", deepScanEnabled ? "true" : "false"); } bool cMovie::NeedsFurtherScan(void) const diff --git a/libs/mediaScan/src/Picture.cc b/libs/mediaScan/src/Picture.cc index 0401401..a480e45 100644 --- a/libs/mediaScan/src/Picture.cc +++ b/libs/mediaScan/src/Picture.cc @@ -23,6 +23,7 @@ * -------------------------------------------------------------- */ #include <Picture.h> +#include <Logging.h> #include <stddef.h> #include <string.h> @@ -72,6 +73,7 @@ const char *cPicture::ContentType(const char* Extension) void cPicture::EnableDeepScan(bool DoScan) { deepScanEnabled = DoScan; + isyslog("cPicture::enableDeepScan(%s)", deepScanEnabled ? "true" : "false"); } bool cPicture::NeedsFurtherScan(void) const diff --git a/libs/mediaScan/src/VdrRecording.cc b/libs/mediaScan/src/VdrRecording.cc index bf1eaab..afb930a 100644 --- a/libs/mediaScan/src/VdrRecording.cc +++ b/libs/mediaScan/src/VdrRecording.cc @@ -25,6 +25,7 @@ #include <VdrRecording.h> #include <StringBuilder.h> #include <File.h> +#include <Logging.h> #include <string.h> #include <stdlib.h> #include <stdio.h> @@ -52,6 +53,7 @@ cVdrRecording::~cVdrRecording() void cVdrRecording::EnableDeepScan(bool DoScan) { deepScanEnabled = DoScan; + isyslog("cVdrRecording::enableDeepScan(%s)", deepScanEnabled ? "true" : "false"); } bool cVdrRecording::NeedsFurtherScan(void) const diff --git a/libs/networking/src/HTTPServer.cc b/libs/networking/src/HTTPServer.cc index ba62283..a857ff1 100644 --- a/libs/networking/src/HTTPServer.cc +++ b/libs/networking/src/HTTPServer.cc @@ -65,8 +65,6 @@ void cHTTPServer::Action() cleaner->Start(); } #endif - fprintf(stderr, "startup server now\n"); - ServerSocket().Open(); while (Running()) { cConnectionPoint *cp = ServerSocket().Accept(); diff --git a/libs/util/include/StringBuilder.h b/libs/util/include/StringBuilder.h index db98934..977c4e7 100644 --- a/libs/util/include/StringBuilder.h +++ b/libs/util/include/StringBuilder.h @@ -34,7 +34,7 @@ public: cStringBuilder(int chunkSize = 127); virtual ~cStringBuilder(); - cStringBuilder &Append(const char *Text); + cStringBuilder &Append(const char *Text, const char char2Replace[] = NULL, const char *replacements[] = NULL); cStringBuilder &Append(char c); cStringBuilder &Append(bool v, const char *TrueValue = "X", const char *FalseValue="-"); cStringBuilder &Append(double v); @@ -48,9 +48,12 @@ public: size_t Copy(char *Buf, size_t BufSize); char *toString(void); +protected: + void Write(const char *Text); + void WriteAndReplace(const char *Text, const char char2Replace[], const char *replacements[]); + private: void init(void); - void Write(const char *p); int chunkSize; size_t readOffset; ///< read offest is the offset over all chunks (thus goes from 0 to size) ///< Copy can be called subsequently, if Buf is smaller than StringBuilders size diff --git a/libs/util/src/JSonWriter.cc b/libs/util/src/JSonWriter.cc index ec9b1dc..8fcb140 100644 --- a/libs/util/src/JSonWriter.cc +++ b/libs/util/src/JSonWriter.cc @@ -28,6 +28,9 @@ #include <stdio.h> #define DEBUG 1 +static const char char2Replace[] = { '"', '\0' }; +static const char *replacements[] = { "\\\"", NULL }; + cJSonWriter::cJSonWriter(cStringBuilder &StringBuilder) : lastState(JS_Unknown) , sb(StringBuilder) @@ -130,7 +133,7 @@ cJSonWriter &cJSonWriter::Value(const char *Text) { } else { PopState(); - sb.Append("\"").Append(Text).Append("\""); + sb.Append("\"").Append(Text, char2Replace, replacements).Append("\""); } return *this; } diff --git a/libs/util/src/StringBuilder.cc b/libs/util/src/StringBuilder.cc index 28b048e..7da1aac 100644 --- a/libs/util/src/StringBuilder.cc +++ b/libs/util/src/StringBuilder.cc @@ -91,6 +91,51 @@ void cStringBuilder::Write(const char *Text) } } +void cStringBuilder::WriteAndReplace(const char *Text, const char char2Replace[], const char *replacements[]) +{ + if (!Text) { + esyslog("ERROR: text to add is a NULL-pointer!"); + return; + } + int done; + char *curChunk = (char *) pool[pool.size() - 1]; + char *chunkLast = curChunk + chunkSize; + char *pd; + const char *ps, *srcLast = Text + strlen(Text), *pChk; + + for (ps = Text, pd = curChunk + writeOffset; ps < srcLast; ++ps) { + done = 0; + for (pChk = char2Replace; pChk && *pChk; ++pChk) { + if (*ps == *pChk) { + const char *rps = replacements[pChk - char2Replace]; + done = 1; + + while (rps && *rps) { + if (writeOffset == chunkSize) { + curChunk = (char *) malloc(chunkSize); + pool.push_back(curChunk); + writeOffset = 0; + pd = curChunk; + chunkLast = curChunk + chunkSize; + } + *pd++ = *rps++; + ++writeOffset; + } + } + } + if (done) continue; + if (writeOffset == chunkSize) { + curChunk = (char *) malloc(chunkSize); + pool.push_back(curChunk); + writeOffset = 0; + pd = curChunk; + chunkLast = curChunk + chunkSize; + } + *pd++ = *ps; + ++writeOffset; + } +} + size_t cStringBuilder::Size() { return (pool.size() - 1) * chunkSize + writeOffset; @@ -125,10 +170,11 @@ size_t cStringBuilder::Copy(char* Buf, size_t BufSize) return bytesWritten; } -cStringBuilder &cStringBuilder::Append(const char* Text) +cStringBuilder &cStringBuilder::Append(const char* Text, const char char2Replace[], const char *replacements[]) { if (!Text) Write("(null)"); - Write(Text); + if (char2Replace && replacements) WriteAndReplace(Text, char2Replace, replacements); + else Write(Text); return *this; } |