Merge pull request #20 from pocoproject/develop

Sync 4.10.2015
This commit is contained in:
Marian Krivoš 2015-10-04 22:39:57 +02:00
commit f9d2148f86
64 changed files with 747 additions and 135 deletions

View File

@ -205,10 +205,10 @@ std::string X509Certificate::issuerName(NID nid) const
if (X509_NAME* issuer = X509_get_issuer_name(_pCert))
{
char buffer[NAME_BUFFER_SIZE];
X509_NAME_get_text_by_NID(issuer, nid, buffer, sizeof(buffer));
if (X509_NAME_get_text_by_NID(issuer, nid, buffer, sizeof(buffer)) >= 0)
return std::string(buffer);
}
else return std::string();
return std::string();
}
@ -217,10 +217,10 @@ std::string X509Certificate::subjectName(NID nid) const
if (X509_NAME* subj = X509_get_subject_name(_pCert))
{
char buffer[NAME_BUFFER_SIZE];
X509_NAME_get_text_by_NID(subj, nid, buffer, sizeof(buffer));
if (X509_NAME_get_text_by_NID(subj, nid, buffer, sizeof(buffer)) >= 0)
return std::string(buffer);
}
else return std::string();
return std::string();
}

View File

@ -156,7 +156,7 @@ add_library( "${LIBNAME}" ${LIB_MODE} ${SRCS})
add_library( "${POCO_LIBNAME}" ALIAS "${LIBNAME}")
set_target_properties( "${LIBNAME}"
PROPERTIES
VERSION ${PROJECT_VERSION} SOVERSION ${SHARED_LIBRARY_VERSION}
VERSION ${SHARED_LIBRARY_VERSION} SOVERSION ${SHARED_LIBRARY_VERSION}
OUTPUT_NAME ${POCO_LIBNAME}
DEFINE_SYMBOL Foundation_EXPORTS
)

View File

@ -2138,6 +2138,8 @@
RelativePath=".\src\Configurable.cpp"/>
<File
RelativePath=".\src\ConsoleChannel.cpp"/>
<File
RelativePath=".\src\EventChannel.cpp"/>
<File
RelativePath=".\src\EventLogChannel.cpp"/>
<File
@ -2421,6 +2423,8 @@
RelativePath=".\include\Poco\Configurable.h"/>
<File
RelativePath=".\include\Poco\ConsoleChannel.h"/>
<File
RelativePath=".\include\Poco\EventChannel.h"/>
<File
RelativePath=".\include\Poco\EventLogChannel.h"/>
<File

View File

@ -679,6 +679,7 @@
<ClCompile Include="src\Channel.cpp" />
<ClCompile Include="src\Configurable.cpp" />
<ClCompile Include="src\ConsoleChannel.cpp" />
<ClCompile Include="src\EventChannel.cpp" />
<ClCompile Include="src\EventLogChannel.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release_shared|SDK_AM335X_SK_WEC2013_V300'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug_shared|SDK_AM335X_SK_WEC2013_V300'">true</ExcludedFromBuild>
@ -1255,6 +1256,7 @@
<ClInclude Include="include\Poco\Channel.h" />
<ClInclude Include="include\Poco\Configurable.h" />
<ClInclude Include="include\Poco\ConsoleChannel.h" />
<ClInclude Include="include\Poco\EventChannel.h" />
<ClInclude Include="include\Poco\EventLogChannel.h" />
<ClInclude Include="include\Poco\FileChannel.h" />
<ClInclude Include="include\Poco\Formatter.h" />

View File

@ -567,6 +567,9 @@
<ClCompile Include="src\ConsoleChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\EventChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\EventLogChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
@ -1418,6 +1421,9 @@
<ClInclude Include="include\Poco\ConsoleChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\EventChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\EventLogChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>

View File

@ -679,6 +679,7 @@
<ClCompile Include="src\Channel.cpp" />
<ClCompile Include="src\Configurable.cpp" />
<ClCompile Include="src\ConsoleChannel.cpp" />
<ClCompile Include="src\EventChannel.cpp" />
<ClCompile Include="src\EventLogChannel.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release_shared|SDK_AM335X_SK_WEC2013_V310'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug_shared|SDK_AM335X_SK_WEC2013_V310'">true</ExcludedFromBuild>
@ -1255,6 +1256,7 @@
<ClInclude Include="include\Poco\Channel.h" />
<ClInclude Include="include\Poco\Configurable.h" />
<ClInclude Include="include\Poco\ConsoleChannel.h" />
<ClInclude Include="include\Poco\EventChannel.h" />
<ClInclude Include="include\Poco\EventLogChannel.h" />
<ClInclude Include="include\Poco\FileChannel.h" />
<ClInclude Include="include\Poco\Formatter.h" />

View File

@ -567,6 +567,9 @@
<ClCompile Include="src\ConsoleChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\EventChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\EventLogChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
@ -1418,6 +1421,9 @@
<ClInclude Include="include\Poco\ConsoleChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\EventChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\EventLogChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>

View File

@ -608,6 +608,7 @@
<ClCompile Include="src\Channel.cpp"/>
<ClCompile Include="src\Configurable.cpp"/>
<ClCompile Include="src\ConsoleChannel.cpp"/>
<ClCompile Include="src\EventChannel.cpp"/>
<ClCompile Include="src\EventLogChannel.cpp"/>
<ClCompile Include="src\FileChannel.cpp"/>
<ClCompile Include="src\Formatter.cpp"/>
@ -1151,6 +1152,7 @@
<ClInclude Include="include\Poco\Channel.h"/>
<ClInclude Include="include\Poco\Configurable.h"/>
<ClInclude Include="include\Poco\ConsoleChannel.h"/>
<ClInclude Include="include\Poco\EventChannel.h"/>
<ClInclude Include="include\Poco\EventLogChannel.h"/>
<ClInclude Include="include\Poco\FileChannel.h"/>
<ClInclude Include="include\Poco\Formatter.h"/>

View File

@ -579,6 +579,9 @@
<ClCompile Include="src\ConsoleChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\EventChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\EventLogChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
@ -1406,6 +1409,9 @@
<ClInclude Include="include\Poco\ConsoleChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\EventChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\EventLogChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>

View File

@ -612,6 +612,7 @@
<ClCompile Include="src\Channel.cpp"/>
<ClCompile Include="src\Configurable.cpp"/>
<ClCompile Include="src\ConsoleChannel.cpp"/>
<ClCompile Include="src\EventChannel.cpp"/>
<ClCompile Include="src\EventLogChannel.cpp"/>
<ClCompile Include="src\FileChannel.cpp"/>
<ClCompile Include="src\Formatter.cpp"/>
@ -1155,6 +1156,7 @@
<ClInclude Include="include\Poco\Channel.h"/>
<ClInclude Include="include\Poco\Configurable.h"/>
<ClInclude Include="include\Poco\ConsoleChannel.h"/>
<ClInclude Include="include\Poco\EventChannel.h"/>
<ClInclude Include="include\Poco\EventLogChannel.h"/>
<ClInclude Include="include\Poco\FileChannel.h"/>
<ClInclude Include="include\Poco\Formatter.h"/>

View File

@ -579,6 +579,9 @@
<ClCompile Include="src\ConsoleChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\EventChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\EventLogChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
@ -1406,6 +1409,9 @@
<ClInclude Include="include\Poco\ConsoleChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\EventChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\EventLogChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>

View File

@ -612,6 +612,7 @@
<ClCompile Include="src\Channel.cpp"/>
<ClCompile Include="src\Configurable.cpp"/>
<ClCompile Include="src\ConsoleChannel.cpp"/>
<ClCompile Include="src\EventChannel.cpp"/>
<ClCompile Include="src\EventLogChannel.cpp"/>
<ClCompile Include="src\FileChannel.cpp"/>
<ClCompile Include="src\Formatter.cpp"/>
@ -1155,6 +1156,7 @@
<ClInclude Include="include\Poco\Channel.h"/>
<ClInclude Include="include\Poco\Configurable.h"/>
<ClInclude Include="include\Poco\ConsoleChannel.h"/>
<ClInclude Include="include\Poco\EventChannel.h"/>
<ClInclude Include="include\Poco\EventLogChannel.h"/>
<ClInclude Include="include\Poco\FileChannel.h"/>
<ClInclude Include="include\Poco\Formatter.h"/>

View File

@ -579,6 +579,9 @@
<ClCompile Include="src\ConsoleChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\EventChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\EventLogChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
@ -1406,6 +1409,9 @@
<ClInclude Include="include\Poco\ConsoleChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\EventChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\EventLogChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>

View File

@ -392,6 +392,7 @@
<ClCompile Include="src\ErrorHandler.cpp"/>
<ClCompile Include="src\Event.cpp"/>
<ClCompile Include="src\EventArgs.cpp"/>
<ClCompile Include="src\EventChannel.cpp"/>
<ClCompile Include="src\EventLogChannel.cpp"/>
<ClCompile Include="src\Event_POSIX.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'">true</ExcludedFromBuild>
@ -1079,6 +1080,7 @@
<ClInclude Include="include\Poco\ErrorHandler.h"/>
<ClInclude Include="include\Poco\Event.h"/>
<ClInclude Include="include\Poco\EventArgs.h"/>
<ClInclude Include="include\Poco\EventChannel.h"/>
<ClInclude Include="include\Poco\EventLogChannel.h"/>
<ClInclude Include="include\Poco\Event_POSIX.h"/>
<ClInclude Include="include\Poco\Event_WIN32.h"/>

View File

@ -579,6 +579,9 @@
<ClCompile Include="src\ConsoleChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\EventChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\EventLogChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
@ -1406,6 +1409,9 @@
<ClInclude Include="include\Poco\ConsoleChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\EventChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\EventLogChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>

View File

@ -2092,6 +2092,8 @@
RelativePath=".\src\Configurable.cpp"/>
<File
RelativePath=".\src\ConsoleChannel.cpp"/>
<File
RelativePath=".\src\EventChannel.cpp"/>
<File
RelativePath=".\src\EventLogChannel.cpp"/>
<File
@ -2375,6 +2377,8 @@
RelativePath=".\include\Poco\Configurable.h"/>
<File
RelativePath=".\include\Poco\ConsoleChannel.h"/>
<File
RelativePath=".\include\Poco\EventChannel.h"/>
<File
RelativePath=".\include\Poco\EventLogChannel.h"/>
<File

View File

@ -606,6 +606,7 @@
<ClCompile Include="src\Channel.cpp"/>
<ClCompile Include="src\Configurable.cpp"/>
<ClCompile Include="src\ConsoleChannel.cpp"/>
<ClCompile Include="src\EventChannel.cpp"/>
<ClCompile Include="src\EventLogChannel.cpp"/>
<ClCompile Include="src\FileChannel.cpp"/>
<ClCompile Include="src\Formatter.cpp"/>
@ -1149,6 +1150,7 @@
<ClInclude Include="include\Poco\Channel.h"/>
<ClInclude Include="include\Poco\Configurable.h"/>
<ClInclude Include="include\Poco\ConsoleChannel.h"/>
<ClInclude Include="include\Poco\EventChannel.h"/>
<ClInclude Include="include\Poco\EventLogChannel.h"/>
<ClInclude Include="include\Poco\FileChannel.h"/>
<ClInclude Include="include\Poco\Formatter.h"/>

View File

@ -579,6 +579,9 @@
<ClCompile Include="src\ConsoleChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\EventChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\EventLogChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
@ -1406,6 +1409,9 @@
<ClInclude Include="include\Poco\ConsoleChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\EventChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\EventLogChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>

View File

@ -610,6 +610,7 @@
<ClCompile Include="src\Channel.cpp"/>
<ClCompile Include="src\Configurable.cpp"/>
<ClCompile Include="src\ConsoleChannel.cpp"/>
<ClCompile Include="src\EventChannel.cpp"/>
<ClCompile Include="src\EventLogChannel.cpp"/>
<ClCompile Include="src\FileChannel.cpp"/>
<ClCompile Include="src\Formatter.cpp"/>
@ -1153,6 +1154,7 @@
<ClInclude Include="include\Poco\Channel.h"/>
<ClInclude Include="include\Poco\Configurable.h"/>
<ClInclude Include="include\Poco\ConsoleChannel.h"/>
<ClInclude Include="include\Poco\EventChannel.h"/>
<ClInclude Include="include\Poco\EventLogChannel.h"/>
<ClInclude Include="include\Poco\FileChannel.h"/>
<ClInclude Include="include\Poco\Formatter.h"/>

View File

@ -579,6 +579,9 @@
<ClCompile Include="src\ConsoleChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\EventChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\EventLogChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
@ -1406,6 +1409,9 @@
<ClInclude Include="include\Poco\ConsoleChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\EventChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\EventLogChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>

View File

@ -610,6 +610,7 @@
<ClCompile Include="src\Channel.cpp"/>
<ClCompile Include="src\Configurable.cpp"/>
<ClCompile Include="src\ConsoleChannel.cpp"/>
<ClCompile Include="src\EventChannel.cpp"/>
<ClCompile Include="src\EventLogChannel.cpp"/>
<ClCompile Include="src\FileChannel.cpp"/>
<ClCompile Include="src\Formatter.cpp"/>
@ -1153,6 +1154,7 @@
<ClInclude Include="include\Poco\Channel.h"/>
<ClInclude Include="include\Poco\Configurable.h"/>
<ClInclude Include="include\Poco\ConsoleChannel.h"/>
<ClInclude Include="include\Poco\EventChannel.h"/>
<ClInclude Include="include\Poco\EventLogChannel.h"/>
<ClInclude Include="include\Poco\FileChannel.h"/>
<ClInclude Include="include\Poco\Formatter.h"/>

View File

@ -579,6 +579,9 @@
<ClCompile Include="src\ConsoleChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\EventChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\EventLogChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
@ -1406,6 +1409,9 @@
<ClInclude Include="include\Poco\ConsoleChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\EventChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\EventLogChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>

View File

@ -390,6 +390,7 @@
<ClCompile Include="src\ErrorHandler.cpp"/>
<ClCompile Include="src\Event.cpp"/>
<ClCompile Include="src\EventArgs.cpp"/>
<ClCompile Include="src\EventChannel.cpp"/>
<ClCompile Include="src\EventLogChannel.cpp"/>
<ClCompile Include="src\Event_POSIX.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'">true</ExcludedFromBuild>
@ -1077,6 +1078,7 @@
<ClInclude Include="include\Poco\ErrorHandler.h"/>
<ClInclude Include="include\Poco\Event.h"/>
<ClInclude Include="include\Poco\EventArgs.h"/>
<ClInclude Include="include\Poco\EventChannel.h"/>
<ClInclude Include="include\Poco\EventLogChannel.h"/>
<ClInclude Include="include\Poco\Event_POSIX.h"/>
<ClInclude Include="include\Poco\Event_WIN32.h"/>

View File

@ -579,6 +579,9 @@
<ClCompile Include="src\ConsoleChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\EventChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
<ClCompile Include="src\EventLogChannel.cpp">
<Filter>Logging\Source Files</Filter>
</ClCompile>
@ -1406,6 +1409,9 @@
<ClInclude Include="include\Poco\ConsoleChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\EventChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Poco\EventLogChannel.h">
<Filter>Logging\Header Files</Filter>
</ClInclude>

View File

@ -2097,6 +2097,8 @@
RelativePath=".\src\Configurable.cpp"/>
<File
RelativePath=".\src\ConsoleChannel.cpp"/>
<File
RelativePath=".\src\EventChannel.cpp"/>
<File
RelativePath=".\src\EventLogChannel.cpp"/>
<File
@ -2380,6 +2382,8 @@
RelativePath=".\include\Poco\Configurable.h"/>
<File
RelativePath=".\include\Poco\ConsoleChannel.h"/>
<File
RelativePath=".\include\Poco\EventChannel.h"/>
<File
RelativePath=".\include\Poco\EventLogChannel.h"/>
<File

View File

@ -13,8 +13,8 @@ objects = ArchiveStrategy Ascii ASCIIEncoding AsyncChannel \
BinaryReader BinaryWriter Bugcheck ByteOrder Channel Checksum Clock Configurable ConsoleChannel \
Condition CountingStream DateTime LocalDateTime DateTimeFormat DateTimeFormatter DateTimeParser \
Debugger DeflatingStream DigestEngine DigestStream DirectoryIterator DirectoryWatcher \
Environment Event Error EventArgs ErrorHandler Exception FIFOBufferStream FPEnvironment File \
FileChannel Formatter FormattingChannel Glob HexBinaryDecoder LineEndingConverter \
Environment Event Error EventArgs EventChannel ErrorHandler Exception FIFOBufferStream FPEnvironment \
File FileChannel Formatter FormattingChannel Glob HexBinaryDecoder LineEndingConverter \
HexBinaryEncoder InflatingStream JSONString Latin1Encoding Latin2Encoding Latin9Encoding \
LogFile Logger LoggingFactory LoggingRegistry LogStream NamedEvent NamedMutex NullChannel \
MemoryPool MD4Engine MD5Engine Manifest Message Mutex \

View File

@ -0,0 +1,56 @@
//
// EventChannel.h
//
// $Id$
//
// Library: Foundation
// Package: Logging
// Module: EventChannel
//
// Definition of the EventChannel class.
//
// Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Foundation_EventChannel_INCLUDED
#define Foundation_EventChannel_INCLUDED
#include "Poco/Foundation.h"
#include "Poco/Channel.h"
#include "Poco/Message.h"
#include "Poco/BasicEvent.h"
namespace Poco {
class Foundation_API EventChannel: public Channel
/// The EventChannel fires the messageLogged event for every log message
/// received. This can be used to hook custom log message processing into
/// the logging framework.
{
public:
Poco::BasicEvent<const Message> messageLogged;
/// Fired when a message is logged by calling the log() method.
EventChannel();
/// Creates the EventChannel.
void log(const Message& msg);
/// Fires the messageLogged event.
protected:
~EventChannel();
/// Destroys the EventChannel.
};
} // namespace Poco
#endif // Foundation_EventChannel_INCLUDED

View File

@ -23,6 +23,7 @@
#include "Poco/Foundation.h"
#include "Poco/Channel.h"
#include "Poco/Timestamp.h"
#include "Poco/Timespan.h"
#include "Poco/Mutex.h"
@ -243,6 +244,11 @@ protected:
void purge();
private:
bool setNoPurge(const std::string& value);
int extractDigit(const std::string& value, std::string::const_iterator* nextToDigit = NULL) const;
void setPurgeStrategy(PurgeStrategy* strategy);
Timespan::TimeDiff extractFactor(const std::string& value, std::string::const_iterator start) const;
std::string _path;
std::string _times;
std::string _rotation;

View File

@ -25,6 +25,7 @@
#include "Poco/Foundation.h"
#include <vector>
#include <map>
//
@ -91,8 +92,10 @@ public:
{
std::string::size_type offset; /// zero based offset (std::string::npos if subexpr does not match)
std::string::size_type length; /// length of substring
std::string name; /// name of group
};
typedef std::vector<Match> MatchVec;
typedef std::map<int, std::string> GroupMap;
RegularExpression(const std::string& pattern, int options = 0, bool study = true);
/// Creates a regular expression and parses the given pattern.
@ -212,6 +215,8 @@ private:
pcre* _pcre;
pcre_extra* _extra;
GroupMap _groups;
static const int OVEC_SIZE;
RegularExpression();

View File

@ -121,7 +121,7 @@ public:
static std::string prefix();
/// Returns the platform-specific filename prefix
/// for shared libraries.
/// Most platforms would return an empty string, but
/// Most platforms would return "lib" as prefix, while
/// on Cygwin, the "cyg" prefix will be returned.
static std::string suffix();
@ -130,6 +130,11 @@ public:
/// In debug mode, the suffix also includes a
/// "d" to specify the debug version of a library.
static std::string getOSName(const std::string& name);
/// Returns the platform-specific filename
/// for shared libraries by prefixing and suffixing name
/// with prefix() and suffix()
private:
SharedLibrary(const SharedLibrary&);
SharedLibrary& operator = (const SharedLibrary&);

View File

@ -0,0 +1,39 @@
//
// EventChannel.cpp
//
// $Id$
//
// Library: Foundation
// Package: Logging
// Module: EventChannel
//
// Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/EventChannel.h"
namespace Poco {
EventChannel::EventChannel()
{
}
EventChannel::~EventChannel()
{
}
void EventChannel::log(const Message& msg)
{
messageLogged(this, msg);
}
} // namespace Poco

View File

@ -24,7 +24,6 @@
#include "Poco/DateTime.h"
#include "Poco/LocalDateTime.h"
#include "Poco/String.h"
#include "Poco/Timespan.h"
#include "Poco/Exception.h"
#include "Poco/Ascii.h"
@ -314,65 +313,22 @@ void FileChannel::setCompress(const std::string& compress)
void FileChannel::setPurgeAge(const std::string& age)
{
delete _pPurgeStrategy;
_pPurgeStrategy = 0;
_purgeAge = "none";
if (setNoPurge(age)) return;
if (age.empty() || 0 == icompare(age, "none"))
return;
std::string::const_iterator nextToDigit;
int num = extractDigit(age, &nextToDigit);
Timespan::TimeDiff factor = extractFactor(age, nextToDigit);
std::string::const_iterator it = age.begin();
std::string::const_iterator end = age.end();
int n = 0;
while (it != end && Ascii::isSpace(*it)) ++it;
while (it != end && Ascii::isDigit(*it)) { n *= 10; n += *it++ - '0'; }
if (0 == n)
throw InvalidArgumentException("Zero is not valid purge age.");
while (it != end && Ascii::isSpace(*it)) ++it;
std::string unit;
while (it != end && Ascii::isAlpha(*it)) unit += *it++;
Timespan::TimeDiff factor = Timespan::SECONDS;
if (unit == "minutes")
factor = Timespan::MINUTES;
else if (unit == "hours")
factor = Timespan::HOURS;
else if (unit == "days")
factor = Timespan::DAYS;
else if (unit == "weeks")
factor = 7*Timespan::DAYS;
else if (unit == "months")
factor = 30*Timespan::DAYS;
else if (unit != "seconds")
throw InvalidArgumentException("purgeAge", age);
_pPurgeStrategy = new PurgeByAgeStrategy(Timespan(factor*n));
setPurgeStrategy(new PurgeByAgeStrategy(Timespan(num * factor)));
_purgeAge = age;
}
void FileChannel::setPurgeCount(const std::string& count)
{
delete _pPurgeStrategy;
_pPurgeStrategy = 0;
_purgeAge = "none";
if (setNoPurge(count)) return;
if (count.empty() || 0 == icompare(count, "none"))
return;
std::string::const_iterator it = count.begin();
std::string::const_iterator end = count.end();
int n = 0;
while (it != end && Ascii::isSpace(*it)) ++it;
while (it != end && Ascii::isDigit(*it)) { n *= 10; n += *it++ - '0'; }
if (0 == n)
throw InvalidArgumentException("Zero is not valid purge count.");
while (it != end && Ascii::isSpace(*it)) ++it;
delete _pPurgeStrategy;
_pPurgeStrategy = new PurgeByCountStrategy(n);
setPurgeStrategy(new PurgeByCountStrategy(extractDigit(count)));
_purgeCount = count;
}
@ -404,4 +360,71 @@ void FileChannel::purge()
}
bool FileChannel::setNoPurge(const std::string& value)
{
if (value.empty() || 0 == icompare(value, "none"))
{
delete _pPurgeStrategy;
_pPurgeStrategy = 0;
_purgeAge = "none";
return true;
}
else return false;
}
int FileChannel::extractDigit(const std::string& value, std::string::const_iterator* nextToDigit) const
{
std::string::const_iterator it = value.begin();
std::string::const_iterator end = value.end();
int digit = 0;
while (it != end && Ascii::isSpace(*it)) ++it;
while (it != end && Ascii::isDigit(*it))
{
digit *= 10;
digit += *it++ - '0';
}
if (digit == 0)
throw InvalidArgumentException("Zero is not valid purge age.");
if (nextToDigit) *nextToDigit = it;
return digit;
}
void FileChannel::setPurgeStrategy(PurgeStrategy* strategy)
{
delete _pPurgeStrategy;
_pPurgeStrategy = strategy;
}
Timespan::TimeDiff FileChannel::extractFactor(const std::string& value, std::string::const_iterator start) const
{
while (start != value.end() && Ascii::isSpace(*start)) ++start;
std::string unit;
while (start != value.end() && Ascii::isAlpha(*start)) unit += *start++;
if (unit == "seconds")
return Timespan::SECONDS;
if (unit == "minutes")
return Timespan::MINUTES;
else if (unit == "hours")
return Timespan::HOURS;
else if (unit == "days")
return Timespan::DAYS;
else if (unit == "weeks")
return 7 * Timespan::DAYS;
else if (unit == "months")
return 30 * Timespan::DAYS;
else throw InvalidArgumentException("purgeAge", value);
return Timespan::TimeDiff();
}
} // namespace Poco

View File

@ -22,6 +22,7 @@
#include "Poco/FormattingChannel.h"
#include "Poco/SplitterChannel.h"
#include "Poco/NullChannel.h"
#include "Poco/EventChannel.h"
#if defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_NO_SYSLOGCHANNEL)
#include "Poco/SyslogChannel.h"
#endif
@ -103,6 +104,7 @@ void LoggingFactory::registerBuiltins()
_channelFactory.registerClass("SplitterChannel", new Instantiator<SplitterChannel, Channel>);
#endif
_channelFactory.registerClass("NullChannel", new Instantiator<NullChannel, Channel>);
_channelFactory.registerClass("EventChannel", new Instantiator<EventChannel, Channel>);
#if defined(POCO_OS_FAMILY_UNIX)
#ifndef POCO_NO_SYSLOGCHANNEL

View File

@ -18,6 +18,7 @@
#include "Poco/Exception.h"
#include "Poco/NumberFormatter.h"
#include "Poco/Pipe.h"
#include <limits>
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
@ -68,7 +69,12 @@ int ProcessHandleImpl::wait() const
while (rc < 0 && errno == EINTR);
if (rc != _pid)
throw SystemException("Cannot wait for process", NumberFormatter::format(_pid));
if (WIFEXITED(status))
return WEXITSTATUS(status);
if (WIFSIGNALED(status))
return -WTERMSIG(status);
// This line should never be reached.
return std::numeric_limits<int>::max();
}
@ -150,6 +156,7 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
ProcessHandleImpl* ProcessImpl::launchByForkExecImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env)
{
#if !defined(POCO_NO_FORK_EXEC)
// We must not allocated memory after fork(),
// therefore allocate all required buffers first.
std::vector<char> envChars = getEnvironmentVariablesBuffer(env);
@ -213,6 +220,9 @@ ProcessHandleImpl* ProcessImpl::launchByForkExecImpl(const std::string& command,
if (outPipe) outPipe->close(Pipe::CLOSE_WRITE);
if (errPipe) errPipe->close(Pipe::CLOSE_WRITE);
return new ProcessHandleImpl(pid);
#else
throw Poco::NotImplementedException("platform does not allow fork/exec");
#endif
}

View File

@ -24,7 +24,6 @@
#include "pcre.h"
#endif
namespace Poco {
@ -35,6 +34,10 @@ RegularExpression::RegularExpression(const std::string& pattern, int options, bo
{
const char* error;
int offs;
unsigned nmcount;
unsigned nmentrysz;
unsigned char* nmtbl;
_pcre = pcre_compile(pattern.c_str(), options, &error, &offs, 0);
if (!_pcre)
{
@ -44,6 +47,18 @@ RegularExpression::RegularExpression(const std::string& pattern, int options, bo
}
if (study)
_extra = pcre_study(_pcre, 0, &error);
pcre_fullinfo(_pcre, _extra, PCRE_INFO_NAMECOUNT, &nmcount);
pcre_fullinfo(_pcre, _extra, PCRE_INFO_NAMEENTRYSIZE, &nmentrysz);
pcre_fullinfo(_pcre, _extra, PCRE_INFO_NAMETABLE, &nmtbl);
for (int i = 0; i < nmcount; i++)
{
unsigned char* group = nmtbl + 2 + (nmentrysz * i);
int n = pcre_get_stringnumber(_pcre, (char*) group);
_groups[n] = std::string((char*) group);
}
}
@ -116,8 +131,17 @@ int RegularExpression::match(const std::string& subject, std::string::size_type
for (int i = 0; i < rc; ++i)
{
Match m;
GroupMap::const_iterator it;
m.offset = ovec[i*2] < 0 ? std::string::npos : ovec[i*2] ;
m.length = ovec[i*2 + 1] - m.offset;
it = _groups.find(i);
if (it != _groups.end())
{
m.name = (*it).second;
}
matches.push_back(m);
}
return rc;

View File

@ -115,5 +115,9 @@ std::string SharedLibrary::suffix()
return suffixImpl();
}
std::string SharedLibrary::getOSName(const std::string& name)
{
return prefix() + name + suffix();
}
} // namespace Poco

View File

@ -85,7 +85,7 @@ const std::string& SharedLibraryImpl::getPathImpl() const
std::string SharedLibraryImpl::prefixImpl()
{
return "";
return "lib";
}

View File

@ -104,7 +104,7 @@ std::string SharedLibraryImpl::prefixImpl()
#if POCO_OS == POCO_OS_CYGWIN
return "cyg";
#else
return "";
return "lib";
#endif
}

View File

@ -38,6 +38,8 @@
#if POCO_OS == POCO_OS_LINUX
#include <sys/syscall.h>
#endif
#include <cstring>
//
// Block SIGPIPE in main thread.
@ -69,18 +71,26 @@ static SignalBlocker signalBlocker;
namespace {
void setThreadName(pthread_t thread, const char* threadName)
void setThreadName(pthread_t thread, const std::string& threadName)
{
# if (POCO_OS == POCO_OS_MAC_OS_X)
pthread_setname_np(threadName); // __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
# else
pthread_setname_np(thread, threadName);
# endif
}
}
#if (POCO_OS == POCO_OS_MAC_OS_X)
pthread_setname_np(threadName.c_str()); // __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
#else
if (pthread_setname_np(thread, threadName.c_str()))
{
char truncName[16] = {0};
std::size_t suffixIndex = threadName.length() - 7;
std::memcpy(truncName, &threadName[0], 7);
truncName[7] = '~';
memcpy(&truncName[8], &threadName[suffixIndex], 7);
pthread_setname_np(thread, truncName);
}
#endif
}
}
#endif // POCO_POSIX_DEBUGGER_THREAD_NAMES
namespace Poco {
@ -448,7 +458,7 @@ void* ThreadImpl::runnableEntry(void* pThread)
ThreadImpl* pThreadImpl = reinterpret_cast<ThreadImpl*>(pThread);
#if defined(POCO_POSIX_DEBUGGER_THREAD_NAMES)
setThreadName(pThreadImpl->_pData->thread, reinterpret_cast<Thread*>(pThread)->getName().c_str());
setThreadName(pThreadImpl->_pData->thread, reinterpret_cast<Thread*>(pThread)->getName());
#endif
#if POCO_OS == POCO_OS_LINUX
pThreadImpl->_pData->tid = static_cast<TIDImpl>( syscall (SYS_gettid) );

View File

@ -518,6 +518,34 @@ void FileChannelTest::testPurgeCount()
}
void FileChannelTest::testWrongPurgeOption()
{
std::string name = filename();
AutoPtr<FileChannel> pChannel = new FileChannel(name);
pChannel->setProperty(FileChannel::PROP_PURGEAGE, "5 seconds");
try
{
pChannel->setProperty(FileChannel::PROP_PURGEAGE, "peace");
fail("must fail");
} catch (InvalidArgumentException)
{
assert(pChannel->getProperty(FileChannel::PROP_PURGEAGE) == "5 seconds");
}
try
{
pChannel->setProperty(FileChannel::PROP_PURGECOUNT, "peace");
fail("must fail");
} catch (InvalidArgumentException)
{
assert(pChannel->getProperty(FileChannel::PROP_PURGEAGE) == "5 seconds");
}
remove(name);
}
void FileChannelTest::setUp()
{
}
@ -620,6 +648,7 @@ CppUnit::Test* FileChannelTest::suite()
CppUnit_addTest(pSuite, FileChannelTest, testCompress);
CppUnit_addTest(pSuite, FileChannelTest, testPurgeAge);
CppUnit_addTest(pSuite, FileChannelTest, testPurgeCount);
CppUnit_addTest(pSuite, FileChannelTest, testWrongPurgeOption);
return pSuite;
}

View File

@ -45,6 +45,7 @@ public:
void testCompress();
void testPurgeAge();
void testPurgeCount();
void testWrongPurgeOption();
void setUp();
void tearDown();

View File

@ -16,6 +16,7 @@
#include "Poco/Process.h"
#include "Poco/Pipe.h"
#include "Poco/PipeStream.h"
#include <csignal>
using Poco::Process;
@ -190,6 +191,27 @@ void ProcessTest::testIsRunning()
}
void ProcessTest::testSignalExitCode()
{
#if defined(POCO_OS_FAMILY_UNIX)
std::string name("TestApp");
std::string cmd;
#if defined(_DEBUG)
name += "d";
#endif
cmd = "./";
cmd += name;
std::vector<std::string> args;
args.push_back("-raise-int");
ProcessHandle ph = Process::launch(cmd, args, 0, 0, 0);
int rc = ph.wait();
assert (rc == -SIGINT);
#endif // defined(POCO_OS_FAMILY_UNIX)
}
void ProcessTest::setUp()
{
}
@ -209,6 +231,7 @@ CppUnit::Test* ProcessTest::suite()
CppUnit_addTest(pSuite, ProcessTest, testLaunchRedirectOut);
CppUnit_addTest(pSuite, ProcessTest, testLaunchEnv);
CppUnit_addTest(pSuite, ProcessTest, testIsRunning);
CppUnit_addTest(pSuite, ProcessTest, testSignalExitCode);
return pSuite;
}

View File

@ -31,6 +31,7 @@ public:
void testLaunchRedirectOut();
void testLaunchEnv();
void testIsRunning();
void testSignalExitCode();
void setUp();
void tearDown();

View File

@ -264,6 +264,16 @@ void RegularExpressionTest::testError()
}
}
void RegularExpressionTest::testGroup()
{
RegularExpression::MatchVec matches;
RegularExpression re("(?P<group1>[a-z]+) (?P<group2>[0-9]+)");
assert (re.match("abcd 1234", 0, matches) == 3);
assert (matches[0].name == "");
assert (matches[1].name == "group1");
assert (matches[2].name == "group2");
}
void RegularExpressionTest::setUp()
{
@ -294,6 +304,7 @@ CppUnit::Test* RegularExpressionTest::suite()
CppUnit_addTest(pSuite, RegularExpressionTest, testSubst3);
CppUnit_addTest(pSuite, RegularExpressionTest, testSubst4);
CppUnit_addTest(pSuite, RegularExpressionTest, testError);
CppUnit_addTest(pSuite, RegularExpressionTest, testGroup);
return pSuite;
}

View File

@ -41,6 +41,7 @@ public:
void testSubst3();
void testSubst4();
void testError();
void testGroup();
void setUp();
void tearDown();

View File

@ -18,6 +18,7 @@
#include <string>
#include <iostream>
#include <cstdlib>
#include <csignal>
int main(int argc, char** argv)
@ -46,6 +47,10 @@ int main(int argc, char** argv)
}
else return 1;
}
else if (arg == "-raise-int")
{
std::raise(SIGINT);
}
}
return argc - 1;
}

View File

@ -25,7 +25,6 @@
#include <limits>
#include <clocale>
#include <istream>
#include <iostream>
namespace Poco {

View File

@ -61,6 +61,7 @@ public:
virtual int sendTo(const void* buffer, int length, const SocketAddress& address, int flags = 0);
virtual int receiveFrom(void* buffer, int length, SocketAddress& address, int flags = 0);
virtual void sendUrgent(unsigned char data);
virtual int available();
virtual bool secure() const;
virtual void setSendTimeout(const Poco::Timespan& timeout);
virtual Poco::Timespan getSendTimeout();

View File

@ -41,8 +41,11 @@ HTTPClientSession* HTTPSessionInstantiator::createClientSession(const Poco::URI&
{
poco_assert (uri.getScheme() == "http");
HTTPClientSession* pSession = new HTTPClientSession(uri.getHost(), uri.getPort());
if (!proxyHost().empty())
{
pSession->setProxy(proxyHost(), proxyPort());
pSession->setProxyCredentials(proxyUsername(), proxyPassword());
}
return pSession;
}

View File

@ -341,4 +341,10 @@ Poco::Timespan WebSocketImpl::getReceiveTimeout()
}
int WebSocketImpl::available()
{
return _pStreamSocketImpl->available();
}
} } // namespace Poco::Net

View File

@ -120,7 +120,7 @@ void WebSocketTest::testWebSocket()
Poco::Thread::sleep(200);
HTTPClientSession cs("localhost", ss.address().port());
HTTPRequest request(HTTPRequest::HTTP_GET, "/ws");
HTTPRequest request(HTTPRequest::HTTP_GET, "/ws", HTTPRequest::HTTP_1_1);
HTTPResponse response;
WebSocket ws(cs, request, response);
@ -201,7 +201,7 @@ void WebSocketTest::testWebSocketLarge()
Poco::Thread::sleep(200);
HTTPClientSession cs("localhost", ss.address().port());
HTTPRequest request(HTTPRequest::HTTP_GET, "/ws");
HTTPRequest request(HTTPRequest::HTTP_GET, "/ws", HTTPRequest::HTTP_1_1);
HTTPResponse response;
WebSocket ws(cs, request, response);
ws.setSendBufferSize(msgSize);
@ -233,7 +233,7 @@ void WebSocketTest::testOneLargeFrame(int msgSize)
Poco::Thread::sleep(200);
HTTPClientSession cs("localhost", ss.address().port());
HTTPRequest request(HTTPRequest::HTTP_GET, "/ws");
HTTPRequest request(HTTPRequest::HTTP_GET, "/ws", HTTPRequest::HTTP_1_1);
HTTPResponse response;
WebSocket ws(cs, request, response);
ws.setSendBufferSize(msgSize);

View File

@ -5,7 +5,6 @@
#
# Makefile for Poco NetSSL_OpenSSL
#
include $(POCO_BASE)/build/rules/global
SYSLIBS += -lssl -lcrypto

View File

@ -333,13 +333,19 @@ void Context::createSSLContext()
case SERVER_USE:
_pSSLContext = SSL_CTX_new(SSLv23_server_method());
break;
#if defined(SSL_OP_NO_TLSv1) && !defined(OPENSSL_NO_TLS1)
case TLSV1_CLIENT_USE:
_pSSLContext = SSL_CTX_new(TLSv1_client_method());
break;
case TLSV1_SERVER_USE:
_pSSLContext = SSL_CTX_new(TLSv1_server_method());
break;
#if OPENSSL_VERSION_NUMBER >= 0x10000000L
#endif
#if defined(SSL_OP_NO_TLSv1_1) && !defined(OPENSSL_NO_TLS1)
/* SSL_OP_NO_TLSv1_1 is defined in ssl.h if the library version supports TLSv1.1.
* OPENSSL_NO_TLS1 is defined in opensslconf.h or on the compiler command line
* if TLS1.x was removed at OpenSSL library build time via Configure options.
*/
case TLSV1_1_CLIENT_USE:
_pSSLContext = SSL_CTX_new(TLSv1_1_client_method());
break;
@ -347,7 +353,7 @@ void Context::createSSLContext()
_pSSLContext = SSL_CTX_new(TLSv1_1_server_method());
break;
#endif
#if OPENSSL_VERSION_NUMBER >= 0x10001000L
#if defined(SSL_OP_NO_TLSv1_2) && !defined(OPENSSL_NO_TLS1)
case TLSV1_2_CLIENT_USE:
_pSSLContext = SSL_CTX_new(TLSv1_2_client_method());
break;

View File

@ -43,8 +43,11 @@ HTTPClientSession* HTTPSSessionInstantiator::createClientSession(const Poco::URI
{
poco_assert (uri.getScheme() == "https");
HTTPSClientSession* pSession = _pContext.isNull() ? new HTTPSClientSession(uri.getHost(), uri.getPort()) : new HTTPSClientSession(uri.getHost(), uri.getPort(), _pContext);
if (!proxyHost().empty())
{
pSession->setProxy(proxyHost(), proxyPort());
pSession->setProxyCredentials(proxyUsername(), proxyPassword());
}
return pSession;
}

View File

@ -43,8 +43,11 @@ HTTPClientSession* HTTPSSessionInstantiator::createClientSession(const Poco::URI
{
poco_assert (uri.getScheme() == "https");
HTTPSClientSession* pSession = _pContext.isNull() ? new HTTPSClientSession(uri.getHost(), uri.getPort()) : new HTTPSClientSession(uri.getHost(), uri.getPort(), _pContext);
if (!proxyHost().empty())
{
pSession->setProxy(proxyHost(), proxyPort());
pSession->setProxyCredentials(proxyUsername(), proxyPassword());
}
return pSession;
}

View File

@ -108,7 +108,7 @@ private:
void saveKeyValue(std::istream& istr);
bool isNewLine(int c) const;
bool isKeyValueSeparator(int c) const;
void outputKeyValue(std::ostream& ostr, const std::string& key, const std::string& value) const;
std::string composeOneLine(const std::string& key, const std::string& value) const;
bool _preserveComment;
FileContent _fileContent;

View File

@ -81,23 +81,13 @@ void PropertyFileConfiguration::save(std::ostream& ostr) const
{
if (_preserveComment)
{
// Check the starting char of each line in _fileContent.
// If the char is a comment sign, write the line out directly.
// Otherwise, use this line as key to get the value from parent's map and write out.
for (FileContent::const_iterator it = _fileContent.begin(); it != _fileContent.end(); ++it)
{
if (isComment((*it)[0])) ostr << *it;
else outputKeyValue(ostr, *it, getString(*it));
ostr << *it;
}
} else
else
{
MapConfiguration::iterator it = begin();
MapConfiguration::iterator ed = end();
while (it != ed)
{
outputKeyValue(ostr, it->first, it->second);
++it;
}
for (MapConfiguration::iterator it = begin(); it != end(); ++it)
ostr << composeOneLine(it->first, it->second);
}
}
@ -117,6 +107,9 @@ void PropertyFileConfiguration::save(const std::string& path) const
}
// If _preserveComment is true, not only save key-value into map
// but also save the entire file into _fileContent.
// Otherwise, only save key-value into map.
void PropertyFileConfiguration::parseLine(std::istream& istr)
{
skipSpace(istr);
@ -125,7 +118,6 @@ void PropertyFileConfiguration::parseLine(std::istream& istr)
{
if (isComment(istr.peek()))
{
// Save
if (_preserveComment) saveComment(istr);
else skipLine(istr);
}
@ -179,12 +171,21 @@ int PropertyFileConfiguration::readChar(std::istream& istr)
void PropertyFileConfiguration::setRaw(const std::string& key, const std::string& value)
{
MapConfiguration::setRaw(key, value);
// Insert the key to the end of _fileContent and update _keyFileContentItMap.
if (_preserveComment)
{
FileContent::iterator fit = _fileContent.insert(_fileContent.end(), key);
// Insert the key-value to the end of _fileContent and update _keyFileContentItMap.
if (_keyFileContentItMap.count(key) == 0)
{
FileContent::iterator fit = _fileContent.insert(_fileContent.end(), composeOneLine(key, value));
_keyFileContentItMap[key] = fit;
}
// Update the key-value in _fileContent.
else
{
FileContent::iterator fit = _keyFileContentItMap[key];
*fit = composeOneLine(key, value);
}
}
}
@ -260,36 +261,36 @@ bool PropertyFileConfiguration::isNewLine(int c) const
}
void PropertyFileConfiguration::outputKeyValue(std::ostream& ostr, const std::string& key, const std::string& value) const
std::string PropertyFileConfiguration::composeOneLine(const std::string& key, const std::string& value) const
{
ostr << key << ": ";
std::string result = key + ": ";
for (std::string::const_iterator its = value.begin(); its != value.end(); ++its)
{
switch (*its)
{
case '\t':
ostr << "\\t";
result += "\\t";
break;
case '\r':
ostr << "\\r";
result += "\\r";
break;
case '\n':
ostr << "\\n";
result += "\\n";
break;
case '\f':
ostr << "\\f";
result += "\\f";
break;
case '\\':
ostr << "\\\\";
result += "\\\\";
break;
default:
ostr << *its;
result += *its;
break;
}
}
ostr << "\n";
return result += "\n";
}

View File

@ -682,6 +682,7 @@ bool ServerApplication::isDaemon(int argc, char** argv)
void ServerApplication::beDaemon()
{
#if !defined(POCO_NO_FORK_EXEC)
pid_t pid;
if ((pid = fork()) < 0)
throw SystemException("cannot fork daemon process");
@ -701,6 +702,9 @@ void ServerApplication::beDaemon()
if (!fout) throw Poco::OpenFileException("Cannot attach stdout to /dev/null");
FILE* ferr = freopen("/dev/null", "r+", stderr);
if (!ferr) throw Poco::OpenFileException("Cannot attach stderr to /dev/null");
#else
throw Poco::NotImplementedException("platform does not allow fork/exec");
#endif
}

View File

@ -140,7 +140,8 @@ void PropertyFileConfigurationTest::testLoadSaveWithPreserveComment()
"# comment !\n"
"prop2 = value2 \n"
"! comment !\n"
"prop3:foo";
"prop3:foo\n"
"prop4";
std::istringstream istr(propFile);
AutoPtr<PropertyFileConfiguration> pConf = new PropertyFileConfiguration(istr, true);
@ -153,7 +154,8 @@ void PropertyFileConfigurationTest::testLoadSaveWithPreserveComment()
"# comment !\n"
"prop2: value2\n"
"! comment !\n"
"prop3: foo\n",
"prop3: foo\n"
"prop4: \n",
ostr.str());
pConf->setString("prop4", "value4");
@ -182,6 +184,19 @@ void PropertyFileConfigurationTest::testLoadSaveWithPreserveComment()
"prop3: foo\n"
"prop4: value4\n",
ostr.str());
pConf->setString("prop4", "value5");
ostr.clear();
ostr.str("");
pConf->save(ostr);
assertEqual ("! comment #\n"
"prop1: value1\n"
"# comment #\n"
"# comment !\n"
"! comment !\n"
"prop3: foo\n"
"prop4: value5\n",
ostr.str());
}

98
build/config/AppleTV Normal file
View File

@ -0,0 +1,98 @@
#
# $Id$
#
# AppleTV
#
# Build settings for tvOS 9.0 and newer
#
#
# General Settings
#
# tvOS does not allow dynamic linking to user libraries
#
LINKMODE ?= STATIC
#
# If the SDK is defined use it
# Otherwise find the latest version installed
#
# TVOS_SDK_VERSION = 9.0
# if TVOS_SDK_VERSION_MIN is defined use that
# Otherwise use the version found.
TVOS_SDK ?= AppleTVOS
TVOS_SDK_ROOT ?= $(shell xcode-select -print-path)/Platforms/$(TVOS_SDK).platform/Developer/SDKs
TVOS_SDK_ROOT_DIR = $(TVOS_SDK_ROOT)/$(TVOS_SDK)
TVOS_SDK_BASE = $(shell ls -d $(TVOS_SDK_ROOT_DIR)$(TVOS_SDK_VERSION)*.sdk | tail -1)
TVOS_SDK_VERSION_MIN ?= $(patsubst %.sdk,%,$(patsubst $(TVOS_SDK_ROOT_DIR)%,%,$(TVOS_SDK_BASE)))
POCO_TARGET_OSNAME ?= $(TVOS_SDK)
POCO_TARGET_OSARCH ?= arm64
TOOL_PREFIX ?= $(shell xcode-select -print-path)/Platforms/$(TVOS_SDK).platform/Developer/usr/bin
OSFLAGS ?= -arch $(POCO_TARGET_OSARCH) -isysroot $(TVOS_SDK_BASE) -mtvos-version-min=$(TVOS_SDK_VERSION_MIN)
#
# Tools
#
# If GCC_VER is defined then use it.
# Otherwise select the latest version
#
CC = $(shell xcrun -find clang)
CXX = $(shell xcrun -find clang++)
LINK = $(CXX) -bind_at_load
LIB = libtool -static -o
RANLIB = ranlib
SHLIB = $(CXX) $(OSFLAGS) -dynamiclib -Wl,-install_name,$@ -o $@
DYLIB = $(CXX) $(OSFLAGS) -dynamic -bundle -read_only_relocs suppress -Wl,-bind_at_load -o $@
SHLIBLN = $(POCO_BASE)/build/script/shlibln
STRIP =
DEP = $(POCO_BASE)/build/script/makedepend.gcc
SHELL = sh
RM = rm -rf
CP = cp
MKDIR = mkdir -p
#
# Extension for Shared Libraries
#
SHAREDLIBEXT = .$(target_version).dylib
SHAREDLIBLINKEXT = .dylib
#
# Compiler and Linker Flags
#
CFLAGS = $(OSFLAGS)
CFLAGS32 =
CFLAGS64 =
CXXFLAGS = $(OSFLAGS) -std=c++11 -stdlib=libc++ -Wall -Wno-sign-compare
CXXFLAGS32 =
CXXFLAGS64 =
LINKFLAGS = $(OSFLAGS) -stdlib=libc++
LINKFLAGS32 =
LINKFLAGS64 =
STATICOPT_CC =
STATICOPT_CXX =
STATICOPT_LINK =
SHAREDOPT_CC = -fPIC
SHAREDOPT_CXX = -fPIC
SHAREDOPT_LINK =
DEBUGOPT_CC = -g -D_DEBUG=$(DEBUGLEVEL)
DEBUGOPT_CXX = -g -D_DEBUG=$(DEBUGLEVEL)
DEBUGOPT_LINK =
RELEASEOPT_CC = -DNDEBUG -O2
RELEASEOPT_CXX = -DNDEBUG -O
RELEASEOPT_LINK =
#
# System Specific Flags
#
SYSFLAGS = -DPOCO_HAVE_IPv6 -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_STAT64 -DPOCO_NO_SHAREDLIBS -DPOCO_NO_NET_IFTYPES -DPOCO_NO_FORK_EXEC
#
# System Specific Libraries
#
SYSLIBS = -ldl

View File

@ -0,0 +1,13 @@
#
# $Id$
#
# AppleTVSimulator
#
# Build settings for tvOS 9.0 Simulator
#
TVOS_SDK = AppleTVSimulator
POCO_TARGET_OSARCH = x86_64
OSFLAGS = -arch $(POCO_TARGET_OSARCH) -isysroot $(TVOS_SDK_BASE) -mtvos-simulator-version-min=$(TVOS_SDK_VERSION_MIN)
include $(POCO_BASE)/build/config/AppleTV

98
build/config/WatchOS Normal file
View File

@ -0,0 +1,98 @@
#
# $Id$
#
# WatchOS
#
# Build settings for Apple WatchOS 2.0 and newer
#
#
# General Settings
#
# WATCHOS does not allow dynamic linking to user libraries
#
LINKMODE ?= STATIC
#
# If the SDK is defined use it
# Otherwise find the latest version installed
#
# WATCHOS_SDK_VERSION = 2.0
# if WATCHOS_SDK_VERSION_MIN is defined use that
# Otherwise use the version found.
WATCHOS_SDK ?= WatchOS
WATCHOS_SDK_ROOT ?= $(shell xcode-select -print-path)/Platforms/$(WATCHOS_SDK).platform/Developer/SDKs
WATCHOS_SDK_ROOT_DIR = $(WATCHOS_SDK_ROOT)/$(WATCHOS_SDK)
WATCHOS_SDK_BASE = $(shell ls -d $(WATCHOS_SDK_ROOT_DIR)$(WATCHOS_SDK_VERSION)*.sdk | tail -1)
WATCHOS_SDK_VERSION_MIN ?= $(patsubst %.sdk,%,$(patsubst $(WATCHOS_SDK_ROOT_DIR)%,%,$(WATCHOS_SDK_BASE)))
POCO_TARGET_OSNAME ?= $(WATCHOS_SDK)
POCO_TARGET_OSARCH ?= armv7k
TOOL_PREFIX ?= $(shell xcode-select -print-path)/Platforms/$(WATCHOS_SDK).platform/Developer/usr/bin
OSFLAGS ?= -arch $(POCO_TARGET_OSARCH) -isysroot $(WATCHOS_SDK_BASE) -mwatchos-version-min=$(WATCHOS_SDK_VERSION_MIN)
#
# Tools
#
# If GCC_VER is defined then use it.
# Otherwise select the latest version
#
CC = $(shell xcrun -find clang)
CXX = $(shell xcrun -find clang++)
LINK = $(CXX) -bind_at_load
LIB = libtool -static -o
RANLIB = ranlib
SHLIB = $(CXX) $(OSFLAGS) -dynamiclib -Wl,-install_name,$@ -o $@
DYLIB = $(CXX) $(OSFLAGS) -dynamic -bundle -read_only_relocs suppress -Wl,-bind_at_load -o $@
SHLIBLN = $(POCO_BASE)/build/script/shlibln
STRIP =
DEP = $(POCO_BASE)/build/script/makedepend.gcc
SHELL = sh
RM = rm -rf
CP = cp
MKDIR = mkdir -p
#
# Extension for Shared Libraries
#
SHAREDLIBEXT = .$(target_version).dylib
SHAREDLIBLINKEXT = .dylib
#
# Compiler and Linker Flags
#
CFLAGS = $(OSFLAGS)
CFLAGS32 =
CFLAGS64 =
CXXFLAGS = $(OSFLAGS) -std=c++11 -stdlib=libc++ -Wall -Wno-sign-compare
CXXFLAGS32 =
CXXFLAGS64 =
LINKFLAGS = $(OSFLAGS) -stdlib=libc++
LINKFLAGS32 =
LINKFLAGS64 =
STATICOPT_CC =
STATICOPT_CXX =
STATICOPT_LINK =
SHAREDOPT_CC = -fPIC
SHAREDOPT_CXX = -fPIC
SHAREDOPT_LINK =
DEBUGOPT_CC = -g -D_DEBUG=$(DEBUGLEVEL)
DEBUGOPT_CXX = -g -D_DEBUG=$(DEBUGLEVEL)
DEBUGOPT_LINK =
RELEASEOPT_CC = -DNDEBUG -O2
RELEASEOPT_CXX = -DNDEBUG -O
RELEASEOPT_LINK =
#
# System Specific Flags
#
SYSFLAGS = -DPOCO_HAVE_IPv6 -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_STAT64 -DPOCO_NO_SHAREDLIBS -DPOCO_NO_NET_IFTYPES -DPOCO_NO_FORK_EXEC
#
# System Specific Libraries
#
SYSLIBS = -ldl

View File

@ -0,0 +1,13 @@
#
# $Id$
#
# WatchSimulator
#
# Build settings for WatchOS 2.0 Simulator
#
WATCHOS_SDK = WatchSimulator
POCO_TARGET_OSARCH = i386
OSFLAGS = -arch $(POCO_TARGET_OSARCH) -isysroot $(WATCHOS_SDK_BASE) -mwatchos-simulator-version-min=$(WATCHOS_SDK_VERSION_MIN)
include $(POCO_BASE)/build/config/WatchOS

View File

@ -16,15 +16,18 @@ if (WIN32)
# be set up anyway
get_filename_component(sdk_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]" REALPATH)
get_filename_component(kit_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot]" REALPATH)
get_filename_component(kit81_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot81]" REALPATH)
if (X64)
set(sdk_bindir "${sdk_dir}/bin/x64")
set(kit_bindir "${kit_dir}/bin/x64")
set(kit81_bindir "${kit81_dir}/bin/x64")
else (X64)
set(sdk_bindir "${sdk_dir}/bin")
set(kit_bindir "${kit_dir}/bin/x86")
set(kit81_bindir "${kit81_dir}/bin/x86")
endif (X64)
endif ()
find_program(CMAKE_MC_COMPILER mc.exe HINTS "${sdk_bindir}" "${kit_bindir}"
find_program(CMAKE_MC_COMPILER mc.exe HINTS "${sdk_bindir}" "${kit_bindir}" "${kit81_bindir}"
DOC "path to message compiler")
if (NOT CMAKE_MC_COMPILER)
message(FATAL_ERROR "message compiler not found: required to build")