Update POCO library.

This commit is contained in:
Sandu Liviu Catalin
2023-03-23 20:19:11 +02:00
parent 8d15f4b6e9
commit 233fc103f9
2521 changed files with 257092 additions and 72789 deletions
+17 -17
View File
@@ -27,24 +27,24 @@ const char* ASCIIEncoding::_names[] =
};
const TextEncoding::CharacterMap ASCIIEncoding::_charMap =
const TextEncoding::CharacterMap ASCIIEncoding::_charMap =
{
/* 00 */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
/* 10 */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
/* 20 */ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
/* 30 */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
/* 40 */ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
/* 50 */ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
/* 60 */ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
/* 70 */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
/* 80 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
/* 90 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
/* a0 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
/* b0 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
/* c0 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
/* d0 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
/* e0 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
/* f0 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
/* 00 */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
/* 10 */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
/* 20 */ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
/* 30 */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
/* 40 */ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
/* 50 */ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
/* 60 */ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
/* 70 */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
/* 80 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
/* 90 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
/* a0 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
/* b0 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
/* c0 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
/* d0 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
/* e0 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
/* f0 */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
};
+1 -1
View File
@@ -32,7 +32,7 @@ AbstractObserver::~AbstractObserver()
{
}
AbstractObserver& AbstractObserver::operator = (const AbstractObserver& /*observer*/)
{
return *this;
+3 -3
View File
@@ -29,16 +29,16 @@ namespace
_pRunnable(pRunnable)
{
}
ActiveRunnableBase::Ptr runnable() const
{
return _pRunnable;
}
private:
ActiveRunnableBase::Ptr _pRunnable;
};
class StopNotification: public Notification
{
};
+10 -4
View File
@@ -40,11 +40,11 @@ public:
compress(this, &ArchiveCompressor::compressImpl)
{
}
~ArchiveCompressor()
{
}
ActiveMethod<void, std::string, ArchiveCompressor, ActiveStarter<ActiveDispatcher>> compress;
protected:
@@ -83,7 +83,7 @@ protected:
//
ArchiveStrategy::ArchiveStrategy():
ArchiveStrategy::ArchiveStrategy():
_compress(false),
_pCompressor(0)
{
@@ -161,6 +161,12 @@ ArchiveByNumberStrategy::~ArchiveByNumberStrategy()
}
LogFile* ArchiveByNumberStrategy::open(LogFile* pFile)
{
return pFile;
}
LogFile* ArchiveByNumberStrategy::archive(LogFile* pFile)
{
std::string basePath = pFile->path();
@@ -174,7 +180,7 @@ LogFile* ArchiveByNumberStrategy::archive(LogFile* pFile)
NumberFormatter::append(path, ++n);
}
while (exists(path));
while (n >= 0)
{
std::string oldPath = basePath;
+1 -1
View File
@@ -18,7 +18,7 @@
namespace Poco {
const int Ascii::CHARACTER_PROPERTIES[128] =
const int Ascii::CHARACTER_PROPERTIES[128] =
{
/* 00 . */ ACP_CONTROL,
/* 01 . */ ACP_CONTROL,
+12 -7
View File
@@ -51,7 +51,8 @@ private:
AsyncChannel::AsyncChannel(Channel::Ptr pChannel, Thread::Priority prio):
_pChannel(pChannel),
_thread("AsyncChannel")
_thread("AsyncChannel"),
_closed(false)
{
_thread.setPriority(prio);
}
@@ -94,21 +95,25 @@ void AsyncChannel::open()
void AsyncChannel::close()
{
if (_thread.isRunning())
if (!_closed.exchange(true))
{
while (!_queue.empty()) Thread::sleep(100);
do
if (_thread.isRunning())
{
_queue.wakeUpAll();
while (!_queue.empty()) Thread::sleep(100);
do
{
_queue.wakeUpAll();
}
while (!_thread.tryJoin(100));
}
while (!_thread.tryJoin(100));
}
}
void AsyncChannel::log(const Message& msg)
{
if (_closed) return;
if (_queueSize != 0 && _queue.size() >= _queueSize)
{
++_dropCount;
+2 -2
View File
@@ -23,7 +23,7 @@ AtomicCounter::AtomicCounter():
{
}
AtomicCounter::AtomicCounter(AtomicCounter::ValueType initialValue):
_counter(initialValue)
{
@@ -47,7 +47,7 @@ AtomicCounter& AtomicCounter::operator = (const AtomicCounter& counter)
return *this;
}
AtomicCounter& AtomicCounter::operator = (AtomicCounter::ValueType value)
{
_counter.store(value);
+5 -5
View File
@@ -32,7 +32,7 @@ namespace
}
Base32DecoderBuf::Base32DecoderBuf(std::istream& istr):
Base32DecoderBuf::Base32DecoderBuf(std::istream& istr):
_groupLength(0),
_groupIndex(0),
_buf(*istr.rdbuf())
@@ -61,7 +61,7 @@ Base32DecoderBuf::~Base32DecoderBuf()
int Base32DecoderBuf::readFromDevice()
{
if (_groupIndex < _groupLength)
if (_groupIndex < _groupLength)
{
return _group[_groupIndex++];
}
@@ -109,11 +109,11 @@ int Base32DecoderBuf::readFromDevice()
if (buffer[2] == '=')
_groupLength = 1;
else if (buffer[4] == '=')
else if (buffer[4] == '=')
_groupLength = 2;
else if (buffer[5] == '=')
else if (buffer[5] == '=')
_groupLength = 3;
else if (buffer[7] == '=')
else if (buffer[7] == '=')
_groupLength = 4;
else
_groupLength = 5;
+1 -1
View File
@@ -27,7 +27,7 @@ const unsigned char Base32EncoderBuf::OUT_ENCODING[32] =
};
Base32EncoderBuf::Base32EncoderBuf(std::ostream& ostr, bool padding):
Base32EncoderBuf::Base32EncoderBuf(std::ostream& ostr, bool padding):
_groupLength(0),
_buf(*ostr.rdbuf()),
_doPadding(padding)
+1 -1
View File
@@ -90,7 +90,7 @@ void Bugcheck::unexpected(const char* file, int line)
catch (...)
{
}
#endif
#endif
}
+8 -8
View File
@@ -85,7 +85,7 @@ Clock& Clock::operator = (ClockVal tv)
}
void Clock::swap(Clock& timestamp)
void Clock::swap(Clock& timestamp) noexcept
{
std::swap(_clock, timestamp._clock);
}
@@ -112,7 +112,7 @@ void Clock::update()
host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cs);
clock_get_time(cs, &ts);
mach_port_deallocate(mach_task_self(), cs);
_clock = ClockVal(ts.tv_sec)*resolution() + ts.tv_nsec/1000;
#elif defined(POCO_VXWORKS)
@@ -138,7 +138,7 @@ void Clock::update()
Poco::Timestamp now;
_clock = now.epochMicroseconds();
#endif
}
@@ -164,7 +164,7 @@ Clock::ClockDiff Clock::accuracy()
host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cs);
clock_get_attributes(cs, CLOCK_GET_TIME_RES, (clock_attr_t)&nanosecs, &n);
mach_port_deallocate(mach_task_self(), cs);
ClockVal acc = nanosecs/1000;
return acc > 0 ? acc : 1;
@@ -186,18 +186,18 @@ Clock::ClockDiff Clock::accuracy()
struct timespec ts;
if (clock_getres(CLOCK_MONOTONIC, &ts))
throw SystemException("cannot get system clock");
ClockVal acc = ClockVal(ts.tv_sec)*resolution() + ts.tv_nsec/1000;
return acc > 0 ? acc : 1;
#else
return 1000;
#endif
}
bool Clock::monotonic()
{
#if defined(POCO_OS_FAMILY_WINDOWS)
@@ -223,7 +223,7 @@ bool Clock::monotonic()
#else
return false;
#endif
}
+2 -2
View File
@@ -30,7 +30,7 @@ Condition::~Condition()
void Condition::signal()
{
FastMutex::ScopedLock lock(_mutex);
if (!_waitQueue.empty())
{
_waitQueue.front()->set();
@@ -42,7 +42,7 @@ void Condition::signal()
void Condition::broadcast()
{
FastMutex::ScopedLock lock(_mutex);
for (auto p: _waitQueue)
{
p->set();
+7 -7
View File
@@ -43,7 +43,7 @@ ConsoleChannel::~ConsoleChannel()
void ConsoleChannel::log(const Message& msg)
{
FastMutex::ScopedLock lock(_mutex);
_str << msg.getText() << std::endl;
}
@@ -52,7 +52,7 @@ FastMutex ColorConsoleChannel::_mutex;
const std::string ColorConsoleChannel::CSI("\033[");
ColorConsoleChannel::ColorConsoleChannel():
ColorConsoleChannel::ColorConsoleChannel():
_str(std::clog),
_enableColors(true)
{
@@ -60,7 +60,7 @@ ColorConsoleChannel::ColorConsoleChannel():
}
ColorConsoleChannel::ColorConsoleChannel(std::ostream& str):
ColorConsoleChannel::ColorConsoleChannel(std::ostream& str):
_str(str),
_enableColors(true)
{
@@ -76,7 +76,7 @@ ColorConsoleChannel::~ColorConsoleChannel()
void ColorConsoleChannel::log(const Message& msg)
{
FastMutex::ScopedLock lock(_mutex);
if (_enableColors)
{
int color = _colors[msg.getPriority()];
@@ -87,14 +87,14 @@ void ColorConsoleChannel::log(const Message& msg)
color &= 0xff;
_str << CSI << color << "m";
}
_str << msg.getText();
if (_enableColors)
{
_str << CSI << "0m";
}
_str << std::endl;
}
+19 -19
View File
@@ -18,31 +18,31 @@
namespace Poco {
CountingStreamBuf::CountingStreamBuf():
_pIstr(0),
_pOstr(0),
_chars(0),
_lines(0),
CountingStreamBuf::CountingStreamBuf():
_pIstr(0),
_pOstr(0),
_chars(0),
_lines(0),
_pos(0)
{
}
CountingStreamBuf::CountingStreamBuf(std::istream& istr):
_pIstr(&istr),
_pOstr(0),
_chars(0),
_lines(0),
CountingStreamBuf::CountingStreamBuf(std::istream& istr):
_pIstr(&istr),
_pOstr(0),
_chars(0),
_lines(0),
_pos(0)
{
}
CountingStreamBuf::CountingStreamBuf(std::ostream& ostr):
_pIstr(0),
_pOstr(&ostr),
_chars(0),
_lines(0),
CountingStreamBuf::CountingStreamBuf(std::ostream& ostr):
_pIstr(0),
_pOstr(&ostr),
_chars(0),
_lines(0),
_pos(0)
{
}
@@ -99,13 +99,13 @@ void CountingStreamBuf::addChars(std::streamsize charsToAdd)
_chars += charsToAdd;
}
void CountingStreamBuf::addLines(std::streamsize linesToAdd)
{
_lines += linesToAdd;
}
void CountingStreamBuf::addPos(std::streamsize posToAdd)
{
_pos += posToAdd;
@@ -152,13 +152,13 @@ void CountingIOS::addChars(std::streamsize charsToAdd)
_buf.addChars(charsToAdd);
}
void CountingIOS::addLines(std::streamsize linesToAdd)
{
_buf.addLines(linesToAdd);
}
void CountingIOS::addPos(std::streamsize posToAdd)
{
_buf.addPos(posToAdd);
+16 -9
View File
@@ -78,7 +78,7 @@ DateTime::DateTime(int year, int month, int day, int hour, int minute, int secon
poco_assert (second >= 0 && second <= 60); // allow leap seconds
poco_assert (millisecond >= 0 && millisecond <= 999);
poco_assert (microsecond >= 0 && microsecond <= 999);
_utcTime = toUtcTime(toJulianDay(year, month, day)) + 10*(hour*Timespan::HOURS + minute*Timespan::MINUTES + second*Timespan::SECONDS + millisecond*Timespan::MILLISECONDS + microsecond);
}
@@ -134,7 +134,7 @@ DateTime& DateTime::operator = (const DateTime& dateTime)
return *this;
}
DateTime& DateTime::operator = (const Timestamp& timestamp)
{
_utcTime = timestamp.utcTime();
@@ -172,12 +172,12 @@ DateTime& DateTime::assign(int year, int month, int day, int hour, int minute, i
_second = second;
_millisecond = millisecond;
_microsecond = microsecond;
return *this;
}
void DateTime::swap(DateTime& dateTime)
void DateTime::swap(DateTime& dateTime) noexcept
{
std::swap(_utcTime, dateTime._utcTime);
std::swap(_year, dateTime._year);
@@ -212,7 +212,7 @@ int DateTime::daysOfMonth(int year, int month)
poco_assert (month >= 1 && month <= 12);
static int daysOfMonthTable[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
if (month == 2 && isLeapYear(year))
return 29;
else
@@ -243,7 +243,7 @@ int DateTime::week(int firstDayOfWeek) const
while (DateTime(_year, 1, baseDay).dayOfWeek() != firstDayOfWeek) ++baseDay;
int doy = dayOfYear();
int offs = baseDay <= 4 ? 0 : 1;
int offs = baseDay <= 4 ? 0 : 1;
if (doy < baseDay)
return offs;
else
@@ -320,7 +320,7 @@ void DateTime::makeUTC(int tzd)
operator -= (Timespan(((Timestamp::TimeDiff) tzd)*Timespan::SECONDS));
}
void DateTime::makeLocal(int tzd)
{
operator += (Timespan(((Timestamp::TimeDiff) tzd)*Timespan::SECONDS));
@@ -331,7 +331,7 @@ double DateTime::toJulianDay(int year, int month, int day, int hour, int minute,
{
// lookup table for (153*month - 457)/5 - note that 3 <= month <= 14.
static int lookup[] = {-91, -60, -30, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275, 306, 337};
// day to double
double dday = double(day) + ((double((hour*60 + minute)*60 + second)*1000 + millisecond)*1000 + microsecond)/86400000000.0;
if (month < 3)
@@ -420,7 +420,14 @@ void DateTime::computeGregorian(double julianDay)
void DateTime::computeDaytime()
{
Timespan span(_utcTime/10);
Timestamp::UtcTimeVal ut(_utcTime);
if (ut < 0) {
// GH3723: UtcTimeVal is negative for pre-gregorian dates
// move it 1600 years to the future
// keeping hour, minute, second,... for corrections
ut += Int64(86400)*1000*1000*10*1600*365;
}
Timespan span(ut/10);
int hour = span.hours();
// Due to double rounding issues, the previous call to computeGregorian()
// may have crossed into the next or previous day. We need to correct that.
+4 -4
View File
@@ -57,9 +57,9 @@ void DateTimeFormatter::append(std::string& str, const DateTime& dateTime, const
case 'A': str.append(dateTime.isAM() ? "AM" : "PM"); break;
case 'M': NumberFormatter::append0(str, dateTime.minute(), 2); break;
case 'S': NumberFormatter::append0(str, dateTime.second(), 2); break;
case 's': NumberFormatter::append0(str, dateTime.second(), 2);
str += '.';
NumberFormatter::append0(str, dateTime.millisecond()*1000 + dateTime.microsecond(), 6);
case 's': NumberFormatter::append0(str, dateTime.second(), 2);
str += '.';
NumberFormatter::append0(str, dateTime.millisecond()*1000 + dateTime.microsecond(), 6);
break;
case 'i': NumberFormatter::append0(str, dateTime.millisecond(), 3); break;
case 'c': NumberFormatter::append(str, dateTime.millisecond()/100); break;
@@ -146,7 +146,7 @@ void DateTimeFormatter::tzdRFC(std::string& str, int timeZoneDifferential)
str += '-';
NumberFormatter::append0(str, -timeZoneDifferential/3600, 2);
NumberFormatter::append0(str, (-timeZoneDifferential%3600)/60, 2);
}
}
}
else str += "GMT";
}
+13 -13
View File
@@ -90,11 +90,11 @@ void DateTimeParser::parse(const std::string& fmt, const std::string& str, DateT
case 'o':
SKIP_JUNK();
PARSE_NUMBER_N(month, 2);
break;
break;
case 'y':
SKIP_JUNK();
PARSE_NUMBER_N(year, 2);
if (year >= 69)
if (year >= 69)
year += 1900;
else
year += 2000;
@@ -108,7 +108,7 @@ void DateTimeParser::parse(const std::string& fmt, const std::string& str, DateT
PARSE_NUMBER(year);
if (year < 1000)
{
if (year >= 69)
if (year >= 69)
year += 1900;
else
year += 2000;
@@ -171,7 +171,7 @@ void DateTimeParser::parse(const std::string& fmt, const std::string& str, DateT
if (day == 0) day = 1;
if (DateTime::isValid(year, month, day, hour, minute, second, millis, micros))
dateTime.assign(year, month, day, hour, minute, second, millis, micros);
else
else
throw SyntaxException("date/time component out of range");
timeZoneDifferential = tzd;
}
@@ -184,7 +184,7 @@ DateTime DateTimeParser::parse(const std::string& fmt, const std::string& str, i
return result;
}
bool DateTimeParser::tryParse(const std::string& fmt, const std::string& str, DateTime& dateTime, int& timeZoneDifferential)
{
try
@@ -205,7 +205,7 @@ void DateTimeParser::parse(const std::string& str, DateTime& dateTime, int& time
throw SyntaxException("Unsupported or invalid date/time format");
}
DateTime DateTimeParser::parse(const std::string& str, int& timeZoneDifferential)
{
DateTime result;
@@ -215,11 +215,11 @@ DateTime DateTimeParser::parse(const std::string& str, int& timeZoneDifferential
throw SyntaxException("Unsupported or invalid date/time format");
}
bool DateTimeParser::tryParse(const std::string& str, DateTime& dateTime, int& timeZoneDifferential)
{
if (str.length() < 4) return false;
if (str[3] == ',')
return tryParse("%w, %e %b %r %H:%M:%S %Z", str, dateTime, timeZoneDifferential);
else if (str[3] == ' ')
@@ -326,14 +326,14 @@ int DateTimeParser::parseMonth(std::string::const_iterator& it, const std::strin
std::string month;
while (it != end && (Ascii::isSpace(*it) || Ascii::isPunct(*it))) ++it;
bool isFirst = true;
while (it != end && Ascii::isAlpha(*it))
while (it != end && Ascii::isAlpha(*it))
{
char ch = (*it++);
if (isFirst) { month += Ascii::toUpper(ch); isFirst = false; }
else month += Ascii::toLower(ch);
}
if (month.length() < 3) throw SyntaxException("Month name must be at least three characters long", month);
for (int i = 0; i < 12; ++i)
for (int i = 0; i < 12; ++i)
{
if (DateTimeFormat::MONTH_NAMES[i].find(month) == 0)
return i + 1;
@@ -347,14 +347,14 @@ int DateTimeParser::parseDayOfWeek(std::string::const_iterator& it, const std::s
std::string dow;
while (it != end && (Ascii::isSpace(*it) || Ascii::isPunct(*it))) ++it;
bool isFirst = true;
while (it != end && Ascii::isAlpha(*it))
while (it != end && Ascii::isAlpha(*it))
{
char ch = (*it++);
if (isFirst) { dow += Ascii::toUpper(ch); isFirst = false; }
else dow += Ascii::toLower(ch);
}
if (dow.length() < 3) throw SyntaxException("Weekday name must be at least three characters long", dow);
for (int i = 0; i < 7; ++i)
for (int i = 0; i < 7; ++i)
{
if (DateTimeFormat::WEEKDAY_NAMES[i].find(dow) == 0)
return i;
@@ -367,7 +367,7 @@ int DateTimeParser::parseAMPM(std::string::const_iterator& it, const std::string
{
std::string ampm;
while (it != end && (Ascii::isSpace(*it) || Ascii::isPunct(*it))) ++it;
while (it != end && Ascii::isAlpha(*it))
while (it != end && Ascii::isAlpha(*it))
{
char ch = (*it++);
ampm += Ascii::toUpper(ch);
+10 -2
View File
@@ -13,6 +13,7 @@
#include "Poco/DigestEngine.h"
#include "Poco/Format.h"
#include "Poco/Exception.h"
@@ -29,15 +30,22 @@ DigestEngine::~DigestEngine()
}
std::string DigestEngine::digestToHex(const Digest& bytes)
std::string DigestEngine::digestToHex(const Digest& bytes, std::size_t length)
{
static const char digits[] = "0123456789abcdef";
const std::size_t fullLen = bytes.size()*2;
std::size_t len = length ? length*2 : fullLen;
if (len > fullLen)
throw Poco::InvalidArgumentException(
Poco::format("DigestEngine::digestToHex(): invalid length : %z,"
"max alllowed is %z", length, fullLen));
std::string result;
result.reserve(bytes.size() * 2);
result.reserve(len);
for (auto b: bytes)
{
result += digits[(b >> 4) & 0xF];
result += digits[b & 0xF];
if (result.size() >= len) break;
}
return result;
}
+22 -22
View File
@@ -21,28 +21,28 @@ namespace Poco {
const int DigestBuf::BUFFER_SIZE = 256;
DigestBuf::DigestBuf(DigestEngine& eng):
BufferedStreamBuf(BUFFER_SIZE, std::ios::out),
_eng(eng),
DigestBuf::DigestBuf(DigestEngine& eng):
BufferedStreamBuf(BUFFER_SIZE, std::ios::out),
_eng(eng),
_pIstr(0),
_pOstr(0)
{
}
DigestBuf::DigestBuf(DigestEngine& eng, std::istream& istr):
BufferedStreamBuf(BUFFER_SIZE, std::ios::in),
_eng(eng),
_pIstr(&istr),
_pOstr(0)
{
}
DigestBuf::DigestBuf(DigestEngine& eng, std::ostream& ostr):
BufferedStreamBuf(BUFFER_SIZE, std::ios::out),
_eng(eng),
_pIstr(0),
DigestBuf::DigestBuf(DigestEngine& eng, std::istream& istr):
BufferedStreamBuf(BUFFER_SIZE, std::ios::in),
_eng(eng),
_pIstr(&istr),
_pOstr(0)
{
}
DigestBuf::DigestBuf(DigestEngine& eng, std::ostream& ostr):
BufferedStreamBuf(BUFFER_SIZE, std::ios::out),
_eng(eng),
_pIstr(0),
_pOstr(&ostr)
{
}
@@ -110,8 +110,8 @@ DigestBuf* DigestIOS::rdbuf()
}
DigestInputStream::DigestInputStream(DigestEngine& eng, std::istream& istr):
DigestIOS(eng, istr),
DigestInputStream::DigestInputStream(DigestEngine& eng, std::istream& istr):
DigestIOS(eng, istr),
std::istream(&_buf)
{
}
@@ -122,15 +122,15 @@ DigestInputStream::~DigestInputStream()
}
DigestOutputStream::DigestOutputStream(DigestEngine& eng):
DigestIOS(eng),
DigestOutputStream::DigestOutputStream(DigestEngine& eng):
DigestIOS(eng),
std::ostream(&_buf)
{
}
DigestOutputStream::DigestOutputStream(DigestEngine& eng, std::ostream& ostr):
DigestIOS(eng, ostr),
DigestOutputStream::DigestOutputStream(DigestEngine& eng, std::ostream& ostr):
DigestIOS(eng, ostr),
std::ostream(&_buf)
{
}
+1 -1
View File
@@ -44,7 +44,7 @@ DirectoryIteratorImpl::DirectoryIteratorImpl(const std::string& path): _fh(INVAL
else
{
UnicodeConverter::toUTF8(_fd.cFileName, _current);
if (_current == "." || _current == "..")
if (_current == "." || _current == "..")
next();
}
}
+36 -36
View File
@@ -61,7 +61,7 @@ public:
{
return _owner;
}
virtual void run() = 0;
virtual void stop() = 0;
virtual bool supportsMoveEvents() const = 0;
@@ -73,21 +73,21 @@ protected:
size(0)
{
}
ItemInfo(const ItemInfo& other):
path(other.path),
size(other.size),
lastModified(other.lastModified)
{
}
explicit ItemInfo(const File& f):
path(f.path()),
size(f.isFile() ? f.getSize() : 0),
lastModified(f.getLastModified())
{
}
std::string path;
File::FileSize size;
Timestamp lastModified;
@@ -104,7 +104,7 @@ protected:
++it;
}
}
void compare(ItemInfoMap& oldEntries, ItemInfoMap& newEntries)
{
for (auto& np: newEntries)
@@ -145,7 +145,7 @@ private:
DirectoryWatcherStrategy();
DirectoryWatcherStrategy(const DirectoryWatcherStrategy&);
DirectoryWatcherStrategy& operator = (const DirectoryWatcherStrategy&);
DirectoryWatcher& _owner;
};
@@ -163,21 +163,21 @@ public:
if (!_hStopped)
throw SystemException("cannot create event");
}
~WindowsDirectoryWatcherStrategy()
{
CloseHandle(_hStopped);
}
void run()
{
ItemInfoMap entries;
scan(entries);
DWORD filter = FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME;
if (owner().eventMask() & DirectoryWatcher::DW_ITEM_MODIFIED)
filter |= FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE;
std::string path(owner().directory().path());
std::wstring upath;
FileImpl::convertPath(path.c_str(), upath);
@@ -195,7 +195,7 @@ public:
}
return;
}
bool stopped = false;
while (!stopped)
{
@@ -228,21 +228,21 @@ public:
catch (Poco::Exception& exc)
{
owner().scanError(&owner(), exc);
}
}
}
FindCloseChangeNotification(hChange);
}
void stop()
{
SetEvent(_hStopped);
}
bool supportsMoveEvents() const
{
return false;
}
private:
HANDLE _hStopped;
};
@@ -262,12 +262,12 @@ public:
_fd = inotify_init();
if (_fd == -1) throw Poco::IOException("cannot initialize inotify", errno);
}
~LinuxDirectoryWatcherStrategy()
{
close(_fd);
}
void run()
{
int mask = 0;
@@ -293,7 +293,7 @@ public:
owner().scanError(&owner(), exc);
}
}
Poco::Buffer<char> buffer(4096);
while (!_stopped)
{
@@ -314,16 +314,16 @@ public:
while (n > 0)
{
struct inotify_event* pEvent = reinterpret_cast<struct inotify_event*>(buffer.begin() + i);
if (pEvent->len > 0)
{
{
if (!owner().eventsSuspended())
{
Poco::Path p(owner().directory().path());
p.makeDirectory();
p.setFileName(pEvent->name);
Poco::File f(p.toString());
if ((pEvent->mask & IN_CREATE) && (owner().eventMask() & DirectoryWatcher::DW_ITEM_ADDED))
{
DirectoryWatcher::DirectoryEvent ev(f, DirectoryWatcher::DW_ITEM_ADDED);
@@ -351,7 +351,7 @@ public:
}
}
}
i += sizeof(inotify_event) + pEvent->len;
n -= sizeof(inotify_event) + pEvent->len;
}
@@ -359,20 +359,20 @@ public:
}
}
}
void stop()
{
_stopped = true;
}
bool supportsMoveEvents() const
{
return true;
}
private:
int _fd;
bool _stopped;
std::atomic<int> _fd;
std::atomic<bool> _stopped;
};
@@ -469,11 +469,11 @@ public:
DirectoryWatcherStrategy(owner)
{
}
~PollingDirectoryWatcherStrategy()
{
}
void run()
{
ItemInfoMap entries;
@@ -493,7 +493,7 @@ public:
}
}
}
void stop()
{
_stopped.set();
@@ -520,7 +520,7 @@ DirectoryWatcher::DirectoryWatcher(const std::string& path, int eventMask, int s
init();
}
DirectoryWatcher::DirectoryWatcher(const Poco::File& directory, int eventMask, int scanInterval):
_directory(directory),
_eventMask(eventMask),
@@ -543,16 +543,16 @@ DirectoryWatcher::~DirectoryWatcher()
}
}
void DirectoryWatcher::suspendEvents()
void DirectoryWatcher::resumeEvents()
{
poco_assert (_eventsSuspended > 0);
_eventsSuspended--;
}
void DirectoryWatcher::resumeEvents()
void DirectoryWatcher::suspendEvents()
{
_eventsSuspended++;
}
@@ -562,7 +562,7 @@ void DirectoryWatcher::init()
{
if (!_directory.exists())
throw Poco::FileNotFoundException(_directory.path());
if (!_directory.isDirectory())
throw Poco::InvalidArgumentException("not a directory", _directory.path());
@@ -578,7 +578,7 @@ void DirectoryWatcher::init()
_thread.start(*this);
}
void DirectoryWatcher::run()
{
_pStrategy->run();
+2 -2
View File
@@ -20,7 +20,7 @@
#include "Poco/Environment.h"
#include "Poco/Version.h"
#include <cstdlib>
#include <cstdio> // sprintf()
#include <cstdio> // snprintf()
#if defined(POCO_VXWORKS)
@@ -101,7 +101,7 @@ std::string Environment::nodeId()
NodeId id;
nodeId(id);
char result[18];
std::sprintf(result, "%02x:%02x:%02x:%02x:%02x:%02x",
std::snprintf(result, sizeof(result), "%02x:%02x:%02x:%02x:%02x:%02x",
id[0],
id[1],
id[2],
+48
View File
@@ -279,6 +279,54 @@ void EnvironmentImpl::nodeIdImpl(NodeId& id)
} // namespace Poco
#elif defined(__GNU__)
//
// GNU Hurd
//
#include <sys/ioctl.h>
#include <net/if.h>
#include <unistd.h>
#include <netinet/in.h>
namespace Poco {
void EnvironmentImpl::nodeIdImpl(NodeId& id)
{
std::memset(&id, 0, sizeof(id));
struct ifreq ifr;
struct ifconf ifc;
char buf[1024];
int sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
if (sock == -1) return;
ifc.ifc_len = sizeof(buf);
ifc.ifc_buf = buf;
if (ioctl(sock, SIOCGIFCONF, &ifc) == -1) return;
struct ifreq* it = ifc.ifc_req;
const struct ifreq* const end = it + (ifc.ifc_len / sizeof(struct ifreq));
for (; it != end; ++it) {
std::strcpy(ifr.ifr_name, it->ifr_name);
if (ioctl(sock, SIOCGIFFLAGS, &ifr) == 0) {
if (! (ifr.ifr_flags & IFF_LOOPBACK)) { // don't count loopback
if (ioctl(sock, SIOCGIFHWADDR, &ifr) == 0) {
std::memcpy(&id, ifr.ifr_hwaddr.sa_data, sizeof(id));
break;
}
}
}
else return;
}
}
} // namespace Poco
#elif defined(POCO_OS_FAMILY_UNIX)
//
// General Unix
+14 -6
View File
@@ -92,7 +92,7 @@ std::string EnvironmentImpl::osNameImpl()
std::string EnvironmentImpl::osDisplayNameImpl()
{
OSVERSIONINFOEX vi; // OSVERSIONINFOEX is supported starting at Windows 2000
OSVERSIONINFOEX vi; // OSVERSIONINFOEX is supported starting at Windows 2000
vi.dwOSVersionInfoSize = sizeof(vi);
if (GetVersionEx((OSVERSIONINFO*) &vi) == 0) throw SystemException("Cannot get OS version information");
switch (vi.dwMajorVersion)
@@ -101,7 +101,14 @@ std::string EnvironmentImpl::osDisplayNameImpl()
switch (vi.dwMinorVersion)
{
case 0:
return vi.wProductType == VER_NT_WORKSTATION ? "Windows 10" : "Windows Server 2016";
if (vi.dwBuildNumber >= 22000)
return "Windows 11";
else if (vi.dwBuildNumber >= 20348 && vi.wProductType != VER_NT_WORKSTATION)
return "Windows Server 2022";
else if (vi.dwBuildNumber >= 17763 && vi.wProductType != VER_NT_WORKSTATION)
return "Windows Server 2019";
else
return vi.wProductType == VER_NT_WORKSTATION ? "Windows 10" : "Windows Server 2016";
}
case 6:
switch (vi.dwMinorVersion)
@@ -202,20 +209,21 @@ void EnvironmentImpl::nodeIdImpl(NodeId& id)
// Make an initial call to GetAdaptersInfo to get
// the necessary size into len
DWORD rc = GetAdaptersInfo(pAdapterInfo, &len);
if (rc == ERROR_BUFFER_OVERFLOW)
if (rc == ERROR_BUFFER_OVERFLOW)
{
delete [] reinterpret_cast<char*>(pAdapterInfo);
pAdapterInfo = reinterpret_cast<IP_ADAPTER_INFO*>(new char[len]);
}
else if (rc != ERROR_SUCCESS)
{
return;
delete[] reinterpret_cast<char*>(pAdapterInfo);
throw SystemException("cannot get network adapter list");
}
if (GetAdaptersInfo(pAdapterInfo, &len) == NO_ERROR)
if (GetAdaptersInfo(pAdapterInfo, &len) == NO_ERROR)
{
pAdapter = pAdapterInfo;
bool found = false;
while (pAdapter && !found)
while (pAdapter && !found)
{
if (pAdapter->Type == MIB_IF_TYPE_ETHERNET && pAdapter->AddressLength == sizeof(id))
{
+6 -5
View File
@@ -121,7 +121,7 @@ std::string EnvironmentImpl::nodeNameImpl()
{
HKEY hKey;
DWORD dwDisposition;
if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"\\Ident", 0, 0, 0, 0, 0, &hKey, &dwDisposition) != ERROR_SUCCESS)
if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"\\Ident", 0, 0, 0, 0, 0, &hKey, &dwDisposition) != ERROR_SUCCESS)
throw SystemException("Cannot get node name", "registry key not found");
std::string value;
@@ -130,7 +130,7 @@ std::string EnvironmentImpl::nodeNameImpl()
DWORD dwData = sizeof(bData);
if (RegQueryValueExW(hKey, L"Name", 0, &dwType, bData, &dwData) == ERROR_SUCCESS)
{
switch (dwType)
switch (dwType)
{
case REG_SZ:
UnicodeConverter::toUTF8(reinterpret_cast<wchar_t*>(bData), value);
@@ -160,22 +160,23 @@ void EnvironmentImpl::nodeIdImpl(NodeId& id)
// Make an initial call to GetAdaptersInfo to get
// the necessary size into len
DWORD rc = GetAdaptersInfo(pAdapterInfo, &len);
if (rc == ERROR_BUFFER_OVERFLOW)
if (rc == ERROR_BUFFER_OVERFLOW)
{
delete [] reinterpret_cast<char*>(pAdapterInfo);
pAdapterInfo = reinterpret_cast<IP_ADAPTER_INFO*>(new char[len]);
}
else if (rc != ERROR_SUCCESS)
{
delete[] reinterpret_cast<char*>(pAdapterInfo);
throw SystemException("cannot get network adapter list");
}
try
{
bool found = false;
if (GetAdaptersInfo(pAdapterInfo, &len) == NO_ERROR)
if (GetAdaptersInfo(pAdapterInfo, &len) == NO_ERROR)
{
pAdapter = pAdapterInfo;
while (pAdapter && !found)
while (pAdapter && !found)
{
if (pAdapter->Type == MIB_IF_TYPE_ETHERNET && pAdapter->AddressLength == sizeof(id))
{
+6 -6
View File
@@ -68,31 +68,31 @@ namespace Poco {
setMessage(strerror_r(err, _buffer, sizeof(_buffer)));
#else
setMessage(strerror(err));
#endif
#endif
}
~StrErrorHelper()
{
}
const std::string& message() const
{
return _message;
}
protected:
void setMessage(int rc)
/// Handles POSIX variant
{
_message = _buffer;
}
void setMessage(const char* msg)
/// Handles GLIBC variant
{
_message = msg;
}
private:
char _buffer[256];
std::string _message;
+2 -2
View File
@@ -38,7 +38,7 @@ void ErrorHandler::exception(const Exception& exc)
poco_debugger_msg(exc.what());
}
void ErrorHandler::exception(const std::exception& exc)
{
poco_debugger_msg(exc.what());
@@ -63,7 +63,7 @@ void ErrorHandler::handle(const Exception& exc)
}
}
void ErrorHandler::handle(const std::exception& exc)
{
FastMutex::ScopedLock lock(_mutex);
+9 -9
View File
@@ -28,7 +28,7 @@ const std::string EventLogChannel::PROP_LOGHOST = "loghost";
const std::string EventLogChannel::PROP_LOGFILE = "logfile";
EventLogChannel::EventLogChannel():
EventLogChannel::EventLogChannel():
_logFile("Application"),
_h(0)
{
@@ -46,16 +46,16 @@ EventLogChannel::EventLogChannel():
}
EventLogChannel::EventLogChannel(const std::string& name):
_name(name),
EventLogChannel::EventLogChannel(const std::string& name):
_name(name),
_logFile("Application"),
_h(0)
{
}
EventLogChannel::EventLogChannel(const std::string& name, const std::string& host):
_name(name),
EventLogChannel::EventLogChannel(const std::string& name, const std::string& host):
_name(name),
_host(host),
_logFile("Application"),
_h(0)
@@ -101,7 +101,7 @@ void EventLogChannel::log(const Message& msg)
std::wstring utext;
UnicodeConverter::toUTF16(msg.getText(), utext);
const wchar_t* pMsg = utext.c_str();
ReportEventW(_h, getType(msg), getCategory(msg), POCO_MSG_LOG, NULL, 1, 0, &pMsg, NULL);
ReportEventW(_h, getType(msg), getCategory(msg), POCO_MSG_LOG, NULL, 1, 0, &pMsg, NULL);
}
@@ -190,7 +190,7 @@ void EventLogChannel::setUpRegistry() const
UnicodeConverter::toUTF16(key, ukey);
DWORD rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE, ukey.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &disp);
if (rc != ERROR_SUCCESS) return;
if (disp == REG_CREATED_NEW_KEY)
{
std::wstring path;
@@ -209,10 +209,10 @@ void EventLogChannel::setUpRegistry() const
#endif
#endif
#endif
if (path.empty())
path = findLibrary(L"PocoMsg.dll");
if (!path.empty())
{
DWORD count = 8;
+4 -1
View File
@@ -92,7 +92,10 @@ EventImpl::EventImpl(bool autoReset): _auto(autoReset), _state(false)
EventImpl::~EventImpl()
{
pthread_cond_destroy(&_cond);
if (0 == pthread_mutex_lock(&_mutex))
pthread_cond_destroy(&_cond);
else poco_unexpected();
pthread_mutex_unlock(&_mutex);
pthread_mutex_destroy(&_mutex);
}
+3 -2
View File
@@ -46,14 +46,15 @@ void EventImpl::waitImpl()
bool EventImpl::waitImpl(long milliseconds)
{
switch (WaitForSingleObject(_event, milliseconds + 1))
poco_assert(milliseconds != INFINITE);
switch (WaitForSingleObject(_event, milliseconds ? milliseconds : 1))
{
case WAIT_TIMEOUT:
return false;
case WAIT_OBJECT_0:
return true;
default:
throw SystemException("wait for event failed");
throw SystemException("wait for event failed");
}
}
+3 -3
View File
@@ -52,7 +52,7 @@ Exception::Exception(const Exception& exc):
_pNested = exc._pNested ? exc._pNested->clone() : 0;
}
Exception::~Exception() noexcept
{
delete _pNested;
@@ -84,13 +84,13 @@ const char* Exception::className() const noexcept
return typeid(*this).name();
}
const char* Exception::what() const noexcept
{
return name();
}
std::string Exception::displayText() const
{
std::string txt = name();
+1 -1
View File
@@ -93,7 +93,7 @@ File& File::operator = (const Path& path)
}
void File::swap(File& file)
void File::swap(File& file) noexcept
{
swapImpl(file);
}
+74 -29
View File
@@ -39,15 +39,15 @@ const std::string FileChannel::PROP_PURGECOUNT = "purgeCount";
const std::string FileChannel::PROP_FLUSH = "flush";
const std::string FileChannel::PROP_ROTATEONOPEN = "rotateOnOpen";
FileChannel::FileChannel():
FileChannel::FileChannel():
_times("utc"),
_compress(false),
_flush(true),
_rotateOnOpen(false),
_pFile(0),
_pRotateStrategy(0),
_pRotateStrategy(new NullRotateStrategy()),
_pArchiveStrategy(new ArchiveByNumberStrategy),
_pPurgeStrategy(0)
_pPurgeStrategy(new NullPurgeStrategy())
{
}
@@ -59,9 +59,9 @@ FileChannel::FileChannel(const std::string& path):
_flush(true),
_rotateOnOpen(false),
_pFile(0),
_pRotateStrategy(0),
_pRotateStrategy(new NullRotateStrategy()),
_pArchiveStrategy(new ArchiveByNumberStrategy),
_pPurgeStrategy(0)
_pPurgeStrategy(new NullPurgeStrategy())
{
}
@@ -85,7 +85,7 @@ FileChannel::~FileChannel()
void FileChannel::open()
{
FastMutex::ScopedLock lock(_mutex);
if (!_pFile)
{
_pFile = new LogFile(_path);
@@ -101,6 +101,8 @@ void FileChannel::open()
_pFile = new LogFile(_path);
}
}
_pFile = _pArchiveStrategy->open(_pFile);
}
}
@@ -120,7 +122,7 @@ void FileChannel::log(const Message& msg)
FastMutex::ScopedLock lock(_mutex);
if (_pRotateStrategy && _pArchiveStrategy && _pRotateStrategy->mustRotate(_pFile))
if (_pRotateStrategy->mustRotate(_pFile))
{
try
{
@@ -139,7 +141,7 @@ void FileChannel::log(const Message& msg)
_pFile->write(msg.getText(), _flush);
}
void FileChannel::setProperty(const std::string& name, const std::string& value)
{
FastMutex::ScopedLock lock(_mutex);
@@ -208,7 +210,7 @@ Timestamp FileChannel::creationDate() const
return 0;
}
UInt64 FileChannel::size() const
{
if (_pFile)
@@ -224,7 +226,7 @@ const std::string& FileChannel::path() const
}
void FileChannel::setRotation(const std::string& rotation)
RotateStrategy* FileChannel::createRotationStrategy(const std::string& rotation, const std::string& times) const
{
std::string::const_iterator it = rotation.begin();
std::string::const_iterator end = rotation.end();
@@ -234,16 +236,16 @@ void FileChannel::setRotation(const std::string& rotation)
while (it != end && Ascii::isSpace(*it)) ++it;
std::string unit;
while (it != end && Ascii::isAlpha(*it)) unit += *it++;
RotateStrategy* pStrategy = 0;
if ((rotation.find(',') != std::string::npos) || (rotation.find(':') != std::string::npos))
{
if (_times == "utc")
if (times == "utc")
pStrategy = new RotateAtTimeStrategy<DateTime>(rotation);
else if (_times == "local")
else if (times == "local")
pStrategy = new RotateAtTimeStrategy<LocalDateTime>(rotation);
else
throw PropertyNotSupportedException("times", _times);
throw PropertyNotSupportedException("times", times);
}
else if (unit == "daily")
pStrategy = new RotateByIntervalStrategy(Timespan(1*Timespan::DAYS));
@@ -271,12 +273,57 @@ void FileChannel::setRotation(const std::string& rotation)
pStrategy = new RotateBySizeStrategy(n);
else if (unit != "never")
throw InvalidArgumentException("rotation", rotation);
return pStrategy;
}
void FileChannel::setRotationStrategy(RotateStrategy* strategy)
{
poco_check_ptr(strategy);
delete _pRotateStrategy;
_pRotateStrategy = pStrategy;
_pRotateStrategy = strategy;
}
void FileChannel::setRotation(const std::string& rotation)
{
setRotationStrategy(createRotationStrategy(rotation, _times));
_rotation = rotation;
}
ArchiveStrategy* FileChannel::createArchiveStrategy(const std::string& archive, const std::string& times) const
{
ArchiveStrategy* pStrategy = 0;
if (archive == "number")
{
pStrategy = new ArchiveByNumberStrategy;
}
else if (archive == "timestamp")
{
if (times == "utc")
pStrategy = new ArchiveByTimestampStrategy<DateTime>;
else if (times == "local")
pStrategy = new ArchiveByTimestampStrategy<LocalDateTime>;
else
throw PropertyNotSupportedException("times", times);
}
else throw InvalidArgumentException("archive", archive);
return pStrategy;
}
void FileChannel::setArchiveStrategy(ArchiveStrategy* strategy)
{
poco_check_ptr(strategy);
delete _pArchiveStrategy;
_pArchiveStrategy = strategy;
}
void FileChannel::setArchive(const std::string& archive)
{
ArchiveStrategy* pStrategy = 0;
@@ -304,8 +351,7 @@ void FileChannel::setArchive(const std::string& archive)
void FileChannel::setCompress(const std::string& compress)
{
_compress = icompare(compress, "true") == 0;
if (_pArchiveStrategy)
_pArchiveStrategy->compress(_compress);
_pArchiveStrategy->compress(_compress);
}
@@ -345,15 +391,12 @@ void FileChannel::setRotateOnOpen(const std::string& rotateOnOpen)
void FileChannel::purge()
{
if (_pPurgeStrategy)
try
{
_pPurgeStrategy->purge(_path);
}
catch (...)
{
try
{
_pPurgeStrategy->purge(_path);
}
catch (...)
{
}
}
}
@@ -363,7 +406,7 @@ bool FileChannel::setNoPurge(const std::string& value)
if (value.empty() || 0 == icompare(value, "none"))
{
delete _pPurgeStrategy;
_pPurgeStrategy = 0;
_pPurgeStrategy = new NullPurgeStrategy();
_purgeAge = "none";
return true;
}
@@ -379,13 +422,13 @@ int FileChannel::extractDigit(const std::string& value, std::string::const_itera
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.");
throw InvalidArgumentException("Zero is not valid purge age.");
if (nextToDigit) *nextToDigit = it;
return digit;
@@ -394,6 +437,8 @@ int FileChannel::extractDigit(const std::string& value, std::string::const_itera
void FileChannel::setPurgeStrategy(PurgeStrategy* strategy)
{
poco_check_ptr(strategy);
delete _pPurgeStrategy;
_pPurgeStrategy = strategy;
}
@@ -405,7 +450,7 @@ Timespan::TimeDiff FileChannel::extractFactor(const std::string& value, std::str
std::string unit;
while (start != value.end() && Ascii::isAlpha(*start)) unit += *start++;
if (unit == "seconds")
return Timespan::SECONDS;
if (unit == "minutes")
+2 -2
View File
@@ -50,13 +50,13 @@ std::istream* FileStreamFactory::open(const Path& path)
{
File file(path);
if (!file.exists()) throw FileNotFoundException(path.toString());
FileInputStream* istr = new FileInputStream(path.toString(), std::ios::binary);
if (!istr->good())
{
delete istr;
throw OpenFileException(path.toString());
}
}
return istr;
}
+6 -6
View File
@@ -60,11 +60,11 @@ void FileStreamBuf::open(const std::string& path, std::ios::openmode mode)
flags |= O_RDONLY;
else
flags |= O_WRONLY;
_fd = ::open(path.c_str(), flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (_fd == -1)
File::handleLastError(_path);
if ((mode & std::ios::app) || (mode & std::ios::ate))
seekoff(0, std::ios::end, mode);
}
@@ -73,10 +73,10 @@ void FileStreamBuf::open(const std::string& path, std::ios::openmode mode)
int FileStreamBuf::readFromDevice(char* buffer, std::streamsize length)
{
if (_fd == -1) return -1;
if (getMode() & std::ios::out)
sync();
int n = read(_fd, buffer, length);
if (n == -1)
File::handleLastError(_path);
@@ -123,7 +123,7 @@ bool FileStreamBuf::close()
std::streampos FileStreamBuf::seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode)
{
if (_fd == -1 || !(getMode() & mode))
if (_fd == -1 || !(getMode() & mode))
return -1;
if (getMode() & std::ios::out)
@@ -154,7 +154,7 @@ std::streampos FileStreamBuf::seekoff(std::streamoff off, std::ios::seekdir dir,
std::streampos FileStreamBuf::seekpos(std::streampos pos, std::ios::openmode mode)
{
if (_fd == -1 || !(getMode() & mode))
if (_fd == -1 || !(getMode() & mode))
return -1;
if (getMode() & std::ios::out)
+7 -7
View File
@@ -53,7 +53,7 @@ void FileStreamBuf::open(const std::string& path, std::ios::openmode mode)
DWORD shareMode = FILE_SHARE_READ;
if (!(mode & std::ios::out))
shareMode |= FILE_SHARE_WRITE;
DWORD creationDisp = OPEN_EXISTING;
if (mode & std::ios::trunc)
creationDisp = CREATE_ALWAYS;
@@ -61,14 +61,14 @@ void FileStreamBuf::open(const std::string& path, std::ios::openmode mode)
creationDisp = OPEN_ALWAYS;
DWORD flags = FILE_ATTRIBUTE_NORMAL;
std::wstring utf16Path;
FileImpl::convertPath(path, utf16Path);
_handle = CreateFileW(utf16Path.c_str(), access, shareMode, NULL, creationDisp, flags, NULL);
if (_handle == INVALID_HANDLE_VALUE)
File::handleLastError(_path);
if ((mode & std::ios::ate) || (mode & std::ios::app))
seekoff(0, std::ios::end, mode);
}
@@ -81,7 +81,7 @@ int FileStreamBuf::readFromDevice(char* buffer, std::streamsize length)
if (getMode() & std::ios::out)
sync();
DWORD bytesRead(0);
BOOL rc = ReadFile(_handle, buffer, static_cast<DWORD>(length), &bytesRead, NULL);
if (rc == 0)
@@ -112,7 +112,7 @@ int FileStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
BOOL rc = WriteFile(_handle, buffer, static_cast<DWORD>(length), &bytesWritten, NULL);
if (rc == 0)
File::handleLastError(_path);
_pos += bytesWritten;
return static_cast<int>(bytesWritten);
@@ -144,7 +144,7 @@ std::streampos FileStreamBuf::seekoff(std::streamoff off, std::ios::seekdir dir,
{
if (INVALID_HANDLE_VALUE == _handle || !(getMode() & mode))
return -1;
if (getMode() & std::ios::out)
sync();
@@ -166,7 +166,7 @@ std::streampos FileStreamBuf::seekoff(std::streamoff off, std::ios::seekdir dir,
{
offset = FILE_END;
}
LARGE_INTEGER li;
li.QuadPart = off;
li.LowPart = SetFilePointer(_handle, li.LowPart, &li.HighPart, offset);
+1 -1
View File
@@ -289,7 +289,7 @@ void FileImpl::renameToImpl(const std::string& path, int options)
struct stat st;
if (stat(path.c_str(), &st) == 0 && (options &OPT_FAIL_ON_OVERWRITE_IMPL))
throw FileExistsException(path, EEXIST);
throw FileExistsException(path, EEXIST);
if (rename(_path.c_str(), path.c_str()) != 0)
handleLastErrorImpl(_path);
+1 -1
View File
@@ -301,7 +301,7 @@ void FileImpl::renameToImpl(const std::string& path, int options)
if (MoveFileW(_upath.c_str(), upath.c_str(), MOVEFILE_REPLACE_EXISTING) == 0)
handleLastErrorImpl(_path);
}
}
+10 -10
View File
@@ -62,8 +62,8 @@ namespace
}
if (width > 0) str.width(width);
}
void parsePrec(std::ostream& str, std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt, std::vector<Any>::const_iterator& itVal)
{
if (itFmt != endFmt && *itFmt == '.')
@@ -86,7 +86,7 @@ namespace
if (prec >= 0) str.precision(prec);
}
}
char parseMod(std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt)
{
char mod = 0;
@@ -96,13 +96,13 @@ namespace
{
case 'l':
case 'h':
case 'L':
case 'L':
case '?': mod = *itFmt++; break;
}
}
return mod;
}
std::size_t parseIndex(std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt)
{
int index = 0;
@@ -129,8 +129,8 @@ namespace
case 'f': str << std::fixed; break;
}
}
void writeAnyInt(std::ostream& str, const Any& any)
{
if (any.type() == typeid(char))
@@ -223,7 +223,7 @@ namespace
str << RefAnyCast<std::string>(*itVal++);
break;
case 'z':
str << AnyCast<std::size_t>(*itVal++);
str << AnyCast<std::size_t>(*itVal++);
break;
case 'I':
case 'D':
@@ -241,7 +241,7 @@ namespace
}
std::string format(const std::string& fmt, const Any& value)
std::string format(const std::string& fmt, const Any& value)
{
std::string result;
format(result, fmt, value);
@@ -260,7 +260,7 @@ void format(std::string& result, const std::string& fmt, const std::vector<Any>&
std::string::const_iterator itFmt = fmt.begin();
std::string::const_iterator endFmt = fmt.end();
std::vector<Any>::const_iterator itVal = values.begin();
std::vector<Any>::const_iterator endVal = values.end();
std::vector<Any>::const_iterator endVal = values.end();
while (itFmt != endFmt)
{
switch (*itFmt)
+6 -6
View File
@@ -20,22 +20,22 @@
namespace Poco {
FormattingChannel::FormattingChannel():
_pFormatter(0),
FormattingChannel::FormattingChannel():
_pFormatter(0),
_pChannel(0)
{
}
FormattingChannel::FormattingChannel(Formatter::Ptr pFormatter):
_pFormatter(pFormatter),
_pFormatter(pFormatter),
_pChannel(0)
{
}
FormattingChannel::FormattingChannel(Formatter::Ptr pFormatter, Channel::Ptr pChannel):
_pFormatter(pFormatter),
FormattingChannel::FormattingChannel(Formatter::Ptr pFormatter, Channel::Ptr pChannel):
_pFormatter(pFormatter),
_pChannel(pChannel)
{
}
@@ -105,7 +105,7 @@ void FormattingChannel::open()
_pChannel->open();
}
void FormattingChannel::close()
{
if (_pChannel)
+3 -3
View File
@@ -42,7 +42,7 @@ bool Glob::match(const std::string& subject)
TextIterator endp(_pattern);
TextIterator its(subject, utf8);
TextIterator ends(subject);
if ((_options & GLOB_DOT_SPECIAL) && its != ends && *its == '.' && (*itp == '?' || *itp == '*'))
return false;
else
@@ -118,7 +118,7 @@ bool Glob::match(TextIterator& itp, const TextIterator& endp, TextIterator& its,
}
return true;
case '[':
if (++itp != endp)
if (++itp != endp)
{
bool invert = *itp == '!';
if (invert) ++itp;
@@ -165,7 +165,7 @@ bool Glob::matchSet(TextIterator& itp, const TextIterator& endp, int c)
switch (*itp)
{
case ']':
++itp;
++itp;
return false;
case '\\':
if (++itp == endp) throw SyntaxException("backslash must be followed by character in glob pattern");
+4 -4
View File
@@ -19,10 +19,10 @@ namespace Poco {
HashStatistic::HashStatistic(
UInt32 tableSize,
UInt32 numEntries,
UInt32 numZeroEntries,
UInt32 maxEntry,
UInt32 tableSize,
UInt32 numEntries,
UInt32 numZeroEntries,
UInt32 maxEntry,
std::vector<UInt32> details):
_sizeOfTable(tableSize),
_numberOfEntries(numEntries),
+1 -1
View File
@@ -19,7 +19,7 @@
namespace Poco {
HexBinaryDecoderBuf::HexBinaryDecoderBuf(std::istream& istr):
HexBinaryDecoderBuf::HexBinaryDecoderBuf(std::istream& istr):
_buf(*istr.rdbuf())
{
}
+3 -3
View File
@@ -18,7 +18,7 @@
namespace Poco {
HexBinaryEncoderBuf::HexBinaryEncoderBuf(std::ostream& ostr):
HexBinaryEncoderBuf::HexBinaryEncoderBuf(std::ostream& ostr):
_pos(0),
_lineLength(72),
_uppercase(0),
@@ -61,11 +61,11 @@ int HexBinaryEncoderBuf::writeToDevice(char c)
{
static const int eof = std::char_traits<char>::eof();
static const char digits[] = "0123456789abcdef0123456789ABCDEF";
if (_buf.sputc(digits[_uppercase + ((c >> 4) & 0xF)]) == eof) return eof;
++_pos;
if (_buf.sputc(digits[_uppercase + (c & 0xF)]) == eof) return eof;
if (++_pos >= _lineLength && _lineLength > 0)
if (++_pos >= _lineLength && _lineLength > 0)
{
if (_buf.sputc('\n') == eof) return eof;
_pos = 0;
+3 -2
View File
@@ -49,11 +49,12 @@ void writeString(const std::string &value, T& obj, typename WriteFunc<T, S>::Typ
{
for(std::string::const_iterator it = value.begin(), end = value.end(); it != end; ++it)
{
if((*it >= 0 && *it <= 31) || (*it == '"') || (*it == '\\'))
if ((*it >= 0 && *it <= 31) || (*it == '"') || (*it == '\\'))
{
std::string str = Poco::UTF8::escape(it, it + 1, true);
(obj.*write)(str.c_str(), str.size());
}else (obj.*write)(&(*it), 1);
}
else (obj.*write)(&(*it), 1);
}
}
if(wrap) (obj.*write)("\"", 1);
+17 -17
View File
@@ -28,25 +28,25 @@ const char* Latin1Encoding::_names[] =
};
const TextEncoding::CharacterMap Latin1Encoding::_charMap =
const TextEncoding::CharacterMap Latin1Encoding::_charMap =
{
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f */
/* 00 */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
/* 10 */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
/* 20 */ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
/* 30 */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
/* 40 */ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
/* 50 */ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
/* 60 */ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
/* 70 */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
/* 80 */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
/* 90 */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
/* a0 */ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
/* b0 */ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
/* c0 */ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
/* d0 */ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
/* e0 */ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
/* f0 */ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
/* 00 */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
/* 10 */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
/* 20 */ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
/* 30 */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
/* 40 */ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
/* 50 */ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
/* 60 */ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
/* 70 */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
/* 80 */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
/* 90 */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
/* a0 */ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
/* b0 */ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
/* c0 */ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
/* d0 */ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
/* e0 */ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
/* f0 */ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
};
+11 -11
View File
@@ -28,19 +28,19 @@ const char* Latin2Encoding::_names[] =
};
const TextEncoding::CharacterMap Latin2Encoding::_charMap =
const TextEncoding::CharacterMap Latin2Encoding::_charMap =
{
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f */
/* 00 */ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
/* 10 */ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
/* 20 */ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
/* 30 */ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
/* 40 */ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
/* 50 */ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
/* 60 */ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
/* 70 */ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
/* 80 */ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
/* 90 */ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
/* 00 */ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
/* 10 */ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
/* 20 */ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
/* 30 */ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
/* 40 */ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
/* 50 */ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
/* 60 */ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
/* 70 */ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
/* 80 */ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
/* 90 */ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
/* a0 */ 0x00a0, 0x0104, 0x02d8, 0x0141, 0x00a4, 0x013d, 0x015a, 0x00a7, 0x00a8, 0x0160, 0x015e, 0x0164, 0x0179, 0x00ad, 0x017d, 0x017b,
/* b0 */ 0x00b0, 0x0105, 0x02db, 0x0142, 0x00b4, 0x013e, 0x015b, 0x02c7, 0x00b8, 0x0161, 0x015f, 0x0165, 0x017a, 0x02dd, 0x017e, 0x017c,
/* c0 */ 0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7, 0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e,
+17 -17
View File
@@ -28,25 +28,25 @@ const char* Latin9Encoding::_names[] =
};
const TextEncoding::CharacterMap Latin9Encoding::_charMap =
const TextEncoding::CharacterMap Latin9Encoding::_charMap =
{
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f */
/* 00 */ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
/* 10 */ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
/* 20 */ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
/* 30 */ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
/* 40 */ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
/* 50 */ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
/* 60 */ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
/* 70 */ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
/* 80 */ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
/* 90 */ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
/* a0 */ 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x20ac, 0x00a5, 0x0160, 0x00a7, 0x0161, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
/* b0 */ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x017d, 0x00b5, 0x00b6, 0x00b7, 0x017e, 0x00b9, 0x00ba, 0x00bb, 0x0152, 0x0153, 0x0178, 0x00bf,
/* c0 */ 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7, 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
/* d0 */ 0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7, 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
/* e0 */ 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
/* f0 */ 0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff,
/* 00 */ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
/* 10 */ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
/* 20 */ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
/* 30 */ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
/* 40 */ 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
/* 50 */ 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
/* 60 */ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
/* 70 */ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
/* 80 */ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
/* 90 */ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
/* a0 */ 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x20ac, 0x00a5, 0x0160, 0x00a7, 0x0161, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
/* b0 */ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x017d, 0x00b5, 0x00b6, 0x00b7, 0x017e, 0x00b9, 0x00ba, 0x00bb, 0x0152, 0x0153, 0x0178, 0x00bf,
/* c0 */ 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7, 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
/* d0 */ 0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7, 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
/* e0 */ 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
/* f0 */ 0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff,
};
+14 -14
View File
@@ -24,9 +24,9 @@ const std::string LineEnding::NEWLINE_CRLF("\r\n");
const std::string LineEnding::NEWLINE_LF("\n");
LineEndingConverterStreamBuf::LineEndingConverterStreamBuf(std::istream& istr):
_pIstr(&istr),
_pOstr(0),
LineEndingConverterStreamBuf::LineEndingConverterStreamBuf(std::istream& istr):
_pIstr(&istr),
_pOstr(0),
_newLine(LineEnding::NEWLINE_DEFAULT),
_lastChar(0)
{
@@ -34,9 +34,9 @@ LineEndingConverterStreamBuf::LineEndingConverterStreamBuf(std::istream& istr):
}
LineEndingConverterStreamBuf::LineEndingConverterStreamBuf(std::ostream& ostr):
_pIstr(0),
_pOstr(&ostr),
LineEndingConverterStreamBuf::LineEndingConverterStreamBuf(std::ostream& ostr):
_pIstr(0),
_pOstr(&ostr),
_newLine(LineEnding::NEWLINE_DEFAULT),
_lastChar(0)
{
@@ -132,15 +132,15 @@ LineEndingConverterStreamBuf* LineEndingConverterIOS::rdbuf()
}
InputLineEndingConverter::InputLineEndingConverter(std::istream& istr):
LineEndingConverterIOS(istr),
InputLineEndingConverter::InputLineEndingConverter(std::istream& istr):
LineEndingConverterIOS(istr),
std::istream(&_buf)
{
}
InputLineEndingConverter::InputLineEndingConverter(std::istream& istr, const std::string& newLineCharacters):
LineEndingConverterIOS(istr),
InputLineEndingConverter::InputLineEndingConverter(std::istream& istr, const std::string& newLineCharacters):
LineEndingConverterIOS(istr),
std::istream(&_buf)
{
setNewLine(newLineCharacters);
@@ -152,15 +152,15 @@ InputLineEndingConverter::~InputLineEndingConverter()
}
OutputLineEndingConverter::OutputLineEndingConverter(std::ostream& ostr):
LineEndingConverterIOS(ostr),
OutputLineEndingConverter::OutputLineEndingConverter(std::ostream& ostr):
LineEndingConverterIOS(ostr),
std::ostream(&_buf)
{
}
OutputLineEndingConverter::OutputLineEndingConverter(std::ostream& ostr, const std::string& newLineCharacters):
LineEndingConverterIOS(ostr),
OutputLineEndingConverter::OutputLineEndingConverter(std::ostream& ostr, const std::string& newLineCharacters):
LineEndingConverterIOS(ostr),
std::ostream(&_buf)
{
setNewLine(newLineCharacters);
+11 -6
View File
@@ -25,6 +25,8 @@
#include <ctime>
#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
#include "wce_time.h"
#elif defined(_WIN32)
#include <time.h>
#endif
@@ -269,10 +271,13 @@ void LocalDateTime::determineTzd(bool adjust)
#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
std::tm* broken = wceex_localtime(&epochTime);
#else
std::tm* broken = std::localtime(&epochTime);
std::tm brokenBuf;
std::tm* broken = &brokenBuf;
errno_t err = localtime_s(broken, &epochTime);
if (err) broken = nullptr;
#endif
if (!broken) throw Poco::SystemException("cannot get local time");
_tzd = (Timezone::utcOffset() + ((broken->tm_isdst == 1) ? 3600 : 0));
_tzd = Timezone::utcOffset() + Timezone::dst(_dateTime.timestamp());
#else
std::tm broken;
#if defined(POCO_VXWORKS) && (defined(_VXWORKS_COMPATIBILITY_MODE) || (defined(_WRS_VXWORKS_MAJOR) && ((_WRS_VXWORKS_MAJOR < 6) || ((_WRS_VXWORKS_MAJOR == 6) && (_WRS_VXWORKS_MINOR < 9)))))
@@ -282,7 +287,7 @@ void LocalDateTime::determineTzd(bool adjust)
if (!localtime_r(&epochTime, &broken))
throw Poco::SystemException("cannot get local time");
#endif
_tzd = (Timezone::utcOffset() + ((broken.tm_isdst == 1) ? 3600 : 0));
_tzd = Timezone::utcOffset() + Timezone::dst(_dateTime.timestamp());
#endif
adjustForTzd();
}
@@ -300,8 +305,8 @@ std::time_t LocalDateTime::dstOffset(int& dstOffset) const
std::time_t local;
std::tm broken;
broken.tm_year = (_dateTime.year() - 1900);
broken.tm_mon = (_dateTime.month() - 1);
broken.tm_year = _dateTime.year() - 1900;
broken.tm_mon = _dateTime.month() - 1;
broken.tm_mday = _dateTime.day();
broken.tm_hour = _dateTime.hour();
broken.tm_min = _dateTime.minute();
@@ -313,7 +318,7 @@ std::time_t LocalDateTime::dstOffset(int& dstOffset) const
local = std::mktime(&broken);
#endif
dstOffset = (broken.tm_isdst == 1) ? 3600 : 0;
dstOffset = (broken.tm_isdst == 1) ? Timezone::dst(_dateTime.timestamp()) : 0;
return local;
}
+13 -5
View File
@@ -20,11 +20,12 @@
namespace Poco {
LogFileImpl::LogFileImpl(const std::string& path):
LogFileImpl::LogFileImpl(const std::string& path):
_path(path),
_str(_path, std::ios::app)
_str(_path, std::ios::app),
_size(static_cast<UInt64>(_str.tellp()))
{
if (sizeImpl() == 0)
if (_size == 0)
_creationDate = File(path).getLastModified();
else
_creationDate = File(path).created();
@@ -38,18 +39,25 @@ LogFileImpl::~LogFileImpl()
void LogFileImpl::writeImpl(const std::string& text, bool flush)
{
std::streampos pos = _str.tellp();
_str << text;
if (flush)
_str << std::endl;
else
_str << "\n";
if (!_str.good()) throw WriteFileException(_path);
if (!_str.good())
{
_str.clear();
_str.seekp(pos);
throw WriteFileException(_path);
}
_size = static_cast<UInt64>(_str.tellp());
}
UInt64 LogFileImpl::sizeImpl() const
{
return (UInt64) _str.tellp();
return _size;
}
+1 -1
View File
@@ -98,7 +98,7 @@ void LogFileImpl::createFile()
{
std::wstring upath;
FileImpl::convertPath(_path, upath);
_hFile = CreateFileW(upath.c_str(), GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (_hFile == INVALID_HANDLE_VALUE) throw OpenFileException(_path);
SetFilePointer(_hFile, 0, 0, FILE_END);
+1 -1
View File
@@ -69,7 +69,7 @@ void Logger::setProperty(const std::string& name, const std::string& value)
setChannel(LoggingRegistry::defaultRegistry().channelForName(value));
else if (name == "level")
setLevel(value);
else
else
Channel::setProperty(name, value);
}
+2 -2
View File
@@ -32,7 +32,7 @@ LoggingRegistry::~LoggingRegistry()
Channel::Ptr LoggingRegistry::channelForName(const std::string& name) const
{
FastMutex::ScopedLock lock(_mutex);
ChannelMap::const_iterator it = _channelMap.find(name);
if (it != _channelMap.end())
return it->second;
@@ -60,7 +60,7 @@ void LoggingRegistry::registerChannel(const std::string& name, Channel::Ptr pCha
_channelMap[name] = ChannelPtr(pChannel, true);
}
void LoggingRegistry::registerFormatter(const std::string& name, Formatter::Ptr pFormatter)
{
FastMutex::ScopedLock lock(_mutex);
+11 -5
View File
@@ -54,7 +54,7 @@ MD4Engine::~MD4Engine()
reset();
}
void MD4Engine::updateImpl(const void* input_, std::size_t inputLen)
{
const unsigned char* input = (const unsigned char*) input_;
@@ -71,7 +71,7 @@ void MD4Engine::updateImpl(const void* input_, std::size_t inputLen)
partLen = 64 - index;
/* Transform as many times as possible. */
if (inputLen >= partLen)
if (inputLen >= partLen)
{
std::memcpy(&_context.buffer[index], input, partLen);
transform(_context.state, _context.buffer);
@@ -107,7 +107,7 @@ void MD4Engine::reset()
const DigestEngine::Digest& MD4Engine::digest()
{
static const unsigned char PADDING[64] =
static const unsigned char PADDING[64] =
{
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -129,10 +129,16 @@ const DigestEngine::Digest& MD4Engine::digest()
/* Store state in digest */
unsigned char digest[16];
encode(digest, _context.state, 16);
encode(digest, _context.state, sizeof(digest));
_digest.clear();
#if defined(POCO_COMPILER_GCC)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
_digest.insert(_digest.begin(), digest, digest + sizeof(digest));
#if defined(POCO_COMPILER_GCC)
#pragma GCC diagnostic pop
#endif
/* Zeroize sensitive information. */
std::memset(&_context, 0, sizeof (_context));
reset();
+13 -7
View File
@@ -14,7 +14,7 @@
// MD5 (RFC 1321) algorithm:
// Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
// rights reserved.
//
//
// License to copy and use this software is granted provided that it
// is identified as the "RSA Data Security, Inc. MD5 Message-Digest
// Algorithm" in all material mentioning or referencing this software
@@ -54,7 +54,7 @@ MD5Engine::~MD5Engine()
reset();
}
void MD5Engine::updateImpl(const void* input_, std::size_t inputLen)
{
const unsigned char* input = (const unsigned char*) input_;
@@ -71,7 +71,7 @@ void MD5Engine::updateImpl(const void* input_, std::size_t inputLen)
partLen = 64 - index;
/* Transform as many times as possible. */
if (inputLen >= partLen)
if (inputLen >= partLen)
{
std::memcpy(&_context.buffer[index], input, partLen);
transform(_context.state, _context.buffer);
@@ -107,7 +107,7 @@ void MD5Engine::reset()
const DigestEngine::Digest& MD5Engine::digest()
{
static const unsigned char PADDING[64] =
static const unsigned char PADDING[64] =
{
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -129,10 +129,16 @@ const DigestEngine::Digest& MD5Engine::digest()
/* Store state in digest */
unsigned char digest[16];
encode(digest, _context.state, 16);
encode(digest, _context.state, sizeof(digest));
_digest.clear();
#if defined(POCO_COMPILER_GCC)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
_digest.insert(_digest.begin(), digest, digest + sizeof(digest));
#if defined(POCO_COMPILER_GCC)
#pragma GCC diagnostic pop
#endif
/* Zeroize sensitive information. */
std::memset(&_context, 0, sizeof (_context));
reset();
@@ -286,7 +292,7 @@ void MD5Engine::encode(unsigned char* output, const UInt32* input, std::size_t l
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
for (i = 0, j = 0; j < len; i++, j += 4)
{
output[j] = (unsigned char)(input[i] & 0xff);
output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
+5 -5
View File
@@ -33,7 +33,7 @@ MemoryPool::MemoryPool(std::size_t blockSize, int preAlloc, int maxAlloc):
if (maxAlloc > 0 && maxAlloc < r)
r = maxAlloc;
_blocks.reserve(r);
try
{
for (int i = 0; i < preAlloc; ++i)
@@ -48,7 +48,7 @@ MemoryPool::MemoryPool(std::size_t blockSize, int preAlloc, int maxAlloc):
}
}
MemoryPool::~MemoryPool()
{
clear();
@@ -68,7 +68,7 @@ void MemoryPool::clear()
void* MemoryPool::get()
{
FastMutex::ScopedLock lock(_mutex);
if (_blocks.empty())
{
if (_maxAlloc == 0 || _allocated < _maxAlloc)
@@ -86,11 +86,11 @@ void* MemoryPool::get()
}
}
void MemoryPool::release(void* ptr)
{
FastMutex::ScopedLock lock(_mutex);
try
{
_blocks.push_back(reinterpret_cast<char*>(ptr));
+4 -4
View File
@@ -30,8 +30,8 @@ MemoryIOS::~MemoryIOS()
}
MemoryInputStream::MemoryInputStream(const char* pBuffer, std::streamsize bufferSize):
MemoryIOS(const_cast<char*>(pBuffer), bufferSize),
MemoryInputStream::MemoryInputStream(const char* pBuffer, std::streamsize bufferSize):
MemoryIOS(const_cast<char*>(pBuffer), bufferSize),
std::istream(&_buf)
{
}
@@ -42,8 +42,8 @@ MemoryInputStream::~MemoryInputStream()
}
MemoryOutputStream::MemoryOutputStream(char* pBuffer, std::streamsize bufferSize):
MemoryIOS(pBuffer, bufferSize),
MemoryOutputStream::MemoryOutputStream(char* pBuffer, std::streamsize bufferSize):
MemoryIOS(pBuffer, bufferSize),
std::ostream(&_buf)
{
}
+18
View File
@@ -27,6 +27,7 @@ namespace Poco {
Message::Message():
_prio(PRIO_FATAL),
_tid(0),
_ostid(0),
_pid(0),
_file(0),
_line(0),
@@ -41,6 +42,7 @@ Message::Message(const std::string& source, const std::string& text, Priority pr
_text(text),
_prio(prio),
_tid(0),
_ostid(0),
_pid(0),
_file(0),
_line(0),
@@ -55,6 +57,7 @@ Message::Message(const std::string& source, const std::string& text, Priority pr
_text(text),
_prio(prio),
_tid(0),
_ostid(0),
_pid(0),
_file(file),
_line(line),
@@ -70,6 +73,7 @@ Message::Message(const Message& msg):
_prio(msg._prio),
_time(msg._time),
_tid(msg._tid),
_ostid(msg._ostid),
_thread(msg._thread),
_pid(msg._pid),
_file(msg._file),
@@ -88,6 +92,7 @@ Message::Message(Message&& msg) noexcept:
_prio(std::move(msg._prio)),
_time(std::move(msg._time)),
_tid(std::move(msg._tid)),
_ostid(std::move(msg._ostid)),
_thread(std::move(msg._thread)),
_pid(std::move(msg._pid)),
_file(std::move(msg._file)),
@@ -104,6 +109,7 @@ Message::Message(const Message& msg, const std::string& text):
_prio(msg._prio),
_time(msg._time),
_tid(msg._tid),
_ostid(msg._ostid),
_thread(msg._thread),
_pid(msg._pid),
_file(msg._file),
@@ -127,6 +133,7 @@ void Message::init()
#if !defined(POCO_VXWORKS)
_pid = Process::id();
#endif
_ostid = (IntPtr)Thread::currentOsTid();
Thread* pThread = Thread::current();
if (pThread)
{
@@ -154,6 +161,7 @@ Message& Message::operator = (Message&& msg) noexcept
_prio = std::move(msg._prio);
_time = std::move(msg._time);
_tid = std::move(msg._tid);
_ostid = std::move(msg._ostid);
_thread = std::move(msg._thread);
_pid = std::move(msg._pid);
_file = std::move(msg._file);
@@ -173,6 +181,7 @@ void Message::swap(Message& msg)
swap(_prio, msg._prio);
swap(_time, msg._time);
swap(_tid, msg._tid);
swap(_ostid, msg._ostid);
swap(_thread, msg._thread);
swap(_pid, msg._pid);
swap(_file, msg._file);
@@ -266,6 +275,15 @@ const std::string& Message::get(const std::string& param, const std::string& def
return defaultValue;
}
const Message::StringMap& Message::getAll() const
{
static StringMap empty;
if (_pMap)
return *_pMap;
return empty;
}
void Message::set(const std::string& param, const std::string& value)
{
-4
View File
@@ -51,8 +51,6 @@ FastMutex::~FastMutex()
}
#ifdef POCO_HAVE_STD_ATOMICS
SpinlockMutex::SpinlockMutex()
{
}
@@ -62,7 +60,5 @@ SpinlockMutex::~SpinlockMutex()
{
}
#endif // POCO_HAVE_STD_ATOMICS
} // namespace Poco
+2 -2
View File
@@ -52,7 +52,7 @@ bool MutexImpl::tryLockImpl()
case WAIT_OBJECT_0:
return true;
default:
throw SystemException("cannot lock mutex");
throw SystemException("cannot lock mutex");
}
}
@@ -66,7 +66,7 @@ bool MutexImpl::tryLockImpl(long milliseconds)
case WAIT_OBJECT_0:
return true;
default:
throw SystemException("cannot lock mutex");
throw SystemException("cannot lock mutex");
}
}
+9 -7
View File
@@ -18,7 +18,7 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <errno.h>
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX) || defined(__GNU__)
#include <semaphore.h>
#else
#include <unistd.h>
@@ -53,12 +53,14 @@ NamedEventImpl::NamedEventImpl(const std::string& name):
_name(name)
{
std::string fileName = getFileName();
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX) || defined(__GNU__)
_sem = sem_open(fileName.c_str(), O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO, 0);
if ((long) _sem == (long) SEM_FAILED)
throw SystemException(Poco::format("cannot create named mutex %s (sem_open() failed, errno=%d)", fileName, errno), _name);
#else
int fd = open(fileName.c_str(), O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
int fd = open(fileName.c_str(), O_RDONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd == -1 && errno == ENOENT)
fd = open(fileName.c_str(), O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd != -1)
close(fd);
else
@@ -78,13 +80,13 @@ NamedEventImpl::NamedEventImpl(const std::string& name):
_semid = semget(key, 1, 0);
}
else throw SystemException(Poco::format("cannot create named mutex %s (semget() failed, errno=%d)", fileName, errno), _name);
#endif // defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
#endif // defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX) || defined(__GNU__)
}
NamedEventImpl::~NamedEventImpl()
{
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX) || defined(__GNU__)
sem_close(_sem);
#endif
}
@@ -92,7 +94,7 @@ NamedEventImpl::~NamedEventImpl()
void NamedEventImpl::setImpl()
{
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX) || defined(__GNU__)
if (sem_post(_sem) != 0)
throw SystemException("cannot set named event", _name);
#else
@@ -108,7 +110,7 @@ void NamedEventImpl::setImpl()
void NamedEventImpl::waitImpl()
{
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX) || defined(__GNU__)
int err;
do
{
+1 -1
View File
@@ -29,7 +29,7 @@ NamedEventImpl::NamedEventImpl(const std::string& name):
_event = CreateEventW(NULL, FALSE, FALSE, _uname.c_str());
if (!_event)
{
DWORD dwRetVal = GetLastError();
DWORD dwRetVal = GetLastError();
throw SystemException(format("cannot create named event %s [Error %d: %s]", _name, (int)dwRetVal, Error::getMessage(dwRetVal)));
}
}
+10 -8
View File
@@ -18,7 +18,7 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <errno.h>
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(_AIX)
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(_AIX) || defined(__GNU__)
#include <semaphore.h>
#else
#include <unistd.h>
@@ -53,12 +53,14 @@ NamedMutexImpl::NamedMutexImpl(const std::string& name):
_name(name)
{
std::string fileName = getFileName();
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX) || defined(__GNU__)
_sem = sem_open(fileName.c_str(), O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO, 1);
if ((long) _sem == (long) SEM_FAILED)
throw SystemException(Poco::format("cannot create named mutex %s (sem_open() failed, errno=%d)", fileName, errno), _name);
#else
int fd = open(fileName.c_str(), O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
int fd = open(fileName.c_str(), O_RDONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd == -1 && errno == ENOENT)
fd = open(fileName.c_str(), O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd != -1)
close(fd);
else
@@ -83,13 +85,13 @@ NamedMutexImpl::NamedMutexImpl(const std::string& name):
}
throw SystemException(Poco::format("cannot create named mutex %s (semget() failed, errno=%d)", fileName, errno), _name);
#endif // defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
#endif // defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX) || defined(__GNU__)
}
NamedMutexImpl::~NamedMutexImpl()
{
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX) || defined(__GNU__)
sem_close(_sem);
#else
if (_owned) semctl(_semid, 0, IPC_RMID, 0);
@@ -99,7 +101,7 @@ NamedMutexImpl::~NamedMutexImpl()
void NamedMutexImpl::lockImpl()
{
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX) || defined(__GNU__)
int err;
do
{
@@ -125,7 +127,7 @@ void NamedMutexImpl::lockImpl()
bool NamedMutexImpl::tryLockImpl()
{
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX) || defined(__GNU__)
return sem_trywait(_sem) == 0;
#else
struct sembuf op;
@@ -139,7 +141,7 @@ bool NamedMutexImpl::tryLockImpl()
void NamedMutexImpl::unlockImpl()
{
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX) || defined(__GNU__)
if (sem_post(_sem) != 0)
throw SystemException("cannot unlock named mutex", _name);
#else
+1 -1
View File
@@ -25,7 +25,7 @@ NamedMutexImpl::NamedMutexImpl(const std::string& name):
{
UnicodeConverter::toUTF16(_name, _uname);
_mutex = CreateMutexW(NULL, FALSE, _uname.c_str());
if (!_mutex)
if (!_mutex)
throw SystemException("cannot create named mutex", _name);
}
+4 -4
View File
@@ -43,7 +43,7 @@ NestedDiagnosticContext& NestedDiagnosticContext::operator = (const NestedDiagno
return *this;
}
void NestedDiagnosticContext::push(const std::string& info)
{
Context ctx;
@@ -53,7 +53,7 @@ void NestedDiagnosticContext::push(const std::string& info)
_stack.push_back(ctx);
}
void NestedDiagnosticContext::push(const std::string& info, int line, const char* filename)
{
Context ctx;
@@ -70,7 +70,7 @@ void NestedDiagnosticContext::pop()
_stack.pop_back();
}
int NestedDiagnosticContext::depth() const
{
return int(_stack.size());
@@ -89,7 +89,7 @@ std::string NestedDiagnosticContext::toString() const
return result;
}
void NestedDiagnosticContext::dump(std::ostream& ostr) const
{
dump(ostr, "\n");
+4 -4
View File
@@ -53,7 +53,7 @@ void NotificationQueue::enqueueNotification(Notification::Ptr pNotification)
_waitQueue.pop_front();
pWI->pNf = pNotification;
pWI->nfAvailable.set();
}
}
}
@@ -71,7 +71,7 @@ void NotificationQueue::enqueueUrgentNotification(Notification::Ptr pNotificatio
_waitQueue.pop_front();
pWI->pNf = pNotification;
pWI->nfAvailable.set();
}
}
}
@@ -162,7 +162,7 @@ bool NotificationQueue::empty() const
return _nfQueue.empty();
}
int NotificationQueue::size() const
{
FastMutex::ScopedLock lock(_mutex);
@@ -173,7 +173,7 @@ int NotificationQueue::size() const
void NotificationQueue::clear()
{
FastMutex::ScopedLock lock(_mutex);
_nfQueue.clear();
_nfQueue.clear();
}
+1 -1
View File
@@ -27,7 +27,7 @@ NullStreamBuf::~NullStreamBuf()
{
}
int NullStreamBuf::readFromDevice()
{
return -1;
+2 -2
View File
@@ -477,9 +477,9 @@ void NumberFormatter::append(std::string& str, const void* ptr)
{
char buffer[24];
#if defined(POCO_PTR_IS_64_BIT)
std::sprintf(buffer, "%016" PRIXPTR, (UIntPtr) ptr);
std::snprintf(buffer, sizeof(buffer), "%016" PRIXPTR, (UIntPtr) ptr);
#else
std::sprintf(buffer, "%08" PRIXPTR, (UIntPtr) ptr);
std::snprintf(buffer, sizeof(buffer), "%08" PRIXPTR, (UIntPtr) ptr);
#endif
str.append(buffer);
}
+5 -5
View File
@@ -28,7 +28,7 @@
#define I64_FMT "l"
#elif defined(_MSC_VER) || defined(__MINGW32__)
#define I64_FMT "I64"
#elif defined(__APPLE__)
#elif defined(__APPLE__)
#define I64_FMT "q"
#else
#define I64_FMT "ll"
@@ -188,7 +188,7 @@ double NumberParser::parseFloat(const std::string& s, char decSep, char thSep)
bool NumberParser::tryParseFloat(const std::string& s, double& value, char decSep, char thSep)
{
return strToDouble(s.c_str(), value, decSep, thSep);
return strToDouble(s, value, decSep, thSep);
}
@@ -201,7 +201,7 @@ bool NumberParser::parseBool(const std::string& s)
throw SyntaxException("Not a valid bool number", s);
}
bool NumberParser::tryParseBool(const std::string& s, bool& value)
{
int n;
@@ -226,7 +226,7 @@ bool NumberParser::tryParseBool(const std::string& s, bool& value)
value = true;
return true;
}
if (icompare(s, "false") == 0)
{
value = false;
@@ -242,7 +242,7 @@ bool NumberParser::tryParseBool(const std::string& s, bool& value)
value = false;
return true;
}
return false;
}
+4 -4
View File
@@ -13,23 +13,23 @@
#include "Poco/Bugcheck.h"
#include "Poco/NumericString.h"
// +++ double conversion +++
// don't collide with standalone double_conversion library
#define double_conversion poco_double_conversion
#define UNIMPLEMENTED poco_bugcheck
#include "diy-fp.cc"
#include "double-conversion.h"
#include "cached-powers.cc"
#include "bignum-dtoa.cc"
#include "bignum.cc"
#include "fast-dtoa.cc"
#include "fixed-dtoa.cc"
#include "strtod.cc"
#include "double-conversion.cc"
#include "double-to-string.cc"
#include "string-to-double.cc"
// --- double conversion ---
#include "Poco/NumericString.h"
poco_static_assert(POCO_MAX_FLT_STRING_LEN == double_conversion::kMaxSignificantDecimalDigits);
#include "Poco/String.h"
#include <memory>
+1 -1
View File
@@ -169,7 +169,7 @@ Path& Path::operator = (const char* path)
}
void Path::swap(Path& path)
void Path::swap(Path& path) noexcept
{
std::swap(_node, path._node);
std::swap(_device, path._device);
+1 -1
View File
@@ -134,7 +134,7 @@ void PathImpl::listRootsImpl(std::vector<std::string>& roots)
roots.push_back(root);
}
}
}
}
while (FindNextFileW(hFind, &fd));
FindClose(hFind);
}
+4 -3
View File
@@ -80,6 +80,7 @@ void PatternFormatter::format(const Message& msg, std::string& text)
case 'P': NumberFormatter::append(text, msg.getPid()); break;
case 'T': text.append(msg.getThread()); break;
case 'I': NumberFormatter::append(text, msg.getTid()); break;
case 'J': NumberFormatter::append(text, msg.getOsTid()); break;
case 'N': text.append(Environment::nodeName()); break;
case 'U': text.append(msg.getSourceFile() ? msg.getSourceFile() : ""); break;
case 'O': text.append(msg.getSourceFile() ? Path(msg.getSourceFile()).getFileName() : ""); break;
@@ -197,7 +198,7 @@ void PatternFormatter::parsePattern()
}
}
void PatternFormatter::setProperty(const std::string& name, const std::string& value)
{
if (name == PROP_PATTERN)
@@ -214,7 +215,7 @@ void PatternFormatter::setProperty(const std::string& name, const std::string& v
_priorityNames = value;
parsePriorityNames();
}
else
else
{
Formatter::setProperty(name, value);
}
@@ -250,7 +251,7 @@ void PatternFormatter::parsePriorityNames()
const std::string& PatternFormatter::getPriorityName(int prio)
{
poco_assert (1 <= prio && prio <= 8);
poco_assert (1 <= prio && prio <= 8);
return _priorities[prio];
}
+1 -1
View File
@@ -23,7 +23,7 @@ Pipe::Pipe():
{
}
Pipe::Pipe(const Pipe& pipe):
_pImpl(pipe._pImpl)
{
+1 -1
View File
@@ -25,7 +25,7 @@ PipeImpl::PipeImpl()
attr.nLength = sizeof(attr);
attr.lpSecurityDescriptor = NULL;
attr.bInheritHandle = FALSE;
if (!CreatePipe(&_readHandle, &_writeHandle, &attr, 0))
throw CreateFileException("anonymous pipe");
}
+1 -1
View File
@@ -23,7 +23,7 @@ namespace Poco {
//
PipeStreamBuf::PipeStreamBuf(const Pipe& pipe, openmode mode):
PipeStreamBuf::PipeStreamBuf(const Pipe& pipe, openmode mode):
BufferedStreamBuf(STREAM_BUFFER_SIZE, mode),
_pipe(pipe)
{
+3 -3
View File
@@ -54,7 +54,7 @@ void PriorityNotificationQueue::enqueueNotification(Notification::Ptr pNotificat
_waitQueue.pop_front();
pWI->pNf = pNotification;
pWI->nfAvailable.set();
}
}
}
@@ -145,7 +145,7 @@ bool PriorityNotificationQueue::empty() const
return _nfQueue.empty();
}
int PriorityNotificationQueue::size() const
{
FastMutex::ScopedLock lock(_mutex);
@@ -156,7 +156,7 @@ int PriorityNotificationQueue::size() const
void PriorityNotificationQueue::clear()
{
FastMutex::ScopedLock lock(_mutex);
_nfQueue.clear();
_nfQueue.clear();
}
+12 -12
View File
@@ -119,50 +119,50 @@ int ProcessHandle::tryWait() const
//
// Process
//
ProcessHandle Process::launch(const std::string& command, const Args& args)
ProcessHandle Process::launch(const std::string& command, const Args& args, int options)
{
std::string initialDirectory;
Env env;
return ProcessHandle(launchImpl(command, args, initialDirectory, 0, 0, 0, env));
return ProcessHandle(launchImpl(command, args, initialDirectory, 0, 0, 0, env, options));
}
ProcessHandle Process::launch(const std::string& command, const Args& args, const std::string& initialDirectory)
ProcessHandle Process::launch(const std::string& command, const Args& args, const std::string& initialDirectory, int options)
{
Env env;
return ProcessHandle(launchImpl(command, args, initialDirectory, 0, 0, 0, env));
return ProcessHandle(launchImpl(command, args, initialDirectory, 0, 0, 0, env, options));
}
ProcessHandle Process::launch(const std::string& command, const Args& args, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe)
ProcessHandle Process::launch(const std::string& command, const Args& args, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, int options)
{
poco_assert (inPipe == 0 || (inPipe != outPipe && inPipe != errPipe));
std::string initialDirectory;
Env env;
return ProcessHandle(launchImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env));
return ProcessHandle(launchImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env, options));
}
ProcessHandle Process::launch(const std::string& command, const Args& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe)
ProcessHandle Process::launch(const std::string& command, const Args& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, int options)
{
poco_assert (inPipe == 0 || (inPipe != outPipe && inPipe != errPipe));
Env env;
return ProcessHandle(launchImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env));
return ProcessHandle(launchImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env, options));
}
ProcessHandle Process::launch(const std::string& command, const Args& args, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const Env& env)
ProcessHandle Process::launch(const std::string& command, const Args& args, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const Env& env, int options)
{
poco_assert (inPipe == 0 || (inPipe != outPipe && inPipe != errPipe));
std::string initialDirectory;
return ProcessHandle(launchImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env));
return ProcessHandle(launchImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env, options));
}
ProcessHandle Process::launch(const std::string& command, const Args& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const Env& env)
ProcessHandle Process::launch(const std::string& command, const Args& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const Env& env, int options)
{
poco_assert (inPipe == 0 || (inPipe != outPipe && inPipe != errPipe));
return ProcessHandle(launchImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env));
return ProcessHandle(launchImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env, options));
}
+12 -4
View File
@@ -12,6 +12,7 @@
//
#include "Poco/ProcessOptions.h"
#include "Poco/Process_UNIX.h"
#include "Poco/Exception.h"
#include "Poco/NumberFormatter.h"
@@ -112,7 +113,7 @@ void ProcessImpl::timesImpl(long& userTime, long& kernelTime)
}
ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env)
ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env, int options)
{
#if defined(__QNX__)
if (initialDirectory.empty())
@@ -156,21 +157,24 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
throw SystemException("cannot spawn", command);
if (inPipe) inPipe->close(Pipe::CLOSE_READ);
if (options & PROCESS_CLOSE_STDIN) close(STDIN_FILENO);
if (outPipe) outPipe->close(Pipe::CLOSE_WRITE);
if (options & PROCESS_CLOSE_STDOUT) close(STDOUT_FILENO);
if (errPipe) errPipe->close(Pipe::CLOSE_WRITE);
if (options & PROCESS_CLOSE_STDERR) close(STDERR_FILENO);
return new ProcessHandleImpl(pid);
}
else
{
return launchByForkExecImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env);
return launchByForkExecImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env, options);
}
#else
return launchByForkExecImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env);
return launchByForkExecImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env, options);
#endif
}
ProcessHandleImpl* ProcessImpl::launchByForkExecImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env)
ProcessHandleImpl* ProcessImpl::launchByForkExecImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env, int options)
{
#if !defined(POCO_NO_FORK_EXEC)
// On some systems, sysconf(_SC_OPEN_MAX) returns a ridiculously high number,
@@ -222,11 +226,15 @@ ProcessHandleImpl* ProcessImpl::launchByForkExecImpl(const std::string& command,
dup2(inPipe->readHandle(), STDIN_FILENO);
inPipe->close(Pipe::CLOSE_BOTH);
}
if (options & PROCESS_CLOSE_STDIN) close(STDIN_FILENO);
// outPipe and errPipe may be the same, so we dup first and close later
if (outPipe) dup2(outPipe->writeHandle(), STDOUT_FILENO);
if (errPipe) dup2(errPipe->writeHandle(), STDERR_FILENO);
if (outPipe) outPipe->close(Pipe::CLOSE_BOTH);
if (options & PROCESS_CLOSE_STDOUT) close(STDOUT_FILENO);
if (errPipe) errPipe->close(Pipe::CLOSE_BOTH);
if (options & PROCESS_CLOSE_STDERR) close(STDERR_FILENO);
// close all open file descriptors other than stdin, stdout, stderr
long fdMax = sysconf(_SC_OPEN_MAX);
// on some systems, sysconf(_SC_OPEN_MAX) returns a ridiculously high number
+6 -1
View File
@@ -12,6 +12,7 @@
//
#include "Poco/ProcessOptions.h"
#include "Poco/Process_WIN32U.h"
#include "Poco/Exception.h"
#include "Poco/NumberFormatter.h"
@@ -227,7 +228,7 @@ std::string ProcessImpl::escapeArg(const std::string& arg)
}
ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env)
ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env, int options)
{
std::string commandLine = escapeArg(command);
for (const auto& a: args)
@@ -279,6 +280,8 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
{
startupInfo.hStdInput = 0;
}
if (options & PROCESS_CLOSE_STDIN) CloseHandle(GetStdHandle(STD_INPUT_HANDLE));
// outPipe may be the same as errPipe, so we duplicate first and close later.
if (outPipe)
{
@@ -309,7 +312,9 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
startupInfo.hStdError = 0;
}
if (outPipe) outPipe->close(Pipe::CLOSE_WRITE);
if (options & PROCESS_CLOSE_STDOUT) CloseHandle(GetStdHandle(STD_OUTPUT_HANDLE));
if (errPipe) errPipe->close(Pipe::CLOSE_WRITE);
if (options & PROCESS_CLOSE_STDERR) CloseHandle(GetStdHandle(STD_ERROR_HANDLE));
if (mustInheritHandles)
{
+1 -1
View File
@@ -118,7 +118,7 @@ void ProcessImpl::timesImpl(long& userTime, long& kernelTime)
}
ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env)
ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env, int options)
{
std::wstring ucommand;
UnicodeConverter::toUTF16(command, ucommand);
+20
View File
@@ -57,6 +57,26 @@ void PurgeStrategy::list(const std::string& path, std::vector<File>& files)
}
//
// NullPurgeStrategy
//
NullPurgeStrategy::NullPurgeStrategy()
{
}
NullPurgeStrategy::~NullPurgeStrategy()
{
}
void NullPurgeStrategy::purge(const std::string& path)
{
}
//
// PurgeByAgeStrategy
//
+1 -1
View File
@@ -37,7 +37,7 @@ RWLock::RWLock()
{
}
RWLock::~RWLock()
{
}
+1 -1
View File
@@ -186,7 +186,7 @@ DWORD RWLockImpl::tryReadLockOnce()
HANDLE h[2];
h[0] = _mutex;
h[1] = _readEvent;
DWORD result = WaitForMultipleObjects(2, h, TRUE, 1);
DWORD result = WaitForMultipleObjects(2, h, TRUE, 1);
switch (result)
{
case WAIT_OBJECT_0:
+21 -21
View File
@@ -19,13 +19,13 @@
namespace Poco {
RWLockImpl::RWLockImpl():
RWLockImpl::RWLockImpl():
_readerCount(0),
_readerWaiting(0),
_writerCount(0),
_writerWaiting(0),
_writeLock(false)
{
InitializeCriticalSection(&_cs);
_readerGreen = CreateEventW(NULL, FALSE, TRUE, NULL);
@@ -56,7 +56,7 @@ void RWLockImpl::readLockImpl()
bool RWLockImpl::tryReadLockImpl(DWORD timeout)
{
bool wait = false;
do
do
{
EnterCriticalSection(&_cs);
if (!_writerCount && !_writerWaiting)
@@ -68,31 +68,31 @@ bool RWLockImpl::tryReadLockImpl(DWORD timeout)
}
_readerCount++;
}
else
else
{
if (!wait)
if (!wait)
{
_readerWaiting++;
wait = true;
}
ResetEvent(_readerGreen);
}
LeaveCriticalSection(&_cs);
if (wait)
LeaveCriticalSection(&_cs);
if (wait)
{
if (WaitForSingleObject(_readerGreen, timeout) != WAIT_OBJECT_0)
if (WaitForSingleObject(_readerGreen, timeout) != WAIT_OBJECT_0)
{
EnterCriticalSection(&_cs);
_readerWaiting--;
SetEvent(_readerGreen);
SetEvent(_readerGreen);
SetEvent(_writerGreen);
LeaveCriticalSection(&_cs);
return false;
}
}
}
}
while (wait);
return true;
}
@@ -107,21 +107,21 @@ bool RWLockImpl::tryWriteLockImpl(DWORD timeout)
{
bool wait = false;
do
do
{
EnterCriticalSection(&_cs);
if (!_readerCount && !_writerCount)
{
if (wait)
if (wait)
{
_writerWaiting--;
wait = false;
}
_writerCount++;
}
else
else
{
if (!wait)
if (!wait)
{
_writerWaiting++;
wait = true;
@@ -129,9 +129,9 @@ bool RWLockImpl::tryWriteLockImpl(DWORD timeout)
ResetEvent(_writerGreen);
}
LeaveCriticalSection(&_cs);
if (wait)
if (wait)
{
if (WaitForSingleObject(_writerGreen, timeout) != WAIT_OBJECT_0)
if (WaitForSingleObject(_writerGreen, timeout) != WAIT_OBJECT_0)
{
EnterCriticalSection(&_cs);
_writerWaiting--;
@@ -143,7 +143,7 @@ bool RWLockImpl::tryWriteLockImpl(DWORD timeout)
}
}
while (wait);
_writeLock = true;
return true;
}
@@ -152,7 +152,7 @@ bool RWLockImpl::tryWriteLockImpl(DWORD timeout)
void RWLockImpl::unlockImpl()
{
EnterCriticalSection(&_cs);
if (_writeLock)
{
_writeLock = false;
@@ -165,8 +165,8 @@ void RWLockImpl::unlockImpl()
if (_writerWaiting)
SetEvent(_writerGreen);
else if (_readerWaiting)
SetEvent(_readerGreen);
SetEvent(_readerGreen);
LeaveCriticalSection(&_cs);
}
+15 -15
View File
@@ -14,7 +14,7 @@
//
//
// Based on the FreeBSD random number generator.
// src/lib/libc/stdlib/random.c,v 1.25
// src/lib/libc/stdlib/random.c,v 1.25
//
// Copyright (c) 1983, 1993
// The Regents of the University of California. All rights reserved.
@@ -206,7 +206,7 @@ void Random::seed(UInt32 x)
_state[0] = x;
if (_randType == TYPE_0)
lim = NSHUFF;
else
else
{
for (i = 1; i < _randDeg; i++)
_state[i] = goodRand(_state[i - 1]);
@@ -267,36 +267,36 @@ void Random::initState(UInt32 s, char* argState, Int32 n)
{
UInt32* intArgState = (UInt32*) argState;
if (n < BREAK_0)
if (n < BREAK_0)
{
poco_bugcheck_msg("not enough state");
return;
}
if (n < BREAK_1)
if (n < BREAK_1)
{
_randType = TYPE_0;
_randDeg = DEG_0;
_randSep = SEP_0;
}
else if (n < BREAK_2)
}
else if (n < BREAK_2)
{
_randType = TYPE_1;
_randDeg = DEG_1;
_randSep = SEP_1;
}
else if (n < BREAK_3)
}
else if (n < BREAK_3)
{
_randType = TYPE_2;
_randDeg = DEG_2;
_randSep = SEP_2;
}
else if (n < BREAK_4)
}
else if (n < BREAK_4)
{
_randType = TYPE_3;
_randDeg = DEG_3;
_randSep = SEP_3;
}
else
}
else
{
_randType = TYPE_4;
_randDeg = DEG_4;
@@ -334,12 +334,12 @@ UInt32 Random::next()
UInt32 i;
UInt32 *f, *r;
if (_randType == TYPE_0)
if (_randType == TYPE_0)
{
i = _state[0];
_state[0] = i = goodRand(i) & 0x7FFFFFFF;
}
else
}
else
{
/*
* Use local variables rather than static variables for speed.
+2 -2
View File
@@ -51,7 +51,7 @@ int RandomBuf::readFromDevice(char* buffer, std::streamsize length)
#else
#if defined(POCO_OS_FAMILY_UNIX)
int fd = open("/dev/urandom", O_RDONLY, 0);
if (fd >= 0)
if (fd >= 0)
{
n = read(fd, buffer, length);
close(fd);
@@ -65,7 +65,7 @@ int RandomBuf::readFromDevice(char* buffer, std::streamsize length)
Random rnd1(256);
Random rnd2(64);
x += rnd1.next();
n = 0;
SHA1Engine engine;
UInt32 t = (UInt32) std::time(NULL);
+165 -36
View File
@@ -16,39 +16,104 @@
#include "Poco/Exception.h"
#include <sstream>
#if defined(POCO_UNBUNDLED)
#include <pcre.h>
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
#else
#include "pcre_config.h"
#include "pcre.h"
#include "pcre2_config.h"
#include "pcre2.h"
#endif
namespace
{
class MatchData
{
public:
MatchData(pcre2_code_8* code):
_match(pcre2_match_data_create_from_pattern_8(reinterpret_cast<pcre2_code_8*>(code), nullptr))
{
if (!_match) throw Poco::RegularExpressionException("cannot create match data");
}
~MatchData()
{
if (_match) pcre2_match_data_free_8(_match);
}
std::uint32_t count() const
{
return pcre2_get_ovector_count_8(_match);
}
const PCRE2_SIZE* data() const
{
return pcre2_get_ovector_pointer_8(_match);
}
operator pcre2_match_data_8*()
{
return _match;
}
private:
pcre2_match_data_8* _match;
};
}
namespace Poco {
const int RegularExpression::OVEC_SIZE = 63; // must be multiple of 3
RegularExpression::RegularExpression(const std::string& pattern, int options, bool study): _pcre(0), _extra(0)
RegularExpression::RegularExpression(const std::string& pattern, int options, bool /*study*/): _pcre(0)
{
const char* error;
int offs;
_pcre = pcre_compile(pattern.c_str(), options, &error, &offs, 0);
int errorCode;
PCRE2_SIZE errorOffset;
unsigned nameCount;
unsigned nameEntrySize;
unsigned char* nameTable;
pcre2_compile_context_8* context = pcre2_compile_context_create_8(nullptr);
if (!context) throw Poco::RegularExpressionException("cannot create compile context");
if (options & RE_NEWLINE_LF)
pcre2_set_newline_8(context, PCRE2_NEWLINE_LF);
else if (options & RE_NEWLINE_CRLF)
pcre2_set_newline_8(context, PCRE2_NEWLINE_CRLF);
else if (options & RE_NEWLINE_ANY)
pcre2_set_newline_8(context, PCRE2_NEWLINE_ANY);
else if (options & RE_NEWLINE_ANYCRLF)
pcre2_set_newline_8(context, PCRE2_NEWLINE_ANYCRLF);
else // default RE_NEWLINE_CR
pcre2_set_newline_8(context, PCRE2_NEWLINE_CR);
_pcre = pcre2_compile_8(reinterpret_cast<const PCRE2_SPTR>(pattern.c_str()), pattern.length(), compileOptions(options), &errorCode, &errorOffset, context);
pcre2_compile_context_free_8(context);
if (!_pcre)
{
PCRE2_UCHAR buffer[256];
pcre2_get_error_message_8(errorCode, buffer, sizeof(buffer));
std::ostringstream msg;
msg << error << " (at offset " << offs << ")";
msg << reinterpret_cast<char*>(buffer) << " (at offset " << errorOffset << ")";
throw RegularExpressionException(msg.str());
}
if (study)
_extra = pcre_study(reinterpret_cast<pcre*>(_pcre), 0, &error);
pcre2_pattern_info_8(reinterpret_cast<pcre2_code_8*>(_pcre), PCRE2_INFO_NAMECOUNT, &nameCount);
pcre2_pattern_info_8(reinterpret_cast<pcre2_code_8*>(_pcre), PCRE2_INFO_NAMEENTRYSIZE, &nameEntrySize);
pcre2_pattern_info_8(reinterpret_cast<pcre2_code_8*>(_pcre), PCRE2_INFO_NAMETABLE, &nameTable);
for (int i = 0; i < nameCount; i++)
{
unsigned char* group = nameTable + 2 + (nameEntrySize * i);
int n = pcre2_substring_number_from_name_8(reinterpret_cast<pcre2_code_8*>(_pcre), group);
_groups[n] = std::string(reinterpret_cast<char*>(group));
}
}
RegularExpression::~RegularExpression()
{
if (_pcre) pcre_free(reinterpret_cast<pcre*>(_pcre));
if (_extra) pcre_free(reinterpret_cast<struct pcre_extra*>(_extra));
if (_pcre) pcre2_code_free_8(reinterpret_cast<pcre2_code_8*>(_pcre));
}
@@ -56,15 +121,15 @@ int RegularExpression::match(const std::string& subject, std::string::size_type
{
poco_assert (offset <= subject.length());
int ovec[OVEC_SIZE];
int rc = pcre_exec(reinterpret_cast<pcre*>(_pcre), reinterpret_cast<struct pcre_extra*>(_extra), subject.c_str(), int(subject.size()), int(offset), options & 0xFFFF, ovec, OVEC_SIZE);
if (rc == PCRE_ERROR_NOMATCH)
MatchData matchData(reinterpret_cast<pcre2_code_8*>(_pcre));
int rc = pcre2_match_8(reinterpret_cast<pcre2_code_8*>(_pcre), reinterpret_cast<const PCRE2_SPTR>(subject.c_str()), subject.size(), offset, matchOptions(options), matchData, nullptr);
if (rc == PCRE2_ERROR_NOMATCH)
{
mtch.offset = std::string::npos;
mtch.length = 0;
return 0;
}
else if (rc == PCRE_ERROR_BADOPTION)
else if (rc == PCRE2_ERROR_BADOPTION)
{
throw RegularExpressionException("bad option");
}
@@ -74,10 +139,11 @@ int RegularExpression::match(const std::string& subject, std::string::size_type
}
else if (rc < 0)
{
std::ostringstream msg;
msg << "PCRE error " << rc;
throw RegularExpressionException(msg.str());
PCRE2_UCHAR buffer[256];
pcre2_get_error_message_8(rc, buffer, sizeof(buffer));
throw RegularExpressionException(std::string(reinterpret_cast<char*>(buffer)));
}
const PCRE2_SIZE* ovec = matchData.data();
mtch.offset = ovec[0] < 0 ? std::string::npos : ovec[0];
mtch.length = ovec[1] - mtch.offset;
return rc;
@@ -90,13 +156,13 @@ int RegularExpression::match(const std::string& subject, std::string::size_type
matches.clear();
int ovec[OVEC_SIZE];
int rc = pcre_exec(reinterpret_cast<pcre*>(_pcre), reinterpret_cast<struct pcre_extra*>(_extra), subject.c_str(), int(subject.size()), int(offset), options & 0xFFFF, ovec, OVEC_SIZE);
if (rc == PCRE_ERROR_NOMATCH)
MatchData matchData(reinterpret_cast<pcre2_code_8*>(_pcre));
int rc = pcre2_match_8(reinterpret_cast<pcre2_code_8*>(_pcre), reinterpret_cast<const PCRE2_SPTR>(subject.c_str()), subject.size(), offset, options & 0xFFFF, matchData, nullptr);
if (rc == PCRE2_ERROR_NOMATCH)
{
return 0;
}
else if (rc == PCRE_ERROR_BADOPTION)
else if (rc == PCRE2_ERROR_BADOPTION)
{
throw RegularExpressionException("bad option");
}
@@ -106,16 +172,26 @@ int RegularExpression::match(const std::string& subject, std::string::size_type
}
else if (rc < 0)
{
std::ostringstream msg;
msg << "PCRE error " << rc;
throw RegularExpressionException(msg.str());
PCRE2_UCHAR buffer[256];
pcre2_get_error_message_8(rc, buffer, sizeof(buffer));
throw RegularExpressionException(std::string(reinterpret_cast<char*>(buffer)));
}
matches.reserve(rc);
const PCRE2_SIZE* ovec = matchData.data();
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;
@@ -203,13 +279,13 @@ std::string::size_type RegularExpression::substOne(std::string& subject, std::st
{
if (offset >= subject.length()) return std::string::npos;
int ovec[OVEC_SIZE];
int rc = pcre_exec(reinterpret_cast<pcre*>(_pcre), reinterpret_cast<struct pcre_extra*>(_extra), subject.c_str(), int(subject.size()), int(offset), options & 0xFFFF, ovec, OVEC_SIZE);
if (rc == PCRE_ERROR_NOMATCH)
MatchData matchData(reinterpret_cast<pcre2_code_8*>(_pcre));
int rc = pcre2_match_8(reinterpret_cast<pcre2_code_8*>(_pcre), reinterpret_cast<const PCRE2_SPTR>(subject.c_str()), subject.size(), offset, matchOptions(options), matchData, nullptr);
if (rc == PCRE2_ERROR_NOMATCH)
{
return std::string::npos;
}
else if (rc == PCRE_ERROR_BADOPTION)
else if (rc == PCRE2_ERROR_BADOPTION)
{
throw RegularExpressionException("bad option");
}
@@ -219,10 +295,11 @@ std::string::size_type RegularExpression::substOne(std::string& subject, std::st
}
else if (rc < 0)
{
std::ostringstream msg;
msg << "PCRE error " << rc;
throw RegularExpressionException(msg.str());
PCRE2_UCHAR buffer[256];
pcre2_get_error_message_8(rc, buffer, sizeof(buffer));
throw RegularExpressionException(std::string(reinterpret_cast<char*>(buffer)));
}
const PCRE2_SIZE* ovec = matchData.data();
std::string result;
std::string::size_type len = subject.length();
std::string::size_type pos = 0;
@@ -281,4 +358,56 @@ bool RegularExpression::match(const std::string& subject, const std::string& pat
}
int RegularExpression::compileOptions(int options)
{
int pcreOptions = 0;
if (options & RE_CASELESS)
pcreOptions |= PCRE2_CASELESS;
if (options & RE_MULTILINE)
pcreOptions |= PCRE2_MULTILINE;
if (options & RE_DOTALL)
pcreOptions |= PCRE2_DOTALL;
if (options & RE_EXTENDED)
pcreOptions |= PCRE2_EXTENDED;
if (options & RE_ANCHORED)
pcreOptions |= PCRE2_ANCHORED;
if (options & RE_DOLLAR_ENDONLY)
pcreOptions |= PCRE2_DOLLAR_ENDONLY;
if (options & RE_UNGREEDY)
pcreOptions |= PCRE2_UNGREEDY;
if (options & RE_UTF8)
pcreOptions |= PCRE2_UTF | PCRE2_UCP;
if (options & RE_NO_AUTO_CAPTURE)
pcreOptions |= PCRE2_NO_AUTO_CAPTURE;
if (options & RE_FIRSTLINE)
pcreOptions |= PCRE2_FIRSTLINE;
if (options & RE_DUPNAMES)
pcreOptions |= PCRE2_DUPNAMES;
return pcreOptions;
}
int RegularExpression::matchOptions(int options)
{
int pcreOptions = 0;
if (options & RE_ANCHORED)
pcreOptions |= PCRE2_ANCHORED;
if (options & RE_NOTBOL)
pcreOptions |= PCRE2_NOTBOL;
if (options & RE_NOTEOL)
pcreOptions |= PCRE2_NOTEOL;
if (options & RE_NOTEMPTY)
pcreOptions |= PCRE2_NOTEMPTY;
if (options & RE_NO_AUTO_CAPTURE)
pcreOptions |= PCRE2_NO_AUTO_CAPTURE;
if (options & RE_NO_UTF8_CHECK)
pcreOptions |= PCRE2_NO_UTF_CHECK;
return pcreOptions;
}
} // namespace Poco
+12 -1
View File
@@ -38,6 +38,17 @@ RotateStrategy::~RotateStrategy()
}
//
// NullRotateStrategy
//
bool NullRotateStrategy::mustRotate(LogFile* pFile)
{
return false;
}
//
// RotateByIntervalStrategy
//
@@ -46,7 +57,7 @@ RotateStrategy::~RotateStrategy()
const std::string RotateByIntervalStrategy::ROTATE_TEXT("# Log file created/rotated ");
RotateByIntervalStrategy::RotateByIntervalStrategy(const Timespan& span):
RotateByIntervalStrategy::RotateByIntervalStrategy(const Timespan& span):
_span(span),
_lastRotate(0)
{
+9 -2
View File
@@ -54,7 +54,7 @@ inline void SHA1Engine::byteReverse(UInt32* buffer, int byteCount)
#endif // POCO_ARCH_LITTLE_ENDIAN
}
void SHA1Engine::updateImpl(const void* buffer_, std::size_t count)
{
const BYTE* buffer = (const BYTE*) buffer_;
@@ -71,7 +71,7 @@ void SHA1Engine::updateImpl(const void* buffer_, std::size_t count)
{
db[_context.slop++] = *(buffer++);
if (_context.slop == BLOCK_SIZE)
{
{
/* transform this one block */
SHA1_BYTE_REVERSE(_context.data, BLOCK_SIZE);
transform();
@@ -143,7 +143,14 @@ const DigestEngine::Digest& SHA1Engine::digest()
for (count = 0; count < DIGEST_SIZE; count++)
hash[count] = (BYTE) ((_context.digest[count>>2]) >> (8*(3-(count & 0x3)))) & 0xff;
_digest.clear();
#if defined(POCO_COMPILER_GCC)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
_digest.insert(_digest.begin(), hash, hash + DIGEST_SIZE);
#if defined(POCO_COMPILER_GCC)
#pragma GCC diagnostic pop
#endif
reset();
return _digest;
}
+52 -8
View File
@@ -41,7 +41,6 @@ typedef struct
Poco::UInt64 state64[8];
} state;
SHA2Engine::ALGORITHM size;
unsigned char buffer[128];
} HASHCONTEXT;
@@ -274,7 +273,7 @@ void SHA2Engine::updateImpl(const void* buffer_, std::size_t count)
Poco::UInt32 left = 0;
HASHCONTEXT* pContext = (HASHCONTEXT*)_context;
unsigned char* data = (unsigned char*)buffer_;
if (pContext->size > SHA_256)
if (_algorithm > SHA_256)
{
left = (Poco::UInt32)(pContext->total.total64[0] & 0x7F);
size_t fill = 128 - left;
@@ -323,7 +322,31 @@ void SHA2Engine::updateImpl(const void* buffer_, std::size_t count)
std::size_t SHA2Engine::digestLength() const
{
return (size_t)((int)_algorithm / 8);
size_t result = 0;
switch (_algorithm)
{
case SHA_224:
result = 224;
break;
case SHA_256:
result = 256;
break;
case SHA_384:
result = 384;
break;
case SHA_512:
result = 512;
break;
case SHA_512_224:
result = 224;
break;
case SHA_512_256:
result = 256;
break;
}
return result / 8;
}
@@ -332,7 +355,6 @@ void SHA2Engine::reset()
if (_context != NULL) free(_context);
_context = calloc(1, sizeof(HASHCONTEXT));
HASHCONTEXT* pContext = (HASHCONTEXT*)_context;
pContext->size = _algorithm;
if (_algorithm == SHA_224)
{
pContext->state.state32[0] = 0xC1059ED8;
@@ -366,7 +388,7 @@ void SHA2Engine::reset()
pContext->state.state64[6] = UL64(0xDB0C2E0D64F98FA7);
pContext->state.state64[7] = UL64(0x47B5481DBEFA4FA4);
}
else
else if (_algorithm == SHA_512)
{
pContext->state.state64[0] = UL64(0x6A09E667F3BCC908);
pContext->state.state64[1] = UL64(0xBB67AE8584CAA73B);
@@ -377,6 +399,27 @@ void SHA2Engine::reset()
pContext->state.state64[6] = UL64(0x1F83D9ABFB41BD6B);
pContext->state.state64[7] = UL64(0x5BE0CD19137E2179);
}
else if (_algorithm == SHA_512_224)
{
pContext->state.state64[0] = UL64(0x8C3D37C819544DA2);
pContext->state.state64[1] = UL64(0x73E1996689DCD4D6);
pContext->state.state64[2] = UL64(0x1DFAB7AE32FF9C82);
pContext->state.state64[3] = UL64(0x679DD514582F9FCF);
pContext->state.state64[4] = UL64(0x0F6D2B697BD44DA8);
pContext->state.state64[5] = UL64(0x77E36F7304C48942);
pContext->state.state64[6] = UL64(0x3F9D85A86A1D36C8);
pContext->state.state64[7] = UL64(0x1112E6AD91D692A1);
} else
{
pContext->state.state64[0] = UL64(0x22312194FC2BF72C);
pContext->state.state64[1] = UL64(0x9F555FA3C84C64C2);
pContext->state.state64[2] = UL64(0x2393B86B6F53B151);
pContext->state.state64[3] = UL64(0x963877195940EABD);
pContext->state.state64[4] = UL64(0x96283EE2A88EFFE3);
pContext->state.state64[5] = UL64(0xBE5E1E2553863992);
pContext->state.state64[6] = UL64(0x2B0199FC2C85B8AA);
pContext->state.state64[7] = UL64(0x0EB72DDC81C52CA2);
}
}
@@ -388,7 +431,8 @@ const DigestEngine::Digest& SHA2Engine::digest()
size_t last, padn;
unsigned char hash[64];
memset(hash, 0, 64);
if (pContext->size > SHA_256)
if (_algorithm > SHA_256)
{
unsigned char msglen[16];
Poco::UInt64 high = (pContext->total.total64[0] >> 61) | (pContext->total.total64[1] << 3);
@@ -405,7 +449,7 @@ const DigestEngine::Digest& SHA2Engine::digest()
PUT_UINT64(pContext->state.state64[3], hash, 24);
PUT_UINT64(pContext->state.state64[4], hash, 32);
PUT_UINT64(pContext->state.state64[5], hash, 40);
if (pContext->size > SHA_384)
if (_algorithm > SHA_384)
{
PUT_UINT64(pContext->state.state64[6], hash, 48);
PUT_UINT64(pContext->state.state64[7], hash, 56);
@@ -429,7 +473,7 @@ const DigestEngine::Digest& SHA2Engine::digest()
PUT_UINT32(pContext->state.state32[4], hash, 16);
PUT_UINT32(pContext->state.state32[5], hash, 20);
PUT_UINT32(pContext->state.state32[6], hash, 24);
if (pContext->size > SHA_224) PUT_UINT32(pContext->state.state32[7], hash, 28);
if (_algorithm > SHA_224) PUT_UINT32(pContext->state.state32[7], hash, 28);
}
_digest.insert(_digest.begin(), hash, hash + digestLength());
reset();
+1 -1
View File
@@ -57,7 +57,7 @@ bool SemaphoreImpl::waitImpl(long milliseconds)
case WAIT_OBJECT_0:
return true;
default:
throw SystemException("wait for semaphore failed");
throw SystemException("wait for semaphore failed");
}
}
+1 -1
View File
@@ -22,7 +22,7 @@
#include "SharedLibrary_VX.cpp"
#elif defined(POCO_OS_FAMILY_UNIX)
#include "SharedLibrary_UNIX.cpp"
#elif defined(POCO_OS_FAMILY_WINDOWS)
#elif defined(POCO_OS_FAMILY_WINDOWS)
#include "SharedLibrary_WIN32U.cpp"
#endif
+1
View File
@@ -59,6 +59,7 @@ void SharedLibraryImpl::unloadImpl()
bool SharedLibraryImpl::isLoadedImpl() const
{
FastMutex::ScopedLock lock(_mutex);
return _handle != 0;
}
+1
View File
@@ -74,6 +74,7 @@ void SharedLibraryImpl::unloadImpl()
bool SharedLibraryImpl::isLoadedImpl() const
{
FastMutex::ScopedLock lock(_mutex);
return _handle != 0;
}
+1
View File
@@ -99,6 +99,7 @@ void SharedLibraryImpl::unloadImpl()
bool SharedLibraryImpl::isLoadedImpl() const
{
FastMutex::ScopedLock lock(_mutex);
return _moduleId != 0;
}
+1
View File
@@ -77,6 +77,7 @@ void SharedLibraryImpl::unloadImpl()
bool SharedLibraryImpl::isLoadedImpl() const
{
FastMutex::ScopedLock lock(_mutex);
return _handle != 0;
}
+1 -1
View File
@@ -54,7 +54,7 @@ SharedMemoryImpl::SharedMemoryImpl(const std::string& name, std::size_t size, Sh
dwRetVal = GetLastError();
throw SystemException(format("Cannot open shared memory object %s [Error %d: %s]", _name, static_cast<int>(dwRetVal), Error::getMessage(dwRetVal)));
}
#endif
#endif
}
map();
}
+1 -1
View File
@@ -89,7 +89,7 @@ void SignalHandler::handleSignal(int sig)
JumpBufferVec& jb = jumpBufferVec();
if (!jb.empty())
siglongjmp(jb.back().buf, sig);
// Abort if no jump buffer registered
std::abort();
}

Some files were not shown because too many files have changed in this diff Show More