new log and fileio features
authorjhurst <jhurst@cinecert.com>
Mon, 22 Jun 2009 05:49:02 +0000 (05:49 +0000)
committerjhurst <>
Mon, 22 Jun 2009 05:49:02 +0000 (05:49 +0000)
XMLElement parse bugfix (was ignoring well-formedness errors)

configure.ac
src/KM_fileio.cpp
src/KM_fileio.h
src/KM_log.cpp
src/KM_log.h
src/KM_xml.cpp

index 304e49b123bbb42079484798d4ae6510f621fac8..64bdca9ef0fd507368f0e5a09f6f091dd0ad7f08 100644 (file)
@@ -37,7 +37,7 @@ AC_PREREQ([2.59])
 # For example, if asdcplib version 1.0.0 were modified to accomodate changes
 # in file format, and if no changes were made to AS_DCP.h, the new version would be
 # 1.0.1. If changes were also required in AS_DCP.h, the new version would be 1.1.1.
-AC_INIT([asdcplib], [1.4.24], [asdcplib@cinecert.com])
+AC_INIT([asdcplib], [1.4.25], [asdcplib@cinecert.com])
 
 AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_SRCDIR([src/KM_error.h])
index 9808cfdfb6edb6c929d03777829863b6f6d11819..95bee9bdda770b38ae70e133b337b22279e62df9 100644 (file)
@@ -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);
 }
 
 //
@@ -429,6 +429,28 @@ Kumu::PathSetExtension(const std::string& Path, const std::string& Extension) //
   return Basename + "." + 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,
index b38429f144818b758eb0fc7323c3be248f4bc9ac..0eb921b7227d2a377fa4741e5cc83f267c17fd74 100755 (executable)
@@ -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
index 23f17d8008a380594b1aff54f9f90022b65fd36d..985d2103289f9ea548e48f4110a006872aa0fda5 100755 (executable)
@@ -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());
+    }
 }
 
 //
index ac56843b174c64c80c4cbdec66044712a962fdaa..09897060386752eb98e12e6190ff77be5f230f06 100755 (executable)
@@ -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();
   
index c82e2f71dab32463805f71a665d7e50ed1e86f9e..412e5cad6542625c6aaff639cc53b8bd0aee850b 100644 (file)
@@ -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;
 }