summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjhurst <jhurst@cinecert.com>2009-06-22 05:49:02 +0000
committerjhurst <>2009-06-22 05:49:02 +0000
commita84ec32cfc61397feeb577637744031cc64d862d (patch)
treea64185ae139d51e1b76fab7e2e9c00f5ef25628d /src
parente34beed6313ea4add7539608ecb92082728778f1 (diff)
new log and fileio features
XMLElement parse bugfix (was ignoring well-formedness errors)
Diffstat (limited to 'src')
-rw-r--r--src/KM_fileio.cpp28
-rwxr-xr-xsrc/KM_fileio.h7
-rwxr-xr-xsrc/KM_log.cpp11
-rwxr-xr-xsrc/KM_log.h1
-rw-r--r--src/KM_xml.cpp3
5 files changed, 42 insertions, 8 deletions
diff --git a/src/KM_fileio.cpp b/src/KM_fileio.cpp
index 9808cfd..95bee9b 100644
--- a/src/KM_fileio.cpp
+++ b/src/KM_fileio.cpp
@@ -213,7 +213,7 @@ Kumu::FileSize(const std::string& pathname)
//
static PathCompList_t&
-s_PathMakeCanonical(PathCompList_t& CList, char separator, bool is_absolute)
+s_PathMakeCanonical(PathCompList_t& CList, bool is_absolute)
{
PathCompList_t::iterator ci, ri; // component and removal iterators
@@ -247,7 +247,7 @@ Kumu::PathMakeCanonical(const std::string& Path, char separator)
{
PathCompList_t CList;
bool is_absolute = PathIsAbsolute(Path, separator);
- s_PathMakeCanonical(PathToComponents(Path, CList, separator), separator, is_absolute);
+ s_PathMakeCanonical(PathToComponents(Path, CList, separator), is_absolute);
if ( is_absolute )
return ComponentsToAbsolutePath(CList, separator);
@@ -353,7 +353,7 @@ Kumu::PathMakeAbsolute(const std::string& Path, char separator)
CList.push_back(cwd_buf);
CList.push_back(Path);
- return ComponentsToAbsolutePath(s_PathMakeCanonical(CList, separator, true), separator);
+ return ComponentsToAbsolutePath(s_PathMakeCanonical(CList, true), separator);
}
//
@@ -430,6 +430,28 @@ Kumu::PathSetExtension(const std::string& Path, const std::string& Extension) //
}
//
+std::string
+Kumu::PathJoin(const std::string& Path1, const std::string& Path2, char separator)
+{
+ return Path1 + separator + Path2;
+}
+
+//
+std::string
+Kumu::PathJoin(const std::string& Path1, const std::string& Path2, const std::string& Path3, char separator)
+{
+ return Path1 + separator + Path2 + separator + Path3;
+}
+
+//
+std::string
+Kumu::PathJoin(const std::string& Path1, const std::string& Path2,
+ const std::string& Path3, const std::string& Path4, char separator)
+{
+ return Path1 + separator + Path2 + separator + Path3 + separator + Path4;
+}
+
+//
Kumu::PathList_t&
Kumu::FindInPaths(const IPathMatch& Pattern, const Kumu::PathList_t& SearchPaths,
Kumu::PathList_t& FoundPaths, bool one_shot, char separator)
diff --git a/src/KM_fileio.h b/src/KM_fileio.h
index b38429f..0eb921b 100755
--- a/src/KM_fileio.h
+++ b/src/KM_fileio.h
@@ -136,7 +136,7 @@ namespace Kumu
bool PathsAreEquivalent(const std::string& lhs, const std::string& rhs); // true if paths point to the same filesystem entry
// Returns free space and total space available for the given path
- Result_t FreeSpaceForPath(const std::string& path, Kumu::fsize_t& free_space, Kumu::fsize_t& total_space);
+ Result_t FreeSpaceForPath(const std::string& path, Kumu::fsize_t& free_space, Kumu::fsize_t& total_space);
// split and reassemble paths as lists of path components
PathCompList_t& PathToComponents(const std::string& Path, PathCompList_t& CList, char separator = '/'); // removes '//'
@@ -155,6 +155,11 @@ namespace Kumu
std::string PathGetExtension(const std::string& Path); // returns everything in the right-most element following the right-most '.'
std::string PathSetExtension(const std::string& Path, const std::string& Extension); // empty extension removes '.' as well
+ std::string PathJoin(const std::string& Path1, const std::string& Path2, char separator = '/');
+ std::string PathJoin(const std::string& Path1, const std::string& Path2, const std::string& Path3, char separator = '/');
+ std::string PathJoin(const std::string& Path1, const std::string& Path2,
+ const std::string& Path3, const std::string& Path4, char separator = '/');
+
//------------------------------------------------------------------------------------------
// Path Search
diff --git a/src/KM_log.cpp b/src/KM_log.cpp
index 23f17d8..985d210 100755
--- a/src/KM_log.cpp
+++ b/src/KM_log.cpp
@@ -182,11 +182,11 @@ Kumu::SyslogLogSink::~SyslogLogSink()
//
void
-Kumu::SyslogLogSink::WriteEntry(const LogEntry& e)
+Kumu::SyslogLogSink::WriteEntry(const LogEntry& Entry)
{
int priority;
- switch ( e.Type )
+ switch ( Entry.Type )
{
case Kumu::LOG_ALERT: priority = SYSLOG_ALERT; break;
case Kumu::LOG_CRIT: priority = SYSLOG_CRIT; break;
@@ -197,7 +197,12 @@ Kumu::SyslogLogSink::WriteEntry(const LogEntry& e)
case Kumu::LOG_DEBUG: priority = SYSLOG_DEBUG; break;
}
- syslog(priority, "%s", e.Msg.substr(0, e.Msg.size() - 1).c_str());
+ AutoMutex L(m_Lock);
+
+ if ( Entry.TestFilter(m_filter) )
+ {
+ syslog(priority, "%s", Entry.Msg.substr(0, Entry.Msg.size() - 1).c_str());
+ }
}
//
diff --git a/src/KM_log.h b/src/KM_log.h
index ac56843..0989706 100755
--- a/src/KM_log.h
+++ b/src/KM_log.h
@@ -296,6 +296,7 @@ namespace Kumu
// write messages to the syslog facility
class SyslogLogSink : public ILogSink
{
+ Mutex m_Lock;
KM_NO_COPY_CONSTRUCT(SyslogLogSink);
SyslogLogSink();
diff --git a/src/KM_xml.cpp b/src/KM_xml.cpp
index c82e2f7..412e5ca 100644
--- a/src/KM_xml.cpp
+++ b/src/KM_xml.cpp
@@ -765,6 +765,7 @@ Kumu::XMLElement::ParseString(const std::string& document)
MyTreeHandler* docHandler = new MyTreeHandler(this);
ErrorHandler* errHandler = (ErrorHandler*)docHandler;
parser->setDocumentHandler(docHandler);
+ parser->setErrorHandler(docHandler);
try
{
@@ -849,7 +850,7 @@ Kumu::StringIsXML(const char* document, ui32_t len)
bool
Kumu::XMLElement::ParseString(const std::string& document)
{
- DefaultLogSink().Error("asdcplib compiled without XML parser support.\n");
+ DefaultLogSink().Error("Kumu compiled without XML parser support.\n");
return false;
}