aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/poco/Foundation/src
diff options
context:
space:
mode:
authororivej <orivej@yandex-team.ru>2022-02-10 16:44:49 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:49 +0300
commit718c552901d703c502ccbefdfc3c9028d608b947 (patch)
tree46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/libs/poco/Foundation/src
parente9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff)
downloadydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/poco/Foundation/src')
-rw-r--r--contrib/libs/poco/Foundation/src/ASCIIEncoding.cpp232
-rw-r--r--contrib/libs/poco/Foundation/src/AbstractObserver.cpp84
-rw-r--r--contrib/libs/poco/Foundation/src/ActiveDispatcher.cpp232
-rw-r--r--contrib/libs/poco/Foundation/src/ArchiveStrategy.cpp396
-rw-r--r--contrib/libs/poco/Foundation/src/Ascii.cpp308
-rw-r--r--contrib/libs/poco/Foundation/src/AsyncChannel.cpp336
-rw-r--r--contrib/libs/poco/Foundation/src/AtomicCounter.cpp462
-rw-r--r--contrib/libs/poco/Foundation/src/Base32Decoder.cpp320
-rw-r--r--contrib/libs/poco/Foundation/src/Base32Encoder.cpp404
-rw-r--r--contrib/libs/poco/Foundation/src/Base64Decoder.cpp356
-rw-r--r--contrib/libs/poco/Foundation/src/Base64Encoder.cpp366
-rw-r--r--contrib/libs/poco/Foundation/src/BinaryReader.cpp574
-rw-r--r--contrib/libs/poco/Foundation/src/BinaryWriter.cpp702
-rw-r--r--contrib/libs/poco/Foundation/src/Bugcheck.cpp238
-rw-r--r--contrib/libs/poco/Foundation/src/ByteOrder.cpp30
-rw-r--r--contrib/libs/poco/Foundation/src/Channel.cpp106
-rw-r--r--contrib/libs/poco/Foundation/src/Checksum.cpp116
-rw-r--r--contrib/libs/poco/Foundation/src/Clock.cpp462
-rw-r--r--contrib/libs/poco/Foundation/src/Condition.cpp158
-rw-r--r--contrib/libs/poco/Foundation/src/Configurable.cpp62
-rw-r--r--contrib/libs/poco/Foundation/src/ConsoleChannel.cpp544
-rw-r--r--contrib/libs/poco/Foundation/src/CountingStream.cpp398
-rw-r--r--contrib/libs/poco/Foundation/src/DateTime.cpp864
-rw-r--r--contrib/libs/poco/Foundation/src/DateTimeFormat.cpp122
-rw-r--r--contrib/libs/poco/Foundation/src/DateTimeFormatter.cpp310
-rw-r--r--contrib/libs/poco/Foundation/src/DateTimeParser.cpp796
-rw-r--r--contrib/libs/poco/Foundation/src/Debugger.cpp300
-rw-r--r--contrib/libs/poco/Foundation/src/DeflatingStream.cpp780
-rw-r--r--contrib/libs/poco/Foundation/src/DigestEngine.cpp198
-rw-r--r--contrib/libs/poco/Foundation/src/DigestStream.cpp298
-rw-r--r--contrib/libs/poco/Foundation/src/DirectoryIterator.cpp290
-rw-r--r--contrib/libs/poco/Foundation/src/DirectoryIteratorStrategy.cpp336
-rw-r--r--contrib/libs/poco/Foundation/src/DirectoryIterator_UNIX.cpp128
-rw-r--r--contrib/libs/poco/Foundation/src/DirectoryIterator_WIN32.cpp132
-rw-r--r--contrib/libs/poco/Foundation/src/DirectoryIterator_WIN32U.cpp150
-rw-r--r--contrib/libs/poco/Foundation/src/DirectoryWatcher.cpp1216
-rw-r--r--contrib/libs/poco/Foundation/src/Environment.cpp320
-rw-r--r--contrib/libs/poco/Foundation/src/Environment_UNIX.cpp664
-rw-r--r--contrib/libs/poco/Foundation/src/Environment_VX.cpp318
-rw-r--r--contrib/libs/poco/Foundation/src/Environment_WIN32.cpp442
-rw-r--r--contrib/libs/poco/Foundation/src/Environment_WIN32U.cpp470
-rw-r--r--contrib/libs/poco/Foundation/src/Environment_WINCE.cpp486
-rw-r--r--contrib/libs/poco/Foundation/src/Error.cpp234
-rw-r--r--contrib/libs/poco/Foundation/src/ErrorHandler.cpp228
-rw-r--r--contrib/libs/poco/Foundation/src/Event.cpp80
-rw-r--r--contrib/libs/poco/Foundation/src/EventArgs.cpp66
-rw-r--r--contrib/libs/poco/Foundation/src/EventChannel.cpp74
-rw-r--r--contrib/libs/poco/Foundation/src/EventLogChannel.cpp654
-rw-r--r--contrib/libs/poco/Foundation/src/Event_POSIX.cpp340
-rw-r--r--contrib/libs/poco/Foundation/src/Event_VX.cpp158
-rw-r--r--contrib/libs/poco/Foundation/src/Event_WIN32.cpp122
-rw-r--r--contrib/libs/poco/Foundation/src/Exception.cpp356
-rw-r--r--contrib/libs/poco/Foundation/src/FIFOBufferStream.cpp372
-rw-r--r--contrib/libs/poco/Foundation/src/FPEnvironment.cpp166
-rw-r--r--contrib/libs/poco/Foundation/src/FPEnvironment_C99.cpp164
-rw-r--r--contrib/libs/poco/Foundation/src/FPEnvironment_DEC.cpp390
-rw-r--r--contrib/libs/poco/Foundation/src/FPEnvironment_DUMMY.cpp158
-rw-r--r--contrib/libs/poco/Foundation/src/FPEnvironment_QNX.cpp164
-rw-r--r--contrib/libs/poco/Foundation/src/FPEnvironment_SUN.cpp278
-rw-r--r--contrib/libs/poco/Foundation/src/FPEnvironment_WIN32.cpp152
-rw-r--r--contrib/libs/poco/Foundation/src/File.cpp788
-rw-r--r--contrib/libs/poco/Foundation/src/FileChannel.cpp900
-rw-r--r--contrib/libs/poco/Foundation/src/FileStream.cpp242
-rw-r--r--contrib/libs/poco/Foundation/src/FileStreamFactory.cpp128
-rw-r--r--contrib/libs/poco/Foundation/src/FileStream_POSIX.cpp340
-rw-r--r--contrib/libs/poco/Foundation/src/FileStream_WIN32.cpp416
-rw-r--r--contrib/libs/poco/Foundation/src/File_UNIX.cpp1054
-rw-r--r--contrib/libs/poco/Foundation/src/File_VX.cpp816
-rw-r--r--contrib/libs/poco/Foundation/src/File_WIN32.cpp930
-rw-r--r--contrib/libs/poco/Foundation/src/File_WIN32U.cpp984
-rw-r--r--contrib/libs/poco/Foundation/src/File_WINCE.cpp882
-rw-r--r--contrib/libs/poco/Foundation/src/Format.cpp952
-rw-r--r--contrib/libs/poco/Foundation/src/Formatter.cpp88
-rw-r--r--contrib/libs/poco/Foundation/src/FormattingChannel.cpp252
-rw-r--r--contrib/libs/poco/Foundation/src/Glob.cpp568
-rw-r--r--contrib/libs/poco/Foundation/src/Hash.cpp68
-rw-r--r--contrib/libs/poco/Foundation/src/HashStatistic.cpp128
-rw-r--r--contrib/libs/poco/Foundation/src/HexBinaryDecoder.cpp188
-rw-r--r--contrib/libs/poco/Foundation/src/HexBinaryEncoder.cpp234
-rw-r--r--contrib/libs/poco/Foundation/src/InflatingStream.cpp710
-rw-r--r--contrib/libs/poco/Foundation/src/JSONString.cpp202
-rw-r--r--contrib/libs/poco/Foundation/src/Latin1Encoding.cpp238
-rw-r--r--contrib/libs/poco/Foundation/src/Latin2Encoding.cpp358
-rw-r--r--contrib/libs/poco/Foundation/src/Latin9Encoding.cpp260
-rw-r--r--contrib/libs/poco/Foundation/src/LineEndingConverter.cpp350
-rw-r--r--contrib/libs/poco/Foundation/src/LocalDateTime.cpp634
-rw-r--r--contrib/libs/poco/Foundation/src/LogFile.cpp80
-rw-r--r--contrib/libs/poco/Foundation/src/LogFile_STD.cpp136
-rw-r--r--contrib/libs/poco/Foundation/src/LogFile_WIN32.cpp222
-rw-r--r--contrib/libs/poco/Foundation/src/LogFile_WIN32U.cpp232
-rw-r--r--contrib/libs/poco/Foundation/src/LogStream.cpp436
-rw-r--r--contrib/libs/poco/Foundation/src/Logger.cpp962
-rw-r--r--contrib/libs/poco/Foundation/src/LoggingFactory.cpp234
-rw-r--r--contrib/libs/poco/Foundation/src/LoggingRegistry.cpp234
-rw-r--r--contrib/libs/poco/Foundation/src/MD4Engine.cpp556
-rw-r--r--contrib/libs/poco/Foundation/src/MD5Engine.cpp614
-rw-r--r--contrib/libs/poco/Foundation/src/Manifest.cpp62
-rw-r--r--contrib/libs/poco/Foundation/src/MemoryPool.cpp210
-rw-r--r--contrib/libs/poco/Foundation/src/MemoryStream.cpp114
-rw-r--r--contrib/libs/poco/Foundation/src/Message.cpp530
-rw-r--r--contrib/libs/poco/Foundation/src/Mutex.cpp108
-rw-r--r--contrib/libs/poco/Foundation/src/Mutex_POSIX.cpp350
-rw-r--r--contrib/libs/poco/Foundation/src/Mutex_VX.cpp136
-rw-r--r--contrib/libs/poco/Foundation/src/Mutex_WIN32.cpp118
-rw-r--r--contrib/libs/poco/Foundation/src/Mutex_WINCE.cpp160
-rw-r--r--contrib/libs/poco/Foundation/src/NamedEvent.cpp86
-rw-r--r--contrib/libs/poco/Foundation/src/NamedEvent_Android.cpp88
-rw-r--r--contrib/libs/poco/Foundation/src/NamedEvent_UNIX.cpp296
-rw-r--r--contrib/libs/poco/Foundation/src/NamedEvent_WIN32.cpp122
-rw-r--r--contrib/libs/poco/Foundation/src/NamedEvent_WIN32U.cpp126
-rw-r--r--contrib/libs/poco/Foundation/src/NamedMutex.cpp86
-rw-r--r--contrib/libs/poco/Foundation/src/NamedMutex_Android.cpp100
-rw-r--r--contrib/libs/poco/Foundation/src/NamedMutex_UNIX.cpp340
-rw-r--r--contrib/libs/poco/Foundation/src/NamedMutex_WIN32.cpp146
-rw-r--r--contrib/libs/poco/Foundation/src/NamedMutex_WIN32U.cpp150
-rw-r--r--contrib/libs/poco/Foundation/src/NestedDiagnosticContext.cpp258
-rw-r--r--contrib/libs/poco/Foundation/src/Notification.cpp76
-rw-r--r--contrib/libs/poco/Foundation/src/NotificationCenter.cpp218
-rw-r--r--contrib/libs/poco/Foundation/src/NotificationQueue.cpp422
-rw-r--r--contrib/libs/poco/Foundation/src/NullChannel.cpp82
-rw-r--r--contrib/libs/poco/Foundation/src/NullStream.cpp148
-rw-r--r--contrib/libs/poco/Foundation/src/NumberFormatter.cpp984
-rw-r--r--contrib/libs/poco/Foundation/src/NumberParser.cpp500
-rw-r--r--contrib/libs/poco/Foundation/src/NumericString.cpp640
-rw-r--r--contrib/libs/poco/Foundation/src/Path.cpp2128
-rw-r--r--contrib/libs/poco/Foundation/src/Path_UNIX.cpp504
-rw-r--r--contrib/libs/poco/Foundation/src/Path_WIN32.cpp406
-rw-r--r--contrib/libs/poco/Foundation/src/Path_WIN32U.cpp444
-rw-r--r--contrib/libs/poco/Foundation/src/Path_WINCE.cpp286
-rw-r--r--contrib/libs/poco/Foundation/src/PatternFormatter.cpp486
-rw-r--r--contrib/libs/poco/Foundation/src/Pipe.cpp140
-rw-r--r--contrib/libs/poco/Foundation/src/PipeImpl.cpp56
-rw-r--r--contrib/libs/poco/Foundation/src/PipeImpl_DUMMY.cpp130
-rw-r--r--contrib/libs/poco/Foundation/src/PipeImpl_POSIX.cpp222
-rw-r--r--contrib/libs/poco/Foundation/src/PipeImpl_WIN32.cpp194
-rw-r--r--contrib/libs/poco/Foundation/src/PipeStream.cpp254
-rw-r--r--contrib/libs/poco/Foundation/src/PriorityNotificationQueue.cpp390
-rw-r--r--contrib/libs/poco/Foundation/src/Process.cpp394
-rw-r--r--contrib/libs/poco/Foundation/src/Process_UNIX.cpp556
-rw-r--r--contrib/libs/poco/Foundation/src/Process_VX.cpp200
-rw-r--r--contrib/libs/poco/Foundation/src/Process_WIN32.cpp674
-rw-r--r--contrib/libs/poco/Foundation/src/Process_WIN32U.cpp718
-rw-r--r--contrib/libs/poco/Foundation/src/Process_WINCE.cpp446
-rw-r--r--contrib/libs/poco/Foundation/src/PurgeStrategy.cpp306
-rw-r--r--contrib/libs/poco/Foundation/src/RWLock.cpp92
-rw-r--r--contrib/libs/poco/Foundation/src/RWLock_Android.cpp78
-rw-r--r--contrib/libs/poco/Foundation/src/RWLock_POSIX.cpp68
-rw-r--r--contrib/libs/poco/Foundation/src/RWLock_VX.cpp96
-rw-r--r--contrib/libs/poco/Foundation/src/RWLock_WIN32.cpp414
-rw-r--r--contrib/libs/poco/Foundation/src/RWLock_WINCE.cpp342
-rw-r--r--contrib/libs/poco/Foundation/src/Random.cpp718
-rw-r--r--contrib/libs/poco/Foundation/src/RandomStream.cpp254
-rw-r--r--contrib/libs/poco/Foundation/src/RefCountedObject.cpp62
-rw-r--r--contrib/libs/poco/Foundation/src/RegularExpression.cpp568
-rw-r--r--contrib/libs/poco/Foundation/src/RotateStrategy.cpp226
-rw-r--r--contrib/libs/poco/Foundation/src/Runnable.cpp64
-rw-r--r--contrib/libs/poco/Foundation/src/SHA1Engine.cpp566
-rw-r--r--contrib/libs/poco/Foundation/src/Semaphore.cpp90
-rw-r--r--contrib/libs/poco/Foundation/src/Semaphore_POSIX.cpp340
-rw-r--r--contrib/libs/poco/Foundation/src/Semaphore_VX.cpp104
-rw-r--r--contrib/libs/poco/Foundation/src/Semaphore_WIN32.cpp130
-rw-r--r--contrib/libs/poco/Foundation/src/SharedLibrary.cpp230
-rw-r--r--contrib/libs/poco/Foundation/src/SharedLibrary_HPUX.cpp200
-rw-r--r--contrib/libs/poco/Foundation/src/SharedLibrary_UNIX.cpp272
-rw-r--r--contrib/libs/poco/Foundation/src/SharedLibrary_VX.cpp282
-rw-r--r--contrib/libs/poco/Foundation/src/SharedLibrary_WIN32.cpp216
-rw-r--r--contrib/libs/poco/Foundation/src/SharedLibrary_WIN32U.cpp242
-rw-r--r--contrib/libs/poco/Foundation/src/SharedMemory.cpp180
-rw-r--r--contrib/libs/poco/Foundation/src/SharedMemory_DUMMY.cpp72
-rw-r--r--contrib/libs/poco/Foundation/src/SharedMemory_POSIX.cpp268
-rw-r--r--contrib/libs/poco/Foundation/src/SharedMemory_WIN32.cpp334
-rw-r--r--contrib/libs/poco/Foundation/src/SignalHandler.cpp222
-rw-r--r--contrib/libs/poco/Foundation/src/SimpleFileChannel.cpp454
-rw-r--r--contrib/libs/poco/Foundation/src/SortedDirectoryIterator.cpp244
-rw-r--r--contrib/libs/poco/Foundation/src/SplitterChannel.cpp226
-rw-r--r--contrib/libs/poco/Foundation/src/Stopwatch.cpp120
-rw-r--r--contrib/libs/poco/Foundation/src/StreamChannel.cpp80
-rw-r--r--contrib/libs/poco/Foundation/src/StreamConverter.cpp384
-rw-r--r--contrib/libs/poco/Foundation/src/StreamCopier.cpp300
-rw-r--r--contrib/libs/poco/Foundation/src/StreamTokenizer.cpp210
-rw-r--r--contrib/libs/poco/Foundation/src/String.cpp480
-rw-r--r--contrib/libs/poco/Foundation/src/StringTokenizer.cpp270
-rw-r--r--contrib/libs/poco/Foundation/src/SynchronizedObject.cpp62
-rw-r--r--contrib/libs/poco/Foundation/src/SyslogChannel.cpp512
-rw-r--r--contrib/libs/poco/Foundation/src/Task.cpp280
-rw-r--r--contrib/libs/poco/Foundation/src/TaskManager.cpp312
-rw-r--r--contrib/libs/poco/Foundation/src/TaskNotification.cpp184
-rw-r--r--contrib/libs/poco/Foundation/src/TeeStream.cpp266
-rw-r--r--contrib/libs/poco/Foundation/src/TemporaryFile.cpp332
-rw-r--r--contrib/libs/poco/Foundation/src/TextBufferIterator.cpp354
-rw-r--r--contrib/libs/poco/Foundation/src/TextConverter.cpp256
-rw-r--r--contrib/libs/poco/Foundation/src/TextEncoding.cpp416
-rw-r--r--contrib/libs/poco/Foundation/src/TextIterator.cpp348
-rw-r--r--contrib/libs/poco/Foundation/src/Thread.cpp424
-rw-r--r--contrib/libs/poco/Foundation/src/ThreadLocal.cpp170
-rw-r--r--contrib/libs/poco/Foundation/src/ThreadPool.cpp1052
-rw-r--r--contrib/libs/poco/Foundation/src/ThreadTarget.cpp86
-rw-r--r--contrib/libs/poco/Foundation/src/Thread_POSIX.cpp824
-rw-r--r--contrib/libs/poco/Foundation/src/Thread_VX.cpp546
-rw-r--r--contrib/libs/poco/Foundation/src/Thread_WIN32.cpp446
-rw-r--r--contrib/libs/poco/Foundation/src/Thread_WINCE.cpp338
-rw-r--r--contrib/libs/poco/Foundation/src/TimedNotificationQueue.cpp406
-rw-r--r--contrib/libs/poco/Foundation/src/Timer.cpp494
-rw-r--r--contrib/libs/poco/Foundation/src/Timespan.cpp290
-rw-r--r--contrib/libs/poco/Foundation/src/Timestamp.cpp626
-rw-r--r--contrib/libs/poco/Foundation/src/Timezone.cpp82
-rw-r--r--contrib/libs/poco/Foundation/src/Timezone_UNIX.cpp220
-rw-r--r--contrib/libs/poco/Foundation/src/Timezone_VX.cpp156
-rw-r--r--contrib/libs/poco/Foundation/src/Timezone_WIN32.cpp202
-rw-r--r--contrib/libs/poco/Foundation/src/Timezone_WINCE.cpp184
-rw-r--r--contrib/libs/poco/Foundation/src/Token.cpp332
-rw-r--r--contrib/libs/poco/Foundation/src/URI.cpp1834
-rw-r--r--contrib/libs/poco/Foundation/src/URIStreamFactory.cpp116
-rw-r--r--contrib/libs/poco/Foundation/src/URIStreamOpener.cpp422
-rw-r--r--contrib/libs/poco/Foundation/src/UTF16Encoding.cpp544
-rw-r--r--contrib/libs/poco/Foundation/src/UTF32Encoding.cpp356
-rw-r--r--contrib/libs/poco/Foundation/src/UTF8Encoding.cpp492
-rw-r--r--contrib/libs/poco/Foundation/src/UTF8String.cpp754
-rw-r--r--contrib/libs/poco/Foundation/src/UUID.cpp740
-rw-r--r--contrib/libs/poco/Foundation/src/UUIDGenerator.cpp302
-rw-r--r--contrib/libs/poco/Foundation/src/Unicode.cpp112
-rw-r--r--contrib/libs/poco/Foundation/src/UnicodeConverter.cpp320
-rw-r--r--contrib/libs/poco/Foundation/src/Var.cpp1268
-rw-r--r--contrib/libs/poco/Foundation/src/VarHolder.cpp184
-rw-r--r--contrib/libs/poco/Foundation/src/VarIterator.cpp334
-rw-r--r--contrib/libs/poco/Foundation/src/Void.cpp84
-rw-r--r--contrib/libs/poco/Foundation/src/Windows1250Encoding.cpp392
-rw-r--r--contrib/libs/poco/Foundation/src/Windows1251Encoding.cpp474
-rw-r--r--contrib/libs/poco/Foundation/src/Windows1252Encoding.cpp302
-rw-r--r--contrib/libs/poco/Foundation/src/WindowsConsoleChannel.cpp604
-rw-r--r--contrib/libs/poco/Foundation/src/pocomsg.h316
231 files changed, 40658 insertions, 40658 deletions
diff --git a/contrib/libs/poco/Foundation/src/ASCIIEncoding.cpp b/contrib/libs/poco/Foundation/src/ASCIIEncoding.cpp
index 32c4f79157..bab850468c 100644
--- a/contrib/libs/poco/Foundation/src/ASCIIEncoding.cpp
+++ b/contrib/libs/poco/Foundation/src/ASCIIEncoding.cpp
@@ -1,116 +1,116 @@
-//
-// ASCIIEncoding.cpp
-//
-// Library: Foundation
-// Package: Text
-// Module: ASCIIEncoding
-//
-// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/ASCIIEncoding.h"
-#include "Poco/String.h"
-
-
-namespace Poco {
-
-
-const char* ASCIIEncoding::_names[] =
-{
- "ASCII",
- NULL
-};
-
-
-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,
-};
-
-
-ASCIIEncoding::ASCIIEncoding()
-{
-}
-
-
-ASCIIEncoding::~ASCIIEncoding()
-{
-}
-
-
-const char* ASCIIEncoding::canonicalName() const
-{
- return _names[0];
-}
-
-
-bool ASCIIEncoding::isA(const std::string& encodingName) const
-{
- for (const char** name = _names; *name; ++name)
- {
- if (Poco::icompare(encodingName, *name) == 0)
- return true;
- }
- return false;
-}
-
-
-const TextEncoding::CharacterMap& ASCIIEncoding::characterMap() const
-{
- return _charMap;
-}
-
-
-int ASCIIEncoding::convert(const unsigned char* bytes) const
-{
- return _charMap[*bytes];
-}
-
-
-int ASCIIEncoding::convert(int ch, unsigned char* bytes, int length) const
-{
- if (ch >= 0 && ch <= 127)
- {
- if (bytes && length >= 1)
- *bytes = (unsigned char) ch;
- return 1;
- }
- else return 0;
-}
-
-
-int ASCIIEncoding::queryConvert(const unsigned char* bytes, int length) const
-{
- if (1 <= length)
- return _charMap [*bytes];
- else
- return -1;
-}
-
-
-int ASCIIEncoding::sequenceLength(const unsigned char* /*bytes*/, int /*length*/) const
-{
- return 1;
-}
-
-
-} // namespace Poco
+//
+// ASCIIEncoding.cpp
+//
+// Library: Foundation
+// Package: Text
+// Module: ASCIIEncoding
+//
+// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/ASCIIEncoding.h"
+#include "Poco/String.h"
+
+
+namespace Poco {
+
+
+const char* ASCIIEncoding::_names[] =
+{
+ "ASCII",
+ NULL
+};
+
+
+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,
+};
+
+
+ASCIIEncoding::ASCIIEncoding()
+{
+}
+
+
+ASCIIEncoding::~ASCIIEncoding()
+{
+}
+
+
+const char* ASCIIEncoding::canonicalName() const
+{
+ return _names[0];
+}
+
+
+bool ASCIIEncoding::isA(const std::string& encodingName) const
+{
+ for (const char** name = _names; *name; ++name)
+ {
+ if (Poco::icompare(encodingName, *name) == 0)
+ return true;
+ }
+ return false;
+}
+
+
+const TextEncoding::CharacterMap& ASCIIEncoding::characterMap() const
+{
+ return _charMap;
+}
+
+
+int ASCIIEncoding::convert(const unsigned char* bytes) const
+{
+ return _charMap[*bytes];
+}
+
+
+int ASCIIEncoding::convert(int ch, unsigned char* bytes, int length) const
+{
+ if (ch >= 0 && ch <= 127)
+ {
+ if (bytes && length >= 1)
+ *bytes = (unsigned char) ch;
+ return 1;
+ }
+ else return 0;
+}
+
+
+int ASCIIEncoding::queryConvert(const unsigned char* bytes, int length) const
+{
+ if (1 <= length)
+ return _charMap [*bytes];
+ else
+ return -1;
+}
+
+
+int ASCIIEncoding::sequenceLength(const unsigned char* /*bytes*/, int /*length*/) const
+{
+ return 1;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/AbstractObserver.cpp b/contrib/libs/poco/Foundation/src/AbstractObserver.cpp
index a0fd89657c..30bf9e5ea4 100644
--- a/contrib/libs/poco/Foundation/src/AbstractObserver.cpp
+++ b/contrib/libs/poco/Foundation/src/AbstractObserver.cpp
@@ -1,42 +1,42 @@
-//
-// AbstractObserver.cpp
-//
-// Library: Foundation
-// Package: Notifications
-// Module: NotificationCenter
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/AbstractObserver.h"
-
-
-namespace Poco {
-
-
-AbstractObserver::AbstractObserver()
-{
-}
-
-
-AbstractObserver::AbstractObserver(const AbstractObserver& /*observer*/)
-{
-}
-
-
-AbstractObserver::~AbstractObserver()
-{
-}
-
-
-AbstractObserver& AbstractObserver::operator = (const AbstractObserver& /*observer*/)
-{
- return *this;
-}
-
-
-} // namespace Poco
+//
+// AbstractObserver.cpp
+//
+// Library: Foundation
+// Package: Notifications
+// Module: NotificationCenter
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/AbstractObserver.h"
+
+
+namespace Poco {
+
+
+AbstractObserver::AbstractObserver()
+{
+}
+
+
+AbstractObserver::AbstractObserver(const AbstractObserver& /*observer*/)
+{
+}
+
+
+AbstractObserver::~AbstractObserver()
+{
+}
+
+
+AbstractObserver& AbstractObserver::operator = (const AbstractObserver& /*observer*/)
+{
+ return *this;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/ActiveDispatcher.cpp b/contrib/libs/poco/Foundation/src/ActiveDispatcher.cpp
index a50bd2fcf4..fc20a04fe8 100644
--- a/contrib/libs/poco/Foundation/src/ActiveDispatcher.cpp
+++ b/contrib/libs/poco/Foundation/src/ActiveDispatcher.cpp
@@ -1,116 +1,116 @@
-//
-// ActiveDispatcher.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: ActiveObjects
-//
-// Copyright (c) 2006-2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/ActiveDispatcher.h"
-#include "Poco/Notification.h"
-#include "Poco/AutoPtr.h"
-
-
-namespace Poco {
-
-
-namespace
-{
- class MethodNotification: public Notification
- {
- public:
- MethodNotification(ActiveRunnableBase::Ptr pRunnable):
- _pRunnable(pRunnable)
- {
- }
-
- ActiveRunnableBase::Ptr runnable() const
- {
- return _pRunnable;
- }
-
- private:
- ActiveRunnableBase::Ptr _pRunnable;
- };
-
- class StopNotification: public Notification
- {
- };
-}
-
-
-ActiveDispatcher::ActiveDispatcher()
-{
-}
-
-
-ActiveDispatcher::ActiveDispatcher(Thread::Priority prio)
-{
- _thread.setPriority(prio);
-}
-
-
-ActiveDispatcher::~ActiveDispatcher()
-{
- try
- {
- stop();
- }
- catch (...)
- {
- }
-}
-
-
-void ActiveDispatcher::start(ActiveRunnableBase::Ptr pRunnable)
-{
- poco_check_ptr (pRunnable);
-
- if (!_thread.isRunning())
- {
- _thread.start(*this);
- }
-
- _queue.enqueueNotification(new MethodNotification(pRunnable));
-}
-
-
-void ActiveDispatcher::cancel()
-{
- _queue.clear();
-}
-
-
-void ActiveDispatcher::run()
-{
- AutoPtr<Notification> pNf = _queue.waitDequeueNotification();
- while (pNf && !dynamic_cast<StopNotification*>(pNf.get()))
- {
- MethodNotification* pMethodNf = dynamic_cast<MethodNotification*>(pNf.get());
- poco_check_ptr (pMethodNf);
- ActiveRunnableBase::Ptr pRunnable = pMethodNf->runnable();
- pRunnable->duplicate(); // run will release
- pRunnable->run();
- pRunnable = 0;
- pNf = 0;
- pNf = _queue.waitDequeueNotification();
- }
-}
-
-
-void ActiveDispatcher::stop()
-{
- _queue.clear();
- _queue.wakeUpAll();
- _queue.enqueueNotification(new StopNotification);
- _thread.join();
-}
-
-
-} // namespace Poco
+//
+// ActiveDispatcher.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: ActiveObjects
+//
+// Copyright (c) 2006-2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/ActiveDispatcher.h"
+#include "Poco/Notification.h"
+#include "Poco/AutoPtr.h"
+
+
+namespace Poco {
+
+
+namespace
+{
+ class MethodNotification: public Notification
+ {
+ public:
+ MethodNotification(ActiveRunnableBase::Ptr pRunnable):
+ _pRunnable(pRunnable)
+ {
+ }
+
+ ActiveRunnableBase::Ptr runnable() const
+ {
+ return _pRunnable;
+ }
+
+ private:
+ ActiveRunnableBase::Ptr _pRunnable;
+ };
+
+ class StopNotification: public Notification
+ {
+ };
+}
+
+
+ActiveDispatcher::ActiveDispatcher()
+{
+}
+
+
+ActiveDispatcher::ActiveDispatcher(Thread::Priority prio)
+{
+ _thread.setPriority(prio);
+}
+
+
+ActiveDispatcher::~ActiveDispatcher()
+{
+ try
+ {
+ stop();
+ }
+ catch (...)
+ {
+ }
+}
+
+
+void ActiveDispatcher::start(ActiveRunnableBase::Ptr pRunnable)
+{
+ poco_check_ptr (pRunnable);
+
+ if (!_thread.isRunning())
+ {
+ _thread.start(*this);
+ }
+
+ _queue.enqueueNotification(new MethodNotification(pRunnable));
+}
+
+
+void ActiveDispatcher::cancel()
+{
+ _queue.clear();
+}
+
+
+void ActiveDispatcher::run()
+{
+ AutoPtr<Notification> pNf = _queue.waitDequeueNotification();
+ while (pNf && !dynamic_cast<StopNotification*>(pNf.get()))
+ {
+ MethodNotification* pMethodNf = dynamic_cast<MethodNotification*>(pNf.get());
+ poco_check_ptr (pMethodNf);
+ ActiveRunnableBase::Ptr pRunnable = pMethodNf->runnable();
+ pRunnable->duplicate(); // run will release
+ pRunnable->run();
+ pRunnable = 0;
+ pNf = 0;
+ pNf = _queue.waitDequeueNotification();
+ }
+}
+
+
+void ActiveDispatcher::stop()
+{
+ _queue.clear();
+ _queue.wakeUpAll();
+ _queue.enqueueNotification(new StopNotification);
+ _thread.join();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/ArchiveStrategy.cpp b/contrib/libs/poco/Foundation/src/ArchiveStrategy.cpp
index b711ff37de..1d669f8ee3 100644
--- a/contrib/libs/poco/Foundation/src/ArchiveStrategy.cpp
+++ b/contrib/libs/poco/Foundation/src/ArchiveStrategy.cpp
@@ -1,198 +1,198 @@
-//
-// ArchiveStrategy.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: FileChannel
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/ArchiveStrategy.h"
-#include "Poco/NumberFormatter.h"
-#include "Poco/File.h"
-#include "Poco/Path.h"
-#include "Poco/DeflatingStream.h"
-#include "Poco/StreamCopier.h"
-#include "Poco/Exception.h"
-#include "Poco/ActiveDispatcher.h"
-#include "Poco/ActiveMethod.h"
-#include "Poco/Void.h"
-#include "Poco/FileStream.h"
-
-#undef compress
-
-
-namespace Poco {
-
-
-//
-// ArchiveCompressor
-//
-
-
-class ArchiveCompressor: public ActiveDispatcher
-{
-public:
- ArchiveCompressor():
- compress(this, &ArchiveCompressor::compressImpl)
- {
- }
-
- ~ArchiveCompressor()
- {
- }
-
- ActiveMethod<void, std::string, ArchiveCompressor, ActiveStarter<ActiveDispatcher> > compress;
-
-protected:
- void compressImpl(const std::string& path)
- {
- std::string gzPath(path);
- gzPath.append(".gz");
- FileInputStream istr(path);
- FileOutputStream ostr(gzPath);
- try
- {
- DeflatingOutputStream deflater(ostr, DeflatingStreamBuf::STREAM_GZIP);
- StreamCopier::copyStream(istr, deflater);
- if (!deflater.good() || !ostr.good()) throw WriteFileException(gzPath);
- deflater.close();
- ostr.close();
- istr.close();
- }
- catch (Poco::Exception&)
- {
- // deflating failed - remove gz file and leave uncompressed log file
- ostr.close();
- Poco::File gzf(gzPath);
- gzf.remove();
- return;
- }
- File f(path);
- f.remove();
- return;
- }
-};
-
-
-//
-// ArchiveStrategy
-//
-
-
-ArchiveStrategy::ArchiveStrategy():
- _compress(false),
- _pCompressor(0)
-{
-}
-
-
-ArchiveStrategy::~ArchiveStrategy()
-{
- delete _pCompressor;
-}
-
-
-void ArchiveStrategy::compress(bool flag)
-{
- _compress = flag;
-}
-
-
-void ArchiveStrategy::moveFile(const std::string& oldPath, const std::string& newPath)
-{
- bool compressed = false;
- Path p(oldPath);
- File f(oldPath);
- if (!f.exists())
- {
- f = oldPath + ".gz";
- compressed = true;
- }
- std::string mvPath(newPath);
- if (_compress || compressed)
- mvPath.append(".gz");
- if (!_compress || compressed)
- {
- f.renameTo(mvPath);
- }
- else
- {
- f.renameTo(newPath);
- if (!_pCompressor) _pCompressor = new ArchiveCompressor;
- _pCompressor->compress(newPath);
- }
-}
-
-
-bool ArchiveStrategy::exists(const std::string& name)
-{
- File f(name);
- if (f.exists())
- {
- return true;
- }
- else if (_compress)
- {
- std::string gzName(name);
- gzName.append(".gz");
- File gzf(gzName);
- return gzf.exists();
- }
- else return false;
-}
-
-
-//
-// ArchiveByNumberStrategy
-//
-
-
-ArchiveByNumberStrategy::ArchiveByNumberStrategy()
-{
-}
-
-
-ArchiveByNumberStrategy::~ArchiveByNumberStrategy()
-{
-}
-
-
-LogFile* ArchiveByNumberStrategy::archive(LogFile* pFile)
-{
- std::string basePath = pFile->path();
- delete pFile;
- int n = -1;
- std::string path;
- do
- {
- path = basePath;
- path.append(".");
- NumberFormatter::append(path, ++n);
- }
- while (exists(path));
-
- while (n >= 0)
- {
- std::string oldPath = basePath;
- if (n > 0)
- {
- oldPath.append(".");
- NumberFormatter::append(oldPath, n - 1);
- }
- std::string newPath = basePath;
- newPath.append(".");
- NumberFormatter::append(newPath, n);
- moveFile(oldPath, newPath);
- --n;
- }
- return new LogFile(basePath);
-}
-
-
-} // namespace Poco
+//
+// ArchiveStrategy.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: FileChannel
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/ArchiveStrategy.h"
+#include "Poco/NumberFormatter.h"
+#include "Poco/File.h"
+#include "Poco/Path.h"
+#include "Poco/DeflatingStream.h"
+#include "Poco/StreamCopier.h"
+#include "Poco/Exception.h"
+#include "Poco/ActiveDispatcher.h"
+#include "Poco/ActiveMethod.h"
+#include "Poco/Void.h"
+#include "Poco/FileStream.h"
+
+#undef compress
+
+
+namespace Poco {
+
+
+//
+// ArchiveCompressor
+//
+
+
+class ArchiveCompressor: public ActiveDispatcher
+{
+public:
+ ArchiveCompressor():
+ compress(this, &ArchiveCompressor::compressImpl)
+ {
+ }
+
+ ~ArchiveCompressor()
+ {
+ }
+
+ ActiveMethod<void, std::string, ArchiveCompressor, ActiveStarter<ActiveDispatcher> > compress;
+
+protected:
+ void compressImpl(const std::string& path)
+ {
+ std::string gzPath(path);
+ gzPath.append(".gz");
+ FileInputStream istr(path);
+ FileOutputStream ostr(gzPath);
+ try
+ {
+ DeflatingOutputStream deflater(ostr, DeflatingStreamBuf::STREAM_GZIP);
+ StreamCopier::copyStream(istr, deflater);
+ if (!deflater.good() || !ostr.good()) throw WriteFileException(gzPath);
+ deflater.close();
+ ostr.close();
+ istr.close();
+ }
+ catch (Poco::Exception&)
+ {
+ // deflating failed - remove gz file and leave uncompressed log file
+ ostr.close();
+ Poco::File gzf(gzPath);
+ gzf.remove();
+ return;
+ }
+ File f(path);
+ f.remove();
+ return;
+ }
+};
+
+
+//
+// ArchiveStrategy
+//
+
+
+ArchiveStrategy::ArchiveStrategy():
+ _compress(false),
+ _pCompressor(0)
+{
+}
+
+
+ArchiveStrategy::~ArchiveStrategy()
+{
+ delete _pCompressor;
+}
+
+
+void ArchiveStrategy::compress(bool flag)
+{
+ _compress = flag;
+}
+
+
+void ArchiveStrategy::moveFile(const std::string& oldPath, const std::string& newPath)
+{
+ bool compressed = false;
+ Path p(oldPath);
+ File f(oldPath);
+ if (!f.exists())
+ {
+ f = oldPath + ".gz";
+ compressed = true;
+ }
+ std::string mvPath(newPath);
+ if (_compress || compressed)
+ mvPath.append(".gz");
+ if (!_compress || compressed)
+ {
+ f.renameTo(mvPath);
+ }
+ else
+ {
+ f.renameTo(newPath);
+ if (!_pCompressor) _pCompressor = new ArchiveCompressor;
+ _pCompressor->compress(newPath);
+ }
+}
+
+
+bool ArchiveStrategy::exists(const std::string& name)
+{
+ File f(name);
+ if (f.exists())
+ {
+ return true;
+ }
+ else if (_compress)
+ {
+ std::string gzName(name);
+ gzName.append(".gz");
+ File gzf(gzName);
+ return gzf.exists();
+ }
+ else return false;
+}
+
+
+//
+// ArchiveByNumberStrategy
+//
+
+
+ArchiveByNumberStrategy::ArchiveByNumberStrategy()
+{
+}
+
+
+ArchiveByNumberStrategy::~ArchiveByNumberStrategy()
+{
+}
+
+
+LogFile* ArchiveByNumberStrategy::archive(LogFile* pFile)
+{
+ std::string basePath = pFile->path();
+ delete pFile;
+ int n = -1;
+ std::string path;
+ do
+ {
+ path = basePath;
+ path.append(".");
+ NumberFormatter::append(path, ++n);
+ }
+ while (exists(path));
+
+ while (n >= 0)
+ {
+ std::string oldPath = basePath;
+ if (n > 0)
+ {
+ oldPath.append(".");
+ NumberFormatter::append(oldPath, n - 1);
+ }
+ std::string newPath = basePath;
+ newPath.append(".");
+ NumberFormatter::append(newPath, n);
+ moveFile(oldPath, newPath);
+ --n;
+ }
+ return new LogFile(basePath);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Ascii.cpp b/contrib/libs/poco/Foundation/src/Ascii.cpp
index 676b2db8eb..c88c4e7044 100644
--- a/contrib/libs/poco/Foundation/src/Ascii.cpp
+++ b/contrib/libs/poco/Foundation/src/Ascii.cpp
@@ -1,154 +1,154 @@
-//
-// Ascii.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: Ascii
-//
-// Copyright (c) 2010, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Ascii.h"
-
-
-namespace Poco {
-
-
-const int Ascii::CHARACTER_PROPERTIES[128] =
-{
- /* 00 . */ ACP_CONTROL,
- /* 01 . */ ACP_CONTROL,
- /* 02 . */ ACP_CONTROL,
- /* 03 . */ ACP_CONTROL,
- /* 04 . */ ACP_CONTROL,
- /* 05 . */ ACP_CONTROL,
- /* 06 . */ ACP_CONTROL,
- /* 07 . */ ACP_CONTROL,
- /* 08 . */ ACP_CONTROL,
- /* 09 . */ ACP_CONTROL | ACP_SPACE,
- /* 0a . */ ACP_CONTROL | ACP_SPACE,
- /* 0b . */ ACP_CONTROL | ACP_SPACE,
- /* 0c . */ ACP_CONTROL | ACP_SPACE,
- /* 0d . */ ACP_CONTROL | ACP_SPACE,
- /* 0e . */ ACP_CONTROL,
- /* 0f . */ ACP_CONTROL,
- /* 10 . */ ACP_CONTROL,
- /* 11 . */ ACP_CONTROL,
- /* 12 . */ ACP_CONTROL,
- /* 13 . */ ACP_CONTROL,
- /* 14 . */ ACP_CONTROL,
- /* 15 . */ ACP_CONTROL,
- /* 16 . */ ACP_CONTROL,
- /* 17 . */ ACP_CONTROL,
- /* 18 . */ ACP_CONTROL,
- /* 19 . */ ACP_CONTROL,
- /* 1a . */ ACP_CONTROL,
- /* 1b . */ ACP_CONTROL,
- /* 1c . */ ACP_CONTROL,
- /* 1d . */ ACP_CONTROL,
- /* 1e . */ ACP_CONTROL,
- /* 1f . */ ACP_CONTROL,
- /* 20 */ ACP_SPACE | ACP_PRINT,
- /* 21 ! */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 22 " */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 23 # */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 24 $ */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 25 % */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 26 & */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 27 ' */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 28 ( */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 29 ) */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 2a * */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 2b + */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 2c , */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 2d - */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 2e . */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 2f / */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 30 0 */ ACP_DIGIT | ACP_HEXDIGIT | ACP_GRAPH | ACP_PRINT,
- /* 31 1 */ ACP_DIGIT | ACP_HEXDIGIT | ACP_GRAPH | ACP_PRINT,
- /* 32 2 */ ACP_DIGIT | ACP_HEXDIGIT | ACP_GRAPH | ACP_PRINT,
- /* 33 3 */ ACP_DIGIT | ACP_HEXDIGIT | ACP_GRAPH | ACP_PRINT,
- /* 34 4 */ ACP_DIGIT | ACP_HEXDIGIT | ACP_GRAPH | ACP_PRINT,
- /* 35 5 */ ACP_DIGIT | ACP_HEXDIGIT | ACP_GRAPH | ACP_PRINT,
- /* 36 6 */ ACP_DIGIT | ACP_HEXDIGIT | ACP_GRAPH | ACP_PRINT,
- /* 37 7 */ ACP_DIGIT | ACP_HEXDIGIT | ACP_GRAPH | ACP_PRINT,
- /* 38 8 */ ACP_DIGIT | ACP_HEXDIGIT | ACP_GRAPH | ACP_PRINT,
- /* 39 9 */ ACP_DIGIT | ACP_HEXDIGIT | ACP_GRAPH | ACP_PRINT,
- /* 3a : */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 3b ; */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 3c < */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 3d = */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 3e > */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 3f ? */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 40 @ */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 41 A */ ACP_HEXDIGIT | ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 42 B */ ACP_HEXDIGIT | ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 43 C */ ACP_HEXDIGIT | ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 44 D */ ACP_HEXDIGIT | ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 45 E */ ACP_HEXDIGIT | ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 46 F */ ACP_HEXDIGIT | ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 47 G */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 48 H */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 49 I */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 4a J */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 4b K */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 4c L */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 4d M */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 4e N */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 4f O */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 50 P */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 51 Q */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 52 R */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 53 S */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 54 T */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 55 U */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 56 V */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 57 W */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 58 X */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 59 Y */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 5a Z */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
- /* 5b [ */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 5c \ */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 5d ] */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 5e ^ */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 5f _ */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 60 ` */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 61 a */ ACP_HEXDIGIT | ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 62 b */ ACP_HEXDIGIT | ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 63 c */ ACP_HEXDIGIT | ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 64 d */ ACP_HEXDIGIT | ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 65 e */ ACP_HEXDIGIT | ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 66 f */ ACP_HEXDIGIT | ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 67 g */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 68 h */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 69 i */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 6a j */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 6b k */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 6c l */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 6d m */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 6e n */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 6f o */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 70 p */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 71 q */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 72 r */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 73 s */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 74 t */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 75 u */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 76 v */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 77 w */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 78 x */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 79 y */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 7a z */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
- /* 7b { */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 7c | */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 7d } */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 7e ~ */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
- /* 7f . */ ACP_CONTROL
-};
-
-
-} // namespace Poco
+//
+// Ascii.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: Ascii
+//
+// Copyright (c) 2010, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Ascii.h"
+
+
+namespace Poco {
+
+
+const int Ascii::CHARACTER_PROPERTIES[128] =
+{
+ /* 00 . */ ACP_CONTROL,
+ /* 01 . */ ACP_CONTROL,
+ /* 02 . */ ACP_CONTROL,
+ /* 03 . */ ACP_CONTROL,
+ /* 04 . */ ACP_CONTROL,
+ /* 05 . */ ACP_CONTROL,
+ /* 06 . */ ACP_CONTROL,
+ /* 07 . */ ACP_CONTROL,
+ /* 08 . */ ACP_CONTROL,
+ /* 09 . */ ACP_CONTROL | ACP_SPACE,
+ /* 0a . */ ACP_CONTROL | ACP_SPACE,
+ /* 0b . */ ACP_CONTROL | ACP_SPACE,
+ /* 0c . */ ACP_CONTROL | ACP_SPACE,
+ /* 0d . */ ACP_CONTROL | ACP_SPACE,
+ /* 0e . */ ACP_CONTROL,
+ /* 0f . */ ACP_CONTROL,
+ /* 10 . */ ACP_CONTROL,
+ /* 11 . */ ACP_CONTROL,
+ /* 12 . */ ACP_CONTROL,
+ /* 13 . */ ACP_CONTROL,
+ /* 14 . */ ACP_CONTROL,
+ /* 15 . */ ACP_CONTROL,
+ /* 16 . */ ACP_CONTROL,
+ /* 17 . */ ACP_CONTROL,
+ /* 18 . */ ACP_CONTROL,
+ /* 19 . */ ACP_CONTROL,
+ /* 1a . */ ACP_CONTROL,
+ /* 1b . */ ACP_CONTROL,
+ /* 1c . */ ACP_CONTROL,
+ /* 1d . */ ACP_CONTROL,
+ /* 1e . */ ACP_CONTROL,
+ /* 1f . */ ACP_CONTROL,
+ /* 20 */ ACP_SPACE | ACP_PRINT,
+ /* 21 ! */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 22 " */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 23 # */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 24 $ */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 25 % */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 26 & */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 27 ' */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 28 ( */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 29 ) */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 2a * */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 2b + */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 2c , */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 2d - */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 2e . */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 2f / */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 30 0 */ ACP_DIGIT | ACP_HEXDIGIT | ACP_GRAPH | ACP_PRINT,
+ /* 31 1 */ ACP_DIGIT | ACP_HEXDIGIT | ACP_GRAPH | ACP_PRINT,
+ /* 32 2 */ ACP_DIGIT | ACP_HEXDIGIT | ACP_GRAPH | ACP_PRINT,
+ /* 33 3 */ ACP_DIGIT | ACP_HEXDIGIT | ACP_GRAPH | ACP_PRINT,
+ /* 34 4 */ ACP_DIGIT | ACP_HEXDIGIT | ACP_GRAPH | ACP_PRINT,
+ /* 35 5 */ ACP_DIGIT | ACP_HEXDIGIT | ACP_GRAPH | ACP_PRINT,
+ /* 36 6 */ ACP_DIGIT | ACP_HEXDIGIT | ACP_GRAPH | ACP_PRINT,
+ /* 37 7 */ ACP_DIGIT | ACP_HEXDIGIT | ACP_GRAPH | ACP_PRINT,
+ /* 38 8 */ ACP_DIGIT | ACP_HEXDIGIT | ACP_GRAPH | ACP_PRINT,
+ /* 39 9 */ ACP_DIGIT | ACP_HEXDIGIT | ACP_GRAPH | ACP_PRINT,
+ /* 3a : */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 3b ; */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 3c < */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 3d = */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 3e > */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 3f ? */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 40 @ */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 41 A */ ACP_HEXDIGIT | ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 42 B */ ACP_HEXDIGIT | ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 43 C */ ACP_HEXDIGIT | ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 44 D */ ACP_HEXDIGIT | ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 45 E */ ACP_HEXDIGIT | ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 46 F */ ACP_HEXDIGIT | ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 47 G */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 48 H */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 49 I */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 4a J */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 4b K */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 4c L */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 4d M */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 4e N */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 4f O */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 50 P */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 51 Q */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 52 R */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 53 S */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 54 T */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 55 U */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 56 V */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 57 W */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 58 X */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 59 Y */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 5a Z */ ACP_ALPHA | ACP_UPPER | ACP_GRAPH | ACP_PRINT,
+ /* 5b [ */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 5c \ */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 5d ] */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 5e ^ */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 5f _ */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 60 ` */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 61 a */ ACP_HEXDIGIT | ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 62 b */ ACP_HEXDIGIT | ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 63 c */ ACP_HEXDIGIT | ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 64 d */ ACP_HEXDIGIT | ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 65 e */ ACP_HEXDIGIT | ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 66 f */ ACP_HEXDIGIT | ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 67 g */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 68 h */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 69 i */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 6a j */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 6b k */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 6c l */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 6d m */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 6e n */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 6f o */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 70 p */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 71 q */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 72 r */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 73 s */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 74 t */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 75 u */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 76 v */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 77 w */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 78 x */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 79 y */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 7a z */ ACP_ALPHA | ACP_LOWER | ACP_GRAPH | ACP_PRINT,
+ /* 7b { */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 7c | */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 7d } */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 7e ~ */ ACP_PUNCT | ACP_GRAPH | ACP_PRINT,
+ /* 7f . */ ACP_CONTROL
+};
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/AsyncChannel.cpp b/contrib/libs/poco/Foundation/src/AsyncChannel.cpp
index adfadf4d09..43f6e1eabe 100644
--- a/contrib/libs/poco/Foundation/src/AsyncChannel.cpp
+++ b/contrib/libs/poco/Foundation/src/AsyncChannel.cpp
@@ -1,168 +1,168 @@
-//
-// AsyncChannel.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: AsyncChannel
-//
-// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/AsyncChannel.h"
-#include "Poco/Notification.h"
-#include "Poco/Message.h"
-#include "Poco/Formatter.h"
-#include "Poco/AutoPtr.h"
-#include "Poco/LoggingRegistry.h"
-#include "Poco/Exception.h"
-
-
-namespace Poco {
-
-
-class MessageNotification: public Notification
-{
-public:
- MessageNotification(const Message& msg):
- _msg(msg)
- {
- }
-
- ~MessageNotification()
- {
- }
-
- const Message& message() const
- {
- return _msg;
- }
-
-private:
- Message _msg;
-};
-
-
-AsyncChannel::AsyncChannel(Channel* pChannel, Thread::Priority prio):
- _pChannel(pChannel),
- _thread("AsyncChannel")
-{
- if (_pChannel) _pChannel->duplicate();
- _thread.setPriority(prio);
-}
-
-
-AsyncChannel::~AsyncChannel()
-{
- try
- {
- close();
- if (_pChannel) _pChannel->release();
- }
- catch (...)
- {
- poco_unexpected();
- }
-}
-
-
-void AsyncChannel::setChannel(Channel* pChannel)
-{
- FastMutex::ScopedLock lock(_channelMutex);
-
- if (_pChannel) _pChannel->release();
- _pChannel = pChannel;
- if (_pChannel) _pChannel->duplicate();
-}
-
-
-Channel* AsyncChannel::getChannel() const
-{
- return _pChannel;
-}
-
-
-void AsyncChannel::open()
-{
- FastMutex::ScopedLock lock(_threadMutex);
-
- if (!_thread.isRunning())
- _thread.start(*this);
-}
-
-
-void AsyncChannel::close()
-{
- if (_thread.isRunning())
- {
- while (!_queue.empty()) Thread::sleep(100);
-
- do
- {
- _queue.wakeUpAll();
- }
- while (!_thread.tryJoin(100));
- }
-}
-
-
-void AsyncChannel::log(const Message& msg)
-{
- open();
-
- _queue.enqueueNotification(new MessageNotification(msg));
-}
-
-
-void AsyncChannel::setProperty(const std::string& name, const std::string& value)
-{
- if (name == "channel")
- setChannel(LoggingRegistry::defaultRegistry().channelForName(value));
- else if (name == "priority")
- setPriority(value);
- else
- Channel::setProperty(name, value);
-}
-
-
-void AsyncChannel::run()
-{
- AutoPtr<Notification> nf = _queue.waitDequeueNotification();
- while (nf)
- {
- MessageNotification* pNf = dynamic_cast<MessageNotification*>(nf.get());
- {
- FastMutex::ScopedLock lock(_channelMutex);
-
- if (pNf && _pChannel) _pChannel->log(pNf->message());
- }
- nf = _queue.waitDequeueNotification();
- }
-}
-
-
-void AsyncChannel::setPriority(const std::string& value)
-{
- Thread::Priority prio = Thread::PRIO_NORMAL;
-
- if (value == "lowest")
- prio = Thread::PRIO_LOWEST;
- else if (value == "low")
- prio = Thread::PRIO_LOW;
- else if (value == "normal")
- prio = Thread::PRIO_NORMAL;
- else if (value == "high")
- prio = Thread::PRIO_HIGH;
- else if (value == "highest")
- prio = Thread::PRIO_HIGHEST;
- else
- throw InvalidArgumentException("thread priority", value);
-
- _thread.setPriority(prio);
-}
-
-
-} // namespace Poco
+//
+// AsyncChannel.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: AsyncChannel
+//
+// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/AsyncChannel.h"
+#include "Poco/Notification.h"
+#include "Poco/Message.h"
+#include "Poco/Formatter.h"
+#include "Poco/AutoPtr.h"
+#include "Poco/LoggingRegistry.h"
+#include "Poco/Exception.h"
+
+
+namespace Poco {
+
+
+class MessageNotification: public Notification
+{
+public:
+ MessageNotification(const Message& msg):
+ _msg(msg)
+ {
+ }
+
+ ~MessageNotification()
+ {
+ }
+
+ const Message& message() const
+ {
+ return _msg;
+ }
+
+private:
+ Message _msg;
+};
+
+
+AsyncChannel::AsyncChannel(Channel* pChannel, Thread::Priority prio):
+ _pChannel(pChannel),
+ _thread("AsyncChannel")
+{
+ if (_pChannel) _pChannel->duplicate();
+ _thread.setPriority(prio);
+}
+
+
+AsyncChannel::~AsyncChannel()
+{
+ try
+ {
+ close();
+ if (_pChannel) _pChannel->release();
+ }
+ catch (...)
+ {
+ poco_unexpected();
+ }
+}
+
+
+void AsyncChannel::setChannel(Channel* pChannel)
+{
+ FastMutex::ScopedLock lock(_channelMutex);
+
+ if (_pChannel) _pChannel->release();
+ _pChannel = pChannel;
+ if (_pChannel) _pChannel->duplicate();
+}
+
+
+Channel* AsyncChannel::getChannel() const
+{
+ return _pChannel;
+}
+
+
+void AsyncChannel::open()
+{
+ FastMutex::ScopedLock lock(_threadMutex);
+
+ if (!_thread.isRunning())
+ _thread.start(*this);
+}
+
+
+void AsyncChannel::close()
+{
+ if (_thread.isRunning())
+ {
+ while (!_queue.empty()) Thread::sleep(100);
+
+ do
+ {
+ _queue.wakeUpAll();
+ }
+ while (!_thread.tryJoin(100));
+ }
+}
+
+
+void AsyncChannel::log(const Message& msg)
+{
+ open();
+
+ _queue.enqueueNotification(new MessageNotification(msg));
+}
+
+
+void AsyncChannel::setProperty(const std::string& name, const std::string& value)
+{
+ if (name == "channel")
+ setChannel(LoggingRegistry::defaultRegistry().channelForName(value));
+ else if (name == "priority")
+ setPriority(value);
+ else
+ Channel::setProperty(name, value);
+}
+
+
+void AsyncChannel::run()
+{
+ AutoPtr<Notification> nf = _queue.waitDequeueNotification();
+ while (nf)
+ {
+ MessageNotification* pNf = dynamic_cast<MessageNotification*>(nf.get());
+ {
+ FastMutex::ScopedLock lock(_channelMutex);
+
+ if (pNf && _pChannel) _pChannel->log(pNf->message());
+ }
+ nf = _queue.waitDequeueNotification();
+ }
+}
+
+
+void AsyncChannel::setPriority(const std::string& value)
+{
+ Thread::Priority prio = Thread::PRIO_NORMAL;
+
+ if (value == "lowest")
+ prio = Thread::PRIO_LOWEST;
+ else if (value == "low")
+ prio = Thread::PRIO_LOW;
+ else if (value == "normal")
+ prio = Thread::PRIO_NORMAL;
+ else if (value == "high")
+ prio = Thread::PRIO_HIGH;
+ else if (value == "highest")
+ prio = Thread::PRIO_HIGHEST;
+ else
+ throw InvalidArgumentException("thread priority", value);
+
+ _thread.setPriority(prio);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/AtomicCounter.cpp b/contrib/libs/poco/Foundation/src/AtomicCounter.cpp
index 72d503caca..d4890d9d38 100644
--- a/contrib/libs/poco/Foundation/src/AtomicCounter.cpp
+++ b/contrib/libs/poco/Foundation/src/AtomicCounter.cpp
@@ -1,231 +1,231 @@
-//
-// AtomicCounter.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: AtomicCounter
-//
-// Copyright (c) 2009, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/AtomicCounter.h"
-
-
-namespace Poco {
-
-
-#if defined(POCO_HAVE_STD_ATOMICS)
-//
-// C++11 atomics
-//
-AtomicCounter::AtomicCounter():
- _counter(0)
-{
-}
-
-
-AtomicCounter::AtomicCounter(AtomicCounter::ValueType initialValue):
- _counter(initialValue)
-{
-}
-
-
-AtomicCounter::AtomicCounter(const AtomicCounter& counter):
- _counter(counter.value())
-{
-}
-
-
-AtomicCounter::~AtomicCounter()
-{
-}
-
-
-AtomicCounter& AtomicCounter::operator = (const AtomicCounter& counter)
-{
- _counter.store(counter._counter.load());
- return *this;
-}
-
-
-AtomicCounter& AtomicCounter::operator = (AtomicCounter::ValueType value)
-{
- _counter.store(value);
- return *this;
-}
-
-
-#elif POCO_OS == POCO_OS_WINDOWS_NT
-//
-// Windows
-//
-AtomicCounter::AtomicCounter():
- _counter(0)
-{
-}
-
-
-AtomicCounter::AtomicCounter(AtomicCounter::ValueType initialValue):
- _counter(initialValue)
-{
-}
-
-
-AtomicCounter::AtomicCounter(const AtomicCounter& counter):
- _counter(counter.value())
-{
-}
-
-
-AtomicCounter::~AtomicCounter()
-{
-}
-
-
-AtomicCounter& AtomicCounter::operator = (const AtomicCounter& counter)
-{
- InterlockedExchange(&_counter, counter.value());
- return *this;
-}
-
-
-AtomicCounter& AtomicCounter::operator = (AtomicCounter::ValueType value)
-{
- InterlockedExchange(&_counter, value);
- return *this;
-}
-
-
-#elif POCO_OS == POCO_OS_MAC_OS_X
-//
-// Mac OS X
-//
-AtomicCounter::AtomicCounter():
- _counter(0)
-{
-}
-
-
-AtomicCounter::AtomicCounter(AtomicCounter::ValueType initialValue):
- _counter(initialValue)
-{
-}
-
-
-AtomicCounter::AtomicCounter(const AtomicCounter& counter):
- _counter(counter.value())
-{
-}
-
-
-AtomicCounter::~AtomicCounter()
-{
-}
-
-
-AtomicCounter& AtomicCounter::operator = (const AtomicCounter& counter)
-{
- _counter = counter.value();
- return *this;
-}
-
-
-AtomicCounter& AtomicCounter::operator = (AtomicCounter::ValueType value)
-{
- _counter = value;
- return *this;
-}
-
-
-#elif defined(POCO_HAVE_GCC_ATOMICS)
-//
-// GCC 4.1+ atomic builtins.
-//
-AtomicCounter::AtomicCounter():
- _counter(0)
-{
-}
-
-
-AtomicCounter::AtomicCounter(AtomicCounter::ValueType initialValue):
- _counter(initialValue)
-{
-}
-
-
-AtomicCounter::AtomicCounter(const AtomicCounter& counter):
- _counter(counter.value())
-{
-}
-
-
-AtomicCounter::~AtomicCounter()
-{
-}
-
-
-AtomicCounter& AtomicCounter::operator = (const AtomicCounter& counter)
-{
- __sync_lock_test_and_set(&_counter, counter.value());
- return *this;
-}
-
-
-AtomicCounter& AtomicCounter::operator = (AtomicCounter::ValueType valueType)
-{
- __sync_lock_test_and_set(&_counter, valueType);
- return *this;
-}
-
-
-#else
-//
-// Generic implementation based on FastMutex
-//
-AtomicCounter::AtomicCounter()
-{
- _counter.value = 0;
-}
-
-
-AtomicCounter::AtomicCounter(AtomicCounter::ValueType initialValue)
-{
- _counter.value = initialValue;
-}
-
-
-AtomicCounter::AtomicCounter(const AtomicCounter& counter)
-{
- _counter.value = counter.value();
-}
-
-
-AtomicCounter::~AtomicCounter()
-{
-}
-
-
-AtomicCounter& AtomicCounter::operator = (const AtomicCounter& counter)
-{
- FastMutex::ScopedLock lock(_counter.mutex);
- _counter.value = counter.value();
- return *this;
-}
-
-
-AtomicCounter& AtomicCounter::operator = (AtomicCounter::ValueType value)
-{
- FastMutex::ScopedLock lock(_counter.mutex);
- _counter.value = value;
- return *this;
-}
-
-
-#endif // POCO_OS
-
-
-} // namespace Poco
+//
+// AtomicCounter.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: AtomicCounter
+//
+// Copyright (c) 2009, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/AtomicCounter.h"
+
+
+namespace Poco {
+
+
+#if defined(POCO_HAVE_STD_ATOMICS)
+//
+// C++11 atomics
+//
+AtomicCounter::AtomicCounter():
+ _counter(0)
+{
+}
+
+
+AtomicCounter::AtomicCounter(AtomicCounter::ValueType initialValue):
+ _counter(initialValue)
+{
+}
+
+
+AtomicCounter::AtomicCounter(const AtomicCounter& counter):
+ _counter(counter.value())
+{
+}
+
+
+AtomicCounter::~AtomicCounter()
+{
+}
+
+
+AtomicCounter& AtomicCounter::operator = (const AtomicCounter& counter)
+{
+ _counter.store(counter._counter.load());
+ return *this;
+}
+
+
+AtomicCounter& AtomicCounter::operator = (AtomicCounter::ValueType value)
+{
+ _counter.store(value);
+ return *this;
+}
+
+
+#elif POCO_OS == POCO_OS_WINDOWS_NT
+//
+// Windows
+//
+AtomicCounter::AtomicCounter():
+ _counter(0)
+{
+}
+
+
+AtomicCounter::AtomicCounter(AtomicCounter::ValueType initialValue):
+ _counter(initialValue)
+{
+}
+
+
+AtomicCounter::AtomicCounter(const AtomicCounter& counter):
+ _counter(counter.value())
+{
+}
+
+
+AtomicCounter::~AtomicCounter()
+{
+}
+
+
+AtomicCounter& AtomicCounter::operator = (const AtomicCounter& counter)
+{
+ InterlockedExchange(&_counter, counter.value());
+ return *this;
+}
+
+
+AtomicCounter& AtomicCounter::operator = (AtomicCounter::ValueType value)
+{
+ InterlockedExchange(&_counter, value);
+ return *this;
+}
+
+
+#elif POCO_OS == POCO_OS_MAC_OS_X
+//
+// Mac OS X
+//
+AtomicCounter::AtomicCounter():
+ _counter(0)
+{
+}
+
+
+AtomicCounter::AtomicCounter(AtomicCounter::ValueType initialValue):
+ _counter(initialValue)
+{
+}
+
+
+AtomicCounter::AtomicCounter(const AtomicCounter& counter):
+ _counter(counter.value())
+{
+}
+
+
+AtomicCounter::~AtomicCounter()
+{
+}
+
+
+AtomicCounter& AtomicCounter::operator = (const AtomicCounter& counter)
+{
+ _counter = counter.value();
+ return *this;
+}
+
+
+AtomicCounter& AtomicCounter::operator = (AtomicCounter::ValueType value)
+{
+ _counter = value;
+ return *this;
+}
+
+
+#elif defined(POCO_HAVE_GCC_ATOMICS)
+//
+// GCC 4.1+ atomic builtins.
+//
+AtomicCounter::AtomicCounter():
+ _counter(0)
+{
+}
+
+
+AtomicCounter::AtomicCounter(AtomicCounter::ValueType initialValue):
+ _counter(initialValue)
+{
+}
+
+
+AtomicCounter::AtomicCounter(const AtomicCounter& counter):
+ _counter(counter.value())
+{
+}
+
+
+AtomicCounter::~AtomicCounter()
+{
+}
+
+
+AtomicCounter& AtomicCounter::operator = (const AtomicCounter& counter)
+{
+ __sync_lock_test_and_set(&_counter, counter.value());
+ return *this;
+}
+
+
+AtomicCounter& AtomicCounter::operator = (AtomicCounter::ValueType valueType)
+{
+ __sync_lock_test_and_set(&_counter, valueType);
+ return *this;
+}
+
+
+#else
+//
+// Generic implementation based on FastMutex
+//
+AtomicCounter::AtomicCounter()
+{
+ _counter.value = 0;
+}
+
+
+AtomicCounter::AtomicCounter(AtomicCounter::ValueType initialValue)
+{
+ _counter.value = initialValue;
+}
+
+
+AtomicCounter::AtomicCounter(const AtomicCounter& counter)
+{
+ _counter.value = counter.value();
+}
+
+
+AtomicCounter::~AtomicCounter()
+{
+}
+
+
+AtomicCounter& AtomicCounter::operator = (const AtomicCounter& counter)
+{
+ FastMutex::ScopedLock lock(_counter.mutex);
+ _counter.value = counter.value();
+ return *this;
+}
+
+
+AtomicCounter& AtomicCounter::operator = (AtomicCounter::ValueType value)
+{
+ FastMutex::ScopedLock lock(_counter.mutex);
+ _counter.value = value;
+ return *this;
+}
+
+
+#endif // POCO_OS
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Base32Decoder.cpp b/contrib/libs/poco/Foundation/src/Base32Decoder.cpp
index 8e5cf0e040..7bd7ccd4a6 100644
--- a/contrib/libs/poco/Foundation/src/Base32Decoder.cpp
+++ b/contrib/libs/poco/Foundation/src/Base32Decoder.cpp
@@ -1,160 +1,160 @@
-//
-// Base32Decoder.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: Base32
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Base32Decoder.h"
-#include "Poco/Base32Encoder.h"
-#include "Poco/Exception.h"
-#include "Poco/Mutex.h"
-#include <cstring>
-
-
-namespace Poco {
-
-
-unsigned char Base32DecoderBuf::IN_ENCODING[256];
-bool Base32DecoderBuf::IN_ENCODING_INIT = false;
-
-
-namespace
-{
- static FastMutex mutex;
-}
-
-
-Base32DecoderBuf::Base32DecoderBuf(std::istream& istr):
- _groupLength(0),
- _groupIndex(0),
- _buf(*istr.rdbuf())
-{
- FastMutex::ScopedLock lock(mutex);
- if (!IN_ENCODING_INIT)
- {
- for (unsigned i = 0; i < sizeof(IN_ENCODING); i++)
- {
- IN_ENCODING[i] = 0xFF;
- }
- for (unsigned i = 0; i < sizeof(Base32EncoderBuf::OUT_ENCODING); i++)
- {
- IN_ENCODING[Base32EncoderBuf::OUT_ENCODING[i]] = static_cast<UInt8>(i);
- }
- IN_ENCODING[static_cast<unsigned char>('=')] = '\0';
- IN_ENCODING_INIT = true;
- }
-}
-
-
-Base32DecoderBuf::~Base32DecoderBuf()
-{
-}
-
-
-int Base32DecoderBuf::readFromDevice()
-{
- if (_groupIndex < _groupLength)
- {
- return _group[_groupIndex++];
- }
- else
- {
- unsigned char buffer[8];
- std::memset(buffer, '=', sizeof(buffer));
- int c;
-
- // per RFC-4648, Section 6, permissible block lengths are:
- // 2, 4, 5, 7, and 8 bytes. Any other length is malformed.
- //
- do {
- if ((c = readOne()) == -1) return -1;
- buffer[0] = (unsigned char) c;
- if (IN_ENCODING[buffer[0]] == 0xFF) throw DataFormatException();
- if ((c = readOne()) == -1) throw DataFormatException();
- buffer[1] = (unsigned char) c;
- if (IN_ENCODING[buffer[1]] == 0xFF) throw DataFormatException();
- if ((c = readOne()) == -1) break;
- buffer[2] = (unsigned char) c;
- if (IN_ENCODING[buffer[2]] == 0xFF) throw DataFormatException();
- if ((c = readOne()) == -1) throw DataFormatException();
- buffer[3] = (unsigned char) c;
- if (IN_ENCODING[buffer[3]] == 0xFF) throw DataFormatException();
- if ((c = readOne()) == -1) break;
- buffer[4] = (unsigned char) c;
- if (IN_ENCODING[buffer[4]] == 0xFF) throw DataFormatException();
- if ((c = readOne()) == -1) break;
- buffer[5] = (unsigned char) c;
- if (IN_ENCODING[buffer[5]] == 0xFF) throw DataFormatException();
- if ((c = readOne()) == -1) throw DataFormatException();
- buffer[6] = (unsigned char) c;
- if (IN_ENCODING[buffer[6]] == 0xFF) throw DataFormatException();
- if ((c = readOne()) == -1) break;
- buffer[7] = (unsigned char) c;
- if (IN_ENCODING[buffer[7]] == 0xFF) throw DataFormatException();
- } while (false);
-
- _group[0] = (IN_ENCODING[buffer[0]] << 3) | (IN_ENCODING[buffer[1]] >> 2);
- _group[1] = ((IN_ENCODING[buffer[1]] & 0x03) << 6) | (IN_ENCODING[buffer[2]] << 1) | (IN_ENCODING[buffer[3]] >> 4);
- _group[2] = ((IN_ENCODING[buffer[3]] & 0x0F) << 4) | (IN_ENCODING[buffer[4]] >> 1);
- _group[3] = ((IN_ENCODING[buffer[4]] & 0x01) << 7) | (IN_ENCODING[buffer[5]] << 2) | (IN_ENCODING[buffer[6]] >> 3);
- _group[4] = ((IN_ENCODING[buffer[6]] & 0x07) << 5) | IN_ENCODING[buffer[7]];
-
- if (buffer[2] == '=')
- _groupLength = 1;
- else if (buffer[4] == '=')
- _groupLength = 2;
- else if (buffer[5] == '=')
- _groupLength = 3;
- else if (buffer[7] == '=')
- _groupLength = 4;
- else
- _groupLength = 5;
- _groupIndex = 1;
- return _group[0];
- }
-}
-
-
-int Base32DecoderBuf::readOne()
-{
- int ch = _buf.sbumpc();
- return ch;
-}
-
-
-Base32DecoderIOS::Base32DecoderIOS(std::istream& istr): _buf(istr)
-{
- poco_ios_init(&_buf);
-}
-
-
-Base32DecoderIOS::~Base32DecoderIOS()
-{
-}
-
-
-Base32DecoderBuf* Base32DecoderIOS::rdbuf()
-{
- return &_buf;
-}
-
-
-Base32Decoder::Base32Decoder(std::istream& istr): Base32DecoderIOS(istr), std::istream(&_buf)
-{
-}
-
-
-Base32Decoder::~Base32Decoder()
-{
-}
-
-
-} // namespace Poco
+//
+// Base32Decoder.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: Base32
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Base32Decoder.h"
+#include "Poco/Base32Encoder.h"
+#include "Poco/Exception.h"
+#include "Poco/Mutex.h"
+#include <cstring>
+
+
+namespace Poco {
+
+
+unsigned char Base32DecoderBuf::IN_ENCODING[256];
+bool Base32DecoderBuf::IN_ENCODING_INIT = false;
+
+
+namespace
+{
+ static FastMutex mutex;
+}
+
+
+Base32DecoderBuf::Base32DecoderBuf(std::istream& istr):
+ _groupLength(0),
+ _groupIndex(0),
+ _buf(*istr.rdbuf())
+{
+ FastMutex::ScopedLock lock(mutex);
+ if (!IN_ENCODING_INIT)
+ {
+ for (unsigned i = 0; i < sizeof(IN_ENCODING); i++)
+ {
+ IN_ENCODING[i] = 0xFF;
+ }
+ for (unsigned i = 0; i < sizeof(Base32EncoderBuf::OUT_ENCODING); i++)
+ {
+ IN_ENCODING[Base32EncoderBuf::OUT_ENCODING[i]] = static_cast<UInt8>(i);
+ }
+ IN_ENCODING[static_cast<unsigned char>('=')] = '\0';
+ IN_ENCODING_INIT = true;
+ }
+}
+
+
+Base32DecoderBuf::~Base32DecoderBuf()
+{
+}
+
+
+int Base32DecoderBuf::readFromDevice()
+{
+ if (_groupIndex < _groupLength)
+ {
+ return _group[_groupIndex++];
+ }
+ else
+ {
+ unsigned char buffer[8];
+ std::memset(buffer, '=', sizeof(buffer));
+ int c;
+
+ // per RFC-4648, Section 6, permissible block lengths are:
+ // 2, 4, 5, 7, and 8 bytes. Any other length is malformed.
+ //
+ do {
+ if ((c = readOne()) == -1) return -1;
+ buffer[0] = (unsigned char) c;
+ if (IN_ENCODING[buffer[0]] == 0xFF) throw DataFormatException();
+ if ((c = readOne()) == -1) throw DataFormatException();
+ buffer[1] = (unsigned char) c;
+ if (IN_ENCODING[buffer[1]] == 0xFF) throw DataFormatException();
+ if ((c = readOne()) == -1) break;
+ buffer[2] = (unsigned char) c;
+ if (IN_ENCODING[buffer[2]] == 0xFF) throw DataFormatException();
+ if ((c = readOne()) == -1) throw DataFormatException();
+ buffer[3] = (unsigned char) c;
+ if (IN_ENCODING[buffer[3]] == 0xFF) throw DataFormatException();
+ if ((c = readOne()) == -1) break;
+ buffer[4] = (unsigned char) c;
+ if (IN_ENCODING[buffer[4]] == 0xFF) throw DataFormatException();
+ if ((c = readOne()) == -1) break;
+ buffer[5] = (unsigned char) c;
+ if (IN_ENCODING[buffer[5]] == 0xFF) throw DataFormatException();
+ if ((c = readOne()) == -1) throw DataFormatException();
+ buffer[6] = (unsigned char) c;
+ if (IN_ENCODING[buffer[6]] == 0xFF) throw DataFormatException();
+ if ((c = readOne()) == -1) break;
+ buffer[7] = (unsigned char) c;
+ if (IN_ENCODING[buffer[7]] == 0xFF) throw DataFormatException();
+ } while (false);
+
+ _group[0] = (IN_ENCODING[buffer[0]] << 3) | (IN_ENCODING[buffer[1]] >> 2);
+ _group[1] = ((IN_ENCODING[buffer[1]] & 0x03) << 6) | (IN_ENCODING[buffer[2]] << 1) | (IN_ENCODING[buffer[3]] >> 4);
+ _group[2] = ((IN_ENCODING[buffer[3]] & 0x0F) << 4) | (IN_ENCODING[buffer[4]] >> 1);
+ _group[3] = ((IN_ENCODING[buffer[4]] & 0x01) << 7) | (IN_ENCODING[buffer[5]] << 2) | (IN_ENCODING[buffer[6]] >> 3);
+ _group[4] = ((IN_ENCODING[buffer[6]] & 0x07) << 5) | IN_ENCODING[buffer[7]];
+
+ if (buffer[2] == '=')
+ _groupLength = 1;
+ else if (buffer[4] == '=')
+ _groupLength = 2;
+ else if (buffer[5] == '=')
+ _groupLength = 3;
+ else if (buffer[7] == '=')
+ _groupLength = 4;
+ else
+ _groupLength = 5;
+ _groupIndex = 1;
+ return _group[0];
+ }
+}
+
+
+int Base32DecoderBuf::readOne()
+{
+ int ch = _buf.sbumpc();
+ return ch;
+}
+
+
+Base32DecoderIOS::Base32DecoderIOS(std::istream& istr): _buf(istr)
+{
+ poco_ios_init(&_buf);
+}
+
+
+Base32DecoderIOS::~Base32DecoderIOS()
+{
+}
+
+
+Base32DecoderBuf* Base32DecoderIOS::rdbuf()
+{
+ return &_buf;
+}
+
+
+Base32Decoder::Base32Decoder(std::istream& istr): Base32DecoderIOS(istr), std::istream(&_buf)
+{
+}
+
+
+Base32Decoder::~Base32Decoder()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Base32Encoder.cpp b/contrib/libs/poco/Foundation/src/Base32Encoder.cpp
index dbac2c977f..22a30fcafe 100644
--- a/contrib/libs/poco/Foundation/src/Base32Encoder.cpp
+++ b/contrib/libs/poco/Foundation/src/Base32Encoder.cpp
@@ -1,202 +1,202 @@
-//
-// Base32Encoder.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: Base32
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Base32Encoder.h"
-
-
-namespace Poco {
-
-
-const unsigned char Base32EncoderBuf::OUT_ENCODING[32] =
-{
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
- 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
- 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
- 'Y', 'Z', '2', '3', '4', '5', '6', '7',
-};
-
-
-Base32EncoderBuf::Base32EncoderBuf(std::ostream& ostr, bool padding):
- _groupLength(0),
- _buf(*ostr.rdbuf()),
- _doPadding(padding)
-{
-}
-
-
-Base32EncoderBuf::~Base32EncoderBuf()
-{
- try
- {
- close();
- }
- catch (...)
- {
- }
-}
-
-
-
-int Base32EncoderBuf::writeToDevice(char c)
-{
- static const int eof = std::char_traits<char>::eof();
-
- _group[_groupLength++] = (unsigned char) c;
- if (_groupLength == 5)
- {
- unsigned char idx;
- idx = _group[0] >> 3;
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- idx = ((_group[0] & 0x07) << 2) | (_group[1] >> 6);
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- idx = ((_group[1] & 0x3E) >> 1);
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- idx = ((_group[1] & 0x01) << 4) | (_group[2] >> 4);
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- idx = ((_group[2] & 0x0F) << 1) | (_group[3] >> 7);
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- idx = ((_group[3] & 0x7C) >> 2);
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- idx = ((_group[3] & 0x03) << 3) | (_group[4] >> 5);
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- idx = (_group[4] & 0x1F);
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- _groupLength = 0;
- }
- return charToInt(c);
-}
-
-
-int Base32EncoderBuf::close()
-{
- static const int eof = std::char_traits<char>::eof();
-
- if (sync() == eof) return eof;
- if (_groupLength == 1)
- {
- _group[1] = 0;
- unsigned char idx;
- idx = _group[0] >> 3;
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- idx = ((_group[0] & 0x07) << 2);
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- if (_doPadding) {
- if (_buf.sputc('=') == eof) return eof;
- if (_buf.sputc('=') == eof) return eof;
- if (_buf.sputc('=') == eof) return eof;
- if (_buf.sputc('=') == eof) return eof;
- if (_buf.sputc('=') == eof) return eof;
- if (_buf.sputc('=') == eof) return eof;
- }
- }
- else if (_groupLength == 2)
- {
- _group[2] = 0;
- unsigned char idx;
- idx = _group[0] >> 3;
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- idx = ((_group[0] & 0x07) << 2) | (_group[1] >> 6);
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- idx = ((_group[1] & 0x3E) >> 1);
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- idx = ((_group[1] & 0x01) << 4);
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- if (_doPadding) {
- if (_buf.sputc('=') == eof) return eof;
- if (_buf.sputc('=') == eof) return eof;
- if (_buf.sputc('=') == eof) return eof;
- if (_buf.sputc('=') == eof) return eof;
- }
- }
- else if (_groupLength == 3)
- {
- _group[3] = 0;
- unsigned char idx;
- idx = _group[0] >> 3;
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- idx = ((_group[0] & 0x07) << 2) | (_group[1] >> 6);
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- idx = ((_group[1] & 0x3E) >> 1);
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- idx = ((_group[1] & 0x01) << 4) | (_group[2] >> 4);
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- idx = ((_group[2] & 0x0F) << 1);
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- if (_doPadding) {
- if (_buf.sputc('=') == eof) return eof;
- if (_buf.sputc('=') == eof) return eof;
- if (_buf.sputc('=') == eof) return eof;
- }
- }
- else if (_groupLength == 4)
- {
- _group[4] = 0;
- unsigned char idx;
- idx = _group[0] >> 3;
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- idx = ((_group[0] & 0x07) << 2) | (_group[1] >> 6);
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- idx = ((_group[1] & 0x3E) >> 1);
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- idx = ((_group[1] & 0x01) << 4) | (_group[2] >> 4);
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- idx = ((_group[2] & 0x0F) << 1) | (_group[3] >> 7);
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- idx = ((_group[3] & 0x7C) >> 2);
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- idx = ((_group[3] & 0x03) << 3);
- if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
- if (_doPadding && _buf.sputc('=') == eof) return eof;
- }
- _groupLength = 0;
- return _buf.pubsync();
-}
-
-
-Base32EncoderIOS::Base32EncoderIOS(std::ostream& ostr, bool padding):
- _buf(ostr, padding)
-{
- poco_ios_init(&_buf);
-}
-
-
-Base32EncoderIOS::~Base32EncoderIOS()
-{
-}
-
-
-int Base32EncoderIOS::close()
-{
- return _buf.close();
-}
-
-
-Base32EncoderBuf* Base32EncoderIOS::rdbuf()
-{
- return &_buf;
-}
-
-
-Base32Encoder::Base32Encoder(std::ostream& ostr, bool padding):
- Base32EncoderIOS(ostr, padding), std::ostream(&_buf)
-{
-}
-
-
-Base32Encoder::~Base32Encoder()
-{
-}
-
-
-} // namespace Poco
+//
+// Base32Encoder.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: Base32
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Base32Encoder.h"
+
+
+namespace Poco {
+
+
+const unsigned char Base32EncoderBuf::OUT_ENCODING[32] =
+{
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
+ 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
+ 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
+ 'Y', 'Z', '2', '3', '4', '5', '6', '7',
+};
+
+
+Base32EncoderBuf::Base32EncoderBuf(std::ostream& ostr, bool padding):
+ _groupLength(0),
+ _buf(*ostr.rdbuf()),
+ _doPadding(padding)
+{
+}
+
+
+Base32EncoderBuf::~Base32EncoderBuf()
+{
+ try
+ {
+ close();
+ }
+ catch (...)
+ {
+ }
+}
+
+
+
+int Base32EncoderBuf::writeToDevice(char c)
+{
+ static const int eof = std::char_traits<char>::eof();
+
+ _group[_groupLength++] = (unsigned char) c;
+ if (_groupLength == 5)
+ {
+ unsigned char idx;
+ idx = _group[0] >> 3;
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ idx = ((_group[0] & 0x07) << 2) | (_group[1] >> 6);
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ idx = ((_group[1] & 0x3E) >> 1);
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ idx = ((_group[1] & 0x01) << 4) | (_group[2] >> 4);
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ idx = ((_group[2] & 0x0F) << 1) | (_group[3] >> 7);
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ idx = ((_group[3] & 0x7C) >> 2);
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ idx = ((_group[3] & 0x03) << 3) | (_group[4] >> 5);
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ idx = (_group[4] & 0x1F);
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ _groupLength = 0;
+ }
+ return charToInt(c);
+}
+
+
+int Base32EncoderBuf::close()
+{
+ static const int eof = std::char_traits<char>::eof();
+
+ if (sync() == eof) return eof;
+ if (_groupLength == 1)
+ {
+ _group[1] = 0;
+ unsigned char idx;
+ idx = _group[0] >> 3;
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ idx = ((_group[0] & 0x07) << 2);
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ if (_doPadding) {
+ if (_buf.sputc('=') == eof) return eof;
+ if (_buf.sputc('=') == eof) return eof;
+ if (_buf.sputc('=') == eof) return eof;
+ if (_buf.sputc('=') == eof) return eof;
+ if (_buf.sputc('=') == eof) return eof;
+ if (_buf.sputc('=') == eof) return eof;
+ }
+ }
+ else if (_groupLength == 2)
+ {
+ _group[2] = 0;
+ unsigned char idx;
+ idx = _group[0] >> 3;
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ idx = ((_group[0] & 0x07) << 2) | (_group[1] >> 6);
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ idx = ((_group[1] & 0x3E) >> 1);
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ idx = ((_group[1] & 0x01) << 4);
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ if (_doPadding) {
+ if (_buf.sputc('=') == eof) return eof;
+ if (_buf.sputc('=') == eof) return eof;
+ if (_buf.sputc('=') == eof) return eof;
+ if (_buf.sputc('=') == eof) return eof;
+ }
+ }
+ else if (_groupLength == 3)
+ {
+ _group[3] = 0;
+ unsigned char idx;
+ idx = _group[0] >> 3;
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ idx = ((_group[0] & 0x07) << 2) | (_group[1] >> 6);
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ idx = ((_group[1] & 0x3E) >> 1);
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ idx = ((_group[1] & 0x01) << 4) | (_group[2] >> 4);
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ idx = ((_group[2] & 0x0F) << 1);
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ if (_doPadding) {
+ if (_buf.sputc('=') == eof) return eof;
+ if (_buf.sputc('=') == eof) return eof;
+ if (_buf.sputc('=') == eof) return eof;
+ }
+ }
+ else if (_groupLength == 4)
+ {
+ _group[4] = 0;
+ unsigned char idx;
+ idx = _group[0] >> 3;
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ idx = ((_group[0] & 0x07) << 2) | (_group[1] >> 6);
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ idx = ((_group[1] & 0x3E) >> 1);
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ idx = ((_group[1] & 0x01) << 4) | (_group[2] >> 4);
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ idx = ((_group[2] & 0x0F) << 1) | (_group[3] >> 7);
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ idx = ((_group[3] & 0x7C) >> 2);
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ idx = ((_group[3] & 0x03) << 3);
+ if (_buf.sputc(OUT_ENCODING[idx]) == eof) return eof;
+ if (_doPadding && _buf.sputc('=') == eof) return eof;
+ }
+ _groupLength = 0;
+ return _buf.pubsync();
+}
+
+
+Base32EncoderIOS::Base32EncoderIOS(std::ostream& ostr, bool padding):
+ _buf(ostr, padding)
+{
+ poco_ios_init(&_buf);
+}
+
+
+Base32EncoderIOS::~Base32EncoderIOS()
+{
+}
+
+
+int Base32EncoderIOS::close()
+{
+ return _buf.close();
+}
+
+
+Base32EncoderBuf* Base32EncoderIOS::rdbuf()
+{
+ return &_buf;
+}
+
+
+Base32Encoder::Base32Encoder(std::ostream& ostr, bool padding):
+ Base32EncoderIOS(ostr, padding), std::ostream(&_buf)
+{
+}
+
+
+Base32Encoder::~Base32Encoder()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Base64Decoder.cpp b/contrib/libs/poco/Foundation/src/Base64Decoder.cpp
index 6f826d6bf5..747df92d17 100644
--- a/contrib/libs/poco/Foundation/src/Base64Decoder.cpp
+++ b/contrib/libs/poco/Foundation/src/Base64Decoder.cpp
@@ -1,178 +1,178 @@
-//
-// Base64Decoder.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: Base64
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Base64Decoder.h"
-#include "Poco/Base64Encoder.h"
-#include "Poco/Exception.h"
-#include "Poco/Mutex.h"
-
-
-namespace Poco {
-
-
-unsigned char Base64DecoderBuf::IN_ENCODING[256];
-bool Base64DecoderBuf::IN_ENCODING_INIT = false;
-unsigned char Base64DecoderBuf::IN_ENCODING_URL[256];
-bool Base64DecoderBuf::IN_ENCODING_URL_INIT = false;
-
-
-namespace
-{
- static FastMutex mutex;
-}
-
-
-Base64DecoderBuf::Base64DecoderBuf(std::istream& istr, int options):
- _options(options),
- _groupLength(0),
- _groupIndex(0),
- _buf(*istr.rdbuf()),
- _pInEncoding((options & BASE64_URL_ENCODING) ? IN_ENCODING_URL : IN_ENCODING)
-{
- FastMutex::ScopedLock lock(mutex);
- if (options & BASE64_URL_ENCODING)
- {
- if (!IN_ENCODING_URL_INIT)
- {
- for (unsigned i = 0; i < sizeof(IN_ENCODING_URL); i++)
- {
- IN_ENCODING_URL[i] = 0xFF;
- }
- for (unsigned i = 0; i < sizeof(Base64EncoderBuf::OUT_ENCODING_URL); i++)
- {
- IN_ENCODING_URL[Base64EncoderBuf::OUT_ENCODING_URL[i]] = static_cast<UInt8>(i);
- }
- IN_ENCODING_URL[static_cast<unsigned char>('=')] = '\0';
- IN_ENCODING_URL_INIT = true;
- }
- }
- else
- {
- if (!IN_ENCODING_INIT)
- {
- for (unsigned i = 0; i < sizeof(IN_ENCODING); i++)
- {
- IN_ENCODING[i] = 0xFF;
- }
- for (unsigned i = 0; i < sizeof(Base64EncoderBuf::OUT_ENCODING); i++)
- {
- IN_ENCODING[Base64EncoderBuf::OUT_ENCODING[i]] = static_cast<UInt8>(i);
- }
- IN_ENCODING[static_cast<unsigned char>('=')] = '\0';
- IN_ENCODING_INIT = true;
- }
- }
-}
-
-
-Base64DecoderBuf::~Base64DecoderBuf()
-{
-}
-
-
-int Base64DecoderBuf::readFromDevice()
-{
- if (_groupIndex < _groupLength)
- {
- return _group[_groupIndex++];
- }
- else
- {
- unsigned char buffer[4];
- int c;
- if ((c = readOne()) == -1) return -1;
- buffer[0] = static_cast<UInt8>(c);
- if (_pInEncoding[buffer[0]] == 0xFF) throw DataFormatException();
- if ((c = readOne()) == -1) return -1;
- buffer[1] = static_cast<UInt8>(c);
- if (_pInEncoding[buffer[1]] == 0xFF) throw DataFormatException();
- if (_options & BASE64_NO_PADDING)
- {
- if ((c = readOne()) != -1)
- buffer[2] = static_cast<UInt8>(c);
- else
- buffer[2] = '=';
- if (_pInEncoding[buffer[2]] == 0xFF) throw DataFormatException();
- if ((c = readOne()) != -1)
- buffer[3] = static_cast<UInt8>(c);
- else
- buffer[3] = '=';
- if (_pInEncoding[buffer[3]] == 0xFF) throw DataFormatException();
- }
- else
- {
- if ((c = readOne()) == -1) throw DataFormatException();
- buffer[2] = static_cast<UInt8>(c);
- if (_pInEncoding[buffer[2]] == 0xFF) throw DataFormatException();
- if ((c = readOne()) == -1) throw DataFormatException();
- buffer[3] = static_cast<UInt8>(c);
- if (_pInEncoding[buffer[3]] == 0xFF) throw DataFormatException();
- }
-
- _group[0] = (_pInEncoding[buffer[0]] << 2) | (_pInEncoding[buffer[1]] >> 4);
- _group[1] = ((_pInEncoding[buffer[1]] & 0x0F) << 4) | (_pInEncoding[buffer[2]] >> 2);
- _group[2] = (_pInEncoding[buffer[2]] << 6) | _pInEncoding[buffer[3]];
-
- if (buffer[2] == '=')
- _groupLength = 1;
- else if (buffer[3] == '=')
- _groupLength = 2;
- else
- _groupLength = 3;
- _groupIndex = 1;
- return _group[0];
- }
-}
-
-
-int Base64DecoderBuf::readOne()
-{
- int ch = _buf.sbumpc();
- if (!(_options & BASE64_URL_ENCODING))
- {
- while (ch == ' ' || ch == '\r' || ch == '\t' || ch == '\n')
- ch = _buf.sbumpc();
- }
- return ch;
-}
-
-
-Base64DecoderIOS::Base64DecoderIOS(std::istream& istr, int options): _buf(istr, options)
-{
- poco_ios_init(&_buf);
-}
-
-
-Base64DecoderIOS::~Base64DecoderIOS()
-{
-}
-
-
-Base64DecoderBuf* Base64DecoderIOS::rdbuf()
-{
- return &_buf;
-}
-
-
-Base64Decoder::Base64Decoder(std::istream& istr, int options): Base64DecoderIOS(istr, options), std::istream(&_buf)
-{
-}
-
-
-Base64Decoder::~Base64Decoder()
-{
-}
-
-
-} // namespace Poco
+//
+// Base64Decoder.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: Base64
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Base64Decoder.h"
+#include "Poco/Base64Encoder.h"
+#include "Poco/Exception.h"
+#include "Poco/Mutex.h"
+
+
+namespace Poco {
+
+
+unsigned char Base64DecoderBuf::IN_ENCODING[256];
+bool Base64DecoderBuf::IN_ENCODING_INIT = false;
+unsigned char Base64DecoderBuf::IN_ENCODING_URL[256];
+bool Base64DecoderBuf::IN_ENCODING_URL_INIT = false;
+
+
+namespace
+{
+ static FastMutex mutex;
+}
+
+
+Base64DecoderBuf::Base64DecoderBuf(std::istream& istr, int options):
+ _options(options),
+ _groupLength(0),
+ _groupIndex(0),
+ _buf(*istr.rdbuf()),
+ _pInEncoding((options & BASE64_URL_ENCODING) ? IN_ENCODING_URL : IN_ENCODING)
+{
+ FastMutex::ScopedLock lock(mutex);
+ if (options & BASE64_URL_ENCODING)
+ {
+ if (!IN_ENCODING_URL_INIT)
+ {
+ for (unsigned i = 0; i < sizeof(IN_ENCODING_URL); i++)
+ {
+ IN_ENCODING_URL[i] = 0xFF;
+ }
+ for (unsigned i = 0; i < sizeof(Base64EncoderBuf::OUT_ENCODING_URL); i++)
+ {
+ IN_ENCODING_URL[Base64EncoderBuf::OUT_ENCODING_URL[i]] = static_cast<UInt8>(i);
+ }
+ IN_ENCODING_URL[static_cast<unsigned char>('=')] = '\0';
+ IN_ENCODING_URL_INIT = true;
+ }
+ }
+ else
+ {
+ if (!IN_ENCODING_INIT)
+ {
+ for (unsigned i = 0; i < sizeof(IN_ENCODING); i++)
+ {
+ IN_ENCODING[i] = 0xFF;
+ }
+ for (unsigned i = 0; i < sizeof(Base64EncoderBuf::OUT_ENCODING); i++)
+ {
+ IN_ENCODING[Base64EncoderBuf::OUT_ENCODING[i]] = static_cast<UInt8>(i);
+ }
+ IN_ENCODING[static_cast<unsigned char>('=')] = '\0';
+ IN_ENCODING_INIT = true;
+ }
+ }
+}
+
+
+Base64DecoderBuf::~Base64DecoderBuf()
+{
+}
+
+
+int Base64DecoderBuf::readFromDevice()
+{
+ if (_groupIndex < _groupLength)
+ {
+ return _group[_groupIndex++];
+ }
+ else
+ {
+ unsigned char buffer[4];
+ int c;
+ if ((c = readOne()) == -1) return -1;
+ buffer[0] = static_cast<UInt8>(c);
+ if (_pInEncoding[buffer[0]] == 0xFF) throw DataFormatException();
+ if ((c = readOne()) == -1) return -1;
+ buffer[1] = static_cast<UInt8>(c);
+ if (_pInEncoding[buffer[1]] == 0xFF) throw DataFormatException();
+ if (_options & BASE64_NO_PADDING)
+ {
+ if ((c = readOne()) != -1)
+ buffer[2] = static_cast<UInt8>(c);
+ else
+ buffer[2] = '=';
+ if (_pInEncoding[buffer[2]] == 0xFF) throw DataFormatException();
+ if ((c = readOne()) != -1)
+ buffer[3] = static_cast<UInt8>(c);
+ else
+ buffer[3] = '=';
+ if (_pInEncoding[buffer[3]] == 0xFF) throw DataFormatException();
+ }
+ else
+ {
+ if ((c = readOne()) == -1) throw DataFormatException();
+ buffer[2] = static_cast<UInt8>(c);
+ if (_pInEncoding[buffer[2]] == 0xFF) throw DataFormatException();
+ if ((c = readOne()) == -1) throw DataFormatException();
+ buffer[3] = static_cast<UInt8>(c);
+ if (_pInEncoding[buffer[3]] == 0xFF) throw DataFormatException();
+ }
+
+ _group[0] = (_pInEncoding[buffer[0]] << 2) | (_pInEncoding[buffer[1]] >> 4);
+ _group[1] = ((_pInEncoding[buffer[1]] & 0x0F) << 4) | (_pInEncoding[buffer[2]] >> 2);
+ _group[2] = (_pInEncoding[buffer[2]] << 6) | _pInEncoding[buffer[3]];
+
+ if (buffer[2] == '=')
+ _groupLength = 1;
+ else if (buffer[3] == '=')
+ _groupLength = 2;
+ else
+ _groupLength = 3;
+ _groupIndex = 1;
+ return _group[0];
+ }
+}
+
+
+int Base64DecoderBuf::readOne()
+{
+ int ch = _buf.sbumpc();
+ if (!(_options & BASE64_URL_ENCODING))
+ {
+ while (ch == ' ' || ch == '\r' || ch == '\t' || ch == '\n')
+ ch = _buf.sbumpc();
+ }
+ return ch;
+}
+
+
+Base64DecoderIOS::Base64DecoderIOS(std::istream& istr, int options): _buf(istr, options)
+{
+ poco_ios_init(&_buf);
+}
+
+
+Base64DecoderIOS::~Base64DecoderIOS()
+{
+}
+
+
+Base64DecoderBuf* Base64DecoderIOS::rdbuf()
+{
+ return &_buf;
+}
+
+
+Base64Decoder::Base64Decoder(std::istream& istr, int options): Base64DecoderIOS(istr, options), std::istream(&_buf)
+{
+}
+
+
+Base64Decoder::~Base64Decoder()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Base64Encoder.cpp b/contrib/libs/poco/Foundation/src/Base64Encoder.cpp
index 8f76f6cffb..9ad7e9ec46 100644
--- a/contrib/libs/poco/Foundation/src/Base64Encoder.cpp
+++ b/contrib/libs/poco/Foundation/src/Base64Encoder.cpp
@@ -1,183 +1,183 @@
-//
-// Base64Encoder.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: Base64
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Base64Encoder.h"
-
-
-namespace Poco {
-
-
-const unsigned char Base64EncoderBuf::OUT_ENCODING[64] =
-{
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
- 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
- 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
- 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
- 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
- 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
- 'w', 'x', 'y', 'z', '0', '1', '2', '3',
- '4', '5', '6', '7', '8', '9', '+', '/'
-};
-
-
-const unsigned char Base64EncoderBuf::OUT_ENCODING_URL[64] =
-{
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
- 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
- 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
- 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
- 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
- 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
- 'w', 'x', 'y', 'z', '0', '1', '2', '3',
- '4', '5', '6', '7', '8', '9', '-', '_'
-};
-
-
-Base64EncoderBuf::Base64EncoderBuf(std::ostream& ostr, int options):
- _options(options),
- _groupLength(0),
- _pos(0),
- _lineLength((options & BASE64_URL_ENCODING) ? 0 : 72),
- _buf(*ostr.rdbuf()),
- _pOutEncoding((options & BASE64_URL_ENCODING) ? OUT_ENCODING_URL : OUT_ENCODING)
-{
-}
-
-
-Base64EncoderBuf::~Base64EncoderBuf()
-{
- try
- {
- close();
- }
- catch (...)
- {
- }
-}
-
-
-void Base64EncoderBuf::setLineLength(int lineLength)
-{
- _lineLength = lineLength;
-}
-
-
-int Base64EncoderBuf::getLineLength() const
-{
- return _lineLength;
-}
-
-
-int Base64EncoderBuf::writeToDevice(char c)
-{
- static const int eof = std::char_traits<char>::eof();
-
- _group[_groupLength++] = (unsigned char) c;
- if (_groupLength == 3)
- {
- unsigned char idx;
- idx = _group[0] >> 2;
- if (_buf.sputc(_pOutEncoding[idx]) == eof) return eof;
- idx = ((_group[0] & 0x03) << 4) | (_group[1] >> 4);
- if (_buf.sputc(_pOutEncoding[idx]) == eof) return eof;
- idx = ((_group[1] & 0x0F) << 2) | (_group[2] >> 6);
- if (_buf.sputc(_pOutEncoding[idx]) == eof) return eof;
- idx = _group[2] & 0x3F;
- if (_buf.sputc(_pOutEncoding[idx]) == eof) return eof;
- _pos += 4;
- if (_lineLength > 0 && _pos >= _lineLength)
- {
- if (_buf.sputc('\r') == eof) return eof;
- if (_buf.sputc('\n') == eof) return eof;
- _pos = 0;
- }
- _groupLength = 0;
- }
- return charToInt(c);
-}
-
-
-int Base64EncoderBuf::close()
-{
- static const int eof = std::char_traits<char>::eof();
-
- if (sync() == eof) return eof;
- if (_groupLength == 1)
- {
- _group[1] = 0;
- unsigned char idx;
- idx = _group[0] >> 2;
- if (_buf.sputc(_pOutEncoding[idx]) == eof) return eof;
- idx = ((_group[0] & 0x03) << 4) | (_group[1] >> 4);
- if (_buf.sputc(_pOutEncoding[idx]) == eof) return eof;
- if (!(_options & BASE64_NO_PADDING))
- {
- if (_buf.sputc('=') == eof) return eof;
- if (_buf.sputc('=') == eof) return eof;
- }
- }
- else if (_groupLength == 2)
- {
- _group[2] = 0;
- unsigned char idx;
- idx = _group[0] >> 2;
- if (_buf.sputc(_pOutEncoding[idx]) == eof) return eof;
- idx = ((_group[0] & 0x03) << 4) | (_group[1] >> 4);
- if (_buf.sputc(_pOutEncoding[idx]) == eof) return eof;
- idx = ((_group[1] & 0x0F) << 2) | (_group[2] >> 6);
- if (_buf.sputc(_pOutEncoding[idx]) == eof) return eof;
- if (!(_options & BASE64_NO_PADDING))
- {
- if (_buf.sputc('=') == eof) return eof;
- }
- }
- _groupLength = 0;
- return _buf.pubsync();
-}
-
-
-Base64EncoderIOS::Base64EncoderIOS(std::ostream& ostr, int options): _buf(ostr, options)
-{
- poco_ios_init(&_buf);
-}
-
-
-Base64EncoderIOS::~Base64EncoderIOS()
-{
-}
-
-
-int Base64EncoderIOS::close()
-{
- return _buf.close();
-}
-
-
-Base64EncoderBuf* Base64EncoderIOS::rdbuf()
-{
- return &_buf;
-}
-
-
-Base64Encoder::Base64Encoder(std::ostream& ostr, int options): Base64EncoderIOS(ostr, options), std::ostream(&_buf)
-{
-}
-
-
-Base64Encoder::~Base64Encoder()
-{
-}
-
-
-} // namespace Poco
+//
+// Base64Encoder.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: Base64
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Base64Encoder.h"
+
+
+namespace Poco {
+
+
+const unsigned char Base64EncoderBuf::OUT_ENCODING[64] =
+{
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
+ 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
+ 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
+ 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
+ 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
+ 'w', 'x', 'y', 'z', '0', '1', '2', '3',
+ '4', '5', '6', '7', '8', '9', '+', '/'
+};
+
+
+const unsigned char Base64EncoderBuf::OUT_ENCODING_URL[64] =
+{
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
+ 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
+ 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
+ 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
+ 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
+ 'w', 'x', 'y', 'z', '0', '1', '2', '3',
+ '4', '5', '6', '7', '8', '9', '-', '_'
+};
+
+
+Base64EncoderBuf::Base64EncoderBuf(std::ostream& ostr, int options):
+ _options(options),
+ _groupLength(0),
+ _pos(0),
+ _lineLength((options & BASE64_URL_ENCODING) ? 0 : 72),
+ _buf(*ostr.rdbuf()),
+ _pOutEncoding((options & BASE64_URL_ENCODING) ? OUT_ENCODING_URL : OUT_ENCODING)
+{
+}
+
+
+Base64EncoderBuf::~Base64EncoderBuf()
+{
+ try
+ {
+ close();
+ }
+ catch (...)
+ {
+ }
+}
+
+
+void Base64EncoderBuf::setLineLength(int lineLength)
+{
+ _lineLength = lineLength;
+}
+
+
+int Base64EncoderBuf::getLineLength() const
+{
+ return _lineLength;
+}
+
+
+int Base64EncoderBuf::writeToDevice(char c)
+{
+ static const int eof = std::char_traits<char>::eof();
+
+ _group[_groupLength++] = (unsigned char) c;
+ if (_groupLength == 3)
+ {
+ unsigned char idx;
+ idx = _group[0] >> 2;
+ if (_buf.sputc(_pOutEncoding[idx]) == eof) return eof;
+ idx = ((_group[0] & 0x03) << 4) | (_group[1] >> 4);
+ if (_buf.sputc(_pOutEncoding[idx]) == eof) return eof;
+ idx = ((_group[1] & 0x0F) << 2) | (_group[2] >> 6);
+ if (_buf.sputc(_pOutEncoding[idx]) == eof) return eof;
+ idx = _group[2] & 0x3F;
+ if (_buf.sputc(_pOutEncoding[idx]) == eof) return eof;
+ _pos += 4;
+ if (_lineLength > 0 && _pos >= _lineLength)
+ {
+ if (_buf.sputc('\r') == eof) return eof;
+ if (_buf.sputc('\n') == eof) return eof;
+ _pos = 0;
+ }
+ _groupLength = 0;
+ }
+ return charToInt(c);
+}
+
+
+int Base64EncoderBuf::close()
+{
+ static const int eof = std::char_traits<char>::eof();
+
+ if (sync() == eof) return eof;
+ if (_groupLength == 1)
+ {
+ _group[1] = 0;
+ unsigned char idx;
+ idx = _group[0] >> 2;
+ if (_buf.sputc(_pOutEncoding[idx]) == eof) return eof;
+ idx = ((_group[0] & 0x03) << 4) | (_group[1] >> 4);
+ if (_buf.sputc(_pOutEncoding[idx]) == eof) return eof;
+ if (!(_options & BASE64_NO_PADDING))
+ {
+ if (_buf.sputc('=') == eof) return eof;
+ if (_buf.sputc('=') == eof) return eof;
+ }
+ }
+ else if (_groupLength == 2)
+ {
+ _group[2] = 0;
+ unsigned char idx;
+ idx = _group[0] >> 2;
+ if (_buf.sputc(_pOutEncoding[idx]) == eof) return eof;
+ idx = ((_group[0] & 0x03) << 4) | (_group[1] >> 4);
+ if (_buf.sputc(_pOutEncoding[idx]) == eof) return eof;
+ idx = ((_group[1] & 0x0F) << 2) | (_group[2] >> 6);
+ if (_buf.sputc(_pOutEncoding[idx]) == eof) return eof;
+ if (!(_options & BASE64_NO_PADDING))
+ {
+ if (_buf.sputc('=') == eof) return eof;
+ }
+ }
+ _groupLength = 0;
+ return _buf.pubsync();
+}
+
+
+Base64EncoderIOS::Base64EncoderIOS(std::ostream& ostr, int options): _buf(ostr, options)
+{
+ poco_ios_init(&_buf);
+}
+
+
+Base64EncoderIOS::~Base64EncoderIOS()
+{
+}
+
+
+int Base64EncoderIOS::close()
+{
+ return _buf.close();
+}
+
+
+Base64EncoderBuf* Base64EncoderIOS::rdbuf()
+{
+ return &_buf;
+}
+
+
+Base64Encoder::Base64Encoder(std::ostream& ostr, int options): Base64EncoderIOS(ostr, options), std::ostream(&_buf)
+{
+}
+
+
+Base64Encoder::~Base64Encoder()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/BinaryReader.cpp b/contrib/libs/poco/Foundation/src/BinaryReader.cpp
index d635898152..6e93fc1a3e 100644
--- a/contrib/libs/poco/Foundation/src/BinaryReader.cpp
+++ b/contrib/libs/poco/Foundation/src/BinaryReader.cpp
@@ -1,287 +1,287 @@
-//
-// BinaryReader.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: BinaryReaderWriter
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/BinaryReader.h"
-#include "Poco/ByteOrder.h"
-#include "Poco/TextEncoding.h"
-#include "Poco/TextConverter.h"
-#include <algorithm>
-
-
-namespace Poco {
-
-
-BinaryReader::BinaryReader(std::istream& istr, StreamByteOrder order):
- _istr(istr),
- _pTextConverter(0)
-{
-#if defined(POCO_ARCH_BIG_ENDIAN)
- _flipBytes = (order == LITTLE_ENDIAN_BYTE_ORDER);
-#else
- _flipBytes = (order == BIG_ENDIAN_BYTE_ORDER);
-#endif
-}
-
-
-BinaryReader::BinaryReader(std::istream& istr, TextEncoding& encoding, StreamByteOrder order):
- _istr(istr),
- _pTextConverter(new TextConverter(encoding, Poco::TextEncoding::global()))
-{
-#if defined(POCO_ARCH_BIG_ENDIAN)
- _flipBytes = (order == LITTLE_ENDIAN_BYTE_ORDER);
-#else
- _flipBytes = (order == BIG_ENDIAN_BYTE_ORDER);
-#endif
-}
-
-
-BinaryReader::~BinaryReader()
-{
- delete _pTextConverter;
-}
-
-
-BinaryReader& BinaryReader::operator >> (bool& value)
-{
- _istr.read((char*) &value, sizeof(value));
- return *this;
-}
-
-
-BinaryReader& BinaryReader::operator >> (char& value)
-{
- _istr.read((char*) &value, sizeof(value));
- return *this;
-}
-
-
-BinaryReader& BinaryReader::operator >> (unsigned char& value)
-{
- _istr.read((char*) &value, sizeof(value));
- return *this;
-}
-
-
-BinaryReader& BinaryReader::operator >> (signed char& value)
-{
- _istr.read((char*) &value, sizeof(value));
- return *this;
-}
-
-
-BinaryReader& BinaryReader::operator >> (short& value)
-{
- _istr.read((char*) &value, sizeof(value));
- if (_flipBytes) value = ByteOrder::flipBytes(value);
- return *this;
-}
-
-
-BinaryReader& BinaryReader::operator >> (unsigned short& value)
-{
- _istr.read((char*) &value, sizeof(value));
- if (_flipBytes) value = ByteOrder::flipBytes(value);
- return *this;
-}
-
-
-BinaryReader& BinaryReader::operator >> (int& value)
-{
- _istr.read((char*) &value, sizeof(value));
- if (_flipBytes) value = ByteOrder::flipBytes(value);
- return *this;
-}
-
-
-BinaryReader& BinaryReader::operator >> (unsigned int& value)
-{
- _istr.read((char*) &value, sizeof(value));
- if (_flipBytes) value = ByteOrder::flipBytes(value);
- return *this;
-}
-
-
-BinaryReader& BinaryReader::operator >> (long& value)
-{
- _istr.read((char*) &value, sizeof(value));
-#if defined(POCO_LONG_IS_64_BIT)
- if (_flipBytes) value = ByteOrder::flipBytes((Int64) value);
-#else
- if (_flipBytes) value = ByteOrder::flipBytes((Int32) value);
-#endif
- return *this;
-}
-
-
-BinaryReader& BinaryReader::operator >> (unsigned long& value)
-{
- _istr.read((char*) &value, sizeof(value));
-#if defined(POCO_LONG_IS_64_BIT)
- if (_flipBytes) value = ByteOrder::flipBytes((UInt64) value);
-#else
- if (_flipBytes) value = ByteOrder::flipBytes((UInt32) value);
-#endif
- return *this;
-}
-
-
-BinaryReader& BinaryReader::operator >> (float& value)
-{
- if (_flipBytes)
- {
- char* ptr = (char*) &value;
- ptr += sizeof(value);
- for (unsigned i = 0; i < sizeof(value); ++i)
- _istr.read(--ptr, 1);
- }
- else
- {
- _istr.read((char*) &value, sizeof(value));
- }
- return *this;
-}
-
-
-BinaryReader& BinaryReader::operator >> (double& value)
-{
- if (_flipBytes)
- {
- char* ptr = (char*) &value;
- ptr += sizeof(value);
- for (unsigned i = 0; i < sizeof(value); ++i)
- _istr.read(--ptr, 1);
- }
- else
- {
- _istr.read((char*) &value, sizeof(value));
- }
- return *this;
-}
-
-
-#if defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
-
-
-BinaryReader& BinaryReader::operator >> (Int64& value)
-{
- _istr.read((char*) &value, sizeof(value));
- if (_flipBytes) value = ByteOrder::flipBytes(value);
- return *this;
-}
-
-
-BinaryReader& BinaryReader::operator >> (UInt64& value)
-{
- _istr.read((char*) &value, sizeof(value));
- if (_flipBytes) value = ByteOrder::flipBytes(value);
- return *this;
-}
-
-
-#endif
-
-
-BinaryReader& BinaryReader::operator >> (std::string& value)
-{
- UInt32 size = 0;
- read7BitEncoded(size);
- value.clear();
- if (!_istr.good()) return *this;
- value.reserve(size);
- while (size--)
- {
- char c;
- if (!_istr.read(&c, 1).good()) break;
- value += c;
- }
- if (_pTextConverter)
- {
- std::string converted;
- _pTextConverter->convert(value, converted);
- std::swap(value, converted);
- }
- return *this;
-}
-
-
-void BinaryReader::read7BitEncoded(UInt32& value)
-{
- char c;
- value = 0;
- int s = 0;
- do
- {
- c = 0;
- _istr.read(&c, 1);
- UInt32 x = (c & 0x7F);
- x <<= s;
- value += x;
- s += 7;
- }
- while (c & 0x80);
-}
-
-
-#if defined(POCO_HAVE_INT64)
-
-
-void BinaryReader::read7BitEncoded(UInt64& value)
-{
- char c;
- value = 0;
- int s = 0;
- do
- {
- c = 0;
- _istr.read(&c, 1);
- UInt64 x = (c & 0x7F);
- x <<= s;
- value += x;
- s += 7;
- }
- while (c & 0x80);
-}
-
-
-#endif
-
-
-void BinaryReader::readRaw(std::streamsize length, std::string& value)
-{
- value.clear();
- value.reserve(static_cast<std::string::size_type>(length));
- while (length--)
- {
- char c;
- if (!_istr.read(&c, 1).good()) break;
- value += c;
- }
-}
-
-
-void BinaryReader::readRaw(char* buffer, std::streamsize length)
-{
- _istr.read(buffer, length);
-}
-
-
-void BinaryReader::readBOM()
-{
- UInt16 bom;
- _istr.read((char*) &bom, sizeof(bom));
- _flipBytes = bom != 0xFEFF;
-}
-
-
-} // namespace Poco
+//
+// BinaryReader.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: BinaryReaderWriter
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/BinaryReader.h"
+#include "Poco/ByteOrder.h"
+#include "Poco/TextEncoding.h"
+#include "Poco/TextConverter.h"
+#include <algorithm>
+
+
+namespace Poco {
+
+
+BinaryReader::BinaryReader(std::istream& istr, StreamByteOrder order):
+ _istr(istr),
+ _pTextConverter(0)
+{
+#if defined(POCO_ARCH_BIG_ENDIAN)
+ _flipBytes = (order == LITTLE_ENDIAN_BYTE_ORDER);
+#else
+ _flipBytes = (order == BIG_ENDIAN_BYTE_ORDER);
+#endif
+}
+
+
+BinaryReader::BinaryReader(std::istream& istr, TextEncoding& encoding, StreamByteOrder order):
+ _istr(istr),
+ _pTextConverter(new TextConverter(encoding, Poco::TextEncoding::global()))
+{
+#if defined(POCO_ARCH_BIG_ENDIAN)
+ _flipBytes = (order == LITTLE_ENDIAN_BYTE_ORDER);
+#else
+ _flipBytes = (order == BIG_ENDIAN_BYTE_ORDER);
+#endif
+}
+
+
+BinaryReader::~BinaryReader()
+{
+ delete _pTextConverter;
+}
+
+
+BinaryReader& BinaryReader::operator >> (bool& value)
+{
+ _istr.read((char*) &value, sizeof(value));
+ return *this;
+}
+
+
+BinaryReader& BinaryReader::operator >> (char& value)
+{
+ _istr.read((char*) &value, sizeof(value));
+ return *this;
+}
+
+
+BinaryReader& BinaryReader::operator >> (unsigned char& value)
+{
+ _istr.read((char*) &value, sizeof(value));
+ return *this;
+}
+
+
+BinaryReader& BinaryReader::operator >> (signed char& value)
+{
+ _istr.read((char*) &value, sizeof(value));
+ return *this;
+}
+
+
+BinaryReader& BinaryReader::operator >> (short& value)
+{
+ _istr.read((char*) &value, sizeof(value));
+ if (_flipBytes) value = ByteOrder::flipBytes(value);
+ return *this;
+}
+
+
+BinaryReader& BinaryReader::operator >> (unsigned short& value)
+{
+ _istr.read((char*) &value, sizeof(value));
+ if (_flipBytes) value = ByteOrder::flipBytes(value);
+ return *this;
+}
+
+
+BinaryReader& BinaryReader::operator >> (int& value)
+{
+ _istr.read((char*) &value, sizeof(value));
+ if (_flipBytes) value = ByteOrder::flipBytes(value);
+ return *this;
+}
+
+
+BinaryReader& BinaryReader::operator >> (unsigned int& value)
+{
+ _istr.read((char*) &value, sizeof(value));
+ if (_flipBytes) value = ByteOrder::flipBytes(value);
+ return *this;
+}
+
+
+BinaryReader& BinaryReader::operator >> (long& value)
+{
+ _istr.read((char*) &value, sizeof(value));
+#if defined(POCO_LONG_IS_64_BIT)
+ if (_flipBytes) value = ByteOrder::flipBytes((Int64) value);
+#else
+ if (_flipBytes) value = ByteOrder::flipBytes((Int32) value);
+#endif
+ return *this;
+}
+
+
+BinaryReader& BinaryReader::operator >> (unsigned long& value)
+{
+ _istr.read((char*) &value, sizeof(value));
+#if defined(POCO_LONG_IS_64_BIT)
+ if (_flipBytes) value = ByteOrder::flipBytes((UInt64) value);
+#else
+ if (_flipBytes) value = ByteOrder::flipBytes((UInt32) value);
+#endif
+ return *this;
+}
+
+
+BinaryReader& BinaryReader::operator >> (float& value)
+{
+ if (_flipBytes)
+ {
+ char* ptr = (char*) &value;
+ ptr += sizeof(value);
+ for (unsigned i = 0; i < sizeof(value); ++i)
+ _istr.read(--ptr, 1);
+ }
+ else
+ {
+ _istr.read((char*) &value, sizeof(value));
+ }
+ return *this;
+}
+
+
+BinaryReader& BinaryReader::operator >> (double& value)
+{
+ if (_flipBytes)
+ {
+ char* ptr = (char*) &value;
+ ptr += sizeof(value);
+ for (unsigned i = 0; i < sizeof(value); ++i)
+ _istr.read(--ptr, 1);
+ }
+ else
+ {
+ _istr.read((char*) &value, sizeof(value));
+ }
+ return *this;
+}
+
+
+#if defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
+
+
+BinaryReader& BinaryReader::operator >> (Int64& value)
+{
+ _istr.read((char*) &value, sizeof(value));
+ if (_flipBytes) value = ByteOrder::flipBytes(value);
+ return *this;
+}
+
+
+BinaryReader& BinaryReader::operator >> (UInt64& value)
+{
+ _istr.read((char*) &value, sizeof(value));
+ if (_flipBytes) value = ByteOrder::flipBytes(value);
+ return *this;
+}
+
+
+#endif
+
+
+BinaryReader& BinaryReader::operator >> (std::string& value)
+{
+ UInt32 size = 0;
+ read7BitEncoded(size);
+ value.clear();
+ if (!_istr.good()) return *this;
+ value.reserve(size);
+ while (size--)
+ {
+ char c;
+ if (!_istr.read(&c, 1).good()) break;
+ value += c;
+ }
+ if (_pTextConverter)
+ {
+ std::string converted;
+ _pTextConverter->convert(value, converted);
+ std::swap(value, converted);
+ }
+ return *this;
+}
+
+
+void BinaryReader::read7BitEncoded(UInt32& value)
+{
+ char c;
+ value = 0;
+ int s = 0;
+ do
+ {
+ c = 0;
+ _istr.read(&c, 1);
+ UInt32 x = (c & 0x7F);
+ x <<= s;
+ value += x;
+ s += 7;
+ }
+ while (c & 0x80);
+}
+
+
+#if defined(POCO_HAVE_INT64)
+
+
+void BinaryReader::read7BitEncoded(UInt64& value)
+{
+ char c;
+ value = 0;
+ int s = 0;
+ do
+ {
+ c = 0;
+ _istr.read(&c, 1);
+ UInt64 x = (c & 0x7F);
+ x <<= s;
+ value += x;
+ s += 7;
+ }
+ while (c & 0x80);
+}
+
+
+#endif
+
+
+void BinaryReader::readRaw(std::streamsize length, std::string& value)
+{
+ value.clear();
+ value.reserve(static_cast<std::string::size_type>(length));
+ while (length--)
+ {
+ char c;
+ if (!_istr.read(&c, 1).good()) break;
+ value += c;
+ }
+}
+
+
+void BinaryReader::readRaw(char* buffer, std::streamsize length)
+{
+ _istr.read(buffer, length);
+}
+
+
+void BinaryReader::readBOM()
+{
+ UInt16 bom;
+ _istr.read((char*) &bom, sizeof(bom));
+ _flipBytes = bom != 0xFEFF;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/BinaryWriter.cpp b/contrib/libs/poco/Foundation/src/BinaryWriter.cpp
index f70550e396..f8a405455f 100644
--- a/contrib/libs/poco/Foundation/src/BinaryWriter.cpp
+++ b/contrib/libs/poco/Foundation/src/BinaryWriter.cpp
@@ -1,351 +1,351 @@
-//
-// BinaryWriter.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: BinaryReaderWriter
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/BinaryWriter.h"
-#include "Poco/ByteOrder.h"
-#include "Poco/TextEncoding.h"
-#include "Poco/TextConverter.h"
-#include <cstring>
-
-
-namespace Poco {
-
-
-BinaryWriter::BinaryWriter(std::ostream& ostr, StreamByteOrder order):
- _ostr(ostr),
- _pTextConverter(0)
-{
-#if defined(POCO_ARCH_BIG_ENDIAN)
- _flipBytes = (order == LITTLE_ENDIAN_BYTE_ORDER);
-#else
- _flipBytes = (order == BIG_ENDIAN_BYTE_ORDER);
-#endif
-}
-
-
-BinaryWriter::BinaryWriter(std::ostream& ostr, TextEncoding& encoding, StreamByteOrder order):
- _ostr(ostr),
- _pTextConverter(new TextConverter(Poco::TextEncoding::global(), encoding))
-{
-#if defined(POCO_ARCH_BIG_ENDIAN)
- _flipBytes = (order == LITTLE_ENDIAN_BYTE_ORDER);
-#else
- _flipBytes = (order == BIG_ENDIAN_BYTE_ORDER);
-#endif
-}
-
-
-BinaryWriter::~BinaryWriter()
-{
- delete _pTextConverter;
-}
-
-
-BinaryWriter& BinaryWriter::operator << (bool value)
-{
- _ostr.write((const char*) &value, sizeof(value));
- return *this;
-}
-
-
-BinaryWriter& BinaryWriter::operator << (char value)
-{
- _ostr.write((const char*) &value, sizeof(value));
- return *this;
-}
-
-
-BinaryWriter& BinaryWriter::operator << (unsigned char value)
-{
- _ostr.write((const char*) &value, sizeof(value));
- return *this;
-}
-
-
-BinaryWriter& BinaryWriter::operator << (signed char value)
-{
- _ostr.write((const char*) &value, sizeof(value));
- return *this;
-}
-
-
-BinaryWriter& BinaryWriter::operator << (short value)
-{
- if (_flipBytes)
- {
- short fValue = ByteOrder::flipBytes(value);
- _ostr.write((const char*) &fValue, sizeof(fValue));
- }
- else
- {
- _ostr.write((const char*) &value, sizeof(value));
- }
- return *this;
-}
-
-
-BinaryWriter& BinaryWriter::operator << (unsigned short value)
-{
- if (_flipBytes)
- {
- unsigned short fValue = ByteOrder::flipBytes(value);
- _ostr.write((const char*) &fValue, sizeof(fValue));
- }
- else
- {
- _ostr.write((const char*) &value, sizeof(value));
- }
- return *this;
-}
-
-
-BinaryWriter& BinaryWriter::operator << (int value)
-{
- if (_flipBytes)
- {
- int fValue = ByteOrder::flipBytes(value);
- _ostr.write((const char*) &fValue, sizeof(fValue));
- }
- else
- {
- _ostr.write((const char*) &value, sizeof(value));
- }
- return *this;
-}
-
-
-BinaryWriter& BinaryWriter::operator << (unsigned int value)
-{
- if (_flipBytes)
- {
- unsigned int fValue = ByteOrder::flipBytes(value);
- _ostr.write((const char*) &fValue, sizeof(fValue));
- }
- else
- {
- _ostr.write((const char*) &value, sizeof(value));
- }
- return *this;
-}
-
-
-BinaryWriter& BinaryWriter::operator << (long value)
-{
- if (_flipBytes)
- {
-#if defined(POCO_LONG_IS_64_BIT)
- long fValue = ByteOrder::flipBytes((Int64) value);
-#else
- long fValue = ByteOrder::flipBytes((Int32) value);
-#endif
- _ostr.write((const char*) &fValue, sizeof(fValue));
- }
- else
- {
- _ostr.write((const char*) &value, sizeof(value));
- }
- return *this;
-}
-
-
-BinaryWriter& BinaryWriter::operator << (unsigned long value)
-{
- if (_flipBytes)
- {
-#if defined(POCO_LONG_IS_64_BIT)
- long fValue = ByteOrder::flipBytes((UInt64) value);
-#else
- long fValue = ByteOrder::flipBytes((UInt32) value);
-#endif
- _ostr.write((const char*) &fValue, sizeof(fValue));
- }
- else
- {
- _ostr.write((const char*) &value, sizeof(value));
- }
- return *this;
-}
-
-
-BinaryWriter& BinaryWriter::operator << (float value)
-{
- if (_flipBytes)
- {
- const char* ptr = (const char*) &value;
- ptr += sizeof(value);
- for (unsigned i = 0; i < sizeof(value); ++i)
- _ostr.write(--ptr, 1);
- }
- else
- {
- _ostr.write((const char*) &value, sizeof(value));
- }
- return *this;
-}
-
-
-BinaryWriter& BinaryWriter::operator << (double value)
-{
- if (_flipBytes)
- {
- const char* ptr = (const char*) &value;
- ptr += sizeof(value);
- for (unsigned i = 0; i < sizeof(value); ++i)
- _ostr.write(--ptr, 1);
- }
- else
- {
- _ostr.write((const char*) &value, sizeof(value));
- }
- return *this;
-}
-
-
-#if defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
-
-
-BinaryWriter& BinaryWriter::operator << (Int64 value)
-{
- if (_flipBytes)
- {
- Int64 fValue = ByteOrder::flipBytes(value);
- _ostr.write((const char*) &fValue, sizeof(fValue));
- }
- else
- {
- _ostr.write((const char*) &value, sizeof(value));
- }
- return *this;
-}
-
-
-BinaryWriter& BinaryWriter::operator << (UInt64 value)
-{
- if (_flipBytes)
- {
- UInt64 fValue = ByteOrder::flipBytes(value);
- _ostr.write((const char*) &fValue, sizeof(fValue));
- }
- else
- {
- _ostr.write((const char*) &value, sizeof(value));
- }
- return *this;
-}
-
-
-#endif
-
-
-BinaryWriter& BinaryWriter::operator << (const std::string& value)
-{
- if (_pTextConverter)
- {
- std::string converted;
- _pTextConverter->convert(value, converted);
- UInt32 length = (UInt32) converted.size();
- write7BitEncoded(length);
- _ostr.write(converted.data(), length);
- }
- else
- {
- UInt32 length = (UInt32) value.size();
- write7BitEncoded(length);
- _ostr.write(value.data(), length);
- }
- return *this;
-}
-
-
-BinaryWriter& BinaryWriter::operator << (const char* value)
-{
- poco_check_ptr (value);
-
- if (_pTextConverter)
- {
- std::string converted;
- _pTextConverter->convert(value, static_cast<int>(std::strlen(value)), converted);
- UInt32 length = (UInt32) converted.size();
- write7BitEncoded(length);
- _ostr.write(converted.data(), length);
- }
- else
- {
- UInt32 length = static_cast<UInt32>(std::strlen(value));
- write7BitEncoded(length);
- _ostr.write(value, length);
- }
- return *this;
-}
-
-
-void BinaryWriter::write7BitEncoded(UInt32 value)
-{
- do
- {
- unsigned char c = (unsigned char) (value & 0x7F);
- value >>= 7;
- if (value) c |= 0x80;
- _ostr.write((const char*) &c, 1);
- }
- while (value);
-}
-
-
-#if defined(POCO_HAVE_INT64)
-
-
-void BinaryWriter::write7BitEncoded(UInt64 value)
-{
- do
- {
- unsigned char c = (unsigned char) (value & 0x7F);
- value >>= 7;
- if (value) c |= 0x80;
- _ostr.write((const char*) &c, 1);
- }
- while (value);
-}
-
-
-#endif
-
-
-void BinaryWriter::writeRaw(const std::string& rawData)
-{
- _ostr.write(rawData.data(), (std::streamsize) rawData.length());
-}
-
-
-void BinaryWriter::writeRaw(const char* buffer, std::streamsize length)
-{
- _ostr.write(buffer, length);
-}
-
-
-void BinaryWriter::writeBOM()
-{
- UInt16 value = 0xFEFF;
- if (_flipBytes) value = ByteOrder::flipBytes(value);
- _ostr.write((const char*) &value, sizeof(value));
-}
-
-
-void BinaryWriter::flush()
-{
- _ostr.flush();
-}
-
-
-} // namespace Poco
+//
+// BinaryWriter.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: BinaryReaderWriter
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/BinaryWriter.h"
+#include "Poco/ByteOrder.h"
+#include "Poco/TextEncoding.h"
+#include "Poco/TextConverter.h"
+#include <cstring>
+
+
+namespace Poco {
+
+
+BinaryWriter::BinaryWriter(std::ostream& ostr, StreamByteOrder order):
+ _ostr(ostr),
+ _pTextConverter(0)
+{
+#if defined(POCO_ARCH_BIG_ENDIAN)
+ _flipBytes = (order == LITTLE_ENDIAN_BYTE_ORDER);
+#else
+ _flipBytes = (order == BIG_ENDIAN_BYTE_ORDER);
+#endif
+}
+
+
+BinaryWriter::BinaryWriter(std::ostream& ostr, TextEncoding& encoding, StreamByteOrder order):
+ _ostr(ostr),
+ _pTextConverter(new TextConverter(Poco::TextEncoding::global(), encoding))
+{
+#if defined(POCO_ARCH_BIG_ENDIAN)
+ _flipBytes = (order == LITTLE_ENDIAN_BYTE_ORDER);
+#else
+ _flipBytes = (order == BIG_ENDIAN_BYTE_ORDER);
+#endif
+}
+
+
+BinaryWriter::~BinaryWriter()
+{
+ delete _pTextConverter;
+}
+
+
+BinaryWriter& BinaryWriter::operator << (bool value)
+{
+ _ostr.write((const char*) &value, sizeof(value));
+ return *this;
+}
+
+
+BinaryWriter& BinaryWriter::operator << (char value)
+{
+ _ostr.write((const char*) &value, sizeof(value));
+ return *this;
+}
+
+
+BinaryWriter& BinaryWriter::operator << (unsigned char value)
+{
+ _ostr.write((const char*) &value, sizeof(value));
+ return *this;
+}
+
+
+BinaryWriter& BinaryWriter::operator << (signed char value)
+{
+ _ostr.write((const char*) &value, sizeof(value));
+ return *this;
+}
+
+
+BinaryWriter& BinaryWriter::operator << (short value)
+{
+ if (_flipBytes)
+ {
+ short fValue = ByteOrder::flipBytes(value);
+ _ostr.write((const char*) &fValue, sizeof(fValue));
+ }
+ else
+ {
+ _ostr.write((const char*) &value, sizeof(value));
+ }
+ return *this;
+}
+
+
+BinaryWriter& BinaryWriter::operator << (unsigned short value)
+{
+ if (_flipBytes)
+ {
+ unsigned short fValue = ByteOrder::flipBytes(value);
+ _ostr.write((const char*) &fValue, sizeof(fValue));
+ }
+ else
+ {
+ _ostr.write((const char*) &value, sizeof(value));
+ }
+ return *this;
+}
+
+
+BinaryWriter& BinaryWriter::operator << (int value)
+{
+ if (_flipBytes)
+ {
+ int fValue = ByteOrder::flipBytes(value);
+ _ostr.write((const char*) &fValue, sizeof(fValue));
+ }
+ else
+ {
+ _ostr.write((const char*) &value, sizeof(value));
+ }
+ return *this;
+}
+
+
+BinaryWriter& BinaryWriter::operator << (unsigned int value)
+{
+ if (_flipBytes)
+ {
+ unsigned int fValue = ByteOrder::flipBytes(value);
+ _ostr.write((const char*) &fValue, sizeof(fValue));
+ }
+ else
+ {
+ _ostr.write((const char*) &value, sizeof(value));
+ }
+ return *this;
+}
+
+
+BinaryWriter& BinaryWriter::operator << (long value)
+{
+ if (_flipBytes)
+ {
+#if defined(POCO_LONG_IS_64_BIT)
+ long fValue = ByteOrder::flipBytes((Int64) value);
+#else
+ long fValue = ByteOrder::flipBytes((Int32) value);
+#endif
+ _ostr.write((const char*) &fValue, sizeof(fValue));
+ }
+ else
+ {
+ _ostr.write((const char*) &value, sizeof(value));
+ }
+ return *this;
+}
+
+
+BinaryWriter& BinaryWriter::operator << (unsigned long value)
+{
+ if (_flipBytes)
+ {
+#if defined(POCO_LONG_IS_64_BIT)
+ long fValue = ByteOrder::flipBytes((UInt64) value);
+#else
+ long fValue = ByteOrder::flipBytes((UInt32) value);
+#endif
+ _ostr.write((const char*) &fValue, sizeof(fValue));
+ }
+ else
+ {
+ _ostr.write((const char*) &value, sizeof(value));
+ }
+ return *this;
+}
+
+
+BinaryWriter& BinaryWriter::operator << (float value)
+{
+ if (_flipBytes)
+ {
+ const char* ptr = (const char*) &value;
+ ptr += sizeof(value);
+ for (unsigned i = 0; i < sizeof(value); ++i)
+ _ostr.write(--ptr, 1);
+ }
+ else
+ {
+ _ostr.write((const char*) &value, sizeof(value));
+ }
+ return *this;
+}
+
+
+BinaryWriter& BinaryWriter::operator << (double value)
+{
+ if (_flipBytes)
+ {
+ const char* ptr = (const char*) &value;
+ ptr += sizeof(value);
+ for (unsigned i = 0; i < sizeof(value); ++i)
+ _ostr.write(--ptr, 1);
+ }
+ else
+ {
+ _ostr.write((const char*) &value, sizeof(value));
+ }
+ return *this;
+}
+
+
+#if defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
+
+
+BinaryWriter& BinaryWriter::operator << (Int64 value)
+{
+ if (_flipBytes)
+ {
+ Int64 fValue = ByteOrder::flipBytes(value);
+ _ostr.write((const char*) &fValue, sizeof(fValue));
+ }
+ else
+ {
+ _ostr.write((const char*) &value, sizeof(value));
+ }
+ return *this;
+}
+
+
+BinaryWriter& BinaryWriter::operator << (UInt64 value)
+{
+ if (_flipBytes)
+ {
+ UInt64 fValue = ByteOrder::flipBytes(value);
+ _ostr.write((const char*) &fValue, sizeof(fValue));
+ }
+ else
+ {
+ _ostr.write((const char*) &value, sizeof(value));
+ }
+ return *this;
+}
+
+
+#endif
+
+
+BinaryWriter& BinaryWriter::operator << (const std::string& value)
+{
+ if (_pTextConverter)
+ {
+ std::string converted;
+ _pTextConverter->convert(value, converted);
+ UInt32 length = (UInt32) converted.size();
+ write7BitEncoded(length);
+ _ostr.write(converted.data(), length);
+ }
+ else
+ {
+ UInt32 length = (UInt32) value.size();
+ write7BitEncoded(length);
+ _ostr.write(value.data(), length);
+ }
+ return *this;
+}
+
+
+BinaryWriter& BinaryWriter::operator << (const char* value)
+{
+ poco_check_ptr (value);
+
+ if (_pTextConverter)
+ {
+ std::string converted;
+ _pTextConverter->convert(value, static_cast<int>(std::strlen(value)), converted);
+ UInt32 length = (UInt32) converted.size();
+ write7BitEncoded(length);
+ _ostr.write(converted.data(), length);
+ }
+ else
+ {
+ UInt32 length = static_cast<UInt32>(std::strlen(value));
+ write7BitEncoded(length);
+ _ostr.write(value, length);
+ }
+ return *this;
+}
+
+
+void BinaryWriter::write7BitEncoded(UInt32 value)
+{
+ do
+ {
+ unsigned char c = (unsigned char) (value & 0x7F);
+ value >>= 7;
+ if (value) c |= 0x80;
+ _ostr.write((const char*) &c, 1);
+ }
+ while (value);
+}
+
+
+#if defined(POCO_HAVE_INT64)
+
+
+void BinaryWriter::write7BitEncoded(UInt64 value)
+{
+ do
+ {
+ unsigned char c = (unsigned char) (value & 0x7F);
+ value >>= 7;
+ if (value) c |= 0x80;
+ _ostr.write((const char*) &c, 1);
+ }
+ while (value);
+}
+
+
+#endif
+
+
+void BinaryWriter::writeRaw(const std::string& rawData)
+{
+ _ostr.write(rawData.data(), (std::streamsize) rawData.length());
+}
+
+
+void BinaryWriter::writeRaw(const char* buffer, std::streamsize length)
+{
+ _ostr.write(buffer, length);
+}
+
+
+void BinaryWriter::writeBOM()
+{
+ UInt16 value = 0xFEFF;
+ if (_flipBytes) value = ByteOrder::flipBytes(value);
+ _ostr.write((const char*) &value, sizeof(value));
+}
+
+
+void BinaryWriter::flush()
+{
+ _ostr.flush();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Bugcheck.cpp b/contrib/libs/poco/Foundation/src/Bugcheck.cpp
index 14f5170c84..7b8df68c92 100644
--- a/contrib/libs/poco/Foundation/src/Bugcheck.cpp
+++ b/contrib/libs/poco/Foundation/src/Bugcheck.cpp
@@ -1,119 +1,119 @@
-//
-// Bugcheck.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: Bugcheck
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Bugcheck.h"
-#include "Poco/Debugger.h"
-#include "Poco/Exception.h"
-#include <sstream>
-
-
-namespace Poco {
-
-
-void Bugcheck::assertion(const char* cond, const char* file, int line, const char* text)
-{
- std::string message("Assertion violation: ");
- message += cond;
- if (text)
- {
- message += " (";
- message += text;
- message += ")";
- }
- Debugger::enter(message, file, line);
- throw AssertionViolationException(what(cond, file, line, text));
-}
-
-
-void Bugcheck::nullPointer(const char* ptr, const char* file, int line)
-{
- Debugger::enter(std::string("NULL pointer: ") + ptr, file, line);
- throw NullPointerException(what(ptr, file, line));
-}
-
-
-void Bugcheck::bugcheck(const char* file, int line)
-{
- Debugger::enter("Bugcheck", file, line);
- throw BugcheckException(what(0, file, line));
-}
-
-
-void Bugcheck::bugcheck(const char* msg, const char* file, int line)
-{
- std::string m("Bugcheck");
- if (msg)
- {
- m.append(": ");
- m.append(msg);
- }
- Debugger::enter(m, file, line);
- throw BugcheckException(what(msg, file, line));
-}
-
-
-void Bugcheck::unexpected(const char* file, int line)
-{
-#ifdef _DEBUG
- try
- {
- std::string msg("Unexpected exception in noexcept function or destructor: ");
- try
- {
- throw;
- }
- catch (Poco::Exception& exc)
- {
- msg += exc.displayText();
- }
- catch (std::exception& exc)
- {
- msg += exc.what();
- }
- catch (...)
- {
- msg += "unknown exception";
- }
- Debugger::enter(msg, file, line);
- }
- catch (...)
- {
- }
-#endif
-}
-
-
-void Bugcheck::debugger(const char* file, int line)
-{
- Debugger::enter(file, line);
-}
-
-
-void Bugcheck::debugger(const char* msg, const char* file, int line)
-{
- Debugger::enter(msg, file, line);
-}
-
-
-std::string Bugcheck::what(const char* msg, const char* file, int line, const char* text)
-{
- std::ostringstream str;
- if (msg) str << msg << " ";
- if (text != NULL) str << "(" << text << ") ";
- str << "in file \"" << file << "\", line " << line;
- return str.str();
-}
-
-
-} // namespace Poco
+//
+// Bugcheck.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: Bugcheck
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Bugcheck.h"
+#include "Poco/Debugger.h"
+#include "Poco/Exception.h"
+#include <sstream>
+
+
+namespace Poco {
+
+
+void Bugcheck::assertion(const char* cond, const char* file, int line, const char* text)
+{
+ std::string message("Assertion violation: ");
+ message += cond;
+ if (text)
+ {
+ message += " (";
+ message += text;
+ message += ")";
+ }
+ Debugger::enter(message, file, line);
+ throw AssertionViolationException(what(cond, file, line, text));
+}
+
+
+void Bugcheck::nullPointer(const char* ptr, const char* file, int line)
+{
+ Debugger::enter(std::string("NULL pointer: ") + ptr, file, line);
+ throw NullPointerException(what(ptr, file, line));
+}
+
+
+void Bugcheck::bugcheck(const char* file, int line)
+{
+ Debugger::enter("Bugcheck", file, line);
+ throw BugcheckException(what(0, file, line));
+}
+
+
+void Bugcheck::bugcheck(const char* msg, const char* file, int line)
+{
+ std::string m("Bugcheck");
+ if (msg)
+ {
+ m.append(": ");
+ m.append(msg);
+ }
+ Debugger::enter(m, file, line);
+ throw BugcheckException(what(msg, file, line));
+}
+
+
+void Bugcheck::unexpected(const char* file, int line)
+{
+#ifdef _DEBUG
+ try
+ {
+ std::string msg("Unexpected exception in noexcept function or destructor: ");
+ try
+ {
+ throw;
+ }
+ catch (Poco::Exception& exc)
+ {
+ msg += exc.displayText();
+ }
+ catch (std::exception& exc)
+ {
+ msg += exc.what();
+ }
+ catch (...)
+ {
+ msg += "unknown exception";
+ }
+ Debugger::enter(msg, file, line);
+ }
+ catch (...)
+ {
+ }
+#endif
+}
+
+
+void Bugcheck::debugger(const char* file, int line)
+{
+ Debugger::enter(file, line);
+}
+
+
+void Bugcheck::debugger(const char* msg, const char* file, int line)
+{
+ Debugger::enter(msg, file, line);
+}
+
+
+std::string Bugcheck::what(const char* msg, const char* file, int line, const char* text)
+{
+ std::ostringstream str;
+ if (msg) str << msg << " ";
+ if (text != NULL) str << "(" << text << ") ";
+ str << "in file \"" << file << "\", line " << line;
+ return str.str();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/ByteOrder.cpp b/contrib/libs/poco/Foundation/src/ByteOrder.cpp
index dd627bcb6a..6512b9ff44 100644
--- a/contrib/libs/poco/Foundation/src/ByteOrder.cpp
+++ b/contrib/libs/poco/Foundation/src/ByteOrder.cpp
@@ -1,15 +1,15 @@
-//
-// ByteOrder.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: ByteOrder
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/ByteOrder.h"
+//
+// ByteOrder.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: ByteOrder
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/ByteOrder.h"
diff --git a/contrib/libs/poco/Foundation/src/Channel.cpp b/contrib/libs/poco/Foundation/src/Channel.cpp
index aa225b5eb4..9b0b650b21 100644
--- a/contrib/libs/poco/Foundation/src/Channel.cpp
+++ b/contrib/libs/poco/Foundation/src/Channel.cpp
@@ -1,53 +1,53 @@
-//
-// Channel.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: Channel
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Channel.h"
-
-
-namespace Poco {
-
-
-Channel::Channel()
-{
-}
-
-
-Channel::~Channel()
-{
-}
-
-
-void Channel::open()
-{
-}
-
-
-void Channel::close()
-{
-}
-
-
-void Channel::setProperty(const std::string& name, const std::string& /*value*/)
-{
- throw PropertyNotSupportedException(name);
-}
-
-
-std::string Channel::getProperty(const std::string& name) const
-{
- throw PropertyNotSupportedException(name);
-}
-
-
-} // namespace Poco
+//
+// Channel.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: Channel
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Channel.h"
+
+
+namespace Poco {
+
+
+Channel::Channel()
+{
+}
+
+
+Channel::~Channel()
+{
+}
+
+
+void Channel::open()
+{
+}
+
+
+void Channel::close()
+{
+}
+
+
+void Channel::setProperty(const std::string& name, const std::string& /*value*/)
+{
+ throw PropertyNotSupportedException(name);
+}
+
+
+std::string Channel::getProperty(const std::string& name) const
+{
+ throw PropertyNotSupportedException(name);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Checksum.cpp b/contrib/libs/poco/Foundation/src/Checksum.cpp
index a745fcd423..3647e451fe 100644
--- a/contrib/libs/poco/Foundation/src/Checksum.cpp
+++ b/contrib/libs/poco/Foundation/src/Checksum.cpp
@@ -1,58 +1,58 @@
-//
-// Checksum.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: Checksum
-//
-// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Checksum.h"
-#if defined(POCO_UNBUNDLED)
-#include <zlib.h>
-#else
-#error #include "Poco/zlib.h"
-#endif
-
-
-namespace Poco {
-
-
-Checksum::Checksum():
- _type(TYPE_CRC32),
- _value(crc32(0L, Z_NULL, 0))
-{
-}
-
-
-Checksum::Checksum(Type t):
- _type(t),
- _value(0)
-{
- if (t == TYPE_CRC32)
- _value = crc32(0L, Z_NULL, 0);
- else
- _value = adler32(0L, Z_NULL, 0);
-}
-
-
-Checksum::~Checksum()
-{
-}
-
-
-void Checksum::update(const char* data, unsigned length)
-{
- if (_type == TYPE_ADLER32)
- _value = adler32(_value, reinterpret_cast<const Bytef*>(data), length);
- else
- _value = crc32(_value, reinterpret_cast<const Bytef*>(data), length);
-}
-
-
-} // namespace Poco
+//
+// Checksum.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: Checksum
+//
+// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Checksum.h"
+#if defined(POCO_UNBUNDLED)
+#include <zlib.h>
+#else
+#error #include "Poco/zlib.h"
+#endif
+
+
+namespace Poco {
+
+
+Checksum::Checksum():
+ _type(TYPE_CRC32),
+ _value(crc32(0L, Z_NULL, 0))
+{
+}
+
+
+Checksum::Checksum(Type t):
+ _type(t),
+ _value(0)
+{
+ if (t == TYPE_CRC32)
+ _value = crc32(0L, Z_NULL, 0);
+ else
+ _value = adler32(0L, Z_NULL, 0);
+}
+
+
+Checksum::~Checksum()
+{
+}
+
+
+void Checksum::update(const char* data, unsigned length)
+{
+ if (_type == TYPE_ADLER32)
+ _value = adler32(_value, reinterpret_cast<const Bytef*>(data), length);
+ else
+ _value = crc32(_value, reinterpret_cast<const Bytef*>(data), length);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Clock.cpp b/contrib/libs/poco/Foundation/src/Clock.cpp
index e52cd5db45..c59bc6d466 100644
--- a/contrib/libs/poco/Foundation/src/Clock.cpp
+++ b/contrib/libs/poco/Foundation/src/Clock.cpp
@@ -1,231 +1,231 @@
-//
-// Clock.cpp
-//
-// Library: Foundation
-// Package: DateTime
-// Module: Clock
-//
-// Copyright (c) 2013, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Clock.h"
-#include "Poco/Exception.h"
-#include "Poco/Timestamp.h"
-#if defined(__MACH__)
-#include <mach/mach.h>
-#include <mach/clock.h>
-#elif defined(POCO_OS_FAMILY_UNIX)
-#include <time.h>
-#include <unistd.h>
-#elif defined(POCO_VXWORKS)
-#include <timers.h>
-#elif defined(POCO_OS_FAMILY_WINDOWS)
-#include "Poco/UnWindows.h"
-#endif
-#include <algorithm>
-#undef min
-#undef max
-#include <limits>
-
-
-#ifndef POCO_HAVE_CLOCK_GETTIME
- #if (defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME)) || defined(POCO_VXWORKS) || defined(__QNX__)
- #ifndef __APPLE__ // See GitHub issue #1453 - not available before Mac OS 10.12/iOS 10
- #define POCO_HAVE_CLOCK_GETTIME
- #endif
- #endif
-#endif
-
-
-namespace Poco {
-
-
-const Clock::ClockVal Clock::CLOCKVAL_MIN = std::numeric_limits<Clock::ClockVal>::min();
-const Clock::ClockVal Clock::CLOCKVAL_MAX = std::numeric_limits<Clock::ClockVal>::max();
-
-
-Clock::Clock()
-{
- update();
-}
-
-
-Clock::Clock(ClockVal tv)
-{
- _clock = tv;
-}
-
-
-Clock::Clock(const Clock& other)
-{
- _clock = other._clock;
-}
-
-
-Clock::~Clock()
-{
-}
-
-
-Clock& Clock::operator = (const Clock& other)
-{
- _clock = other._clock;
- return *this;
-}
-
-
-Clock& Clock::operator = (ClockVal tv)
-{
- _clock = tv;
- return *this;
-}
-
-
-void Clock::swap(Clock& timestamp)
-{
- std::swap(_clock, timestamp._clock);
-}
-
-
-void Clock::update()
-{
-#if defined(POCO_OS_FAMILY_WINDOWS)
-
- LARGE_INTEGER perfCounter;
- LARGE_INTEGER perfFreq;
- if (QueryPerformanceCounter(&perfCounter) && QueryPerformanceFrequency(&perfFreq))
- {
- _clock = resolution()*(perfCounter.QuadPart/perfFreq.QuadPart);
- _clock += (perfCounter.QuadPart % perfFreq.QuadPart)*resolution()/perfFreq.QuadPart;
- }
- else throw Poco::SystemException("cannot get system clock");
-
-#elif defined(__MACH__)
-
- clock_serv_t cs;
- mach_timespec_t ts;
-
- 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)
-
- struct timespec ts;
-#if defined(CLOCK_MONOTONIC) // should be in VxWorks 6.x
- if (clock_gettime(CLOCK_MONOTONIC, &ts))
- throw SystemException("cannot get system clock");
-#else
- if (clock_gettime(CLOCK_REALTIME, &ts))
- throw SystemException("cannot get system clock");
-#endif
- _clock = ClockVal(ts.tv_sec)*resolution() + ts.tv_nsec/1000;
-
-#elif defined(POCO_HAVE_CLOCK_GETTIME)
-
- struct timespec ts;
- if (clock_gettime(CLOCK_MONOTONIC, &ts))
- throw SystemException("cannot get system clock");
- _clock = ClockVal(ts.tv_sec)*resolution() + ts.tv_nsec/1000;
-
-#else
-
- Poco::Timestamp now;
- _clock = now.epochMicroseconds();
-
-#endif
-}
-
-
-Clock::ClockDiff Clock::accuracy()
-{
-#if defined(POCO_OS_FAMILY_WINDOWS)
-
- LARGE_INTEGER perfFreq;
- if (QueryPerformanceFrequency(&perfFreq) && perfFreq.QuadPart > 0)
- {
- ClockVal acc = resolution()/perfFreq.QuadPart;
- return acc > 0 ? acc : 1;
- }
- else throw Poco::SystemException("cannot get system clock accuracy");
-
-#elif defined(__MACH__)
-
- clock_serv_t cs;
- int nanosecs;
- mach_msg_type_number_t n = 1;
-
- 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;
-
-#elif defined(POCO_VXWORKS)
-
- struct timespec ts;
-#if defined(CLOCK_MONOTONIC) // should be in VxWorks 6.x
- if (clock_getres(CLOCK_MONOTONIC, &ts))
- throw SystemException("cannot get system clock");
-#else
- if (clock_getres(CLOCK_REALTIME, &ts))
- throw SystemException("cannot get system clock");
-#endif
- ClockVal acc = ClockVal(ts.tv_sec)*resolution() + ts.tv_nsec/1000;
- return acc > 0 ? acc : 1;
-
-#elif defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
-
- 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)
-
- return true;
-
-#elif defined(__MACH__)
-
- return true;
-
-#elif defined(POCO_VXWORKS)
-
-#if defined(CLOCK_MONOTONIC) // should be in VxWorks 6.x
- return true;
-#else
- return false;
-#endif
-
-#elif defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
-
- return true;
-
-#else
-
- return false;
-
-#endif
-}
-
-
-} // namespace Poco
+//
+// Clock.cpp
+//
+// Library: Foundation
+// Package: DateTime
+// Module: Clock
+//
+// Copyright (c) 2013, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Clock.h"
+#include "Poco/Exception.h"
+#include "Poco/Timestamp.h"
+#if defined(__MACH__)
+#include <mach/mach.h>
+#include <mach/clock.h>
+#elif defined(POCO_OS_FAMILY_UNIX)
+#include <time.h>
+#include <unistd.h>
+#elif defined(POCO_VXWORKS)
+#include <timers.h>
+#elif defined(POCO_OS_FAMILY_WINDOWS)
+#include "Poco/UnWindows.h"
+#endif
+#include <algorithm>
+#undef min
+#undef max
+#include <limits>
+
+
+#ifndef POCO_HAVE_CLOCK_GETTIME
+ #if (defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME)) || defined(POCO_VXWORKS) || defined(__QNX__)
+ #ifndef __APPLE__ // See GitHub issue #1453 - not available before Mac OS 10.12/iOS 10
+ #define POCO_HAVE_CLOCK_GETTIME
+ #endif
+ #endif
+#endif
+
+
+namespace Poco {
+
+
+const Clock::ClockVal Clock::CLOCKVAL_MIN = std::numeric_limits<Clock::ClockVal>::min();
+const Clock::ClockVal Clock::CLOCKVAL_MAX = std::numeric_limits<Clock::ClockVal>::max();
+
+
+Clock::Clock()
+{
+ update();
+}
+
+
+Clock::Clock(ClockVal tv)
+{
+ _clock = tv;
+}
+
+
+Clock::Clock(const Clock& other)
+{
+ _clock = other._clock;
+}
+
+
+Clock::~Clock()
+{
+}
+
+
+Clock& Clock::operator = (const Clock& other)
+{
+ _clock = other._clock;
+ return *this;
+}
+
+
+Clock& Clock::operator = (ClockVal tv)
+{
+ _clock = tv;
+ return *this;
+}
+
+
+void Clock::swap(Clock& timestamp)
+{
+ std::swap(_clock, timestamp._clock);
+}
+
+
+void Clock::update()
+{
+#if defined(POCO_OS_FAMILY_WINDOWS)
+
+ LARGE_INTEGER perfCounter;
+ LARGE_INTEGER perfFreq;
+ if (QueryPerformanceCounter(&perfCounter) && QueryPerformanceFrequency(&perfFreq))
+ {
+ _clock = resolution()*(perfCounter.QuadPart/perfFreq.QuadPart);
+ _clock += (perfCounter.QuadPart % perfFreq.QuadPart)*resolution()/perfFreq.QuadPart;
+ }
+ else throw Poco::SystemException("cannot get system clock");
+
+#elif defined(__MACH__)
+
+ clock_serv_t cs;
+ mach_timespec_t ts;
+
+ 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)
+
+ struct timespec ts;
+#if defined(CLOCK_MONOTONIC) // should be in VxWorks 6.x
+ if (clock_gettime(CLOCK_MONOTONIC, &ts))
+ throw SystemException("cannot get system clock");
+#else
+ if (clock_gettime(CLOCK_REALTIME, &ts))
+ throw SystemException("cannot get system clock");
+#endif
+ _clock = ClockVal(ts.tv_sec)*resolution() + ts.tv_nsec/1000;
+
+#elif defined(POCO_HAVE_CLOCK_GETTIME)
+
+ struct timespec ts;
+ if (clock_gettime(CLOCK_MONOTONIC, &ts))
+ throw SystemException("cannot get system clock");
+ _clock = ClockVal(ts.tv_sec)*resolution() + ts.tv_nsec/1000;
+
+#else
+
+ Poco::Timestamp now;
+ _clock = now.epochMicroseconds();
+
+#endif
+}
+
+
+Clock::ClockDiff Clock::accuracy()
+{
+#if defined(POCO_OS_FAMILY_WINDOWS)
+
+ LARGE_INTEGER perfFreq;
+ if (QueryPerformanceFrequency(&perfFreq) && perfFreq.QuadPart > 0)
+ {
+ ClockVal acc = resolution()/perfFreq.QuadPart;
+ return acc > 0 ? acc : 1;
+ }
+ else throw Poco::SystemException("cannot get system clock accuracy");
+
+#elif defined(__MACH__)
+
+ clock_serv_t cs;
+ int nanosecs;
+ mach_msg_type_number_t n = 1;
+
+ 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;
+
+#elif defined(POCO_VXWORKS)
+
+ struct timespec ts;
+#if defined(CLOCK_MONOTONIC) // should be in VxWorks 6.x
+ if (clock_getres(CLOCK_MONOTONIC, &ts))
+ throw SystemException("cannot get system clock");
+#else
+ if (clock_getres(CLOCK_REALTIME, &ts))
+ throw SystemException("cannot get system clock");
+#endif
+ ClockVal acc = ClockVal(ts.tv_sec)*resolution() + ts.tv_nsec/1000;
+ return acc > 0 ? acc : 1;
+
+#elif defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
+
+ 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)
+
+ return true;
+
+#elif defined(__MACH__)
+
+ return true;
+
+#elif defined(POCO_VXWORKS)
+
+#if defined(CLOCK_MONOTONIC) // should be in VxWorks 6.x
+ return true;
+#else
+ return false;
+#endif
+
+#elif defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
+
+ return true;
+
+#else
+
+ return false;
+
+#endif
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Condition.cpp b/contrib/libs/poco/Foundation/src/Condition.cpp
index 0acb9d1bba..aa163c7dcc 100644
--- a/contrib/libs/poco/Foundation/src/Condition.cpp
+++ b/contrib/libs/poco/Foundation/src/Condition.cpp
@@ -1,79 +1,79 @@
-//
-// Condition.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: Condition
-//
-// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Condition.h"
-
-
-namespace Poco {
-
-
-Condition::Condition()
-{
-}
-
-Condition::~Condition()
-{
-}
-
-
-void Condition::signal()
-{
- FastMutex::ScopedLock lock(_mutex);
-
- if (!_waitQueue.empty())
- {
- _waitQueue.front()->set();
- dequeue();
- }
-}
-
-
-void Condition::broadcast()
-{
- FastMutex::ScopedLock lock(_mutex);
-
- for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it)
- {
- (*it)->set();
- }
- _waitQueue.clear();
-}
-
-
-void Condition::enqueue(Event& event)
-{
- _waitQueue.push_back(&event);
-}
-
-
-void Condition::dequeue()
-{
- _waitQueue.pop_front();
-}
-
-
-void Condition::dequeue(Event& event)
-{
- for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it)
- {
- if (*it == &event)
- {
- _waitQueue.erase(it);
- break;
- }
- }
-}
-
-
-} // namespace Poco
+//
+// Condition.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: Condition
+//
+// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Condition.h"
+
+
+namespace Poco {
+
+
+Condition::Condition()
+{
+}
+
+Condition::~Condition()
+{
+}
+
+
+void Condition::signal()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (!_waitQueue.empty())
+ {
+ _waitQueue.front()->set();
+ dequeue();
+ }
+}
+
+
+void Condition::broadcast()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it)
+ {
+ (*it)->set();
+ }
+ _waitQueue.clear();
+}
+
+
+void Condition::enqueue(Event& event)
+{
+ _waitQueue.push_back(&event);
+}
+
+
+void Condition::dequeue()
+{
+ _waitQueue.pop_front();
+}
+
+
+void Condition::dequeue(Event& event)
+{
+ for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it)
+ {
+ if (*it == &event)
+ {
+ _waitQueue.erase(it);
+ break;
+ }
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Configurable.cpp b/contrib/libs/poco/Foundation/src/Configurable.cpp
index 822ecab24a..1945e32c4b 100644
--- a/contrib/libs/poco/Foundation/src/Configurable.cpp
+++ b/contrib/libs/poco/Foundation/src/Configurable.cpp
@@ -1,31 +1,31 @@
-//
-// Configurable.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: Configurable
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Configurable.h"
-
-
-namespace Poco {
-
-
-Configurable::Configurable()
-{
-}
-
-
-Configurable::~Configurable()
-{
-}
-
-
-} // namespace Poco
+//
+// Configurable.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: Configurable
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Configurable.h"
+
+
+namespace Poco {
+
+
+Configurable::Configurable()
+{
+}
+
+
+Configurable::~Configurable()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/ConsoleChannel.cpp b/contrib/libs/poco/Foundation/src/ConsoleChannel.cpp
index 056e3fa4be..b875874a52 100644
--- a/contrib/libs/poco/Foundation/src/ConsoleChannel.cpp
+++ b/contrib/libs/poco/Foundation/src/ConsoleChannel.cpp
@@ -1,281 +1,281 @@
-//
-// ConsoleChannel.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: ConsoleChannel
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/ConsoleChannel.h"
-#include "Poco/Message.h"
-#include "Poco/String.h"
-#include "Poco/Exception.h"
-#include <iostream>
-
-
-namespace Poco {
-
-
-FastMutex ConsoleChannel::_mutex;
-
-
-ConsoleChannel::ConsoleChannel(): _str(std::clog)
-{
-}
-
-
-ConsoleChannel::ConsoleChannel(std::ostream& str): _str(str)
-{
-}
-
-
-ConsoleChannel::~ConsoleChannel()
-{
-}
-
-
-void ConsoleChannel::log(const Message& msg)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- _str << msg.getText() << std::endl;
-}
-
-
-FastMutex ColorConsoleChannel::_mutex;
-const std::string ColorConsoleChannel::CSI("\033[");
-
-
-ColorConsoleChannel::ColorConsoleChannel():
- _str(std::clog),
- _enableColors(true)
-{
- initColors();
-}
-
-
-ColorConsoleChannel::ColorConsoleChannel(std::ostream& str):
- _str(str),
- _enableColors(true)
-{
- initColors();
-}
-
-
-ColorConsoleChannel::~ColorConsoleChannel()
-{
-}
-
-
-void ColorConsoleChannel::log(const Message& msg)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- if (_enableColors)
- {
- int color = _colors[msg.getPriority()];
- if (color & 0x100)
- {
- _str << CSI << "1m";
- }
- color &= 0xff;
- _str << CSI << color << "m";
- }
-
- _str << msg.getText();
-
- if (_enableColors)
- {
- _str << CSI << "0m";
- }
-
- _str << std::endl;
-}
-
-
-void ColorConsoleChannel::setProperty(const std::string& name, const std::string& value)
-{
- if (name == "enableColors")
- {
- _enableColors = icompare(value, "true") == 0;
- }
+//
+// ConsoleChannel.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: ConsoleChannel
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/ConsoleChannel.h"
+#include "Poco/Message.h"
+#include "Poco/String.h"
+#include "Poco/Exception.h"
+#include <iostream>
+
+
+namespace Poco {
+
+
+FastMutex ConsoleChannel::_mutex;
+
+
+ConsoleChannel::ConsoleChannel(): _str(std::clog)
+{
+}
+
+
+ConsoleChannel::ConsoleChannel(std::ostream& str): _str(str)
+{
+}
+
+
+ConsoleChannel::~ConsoleChannel()
+{
+}
+
+
+void ConsoleChannel::log(const Message& msg)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ _str << msg.getText() << std::endl;
+}
+
+
+FastMutex ColorConsoleChannel::_mutex;
+const std::string ColorConsoleChannel::CSI("\033[");
+
+
+ColorConsoleChannel::ColorConsoleChannel():
+ _str(std::clog),
+ _enableColors(true)
+{
+ initColors();
+}
+
+
+ColorConsoleChannel::ColorConsoleChannel(std::ostream& str):
+ _str(str),
+ _enableColors(true)
+{
+ initColors();
+}
+
+
+ColorConsoleChannel::~ColorConsoleChannel()
+{
+}
+
+
+void ColorConsoleChannel::log(const Message& msg)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (_enableColors)
+ {
+ int color = _colors[msg.getPriority()];
+ if (color & 0x100)
+ {
+ _str << CSI << "1m";
+ }
+ color &= 0xff;
+ _str << CSI << color << "m";
+ }
+
+ _str << msg.getText();
+
+ if (_enableColors)
+ {
+ _str << CSI << "0m";
+ }
+
+ _str << std::endl;
+}
+
+
+void ColorConsoleChannel::setProperty(const std::string& name, const std::string& value)
+{
+ if (name == "enableColors")
+ {
+ _enableColors = icompare(value, "true") == 0;
+ }
else if (name == "testColor")
{
_colors[Message::PRIO_TEST] = parseColor(value);
}
- else if (name == "traceColor")
- {
- _colors[Message::PRIO_TRACE] = parseColor(value);
- }
- else if (name == "debugColor")
- {
- _colors[Message::PRIO_DEBUG] = parseColor(value);
- }
- else if (name == "informationColor")
- {
- _colors[Message::PRIO_INFORMATION] = parseColor(value);
- }
- else if (name == "noticeColor")
- {
- _colors[Message::PRIO_NOTICE] = parseColor(value);
- }
- else if (name == "warningColor")
- {
- _colors[Message::PRIO_WARNING] = parseColor(value);
- }
- else if (name == "errorColor")
- {
- _colors[Message::PRIO_ERROR] = parseColor(value);
- }
- else if (name == "criticalColor")
- {
- _colors[Message::PRIO_CRITICAL] = parseColor(value);
- }
- else if (name == "fatalColor")
- {
- _colors[Message::PRIO_FATAL] = parseColor(value);
- }
- else
- {
- Channel::setProperty(name, value);
- }
-}
-
-
-std::string ColorConsoleChannel::getProperty(const std::string& name) const
-{
- if (name == "enableColors")
- {
- return _enableColors ? "true" : "false";
- }
+ else if (name == "traceColor")
+ {
+ _colors[Message::PRIO_TRACE] = parseColor(value);
+ }
+ else if (name == "debugColor")
+ {
+ _colors[Message::PRIO_DEBUG] = parseColor(value);
+ }
+ else if (name == "informationColor")
+ {
+ _colors[Message::PRIO_INFORMATION] = parseColor(value);
+ }
+ else if (name == "noticeColor")
+ {
+ _colors[Message::PRIO_NOTICE] = parseColor(value);
+ }
+ else if (name == "warningColor")
+ {
+ _colors[Message::PRIO_WARNING] = parseColor(value);
+ }
+ else if (name == "errorColor")
+ {
+ _colors[Message::PRIO_ERROR] = parseColor(value);
+ }
+ else if (name == "criticalColor")
+ {
+ _colors[Message::PRIO_CRITICAL] = parseColor(value);
+ }
+ else if (name == "fatalColor")
+ {
+ _colors[Message::PRIO_FATAL] = parseColor(value);
+ }
+ else
+ {
+ Channel::setProperty(name, value);
+ }
+}
+
+
+std::string ColorConsoleChannel::getProperty(const std::string& name) const
+{
+ if (name == "enableColors")
+ {
+ return _enableColors ? "true" : "false";
+ }
else if (name == "testColor")
{
return formatColor(_colors[Message::PRIO_TEST]);
}
- else if (name == "traceColor")
- {
- return formatColor(_colors[Message::PRIO_TRACE]);
- }
- else if (name == "debugColor")
- {
- return formatColor(_colors[Message::PRIO_DEBUG]);
- }
- else if (name == "informationColor")
- {
- return formatColor(_colors[Message::PRIO_INFORMATION]);
- }
- else if (name == "noticeColor")
- {
- return formatColor(_colors[Message::PRIO_NOTICE]);
- }
- else if (name == "warningColor")
- {
- return formatColor(_colors[Message::PRIO_WARNING]);
- }
- else if (name == "errorColor")
- {
- return formatColor(_colors[Message::PRIO_ERROR]);
- }
- else if (name == "criticalColor")
- {
- return formatColor(_colors[Message::PRIO_CRITICAL]);
- }
- else if (name == "fatalColor")
- {
- return formatColor(_colors[Message::PRIO_FATAL]);
- }
- else
- {
- return Channel::getProperty(name);
- }
-}
-
-
-ColorConsoleChannel::Color ColorConsoleChannel::parseColor(const std::string& color) const
-{
- if (icompare(color, "default") == 0)
- return CC_DEFAULT;
- else if (icompare(color, "black") == 0)
- return CC_BLACK;
- else if (icompare(color, "red") == 0)
- return CC_RED;
- else if (icompare(color, "green") == 0)
- return CC_GREEN;
- else if (icompare(color, "brown") == 0)
- return CC_BROWN;
- else if (icompare(color, "blue") == 0)
- return CC_BLUE;
- else if (icompare(color, "magenta") == 0)
- return CC_MAGENTA;
- else if (icompare(color, "cyan") == 0)
- return CC_CYAN;
- else if (icompare(color, "gray") == 0)
- return CC_GRAY;
- else if (icompare(color, "darkGray") == 0)
- return CC_DARKGRAY;
- else if (icompare(color, "lightRed") == 0)
- return CC_LIGHTRED;
- else if (icompare(color, "lightGreen") == 0)
- return CC_LIGHTGREEN;
- else if (icompare(color, "yellow") == 0)
- return CC_YELLOW;
- else if (icompare(color, "lightBlue") == 0)
- return CC_LIGHTBLUE;
- else if (icompare(color, "lightMagenta") == 0)
- return CC_LIGHTMAGENTA;
- else if (icompare(color, "lightCyan") == 0)
- return CC_LIGHTCYAN;
- else if (icompare(color, "white") == 0)
- return CC_WHITE;
- else throw InvalidArgumentException("Invalid color value", color);
-}
-
-
-std::string ColorConsoleChannel::formatColor(Color color) const
-{
- switch (color)
- {
- case CC_DEFAULT: return "default";
- case CC_BLACK: return "black";
- case CC_RED: return "red";
- case CC_GREEN: return "green";
- case CC_BROWN: return "brown";
- case CC_BLUE: return "blue";
- case CC_MAGENTA: return "magenta";
- case CC_CYAN: return "cyan";
- case CC_GRAY: return "gray";
- case CC_DARKGRAY: return "darkGray";
- case CC_LIGHTRED: return "lightRed";
- case CC_LIGHTGREEN: return "lightGreen";
- case CC_YELLOW: return "yellow";
- case CC_LIGHTBLUE: return "lightBlue";
- case CC_LIGHTMAGENTA: return "lightMagenta";
- case CC_LIGHTCYAN: return "lightCyan";
- case CC_WHITE: return "white";
- default: return "invalid";
- }
-}
-
-
-void ColorConsoleChannel::initColors()
-{
- _colors[0] = CC_DEFAULT; // unused
- _colors[Message::PRIO_FATAL] = CC_LIGHTRED;
- _colors[Message::PRIO_CRITICAL] = CC_LIGHTRED;
- _colors[Message::PRIO_ERROR] = CC_LIGHTRED;
- _colors[Message::PRIO_WARNING] = CC_YELLOW;
- _colors[Message::PRIO_NOTICE] = CC_DEFAULT;
- _colors[Message::PRIO_INFORMATION] = CC_DEFAULT;
- _colors[Message::PRIO_DEBUG] = CC_GRAY;
- _colors[Message::PRIO_TRACE] = CC_GRAY;
+ else if (name == "traceColor")
+ {
+ return formatColor(_colors[Message::PRIO_TRACE]);
+ }
+ else if (name == "debugColor")
+ {
+ return formatColor(_colors[Message::PRIO_DEBUG]);
+ }
+ else if (name == "informationColor")
+ {
+ return formatColor(_colors[Message::PRIO_INFORMATION]);
+ }
+ else if (name == "noticeColor")
+ {
+ return formatColor(_colors[Message::PRIO_NOTICE]);
+ }
+ else if (name == "warningColor")
+ {
+ return formatColor(_colors[Message::PRIO_WARNING]);
+ }
+ else if (name == "errorColor")
+ {
+ return formatColor(_colors[Message::PRIO_ERROR]);
+ }
+ else if (name == "criticalColor")
+ {
+ return formatColor(_colors[Message::PRIO_CRITICAL]);
+ }
+ else if (name == "fatalColor")
+ {
+ return formatColor(_colors[Message::PRIO_FATAL]);
+ }
+ else
+ {
+ return Channel::getProperty(name);
+ }
+}
+
+
+ColorConsoleChannel::Color ColorConsoleChannel::parseColor(const std::string& color) const
+{
+ if (icompare(color, "default") == 0)
+ return CC_DEFAULT;
+ else if (icompare(color, "black") == 0)
+ return CC_BLACK;
+ else if (icompare(color, "red") == 0)
+ return CC_RED;
+ else if (icompare(color, "green") == 0)
+ return CC_GREEN;
+ else if (icompare(color, "brown") == 0)
+ return CC_BROWN;
+ else if (icompare(color, "blue") == 0)
+ return CC_BLUE;
+ else if (icompare(color, "magenta") == 0)
+ return CC_MAGENTA;
+ else if (icompare(color, "cyan") == 0)
+ return CC_CYAN;
+ else if (icompare(color, "gray") == 0)
+ return CC_GRAY;
+ else if (icompare(color, "darkGray") == 0)
+ return CC_DARKGRAY;
+ else if (icompare(color, "lightRed") == 0)
+ return CC_LIGHTRED;
+ else if (icompare(color, "lightGreen") == 0)
+ return CC_LIGHTGREEN;
+ else if (icompare(color, "yellow") == 0)
+ return CC_YELLOW;
+ else if (icompare(color, "lightBlue") == 0)
+ return CC_LIGHTBLUE;
+ else if (icompare(color, "lightMagenta") == 0)
+ return CC_LIGHTMAGENTA;
+ else if (icompare(color, "lightCyan") == 0)
+ return CC_LIGHTCYAN;
+ else if (icompare(color, "white") == 0)
+ return CC_WHITE;
+ else throw InvalidArgumentException("Invalid color value", color);
+}
+
+
+std::string ColorConsoleChannel::formatColor(Color color) const
+{
+ switch (color)
+ {
+ case CC_DEFAULT: return "default";
+ case CC_BLACK: return "black";
+ case CC_RED: return "red";
+ case CC_GREEN: return "green";
+ case CC_BROWN: return "brown";
+ case CC_BLUE: return "blue";
+ case CC_MAGENTA: return "magenta";
+ case CC_CYAN: return "cyan";
+ case CC_GRAY: return "gray";
+ case CC_DARKGRAY: return "darkGray";
+ case CC_LIGHTRED: return "lightRed";
+ case CC_LIGHTGREEN: return "lightGreen";
+ case CC_YELLOW: return "yellow";
+ case CC_LIGHTBLUE: return "lightBlue";
+ case CC_LIGHTMAGENTA: return "lightMagenta";
+ case CC_LIGHTCYAN: return "lightCyan";
+ case CC_WHITE: return "white";
+ default: return "invalid";
+ }
+}
+
+
+void ColorConsoleChannel::initColors()
+{
+ _colors[0] = CC_DEFAULT; // unused
+ _colors[Message::PRIO_FATAL] = CC_LIGHTRED;
+ _colors[Message::PRIO_CRITICAL] = CC_LIGHTRED;
+ _colors[Message::PRIO_ERROR] = CC_LIGHTRED;
+ _colors[Message::PRIO_WARNING] = CC_YELLOW;
+ _colors[Message::PRIO_NOTICE] = CC_DEFAULT;
+ _colors[Message::PRIO_INFORMATION] = CC_DEFAULT;
+ _colors[Message::PRIO_DEBUG] = CC_GRAY;
+ _colors[Message::PRIO_TRACE] = CC_GRAY;
_colors[Message::PRIO_TEST] = CC_GRAY;
-}
-
-
-} // namespace Poco
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/CountingStream.cpp b/contrib/libs/poco/Foundation/src/CountingStream.cpp
index b3f56b345b..bce4629656 100644
--- a/contrib/libs/poco/Foundation/src/CountingStream.cpp
+++ b/contrib/libs/poco/Foundation/src/CountingStream.cpp
@@ -1,199 +1,199 @@
-//
-// CountingStream.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: CountingStream
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/CountingStream.h"
-
-
-namespace Poco {
-
-
-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),
- _pos(0)
-{
-}
-
-
-CountingStreamBuf::CountingStreamBuf(std::ostream& ostr):
- _pIstr(0),
- _pOstr(&ostr),
- _chars(0),
- _lines(0),
- _pos(0)
-{
-}
-
-
-CountingStreamBuf::~CountingStreamBuf()
-{
-}
-
-
-int CountingStreamBuf::readFromDevice()
-{
- if (_pIstr)
- {
- int c = _pIstr->get();
- if (c != -1)
- {
- ++_chars;
- if (_pos++ == 0) ++_lines;
- if (c == '\n') _pos = 0;
- }
- return c;
- }
- return -1;
-}
-
-
-int CountingStreamBuf::writeToDevice(char c)
-{
- ++_chars;
- if (_pos++ == 0) ++_lines;
- if (c == '\n') _pos = 0;
- if (_pOstr) _pOstr->put(c);
- return charToInt(c);
-}
-
-
-void CountingStreamBuf::reset()
-{
- _chars = 0;
- _lines = 0;
- _pos = 0;
-}
-
-
-void CountingStreamBuf::setCurrentLineNumber(int line)
-{
- _lines = line;
-}
-
-
-void CountingStreamBuf::addChars(int charsToAdd)
-{
- _chars += charsToAdd;
-}
-
-
-void CountingStreamBuf::addLines(int linesToAdd)
-{
- _lines += linesToAdd;
-}
-
-
-void CountingStreamBuf::addPos(int posToAdd)
-{
- _pos += posToAdd;
-}
-
-
-CountingIOS::CountingIOS()
-{
- poco_ios_init(&_buf);
-}
-
-
-CountingIOS::CountingIOS(std::istream& istr): _buf(istr)
-{
- poco_ios_init(&_buf);
-}
-
-
-CountingIOS::CountingIOS(std::ostream& ostr): _buf(ostr)
-{
- poco_ios_init(&_buf);
-}
-
-
-CountingIOS::~CountingIOS()
-{
-}
-
-
-void CountingIOS::reset()
-{
- _buf.reset();
-}
-
-
-void CountingIOS::setCurrentLineNumber(int line)
-{
- _buf.setCurrentLineNumber(line);
-}
-
-
-void CountingIOS::addChars(int charsToAdd)
-{
- _buf.addChars(charsToAdd);
-}
-
-
-void CountingIOS::addLines(int linesToAdd)
-{
- _buf.addLines(linesToAdd);
-}
-
-
-void CountingIOS::addPos(int posToAdd)
-{
- _buf.addPos(posToAdd);
-}
-
-
-CountingStreamBuf* CountingIOS::rdbuf()
-{
- return &_buf;
-}
-
-
-CountingInputStream::CountingInputStream(std::istream& istr): CountingIOS(istr), std::istream(&_buf)
-{
-}
-
-
-CountingInputStream::~CountingInputStream()
-{
-}
-
-
-CountingOutputStream::CountingOutputStream(): std::ostream(&_buf)
-{
-}
-
-
-CountingOutputStream::CountingOutputStream(std::ostream& ostr): CountingIOS(ostr), std::ostream(&_buf)
-{
-}
-
-
-CountingOutputStream::~CountingOutputStream()
-{
-}
-
-
-} // namespace Poco
+//
+// CountingStream.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: CountingStream
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/CountingStream.h"
+
+
+namespace Poco {
+
+
+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),
+ _pos(0)
+{
+}
+
+
+CountingStreamBuf::CountingStreamBuf(std::ostream& ostr):
+ _pIstr(0),
+ _pOstr(&ostr),
+ _chars(0),
+ _lines(0),
+ _pos(0)
+{
+}
+
+
+CountingStreamBuf::~CountingStreamBuf()
+{
+}
+
+
+int CountingStreamBuf::readFromDevice()
+{
+ if (_pIstr)
+ {
+ int c = _pIstr->get();
+ if (c != -1)
+ {
+ ++_chars;
+ if (_pos++ == 0) ++_lines;
+ if (c == '\n') _pos = 0;
+ }
+ return c;
+ }
+ return -1;
+}
+
+
+int CountingStreamBuf::writeToDevice(char c)
+{
+ ++_chars;
+ if (_pos++ == 0) ++_lines;
+ if (c == '\n') _pos = 0;
+ if (_pOstr) _pOstr->put(c);
+ return charToInt(c);
+}
+
+
+void CountingStreamBuf::reset()
+{
+ _chars = 0;
+ _lines = 0;
+ _pos = 0;
+}
+
+
+void CountingStreamBuf::setCurrentLineNumber(int line)
+{
+ _lines = line;
+}
+
+
+void CountingStreamBuf::addChars(int charsToAdd)
+{
+ _chars += charsToAdd;
+}
+
+
+void CountingStreamBuf::addLines(int linesToAdd)
+{
+ _lines += linesToAdd;
+}
+
+
+void CountingStreamBuf::addPos(int posToAdd)
+{
+ _pos += posToAdd;
+}
+
+
+CountingIOS::CountingIOS()
+{
+ poco_ios_init(&_buf);
+}
+
+
+CountingIOS::CountingIOS(std::istream& istr): _buf(istr)
+{
+ poco_ios_init(&_buf);
+}
+
+
+CountingIOS::CountingIOS(std::ostream& ostr): _buf(ostr)
+{
+ poco_ios_init(&_buf);
+}
+
+
+CountingIOS::~CountingIOS()
+{
+}
+
+
+void CountingIOS::reset()
+{
+ _buf.reset();
+}
+
+
+void CountingIOS::setCurrentLineNumber(int line)
+{
+ _buf.setCurrentLineNumber(line);
+}
+
+
+void CountingIOS::addChars(int charsToAdd)
+{
+ _buf.addChars(charsToAdd);
+}
+
+
+void CountingIOS::addLines(int linesToAdd)
+{
+ _buf.addLines(linesToAdd);
+}
+
+
+void CountingIOS::addPos(int posToAdd)
+{
+ _buf.addPos(posToAdd);
+}
+
+
+CountingStreamBuf* CountingIOS::rdbuf()
+{
+ return &_buf;
+}
+
+
+CountingInputStream::CountingInputStream(std::istream& istr): CountingIOS(istr), std::istream(&_buf)
+{
+}
+
+
+CountingInputStream::~CountingInputStream()
+{
+}
+
+
+CountingOutputStream::CountingOutputStream(): std::ostream(&_buf)
+{
+}
+
+
+CountingOutputStream::CountingOutputStream(std::ostream& ostr): CountingIOS(ostr), std::ostream(&_buf)
+{
+}
+
+
+CountingOutputStream::~CountingOutputStream()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/DateTime.cpp b/contrib/libs/poco/Foundation/src/DateTime.cpp
index f559d97e75..a13365f41e 100644
--- a/contrib/libs/poco/Foundation/src/DateTime.cpp
+++ b/contrib/libs/poco/Foundation/src/DateTime.cpp
@@ -1,432 +1,432 @@
-//
-// DateTime.cpp
-//
-// Library: Foundation
-// Package: DateTime
-// Module: DateTime
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/DateTime.h"
-#include "Poco/Timespan.h"
-#include <algorithm>
-#include <cmath>
-
-
-namespace Poco {
-
-
-inline double DateTime::toJulianDay(Timestamp::UtcTimeVal utcTime)
-{
- double utcDays = double(utcTime)/864000000000.0;
- return utcDays + 2299160.5; // first day of Gregorian reform (Oct 15 1582)
-}
-
-
-inline Timestamp::UtcTimeVal DateTime::toUtcTime(double julianDay)
-{
- return Timestamp::UtcTimeVal((julianDay - 2299160.5)*864000000000.0);
-}
-
-
-DateTime::DateTime()
-{
- Timestamp now;
- _utcTime = now.utcTime();
- computeGregorian(julianDay());
- computeDaytime();
-}
-
-
-DateTime::DateTime(const Timestamp& rTimestamp):
- _utcTime(rTimestamp.utcTime())
-{
- computeGregorian(julianDay());
- computeDaytime();
-}
-
-
-DateTime::DateTime(int otherYear, int otherMonth, int otherDay, int otherHour, int otherMinute, int otherSecond, int otherMillisecond, int otherMicrosecond):
- _year(static_cast<short>(otherYear)),
- _month(static_cast<short>(otherMonth)),
- _day(static_cast<short>(otherDay)),
- _hour(static_cast<short>(otherHour)),
- _minute(static_cast<short>(otherMinute)),
- _second(static_cast<short>(otherSecond)),
- _millisecond(static_cast<short>(otherMillisecond)),
- _microsecond(static_cast<short>(otherMicrosecond))
-{
- poco_assert (_year >= 0 && _year <= 9999);
- poco_assert (_month >= 1 && _month <= 12);
- poco_assert (_day >= 1 && _day <= daysOfMonth(_year, _month));
- poco_assert (_hour >= 0 && _hour <= 23);
- poco_assert (_minute >= 0 && _minute <= 59);
- 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);
-}
-
-
-DateTime::DateTime(double otherJulianDay):
- _utcTime(toUtcTime(otherJulianDay))
-{
- computeGregorian(otherJulianDay);
-}
-
-
-DateTime::DateTime(Timestamp::UtcTimeVal otherUtcTime, Timestamp::TimeDiff diff):
- _utcTime(otherUtcTime + diff*10)
-{
- computeGregorian(julianDay());
- computeDaytime();
-}
-
-
-DateTime::DateTime(const DateTime& dateTime):
- _utcTime(dateTime._utcTime),
- _year(dateTime._year),
- _month(dateTime._month),
- _day(dateTime._day),
- _hour(dateTime._hour),
- _minute(dateTime._minute),
- _second(dateTime._second),
- _millisecond(dateTime._millisecond),
- _microsecond(dateTime._microsecond)
-{
-}
-
-
-DateTime::~DateTime()
-{
-}
-
-
-DateTime& DateTime::operator = (const DateTime& dateTime)
-{
- if (&dateTime != this)
- {
- _utcTime = dateTime._utcTime;
- _year = dateTime._year;
- _month = dateTime._month;
- _day = dateTime._day;
- _hour = dateTime._hour;
- _minute = dateTime._minute;
- _second = dateTime._second;
- _millisecond = dateTime._millisecond;
- _microsecond = dateTime._microsecond;
- }
- return *this;
-}
-
-
-DateTime& DateTime::operator = (const Timestamp& otherTimestamp)
-{
- _utcTime = otherTimestamp.utcTime();
- computeGregorian(julianDay());
- computeDaytime();
- return *this;
-}
-
-
-DateTime& DateTime::operator = (double otherJulianDay)
-{
- _utcTime = toUtcTime(otherJulianDay);
- computeGregorian(otherJulianDay);
- return *this;
-}
-
-
-DateTime& DateTime::assign(int otherYear, int otherMonth, int otherDay, int otherHour, int otherMinute, int otherSecond, int otherMillisecond, int otherMicrosecond)
-{
- poco_assert (otherYear >= 0 && otherYear <= 9999);
- poco_assert (otherMonth >= 1 && otherMonth <= 12);
- poco_assert (otherDay >= 1 && otherDay <= daysOfMonth(otherYear, otherMonth));
- poco_assert (otherHour >= 0 && otherHour <= 23);
- poco_assert (otherMinute >= 0 && otherMinute <= 59);
- poco_assert (otherSecond >= 0 && otherSecond <= 60); // allow leap seconds
- poco_assert (otherMillisecond >= 0 && otherMillisecond <= 999);
- poco_assert (otherMicrosecond >= 0 && otherMicrosecond <= 999);
-
- _utcTime = toUtcTime(toJulianDay(otherYear, otherMonth, otherDay)) + 10*(otherHour*Timespan::HOURS + otherMinute*Timespan::MINUTES + otherSecond*Timespan::SECONDS + otherMillisecond*Timespan::MILLISECONDS + otherMicrosecond);
- _year = static_cast<short>(otherYear);
- _month = static_cast<short>(otherMonth);
- _day = static_cast<short>(otherDay);
- _hour = static_cast<short>(otherHour);
- _minute = static_cast<short>(otherMinute);
- _second = static_cast<short>(otherSecond);
- _millisecond = static_cast<short>(otherMillisecond);
- _microsecond = static_cast<short>(otherMicrosecond);
-
- return *this;
-}
-
-
-void DateTime::swap(DateTime& dateTime)
-{
- std::swap(_utcTime, dateTime._utcTime);
- std::swap(_year, dateTime._year);
- std::swap(_month, dateTime._month);
- std::swap(_day, dateTime._day);
- std::swap(_hour, dateTime._hour);
- std::swap(_minute, dateTime._minute);
- std::swap(_second, dateTime._second);
- std::swap(_millisecond, dateTime._millisecond);
- std::swap(_microsecond, dateTime._microsecond);
-}
-
-
-int DateTime::dayOfWeek() const
-{
- return int((std::floor(julianDay() + 1.5))) % 7;
-}
-
-
-int DateTime::dayOfYear() const
-{
- int doy = 0;
- for (int currentMonth = 1; currentMonth < _month; ++currentMonth)
- doy += daysOfMonth(_year, currentMonth);
- doy += _day;
- return doy;
-}
-
-
-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
- return daysOfMonthTable[month];
-}
-
-
-bool DateTime::isValid(int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond)
-{
- return
- (year >= 0 && year <= 9999) &&
- (month >= 1 && month <= 12) &&
- (day >= 1 && day <= daysOfMonth(year, month)) &&
- (hour >= 0 && hour <= 23) &&
- (minute >= 0 && minute <= 59) &&
- (second >= 0 && second <= 60) &&
- (millisecond >= 0 && millisecond <= 999) &&
- (microsecond >= 0 && microsecond <= 999);
-}
-
-
-int DateTime::week(int firstDayOfWeek) const
-{
- poco_assert (firstDayOfWeek >= 0 && firstDayOfWeek <= 6);
-
- /// find the first firstDayOfWeek.
- int baseDay = 1;
- while (DateTime(_year, 1, baseDay).dayOfWeek() != firstDayOfWeek) ++baseDay;
-
- int doy = dayOfYear();
- int offs = baseDay <= 4 ? 0 : 1;
- if (doy < baseDay)
- return offs;
- else
- return (doy - baseDay)/7 + 1 + offs;
-}
-
-
-double DateTime::julianDay() const
-{
- return toJulianDay(_utcTime);
-}
-
-
-DateTime DateTime::operator + (const Timespan& span) const
-{
- return DateTime(_utcTime, span.totalMicroseconds());
-}
-
-
-DateTime DateTime::operator - (const Timespan& span) const
-{
- return DateTime(_utcTime, -span.totalMicroseconds());
-}
-
-
-Timespan DateTime::operator - (const DateTime& dateTime) const
-{
- return Timespan((_utcTime - dateTime._utcTime)/10);
-}
-
-
-DateTime& DateTime::operator += (const Timespan& span)
-{
- _utcTime += span.totalMicroseconds()*10;
- computeGregorian(julianDay());
- computeDaytime();
- return *this;
-}
-
-
-DateTime& DateTime::operator -= (const Timespan& span)
-{
- _utcTime -= span.totalMicroseconds()*10;
- computeGregorian(julianDay());
- computeDaytime();
- return *this;
-}
-
-
-void DateTime::makeUTC(int tzd)
-{
- operator -= (Timespan(((Timestamp::TimeDiff) tzd)*Timespan::SECONDS));
-}
-
-
-void DateTime::makeLocal(int tzd)
-{
- operator += (Timespan(((Timestamp::TimeDiff) tzd)*Timespan::SECONDS));
-}
-
-
-double DateTime::toJulianDay(int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond)
-{
- // 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)
- {
- month += 12;
- --year;
- }
- double dyear = double(year);
- return dday + lookup[month] + 365*year + std::floor(dyear/4) - std::floor(dyear/100) + std::floor(dyear/400) + 1721118.5;
-}
-
-
-void DateTime::checkLimit(short& lower, short& higher, short limit)
-{
- if (lower >= limit)
- {
- higher += short(lower / limit);
- lower = short(lower % limit);
- }
-}
-
-
-void DateTime::normalize()
-{
- checkLimit(_microsecond, _millisecond, 1000);
- checkLimit(_millisecond, _second, 1000);
- checkLimit(_second, _minute, 60);
- checkLimit(_minute, _hour, 60);
- checkLimit(_hour, _day, 24);
-
- if (_day > daysOfMonth(_year, _month))
- {
- _day -= static_cast<short>(daysOfMonth(_year, _month));
- if (++_month > 12)
- {
- ++_year;
- _month -= 12;
- }
- }
-}
-
-
-void DateTime::computeGregorian(double otherJulianDay)
-{
- double z = std::floor(otherJulianDay - 1721118.5);
- double r = otherJulianDay - 1721118.5 - z;
- double g = z - 0.25;
- double a = std::floor(g / 36524.25);
- double b = a - std::floor(a/4);
- _year = short(std::floor((b + g)/365.25));
- double c = b + z - std::floor(365.25*_year);
- _month = short(std::floor((5*c + 456)/153));
- double dday = c - std::floor((153.0*_month - 457)/5) + r;
- _day = short(dday);
- if (_month > 12)
- {
- ++_year;
- _month -= 12;
- }
- r *= 24;
- _hour = short(std::floor(r));
- r -= std::floor(r);
- r *= 60;
- _minute = short(std::floor(r));
- r -= std::floor(r);
- r *= 60;
- _second = short(std::floor(r));
- r -= std::floor(r);
- r *= 1000;
- _millisecond = short(std::floor(r));
- r -= std::floor(r);
- r *= 1000;
- _microsecond = short(r + 0.5);
-
- normalize();
-
- poco_assert_dbg (_month >= 1 && _month <= 12);
- poco_assert_dbg (_day >= 1 && _day <= daysOfMonth(_year, _month));
- poco_assert_dbg (_hour >= 0 && _hour <= 23);
- poco_assert_dbg (_minute >= 0 && _minute <= 59);
- poco_assert_dbg (_second >= 0 && _second <= 59);
- poco_assert_dbg (_millisecond >= 0 && _millisecond <= 999);
- poco_assert_dbg (_microsecond >= 0 && _microsecond <= 999);
-}
-
-
-void DateTime::computeDaytime()
-{
- Timespan span(_utcTime/10);
- int spanHour = 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.
- if (spanHour == 23 && _hour == 0)
- {
- _day--;
- if (_day == 0)
- {
- _month--;
- if (_month == 0)
- {
- _month = 12;
- _year--;
- }
- _day = static_cast<short>(daysOfMonth(_year, _month));
- }
- }
- else if (spanHour == 0 && _hour == 23)
- {
- _day++;
- if (_day > daysOfMonth(_year, _month))
- {
- _month++;
- if (_month > 12)
- {
- _month = 1;
- _year++;
- }
- _day = 1;
- }
- }
- _hour = static_cast<short>(spanHour);
- _minute = static_cast<short>(span.minutes());
- _second = static_cast<short>(span.seconds());
- _millisecond = static_cast<short>(span.milliseconds());
- _microsecond = static_cast<short>(span.microseconds());
-}
-
-
-} // namespace Poco
+//
+// DateTime.cpp
+//
+// Library: Foundation
+// Package: DateTime
+// Module: DateTime
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/DateTime.h"
+#include "Poco/Timespan.h"
+#include <algorithm>
+#include <cmath>
+
+
+namespace Poco {
+
+
+inline double DateTime::toJulianDay(Timestamp::UtcTimeVal utcTime)
+{
+ double utcDays = double(utcTime)/864000000000.0;
+ return utcDays + 2299160.5; // first day of Gregorian reform (Oct 15 1582)
+}
+
+
+inline Timestamp::UtcTimeVal DateTime::toUtcTime(double julianDay)
+{
+ return Timestamp::UtcTimeVal((julianDay - 2299160.5)*864000000000.0);
+}
+
+
+DateTime::DateTime()
+{
+ Timestamp now;
+ _utcTime = now.utcTime();
+ computeGregorian(julianDay());
+ computeDaytime();
+}
+
+
+DateTime::DateTime(const Timestamp& rTimestamp):
+ _utcTime(rTimestamp.utcTime())
+{
+ computeGregorian(julianDay());
+ computeDaytime();
+}
+
+
+DateTime::DateTime(int otherYear, int otherMonth, int otherDay, int otherHour, int otherMinute, int otherSecond, int otherMillisecond, int otherMicrosecond):
+ _year(static_cast<short>(otherYear)),
+ _month(static_cast<short>(otherMonth)),
+ _day(static_cast<short>(otherDay)),
+ _hour(static_cast<short>(otherHour)),
+ _minute(static_cast<short>(otherMinute)),
+ _second(static_cast<short>(otherSecond)),
+ _millisecond(static_cast<short>(otherMillisecond)),
+ _microsecond(static_cast<short>(otherMicrosecond))
+{
+ poco_assert (_year >= 0 && _year <= 9999);
+ poco_assert (_month >= 1 && _month <= 12);
+ poco_assert (_day >= 1 && _day <= daysOfMonth(_year, _month));
+ poco_assert (_hour >= 0 && _hour <= 23);
+ poco_assert (_minute >= 0 && _minute <= 59);
+ 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);
+}
+
+
+DateTime::DateTime(double otherJulianDay):
+ _utcTime(toUtcTime(otherJulianDay))
+{
+ computeGregorian(otherJulianDay);
+}
+
+
+DateTime::DateTime(Timestamp::UtcTimeVal otherUtcTime, Timestamp::TimeDiff diff):
+ _utcTime(otherUtcTime + diff*10)
+{
+ computeGregorian(julianDay());
+ computeDaytime();
+}
+
+
+DateTime::DateTime(const DateTime& dateTime):
+ _utcTime(dateTime._utcTime),
+ _year(dateTime._year),
+ _month(dateTime._month),
+ _day(dateTime._day),
+ _hour(dateTime._hour),
+ _minute(dateTime._minute),
+ _second(dateTime._second),
+ _millisecond(dateTime._millisecond),
+ _microsecond(dateTime._microsecond)
+{
+}
+
+
+DateTime::~DateTime()
+{
+}
+
+
+DateTime& DateTime::operator = (const DateTime& dateTime)
+{
+ if (&dateTime != this)
+ {
+ _utcTime = dateTime._utcTime;
+ _year = dateTime._year;
+ _month = dateTime._month;
+ _day = dateTime._day;
+ _hour = dateTime._hour;
+ _minute = dateTime._minute;
+ _second = dateTime._second;
+ _millisecond = dateTime._millisecond;
+ _microsecond = dateTime._microsecond;
+ }
+ return *this;
+}
+
+
+DateTime& DateTime::operator = (const Timestamp& otherTimestamp)
+{
+ _utcTime = otherTimestamp.utcTime();
+ computeGregorian(julianDay());
+ computeDaytime();
+ return *this;
+}
+
+
+DateTime& DateTime::operator = (double otherJulianDay)
+{
+ _utcTime = toUtcTime(otherJulianDay);
+ computeGregorian(otherJulianDay);
+ return *this;
+}
+
+
+DateTime& DateTime::assign(int otherYear, int otherMonth, int otherDay, int otherHour, int otherMinute, int otherSecond, int otherMillisecond, int otherMicrosecond)
+{
+ poco_assert (otherYear >= 0 && otherYear <= 9999);
+ poco_assert (otherMonth >= 1 && otherMonth <= 12);
+ poco_assert (otherDay >= 1 && otherDay <= daysOfMonth(otherYear, otherMonth));
+ poco_assert (otherHour >= 0 && otherHour <= 23);
+ poco_assert (otherMinute >= 0 && otherMinute <= 59);
+ poco_assert (otherSecond >= 0 && otherSecond <= 60); // allow leap seconds
+ poco_assert (otherMillisecond >= 0 && otherMillisecond <= 999);
+ poco_assert (otherMicrosecond >= 0 && otherMicrosecond <= 999);
+
+ _utcTime = toUtcTime(toJulianDay(otherYear, otherMonth, otherDay)) + 10*(otherHour*Timespan::HOURS + otherMinute*Timespan::MINUTES + otherSecond*Timespan::SECONDS + otherMillisecond*Timespan::MILLISECONDS + otherMicrosecond);
+ _year = static_cast<short>(otherYear);
+ _month = static_cast<short>(otherMonth);
+ _day = static_cast<short>(otherDay);
+ _hour = static_cast<short>(otherHour);
+ _minute = static_cast<short>(otherMinute);
+ _second = static_cast<short>(otherSecond);
+ _millisecond = static_cast<short>(otherMillisecond);
+ _microsecond = static_cast<short>(otherMicrosecond);
+
+ return *this;
+}
+
+
+void DateTime::swap(DateTime& dateTime)
+{
+ std::swap(_utcTime, dateTime._utcTime);
+ std::swap(_year, dateTime._year);
+ std::swap(_month, dateTime._month);
+ std::swap(_day, dateTime._day);
+ std::swap(_hour, dateTime._hour);
+ std::swap(_minute, dateTime._minute);
+ std::swap(_second, dateTime._second);
+ std::swap(_millisecond, dateTime._millisecond);
+ std::swap(_microsecond, dateTime._microsecond);
+}
+
+
+int DateTime::dayOfWeek() const
+{
+ return int((std::floor(julianDay() + 1.5))) % 7;
+}
+
+
+int DateTime::dayOfYear() const
+{
+ int doy = 0;
+ for (int currentMonth = 1; currentMonth < _month; ++currentMonth)
+ doy += daysOfMonth(_year, currentMonth);
+ doy += _day;
+ return doy;
+}
+
+
+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
+ return daysOfMonthTable[month];
+}
+
+
+bool DateTime::isValid(int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond)
+{
+ return
+ (year >= 0 && year <= 9999) &&
+ (month >= 1 && month <= 12) &&
+ (day >= 1 && day <= daysOfMonth(year, month)) &&
+ (hour >= 0 && hour <= 23) &&
+ (minute >= 0 && minute <= 59) &&
+ (second >= 0 && second <= 60) &&
+ (millisecond >= 0 && millisecond <= 999) &&
+ (microsecond >= 0 && microsecond <= 999);
+}
+
+
+int DateTime::week(int firstDayOfWeek) const
+{
+ poco_assert (firstDayOfWeek >= 0 && firstDayOfWeek <= 6);
+
+ /// find the first firstDayOfWeek.
+ int baseDay = 1;
+ while (DateTime(_year, 1, baseDay).dayOfWeek() != firstDayOfWeek) ++baseDay;
+
+ int doy = dayOfYear();
+ int offs = baseDay <= 4 ? 0 : 1;
+ if (doy < baseDay)
+ return offs;
+ else
+ return (doy - baseDay)/7 + 1 + offs;
+}
+
+
+double DateTime::julianDay() const
+{
+ return toJulianDay(_utcTime);
+}
+
+
+DateTime DateTime::operator + (const Timespan& span) const
+{
+ return DateTime(_utcTime, span.totalMicroseconds());
+}
+
+
+DateTime DateTime::operator - (const Timespan& span) const
+{
+ return DateTime(_utcTime, -span.totalMicroseconds());
+}
+
+
+Timespan DateTime::operator - (const DateTime& dateTime) const
+{
+ return Timespan((_utcTime - dateTime._utcTime)/10);
+}
+
+
+DateTime& DateTime::operator += (const Timespan& span)
+{
+ _utcTime += span.totalMicroseconds()*10;
+ computeGregorian(julianDay());
+ computeDaytime();
+ return *this;
+}
+
+
+DateTime& DateTime::operator -= (const Timespan& span)
+{
+ _utcTime -= span.totalMicroseconds()*10;
+ computeGregorian(julianDay());
+ computeDaytime();
+ return *this;
+}
+
+
+void DateTime::makeUTC(int tzd)
+{
+ operator -= (Timespan(((Timestamp::TimeDiff) tzd)*Timespan::SECONDS));
+}
+
+
+void DateTime::makeLocal(int tzd)
+{
+ operator += (Timespan(((Timestamp::TimeDiff) tzd)*Timespan::SECONDS));
+}
+
+
+double DateTime::toJulianDay(int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond)
+{
+ // 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)
+ {
+ month += 12;
+ --year;
+ }
+ double dyear = double(year);
+ return dday + lookup[month] + 365*year + std::floor(dyear/4) - std::floor(dyear/100) + std::floor(dyear/400) + 1721118.5;
+}
+
+
+void DateTime::checkLimit(short& lower, short& higher, short limit)
+{
+ if (lower >= limit)
+ {
+ higher += short(lower / limit);
+ lower = short(lower % limit);
+ }
+}
+
+
+void DateTime::normalize()
+{
+ checkLimit(_microsecond, _millisecond, 1000);
+ checkLimit(_millisecond, _second, 1000);
+ checkLimit(_second, _minute, 60);
+ checkLimit(_minute, _hour, 60);
+ checkLimit(_hour, _day, 24);
+
+ if (_day > daysOfMonth(_year, _month))
+ {
+ _day -= static_cast<short>(daysOfMonth(_year, _month));
+ if (++_month > 12)
+ {
+ ++_year;
+ _month -= 12;
+ }
+ }
+}
+
+
+void DateTime::computeGregorian(double otherJulianDay)
+{
+ double z = std::floor(otherJulianDay - 1721118.5);
+ double r = otherJulianDay - 1721118.5 - z;
+ double g = z - 0.25;
+ double a = std::floor(g / 36524.25);
+ double b = a - std::floor(a/4);
+ _year = short(std::floor((b + g)/365.25));
+ double c = b + z - std::floor(365.25*_year);
+ _month = short(std::floor((5*c + 456)/153));
+ double dday = c - std::floor((153.0*_month - 457)/5) + r;
+ _day = short(dday);
+ if (_month > 12)
+ {
+ ++_year;
+ _month -= 12;
+ }
+ r *= 24;
+ _hour = short(std::floor(r));
+ r -= std::floor(r);
+ r *= 60;
+ _minute = short(std::floor(r));
+ r -= std::floor(r);
+ r *= 60;
+ _second = short(std::floor(r));
+ r -= std::floor(r);
+ r *= 1000;
+ _millisecond = short(std::floor(r));
+ r -= std::floor(r);
+ r *= 1000;
+ _microsecond = short(r + 0.5);
+
+ normalize();
+
+ poco_assert_dbg (_month >= 1 && _month <= 12);
+ poco_assert_dbg (_day >= 1 && _day <= daysOfMonth(_year, _month));
+ poco_assert_dbg (_hour >= 0 && _hour <= 23);
+ poco_assert_dbg (_minute >= 0 && _minute <= 59);
+ poco_assert_dbg (_second >= 0 && _second <= 59);
+ poco_assert_dbg (_millisecond >= 0 && _millisecond <= 999);
+ poco_assert_dbg (_microsecond >= 0 && _microsecond <= 999);
+}
+
+
+void DateTime::computeDaytime()
+{
+ Timespan span(_utcTime/10);
+ int spanHour = 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.
+ if (spanHour == 23 && _hour == 0)
+ {
+ _day--;
+ if (_day == 0)
+ {
+ _month--;
+ if (_month == 0)
+ {
+ _month = 12;
+ _year--;
+ }
+ _day = static_cast<short>(daysOfMonth(_year, _month));
+ }
+ }
+ else if (spanHour == 0 && _hour == 23)
+ {
+ _day++;
+ if (_day > daysOfMonth(_year, _month))
+ {
+ _month++;
+ if (_month > 12)
+ {
+ _month = 1;
+ _year++;
+ }
+ _day = 1;
+ }
+ }
+ _hour = static_cast<short>(spanHour);
+ _minute = static_cast<short>(span.minutes());
+ _second = static_cast<short>(span.seconds());
+ _millisecond = static_cast<short>(span.milliseconds());
+ _microsecond = static_cast<short>(span.microseconds());
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/DateTimeFormat.cpp b/contrib/libs/poco/Foundation/src/DateTimeFormat.cpp
index 9f16a392ea..8f5f3e4e92 100644
--- a/contrib/libs/poco/Foundation/src/DateTimeFormat.cpp
+++ b/contrib/libs/poco/Foundation/src/DateTimeFormat.cpp
@@ -1,61 +1,61 @@
-//
-// DateTimeFormat.cpp
-//
-// Library: Foundation
-// Package: DateTime
-// Module: DateTimeFormat
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/DateTimeFormat.h"
-
-
-namespace Poco {
-
-
-const std::string DateTimeFormat::ISO8601_FORMAT("%Y-%m-%dT%H:%M:%S%z");
-const std::string DateTimeFormat::ISO8601_FRAC_FORMAT("%Y-%m-%dT%H:%M:%s%z");
-const std::string DateTimeFormat::RFC822_FORMAT("%w, %e %b %y %H:%M:%S %Z");
-const std::string DateTimeFormat::RFC1123_FORMAT("%w, %e %b %Y %H:%M:%S %Z");
-const std::string DateTimeFormat::HTTP_FORMAT("%w, %d %b %Y %H:%M:%S %Z");
-const std::string DateTimeFormat::RFC850_FORMAT("%W, %e-%b-%y %H:%M:%S %Z");
-const std::string DateTimeFormat::RFC1036_FORMAT("%W, %e %b %y %H:%M:%S %Z");
-const std::string DateTimeFormat::ASCTIME_FORMAT("%w %b %f %H:%M:%S %Y");
-const std::string DateTimeFormat::SORTABLE_FORMAT("%Y-%m-%d %H:%M:%S");
-
-
-const std::string DateTimeFormat::WEEKDAY_NAMES[] =
-{
- "Sunday",
- "Monday",
- "Tuesday",
- "Wednesday",
- "Thursday",
- "Friday",
- "Saturday"
-};
-
-
-const std::string DateTimeFormat::MONTH_NAMES[] =
-{
- "January",
- "February",
- "March",
- "April",
- "May",
- "June",
- "July",
- "August",
- "September",
- "October",
- "November",
- "December"
-};
-
-
-} // namespace Poco
+//
+// DateTimeFormat.cpp
+//
+// Library: Foundation
+// Package: DateTime
+// Module: DateTimeFormat
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/DateTimeFormat.h"
+
+
+namespace Poco {
+
+
+const std::string DateTimeFormat::ISO8601_FORMAT("%Y-%m-%dT%H:%M:%S%z");
+const std::string DateTimeFormat::ISO8601_FRAC_FORMAT("%Y-%m-%dT%H:%M:%s%z");
+const std::string DateTimeFormat::RFC822_FORMAT("%w, %e %b %y %H:%M:%S %Z");
+const std::string DateTimeFormat::RFC1123_FORMAT("%w, %e %b %Y %H:%M:%S %Z");
+const std::string DateTimeFormat::HTTP_FORMAT("%w, %d %b %Y %H:%M:%S %Z");
+const std::string DateTimeFormat::RFC850_FORMAT("%W, %e-%b-%y %H:%M:%S %Z");
+const std::string DateTimeFormat::RFC1036_FORMAT("%W, %e %b %y %H:%M:%S %Z");
+const std::string DateTimeFormat::ASCTIME_FORMAT("%w %b %f %H:%M:%S %Y");
+const std::string DateTimeFormat::SORTABLE_FORMAT("%Y-%m-%d %H:%M:%S");
+
+
+const std::string DateTimeFormat::WEEKDAY_NAMES[] =
+{
+ "Sunday",
+ "Monday",
+ "Tuesday",
+ "Wednesday",
+ "Thursday",
+ "Friday",
+ "Saturday"
+};
+
+
+const std::string DateTimeFormat::MONTH_NAMES[] =
+{
+ "January",
+ "February",
+ "March",
+ "April",
+ "May",
+ "June",
+ "July",
+ "August",
+ "September",
+ "October",
+ "November",
+ "December"
+};
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/DateTimeFormatter.cpp b/contrib/libs/poco/Foundation/src/DateTimeFormatter.cpp
index 25ce6b01ff..f72dd978d6 100644
--- a/contrib/libs/poco/Foundation/src/DateTimeFormatter.cpp
+++ b/contrib/libs/poco/Foundation/src/DateTimeFormatter.cpp
@@ -1,155 +1,155 @@
-//
-// DateTimeFormatter.cpp
-//
-// Library: Foundation
-// Package: DateTime
-// Module: DateTimeFormatter
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/DateTimeFormatter.h"
-#include "Poco/DateTimeFormat.h"
-#include "Poco/Timestamp.h"
-#include "Poco/NumberFormatter.h"
-
-
-namespace Poco {
-
-
-void DateTimeFormatter::append(std::string& str, const LocalDateTime& dateTime, const std::string& fmt)
-{
- DateTimeFormatter::append(str, dateTime._dateTime, fmt, dateTime.tzd());
-}
-
-
-void DateTimeFormatter::append(std::string& str, const DateTime& dateTime, const std::string& fmt, int timeZoneDifferential)
-{
- std::string::const_iterator it = fmt.begin();
- std::string::const_iterator end = fmt.end();
- while (it != end)
- {
- if (*it == '%')
- {
- if (++it != end)
- {
- switch (*it)
- {
- case 'w': str.append(DateTimeFormat::WEEKDAY_NAMES[dateTime.dayOfWeek()], 0, 3); break;
- case 'W': str.append(DateTimeFormat::WEEKDAY_NAMES[dateTime.dayOfWeek()]); break;
- case 'b': str.append(DateTimeFormat::MONTH_NAMES[dateTime.month() - 1], 0, 3); break;
- case 'B': str.append(DateTimeFormat::MONTH_NAMES[dateTime.month() - 1]); break;
- case 'd': NumberFormatter::append0(str, dateTime.day(), 2); break;
- case 'e': NumberFormatter::append(str, dateTime.day()); break;
- case 'f': NumberFormatter::append(str, dateTime.day(), 2); break;
- case 'm': NumberFormatter::append0(str, dateTime.month(), 2); break;
- case 'n': NumberFormatter::append(str, dateTime.month()); break;
- case 'o': NumberFormatter::append(str, dateTime.month(), 2); break;
- case 'y': NumberFormatter::append0(str, dateTime.year() % 100, 2); break;
- case 'Y': NumberFormatter::append0(str, dateTime.year(), 4); break;
- case 'H': NumberFormatter::append0(str, dateTime.hour(), 2); break;
- case 'h': NumberFormatter::append0(str, dateTime.hourAMPM(), 2); break;
- case 'a': str.append(dateTime.isAM() ? "am" : "pm"); break;
- 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);
- break;
- case 'i': NumberFormatter::append0(str, dateTime.millisecond(), 3); break;
- case 'c': NumberFormatter::append(str, dateTime.millisecond()/100); break;
- case 'F': NumberFormatter::append0(str, dateTime.millisecond()*1000 + dateTime.microsecond(), 6); break;
- case 'z': tzdISO(str, timeZoneDifferential); break;
- case 'Z': tzdRFC(str, timeZoneDifferential); break;
- default: str += *it;
- }
- ++it;
- }
- }
- else str += *it++;
- }
-}
-
-
-void DateTimeFormatter::append(std::string& str, const Timespan& timespan, const std::string& fmt)
-{
- std::string::const_iterator it = fmt.begin();
- std::string::const_iterator end = fmt.end();
- while (it != end)
- {
- if (*it == '%')
- {
- if (++it != end)
- {
- switch (*it)
- {
- case 'd': NumberFormatter::append(str, timespan.days()); break;
- case 'H': NumberFormatter::append0(str, timespan.hours(), 2); break;
- case 'h': NumberFormatter::append(str, timespan.totalHours()); break;
- case 'M': NumberFormatter::append0(str, timespan.minutes(), 2); break;
- case 'm': NumberFormatter::append(str, timespan.totalMinutes()); break;
- case 'S': NumberFormatter::append0(str, timespan.seconds(), 2); break;
- case 's': NumberFormatter::append(str, timespan.totalSeconds()); break;
- case 'i': NumberFormatter::append0(str, timespan.milliseconds(), 3); break;
- case 'c': NumberFormatter::append(str, timespan.milliseconds()/100); break;
- case 'F': NumberFormatter::append0(str, timespan.milliseconds()*1000 + timespan.microseconds(), 6); break;
- default: str += *it;
- }
- ++it;
- }
- }
- else str += *it++;
- }
-}
-
-
-void DateTimeFormatter::tzdISO(std::string& str, int timeZoneDifferential)
-{
- if (timeZoneDifferential != UTC)
- {
- if (timeZoneDifferential >= 0)
- {
- str += '+';
- NumberFormatter::append0(str, timeZoneDifferential/3600, 2);
- str += ':';
- NumberFormatter::append0(str, (timeZoneDifferential%3600)/60, 2);
- }
- else
- {
- str += '-';
- NumberFormatter::append0(str, -timeZoneDifferential/3600, 2);
- str += ':';
- NumberFormatter::append0(str, (-timeZoneDifferential%3600)/60, 2);
- }
- }
- else str += 'Z';
-}
-
-
-void DateTimeFormatter::tzdRFC(std::string& str, int timeZoneDifferential)
-{
- if (timeZoneDifferential != UTC)
- {
- if (timeZoneDifferential >= 0)
- {
- str += '+';
- NumberFormatter::append0(str, timeZoneDifferential/3600, 2);
- NumberFormatter::append0(str, (timeZoneDifferential%3600)/60, 2);
- }
- else
- {
- str += '-';
- NumberFormatter::append0(str, -timeZoneDifferential/3600, 2);
- NumberFormatter::append0(str, (-timeZoneDifferential%3600)/60, 2);
- }
- }
- else str += "GMT";
-}
-
-
-} // namespace Poco
+//
+// DateTimeFormatter.cpp
+//
+// Library: Foundation
+// Package: DateTime
+// Module: DateTimeFormatter
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/DateTimeFormatter.h"
+#include "Poco/DateTimeFormat.h"
+#include "Poco/Timestamp.h"
+#include "Poco/NumberFormatter.h"
+
+
+namespace Poco {
+
+
+void DateTimeFormatter::append(std::string& str, const LocalDateTime& dateTime, const std::string& fmt)
+{
+ DateTimeFormatter::append(str, dateTime._dateTime, fmt, dateTime.tzd());
+}
+
+
+void DateTimeFormatter::append(std::string& str, const DateTime& dateTime, const std::string& fmt, int timeZoneDifferential)
+{
+ std::string::const_iterator it = fmt.begin();
+ std::string::const_iterator end = fmt.end();
+ while (it != end)
+ {
+ if (*it == '%')
+ {
+ if (++it != end)
+ {
+ switch (*it)
+ {
+ case 'w': str.append(DateTimeFormat::WEEKDAY_NAMES[dateTime.dayOfWeek()], 0, 3); break;
+ case 'W': str.append(DateTimeFormat::WEEKDAY_NAMES[dateTime.dayOfWeek()]); break;
+ case 'b': str.append(DateTimeFormat::MONTH_NAMES[dateTime.month() - 1], 0, 3); break;
+ case 'B': str.append(DateTimeFormat::MONTH_NAMES[dateTime.month() - 1]); break;
+ case 'd': NumberFormatter::append0(str, dateTime.day(), 2); break;
+ case 'e': NumberFormatter::append(str, dateTime.day()); break;
+ case 'f': NumberFormatter::append(str, dateTime.day(), 2); break;
+ case 'm': NumberFormatter::append0(str, dateTime.month(), 2); break;
+ case 'n': NumberFormatter::append(str, dateTime.month()); break;
+ case 'o': NumberFormatter::append(str, dateTime.month(), 2); break;
+ case 'y': NumberFormatter::append0(str, dateTime.year() % 100, 2); break;
+ case 'Y': NumberFormatter::append0(str, dateTime.year(), 4); break;
+ case 'H': NumberFormatter::append0(str, dateTime.hour(), 2); break;
+ case 'h': NumberFormatter::append0(str, dateTime.hourAMPM(), 2); break;
+ case 'a': str.append(dateTime.isAM() ? "am" : "pm"); break;
+ 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);
+ break;
+ case 'i': NumberFormatter::append0(str, dateTime.millisecond(), 3); break;
+ case 'c': NumberFormatter::append(str, dateTime.millisecond()/100); break;
+ case 'F': NumberFormatter::append0(str, dateTime.millisecond()*1000 + dateTime.microsecond(), 6); break;
+ case 'z': tzdISO(str, timeZoneDifferential); break;
+ case 'Z': tzdRFC(str, timeZoneDifferential); break;
+ default: str += *it;
+ }
+ ++it;
+ }
+ }
+ else str += *it++;
+ }
+}
+
+
+void DateTimeFormatter::append(std::string& str, const Timespan& timespan, const std::string& fmt)
+{
+ std::string::const_iterator it = fmt.begin();
+ std::string::const_iterator end = fmt.end();
+ while (it != end)
+ {
+ if (*it == '%')
+ {
+ if (++it != end)
+ {
+ switch (*it)
+ {
+ case 'd': NumberFormatter::append(str, timespan.days()); break;
+ case 'H': NumberFormatter::append0(str, timespan.hours(), 2); break;
+ case 'h': NumberFormatter::append(str, timespan.totalHours()); break;
+ case 'M': NumberFormatter::append0(str, timespan.minutes(), 2); break;
+ case 'm': NumberFormatter::append(str, timespan.totalMinutes()); break;
+ case 'S': NumberFormatter::append0(str, timespan.seconds(), 2); break;
+ case 's': NumberFormatter::append(str, timespan.totalSeconds()); break;
+ case 'i': NumberFormatter::append0(str, timespan.milliseconds(), 3); break;
+ case 'c': NumberFormatter::append(str, timespan.milliseconds()/100); break;
+ case 'F': NumberFormatter::append0(str, timespan.milliseconds()*1000 + timespan.microseconds(), 6); break;
+ default: str += *it;
+ }
+ ++it;
+ }
+ }
+ else str += *it++;
+ }
+}
+
+
+void DateTimeFormatter::tzdISO(std::string& str, int timeZoneDifferential)
+{
+ if (timeZoneDifferential != UTC)
+ {
+ if (timeZoneDifferential >= 0)
+ {
+ str += '+';
+ NumberFormatter::append0(str, timeZoneDifferential/3600, 2);
+ str += ':';
+ NumberFormatter::append0(str, (timeZoneDifferential%3600)/60, 2);
+ }
+ else
+ {
+ str += '-';
+ NumberFormatter::append0(str, -timeZoneDifferential/3600, 2);
+ str += ':';
+ NumberFormatter::append0(str, (-timeZoneDifferential%3600)/60, 2);
+ }
+ }
+ else str += 'Z';
+}
+
+
+void DateTimeFormatter::tzdRFC(std::string& str, int timeZoneDifferential)
+{
+ if (timeZoneDifferential != UTC)
+ {
+ if (timeZoneDifferential >= 0)
+ {
+ str += '+';
+ NumberFormatter::append0(str, timeZoneDifferential/3600, 2);
+ NumberFormatter::append0(str, (timeZoneDifferential%3600)/60, 2);
+ }
+ else
+ {
+ str += '-';
+ NumberFormatter::append0(str, -timeZoneDifferential/3600, 2);
+ NumberFormatter::append0(str, (-timeZoneDifferential%3600)/60, 2);
+ }
+ }
+ else str += "GMT";
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/DateTimeParser.cpp b/contrib/libs/poco/Foundation/src/DateTimeParser.cpp
index d70e9dbab5..b2588c858d 100644
--- a/contrib/libs/poco/Foundation/src/DateTimeParser.cpp
+++ b/contrib/libs/poco/Foundation/src/DateTimeParser.cpp
@@ -1,401 +1,401 @@
-//
-// DateTimeParser.cpp
-//
-// Library: Foundation
-// Package: DateTime
-// Module: DateTimeParser
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/DateTimeParser.h"
-#include "Poco/DateTimeFormat.h"
-#include "Poco/DateTime.h"
-#include "Poco/Exception.h"
-#include "Poco/Ascii.h"
-
-
-namespace Poco {
-
-
-#define SKIP_JUNK() \
- while (it != end && !Ascii::isDigit(*it)) ++it
-
-
-#define SKIP_DIGITS() \
- while (it != end && Ascii::isDigit(*it)) ++it
-
-
-#define PARSE_NUMBER(var) \
- while (it != end && Ascii::isDigit(*it)) var = var*10 + ((*it++) - '0')
-
-
-#define PARSE_NUMBER_N(var, n) \
- { int i = 0; while (i++ < n && it != end && Ascii::isDigit(*it)) var = var*10 + ((*it++) - '0'); }
-
-
-#define PARSE_FRACTIONAL_N(var, n) \
- { int i = 0; while (i < n && it != end && Ascii::isDigit(*it)) { var = var*10 + ((*it++) - '0'); i++; } while (i++ < n) var *= 10; }
-
-
-void DateTimeParser::parse(const std::string& fmt, const std::string& str, DateTime& dateTime, int& timeZoneDifferential)
-{
- if (fmt.empty() || str.empty())
- throw SyntaxException("Empty string.");
-
- int year = 0;
- int month = 0;
- int day = 0;
- int hour = 0;
- int minute = 0;
- int second = 0;
- int millis = 0;
- int micros = 0;
- int tzd = 0;
-
- std::string::const_iterator it = str.begin();
- std::string::const_iterator end = str.end();
- std::string::const_iterator itf = fmt.begin();
- std::string::const_iterator endf = fmt.end();
-
- while (itf != endf && it != end)
- {
- if (*itf == '%')
- {
- if (++itf != endf)
- {
- switch (*itf)
- {
- case 'w':
- case 'W':
- while (it != end && Ascii::isSpace(*it)) ++it;
- while (it != end && Ascii::isAlpha(*it)) ++it;
- break;
- case 'b':
- case 'B':
- month = parseMonth(it, end);
- break;
- case 'd':
- case 'e':
- case 'f':
- SKIP_JUNK();
- PARSE_NUMBER_N(day, 2);
- break;
- case 'm':
- case 'n':
- case 'o':
- SKIP_JUNK();
- PARSE_NUMBER_N(month, 2);
- break;
- case 'y':
- SKIP_JUNK();
- PARSE_NUMBER_N(year, 2);
- if (year >= 69)
- year += 1900;
- else
- year += 2000;
- break;
- case 'Y':
- SKIP_JUNK();
- PARSE_NUMBER_N(year, 4);
- break;
- case 'r':
- SKIP_JUNK();
- PARSE_NUMBER(year);
- if (year < 1000)
- {
- if (year >= 69)
- year += 1900;
- else
- year += 2000;
- }
- break;
- case 'H':
- case 'h':
- SKIP_JUNK();
- PARSE_NUMBER_N(hour, 2);
- break;
- case 'a':
- case 'A':
- hour = parseAMPM(it, end, hour);
- break;
- case 'M':
- SKIP_JUNK();
- PARSE_NUMBER_N(minute, 2);
- break;
- case 'S':
- SKIP_JUNK();
- PARSE_NUMBER_N(second, 2);
- break;
- case 's':
- SKIP_JUNK();
- PARSE_NUMBER_N(second, 2);
- if (it != end && (*it == '.' || *it == ','))
- {
- ++it;
- PARSE_FRACTIONAL_N(millis, 3);
- PARSE_FRACTIONAL_N(micros, 3);
- SKIP_DIGITS();
- }
- break;
- case 'i':
- SKIP_JUNK();
- PARSE_NUMBER_N(millis, 3);
- break;
- case 'c':
- SKIP_JUNK();
- PARSE_NUMBER_N(millis, 1);
- millis *= 100;
- break;
- case 'F':
- SKIP_JUNK();
- PARSE_FRACTIONAL_N(millis, 3);
- PARSE_FRACTIONAL_N(micros, 3);
- SKIP_DIGITS();
- break;
- case 'z':
- case 'Z':
- tzd = parseTZD(it, end);
- break;
- }
- ++itf;
- }
- }
- else ++itf;
- }
- if (month == 0) month = 1;
- 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);
+//
+// DateTimeParser.cpp
+//
+// Library: Foundation
+// Package: DateTime
+// Module: DateTimeParser
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/DateTimeParser.h"
+#include "Poco/DateTimeFormat.h"
+#include "Poco/DateTime.h"
+#include "Poco/Exception.h"
+#include "Poco/Ascii.h"
+
+
+namespace Poco {
+
+
+#define SKIP_JUNK() \
+ while (it != end && !Ascii::isDigit(*it)) ++it
+
+
+#define SKIP_DIGITS() \
+ while (it != end && Ascii::isDigit(*it)) ++it
+
+
+#define PARSE_NUMBER(var) \
+ while (it != end && Ascii::isDigit(*it)) var = var*10 + ((*it++) - '0')
+
+
+#define PARSE_NUMBER_N(var, n) \
+ { int i = 0; while (i++ < n && it != end && Ascii::isDigit(*it)) var = var*10 + ((*it++) - '0'); }
+
+
+#define PARSE_FRACTIONAL_N(var, n) \
+ { int i = 0; while (i < n && it != end && Ascii::isDigit(*it)) { var = var*10 + ((*it++) - '0'); i++; } while (i++ < n) var *= 10; }
+
+
+void DateTimeParser::parse(const std::string& fmt, const std::string& str, DateTime& dateTime, int& timeZoneDifferential)
+{
+ if (fmt.empty() || str.empty())
+ throw SyntaxException("Empty string.");
+
+ int year = 0;
+ int month = 0;
+ int day = 0;
+ int hour = 0;
+ int minute = 0;
+ int second = 0;
+ int millis = 0;
+ int micros = 0;
+ int tzd = 0;
+
+ std::string::const_iterator it = str.begin();
+ std::string::const_iterator end = str.end();
+ std::string::const_iterator itf = fmt.begin();
+ std::string::const_iterator endf = fmt.end();
+
+ while (itf != endf && it != end)
+ {
+ if (*itf == '%')
+ {
+ if (++itf != endf)
+ {
+ switch (*itf)
+ {
+ case 'w':
+ case 'W':
+ while (it != end && Ascii::isSpace(*it)) ++it;
+ while (it != end && Ascii::isAlpha(*it)) ++it;
+ break;
+ case 'b':
+ case 'B':
+ month = parseMonth(it, end);
+ break;
+ case 'd':
+ case 'e':
+ case 'f':
+ SKIP_JUNK();
+ PARSE_NUMBER_N(day, 2);
+ break;
+ case 'm':
+ case 'n':
+ case 'o':
+ SKIP_JUNK();
+ PARSE_NUMBER_N(month, 2);
+ break;
+ case 'y':
+ SKIP_JUNK();
+ PARSE_NUMBER_N(year, 2);
+ if (year >= 69)
+ year += 1900;
+ else
+ year += 2000;
+ break;
+ case 'Y':
+ SKIP_JUNK();
+ PARSE_NUMBER_N(year, 4);
+ break;
+ case 'r':
+ SKIP_JUNK();
+ PARSE_NUMBER(year);
+ if (year < 1000)
+ {
+ if (year >= 69)
+ year += 1900;
+ else
+ year += 2000;
+ }
+ break;
+ case 'H':
+ case 'h':
+ SKIP_JUNK();
+ PARSE_NUMBER_N(hour, 2);
+ break;
+ case 'a':
+ case 'A':
+ hour = parseAMPM(it, end, hour);
+ break;
+ case 'M':
+ SKIP_JUNK();
+ PARSE_NUMBER_N(minute, 2);
+ break;
+ case 'S':
+ SKIP_JUNK();
+ PARSE_NUMBER_N(second, 2);
+ break;
+ case 's':
+ SKIP_JUNK();
+ PARSE_NUMBER_N(second, 2);
+ if (it != end && (*it == '.' || *it == ','))
+ {
+ ++it;
+ PARSE_FRACTIONAL_N(millis, 3);
+ PARSE_FRACTIONAL_N(micros, 3);
+ SKIP_DIGITS();
+ }
+ break;
+ case 'i':
+ SKIP_JUNK();
+ PARSE_NUMBER_N(millis, 3);
+ break;
+ case 'c':
+ SKIP_JUNK();
+ PARSE_NUMBER_N(millis, 1);
+ millis *= 100;
+ break;
+ case 'F':
+ SKIP_JUNK();
+ PARSE_FRACTIONAL_N(millis, 3);
+ PARSE_FRACTIONAL_N(micros, 3);
+ SKIP_DIGITS();
+ break;
+ case 'z':
+ case 'Z':
+ tzd = parseTZD(it, end);
+ break;
+ }
+ ++itf;
+ }
+ }
+ else ++itf;
+ }
+ if (month == 0) month = 1;
+ 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
+ throw SyntaxException("date/time component out of range");
+ timeZoneDifferential = tzd;
+}
+
+
+DateTime DateTimeParser::parse(const std::string& fmt, const std::string& str, int& timeZoneDifferential)
+{
+ DateTime result;
+ parse(fmt, str, result, timeZoneDifferential);
+ return result;
+}
+
+
+bool DateTimeParser::tryParse(const std::string& fmt, const std::string& str, DateTime& dateTime, int& timeZoneDifferential)
+{
+ try
+ {
+ parse(fmt, str, dateTime, timeZoneDifferential);
+ }
+ catch (Exception&)
+ {
+ return false;
+ }
+ return true;
+}
+
+
+void DateTimeParser::parse(const std::string& str, DateTime& dateTime, int& timeZoneDifferential)
+{
+ if (!tryParse(str, dateTime, timeZoneDifferential))
+ throw SyntaxException("Unsupported or invalid date/time format");
+}
+
+
+DateTime DateTimeParser::parse(const std::string& str, int& timeZoneDifferential)
+{
+ DateTime result;
+ if (tryParse(str, result, timeZoneDifferential))
+ return result;
else
- throw SyntaxException("date/time component out of range");
- timeZoneDifferential = tzd;
-}
-
-
-DateTime DateTimeParser::parse(const std::string& fmt, const std::string& str, int& timeZoneDifferential)
-{
- DateTime result;
- parse(fmt, str, result, timeZoneDifferential);
- return result;
-}
-
-
-bool DateTimeParser::tryParse(const std::string& fmt, const std::string& str, DateTime& dateTime, int& timeZoneDifferential)
-{
- try
- {
- parse(fmt, str, dateTime, timeZoneDifferential);
- }
- catch (Exception&)
- {
- return false;
- }
- return true;
-}
-
-
-void DateTimeParser::parse(const std::string& str, DateTime& dateTime, int& timeZoneDifferential)
-{
- if (!tryParse(str, dateTime, timeZoneDifferential))
- throw SyntaxException("Unsupported or invalid date/time format");
-}
-
-
-DateTime DateTimeParser::parse(const std::string& str, int& timeZoneDifferential)
-{
- DateTime result;
- if (tryParse(str, result, timeZoneDifferential))
- return result;
- else
- 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] == ' ')
- return tryParse(DateTimeFormat::ASCTIME_FORMAT, str, dateTime, timeZoneDifferential);
- else if (str.find(',') < 10)
- return tryParse("%W, %e %b %r %H:%M:%S %Z", str, dateTime, timeZoneDifferential);
- else if (Ascii::isDigit(str[0]))
- {
- if (str.find(' ') != std::string::npos || str.length() == 10)
- return tryParse(DateTimeFormat::SORTABLE_FORMAT, str, dateTime, timeZoneDifferential);
- else if (str.find('.') != std::string::npos || str.find(',') != std::string::npos)
- return tryParse(DateTimeFormat::ISO8601_FRAC_FORMAT, str, dateTime, timeZoneDifferential);
- else
- return tryParse(DateTimeFormat::ISO8601_FORMAT, str, dateTime, timeZoneDifferential);
- }
- else return false;
-}
-
-
-int DateTimeParser::parseTZD(std::string::const_iterator& it, const std::string::const_iterator& end)
-{
- struct Zone
- {
- const char* designator;
- int timeZoneDifferential;
- };
-
- static Zone zones[] =
- {
- {"Z", 0},
- {"UT", 0},
- {"GMT", 0},
- {"BST", 1*3600},
- {"IST", 1*3600},
- {"WET", 0},
- {"WEST", 1*3600},
- {"CET", 1*3600},
- {"CEST", 2*3600},
- {"EET", 2*3600},
- {"EEST", 3*3600},
- {"MSK", 3*3600},
- {"MSD", 4*3600},
- {"NST", -3*3600-1800},
- {"NDT", -2*3600-1800},
- {"AST", -4*3600},
- {"ADT", -3*3600},
- {"EST", -5*3600},
- {"EDT", -4*3600},
- {"CST", -6*3600},
- {"CDT", -5*3600},
- {"MST", -7*3600},
- {"MDT", -6*3600},
- {"PST", -8*3600},
- {"PDT", -7*3600},
- {"AKST", -9*3600},
- {"AKDT", -8*3600},
- {"HST", -10*3600},
- {"AEST", 10*3600},
- {"AEDT", 11*3600},
- {"ACST", 9*3600+1800},
- {"ACDT", 10*3600+1800},
- {"AWST", 8*3600},
- {"AWDT", 9*3600}
- };
-
- int tzd = 0;
- while (it != end && Ascii::isSpace(*it)) ++it;
- if (it != end)
- {
- if (Ascii::isAlpha(*it))
- {
- std::string designator;
- designator += *it++;
- if (it != end && Ascii::isAlpha(*it)) designator += *it++;
- if (it != end && Ascii::isAlpha(*it)) designator += *it++;
- if (it != end && Ascii::isAlpha(*it)) designator += *it++;
- for (unsigned i = 0; i < sizeof(zones)/sizeof(Zone); ++i)
- {
- if (designator == zones[i].designator)
- {
- tzd = zones[i].timeZoneDifferential;
- break;
- }
- }
- }
- if (it != end && (*it == '+' || *it == '-'))
- {
- int sign = *it == '+' ? 1 : -1;
- ++it;
- int hours = 0;
- PARSE_NUMBER_N(hours, 2);
- if (it != end && *it == ':') ++it;
- int minutes = 0;
- PARSE_NUMBER_N(minutes, 2);
- tzd += sign*(hours*3600 + minutes*60);
- }
- }
- return tzd;
-}
-
-
-int DateTimeParser::parseMonth(std::string::const_iterator& it, const std::string::const_iterator& end)
-{
- std::string month;
- while (it != end && (Ascii::isSpace(*it) || Ascii::isPunct(*it))) ++it;
- bool isFirst = true;
- while (it != end && Ascii::isAlpha(*it))
- {
- char ch = (*it++);
- if (isFirst)
+ 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] == ' ')
+ return tryParse(DateTimeFormat::ASCTIME_FORMAT, str, dateTime, timeZoneDifferential);
+ else if (str.find(',') < 10)
+ return tryParse("%W, %e %b %r %H:%M:%S %Z", str, dateTime, timeZoneDifferential);
+ else if (Ascii::isDigit(str[0]))
+ {
+ if (str.find(' ') != std::string::npos || str.length() == 10)
+ return tryParse(DateTimeFormat::SORTABLE_FORMAT, str, dateTime, timeZoneDifferential);
+ else if (str.find('.') != std::string::npos || str.find(',') != std::string::npos)
+ return tryParse(DateTimeFormat::ISO8601_FRAC_FORMAT, str, dateTime, timeZoneDifferential);
+ else
+ return tryParse(DateTimeFormat::ISO8601_FORMAT, str, dateTime, timeZoneDifferential);
+ }
+ else return false;
+}
+
+
+int DateTimeParser::parseTZD(std::string::const_iterator& it, const std::string::const_iterator& end)
+{
+ struct Zone
+ {
+ const char* designator;
+ int timeZoneDifferential;
+ };
+
+ static Zone zones[] =
+ {
+ {"Z", 0},
+ {"UT", 0},
+ {"GMT", 0},
+ {"BST", 1*3600},
+ {"IST", 1*3600},
+ {"WET", 0},
+ {"WEST", 1*3600},
+ {"CET", 1*3600},
+ {"CEST", 2*3600},
+ {"EET", 2*3600},
+ {"EEST", 3*3600},
+ {"MSK", 3*3600},
+ {"MSD", 4*3600},
+ {"NST", -3*3600-1800},
+ {"NDT", -2*3600-1800},
+ {"AST", -4*3600},
+ {"ADT", -3*3600},
+ {"EST", -5*3600},
+ {"EDT", -4*3600},
+ {"CST", -6*3600},
+ {"CDT", -5*3600},
+ {"MST", -7*3600},
+ {"MDT", -6*3600},
+ {"PST", -8*3600},
+ {"PDT", -7*3600},
+ {"AKST", -9*3600},
+ {"AKDT", -8*3600},
+ {"HST", -10*3600},
+ {"AEST", 10*3600},
+ {"AEDT", 11*3600},
+ {"ACST", 9*3600+1800},
+ {"ACDT", 10*3600+1800},
+ {"AWST", 8*3600},
+ {"AWDT", 9*3600}
+ };
+
+ int tzd = 0;
+ while (it != end && Ascii::isSpace(*it)) ++it;
+ if (it != end)
+ {
+ if (Ascii::isAlpha(*it))
{
- month += static_cast<char>(Ascii::toUpper(ch));
- isFirst = false;
- }
- else month += static_cast<char>(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)
- {
- if (DateTimeFormat::MONTH_NAMES[i].find(month) == 0)
- return i + 1;
- }
- throw SyntaxException("Not a valid month name", month);
-}
-
-
-int DateTimeParser::parseDayOfWeek(std::string::const_iterator& it, const std::string::const_iterator& end)
-{
- std::string dow;
- while (it != end && (Ascii::isSpace(*it) || Ascii::isPunct(*it))) ++it;
- bool isFirst = true;
- while (it != end && Ascii::isAlpha(*it))
- {
- char ch = (*it++);
- if (isFirst)
+ std::string designator;
+ designator += *it++;
+ if (it != end && Ascii::isAlpha(*it)) designator += *it++;
+ if (it != end && Ascii::isAlpha(*it)) designator += *it++;
+ if (it != end && Ascii::isAlpha(*it)) designator += *it++;
+ for (unsigned i = 0; i < sizeof(zones)/sizeof(Zone); ++i)
+ {
+ if (designator == zones[i].designator)
+ {
+ tzd = zones[i].timeZoneDifferential;
+ break;
+ }
+ }
+ }
+ if (it != end && (*it == '+' || *it == '-'))
{
- dow += static_cast<char>(Ascii::toUpper(ch));
- isFirst = false;
- }
- else dow += static_cast<char>(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)
- {
- if (DateTimeFormat::WEEKDAY_NAMES[i].find(dow) == 0)
- return i;
- }
- throw SyntaxException("Not a valid weekday name", dow);
-}
-
-
-int DateTimeParser::parseAMPM(std::string::const_iterator& it, const std::string::const_iterator& end, int hour)
-{
- std::string ampm;
- while (it != end && (Ascii::isSpace(*it) || Ascii::isPunct(*it))) ++it;
- while (it != end && Ascii::isAlpha(*it))
- {
- char ch = (*it++);
- ampm += static_cast<char>(Ascii::toUpper(ch));
- }
- if (ampm == "AM")
- {
- if (hour == 12)
- return 0;
- else
- return hour;
- }
- else if (ampm == "PM")
- {
- if (hour < 12)
- return hour + 12;
- else
- return hour;
- }
- else throw SyntaxException("Not a valid AM/PM designator", ampm);
-}
-
-
-} // namespace Poco
+ int sign = *it == '+' ? 1 : -1;
+ ++it;
+ int hours = 0;
+ PARSE_NUMBER_N(hours, 2);
+ if (it != end && *it == ':') ++it;
+ int minutes = 0;
+ PARSE_NUMBER_N(minutes, 2);
+ tzd += sign*(hours*3600 + minutes*60);
+ }
+ }
+ return tzd;
+}
+
+
+int DateTimeParser::parseMonth(std::string::const_iterator& it, const std::string::const_iterator& end)
+{
+ std::string month;
+ while (it != end && (Ascii::isSpace(*it) || Ascii::isPunct(*it))) ++it;
+ bool isFirst = true;
+ while (it != end && Ascii::isAlpha(*it))
+ {
+ char ch = (*it++);
+ if (isFirst)
+ {
+ month += static_cast<char>(Ascii::toUpper(ch));
+ isFirst = false;
+ }
+ else month += static_cast<char>(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)
+ {
+ if (DateTimeFormat::MONTH_NAMES[i].find(month) == 0)
+ return i + 1;
+ }
+ throw SyntaxException("Not a valid month name", month);
+}
+
+
+int DateTimeParser::parseDayOfWeek(std::string::const_iterator& it, const std::string::const_iterator& end)
+{
+ std::string dow;
+ while (it != end && (Ascii::isSpace(*it) || Ascii::isPunct(*it))) ++it;
+ bool isFirst = true;
+ while (it != end && Ascii::isAlpha(*it))
+ {
+ char ch = (*it++);
+ if (isFirst)
+ {
+ dow += static_cast<char>(Ascii::toUpper(ch));
+ isFirst = false;
+ }
+ else dow += static_cast<char>(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)
+ {
+ if (DateTimeFormat::WEEKDAY_NAMES[i].find(dow) == 0)
+ return i;
+ }
+ throw SyntaxException("Not a valid weekday name", dow);
+}
+
+
+int DateTimeParser::parseAMPM(std::string::const_iterator& it, const std::string::const_iterator& end, int hour)
+{
+ std::string ampm;
+ while (it != end && (Ascii::isSpace(*it) || Ascii::isPunct(*it))) ++it;
+ while (it != end && Ascii::isAlpha(*it))
+ {
+ char ch = (*it++);
+ ampm += static_cast<char>(Ascii::toUpper(ch));
+ }
+ if (ampm == "AM")
+ {
+ if (hour == 12)
+ return 0;
+ else
+ return hour;
+ }
+ else if (ampm == "PM")
+ {
+ if (hour < 12)
+ return hour + 12;
+ else
+ return hour;
+ }
+ else throw SyntaxException("Not a valid AM/PM designator", ampm);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Debugger.cpp b/contrib/libs/poco/Foundation/src/Debugger.cpp
index c9efe5eac1..ac468212d9 100644
--- a/contrib/libs/poco/Foundation/src/Debugger.cpp
+++ b/contrib/libs/poco/Foundation/src/Debugger.cpp
@@ -1,150 +1,150 @@
-//
-// Debugger.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: Debugger
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Debugger.h"
-#include <sstream>
-#include <cstdlib>
-#include <cstdio>
-#if defined(POCO_OS_FAMILY_WINDOWS)
- #include "Poco/UnWindows.h"
-#elif defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_VXWORKS)
- #include <unistd.h>
- #include <signal.h>
-#endif
-#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
-#include "Poco/UnicodeConverter.h"
-#endif
-
-
-// NOTE: In this module, we use the C library functions (fputs) for,
-// output since, at the time we're called, the C++ iostream objects std::cout, etc.
-// might not have been initialized yet.
-
-
-namespace Poco {
-
-
-bool Debugger::isAvailable()
-{
-#if defined(_DEBUG)
- #if defined(POCO_OS_FAMILY_WINDOWS)
- #if defined(_WIN32_WCE)
- #if (_WIN32_WCE >= 0x600)
- BOOL isDebuggerPresent;
- if (CheckRemoteDebuggerPresent(GetCurrentProcess(), &isDebuggerPresent))
- {
- return isDebuggerPresent ? true : false;
- }
- return false;
- #else
- return false;
- #endif
- #else
- return IsDebuggerPresent() ? true : false;
- #endif
- #elif defined(POCO_VXWORKS)
- return false;
- #elif defined(POCO_OS_FAMILY_UNIX)
- return std::getenv("POCO_ENABLE_DEBUGGER") ? true : false;
- #endif
-#else
- return false;
-#endif
-}
-
-
-void Debugger::message(const std::string& msg)
-{
-#if defined(_DEBUG)
- std::fputs("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", stderr);
- std::fputs(msg.c_str(), stderr);
- std::fputs("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", stderr);
- #if defined(POCO_OS_FAMILY_WINDOWS)
- if (isAvailable())
- {
- #if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
- std::wstring umsg;
- UnicodeConverter::toUTF16(msg, umsg);
- umsg += '\n';
- OutputDebugStringW(umsg.c_str());
- #else
- OutputDebugStringA(msg.c_str());
- OutputDebugStringA("\n");
- #endif
- }
- #endif
-#endif
-}
-
-
-void Debugger::message(const std::string& msg, const char* file, int line)
-{
-#if defined(_DEBUG)
- std::ostringstream str;
- str << msg << " [in file \"" << file << "\", line " << line << "]";
- message(str.str());
-#endif
-}
-
-
-void Debugger::enter()
-{
-#if defined(_DEBUG)
- #if defined(POCO_OS_FAMILY_WINDOWS)
- if (isAvailable())
- {
- DebugBreak();
- }
- #elif defined(POCO_VXWORKS)
- {
- // not supported
- }
- #elif defined(POCO_OS_FAMILY_UNIX)
- if (isAvailable())
- {
- kill(getpid(), SIGINT);
- }
- #endif
-#endif
-}
-
-
-void Debugger::enter(const std::string& msg)
-{
-#if defined(_DEBUG)
- message(msg);
- enter();
-#endif
-}
-
-
-void Debugger::enter(const std::string& msg, const char* file, int line)
-{
-#if defined(_DEBUG)
- message(msg, file, line);
- enter();
-#endif
-}
-
-
-void Debugger::enter(const char* file, int line)
-{
-#if defined(_DEBUG)
- message("BREAK", file, line);
- enter();
-#endif
-}
-
-
-} // namespace Poco
+//
+// Debugger.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: Debugger
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Debugger.h"
+#include <sstream>
+#include <cstdlib>
+#include <cstdio>
+#if defined(POCO_OS_FAMILY_WINDOWS)
+ #include "Poco/UnWindows.h"
+#elif defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_VXWORKS)
+ #include <unistd.h>
+ #include <signal.h>
+#endif
+#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
+#include "Poco/UnicodeConverter.h"
+#endif
+
+
+// NOTE: In this module, we use the C library functions (fputs) for,
+// output since, at the time we're called, the C++ iostream objects std::cout, etc.
+// might not have been initialized yet.
+
+
+namespace Poco {
+
+
+bool Debugger::isAvailable()
+{
+#if defined(_DEBUG)
+ #if defined(POCO_OS_FAMILY_WINDOWS)
+ #if defined(_WIN32_WCE)
+ #if (_WIN32_WCE >= 0x600)
+ BOOL isDebuggerPresent;
+ if (CheckRemoteDebuggerPresent(GetCurrentProcess(), &isDebuggerPresent))
+ {
+ return isDebuggerPresent ? true : false;
+ }
+ return false;
+ #else
+ return false;
+ #endif
+ #else
+ return IsDebuggerPresent() ? true : false;
+ #endif
+ #elif defined(POCO_VXWORKS)
+ return false;
+ #elif defined(POCO_OS_FAMILY_UNIX)
+ return std::getenv("POCO_ENABLE_DEBUGGER") ? true : false;
+ #endif
+#else
+ return false;
+#endif
+}
+
+
+void Debugger::message(const std::string& msg)
+{
+#if defined(_DEBUG)
+ std::fputs("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", stderr);
+ std::fputs(msg.c_str(), stderr);
+ std::fputs("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", stderr);
+ #if defined(POCO_OS_FAMILY_WINDOWS)
+ if (isAvailable())
+ {
+ #if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
+ std::wstring umsg;
+ UnicodeConverter::toUTF16(msg, umsg);
+ umsg += '\n';
+ OutputDebugStringW(umsg.c_str());
+ #else
+ OutputDebugStringA(msg.c_str());
+ OutputDebugStringA("\n");
+ #endif
+ }
+ #endif
+#endif
+}
+
+
+void Debugger::message(const std::string& msg, const char* file, int line)
+{
+#if defined(_DEBUG)
+ std::ostringstream str;
+ str << msg << " [in file \"" << file << "\", line " << line << "]";
+ message(str.str());
+#endif
+}
+
+
+void Debugger::enter()
+{
+#if defined(_DEBUG)
+ #if defined(POCO_OS_FAMILY_WINDOWS)
+ if (isAvailable())
+ {
+ DebugBreak();
+ }
+ #elif defined(POCO_VXWORKS)
+ {
+ // not supported
+ }
+ #elif defined(POCO_OS_FAMILY_UNIX)
+ if (isAvailable())
+ {
+ kill(getpid(), SIGINT);
+ }
+ #endif
+#endif
+}
+
+
+void Debugger::enter(const std::string& msg)
+{
+#if defined(_DEBUG)
+ message(msg);
+ enter();
+#endif
+}
+
+
+void Debugger::enter(const std::string& msg, const char* file, int line)
+{
+#if defined(_DEBUG)
+ message(msg, file, line);
+ enter();
+#endif
+}
+
+
+void Debugger::enter(const char* file, int line)
+{
+#if defined(_DEBUG)
+ message("BREAK", file, line);
+ enter();
+#endif
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/DeflatingStream.cpp b/contrib/libs/poco/Foundation/src/DeflatingStream.cpp
index 7349118354..130b8cf066 100644
--- a/contrib/libs/poco/Foundation/src/DeflatingStream.cpp
+++ b/contrib/libs/poco/Foundation/src/DeflatingStream.cpp
@@ -1,390 +1,390 @@
-//
-// DeflatingStream.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: ZLibStream
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/DeflatingStream.h"
-#include "Poco/Exception.h"
-
-
-namespace Poco {
-
-
-DeflatingStreamBuf::DeflatingStreamBuf(std::istream& istr, StreamType type, int level):
- BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::in),
- _pIstr(&istr),
- _pOstr(0),
- _eof(false)
-{
- _zstr.next_in = 0;
- _zstr.avail_in = 0;
- _zstr.total_in = 0;
- _zstr.next_out = 0;
- _zstr.avail_out = 0;
- _zstr.total_out = 0;
- _zstr.msg = 0;
- _zstr.state = 0;
- _zstr.zalloc = Z_NULL;
- _zstr.zfree = Z_NULL;
- _zstr.opaque = Z_NULL;
- _zstr.data_type = 0;
- _zstr.adler = 0;
- _zstr.reserved = 0;
-
- _buffer = new char[DEFLATE_BUFFER_SIZE];
-
- int rc = deflateInit2(&_zstr, level, Z_DEFLATED, 15 + (type == STREAM_GZIP ? 16 : 0), 8, Z_DEFAULT_STRATEGY);
- if (rc != Z_OK)
- {
- delete [] _buffer;
- throw IOException(zError(rc));
- }
-}
-
-
-DeflatingStreamBuf::DeflatingStreamBuf(std::istream& istr, int windowBits, int level):
- BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::in),
- _pIstr(&istr),
- _pOstr(0),
- _eof(false)
-{
- _zstr.zalloc = Z_NULL;
- _zstr.zfree = Z_NULL;
- _zstr.opaque = Z_NULL;
- _zstr.next_in = 0;
- _zstr.avail_in = 0;
- _zstr.next_out = 0;
- _zstr.avail_out = 0;
-
- _buffer = new char[DEFLATE_BUFFER_SIZE];
-
- int rc = deflateInit2(&_zstr, level, Z_DEFLATED, windowBits, 8, Z_DEFAULT_STRATEGY);
- if (rc != Z_OK)
- {
- delete [] _buffer;
- throw IOException(zError(rc));
- }
-}
-
-
-DeflatingStreamBuf::DeflatingStreamBuf(std::ostream& ostr, StreamType type, int level):
- BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::out),
- _pIstr(0),
- _pOstr(&ostr),
- _eof(false)
-{
- _zstr.zalloc = Z_NULL;
- _zstr.zfree = Z_NULL;
- _zstr.opaque = Z_NULL;
- _zstr.next_in = 0;
- _zstr.avail_in = 0;
- _zstr.next_out = 0;
- _zstr.avail_out = 0;
-
- _buffer = new char[DEFLATE_BUFFER_SIZE];
-
- int rc = deflateInit2(&_zstr, level, Z_DEFLATED, 15 + (type == STREAM_GZIP ? 16 : 0), 8, Z_DEFAULT_STRATEGY);
- if (rc != Z_OK)
- {
- delete [] _buffer;
- throw IOException(zError(rc));
- }
-}
-
-
-DeflatingStreamBuf::DeflatingStreamBuf(std::ostream& ostr, int windowBits, int level):
- BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::out),
- _pIstr(0),
- _pOstr(&ostr),
- _eof(false)
-{
- _zstr.zalloc = Z_NULL;
- _zstr.zfree = Z_NULL;
- _zstr.opaque = Z_NULL;
- _zstr.next_in = 0;
- _zstr.avail_in = 0;
- _zstr.next_out = 0;
- _zstr.avail_out = 0;
-
- _buffer = new char[DEFLATE_BUFFER_SIZE];
-
- int rc = deflateInit2(&_zstr, level, Z_DEFLATED, windowBits, 8, Z_DEFAULT_STRATEGY);
- if (rc != Z_OK)
- {
- delete [] _buffer;
- throw IOException(zError(rc));
- }
-}
-
-
-DeflatingStreamBuf::~DeflatingStreamBuf()
-{
- try
- {
- close();
- }
- catch (...)
- {
- }
- delete [] _buffer;
- deflateEnd(&_zstr);
-}
-
-
-int DeflatingStreamBuf::close()
-{
- BufferedStreamBuf::sync();
- _pIstr = 0;
- if (_pOstr)
- {
- if (_zstr.next_out)
- {
- int rc = deflate(&_zstr, Z_FINISH);
- if (rc != Z_OK && rc != Z_STREAM_END) throw IOException(zError(rc));
- _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out);
- if (!_pOstr->good()) throw IOException(zError(rc));
- _zstr.next_out = (unsigned char*) _buffer;
- _zstr.avail_out = DEFLATE_BUFFER_SIZE;
- while (rc != Z_STREAM_END)
- {
- rc = deflate(&_zstr, Z_FINISH);
- if (rc != Z_OK && rc != Z_STREAM_END) throw IOException(zError(rc));
- _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out);
- if (!_pOstr->good()) throw IOException(zError(rc));
- _zstr.next_out = (unsigned char*) _buffer;
- _zstr.avail_out = DEFLATE_BUFFER_SIZE;
- }
- }
- _pOstr->flush();
- _pOstr = 0;
- }
- return 0;
-}
-
-
-int DeflatingStreamBuf::sync()
-{
- if (BufferedStreamBuf::sync())
- return -1;
-
- if (_pOstr)
- {
- if (_zstr.next_out)
- {
- int rc = deflate(&_zstr, Z_SYNC_FLUSH);
- if (rc != Z_OK) throw IOException(zError(rc));
- _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out);
- if (!_pOstr->good()) throw IOException(zError(rc));
- while (_zstr.avail_out == 0)
- {
- _zstr.next_out = (unsigned char*) _buffer;
- _zstr.avail_out = DEFLATE_BUFFER_SIZE;
- rc = deflate(&_zstr, Z_SYNC_FLUSH);
- if (rc != Z_OK) throw IOException(zError(rc));
- _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out);
- if (!_pOstr->good()) throw IOException(zError(rc));
- };
- _zstr.next_out = (unsigned char*) _buffer;
- _zstr.avail_out = DEFLATE_BUFFER_SIZE;
- }
- // NOTE: This breaks the Zip library and causes corruption in some files.
- // See GH #1828
- // _pOstr->flush();
- }
- return 0;
-}
-
-
-int DeflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length)
-{
- if (!_pIstr) return 0;
- if (_zstr.avail_in == 0 && !_eof)
- {
- int n = 0;
- if (_pIstr->good())
- {
- _pIstr->read(_buffer, DEFLATE_BUFFER_SIZE);
- n = static_cast<int>(_pIstr->gcount());
- }
- if (n > 0)
- {
- _zstr.next_in = (unsigned char*) _buffer;
- _zstr.avail_in = n;
- }
- else
- {
- _zstr.next_in = 0;
- _zstr.avail_in = 0;
- _eof = true;
- }
- }
- _zstr.next_out = (unsigned char*) buffer;
- _zstr.avail_out = static_cast<unsigned>(length);
- for (;;)
- {
- int rc = deflate(&_zstr, _eof ? Z_FINISH : Z_NO_FLUSH);
- if (_eof && rc == Z_STREAM_END)
- {
- _pIstr = 0;
- return static_cast<int>(length) - _zstr.avail_out;
- }
- if (rc != Z_OK) throw IOException(zError(rc));
- if (_zstr.avail_out == 0)
- {
- return static_cast<int>(length);
- }
- if (_zstr.avail_in == 0)
- {
- int n = 0;
- if (_pIstr->good())
- {
- _pIstr->read(_buffer, DEFLATE_BUFFER_SIZE);
- n = static_cast<int>(_pIstr->gcount());
- }
- if (n > 0)
- {
- _zstr.next_in = (unsigned char*) _buffer;
- _zstr.avail_in = n;
- }
- else
- {
- _zstr.next_in = 0;
- _zstr.avail_in = 0;
- _eof = true;
- }
- }
- }
-}
-
-
-int DeflatingStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
-{
- if (length == 0 || !_pOstr) return 0;
-
- _zstr.next_in = (unsigned char*) buffer;
- _zstr.avail_in = static_cast<unsigned>(length);
- _zstr.next_out = (unsigned char*) _buffer;
- _zstr.avail_out = DEFLATE_BUFFER_SIZE;
- for (;;)
- {
- int rc = deflate(&_zstr, Z_NO_FLUSH);
- if (rc != Z_OK) throw IOException(zError(rc));
- if (_zstr.avail_out == 0)
- {
- _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE);
- if (!_pOstr->good()) throw IOException(zError(rc));
- _zstr.next_out = (unsigned char*) _buffer;
- _zstr.avail_out = DEFLATE_BUFFER_SIZE;
- }
- if (_zstr.avail_in == 0)
- {
- _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out);
- if (!_pOstr->good()) throw IOException(zError(rc));
- _zstr.next_out = (unsigned char*) _buffer;
- _zstr.avail_out = DEFLATE_BUFFER_SIZE;
- break;
- }
- }
- return static_cast<int>(length);
-}
-
-
-DeflatingIOS::DeflatingIOS(std::ostream& ostr, DeflatingStreamBuf::StreamType type, int level):
- _buf(ostr, type, level)
-{
- poco_ios_init(&_buf);
-}
-
-
-DeflatingIOS::DeflatingIOS(std::ostream& ostr, int windowBits, int level):
- _buf(ostr, windowBits, level)
-{
- poco_ios_init(&_buf);
-}
-
-
-DeflatingIOS::DeflatingIOS(std::istream& istr, DeflatingStreamBuf::StreamType type, int level):
- _buf(istr, type, level)
-{
- poco_ios_init(&_buf);
-}
-
-
-DeflatingIOS::DeflatingIOS(std::istream& istr, int windowBits, int level):
- _buf(istr, windowBits, level)
-{
- poco_ios_init(&_buf);
-}
-
-
-DeflatingIOS::~DeflatingIOS()
-{
-}
-
-
-DeflatingStreamBuf* DeflatingIOS::rdbuf()
-{
- return &_buf;
-}
-
-
-DeflatingOutputStream::DeflatingOutputStream(std::ostream& ostr, DeflatingStreamBuf::StreamType type, int level):
- std::ostream(&_buf),
- DeflatingIOS(ostr, type, level)
-{
-}
-
-
-DeflatingOutputStream::DeflatingOutputStream(std::ostream& ostr, int windowBits, int level):
- std::ostream(&_buf),
- DeflatingIOS(ostr, windowBits, level)
-{
-}
-
-
-DeflatingOutputStream::~DeflatingOutputStream()
-{
-}
-
-
-int DeflatingOutputStream::close()
-{
- return _buf.close();
-}
-
-
-int DeflatingOutputStream::sync()
-{
- return _buf.pubsync();
-}
-
-
-DeflatingInputStream::DeflatingInputStream(std::istream& istr, DeflatingStreamBuf::StreamType type, int level):
- std::istream(&_buf),
- DeflatingIOS(istr, type, level)
-{
-}
-
-
-DeflatingInputStream::DeflatingInputStream(std::istream& istr, int windowBits, int level):
- std::istream(&_buf),
- DeflatingIOS(istr, windowBits, level)
-{
-}
-
-
-DeflatingInputStream::~DeflatingInputStream()
-{
-}
-
-
-} // namespace Poco
+//
+// DeflatingStream.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: ZLibStream
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/DeflatingStream.h"
+#include "Poco/Exception.h"
+
+
+namespace Poco {
+
+
+DeflatingStreamBuf::DeflatingStreamBuf(std::istream& istr, StreamType type, int level):
+ BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::in),
+ _pIstr(&istr),
+ _pOstr(0),
+ _eof(false)
+{
+ _zstr.next_in = 0;
+ _zstr.avail_in = 0;
+ _zstr.total_in = 0;
+ _zstr.next_out = 0;
+ _zstr.avail_out = 0;
+ _zstr.total_out = 0;
+ _zstr.msg = 0;
+ _zstr.state = 0;
+ _zstr.zalloc = Z_NULL;
+ _zstr.zfree = Z_NULL;
+ _zstr.opaque = Z_NULL;
+ _zstr.data_type = 0;
+ _zstr.adler = 0;
+ _zstr.reserved = 0;
+
+ _buffer = new char[DEFLATE_BUFFER_SIZE];
+
+ int rc = deflateInit2(&_zstr, level, Z_DEFLATED, 15 + (type == STREAM_GZIP ? 16 : 0), 8, Z_DEFAULT_STRATEGY);
+ if (rc != Z_OK)
+ {
+ delete [] _buffer;
+ throw IOException(zError(rc));
+ }
+}
+
+
+DeflatingStreamBuf::DeflatingStreamBuf(std::istream& istr, int windowBits, int level):
+ BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::in),
+ _pIstr(&istr),
+ _pOstr(0),
+ _eof(false)
+{
+ _zstr.zalloc = Z_NULL;
+ _zstr.zfree = Z_NULL;
+ _zstr.opaque = Z_NULL;
+ _zstr.next_in = 0;
+ _zstr.avail_in = 0;
+ _zstr.next_out = 0;
+ _zstr.avail_out = 0;
+
+ _buffer = new char[DEFLATE_BUFFER_SIZE];
+
+ int rc = deflateInit2(&_zstr, level, Z_DEFLATED, windowBits, 8, Z_DEFAULT_STRATEGY);
+ if (rc != Z_OK)
+ {
+ delete [] _buffer;
+ throw IOException(zError(rc));
+ }
+}
+
+
+DeflatingStreamBuf::DeflatingStreamBuf(std::ostream& ostr, StreamType type, int level):
+ BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::out),
+ _pIstr(0),
+ _pOstr(&ostr),
+ _eof(false)
+{
+ _zstr.zalloc = Z_NULL;
+ _zstr.zfree = Z_NULL;
+ _zstr.opaque = Z_NULL;
+ _zstr.next_in = 0;
+ _zstr.avail_in = 0;
+ _zstr.next_out = 0;
+ _zstr.avail_out = 0;
+
+ _buffer = new char[DEFLATE_BUFFER_SIZE];
+
+ int rc = deflateInit2(&_zstr, level, Z_DEFLATED, 15 + (type == STREAM_GZIP ? 16 : 0), 8, Z_DEFAULT_STRATEGY);
+ if (rc != Z_OK)
+ {
+ delete [] _buffer;
+ throw IOException(zError(rc));
+ }
+}
+
+
+DeflatingStreamBuf::DeflatingStreamBuf(std::ostream& ostr, int windowBits, int level):
+ BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::out),
+ _pIstr(0),
+ _pOstr(&ostr),
+ _eof(false)
+{
+ _zstr.zalloc = Z_NULL;
+ _zstr.zfree = Z_NULL;
+ _zstr.opaque = Z_NULL;
+ _zstr.next_in = 0;
+ _zstr.avail_in = 0;
+ _zstr.next_out = 0;
+ _zstr.avail_out = 0;
+
+ _buffer = new char[DEFLATE_BUFFER_SIZE];
+
+ int rc = deflateInit2(&_zstr, level, Z_DEFLATED, windowBits, 8, Z_DEFAULT_STRATEGY);
+ if (rc != Z_OK)
+ {
+ delete [] _buffer;
+ throw IOException(zError(rc));
+ }
+}
+
+
+DeflatingStreamBuf::~DeflatingStreamBuf()
+{
+ try
+ {
+ close();
+ }
+ catch (...)
+ {
+ }
+ delete [] _buffer;
+ deflateEnd(&_zstr);
+}
+
+
+int DeflatingStreamBuf::close()
+{
+ BufferedStreamBuf::sync();
+ _pIstr = 0;
+ if (_pOstr)
+ {
+ if (_zstr.next_out)
+ {
+ int rc = deflate(&_zstr, Z_FINISH);
+ if (rc != Z_OK && rc != Z_STREAM_END) throw IOException(zError(rc));
+ _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out);
+ if (!_pOstr->good()) throw IOException(zError(rc));
+ _zstr.next_out = (unsigned char*) _buffer;
+ _zstr.avail_out = DEFLATE_BUFFER_SIZE;
+ while (rc != Z_STREAM_END)
+ {
+ rc = deflate(&_zstr, Z_FINISH);
+ if (rc != Z_OK && rc != Z_STREAM_END) throw IOException(zError(rc));
+ _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out);
+ if (!_pOstr->good()) throw IOException(zError(rc));
+ _zstr.next_out = (unsigned char*) _buffer;
+ _zstr.avail_out = DEFLATE_BUFFER_SIZE;
+ }
+ }
+ _pOstr->flush();
+ _pOstr = 0;
+ }
+ return 0;
+}
+
+
+int DeflatingStreamBuf::sync()
+{
+ if (BufferedStreamBuf::sync())
+ return -1;
+
+ if (_pOstr)
+ {
+ if (_zstr.next_out)
+ {
+ int rc = deflate(&_zstr, Z_SYNC_FLUSH);
+ if (rc != Z_OK) throw IOException(zError(rc));
+ _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out);
+ if (!_pOstr->good()) throw IOException(zError(rc));
+ while (_zstr.avail_out == 0)
+ {
+ _zstr.next_out = (unsigned char*) _buffer;
+ _zstr.avail_out = DEFLATE_BUFFER_SIZE;
+ rc = deflate(&_zstr, Z_SYNC_FLUSH);
+ if (rc != Z_OK) throw IOException(zError(rc));
+ _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out);
+ if (!_pOstr->good()) throw IOException(zError(rc));
+ };
+ _zstr.next_out = (unsigned char*) _buffer;
+ _zstr.avail_out = DEFLATE_BUFFER_SIZE;
+ }
+ // NOTE: This breaks the Zip library and causes corruption in some files.
+ // See GH #1828
+ // _pOstr->flush();
+ }
+ return 0;
+}
+
+
+int DeflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length)
+{
+ if (!_pIstr) return 0;
+ if (_zstr.avail_in == 0 && !_eof)
+ {
+ int n = 0;
+ if (_pIstr->good())
+ {
+ _pIstr->read(_buffer, DEFLATE_BUFFER_SIZE);
+ n = static_cast<int>(_pIstr->gcount());
+ }
+ if (n > 0)
+ {
+ _zstr.next_in = (unsigned char*) _buffer;
+ _zstr.avail_in = n;
+ }
+ else
+ {
+ _zstr.next_in = 0;
+ _zstr.avail_in = 0;
+ _eof = true;
+ }
+ }
+ _zstr.next_out = (unsigned char*) buffer;
+ _zstr.avail_out = static_cast<unsigned>(length);
+ for (;;)
+ {
+ int rc = deflate(&_zstr, _eof ? Z_FINISH : Z_NO_FLUSH);
+ if (_eof && rc == Z_STREAM_END)
+ {
+ _pIstr = 0;
+ return static_cast<int>(length) - _zstr.avail_out;
+ }
+ if (rc != Z_OK) throw IOException(zError(rc));
+ if (_zstr.avail_out == 0)
+ {
+ return static_cast<int>(length);
+ }
+ if (_zstr.avail_in == 0)
+ {
+ int n = 0;
+ if (_pIstr->good())
+ {
+ _pIstr->read(_buffer, DEFLATE_BUFFER_SIZE);
+ n = static_cast<int>(_pIstr->gcount());
+ }
+ if (n > 0)
+ {
+ _zstr.next_in = (unsigned char*) _buffer;
+ _zstr.avail_in = n;
+ }
+ else
+ {
+ _zstr.next_in = 0;
+ _zstr.avail_in = 0;
+ _eof = true;
+ }
+ }
+ }
+}
+
+
+int DeflatingStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
+{
+ if (length == 0 || !_pOstr) return 0;
+
+ _zstr.next_in = (unsigned char*) buffer;
+ _zstr.avail_in = static_cast<unsigned>(length);
+ _zstr.next_out = (unsigned char*) _buffer;
+ _zstr.avail_out = DEFLATE_BUFFER_SIZE;
+ for (;;)
+ {
+ int rc = deflate(&_zstr, Z_NO_FLUSH);
+ if (rc != Z_OK) throw IOException(zError(rc));
+ if (_zstr.avail_out == 0)
+ {
+ _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE);
+ if (!_pOstr->good()) throw IOException(zError(rc));
+ _zstr.next_out = (unsigned char*) _buffer;
+ _zstr.avail_out = DEFLATE_BUFFER_SIZE;
+ }
+ if (_zstr.avail_in == 0)
+ {
+ _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out);
+ if (!_pOstr->good()) throw IOException(zError(rc));
+ _zstr.next_out = (unsigned char*) _buffer;
+ _zstr.avail_out = DEFLATE_BUFFER_SIZE;
+ break;
+ }
+ }
+ return static_cast<int>(length);
+}
+
+
+DeflatingIOS::DeflatingIOS(std::ostream& ostr, DeflatingStreamBuf::StreamType type, int level):
+ _buf(ostr, type, level)
+{
+ poco_ios_init(&_buf);
+}
+
+
+DeflatingIOS::DeflatingIOS(std::ostream& ostr, int windowBits, int level):
+ _buf(ostr, windowBits, level)
+{
+ poco_ios_init(&_buf);
+}
+
+
+DeflatingIOS::DeflatingIOS(std::istream& istr, DeflatingStreamBuf::StreamType type, int level):
+ _buf(istr, type, level)
+{
+ poco_ios_init(&_buf);
+}
+
+
+DeflatingIOS::DeflatingIOS(std::istream& istr, int windowBits, int level):
+ _buf(istr, windowBits, level)
+{
+ poco_ios_init(&_buf);
+}
+
+
+DeflatingIOS::~DeflatingIOS()
+{
+}
+
+
+DeflatingStreamBuf* DeflatingIOS::rdbuf()
+{
+ return &_buf;
+}
+
+
+DeflatingOutputStream::DeflatingOutputStream(std::ostream& ostr, DeflatingStreamBuf::StreamType type, int level):
+ std::ostream(&_buf),
+ DeflatingIOS(ostr, type, level)
+{
+}
+
+
+DeflatingOutputStream::DeflatingOutputStream(std::ostream& ostr, int windowBits, int level):
+ std::ostream(&_buf),
+ DeflatingIOS(ostr, windowBits, level)
+{
+}
+
+
+DeflatingOutputStream::~DeflatingOutputStream()
+{
+}
+
+
+int DeflatingOutputStream::close()
+{
+ return _buf.close();
+}
+
+
+int DeflatingOutputStream::sync()
+{
+ return _buf.pubsync();
+}
+
+
+DeflatingInputStream::DeflatingInputStream(std::istream& istr, DeflatingStreamBuf::StreamType type, int level):
+ std::istream(&_buf),
+ DeflatingIOS(istr, type, level)
+{
+}
+
+
+DeflatingInputStream::DeflatingInputStream(std::istream& istr, int windowBits, int level):
+ std::istream(&_buf),
+ DeflatingIOS(istr, windowBits, level)
+{
+}
+
+
+DeflatingInputStream::~DeflatingInputStream()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/DigestEngine.cpp b/contrib/libs/poco/Foundation/src/DigestEngine.cpp
index 2c01eb6b87..307bdb1924 100644
--- a/contrib/libs/poco/Foundation/src/DigestEngine.cpp
+++ b/contrib/libs/poco/Foundation/src/DigestEngine.cpp
@@ -1,99 +1,99 @@
-//
-// DigestEngine.cpp
-//
-// Library: Foundation
-// Package: Crypt
-// Module: DigestEngine
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/DigestEngine.h"
-#include "Poco/Exception.h"
-
-
-namespace Poco
-{
-
-DigestEngine::DigestEngine()
-{
-}
-
-
-DigestEngine::~DigestEngine()
-{
-}
-
-
-std::string DigestEngine::digestToHex(const Digest& bytes)
-{
- static const char digits[] = "0123456789abcdef";
- std::string result;
- result.reserve(bytes.size() * 2);
- for (Digest::const_iterator it = bytes.begin(); it != bytes.end(); ++it)
- {
- unsigned char c = *it;
- result += digits[(c >> 4) & 0xF];
- result += digits[c & 0xF];
- }
- return result;
-}
-
-
-DigestEngine::Digest DigestEngine::digestFromHex(const std::string& digest)
-{
- if (digest.size() % 2 != 0)
- throw DataFormatException();
- Digest result;
- result.reserve(digest.size() / 2);
- for (std::size_t i = 0; i < digest.size(); ++i)
- {
- int c = 0;
- // first upper 4 bits
- if (digest[i] >= '0' && digest[i] <= '9')
- c = digest[i] - '0';
- else if (digest[i] >= 'a' && digest[i] <= 'f')
- c = digest[i] - 'a' + 10;
- else if (digest[i] >= 'A' && digest[i] <= 'F')
- c = digest[i] - 'A' + 10;
- else
- throw DataFormatException();
- c <<= 4;
- ++i;
- if (digest[i] >= '0' && digest[i] <= '9')
- c += digest[i] - '0';
- else if (digest[i] >= 'a' && digest[i] <= 'f')
- c += digest[i] - 'a' + 10;
- else if (digest[i] >= 'A' && digest[i] <= 'F')
- c += digest[i] - 'A' + 10;
- else
- throw DataFormatException();
-
- result.push_back(static_cast<unsigned char>(c));
- }
- return result;
-}
-
-
-bool DigestEngine::constantTimeEquals(const Digest& d1, const Digest& d2)
-{
- if (d1.size() != d2.size()) return false;
-
- int result = 0;
- Digest::const_iterator it1 = d1.begin();
- Digest::const_iterator it2 = d2.begin();
- Digest::const_iterator end1 = d1.end();
- while (it1 != end1)
- {
- result |= *it1++ ^ *it2++;
- }
- return result == 0;
-}
-
-
-} // namespace Poco
-
+//
+// DigestEngine.cpp
+//
+// Library: Foundation
+// Package: Crypt
+// Module: DigestEngine
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/DigestEngine.h"
+#include "Poco/Exception.h"
+
+
+namespace Poco
+{
+
+DigestEngine::DigestEngine()
+{
+}
+
+
+DigestEngine::~DigestEngine()
+{
+}
+
+
+std::string DigestEngine::digestToHex(const Digest& bytes)
+{
+ static const char digits[] = "0123456789abcdef";
+ std::string result;
+ result.reserve(bytes.size() * 2);
+ for (Digest::const_iterator it = bytes.begin(); it != bytes.end(); ++it)
+ {
+ unsigned char c = *it;
+ result += digits[(c >> 4) & 0xF];
+ result += digits[c & 0xF];
+ }
+ return result;
+}
+
+
+DigestEngine::Digest DigestEngine::digestFromHex(const std::string& digest)
+{
+ if (digest.size() % 2 != 0)
+ throw DataFormatException();
+ Digest result;
+ result.reserve(digest.size() / 2);
+ for (std::size_t i = 0; i < digest.size(); ++i)
+ {
+ int c = 0;
+ // first upper 4 bits
+ if (digest[i] >= '0' && digest[i] <= '9')
+ c = digest[i] - '0';
+ else if (digest[i] >= 'a' && digest[i] <= 'f')
+ c = digest[i] - 'a' + 10;
+ else if (digest[i] >= 'A' && digest[i] <= 'F')
+ c = digest[i] - 'A' + 10;
+ else
+ throw DataFormatException();
+ c <<= 4;
+ ++i;
+ if (digest[i] >= '0' && digest[i] <= '9')
+ c += digest[i] - '0';
+ else if (digest[i] >= 'a' && digest[i] <= 'f')
+ c += digest[i] - 'a' + 10;
+ else if (digest[i] >= 'A' && digest[i] <= 'F')
+ c += digest[i] - 'A' + 10;
+ else
+ throw DataFormatException();
+
+ result.push_back(static_cast<unsigned char>(c));
+ }
+ return result;
+}
+
+
+bool DigestEngine::constantTimeEquals(const Digest& d1, const Digest& d2)
+{
+ if (d1.size() != d2.size()) return false;
+
+ int result = 0;
+ Digest::const_iterator it1 = d1.begin();
+ Digest::const_iterator it2 = d2.begin();
+ Digest::const_iterator end1 = d1.end();
+ while (it1 != end1)
+ {
+ result |= *it1++ ^ *it2++;
+ }
+ return result == 0;
+}
+
+
+} // namespace Poco
+
diff --git a/contrib/libs/poco/Foundation/src/DigestStream.cpp b/contrib/libs/poco/Foundation/src/DigestStream.cpp
index c5ec7b23bc..7946d9775a 100644
--- a/contrib/libs/poco/Foundation/src/DigestStream.cpp
+++ b/contrib/libs/poco/Foundation/src/DigestStream.cpp
@@ -1,150 +1,150 @@
-//
-// DigestStream.cpp
-//
-// Library: Foundation
-// Package: Crypt
-// Module: DigestStream
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/DigestStream.h"
-
-
-namespace Poco {
-
-
-const int DigestBuf::BUFFER_SIZE = 256;
-
-
-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),
+//
+// DigestStream.cpp
+//
+// Library: Foundation
+// Package: Crypt
+// Module: DigestStream
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/DigestStream.h"
+
+
+namespace Poco {
+
+
+const int DigestBuf::BUFFER_SIZE = 256;
+
+
+DigestBuf::DigestBuf(DigestEngine& eng):
+ BufferedStreamBuf(BUFFER_SIZE, std::ios::out),
+ _eng(eng),
_pIstr(0),
- _pOstr(&ostr)
-{
-}
-
-
-DigestBuf::~DigestBuf()
-{
-}
-
-
-int DigestBuf::readFromDevice(char* buffer, std::streamsize length)
-{
- if (_pIstr && _pIstr->good())
- {
- _pIstr->read(buffer, length);
- std::streamsize n = _pIstr->gcount();
- if (n > 0) _eng.update(buffer, static_cast<unsigned>(n));
- return static_cast<int>(n);
- }
- return -1;
-}
-
-
-int DigestBuf::writeToDevice(const char* buffer, std::streamsize length)
-{
- _eng.update(buffer, (unsigned) length);
- if (_pOstr) _pOstr->write(buffer, length);
- return static_cast<int>(length);
-}
-
-
-void DigestBuf::close()
-{
- sync();
- if (_pOstr) _pOstr->flush();
-}
-
-
-DigestIOS::DigestIOS(DigestEngine& eng): _buf(eng)
-{
- poco_ios_init(&_buf);
-}
-
-
-DigestIOS::DigestIOS(DigestEngine& eng, std::istream& istr): _buf(eng, istr)
-{
- poco_ios_init(&_buf);
-}
-
-
-DigestIOS::DigestIOS(DigestEngine& eng, std::ostream& ostr): _buf(eng, ostr)
-{
- poco_ios_init(&_buf);
-}
-
-
-DigestIOS::~DigestIOS()
-{
-}
-
-
-DigestBuf* DigestIOS::rdbuf()
-{
- return &_buf;
-}
-
-
-DigestInputStream::DigestInputStream(DigestEngine& eng, std::istream& istr):
- DigestIOS(eng, istr),
- std::istream(&_buf)
-{
-}
-
-
-DigestInputStream::~DigestInputStream()
-{
-}
-
-
-DigestOutputStream::DigestOutputStream(DigestEngine& eng):
- DigestIOS(eng),
- std::ostream(&_buf)
-{
-}
-
-
-DigestOutputStream::DigestOutputStream(DigestEngine& eng, std::ostream& ostr):
- DigestIOS(eng, ostr),
- std::ostream(&_buf)
-{
-}
-
-
-DigestOutputStream::~DigestOutputStream()
-{
-}
-
-
-void DigestOutputStream::close()
-{
- _buf.close();
-}
-
-
-} // namespace Poco
+ _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),
+ _pOstr(&ostr)
+{
+}
+
+
+DigestBuf::~DigestBuf()
+{
+}
+
+
+int DigestBuf::readFromDevice(char* buffer, std::streamsize length)
+{
+ if (_pIstr && _pIstr->good())
+ {
+ _pIstr->read(buffer, length);
+ std::streamsize n = _pIstr->gcount();
+ if (n > 0) _eng.update(buffer, static_cast<unsigned>(n));
+ return static_cast<int>(n);
+ }
+ return -1;
+}
+
+
+int DigestBuf::writeToDevice(const char* buffer, std::streamsize length)
+{
+ _eng.update(buffer, (unsigned) length);
+ if (_pOstr) _pOstr->write(buffer, length);
+ return static_cast<int>(length);
+}
+
+
+void DigestBuf::close()
+{
+ sync();
+ if (_pOstr) _pOstr->flush();
+}
+
+
+DigestIOS::DigestIOS(DigestEngine& eng): _buf(eng)
+{
+ poco_ios_init(&_buf);
+}
+
+
+DigestIOS::DigestIOS(DigestEngine& eng, std::istream& istr): _buf(eng, istr)
+{
+ poco_ios_init(&_buf);
+}
+
+
+DigestIOS::DigestIOS(DigestEngine& eng, std::ostream& ostr): _buf(eng, ostr)
+{
+ poco_ios_init(&_buf);
+}
+
+
+DigestIOS::~DigestIOS()
+{
+}
+
+
+DigestBuf* DigestIOS::rdbuf()
+{
+ return &_buf;
+}
+
+
+DigestInputStream::DigestInputStream(DigestEngine& eng, std::istream& istr):
+ DigestIOS(eng, istr),
+ std::istream(&_buf)
+{
+}
+
+
+DigestInputStream::~DigestInputStream()
+{
+}
+
+
+DigestOutputStream::DigestOutputStream(DigestEngine& eng):
+ DigestIOS(eng),
+ std::ostream(&_buf)
+{
+}
+
+
+DigestOutputStream::DigestOutputStream(DigestEngine& eng, std::ostream& ostr):
+ DigestIOS(eng, ostr),
+ std::ostream(&_buf)
+{
+}
+
+
+DigestOutputStream::~DigestOutputStream()
+{
+}
+
+
+void DigestOutputStream::close()
+{
+ _buf.close();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/DirectoryIterator.cpp b/contrib/libs/poco/Foundation/src/DirectoryIterator.cpp
index 115770a73a..cb07c3d321 100644
--- a/contrib/libs/poco/Foundation/src/DirectoryIterator.cpp
+++ b/contrib/libs/poco/Foundation/src/DirectoryIterator.cpp
@@ -1,145 +1,145 @@
-//
-// DirectoryIterator.cpp
-//
-// Library: Foundation
-// Package: Filesystem
-// Module: DirectoryIterator
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/DirectoryIterator.h"
-
-
-#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
-#include "DirectoryIterator_WIN32U.cpp"
-#elif defined(POCO_OS_FAMILY_WINDOWS)
-#include "DirectoryIterator_WIN32.cpp"
-#elif defined(POCO_OS_FAMILY_UNIX)
-#include "DirectoryIterator_UNIX.cpp"
-#endif
-
-
-namespace Poco {
-
-
-DirectoryIterator::DirectoryIterator(): _pImpl(0)
-{
-}
-
-
-DirectoryIterator::DirectoryIterator(const std::string& pathString): _path(pathString), _pImpl(new DirectoryIteratorImpl(pathString))
-{
- _path.makeDirectory();
- _path.setFileName(_pImpl->get());
- _file = _path;
-}
-
-
-DirectoryIterator::DirectoryIterator(const DirectoryIterator& iterator): _path(iterator._path), _pImpl(iterator._pImpl)
-{
- if (_pImpl)
- {
- _pImpl->duplicate();
- _file = _path;
- }
-}
-
-
-DirectoryIterator::DirectoryIterator(const File& file): _path(file.path()), _pImpl(new DirectoryIteratorImpl(file.path()))
-{
- _path.makeDirectory();
- _path.setFileName(_pImpl->get());
- _file = _path;
-}
-
-
-DirectoryIterator::DirectoryIterator(const Path& otherPath): _path(otherPath), _pImpl(new DirectoryIteratorImpl(otherPath.toString()))
-{
- _path.makeDirectory();
- _path.setFileName(_pImpl->get());
- _file = _path;
-}
-
-
-DirectoryIterator::~DirectoryIterator()
-{
- if (_pImpl) _pImpl->release();
-}
-
-
-DirectoryIterator& DirectoryIterator::operator = (const DirectoryIterator& it)
-{
- if (_pImpl) _pImpl->release();
- _pImpl = it._pImpl;
- if (_pImpl)
- {
- _pImpl->duplicate();
- _path = it._path;
- _file = _path;
- }
- return *this;
-}
-
-
-DirectoryIterator& DirectoryIterator::operator = (const File& file)
-{
- if (_pImpl) _pImpl->release();
- _pImpl = new DirectoryIteratorImpl(file.path());
- _path.parseDirectory(file.path());
- _path.setFileName(_pImpl->get());
- _file = _path;
- return *this;
-}
-
-
-DirectoryIterator& DirectoryIterator::operator = (const Path& otherPath)
-{
- if (_pImpl) _pImpl->release();
- _pImpl = new DirectoryIteratorImpl(otherPath.toString());
- _path = otherPath;
- _path.makeDirectory();
- _path.setFileName(_pImpl->get());
- _file = _path;
- return *this;
-}
-
-
-DirectoryIterator& DirectoryIterator::operator = (const std::string& pathString)
-{
- if (_pImpl) _pImpl->release();
- _pImpl = new DirectoryIteratorImpl(pathString);
- _path.parseDirectory(pathString);
- _path.setFileName(_pImpl->get());
- _file = _path;
- return *this;
-}
-
-
-DirectoryIterator& DirectoryIterator::operator ++ ()
-{
- if (_pImpl)
- {
- _path.setFileName(_pImpl->next());
- _file = _path;
- }
- return *this;
-}
-
-
-DirectoryIterator DirectoryIterator::operator ++ (int /*dummy*/)
-{
- if (_pImpl)
- {
- _path.setFileName(_pImpl->next());
- _file = _path;
- }
- return *this;
-}
-
-
-} // namespace Poco
+//
+// DirectoryIterator.cpp
+//
+// Library: Foundation
+// Package: Filesystem
+// Module: DirectoryIterator
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/DirectoryIterator.h"
+
+
+#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
+#include "DirectoryIterator_WIN32U.cpp"
+#elif defined(POCO_OS_FAMILY_WINDOWS)
+#include "DirectoryIterator_WIN32.cpp"
+#elif defined(POCO_OS_FAMILY_UNIX)
+#include "DirectoryIterator_UNIX.cpp"
+#endif
+
+
+namespace Poco {
+
+
+DirectoryIterator::DirectoryIterator(): _pImpl(0)
+{
+}
+
+
+DirectoryIterator::DirectoryIterator(const std::string& pathString): _path(pathString), _pImpl(new DirectoryIteratorImpl(pathString))
+{
+ _path.makeDirectory();
+ _path.setFileName(_pImpl->get());
+ _file = _path;
+}
+
+
+DirectoryIterator::DirectoryIterator(const DirectoryIterator& iterator): _path(iterator._path), _pImpl(iterator._pImpl)
+{
+ if (_pImpl)
+ {
+ _pImpl->duplicate();
+ _file = _path;
+ }
+}
+
+
+DirectoryIterator::DirectoryIterator(const File& file): _path(file.path()), _pImpl(new DirectoryIteratorImpl(file.path()))
+{
+ _path.makeDirectory();
+ _path.setFileName(_pImpl->get());
+ _file = _path;
+}
+
+
+DirectoryIterator::DirectoryIterator(const Path& otherPath): _path(otherPath), _pImpl(new DirectoryIteratorImpl(otherPath.toString()))
+{
+ _path.makeDirectory();
+ _path.setFileName(_pImpl->get());
+ _file = _path;
+}
+
+
+DirectoryIterator::~DirectoryIterator()
+{
+ if (_pImpl) _pImpl->release();
+}
+
+
+DirectoryIterator& DirectoryIterator::operator = (const DirectoryIterator& it)
+{
+ if (_pImpl) _pImpl->release();
+ _pImpl = it._pImpl;
+ if (_pImpl)
+ {
+ _pImpl->duplicate();
+ _path = it._path;
+ _file = _path;
+ }
+ return *this;
+}
+
+
+DirectoryIterator& DirectoryIterator::operator = (const File& file)
+{
+ if (_pImpl) _pImpl->release();
+ _pImpl = new DirectoryIteratorImpl(file.path());
+ _path.parseDirectory(file.path());
+ _path.setFileName(_pImpl->get());
+ _file = _path;
+ return *this;
+}
+
+
+DirectoryIterator& DirectoryIterator::operator = (const Path& otherPath)
+{
+ if (_pImpl) _pImpl->release();
+ _pImpl = new DirectoryIteratorImpl(otherPath.toString());
+ _path = otherPath;
+ _path.makeDirectory();
+ _path.setFileName(_pImpl->get());
+ _file = _path;
+ return *this;
+}
+
+
+DirectoryIterator& DirectoryIterator::operator = (const std::string& pathString)
+{
+ if (_pImpl) _pImpl->release();
+ _pImpl = new DirectoryIteratorImpl(pathString);
+ _path.parseDirectory(pathString);
+ _path.setFileName(_pImpl->get());
+ _file = _path;
+ return *this;
+}
+
+
+DirectoryIterator& DirectoryIterator::operator ++ ()
+{
+ if (_pImpl)
+ {
+ _path.setFileName(_pImpl->next());
+ _file = _path;
+ }
+ return *this;
+}
+
+
+DirectoryIterator DirectoryIterator::operator ++ (int /*dummy*/)
+{
+ if (_pImpl)
+ {
+ _path.setFileName(_pImpl->next());
+ _file = _path;
+ }
+ return *this;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/DirectoryIteratorStrategy.cpp b/contrib/libs/poco/Foundation/src/DirectoryIteratorStrategy.cpp
index 21c9755bb4..57a5b36c4e 100644
--- a/contrib/libs/poco/Foundation/src/DirectoryIteratorStrategy.cpp
+++ b/contrib/libs/poco/Foundation/src/DirectoryIteratorStrategy.cpp
@@ -1,168 +1,168 @@
-//
-// RecursiveDirectoryIteratorStategies.cpp
-//
-// Library: Foundation
-// Package: Filesystem
-// Module: RecursiveDirectoryIterator
-//
-// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/DirectoryIteratorStrategy.h"
-
-
-namespace Poco {
-
-
-//
-// TraverseBase
-//
-TraverseBase::TraverseBase(DepthFunPtr depthDeterminer, UInt16 maxDepth)
- : _depthDeterminer(depthDeterminer), _maxDepth(maxDepth)
-{
-}
-
-
-inline bool TraverseBase::isFiniteDepth()
-{
- return _maxDepth != D_INFINITE;
-}
-
-
-bool TraverseBase::isDirectory(Poco::File& file)
-{
- try
- {
- return file.isDirectory();
- }
- catch (...)
- {
- return false;
- }
-}
-
-
-//
-// ChildrenFirstTraverse
-//
-ChildrenFirstTraverse::ChildrenFirstTraverse(DepthFunPtr depthDeterminer, UInt16 maxDepth)
- : TraverseBase(depthDeterminer, maxDepth)
-{
-}
-
-
-const std::string ChildrenFirstTraverse::next(Stack* itStack, bool* isFinished)
-{
- // pointer mustn't point to NULL and iteration mustn't be finished
- poco_check_ptr(isFinished);
- poco_assert(!(*isFinished));
-
- std::stack<DirectoryIterator> it;
-
- //_depthDeterminer(it);
-
- // go deeper into not empty directory
- // (if depth limit allows)
- bool isDepthLimitReached = isFiniteDepth() && _depthDeterminer(*itStack) >= _maxDepth;
- if (!isDepthLimitReached && isDirectory(*itStack->top()))
- {
- DirectoryIterator child_it(itStack->top().path());
- // check if directory is empty
- if (child_it != _itEnd)
- {
- itStack->push(child_it);
- return child_it->path();
- }
- }
-
- ++(itStack->top());
-
- poco_assert(!itStack->empty());
- // return up until there isn't right sibling
- while (itStack->top() == _itEnd)
- {
- itStack->pop();
-
- // detect end of traversal
- if (itStack->empty())
- {
- *isFinished = true;
- return _itEnd->path();
- }
- else
- {
- ++(itStack->top());
- }
- }
-
- return itStack->top()->path();
-}
-
-
-//
-// SiblingsFirstTraverse
-//
-SiblingsFirstTraverse::SiblingsFirstTraverse(DepthFunPtr depthDeterminer, UInt16 maxDepth)
- : TraverseBase(depthDeterminer, maxDepth)
-{
- _dirsStack.push(std::queue<std::string>());
-}
-
-
-const std::string SiblingsFirstTraverse::next(Stack* itStack, bool* isFinished)
-{
- // pointer mustn't point to NULL and iteration mustn't be finished
- poco_check_ptr(isFinished);
- poco_assert(!(*isFinished));
-
- // add dirs to queue (if depth limit allows)
- bool isDepthLimitReached = isFiniteDepth() && _depthDeterminer(*itStack) >= _maxDepth;
- if (!isDepthLimitReached && isDirectory(*itStack->top()))
- {
- const std::string& p = itStack->top()->path();
- _dirsStack.top().push(p);
- }
-
- ++(itStack->top());
-
- poco_assert(!itStack->empty());
- // return up until there isn't right sibling
- while (itStack->top() == _itEnd)
- {
- // try to find first not empty directory and go deeper
- while (!_dirsStack.top().empty())
- {
- std::string dir = _dirsStack.top().front();
- _dirsStack.top().pop();
- DirectoryIterator child_it(dir);
-
- // check if directory is empty
- if (child_it != _itEnd)
- {
- itStack->push(child_it);
- _dirsStack.push(std::queue<std::string>());
- return child_it->path();
- }
- }
-
- // if fail go upper
- itStack->pop();
- _dirsStack.pop();
-
- // detect end of traversal
- if (itStack->empty())
- {
- *isFinished = true;
- return _itEnd->path();
- }
- }
-
- return itStack->top()->path();
-}
-
-
-} // namespace Poco
+//
+// RecursiveDirectoryIteratorStategies.cpp
+//
+// Library: Foundation
+// Package: Filesystem
+// Module: RecursiveDirectoryIterator
+//
+// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/DirectoryIteratorStrategy.h"
+
+
+namespace Poco {
+
+
+//
+// TraverseBase
+//
+TraverseBase::TraverseBase(DepthFunPtr depthDeterminer, UInt16 maxDepth)
+ : _depthDeterminer(depthDeterminer), _maxDepth(maxDepth)
+{
+}
+
+
+inline bool TraverseBase::isFiniteDepth()
+{
+ return _maxDepth != D_INFINITE;
+}
+
+
+bool TraverseBase::isDirectory(Poco::File& file)
+{
+ try
+ {
+ return file.isDirectory();
+ }
+ catch (...)
+ {
+ return false;
+ }
+}
+
+
+//
+// ChildrenFirstTraverse
+//
+ChildrenFirstTraverse::ChildrenFirstTraverse(DepthFunPtr depthDeterminer, UInt16 maxDepth)
+ : TraverseBase(depthDeterminer, maxDepth)
+{
+}
+
+
+const std::string ChildrenFirstTraverse::next(Stack* itStack, bool* isFinished)
+{
+ // pointer mustn't point to NULL and iteration mustn't be finished
+ poco_check_ptr(isFinished);
+ poco_assert(!(*isFinished));
+
+ std::stack<DirectoryIterator> it;
+
+ //_depthDeterminer(it);
+
+ // go deeper into not empty directory
+ // (if depth limit allows)
+ bool isDepthLimitReached = isFiniteDepth() && _depthDeterminer(*itStack) >= _maxDepth;
+ if (!isDepthLimitReached && isDirectory(*itStack->top()))
+ {
+ DirectoryIterator child_it(itStack->top().path());
+ // check if directory is empty
+ if (child_it != _itEnd)
+ {
+ itStack->push(child_it);
+ return child_it->path();
+ }
+ }
+
+ ++(itStack->top());
+
+ poco_assert(!itStack->empty());
+ // return up until there isn't right sibling
+ while (itStack->top() == _itEnd)
+ {
+ itStack->pop();
+
+ // detect end of traversal
+ if (itStack->empty())
+ {
+ *isFinished = true;
+ return _itEnd->path();
+ }
+ else
+ {
+ ++(itStack->top());
+ }
+ }
+
+ return itStack->top()->path();
+}
+
+
+//
+// SiblingsFirstTraverse
+//
+SiblingsFirstTraverse::SiblingsFirstTraverse(DepthFunPtr depthDeterminer, UInt16 maxDepth)
+ : TraverseBase(depthDeterminer, maxDepth)
+{
+ _dirsStack.push(std::queue<std::string>());
+}
+
+
+const std::string SiblingsFirstTraverse::next(Stack* itStack, bool* isFinished)
+{
+ // pointer mustn't point to NULL and iteration mustn't be finished
+ poco_check_ptr(isFinished);
+ poco_assert(!(*isFinished));
+
+ // add dirs to queue (if depth limit allows)
+ bool isDepthLimitReached = isFiniteDepth() && _depthDeterminer(*itStack) >= _maxDepth;
+ if (!isDepthLimitReached && isDirectory(*itStack->top()))
+ {
+ const std::string& p = itStack->top()->path();
+ _dirsStack.top().push(p);
+ }
+
+ ++(itStack->top());
+
+ poco_assert(!itStack->empty());
+ // return up until there isn't right sibling
+ while (itStack->top() == _itEnd)
+ {
+ // try to find first not empty directory and go deeper
+ while (!_dirsStack.top().empty())
+ {
+ std::string dir = _dirsStack.top().front();
+ _dirsStack.top().pop();
+ DirectoryIterator child_it(dir);
+
+ // check if directory is empty
+ if (child_it != _itEnd)
+ {
+ itStack->push(child_it);
+ _dirsStack.push(std::queue<std::string>());
+ return child_it->path();
+ }
+ }
+
+ // if fail go upper
+ itStack->pop();
+ _dirsStack.pop();
+
+ // detect end of traversal
+ if (itStack->empty())
+ {
+ *isFinished = true;
+ return _itEnd->path();
+ }
+ }
+
+ return itStack->top()->path();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/DirectoryIterator_UNIX.cpp b/contrib/libs/poco/Foundation/src/DirectoryIterator_UNIX.cpp
index 16be5051ea..d16bbafa4b 100644
--- a/contrib/libs/poco/Foundation/src/DirectoryIterator_UNIX.cpp
+++ b/contrib/libs/poco/Foundation/src/DirectoryIterator_UNIX.cpp
@@ -1,64 +1,64 @@
-//
-// DirectoryIterator_UNIX.cpp
-//
-// Library: Foundation
-// Package: Filesystem
-// Module: DirectoryIterator
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/DirectoryIterator_UNIX.h"
-#if defined(POCO_VXWORKS)
-#include "Poco/File_VX.h"
-#else
-#include "Poco/File_UNIX.h"
-#endif
-#include "Poco/Path.h"
-
-
-namespace Poco {
-
-
-DirectoryIteratorImpl::DirectoryIteratorImpl(const std::string& path): _pDir(0), _rc(1)
-{
- Path p(path);
- p.makeFile();
-
-#if defined(POCO_VXWORKS)
- _pDir = opendir(const_cast<char*>(p.toString().c_str()));
-#else
- _pDir = opendir(p.toString().c_str());
-#endif
- if (!_pDir) File::handleLastError(path);
-
- next();
-}
-
-
-DirectoryIteratorImpl::~DirectoryIteratorImpl()
-{
- if (_pDir) closedir(_pDir);
-}
-
-
-const std::string& DirectoryIteratorImpl::next()
-{
- do
- {
- struct dirent* pEntry = readdir(_pDir);
- if (pEntry)
- _current = pEntry->d_name;
- else
- _current.clear();
- }
- while (_current == "." || _current == "..");
- return _current;
-}
-
-
-} // namespace Poco
+//
+// DirectoryIterator_UNIX.cpp
+//
+// Library: Foundation
+// Package: Filesystem
+// Module: DirectoryIterator
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/DirectoryIterator_UNIX.h"
+#if defined(POCO_VXWORKS)
+#include "Poco/File_VX.h"
+#else
+#include "Poco/File_UNIX.h"
+#endif
+#include "Poco/Path.h"
+
+
+namespace Poco {
+
+
+DirectoryIteratorImpl::DirectoryIteratorImpl(const std::string& path): _pDir(0), _rc(1)
+{
+ Path p(path);
+ p.makeFile();
+
+#if defined(POCO_VXWORKS)
+ _pDir = opendir(const_cast<char*>(p.toString().c_str()));
+#else
+ _pDir = opendir(p.toString().c_str());
+#endif
+ if (!_pDir) File::handleLastError(path);
+
+ next();
+}
+
+
+DirectoryIteratorImpl::~DirectoryIteratorImpl()
+{
+ if (_pDir) closedir(_pDir);
+}
+
+
+const std::string& DirectoryIteratorImpl::next()
+{
+ do
+ {
+ struct dirent* pEntry = readdir(_pDir);
+ if (pEntry)
+ _current = pEntry->d_name;
+ else
+ _current.clear();
+ }
+ while (_current == "." || _current == "..");
+ return _current;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/DirectoryIterator_WIN32.cpp b/contrib/libs/poco/Foundation/src/DirectoryIterator_WIN32.cpp
index e7ebfc859b..d296e4afb3 100644
--- a/contrib/libs/poco/Foundation/src/DirectoryIterator_WIN32.cpp
+++ b/contrib/libs/poco/Foundation/src/DirectoryIterator_WIN32.cpp
@@ -1,66 +1,66 @@
-//
-// DirectoryIterator_WIN32.cpp
-//
-// Library: Foundation
-// Package: Filesystem
-// Module: DirectoryIterator
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/DirectoryIterator_WIN32.h"
-#include "Poco/File_WIN32.h"
-#include "Poco/Path.h"
-
-
-namespace Poco {
-
-
-DirectoryIteratorImpl::DirectoryIteratorImpl(const std::string& path): _fh(INVALID_HANDLE_VALUE), _rc(1)
-{
- Path p(path);
- p.makeDirectory();
- std::string findPath = p.toString();
- findPath.append("*");
-
- _fh = FindFirstFile(findPath.c_str(), &_fd);
- if (_fh == INVALID_HANDLE_VALUE)
- {
- if (GetLastError() != ERROR_NO_MORE_FILES)
- File::handleLastError(path);
- }
- else
- {
- _current = _fd.cFileName;
- if (_current == "." || _current == "..")
- next();
- }
-}
-
-
-DirectoryIteratorImpl::~DirectoryIteratorImpl()
-{
- if (_fh != INVALID_HANDLE_VALUE)
- FindClose(_fh);
-}
-
-
-const std::string& DirectoryIteratorImpl::next()
-{
- do
- {
- if (FindNextFile(_fh, &_fd) != 0)
- _current = _fd.cFileName;
- else
- _current.clear();
- }
- while (_current == "." || _current == "..");
- return _current;
-}
-
-
-} // namespace Poco
+//
+// DirectoryIterator_WIN32.cpp
+//
+// Library: Foundation
+// Package: Filesystem
+// Module: DirectoryIterator
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/DirectoryIterator_WIN32.h"
+#include "Poco/File_WIN32.h"
+#include "Poco/Path.h"
+
+
+namespace Poco {
+
+
+DirectoryIteratorImpl::DirectoryIteratorImpl(const std::string& path): _fh(INVALID_HANDLE_VALUE), _rc(1)
+{
+ Path p(path);
+ p.makeDirectory();
+ std::string findPath = p.toString();
+ findPath.append("*");
+
+ _fh = FindFirstFile(findPath.c_str(), &_fd);
+ if (_fh == INVALID_HANDLE_VALUE)
+ {
+ if (GetLastError() != ERROR_NO_MORE_FILES)
+ File::handleLastError(path);
+ }
+ else
+ {
+ _current = _fd.cFileName;
+ if (_current == "." || _current == "..")
+ next();
+ }
+}
+
+
+DirectoryIteratorImpl::~DirectoryIteratorImpl()
+{
+ if (_fh != INVALID_HANDLE_VALUE)
+ FindClose(_fh);
+}
+
+
+const std::string& DirectoryIteratorImpl::next()
+{
+ do
+ {
+ if (FindNextFile(_fh, &_fd) != 0)
+ _current = _fd.cFileName;
+ else
+ _current.clear();
+ }
+ while (_current == "." || _current == "..");
+ return _current;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/DirectoryIterator_WIN32U.cpp b/contrib/libs/poco/Foundation/src/DirectoryIterator_WIN32U.cpp
index 8f17bc3144..18d7d6aed7 100644
--- a/contrib/libs/poco/Foundation/src/DirectoryIterator_WIN32U.cpp
+++ b/contrib/libs/poco/Foundation/src/DirectoryIterator_WIN32U.cpp
@@ -1,75 +1,75 @@
-//
-// DirectoryIterator_WIN32U.cpp
-//
-// Library: Foundation
-// Package: Filesystem
-// Module: DirectoryIterator
-//
-// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/DirectoryIterator_WIN32U.h"
-#if defined(_WIN32_WCE)
-#include "Poco/File_WINCE.h"
-#else
-#include "Poco/File_WIN32U.h"
-#endif
-#include "Poco/Path.h"
-#include "Poco/UnicodeConverter.h"
-#include <cstring>
-
-
-namespace Poco {
-
-
-DirectoryIteratorImpl::DirectoryIteratorImpl(const std::string& path): _fh(INVALID_HANDLE_VALUE), _rc(1)
-{
- Path p(path);
- p.makeDirectory();
- std::string findPath = p.toString();
- findPath.append("*");
- std::wstring uFindPath;
- FileImpl::convertPath(findPath, uFindPath);
-
- _fh = FindFirstFileW(uFindPath.c_str(), &_fd);
- if (_fh == INVALID_HANDLE_VALUE)
- {
- if (GetLastError() != ERROR_NO_MORE_FILES)
- File::handleLastError(path);
- }
- else
- {
- UnicodeConverter::toUTF8(_fd.cFileName, _current);
- if (_current == "." || _current == "..")
- next();
- }
-}
-
-
-DirectoryIteratorImpl::~DirectoryIteratorImpl()
-{
- if (_fh != INVALID_HANDLE_VALUE)
- FindClose(_fh);
-}
-
-
-const std::string& DirectoryIteratorImpl::next()
-{
- do
- {
- _current.clear();
- if (FindNextFileW(_fh, &_fd) != 0)
- {
- UnicodeConverter::toUTF8(_fd.cFileName, _current);
- }
- }
- while (_current == "." || _current == "..");
- return _current;
-}
-
-
-} // namespace Poco
+//
+// DirectoryIterator_WIN32U.cpp
+//
+// Library: Foundation
+// Package: Filesystem
+// Module: DirectoryIterator
+//
+// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/DirectoryIterator_WIN32U.h"
+#if defined(_WIN32_WCE)
+#include "Poco/File_WINCE.h"
+#else
+#include "Poco/File_WIN32U.h"
+#endif
+#include "Poco/Path.h"
+#include "Poco/UnicodeConverter.h"
+#include <cstring>
+
+
+namespace Poco {
+
+
+DirectoryIteratorImpl::DirectoryIteratorImpl(const std::string& path): _fh(INVALID_HANDLE_VALUE), _rc(1)
+{
+ Path p(path);
+ p.makeDirectory();
+ std::string findPath = p.toString();
+ findPath.append("*");
+ std::wstring uFindPath;
+ FileImpl::convertPath(findPath, uFindPath);
+
+ _fh = FindFirstFileW(uFindPath.c_str(), &_fd);
+ if (_fh == INVALID_HANDLE_VALUE)
+ {
+ if (GetLastError() != ERROR_NO_MORE_FILES)
+ File::handleLastError(path);
+ }
+ else
+ {
+ UnicodeConverter::toUTF8(_fd.cFileName, _current);
+ if (_current == "." || _current == "..")
+ next();
+ }
+}
+
+
+DirectoryIteratorImpl::~DirectoryIteratorImpl()
+{
+ if (_fh != INVALID_HANDLE_VALUE)
+ FindClose(_fh);
+}
+
+
+const std::string& DirectoryIteratorImpl::next()
+{
+ do
+ {
+ _current.clear();
+ if (FindNextFileW(_fh, &_fd) != 0)
+ {
+ UnicodeConverter::toUTF8(_fd.cFileName, _current);
+ }
+ }
+ while (_current == "." || _current == "..");
+ return _current;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/DirectoryWatcher.cpp b/contrib/libs/poco/Foundation/src/DirectoryWatcher.cpp
index e939e9c295..49b57087dc 100644
--- a/contrib/libs/poco/Foundation/src/DirectoryWatcher.cpp
+++ b/contrib/libs/poco/Foundation/src/DirectoryWatcher.cpp
@@ -1,608 +1,608 @@
-//
-// DirectoryWatcher.cpp
-//
-// Library: Foundation
-// Package: Filesystem
-// Module: DirectoryWatcher
-//
-// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/DirectoryWatcher.h"
-
-
-#ifndef POCO_NO_INOTIFY
-
-
-#include "Poco/Path.h"
-#include "Poco/Glob.h"
-#include "Poco/DirectoryIterator.h"
-#include "Poco/Event.h"
-#include "Poco/Exception.h"
-#include "Poco/Buffer.h"
-#if POCO_OS == POCO_OS_LINUX || POCO_OS == POCO_OS_ANDROID
- #include <sys/inotify.h>
- #include <sys/select.h>
- #include <unistd.h>
-#elif POCO_OS == POCO_OS_MAC_OS_X || POCO_OS == POCO_OS_FREE_BSD
- #include <fcntl.h>
- #include <sys/types.h>
- #include <sys/event.h>
- #include <sys/time.h>
- #include <unistd.h>
- #if (POCO_OS == POCO_OS_FREE_BSD) && !defined(O_EVTONLY)
- #define O_EVTONLY 0x8000
- #endif
-#endif
-#include <algorithm>
-#include <map>
-
-
-namespace Poco {
-
-
-class DirectoryWatcherStrategy
-{
-public:
- DirectoryWatcherStrategy(DirectoryWatcher& ownerWatcher):
- _owner(ownerWatcher)
- {
- }
-
- virtual ~DirectoryWatcherStrategy()
- {
- }
-
- DirectoryWatcher& owner()
- {
- return _owner;
- }
-
- virtual void run() = 0;
- virtual void stop() = 0;
- virtual bool supportsMoveEvents() const = 0;
-
-protected:
- struct ItemInfo
- {
- ItemInfo():
- 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;
- };
- typedef std::map<std::string, ItemInfo> ItemInfoMap;
-
- void scan(ItemInfoMap& entries)
- {
- DirectoryIterator it(owner().directory());
- DirectoryIterator end;
- while (it != end)
- {
- entries[it.path().getFileName()] = ItemInfo(*it);
- ++it;
- }
- }
-
- void compare(ItemInfoMap& oldEntries, ItemInfoMap& newEntries)
- {
- for (ItemInfoMap::iterator itn = newEntries.begin(); itn != newEntries.end(); ++itn)
- {
- ItemInfoMap::iterator ito = oldEntries.find(itn->first);
- if (ito != oldEntries.end())
- {
- if ((owner().eventMask() & DirectoryWatcher::DW_ITEM_MODIFIED) && !owner().eventsSuspended())
- {
- if (itn->second.size != ito->second.size || itn->second.lastModified != ito->second.lastModified)
- {
- Poco::File f(itn->second.path);
- DirectoryWatcher::DirectoryEvent ev(f, DirectoryWatcher::DW_ITEM_MODIFIED);
- owner().itemModified(&owner(), ev);
- }
- }
- oldEntries.erase(ito);
- }
- else if ((owner().eventMask() & DirectoryWatcher::DW_ITEM_ADDED) && !owner().eventsSuspended())
- {
- Poco::File f(itn->second.path);
- DirectoryWatcher::DirectoryEvent ev(f, DirectoryWatcher::DW_ITEM_ADDED);
- owner().itemAdded(&owner(), ev);
- }
- }
- if ((owner().eventMask() & DirectoryWatcher::DW_ITEM_REMOVED) && !owner().eventsSuspended())
- {
- for (ItemInfoMap::iterator it = oldEntries.begin(); it != oldEntries.end(); ++it)
- {
- Poco::File f(it->second.path);
- DirectoryWatcher::DirectoryEvent ev(f, DirectoryWatcher::DW_ITEM_REMOVED);
- owner().itemRemoved(&owner(), ev);
- }
- }
- }
-
-private:
- DirectoryWatcherStrategy();
- DirectoryWatcherStrategy(const DirectoryWatcherStrategy&);
- DirectoryWatcherStrategy& operator = (const DirectoryWatcherStrategy&);
-
- DirectoryWatcher& _owner;
-};
-
-
-#if POCO_OS == POCO_OS_WINDOWS_NT
-
-
-class WindowsDirectoryWatcherStrategy: public DirectoryWatcherStrategy
-{
-public:
- WindowsDirectoryWatcherStrategy(DirectoryWatcher& owner):
- DirectoryWatcherStrategy(owner)
- {
- _hStopped = CreateEventW(NULL, FALSE, FALSE, NULL);
- 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());
-#if defined(POCO_WIN32_UTF8)
- std::wstring upath;
- FileImpl::convertPath(path.c_str(), upath);
- HANDLE hChange = FindFirstChangeNotificationW(upath.c_str(), FALSE, filter);
-#else
- HANDLE hChange = FindFirstChangeNotificationA(path.c_str(), FALSE, filter);
-#endif
-
- if (hChange == INVALID_HANDLE_VALUE)
- {
- try
- {
- FileImpl::handleLastErrorImpl(path);
- }
- catch (Poco::Exception& exc)
- {
- owner().scanError(&owner(), exc);
- }
- return;
- }
-
- bool stopped = false;
- while (!stopped)
- {
- try
- {
- HANDLE h[2];
- h[0] = _hStopped;
- h[1] = hChange;
- switch (WaitForMultipleObjects(2, h, FALSE, INFINITE))
- {
- case WAIT_OBJECT_0:
- stopped = true;
- break;
- case WAIT_OBJECT_0 + 1:
- {
- ItemInfoMap newEntries;
- scan(newEntries);
- compare(entries, newEntries);
- std::swap(entries, newEntries);
- if (FindNextChangeNotification(hChange) == FALSE)
- {
- FileImpl::handleLastErrorImpl(path);
- }
- }
- break;
- default:
- throw SystemException("failed to wait for directory changes");
- }
- }
- catch (Poco::Exception& exc)
- {
- owner().scanError(&owner(), exc);
- }
- }
- FindCloseChangeNotification(hChange);
- }
-
- void stop()
- {
- SetEvent(_hStopped);
- }
-
- bool supportsMoveEvents() const
- {
- return false;
- }
-
-private:
- HANDLE _hStopped;
-};
-
-
-#elif POCO_OS == POCO_OS_LINUX || POCO_OS == POCO_OS_ANDROID
-
-
-class LinuxDirectoryWatcherStrategy: public DirectoryWatcherStrategy
-{
-public:
- LinuxDirectoryWatcherStrategy(DirectoryWatcher& ownerWatcher):
- DirectoryWatcherStrategy(ownerWatcher),
- _fd(-1),
- _stopped(false)
- {
- _fd = inotify_init();
- if (_fd == -1) throw Poco::IOException("cannot initialize inotify", errno);
- }
-
- ~LinuxDirectoryWatcherStrategy()
- {
- close(_fd);
- }
-
- void run()
- {
- int mask = 0;
- if (owner().eventMask() & DirectoryWatcher::DW_ITEM_ADDED)
- mask |= IN_CREATE;
- if (owner().eventMask() & DirectoryWatcher::DW_ITEM_REMOVED)
- mask |= IN_DELETE;
- if (owner().eventMask() & DirectoryWatcher::DW_ITEM_MODIFIED)
- mask |= IN_MODIFY;
- if (owner().eventMask() & DirectoryWatcher::DW_ITEM_MOVED_FROM)
- mask |= IN_MOVED_FROM;
- if (owner().eventMask() & DirectoryWatcher::DW_ITEM_MOVED_TO)
- mask |= IN_MOVED_TO;
- int wd = inotify_add_watch(_fd, owner().directory().path().c_str(), mask);
- if (wd == -1)
- {
- try
- {
- FileImpl::handleLastErrorImpl(owner().directory().path());
- }
- catch (Poco::Exception& exc)
- {
- owner().scanError(&owner(), exc);
- }
- }
-
- Poco::Buffer<char> buffer(4096);
- while (!_stopped)
- {
- fd_set fds;
- FD_ZERO(&fds);
- FD_SET(_fd, &fds);
-
- struct timeval tv;
- tv.tv_sec = 0;
- tv.tv_usec = 200000;
-
- if (select(_fd + 1, &fds, NULL, NULL, &tv) == 1)
- {
- int n = read(_fd, buffer.begin(), buffer.size());
- int i = 0;
- if (n > 0)
- {
- 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);
- owner().itemAdded(&owner(), ev);
- }
- if ((pEvent->mask & IN_DELETE) && (owner().eventMask() & DirectoryWatcher::DW_ITEM_REMOVED))
- {
- DirectoryWatcher::DirectoryEvent ev(f, DirectoryWatcher::DW_ITEM_REMOVED);
- owner().itemRemoved(&owner(), ev);
- }
- if ((pEvent->mask & IN_MODIFY) && (owner().eventMask() & DirectoryWatcher::DW_ITEM_MODIFIED))
- {
- DirectoryWatcher::DirectoryEvent ev(f, DirectoryWatcher::DW_ITEM_MODIFIED);
- owner().itemModified(&owner(), ev);
- }
- if ((pEvent->mask & IN_MOVED_FROM) && (owner().eventMask() & DirectoryWatcher::DW_ITEM_MOVED_FROM))
- {
- DirectoryWatcher::DirectoryEvent ev(f, DirectoryWatcher::DW_ITEM_MOVED_FROM);
- owner().itemMovedFrom(&owner(), ev);
- }
- if ((pEvent->mask & IN_MOVED_TO) && (owner().eventMask() & DirectoryWatcher::DW_ITEM_MOVED_TO))
- {
- DirectoryWatcher::DirectoryEvent ev(f, DirectoryWatcher::DW_ITEM_MOVED_TO);
- owner().itemMovedTo(&owner(), ev);
- }
- }
- }
-
- i += sizeof(inotify_event) + pEvent->len;
- n -= sizeof(inotify_event) + pEvent->len;
- }
- }
- }
- }
- }
-
- void stop()
- {
- _stopped = true;
- }
-
- bool supportsMoveEvents() const
- {
- return true;
- }
-
-private:
- int _fd;
- bool _stopped;
-};
-
-
-#elif POCO_OS == POCO_OS_MAC_OS_X || POCO_OS == POCO_OS_FREE_BSD
-
-
-class BSDDirectoryWatcherStrategy: public DirectoryWatcherStrategy
-{
-public:
- BSDDirectoryWatcherStrategy(DirectoryWatcher& owner):
- DirectoryWatcherStrategy(owner),
- _queueFD(-1),
- _dirFD(-1),
- _stopped(false)
- {
- _dirFD = open(owner.directory().path().c_str(), O_EVTONLY);
- if (_dirFD < 0) throw Poco::FileNotFoundException(owner.directory().path());
- _queueFD = kqueue();
- if (_queueFD < 0)
- {
- close(_dirFD);
- throw Poco::SystemException("Cannot create kqueue", errno);
- }
- }
-
- ~BSDDirectoryWatcherStrategy()
- {
- close(_dirFD);
- close(_queueFD);
- }
-
- void run()
- {
- Poco::Timestamp lastScan;
- ItemInfoMap entries;
- scan(entries);
-
- while (!_stopped)
- {
- struct timespec timeout;
- timeout.tv_sec = 0;
- timeout.tv_nsec = 200000000;
- unsigned eventFilter = NOTE_WRITE;
- struct kevent event;
- struct kevent eventData;
- EV_SET(&event, _dirFD, EVFILT_VNODE, EV_ADD | EV_CLEAR, eventFilter, 0, 0);
- int nEvents = kevent(_queueFD, &event, 1, &eventData, 1, &timeout);
- if (nEvents < 0 || eventData.flags == EV_ERROR)
- {
- try
- {
- FileImpl::handleLastErrorImpl(owner().directory().path());
- }
- catch (Poco::Exception& exc)
- {
- owner().scanError(&owner(), exc);
- }
- }
- else if (nEvents > 0 || ((owner().eventMask() & DirectoryWatcher::DW_ITEM_MODIFIED) && lastScan.isElapsed(owner().scanInterval()*1000000)))
- {
- ItemInfoMap newEntries;
- scan(newEntries);
- compare(entries, newEntries);
- std::swap(entries, newEntries);
- lastScan.update();
- }
- }
- }
-
- void stop()
- {
- _stopped = true;
- }
-
- bool supportsMoveEvents() const
- {
- return false;
- }
-
-private:
- int _queueFD;
- int _dirFD;
- bool _stopped;
-};
-
-
-#else
-
-
-class PollingDirectoryWatcherStrategy: public DirectoryWatcherStrategy
-{
-public:
- PollingDirectoryWatcherStrategy(DirectoryWatcher& ownerWatcher):
- DirectoryWatcherStrategy(ownerWatcher)
- {
- }
-
- ~PollingDirectoryWatcherStrategy()
- {
- }
-
- void run()
- {
- ItemInfoMap entries;
- scan(entries);
- while (!_stopped.tryWait(1000*owner().scanInterval()))
- {
- try
- {
- ItemInfoMap newEntries;
- scan(newEntries);
- compare(entries, newEntries);
- std::swap(entries, newEntries);
- }
- catch (Poco::Exception& exc)
- {
- owner().scanError(&owner(), exc);
- }
- }
- }
-
- void stop()
- {
- _stopped.set();
- }
-
- bool supportsMoveEvents() const
- {
- return false;
- }
-
-private:
- Poco::Event _stopped;
-};
-
-
-#endif
-
-
-DirectoryWatcher::DirectoryWatcher(const std::string& path, int otherEventMask, int otherScanInterval):
- _directory(path),
- _eventMask(otherEventMask),
- _scanInterval(otherScanInterval)
-{
- init();
-}
-
-
-DirectoryWatcher::DirectoryWatcher(const Poco::File& otherDirectory, int otherEventMask, int otherScanInterval):
- _directory(otherDirectory),
- _eventMask(otherEventMask),
- _scanInterval(otherScanInterval)
-{
- init();
-}
-
-
-DirectoryWatcher::~DirectoryWatcher()
-{
- try
- {
- stop();
- delete _pStrategy;
- }
- catch (...)
- {
- poco_unexpected();
- }
-}
-
-
-void DirectoryWatcher::suspendEvents()
-{
- poco_assert (_eventsSuspended > 0);
-
- _eventsSuspended--;
-}
-
-
-void DirectoryWatcher::resumeEvents()
-{
- _eventsSuspended++;
-}
-
-
-void DirectoryWatcher::init()
-{
- if (!_directory.exists())
- throw Poco::FileNotFoundException(_directory.path());
-
- if (!_directory.isDirectory())
- throw Poco::InvalidArgumentException("not a directory", _directory.path());
-
-#if POCO_OS == POCO_OS_WINDOWS_NT
- _pStrategy = new WindowsDirectoryWatcherStrategy(*this);
-#elif POCO_OS == POCO_OS_LINUX || POCO_OS == POCO_OS_ANDROID
- _pStrategy = new LinuxDirectoryWatcherStrategy(*this);
-#elif POCO_OS == POCO_OS_MAC_OS_X || POCO_OS == POCO_OS_FREE_BSD
- _pStrategy = new BSDDirectoryWatcherStrategy(*this);
-#else
- _pStrategy = new PollingDirectoryWatcherStrategy(*this);
-#endif
- _thread.start(*this);
-}
-
-
-void DirectoryWatcher::run()
-{
- _pStrategy->run();
-}
-
-
-void DirectoryWatcher::stop()
-{
- _pStrategy->stop();
- _thread.join();
-}
-
-
-bool DirectoryWatcher::supportsMoveEvents() const
-{
- return _pStrategy->supportsMoveEvents();
-}
-
-
-} // namespace Poco
-
-
-#endif // POCO_NO_INOTIFY
+//
+// DirectoryWatcher.cpp
+//
+// Library: Foundation
+// Package: Filesystem
+// Module: DirectoryWatcher
+//
+// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/DirectoryWatcher.h"
+
+
+#ifndef POCO_NO_INOTIFY
+
+
+#include "Poco/Path.h"
+#include "Poco/Glob.h"
+#include "Poco/DirectoryIterator.h"
+#include "Poco/Event.h"
+#include "Poco/Exception.h"
+#include "Poco/Buffer.h"
+#if POCO_OS == POCO_OS_LINUX || POCO_OS == POCO_OS_ANDROID
+ #include <sys/inotify.h>
+ #include <sys/select.h>
+ #include <unistd.h>
+#elif POCO_OS == POCO_OS_MAC_OS_X || POCO_OS == POCO_OS_FREE_BSD
+ #include <fcntl.h>
+ #include <sys/types.h>
+ #include <sys/event.h>
+ #include <sys/time.h>
+ #include <unistd.h>
+ #if (POCO_OS == POCO_OS_FREE_BSD) && !defined(O_EVTONLY)
+ #define O_EVTONLY 0x8000
+ #endif
+#endif
+#include <algorithm>
+#include <map>
+
+
+namespace Poco {
+
+
+class DirectoryWatcherStrategy
+{
+public:
+ DirectoryWatcherStrategy(DirectoryWatcher& ownerWatcher):
+ _owner(ownerWatcher)
+ {
+ }
+
+ virtual ~DirectoryWatcherStrategy()
+ {
+ }
+
+ DirectoryWatcher& owner()
+ {
+ return _owner;
+ }
+
+ virtual void run() = 0;
+ virtual void stop() = 0;
+ virtual bool supportsMoveEvents() const = 0;
+
+protected:
+ struct ItemInfo
+ {
+ ItemInfo():
+ 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;
+ };
+ typedef std::map<std::string, ItemInfo> ItemInfoMap;
+
+ void scan(ItemInfoMap& entries)
+ {
+ DirectoryIterator it(owner().directory());
+ DirectoryIterator end;
+ while (it != end)
+ {
+ entries[it.path().getFileName()] = ItemInfo(*it);
+ ++it;
+ }
+ }
+
+ void compare(ItemInfoMap& oldEntries, ItemInfoMap& newEntries)
+ {
+ for (ItemInfoMap::iterator itn = newEntries.begin(); itn != newEntries.end(); ++itn)
+ {
+ ItemInfoMap::iterator ito = oldEntries.find(itn->first);
+ if (ito != oldEntries.end())
+ {
+ if ((owner().eventMask() & DirectoryWatcher::DW_ITEM_MODIFIED) && !owner().eventsSuspended())
+ {
+ if (itn->second.size != ito->second.size || itn->second.lastModified != ito->second.lastModified)
+ {
+ Poco::File f(itn->second.path);
+ DirectoryWatcher::DirectoryEvent ev(f, DirectoryWatcher::DW_ITEM_MODIFIED);
+ owner().itemModified(&owner(), ev);
+ }
+ }
+ oldEntries.erase(ito);
+ }
+ else if ((owner().eventMask() & DirectoryWatcher::DW_ITEM_ADDED) && !owner().eventsSuspended())
+ {
+ Poco::File f(itn->second.path);
+ DirectoryWatcher::DirectoryEvent ev(f, DirectoryWatcher::DW_ITEM_ADDED);
+ owner().itemAdded(&owner(), ev);
+ }
+ }
+ if ((owner().eventMask() & DirectoryWatcher::DW_ITEM_REMOVED) && !owner().eventsSuspended())
+ {
+ for (ItemInfoMap::iterator it = oldEntries.begin(); it != oldEntries.end(); ++it)
+ {
+ Poco::File f(it->second.path);
+ DirectoryWatcher::DirectoryEvent ev(f, DirectoryWatcher::DW_ITEM_REMOVED);
+ owner().itemRemoved(&owner(), ev);
+ }
+ }
+ }
+
+private:
+ DirectoryWatcherStrategy();
+ DirectoryWatcherStrategy(const DirectoryWatcherStrategy&);
+ DirectoryWatcherStrategy& operator = (const DirectoryWatcherStrategy&);
+
+ DirectoryWatcher& _owner;
+};
+
+
+#if POCO_OS == POCO_OS_WINDOWS_NT
+
+
+class WindowsDirectoryWatcherStrategy: public DirectoryWatcherStrategy
+{
+public:
+ WindowsDirectoryWatcherStrategy(DirectoryWatcher& owner):
+ DirectoryWatcherStrategy(owner)
+ {
+ _hStopped = CreateEventW(NULL, FALSE, FALSE, NULL);
+ 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());
+#if defined(POCO_WIN32_UTF8)
+ std::wstring upath;
+ FileImpl::convertPath(path.c_str(), upath);
+ HANDLE hChange = FindFirstChangeNotificationW(upath.c_str(), FALSE, filter);
+#else
+ HANDLE hChange = FindFirstChangeNotificationA(path.c_str(), FALSE, filter);
+#endif
+
+ if (hChange == INVALID_HANDLE_VALUE)
+ {
+ try
+ {
+ FileImpl::handleLastErrorImpl(path);
+ }
+ catch (Poco::Exception& exc)
+ {
+ owner().scanError(&owner(), exc);
+ }
+ return;
+ }
+
+ bool stopped = false;
+ while (!stopped)
+ {
+ try
+ {
+ HANDLE h[2];
+ h[0] = _hStopped;
+ h[1] = hChange;
+ switch (WaitForMultipleObjects(2, h, FALSE, INFINITE))
+ {
+ case WAIT_OBJECT_0:
+ stopped = true;
+ break;
+ case WAIT_OBJECT_0 + 1:
+ {
+ ItemInfoMap newEntries;
+ scan(newEntries);
+ compare(entries, newEntries);
+ std::swap(entries, newEntries);
+ if (FindNextChangeNotification(hChange) == FALSE)
+ {
+ FileImpl::handleLastErrorImpl(path);
+ }
+ }
+ break;
+ default:
+ throw SystemException("failed to wait for directory changes");
+ }
+ }
+ catch (Poco::Exception& exc)
+ {
+ owner().scanError(&owner(), exc);
+ }
+ }
+ FindCloseChangeNotification(hChange);
+ }
+
+ void stop()
+ {
+ SetEvent(_hStopped);
+ }
+
+ bool supportsMoveEvents() const
+ {
+ return false;
+ }
+
+private:
+ HANDLE _hStopped;
+};
+
+
+#elif POCO_OS == POCO_OS_LINUX || POCO_OS == POCO_OS_ANDROID
+
+
+class LinuxDirectoryWatcherStrategy: public DirectoryWatcherStrategy
+{
+public:
+ LinuxDirectoryWatcherStrategy(DirectoryWatcher& ownerWatcher):
+ DirectoryWatcherStrategy(ownerWatcher),
+ _fd(-1),
+ _stopped(false)
+ {
+ _fd = inotify_init();
+ if (_fd == -1) throw Poco::IOException("cannot initialize inotify", errno);
+ }
+
+ ~LinuxDirectoryWatcherStrategy()
+ {
+ close(_fd);
+ }
+
+ void run()
+ {
+ int mask = 0;
+ if (owner().eventMask() & DirectoryWatcher::DW_ITEM_ADDED)
+ mask |= IN_CREATE;
+ if (owner().eventMask() & DirectoryWatcher::DW_ITEM_REMOVED)
+ mask |= IN_DELETE;
+ if (owner().eventMask() & DirectoryWatcher::DW_ITEM_MODIFIED)
+ mask |= IN_MODIFY;
+ if (owner().eventMask() & DirectoryWatcher::DW_ITEM_MOVED_FROM)
+ mask |= IN_MOVED_FROM;
+ if (owner().eventMask() & DirectoryWatcher::DW_ITEM_MOVED_TO)
+ mask |= IN_MOVED_TO;
+ int wd = inotify_add_watch(_fd, owner().directory().path().c_str(), mask);
+ if (wd == -1)
+ {
+ try
+ {
+ FileImpl::handleLastErrorImpl(owner().directory().path());
+ }
+ catch (Poco::Exception& exc)
+ {
+ owner().scanError(&owner(), exc);
+ }
+ }
+
+ Poco::Buffer<char> buffer(4096);
+ while (!_stopped)
+ {
+ fd_set fds;
+ FD_ZERO(&fds);
+ FD_SET(_fd, &fds);
+
+ struct timeval tv;
+ tv.tv_sec = 0;
+ tv.tv_usec = 200000;
+
+ if (select(_fd + 1, &fds, NULL, NULL, &tv) == 1)
+ {
+ int n = read(_fd, buffer.begin(), buffer.size());
+ int i = 0;
+ if (n > 0)
+ {
+ 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);
+ owner().itemAdded(&owner(), ev);
+ }
+ if ((pEvent->mask & IN_DELETE) && (owner().eventMask() & DirectoryWatcher::DW_ITEM_REMOVED))
+ {
+ DirectoryWatcher::DirectoryEvent ev(f, DirectoryWatcher::DW_ITEM_REMOVED);
+ owner().itemRemoved(&owner(), ev);
+ }
+ if ((pEvent->mask & IN_MODIFY) && (owner().eventMask() & DirectoryWatcher::DW_ITEM_MODIFIED))
+ {
+ DirectoryWatcher::DirectoryEvent ev(f, DirectoryWatcher::DW_ITEM_MODIFIED);
+ owner().itemModified(&owner(), ev);
+ }
+ if ((pEvent->mask & IN_MOVED_FROM) && (owner().eventMask() & DirectoryWatcher::DW_ITEM_MOVED_FROM))
+ {
+ DirectoryWatcher::DirectoryEvent ev(f, DirectoryWatcher::DW_ITEM_MOVED_FROM);
+ owner().itemMovedFrom(&owner(), ev);
+ }
+ if ((pEvent->mask & IN_MOVED_TO) && (owner().eventMask() & DirectoryWatcher::DW_ITEM_MOVED_TO))
+ {
+ DirectoryWatcher::DirectoryEvent ev(f, DirectoryWatcher::DW_ITEM_MOVED_TO);
+ owner().itemMovedTo(&owner(), ev);
+ }
+ }
+ }
+
+ i += sizeof(inotify_event) + pEvent->len;
+ n -= sizeof(inotify_event) + pEvent->len;
+ }
+ }
+ }
+ }
+ }
+
+ void stop()
+ {
+ _stopped = true;
+ }
+
+ bool supportsMoveEvents() const
+ {
+ return true;
+ }
+
+private:
+ int _fd;
+ bool _stopped;
+};
+
+
+#elif POCO_OS == POCO_OS_MAC_OS_X || POCO_OS == POCO_OS_FREE_BSD
+
+
+class BSDDirectoryWatcherStrategy: public DirectoryWatcherStrategy
+{
+public:
+ BSDDirectoryWatcherStrategy(DirectoryWatcher& owner):
+ DirectoryWatcherStrategy(owner),
+ _queueFD(-1),
+ _dirFD(-1),
+ _stopped(false)
+ {
+ _dirFD = open(owner.directory().path().c_str(), O_EVTONLY);
+ if (_dirFD < 0) throw Poco::FileNotFoundException(owner.directory().path());
+ _queueFD = kqueue();
+ if (_queueFD < 0)
+ {
+ close(_dirFD);
+ throw Poco::SystemException("Cannot create kqueue", errno);
+ }
+ }
+
+ ~BSDDirectoryWatcherStrategy()
+ {
+ close(_dirFD);
+ close(_queueFD);
+ }
+
+ void run()
+ {
+ Poco::Timestamp lastScan;
+ ItemInfoMap entries;
+ scan(entries);
+
+ while (!_stopped)
+ {
+ struct timespec timeout;
+ timeout.tv_sec = 0;
+ timeout.tv_nsec = 200000000;
+ unsigned eventFilter = NOTE_WRITE;
+ struct kevent event;
+ struct kevent eventData;
+ EV_SET(&event, _dirFD, EVFILT_VNODE, EV_ADD | EV_CLEAR, eventFilter, 0, 0);
+ int nEvents = kevent(_queueFD, &event, 1, &eventData, 1, &timeout);
+ if (nEvents < 0 || eventData.flags == EV_ERROR)
+ {
+ try
+ {
+ FileImpl::handleLastErrorImpl(owner().directory().path());
+ }
+ catch (Poco::Exception& exc)
+ {
+ owner().scanError(&owner(), exc);
+ }
+ }
+ else if (nEvents > 0 || ((owner().eventMask() & DirectoryWatcher::DW_ITEM_MODIFIED) && lastScan.isElapsed(owner().scanInterval()*1000000)))
+ {
+ ItemInfoMap newEntries;
+ scan(newEntries);
+ compare(entries, newEntries);
+ std::swap(entries, newEntries);
+ lastScan.update();
+ }
+ }
+ }
+
+ void stop()
+ {
+ _stopped = true;
+ }
+
+ bool supportsMoveEvents() const
+ {
+ return false;
+ }
+
+private:
+ int _queueFD;
+ int _dirFD;
+ bool _stopped;
+};
+
+
+#else
+
+
+class PollingDirectoryWatcherStrategy: public DirectoryWatcherStrategy
+{
+public:
+ PollingDirectoryWatcherStrategy(DirectoryWatcher& ownerWatcher):
+ DirectoryWatcherStrategy(ownerWatcher)
+ {
+ }
+
+ ~PollingDirectoryWatcherStrategy()
+ {
+ }
+
+ void run()
+ {
+ ItemInfoMap entries;
+ scan(entries);
+ while (!_stopped.tryWait(1000*owner().scanInterval()))
+ {
+ try
+ {
+ ItemInfoMap newEntries;
+ scan(newEntries);
+ compare(entries, newEntries);
+ std::swap(entries, newEntries);
+ }
+ catch (Poco::Exception& exc)
+ {
+ owner().scanError(&owner(), exc);
+ }
+ }
+ }
+
+ void stop()
+ {
+ _stopped.set();
+ }
+
+ bool supportsMoveEvents() const
+ {
+ return false;
+ }
+
+private:
+ Poco::Event _stopped;
+};
+
+
+#endif
+
+
+DirectoryWatcher::DirectoryWatcher(const std::string& path, int otherEventMask, int otherScanInterval):
+ _directory(path),
+ _eventMask(otherEventMask),
+ _scanInterval(otherScanInterval)
+{
+ init();
+}
+
+
+DirectoryWatcher::DirectoryWatcher(const Poco::File& otherDirectory, int otherEventMask, int otherScanInterval):
+ _directory(otherDirectory),
+ _eventMask(otherEventMask),
+ _scanInterval(otherScanInterval)
+{
+ init();
+}
+
+
+DirectoryWatcher::~DirectoryWatcher()
+{
+ try
+ {
+ stop();
+ delete _pStrategy;
+ }
+ catch (...)
+ {
+ poco_unexpected();
+ }
+}
+
+
+void DirectoryWatcher::suspendEvents()
+{
+ poco_assert (_eventsSuspended > 0);
+
+ _eventsSuspended--;
+}
+
+
+void DirectoryWatcher::resumeEvents()
+{
+ _eventsSuspended++;
+}
+
+
+void DirectoryWatcher::init()
+{
+ if (!_directory.exists())
+ throw Poco::FileNotFoundException(_directory.path());
+
+ if (!_directory.isDirectory())
+ throw Poco::InvalidArgumentException("not a directory", _directory.path());
+
+#if POCO_OS == POCO_OS_WINDOWS_NT
+ _pStrategy = new WindowsDirectoryWatcherStrategy(*this);
+#elif POCO_OS == POCO_OS_LINUX || POCO_OS == POCO_OS_ANDROID
+ _pStrategy = new LinuxDirectoryWatcherStrategy(*this);
+#elif POCO_OS == POCO_OS_MAC_OS_X || POCO_OS == POCO_OS_FREE_BSD
+ _pStrategy = new BSDDirectoryWatcherStrategy(*this);
+#else
+ _pStrategy = new PollingDirectoryWatcherStrategy(*this);
+#endif
+ _thread.start(*this);
+}
+
+
+void DirectoryWatcher::run()
+{
+ _pStrategy->run();
+}
+
+
+void DirectoryWatcher::stop()
+{
+ _pStrategy->stop();
+ _thread.join();
+}
+
+
+bool DirectoryWatcher::supportsMoveEvents() const
+{
+ return _pStrategy->supportsMoveEvents();
+}
+
+
+} // namespace Poco
+
+
+#endif // POCO_NO_INOTIFY
diff --git a/contrib/libs/poco/Foundation/src/Environment.cpp b/contrib/libs/poco/Foundation/src/Environment.cpp
index 32753efc5a..42a27033d1 100644
--- a/contrib/libs/poco/Foundation/src/Environment.cpp
+++ b/contrib/libs/poco/Foundation/src/Environment.cpp
@@ -1,160 +1,160 @@
-//
-// Environment.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: Environment
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Environment.h"
-#include "Poco/Version.h"
-#include <cstdlib>
-#include <cstdio> // sprintf()
-
-
-#if defined(POCO_VXWORKS)
-#include "Environment_VX.cpp"
-#elif defined(POCO_OS_FAMILY_UNIX)
-#include "Environment_UNIX.cpp"
-#elif defined(POCO_OS_FAMILY_WINDOWS)
-#if defined(_WIN32_WCE)
-#include "Environment_WINCE.cpp"
-#else
-#include "Environment_WIN32.cpp"
-#endif
-#endif
-
-
-namespace Poco {
-
-
-std::string Environment::get(const std::string& name)
-{
- return EnvironmentImpl::getImpl(name);
-}
-
-
-std::string Environment::get(const std::string& name, const std::string& defaultValue)
-{
- if (has(name))
- return get(name);
- else
- return defaultValue;
-}
-
-
-bool Environment::has(const std::string& name)
-{
- return EnvironmentImpl::hasImpl(name);
-}
-
-
-void Environment::set(const std::string& name, const std::string& value)
-{
- EnvironmentImpl::setImpl(name, value);
-}
-
-
-std::string Environment::osName()
-{
- return EnvironmentImpl::osNameImpl();
-}
-
-
-std::string Environment::osDisplayName()
-{
- return EnvironmentImpl::osDisplayNameImpl();
-}
-
-
-std::string Environment::osVersion()
-{
- return EnvironmentImpl::osVersionImpl();
-}
-
-
-std::string Environment::osArchitecture()
-{
- return EnvironmentImpl::osArchitectureImpl();
-}
-
-
-std::string Environment::nodeName()
-{
- return EnvironmentImpl::nodeNameImpl();
-}
-
-
-std::string Environment::nodeId()
-{
- NodeId id;
- nodeId(id);
- char result[18];
- std::sprintf(result, "%02x:%02x:%02x:%02x:%02x:%02x",
- id[0],
- id[1],
- id[2],
- id[3],
- id[4],
- id[5]);
- return std::string(result);
-}
-
-
-void Environment::nodeId(NodeId& id)
-{
- return EnvironmentImpl::nodeIdImpl(id);
-}
-
-
-unsigned Environment::processorCount()
-{
- return EnvironmentImpl::processorCountImpl();
-}
-
-
-Poco::UInt32 Environment::libraryVersion()
-{
- return POCO_VERSION;
-}
-
-
-Poco::Int32 Environment::os()
-{
- return POCO_OS;
-}
-
-
-Poco::Int32 Environment::arch()
-{
- return POCO_ARCH;
-}
-
-
-bool Environment::isUnix()
-{
-#if defined(POCO_OS_FAMILY_UNIX)
- return true;
-#else
- return false;
-#endif
-}
-
-
-bool Environment::isWindows()
-{
-#if defined(POCO_OS_FAMILY_WINDOWS)
- return true;
-#else
- return false;
-#endif
-}
-
-
-} // namespace Poco
+//
+// Environment.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: Environment
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Environment.h"
+#include "Poco/Version.h"
+#include <cstdlib>
+#include <cstdio> // sprintf()
+
+
+#if defined(POCO_VXWORKS)
+#include "Environment_VX.cpp"
+#elif defined(POCO_OS_FAMILY_UNIX)
+#include "Environment_UNIX.cpp"
+#elif defined(POCO_OS_FAMILY_WINDOWS)
+#if defined(_WIN32_WCE)
+#include "Environment_WINCE.cpp"
+#else
+#include "Environment_WIN32.cpp"
+#endif
+#endif
+
+
+namespace Poco {
+
+
+std::string Environment::get(const std::string& name)
+{
+ return EnvironmentImpl::getImpl(name);
+}
+
+
+std::string Environment::get(const std::string& name, const std::string& defaultValue)
+{
+ if (has(name))
+ return get(name);
+ else
+ return defaultValue;
+}
+
+
+bool Environment::has(const std::string& name)
+{
+ return EnvironmentImpl::hasImpl(name);
+}
+
+
+void Environment::set(const std::string& name, const std::string& value)
+{
+ EnvironmentImpl::setImpl(name, value);
+}
+
+
+std::string Environment::osName()
+{
+ return EnvironmentImpl::osNameImpl();
+}
+
+
+std::string Environment::osDisplayName()
+{
+ return EnvironmentImpl::osDisplayNameImpl();
+}
+
+
+std::string Environment::osVersion()
+{
+ return EnvironmentImpl::osVersionImpl();
+}
+
+
+std::string Environment::osArchitecture()
+{
+ return EnvironmentImpl::osArchitectureImpl();
+}
+
+
+std::string Environment::nodeName()
+{
+ return EnvironmentImpl::nodeNameImpl();
+}
+
+
+std::string Environment::nodeId()
+{
+ NodeId id;
+ nodeId(id);
+ char result[18];
+ std::sprintf(result, "%02x:%02x:%02x:%02x:%02x:%02x",
+ id[0],
+ id[1],
+ id[2],
+ id[3],
+ id[4],
+ id[5]);
+ return std::string(result);
+}
+
+
+void Environment::nodeId(NodeId& id)
+{
+ return EnvironmentImpl::nodeIdImpl(id);
+}
+
+
+unsigned Environment::processorCount()
+{
+ return EnvironmentImpl::processorCountImpl();
+}
+
+
+Poco::UInt32 Environment::libraryVersion()
+{
+ return POCO_VERSION;
+}
+
+
+Poco::Int32 Environment::os()
+{
+ return POCO_OS;
+}
+
+
+Poco::Int32 Environment::arch()
+{
+ return POCO_ARCH;
+}
+
+
+bool Environment::isUnix()
+{
+#if defined(POCO_OS_FAMILY_UNIX)
+ return true;
+#else
+ return false;
+#endif
+}
+
+
+bool Environment::isWindows()
+{
+#if defined(POCO_OS_FAMILY_WINDOWS)
+ return true;
+#else
+ return false;
+#endif
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Environment_UNIX.cpp b/contrib/libs/poco/Foundation/src/Environment_UNIX.cpp
index b7e57e4314..ca5772267f 100644
--- a/contrib/libs/poco/Foundation/src/Environment_UNIX.cpp
+++ b/contrib/libs/poco/Foundation/src/Environment_UNIX.cpp
@@ -1,332 +1,332 @@
-
-// Environment_UNIX.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: Environment
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Environment_UNIX.h"
-#include "Poco/Exception.h"
-#include "Poco/Buffer.h"
-#include <cstring>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/utsname.h>
-#include <sys/param.h>
-#if defined(POCO_OS_FAMILY_BSD)
-#include <sys/sysctl.h>
-#elif POCO_OS == POCO_OS_HPUX
-#include <pthread.h>
-#endif
-
-
-namespace Poco {
-
-
-EnvironmentImpl::StringMap EnvironmentImpl::_map;
-FastMutex EnvironmentImpl::_mutex;
-
-
-std::string EnvironmentImpl::getImpl(const std::string& name)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- const char* val = getenv(name.c_str());
- if (val)
- return std::string(val);
- else
- throw NotFoundException(name);
-}
-
-
-bool EnvironmentImpl::hasImpl(const std::string& name)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- return getenv(name.c_str()) != 0;
-}
-
-
-void EnvironmentImpl::setImpl(const std::string& name, const std::string& value)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- std::string var = name;
- var.append("=");
- var.append(value);
- std::swap(_map[name], var);
- if (putenv((char*) _map[name].c_str()))
- {
- std::string msg = "cannot set environment variable: ";
- msg.append(name);
- throw SystemException(msg);
- }
-}
-
-
-std::string EnvironmentImpl::osNameImpl()
-{
- struct utsname uts;
- uname(&uts);
- return uts.sysname;
-}
-
-
-std::string EnvironmentImpl::osDisplayNameImpl()
-{
- return osNameImpl();
-}
-
-
-std::string EnvironmentImpl::osVersionImpl()
-{
- struct utsname uts;
- uname(&uts);
- return uts.release;
-}
-
-
-std::string EnvironmentImpl::osArchitectureImpl()
-{
- struct utsname uts;
- uname(&uts);
- return uts.machine;
-}
-
-
-std::string EnvironmentImpl::nodeNameImpl()
-{
- struct utsname uts;
- uname(&uts);
- return uts.nodename;
-}
-
-
-unsigned EnvironmentImpl::processorCountImpl()
-{
-#if defined(_SC_NPROCESSORS_ONLN)
- int count = sysconf(_SC_NPROCESSORS_ONLN);
- if (count <= 0) count = 1;
- return static_cast<int>(count);
-#elif defined(POCO_OS_FAMILY_BSD)
- unsigned count;
- std::size_t size = sizeof(count);
- if (sysctlbyname("hw.ncpu", &count, &size, 0, 0))
- return 1;
- else
- return count;
-#elif POCO_OS == POCO_OS_HPUX
- return pthread_num_processors_np();
-#else
- return 1;
-#endif
-}
-
-
-} // namespace Poco
-
-
-//
-// nodeIdImpl
-//
-#if defined(POCO_OS_FAMILY_BSD) || POCO_OS == POCO_OS_QNX
-//
-// BSD variants
-//
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <ifaddrs.h>
-#include <net/if_dl.h>
-
-
-namespace Poco {
-
-
-void EnvironmentImpl::nodeIdImpl(NodeId& id)
-{
- std::memset(&id, 0, sizeof(id));
- struct ifaddrs* ifaphead;
- int rc = getifaddrs(&ifaphead);
- if (rc) return;
-
- for (struct ifaddrs* ifap = ifaphead; ifap; ifap = ifap->ifa_next)
- {
- if (ifap->ifa_addr && ifap->ifa_addr->sa_family == AF_LINK)
- {
- struct sockaddr_dl* sdl = reinterpret_cast<struct sockaddr_dl*>(ifap->ifa_addr);
- caddr_t ap = LLADDR(sdl);
- int alen = sdl->sdl_alen;
- if (ap && alen > 0)
- {
- std::memcpy(&id, ap, sizeof(id));
- break;
- }
- }
- }
- freeifaddrs(ifaphead);
-}
-
-
-} // namespace Poco
-
-
-#elif defined(__CYGWIN__) || POCO_OS == POCO_OS_LINUX || POCO_OS == POCO_OS_ANDROID
-//
-// Linux, Cygwin
-//
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <net/if.h>
-#ifndef __CYGWIN__
-#include <net/if_arp.h>
-#else // workaround for Cygwin, which does not have if_arp.h
-#define ARPHRD_ETHER 1 /* Ethernet 10Mbps */
-#endif
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <cstdio>
-
-
-namespace Poco {
-
-
-void EnvironmentImpl::nodeIdImpl(NodeId& id)
-{
- std::memset(&id, 0, sizeof(id));
-
- // ideally, the following code should be rewritten
- // to use netlink
-
- // first try to obtain the MAC address of eth0 using /sys/class/net
- int fd = open("/sys/class/net/eth0/address", O_RDONLY);
- if (fd >= 0)
- {
- char buffer[18];
- int n = read(fd, buffer, 17);
- close(fd);
- if (n == 17)
- {
- buffer[n] = 0;
- if (std::sscanf(buffer, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &id[0], &id[1], &id[2], &id[3], &id[4], &id[5]) == 6)
- return;
- }
- }
-
- // if that did not work, search active interfaces
- int sock = socket(PF_INET, SOCK_DGRAM, 0);
- if (sock == -1) return;
-
- // the following code is loosely based
- // on W. Richard Stevens, UNIX Network Programming, pp 434ff.
- int lastlen = 0;
- int len = 100*sizeof(struct ifreq);
- struct ifconf ifc;
- char* buf = 0;
- for (;;)
- {
- buf = new char[len];
- ifc.ifc_len = len;
- ifc.ifc_buf = buf;
- if (::ioctl(sock, SIOCGIFCONF, &ifc) < 0)
- {
- if (errno != EINVAL || lastlen != 0)
- {
- close(sock);
- delete [] buf;
- return;
- }
- }
- else
- {
- if (ifc.ifc_len == lastlen)
- break;
- lastlen = ifc.ifc_len;
- }
- len += 10*sizeof(struct ifreq);
- delete [] buf;
- }
- for (const char* ptr = buf; ptr < buf + ifc.ifc_len;)
- {
- const struct ifreq* ifr = reinterpret_cast<const struct ifreq*>(ptr);
- int rc = ioctl(sock, SIOCGIFHWADDR, ifr);
- if (rc != -1)
- {
- const struct sockaddr* sa = reinterpret_cast<const struct sockaddr*>(&ifr->ifr_hwaddr);
- if (sa->sa_family == ARPHRD_ETHER)
- {
- std::memcpy(&id, sa->sa_data, sizeof(id));
- break;
- }
- }
- ptr += sizeof(struct ifreq);
- }
- close(sock);
- delete [] buf;
-}
-
-
-} // namespace Poco
-
-
-#elif defined(POCO_OS_FAMILY_UNIX)
-//
-// General Unix
-//
-#include <sys/ioctl.h>
-#if defined(sun) || defined(__sun)
-#include <sys/sockio.h>
-#endif
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <unistd.h>
-
-
-namespace Poco {
-
-
-void EnvironmentImpl::nodeIdImpl(NodeId& id)
-{
- std::memset(&id, 0, sizeof(id));
- char name[MAXHOSTNAMELEN];
- if (gethostname(name, sizeof(name)))
- return;
-
- struct hostent* pHost = gethostbyname(name);
- if (!pHost) return;
-
- int s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
- if (s == -1) return;
-
- struct arpreq ar;
- std::memset(&ar, 0, sizeof(ar));
- struct sockaddr_in* pAddr = reinterpret_cast<struct sockaddr_in*>(&ar.arp_pa);
- pAddr->sin_family = AF_INET;
- std::memcpy(&pAddr->sin_addr, *pHost->h_addr_list, sizeof(struct in_addr));
- int rc = ioctl(s, SIOCGARP, &ar);
- close(s);
- if (rc < 0) return;
- std::memcpy(&id, ar.arp_ha.sa_data, sizeof(id));
-}
-
-
-} // namespace Poco
-
-
-#endif
+
+// Environment_UNIX.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: Environment
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Environment_UNIX.h"
+#include "Poco/Exception.h"
+#include "Poco/Buffer.h"
+#include <cstring>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/utsname.h>
+#include <sys/param.h>
+#if defined(POCO_OS_FAMILY_BSD)
+#include <sys/sysctl.h>
+#elif POCO_OS == POCO_OS_HPUX
+#include <pthread.h>
+#endif
+
+
+namespace Poco {
+
+
+EnvironmentImpl::StringMap EnvironmentImpl::_map;
+FastMutex EnvironmentImpl::_mutex;
+
+
+std::string EnvironmentImpl::getImpl(const std::string& name)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ const char* val = getenv(name.c_str());
+ if (val)
+ return std::string(val);
+ else
+ throw NotFoundException(name);
+}
+
+
+bool EnvironmentImpl::hasImpl(const std::string& name)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ return getenv(name.c_str()) != 0;
+}
+
+
+void EnvironmentImpl::setImpl(const std::string& name, const std::string& value)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ std::string var = name;
+ var.append("=");
+ var.append(value);
+ std::swap(_map[name], var);
+ if (putenv((char*) _map[name].c_str()))
+ {
+ std::string msg = "cannot set environment variable: ";
+ msg.append(name);
+ throw SystemException(msg);
+ }
+}
+
+
+std::string EnvironmentImpl::osNameImpl()
+{
+ struct utsname uts;
+ uname(&uts);
+ return uts.sysname;
+}
+
+
+std::string EnvironmentImpl::osDisplayNameImpl()
+{
+ return osNameImpl();
+}
+
+
+std::string EnvironmentImpl::osVersionImpl()
+{
+ struct utsname uts;
+ uname(&uts);
+ return uts.release;
+}
+
+
+std::string EnvironmentImpl::osArchitectureImpl()
+{
+ struct utsname uts;
+ uname(&uts);
+ return uts.machine;
+}
+
+
+std::string EnvironmentImpl::nodeNameImpl()
+{
+ struct utsname uts;
+ uname(&uts);
+ return uts.nodename;
+}
+
+
+unsigned EnvironmentImpl::processorCountImpl()
+{
+#if defined(_SC_NPROCESSORS_ONLN)
+ int count = sysconf(_SC_NPROCESSORS_ONLN);
+ if (count <= 0) count = 1;
+ return static_cast<int>(count);
+#elif defined(POCO_OS_FAMILY_BSD)
+ unsigned count;
+ std::size_t size = sizeof(count);
+ if (sysctlbyname("hw.ncpu", &count, &size, 0, 0))
+ return 1;
+ else
+ return count;
+#elif POCO_OS == POCO_OS_HPUX
+ return pthread_num_processors_np();
+#else
+ return 1;
+#endif
+}
+
+
+} // namespace Poco
+
+
+//
+// nodeIdImpl
+//
+#if defined(POCO_OS_FAMILY_BSD) || POCO_OS == POCO_OS_QNX
+//
+// BSD variants
+//
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <ifaddrs.h>
+#include <net/if_dl.h>
+
+
+namespace Poco {
+
+
+void EnvironmentImpl::nodeIdImpl(NodeId& id)
+{
+ std::memset(&id, 0, sizeof(id));
+ struct ifaddrs* ifaphead;
+ int rc = getifaddrs(&ifaphead);
+ if (rc) return;
+
+ for (struct ifaddrs* ifap = ifaphead; ifap; ifap = ifap->ifa_next)
+ {
+ if (ifap->ifa_addr && ifap->ifa_addr->sa_family == AF_LINK)
+ {
+ struct sockaddr_dl* sdl = reinterpret_cast<struct sockaddr_dl*>(ifap->ifa_addr);
+ caddr_t ap = LLADDR(sdl);
+ int alen = sdl->sdl_alen;
+ if (ap && alen > 0)
+ {
+ std::memcpy(&id, ap, sizeof(id));
+ break;
+ }
+ }
+ }
+ freeifaddrs(ifaphead);
+}
+
+
+} // namespace Poco
+
+
+#elif defined(__CYGWIN__) || POCO_OS == POCO_OS_LINUX || POCO_OS == POCO_OS_ANDROID
+//
+// Linux, Cygwin
+//
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <net/if.h>
+#ifndef __CYGWIN__
+#include <net/if_arp.h>
+#else // workaround for Cygwin, which does not have if_arp.h
+#define ARPHRD_ETHER 1 /* Ethernet 10Mbps */
+#endif
+#include <arpa/inet.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <cstdio>
+
+
+namespace Poco {
+
+
+void EnvironmentImpl::nodeIdImpl(NodeId& id)
+{
+ std::memset(&id, 0, sizeof(id));
+
+ // ideally, the following code should be rewritten
+ // to use netlink
+
+ // first try to obtain the MAC address of eth0 using /sys/class/net
+ int fd = open("/sys/class/net/eth0/address", O_RDONLY);
+ if (fd >= 0)
+ {
+ char buffer[18];
+ int n = read(fd, buffer, 17);
+ close(fd);
+ if (n == 17)
+ {
+ buffer[n] = 0;
+ if (std::sscanf(buffer, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &id[0], &id[1], &id[2], &id[3], &id[4], &id[5]) == 6)
+ return;
+ }
+ }
+
+ // if that did not work, search active interfaces
+ int sock = socket(PF_INET, SOCK_DGRAM, 0);
+ if (sock == -1) return;
+
+ // the following code is loosely based
+ // on W. Richard Stevens, UNIX Network Programming, pp 434ff.
+ int lastlen = 0;
+ int len = 100*sizeof(struct ifreq);
+ struct ifconf ifc;
+ char* buf = 0;
+ for (;;)
+ {
+ buf = new char[len];
+ ifc.ifc_len = len;
+ ifc.ifc_buf = buf;
+ if (::ioctl(sock, SIOCGIFCONF, &ifc) < 0)
+ {
+ if (errno != EINVAL || lastlen != 0)
+ {
+ close(sock);
+ delete [] buf;
+ return;
+ }
+ }
+ else
+ {
+ if (ifc.ifc_len == lastlen)
+ break;
+ lastlen = ifc.ifc_len;
+ }
+ len += 10*sizeof(struct ifreq);
+ delete [] buf;
+ }
+ for (const char* ptr = buf; ptr < buf + ifc.ifc_len;)
+ {
+ const struct ifreq* ifr = reinterpret_cast<const struct ifreq*>(ptr);
+ int rc = ioctl(sock, SIOCGIFHWADDR, ifr);
+ if (rc != -1)
+ {
+ const struct sockaddr* sa = reinterpret_cast<const struct sockaddr*>(&ifr->ifr_hwaddr);
+ if (sa->sa_family == ARPHRD_ETHER)
+ {
+ std::memcpy(&id, sa->sa_data, sizeof(id));
+ break;
+ }
+ }
+ ptr += sizeof(struct ifreq);
+ }
+ close(sock);
+ delete [] buf;
+}
+
+
+} // namespace Poco
+
+
+#elif defined(POCO_OS_FAMILY_UNIX)
+//
+// General Unix
+//
+#include <sys/ioctl.h>
+#if defined(sun) || defined(__sun)
+#include <sys/sockio.h>
+#endif
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <net/if.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <unistd.h>
+
+
+namespace Poco {
+
+
+void EnvironmentImpl::nodeIdImpl(NodeId& id)
+{
+ std::memset(&id, 0, sizeof(id));
+ char name[MAXHOSTNAMELEN];
+ if (gethostname(name, sizeof(name)))
+ return;
+
+ struct hostent* pHost = gethostbyname(name);
+ if (!pHost) return;
+
+ int s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ if (s == -1) return;
+
+ struct arpreq ar;
+ std::memset(&ar, 0, sizeof(ar));
+ struct sockaddr_in* pAddr = reinterpret_cast<struct sockaddr_in*>(&ar.arp_pa);
+ pAddr->sin_family = AF_INET;
+ std::memcpy(&pAddr->sin_addr, *pHost->h_addr_list, sizeof(struct in_addr));
+ int rc = ioctl(s, SIOCGARP, &ar);
+ close(s);
+ if (rc < 0) return;
+ std::memcpy(&id, ar.arp_ha.sa_data, sizeof(id));
+}
+
+
+} // namespace Poco
+
+
+#endif
diff --git a/contrib/libs/poco/Foundation/src/Environment_VX.cpp b/contrib/libs/poco/Foundation/src/Environment_VX.cpp
index fa0469dc95..714e902b0f 100644
--- a/contrib/libs/poco/Foundation/src/Environment_VX.cpp
+++ b/contrib/libs/poco/Foundation/src/Environment_VX.cpp
@@ -1,159 +1,159 @@
-
-// Environment_VX.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: Environment
-//
-// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Environment_VX.h"
-#include "Poco/Exception.h"
-#include "Poco/Buffer.h"
-#error #include <VxWorks.h>
-#error #include <envLib.h>
-#include <hostLib.h>
-#error #include <ifLib.h>
-#include <sockLib.h>
-#include <ioLib.h>
-#error #include <version.h>
-#include <cstring>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-#include <netinet/if_ether.h>
-#error #include <ifLib.h>
-#include <unistd.h>
-
-
-namespace Poco {
-
-
-EnvironmentImpl::StringMap EnvironmentImpl::_map;
-FastMutex EnvironmentImpl::_mutex;
-
-
-std::string EnvironmentImpl::getImpl(const std::string& name)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- const char* val = getenv(name.c_str());
- if (val)
- return std::string(val);
- else
- throw NotFoundException(name);
-}
-
-
-bool EnvironmentImpl::hasImpl(const std::string& name)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- return getenv(name.c_str()) != 0;
-}
-
-
-void EnvironmentImpl::setImpl(const std::string& name, const std::string& value)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- std::string var = name;
- var.append("=");
- var.append(value);
- std::swap(_map[name], var);
- if (putenv((char*) _map[name].c_str()))
- {
- std::string msg = "cannot set environment variable: ";
- msg.append(name);
- throw SystemException(msg);
- }
-}
-
-
-std::string EnvironmentImpl::osNameImpl()
-{
- return runtimeName;
-}
-
-
-std::string EnvironmentImpl::osDisplayNameImpl()
-{
- return osNameImpl();
-}
-
-
-std::string EnvironmentImpl::osVersionImpl()
-{
- return runtimeVersion;
-}
-
-
-std::string EnvironmentImpl::osArchitectureImpl()
-{
-#if POCO_ARCH == POCO_ARCH_IA32
- return "i386";
-#elif POCO_ARCH == POCO_ARCH_MIPS
- return "mips";
-#elif POCO_ARCH == POCO_ARCH_PPC
- return "ppc";
-#elif POCO_ARCH == POCO_ARCH_ARM
- return "arm";
-#elif POCO_ARCH == POCO_ARCH_SH
- return "sh";
-#else
- return "unknown";
-#endif
-}
-
-
-std::string EnvironmentImpl::nodeNameImpl()
-{
- char buffer[64];
- if (gethostname(buffer, sizeof(buffer)) == OK)
- return buffer;
- else
- return "unknown";
-}
-
-
-unsigned EnvironmentImpl::processorCountImpl()
-{
- return 1;
-}
-
-
-void EnvironmentImpl::nodeIdImpl(NodeId& id)
-{
- std::memset(&id, 0, sizeof(id));
-
- int ifIndex = 1;
- char ifName[32];
- for (;;)
- {
- if (ifIndexToIfName(ifIndex, ifName) == OK)
- {
- struct ifnet* pIf = ifunit(ifName);
- if (pIf)
- {
- std::memcpy(&id, ((struct arpcom *) pIf)->ac_enaddr, sizeof(id));
- return;
- }
- }
- else break;
- ++ifIndex;
- }
- throw SystemException("cannot get Ethernet hardware address");
-}
-
-
-} // namespace Poco
+
+// Environment_VX.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: Environment
+//
+// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Environment_VX.h"
+#include "Poco/Exception.h"
+#include "Poco/Buffer.h"
+#error #include <VxWorks.h>
+#error #include <envLib.h>
+#include <hostLib.h>
+#error #include <ifLib.h>
+#include <sockLib.h>
+#include <ioLib.h>
+#error #include <version.h>
+#include <cstring>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <net/if.h>
+#include <arpa/inet.h>
+#include <netinet/if_ether.h>
+#error #include <ifLib.h>
+#include <unistd.h>
+
+
+namespace Poco {
+
+
+EnvironmentImpl::StringMap EnvironmentImpl::_map;
+FastMutex EnvironmentImpl::_mutex;
+
+
+std::string EnvironmentImpl::getImpl(const std::string& name)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ const char* val = getenv(name.c_str());
+ if (val)
+ return std::string(val);
+ else
+ throw NotFoundException(name);
+}
+
+
+bool EnvironmentImpl::hasImpl(const std::string& name)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ return getenv(name.c_str()) != 0;
+}
+
+
+void EnvironmentImpl::setImpl(const std::string& name, const std::string& value)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ std::string var = name;
+ var.append("=");
+ var.append(value);
+ std::swap(_map[name], var);
+ if (putenv((char*) _map[name].c_str()))
+ {
+ std::string msg = "cannot set environment variable: ";
+ msg.append(name);
+ throw SystemException(msg);
+ }
+}
+
+
+std::string EnvironmentImpl::osNameImpl()
+{
+ return runtimeName;
+}
+
+
+std::string EnvironmentImpl::osDisplayNameImpl()
+{
+ return osNameImpl();
+}
+
+
+std::string EnvironmentImpl::osVersionImpl()
+{
+ return runtimeVersion;
+}
+
+
+std::string EnvironmentImpl::osArchitectureImpl()
+{
+#if POCO_ARCH == POCO_ARCH_IA32
+ return "i386";
+#elif POCO_ARCH == POCO_ARCH_MIPS
+ return "mips";
+#elif POCO_ARCH == POCO_ARCH_PPC
+ return "ppc";
+#elif POCO_ARCH == POCO_ARCH_ARM
+ return "arm";
+#elif POCO_ARCH == POCO_ARCH_SH
+ return "sh";
+#else
+ return "unknown";
+#endif
+}
+
+
+std::string EnvironmentImpl::nodeNameImpl()
+{
+ char buffer[64];
+ if (gethostname(buffer, sizeof(buffer)) == OK)
+ return buffer;
+ else
+ return "unknown";
+}
+
+
+unsigned EnvironmentImpl::processorCountImpl()
+{
+ return 1;
+}
+
+
+void EnvironmentImpl::nodeIdImpl(NodeId& id)
+{
+ std::memset(&id, 0, sizeof(id));
+
+ int ifIndex = 1;
+ char ifName[32];
+ for (;;)
+ {
+ if (ifIndexToIfName(ifIndex, ifName) == OK)
+ {
+ struct ifnet* pIf = ifunit(ifName);
+ if (pIf)
+ {
+ std::memcpy(&id, ((struct arpcom *) pIf)->ac_enaddr, sizeof(id));
+ return;
+ }
+ }
+ else break;
+ ++ifIndex;
+ }
+ throw SystemException("cannot get Ethernet hardware address");
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Environment_WIN32.cpp b/contrib/libs/poco/Foundation/src/Environment_WIN32.cpp
index 62845fab02..2d72ec6304 100644
--- a/contrib/libs/poco/Foundation/src/Environment_WIN32.cpp
+++ b/contrib/libs/poco/Foundation/src/Environment_WIN32.cpp
@@ -1,221 +1,221 @@
-//
-// Environment_WIN32.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: Environment
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Environment_WIN32.h"
-#include "Poco/Exception.h"
-#include <sstream>
-#include <cstring>
-#include "Poco/UnWindows.h"
-#include <winsock2.h>
-#include <wincrypt.h>
-#include <ws2ipdef.h>
-#include <iphlpapi.h>
-
-
-namespace Poco {
-
-
-std::string EnvironmentImpl::getImpl(const std::string& name)
-{
- DWORD len = GetEnvironmentVariableA(name.c_str(), 0, 0);
- if (len == 0) throw NotFoundException(name);
- char* buffer = new char[len];
- GetEnvironmentVariableA(name.c_str(), buffer, len);
- std::string result(buffer);
- delete [] buffer;
- return result;
-}
-
-
-bool EnvironmentImpl::hasImpl(const std::string& name)
-{
- DWORD len = GetEnvironmentVariableA(name.c_str(), 0, 0);
- return len > 0;
-}
-
-
-void EnvironmentImpl::setImpl(const std::string& name, const std::string& value)
-{
- if (SetEnvironmentVariableA(name.c_str(), value.c_str()) == 0)
- {
- std::string msg = "cannot set environment variable: ";
- msg.append(name);
- throw SystemException(msg);
- }
-}
-
-
-std::string EnvironmentImpl::osNameImpl()
-{
- OSVERSIONINFO vi;
- vi.dwOSVersionInfoSize = sizeof(vi);
- if (GetVersionEx(&vi) == 0) throw SystemException("Cannot get OS version information");
- switch (vi.dwPlatformId)
- {
- case VER_PLATFORM_WIN32s:
- return "Windows 3.x";
- case VER_PLATFORM_WIN32_WINDOWS:
- return vi.dwMinorVersion == 0 ? "Windows 95" : "Windows 98";
- case VER_PLATFORM_WIN32_NT:
- return "Windows NT";
- default:
- return "Unknown";
- }
-}
-
-
-std::string EnvironmentImpl::osDisplayNameImpl()
-{
- 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)
- {
- case 10:
- switch (vi.dwMinorVersion)
- {
- case 0:
- return vi.wProductType == VER_NT_WORKSTATION ? "Windows 10" : "Windows Server 2016";
- }
- case 6:
- switch (vi.dwMinorVersion)
- {
- case 0:
- return vi.wProductType == VER_NT_WORKSTATION ? "Windows Vista" : "Windows Server 2008";
- case 1:
- return vi.wProductType == VER_NT_WORKSTATION ? "Windows 7" : "Windows Server 2008 R2";
- case 2:
- return vi.wProductType == VER_NT_WORKSTATION ? "Windows 8" : "Windows Server 2012";
- case 3:
- return vi.wProductType == VER_NT_WORKSTATION ? "Windows 8.1" : "Windows Server 2012 R2";
- default:
- return "Unknown";
- }
- case 5:
- switch (vi.dwMinorVersion)
- {
- case 0:
- return "Windows 2000";
- case 1:
- return "Windows XP";
- case 2:
- return "Windows Server 2003/Windows Server 2003 R2";
- default:
- return "Unknown";
- }
- default:
- return "Unknown";
- }
-}
-
-
-std::string EnvironmentImpl::osVersionImpl()
-{
- OSVERSIONINFO vi;
- vi.dwOSVersionInfoSize = sizeof(vi);
- if (GetVersionEx(&vi) == 0) throw SystemException("Cannot get OS version information");
- std::ostringstream str;
- str << vi.dwMajorVersion << "." << vi.dwMinorVersion << " (Build " << (vi.dwBuildNumber & 0xFFFF);
- if (vi.szCSDVersion[0]) str << ": " << vi.szCSDVersion;
- str << ")";
- return str.str();
-}
-
-
-std::string EnvironmentImpl::osArchitectureImpl()
-{
- SYSTEM_INFO si;
- GetSystemInfo(&si);
- switch (si.wProcessorArchitecture)
- {
- case PROCESSOR_ARCHITECTURE_INTEL:
- return "IA32";
- case PROCESSOR_ARCHITECTURE_MIPS:
- return "MIPS";
- case PROCESSOR_ARCHITECTURE_ALPHA:
- return "ALPHA";
- case PROCESSOR_ARCHITECTURE_PPC:
- return "PPC";
- case PROCESSOR_ARCHITECTURE_IA64:
- return "IA64";
-#ifdef PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
- case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
- return "IA64/32";
-#endif
-#ifdef PROCESSOR_ARCHITECTURE_AMD64
- case PROCESSOR_ARCHITECTURE_AMD64:
- return "AMD64";
-#endif
- default:
- return "Unknown";
- }
-}
-
-
-std::string EnvironmentImpl::nodeNameImpl()
-{
- char name[MAX_COMPUTERNAME_LENGTH + 1];
- DWORD size = sizeof(name);
- if (GetComputerNameA(name, &size) == 0) throw SystemException("Cannot get computer name");
- return std::string(name);
-}
-
-
-void EnvironmentImpl::nodeIdImpl(NodeId& id)
-{
- std::memset(&id, 0, sizeof(id));
-
- PIP_ADAPTER_INFO pAdapterInfo;
- PIP_ADAPTER_INFO pAdapter = 0;
- ULONG len = sizeof(IP_ADAPTER_INFO);
- pAdapterInfo = reinterpret_cast<IP_ADAPTER_INFO*>(new char[len]);
- // Make an initial call to GetAdaptersInfo to get
- // the necessary size into len
- DWORD rc = GetAdaptersInfo(pAdapterInfo, &len);
- 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;
- }
- if (GetAdaptersInfo(pAdapterInfo, &len) == NO_ERROR)
- {
- pAdapter = pAdapterInfo;
- bool found = false;
- while (pAdapter && !found)
- {
- if (pAdapter->Type == MIB_IF_TYPE_ETHERNET && pAdapter->AddressLength == sizeof(id))
- {
- found = true;
- std::memcpy(&id, pAdapter->Address, pAdapter->AddressLength);
- }
- pAdapter = pAdapter->Next;
- }
- }
- delete [] reinterpret_cast<char*>(pAdapterInfo);
-}
-
-
-unsigned EnvironmentImpl::processorCountImpl()
-{
- SYSTEM_INFO si;
- GetSystemInfo(&si);
- return si.dwNumberOfProcessors;
-}
-
-
-} // namespace Poco
+//
+// Environment_WIN32.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: Environment
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Environment_WIN32.h"
+#include "Poco/Exception.h"
+#include <sstream>
+#include <cstring>
+#include "Poco/UnWindows.h"
+#include <winsock2.h>
+#include <wincrypt.h>
+#include <ws2ipdef.h>
+#include <iphlpapi.h>
+
+
+namespace Poco {
+
+
+std::string EnvironmentImpl::getImpl(const std::string& name)
+{
+ DWORD len = GetEnvironmentVariableA(name.c_str(), 0, 0);
+ if (len == 0) throw NotFoundException(name);
+ char* buffer = new char[len];
+ GetEnvironmentVariableA(name.c_str(), buffer, len);
+ std::string result(buffer);
+ delete [] buffer;
+ return result;
+}
+
+
+bool EnvironmentImpl::hasImpl(const std::string& name)
+{
+ DWORD len = GetEnvironmentVariableA(name.c_str(), 0, 0);
+ return len > 0;
+}
+
+
+void EnvironmentImpl::setImpl(const std::string& name, const std::string& value)
+{
+ if (SetEnvironmentVariableA(name.c_str(), value.c_str()) == 0)
+ {
+ std::string msg = "cannot set environment variable: ";
+ msg.append(name);
+ throw SystemException(msg);
+ }
+}
+
+
+std::string EnvironmentImpl::osNameImpl()
+{
+ OSVERSIONINFO vi;
+ vi.dwOSVersionInfoSize = sizeof(vi);
+ if (GetVersionEx(&vi) == 0) throw SystemException("Cannot get OS version information");
+ switch (vi.dwPlatformId)
+ {
+ case VER_PLATFORM_WIN32s:
+ return "Windows 3.x";
+ case VER_PLATFORM_WIN32_WINDOWS:
+ return vi.dwMinorVersion == 0 ? "Windows 95" : "Windows 98";
+ case VER_PLATFORM_WIN32_NT:
+ return "Windows NT";
+ default:
+ return "Unknown";
+ }
+}
+
+
+std::string EnvironmentImpl::osDisplayNameImpl()
+{
+ 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)
+ {
+ case 10:
+ switch (vi.dwMinorVersion)
+ {
+ case 0:
+ return vi.wProductType == VER_NT_WORKSTATION ? "Windows 10" : "Windows Server 2016";
+ }
+ case 6:
+ switch (vi.dwMinorVersion)
+ {
+ case 0:
+ return vi.wProductType == VER_NT_WORKSTATION ? "Windows Vista" : "Windows Server 2008";
+ case 1:
+ return vi.wProductType == VER_NT_WORKSTATION ? "Windows 7" : "Windows Server 2008 R2";
+ case 2:
+ return vi.wProductType == VER_NT_WORKSTATION ? "Windows 8" : "Windows Server 2012";
+ case 3:
+ return vi.wProductType == VER_NT_WORKSTATION ? "Windows 8.1" : "Windows Server 2012 R2";
+ default:
+ return "Unknown";
+ }
+ case 5:
+ switch (vi.dwMinorVersion)
+ {
+ case 0:
+ return "Windows 2000";
+ case 1:
+ return "Windows XP";
+ case 2:
+ return "Windows Server 2003/Windows Server 2003 R2";
+ default:
+ return "Unknown";
+ }
+ default:
+ return "Unknown";
+ }
+}
+
+
+std::string EnvironmentImpl::osVersionImpl()
+{
+ OSVERSIONINFO vi;
+ vi.dwOSVersionInfoSize = sizeof(vi);
+ if (GetVersionEx(&vi) == 0) throw SystemException("Cannot get OS version information");
+ std::ostringstream str;
+ str << vi.dwMajorVersion << "." << vi.dwMinorVersion << " (Build " << (vi.dwBuildNumber & 0xFFFF);
+ if (vi.szCSDVersion[0]) str << ": " << vi.szCSDVersion;
+ str << ")";
+ return str.str();
+}
+
+
+std::string EnvironmentImpl::osArchitectureImpl()
+{
+ SYSTEM_INFO si;
+ GetSystemInfo(&si);
+ switch (si.wProcessorArchitecture)
+ {
+ case PROCESSOR_ARCHITECTURE_INTEL:
+ return "IA32";
+ case PROCESSOR_ARCHITECTURE_MIPS:
+ return "MIPS";
+ case PROCESSOR_ARCHITECTURE_ALPHA:
+ return "ALPHA";
+ case PROCESSOR_ARCHITECTURE_PPC:
+ return "PPC";
+ case PROCESSOR_ARCHITECTURE_IA64:
+ return "IA64";
+#ifdef PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
+ case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
+ return "IA64/32";
+#endif
+#ifdef PROCESSOR_ARCHITECTURE_AMD64
+ case PROCESSOR_ARCHITECTURE_AMD64:
+ return "AMD64";
+#endif
+ default:
+ return "Unknown";
+ }
+}
+
+
+std::string EnvironmentImpl::nodeNameImpl()
+{
+ char name[MAX_COMPUTERNAME_LENGTH + 1];
+ DWORD size = sizeof(name);
+ if (GetComputerNameA(name, &size) == 0) throw SystemException("Cannot get computer name");
+ return std::string(name);
+}
+
+
+void EnvironmentImpl::nodeIdImpl(NodeId& id)
+{
+ std::memset(&id, 0, sizeof(id));
+
+ PIP_ADAPTER_INFO pAdapterInfo;
+ PIP_ADAPTER_INFO pAdapter = 0;
+ ULONG len = sizeof(IP_ADAPTER_INFO);
+ pAdapterInfo = reinterpret_cast<IP_ADAPTER_INFO*>(new char[len]);
+ // Make an initial call to GetAdaptersInfo to get
+ // the necessary size into len
+ DWORD rc = GetAdaptersInfo(pAdapterInfo, &len);
+ 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;
+ }
+ if (GetAdaptersInfo(pAdapterInfo, &len) == NO_ERROR)
+ {
+ pAdapter = pAdapterInfo;
+ bool found = false;
+ while (pAdapter && !found)
+ {
+ if (pAdapter->Type == MIB_IF_TYPE_ETHERNET && pAdapter->AddressLength == sizeof(id))
+ {
+ found = true;
+ std::memcpy(&id, pAdapter->Address, pAdapter->AddressLength);
+ }
+ pAdapter = pAdapter->Next;
+ }
+ }
+ delete [] reinterpret_cast<char*>(pAdapterInfo);
+}
+
+
+unsigned EnvironmentImpl::processorCountImpl()
+{
+ SYSTEM_INFO si;
+ GetSystemInfo(&si);
+ return si.dwNumberOfProcessors;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Environment_WIN32U.cpp b/contrib/libs/poco/Foundation/src/Environment_WIN32U.cpp
index 624ff83c8c..ca18e44dc1 100644
--- a/contrib/libs/poco/Foundation/src/Environment_WIN32U.cpp
+++ b/contrib/libs/poco/Foundation/src/Environment_WIN32U.cpp
@@ -1,235 +1,235 @@
-//
-// Environment_WIN32U.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: Environment
-//
-// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Environment_WIN32U.h"
-#include "Poco/Exception.h"
-#include "Poco/UnicodeConverter.h"
-#include "Poco/Buffer.h"
-#include <sstream>
-#include <cstring>
-#include "Poco/UnWindows.h"
-#include <winsock2.h>
-#include <wincrypt.h>
-#include <ws2ipdef.h>
-#include <iphlpapi.h>
-
-
-namespace Poco {
-
-
-std::string EnvironmentImpl::getImpl(const std::string& name)
-{
- std::wstring uname;
- UnicodeConverter::toUTF16(name, uname);
- DWORD len = GetEnvironmentVariableW(uname.c_str(), 0, 0);
- if (len == 0) throw NotFoundException(name);
- Buffer<wchar_t> buffer(len);
- GetEnvironmentVariableW(uname.c_str(), buffer.begin(), len);
- std::string result;
- UnicodeConverter::toUTF8(buffer.begin(), len - 1, result);
- return result;
-}
-
-
-bool EnvironmentImpl::hasImpl(const std::string& name)
-{
- std::wstring uname;
- UnicodeConverter::toUTF16(name, uname);
- DWORD len = GetEnvironmentVariableW(uname.c_str(), 0, 0);
- return len > 0;
-}
-
-
-void EnvironmentImpl::setImpl(const std::string& name, const std::string& value)
-{
- std::wstring uname;
- std::wstring uvalue;
- UnicodeConverter::toUTF16(name, uname);
- UnicodeConverter::toUTF16(value, uvalue);
- if (SetEnvironmentVariableW(uname.c_str(), uvalue.c_str()) == 0)
- {
- std::string msg = "cannot set environment variable: ";
- msg.append(name);
- throw SystemException(msg);
- }
-}
-
-
-std::string EnvironmentImpl::osNameImpl()
-{
- OSVERSIONINFO vi;
- vi.dwOSVersionInfoSize = sizeof(vi);
- if (GetVersionEx(&vi) == 0) throw SystemException("Cannot get OS version information");
- switch (vi.dwPlatformId)
- {
- case VER_PLATFORM_WIN32s:
- return "Windows 3.x";
- case VER_PLATFORM_WIN32_WINDOWS:
- return vi.dwMinorVersion == 0 ? "Windows 95" : "Windows 98";
- case VER_PLATFORM_WIN32_NT:
- return "Windows NT";
- default:
- return "Unknown";
- }
-}
-
-
-std::string EnvironmentImpl::osDisplayNameImpl()
-{
- 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)
- {
- case 10:
- switch (vi.dwMinorVersion)
- {
- case 0:
- return vi.wProductType == VER_NT_WORKSTATION ? "Windows 10" : "Windows Server 2016";
- }
- case 6:
- switch (vi.dwMinorVersion)
- {
- case 0:
- return vi.wProductType == VER_NT_WORKSTATION ? "Windows Vista" : "Windows Server 2008";
- case 1:
- return vi.wProductType == VER_NT_WORKSTATION ? "Windows 7" : "Windows Server 2008 R2";
- case 2:
- return vi.wProductType == VER_NT_WORKSTATION ? "Windows 8" : "Windows Server 2012";
- case 3:
- return vi.wProductType == VER_NT_WORKSTATION ? "Windows 8.1" : "Windows Server 2012 R2";
- default:
- return "Unknown";
- }
- case 5:
- switch (vi.dwMinorVersion)
- {
- case 0:
- return "Windows 2000";
- case 1:
- return "Windows XP";
- case 2:
- return "Windows Server 2003/Windows Server 2003 R2";
- default:
- return "Unknown";
- }
- default:
- return "Unknown";
- }
-}
-
-
-std::string EnvironmentImpl::osVersionImpl()
-{
- OSVERSIONINFOW vi;
- vi.dwOSVersionInfoSize = sizeof(vi);
- if (GetVersionExW(&vi) == 0) throw SystemException("Cannot get OS version information");
- std::ostringstream str;
- str << vi.dwMajorVersion << "." << vi.dwMinorVersion << " (Build " << (vi.dwBuildNumber & 0xFFFF);
- std::string version;
- UnicodeConverter::toUTF8(vi.szCSDVersion, version);
- if (!version.empty()) str << ": " << version;
- str << ")";
- return str.str();
-}
-
-
-std::string EnvironmentImpl::osArchitectureImpl()
-{
- SYSTEM_INFO si;
- GetSystemInfo(&si);
- switch (si.wProcessorArchitecture)
- {
- case PROCESSOR_ARCHITECTURE_INTEL:
- return "IA32";
- case PROCESSOR_ARCHITECTURE_MIPS:
- return "MIPS";
- case PROCESSOR_ARCHITECTURE_ALPHA:
- return "ALPHA";
- case PROCESSOR_ARCHITECTURE_PPC:
- return "PPC";
- case PROCESSOR_ARCHITECTURE_IA64:
- return "IA64";
-#ifdef PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
- case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
- return "IA64/32";
-#endif
-#ifdef PROCESSOR_ARCHITECTURE_AMD64
- case PROCESSOR_ARCHITECTURE_AMD64:
- return "AMD64";
-#endif
- default:
- return "Unknown";
- }
-}
-
-
-std::string EnvironmentImpl::nodeNameImpl()
-{
- wchar_t name[MAX_COMPUTERNAME_LENGTH + 1];
- DWORD size = MAX_COMPUTERNAME_LENGTH + 1;
- if (GetComputerNameW(name, &size) == 0) throw SystemException("Cannot get computer name");
- std::string result;
- UnicodeConverter::toUTF8(name, result);
- return result;
-}
-
-
-void EnvironmentImpl::nodeIdImpl(NodeId& id)
-{
- std::memset(&id, 0, sizeof(id));
-
- PIP_ADAPTER_INFO pAdapterInfo;
- PIP_ADAPTER_INFO pAdapter = 0;
- ULONG len = sizeof(IP_ADAPTER_INFO);
- pAdapterInfo = reinterpret_cast<IP_ADAPTER_INFO*>(new char[len]);
- // Make an initial call to GetAdaptersInfo to get
- // the necessary size into len
- DWORD rc = GetAdaptersInfo(pAdapterInfo, &len);
- 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;
- }
- if (GetAdaptersInfo(pAdapterInfo, &len) == NO_ERROR)
- {
- pAdapter = pAdapterInfo;
- bool found = false;
- while (pAdapter && !found)
- {
- if (pAdapter->Type == MIB_IF_TYPE_ETHERNET && pAdapter->AddressLength == sizeof(id))
- {
- found = true;
- std::memcpy(&id, pAdapter->Address, pAdapter->AddressLength);
- }
- pAdapter = pAdapter->Next;
- }
- }
- delete [] reinterpret_cast<char*>(pAdapterInfo);
-}
-
-
-unsigned EnvironmentImpl::processorCountImpl()
-{
- SYSTEM_INFO si;
- GetSystemInfo(&si);
- return si.dwNumberOfProcessors;
-}
-
-
-} // namespace Poco
+//
+// Environment_WIN32U.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: Environment
+//
+// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Environment_WIN32U.h"
+#include "Poco/Exception.h"
+#include "Poco/UnicodeConverter.h"
+#include "Poco/Buffer.h"
+#include <sstream>
+#include <cstring>
+#include "Poco/UnWindows.h"
+#include <winsock2.h>
+#include <wincrypt.h>
+#include <ws2ipdef.h>
+#include <iphlpapi.h>
+
+
+namespace Poco {
+
+
+std::string EnvironmentImpl::getImpl(const std::string& name)
+{
+ std::wstring uname;
+ UnicodeConverter::toUTF16(name, uname);
+ DWORD len = GetEnvironmentVariableW(uname.c_str(), 0, 0);
+ if (len == 0) throw NotFoundException(name);
+ Buffer<wchar_t> buffer(len);
+ GetEnvironmentVariableW(uname.c_str(), buffer.begin(), len);
+ std::string result;
+ UnicodeConverter::toUTF8(buffer.begin(), len - 1, result);
+ return result;
+}
+
+
+bool EnvironmentImpl::hasImpl(const std::string& name)
+{
+ std::wstring uname;
+ UnicodeConverter::toUTF16(name, uname);
+ DWORD len = GetEnvironmentVariableW(uname.c_str(), 0, 0);
+ return len > 0;
+}
+
+
+void EnvironmentImpl::setImpl(const std::string& name, const std::string& value)
+{
+ std::wstring uname;
+ std::wstring uvalue;
+ UnicodeConverter::toUTF16(name, uname);
+ UnicodeConverter::toUTF16(value, uvalue);
+ if (SetEnvironmentVariableW(uname.c_str(), uvalue.c_str()) == 0)
+ {
+ std::string msg = "cannot set environment variable: ";
+ msg.append(name);
+ throw SystemException(msg);
+ }
+}
+
+
+std::string EnvironmentImpl::osNameImpl()
+{
+ OSVERSIONINFO vi;
+ vi.dwOSVersionInfoSize = sizeof(vi);
+ if (GetVersionEx(&vi) == 0) throw SystemException("Cannot get OS version information");
+ switch (vi.dwPlatformId)
+ {
+ case VER_PLATFORM_WIN32s:
+ return "Windows 3.x";
+ case VER_PLATFORM_WIN32_WINDOWS:
+ return vi.dwMinorVersion == 0 ? "Windows 95" : "Windows 98";
+ case VER_PLATFORM_WIN32_NT:
+ return "Windows NT";
+ default:
+ return "Unknown";
+ }
+}
+
+
+std::string EnvironmentImpl::osDisplayNameImpl()
+{
+ 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)
+ {
+ case 10:
+ switch (vi.dwMinorVersion)
+ {
+ case 0:
+ return vi.wProductType == VER_NT_WORKSTATION ? "Windows 10" : "Windows Server 2016";
+ }
+ case 6:
+ switch (vi.dwMinorVersion)
+ {
+ case 0:
+ return vi.wProductType == VER_NT_WORKSTATION ? "Windows Vista" : "Windows Server 2008";
+ case 1:
+ return vi.wProductType == VER_NT_WORKSTATION ? "Windows 7" : "Windows Server 2008 R2";
+ case 2:
+ return vi.wProductType == VER_NT_WORKSTATION ? "Windows 8" : "Windows Server 2012";
+ case 3:
+ return vi.wProductType == VER_NT_WORKSTATION ? "Windows 8.1" : "Windows Server 2012 R2";
+ default:
+ return "Unknown";
+ }
+ case 5:
+ switch (vi.dwMinorVersion)
+ {
+ case 0:
+ return "Windows 2000";
+ case 1:
+ return "Windows XP";
+ case 2:
+ return "Windows Server 2003/Windows Server 2003 R2";
+ default:
+ return "Unknown";
+ }
+ default:
+ return "Unknown";
+ }
+}
+
+
+std::string EnvironmentImpl::osVersionImpl()
+{
+ OSVERSIONINFOW vi;
+ vi.dwOSVersionInfoSize = sizeof(vi);
+ if (GetVersionExW(&vi) == 0) throw SystemException("Cannot get OS version information");
+ std::ostringstream str;
+ str << vi.dwMajorVersion << "." << vi.dwMinorVersion << " (Build " << (vi.dwBuildNumber & 0xFFFF);
+ std::string version;
+ UnicodeConverter::toUTF8(vi.szCSDVersion, version);
+ if (!version.empty()) str << ": " << version;
+ str << ")";
+ return str.str();
+}
+
+
+std::string EnvironmentImpl::osArchitectureImpl()
+{
+ SYSTEM_INFO si;
+ GetSystemInfo(&si);
+ switch (si.wProcessorArchitecture)
+ {
+ case PROCESSOR_ARCHITECTURE_INTEL:
+ return "IA32";
+ case PROCESSOR_ARCHITECTURE_MIPS:
+ return "MIPS";
+ case PROCESSOR_ARCHITECTURE_ALPHA:
+ return "ALPHA";
+ case PROCESSOR_ARCHITECTURE_PPC:
+ return "PPC";
+ case PROCESSOR_ARCHITECTURE_IA64:
+ return "IA64";
+#ifdef PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
+ case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
+ return "IA64/32";
+#endif
+#ifdef PROCESSOR_ARCHITECTURE_AMD64
+ case PROCESSOR_ARCHITECTURE_AMD64:
+ return "AMD64";
+#endif
+ default:
+ return "Unknown";
+ }
+}
+
+
+std::string EnvironmentImpl::nodeNameImpl()
+{
+ wchar_t name[MAX_COMPUTERNAME_LENGTH + 1];
+ DWORD size = MAX_COMPUTERNAME_LENGTH + 1;
+ if (GetComputerNameW(name, &size) == 0) throw SystemException("Cannot get computer name");
+ std::string result;
+ UnicodeConverter::toUTF8(name, result);
+ return result;
+}
+
+
+void EnvironmentImpl::nodeIdImpl(NodeId& id)
+{
+ std::memset(&id, 0, sizeof(id));
+
+ PIP_ADAPTER_INFO pAdapterInfo;
+ PIP_ADAPTER_INFO pAdapter = 0;
+ ULONG len = sizeof(IP_ADAPTER_INFO);
+ pAdapterInfo = reinterpret_cast<IP_ADAPTER_INFO*>(new char[len]);
+ // Make an initial call to GetAdaptersInfo to get
+ // the necessary size into len
+ DWORD rc = GetAdaptersInfo(pAdapterInfo, &len);
+ 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;
+ }
+ if (GetAdaptersInfo(pAdapterInfo, &len) == NO_ERROR)
+ {
+ pAdapter = pAdapterInfo;
+ bool found = false;
+ while (pAdapter && !found)
+ {
+ if (pAdapter->Type == MIB_IF_TYPE_ETHERNET && pAdapter->AddressLength == sizeof(id))
+ {
+ found = true;
+ std::memcpy(&id, pAdapter->Address, pAdapter->AddressLength);
+ }
+ pAdapter = pAdapter->Next;
+ }
+ }
+ delete [] reinterpret_cast<char*>(pAdapterInfo);
+}
+
+
+unsigned EnvironmentImpl::processorCountImpl()
+{
+ SYSTEM_INFO si;
+ GetSystemInfo(&si);
+ return si.dwNumberOfProcessors;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Environment_WINCE.cpp b/contrib/libs/poco/Foundation/src/Environment_WINCE.cpp
index afa59b68d3..3186d0df11 100644
--- a/contrib/libs/poco/Foundation/src/Environment_WINCE.cpp
+++ b/contrib/libs/poco/Foundation/src/Environment_WINCE.cpp
@@ -1,243 +1,243 @@
-//
-// Environment_WINCE.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: Environment
-//
-// Copyright (c) 2009-2010, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Environment_WINCE.h"
-#include "Poco/Exception.h"
-#include "Poco/UnicodeConverter.h"
-#include "Poco/String.h"
-#include "Poco/Path.h"
-#include "Poco/NumberFormatter.h"
-#include <sstream>
-#include <cstring>
-#include <windows.h>
-#include <iphlpapi.h>
-
-
-namespace Poco {
-
-
-const std::string EnvironmentImpl::TEMP("TEMP");
-const std::string EnvironmentImpl::TMP("TMP");
-const std::string EnvironmentImpl::HOMEPATH("HOMEPATH");
-const std::string EnvironmentImpl::COMPUTERNAME("COMPUTERNAME");
-const std::string EnvironmentImpl::OS("OS");
-const std::string EnvironmentImpl::NUMBER_OF_PROCESSORS("NUMBER_OF_PROCESSORS");
-const std::string EnvironmentImpl::PROCESSOR_ARCHITECTURE("PROCESSOR_ARCHITECTURE");
-
-
-std::string EnvironmentImpl::getImpl(const std::string& name)
-{
- std::string value;
- if (!envVar(name, &value)) throw NotFoundException(name);
- return value;
-}
-
-
-bool EnvironmentImpl::hasImpl(const std::string& name)
-{
- return envVar(name, 0);
-}
-
-
-void EnvironmentImpl::setImpl(const std::string& name, const std::string& value)
-{
- throw NotImplementedException("Cannot set environment variables on Windows CE");
-}
-
-
-std::string EnvironmentImpl::osNameImpl()
-{
- return "Windows CE";
-}
-
-
-std::string EnvironmentImpl::osDisplayNameImpl()
-{
- return osNameImpl();
-}
-
-
-std::string EnvironmentImpl::osVersionImpl()
-{
- OSVERSIONINFOW vi;
- vi.dwOSVersionInfoSize = sizeof(vi);
- if (GetVersionExW(&vi) == 0) throw SystemException("Cannot get OS version information");
- std::ostringstream str;
- str << vi.dwMajorVersion << "." << vi.dwMinorVersion << " (Build " << (vi.dwBuildNumber & 0xFFFF);
- std::string version;
- UnicodeConverter::toUTF8(vi.szCSDVersion, version);
- if (!version.empty()) str << ": " << version;
- str << ")";
- return str.str();
-}
-
-
-std::string EnvironmentImpl::osArchitectureImpl()
-{
- SYSTEM_INFO si;
- GetSystemInfo(&si);
- switch (si.wProcessorArchitecture)
- {
- case PROCESSOR_ARCHITECTURE_INTEL:
- return "IA32";
- case PROCESSOR_ARCHITECTURE_MIPS:
- return "MIPS";
- case PROCESSOR_ARCHITECTURE_ALPHA:
- return "ALPHA";
- case PROCESSOR_ARCHITECTURE_PPC:
- return "PPC";
- case PROCESSOR_ARCHITECTURE_IA64:
- return "IA64";
-#ifdef PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
- case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
- return "IA64/32";
-#endif
-#ifdef PROCESSOR_ARCHITECTURE_AMD64
- case PROCESSOR_ARCHITECTURE_AMD64:
- return "AMD64";
-#endif
- case PROCESSOR_ARCHITECTURE_SHX:
- return "SHX";
- case PROCESSOR_ARCHITECTURE_ARM:
- return "ARM";
- default:
- return "Unknown";
- }
-}
-
-
-std::string EnvironmentImpl::nodeNameImpl()
-{
- HKEY hKey;
- DWORD dwDisposition;
- 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;
- DWORD dwType;
- BYTE bData[1026];
- DWORD dwData = sizeof(bData);
- if (RegQueryValueExW(hKey, L"Name", 0, &dwType, bData, &dwData) == ERROR_SUCCESS)
- {
- switch (dwType)
- {
- case REG_SZ:
- UnicodeConverter::toUTF8(reinterpret_cast<wchar_t*>(bData), value);
- break;
-
- default:
- RegCloseKey(hKey);
- throw SystemException("Cannot get node name", "registry value has wrong type");
- }
- }
- else
- {
- RegCloseKey(hKey);
- throw SystemException("Cannot get node name", "registry value not found");
- }
- RegCloseKey(hKey);
- return value;
-}
-
-
-void EnvironmentImpl::nodeIdImpl(NodeId& id)
-{
- PIP_ADAPTER_INFO pAdapterInfo;
- PIP_ADAPTER_INFO pAdapter = 0;
- ULONG len = sizeof(IP_ADAPTER_INFO);
- pAdapterInfo = reinterpret_cast<IP_ADAPTER_INFO*>(new char[len]);
- // Make an initial call to GetAdaptersInfo to get
- // the necessary size into len
- DWORD rc = GetAdaptersInfo(pAdapterInfo, &len);
- if (rc == ERROR_BUFFER_OVERFLOW)
- {
- delete [] reinterpret_cast<char*>(pAdapterInfo);
- pAdapterInfo = reinterpret_cast<IP_ADAPTER_INFO*>(new char[len]);
- }
- else if (rc != ERROR_SUCCESS)
- {
- throw SystemException("cannot get network adapter list");
- }
- try
- {
- bool found = false;
- if (GetAdaptersInfo(pAdapterInfo, &len) == NO_ERROR)
- {
- pAdapter = pAdapterInfo;
- while (pAdapter && !found)
- {
- if (pAdapter->Type == MIB_IF_TYPE_ETHERNET && pAdapter->AddressLength == sizeof(id))
- {
- std::memcpy(&id, pAdapter->Address, pAdapter->AddressLength);
- found = true;
- }
- pAdapter = pAdapter->Next;
- }
- }
- else throw SystemException("cannot get network adapter list");
- if (!found) throw SystemException("no Ethernet adapter found");
- }
- catch (Exception&)
- {
- delete [] reinterpret_cast<char*>(pAdapterInfo);
- throw;
- }
- delete [] reinterpret_cast<char*>(pAdapterInfo);
-}
-
-
-unsigned EnvironmentImpl::processorCountImpl()
-{
- SYSTEM_INFO si;
- GetSystemInfo(&si);
- return si.dwNumberOfProcessors;
-}
-
-
-bool EnvironmentImpl::envVar(const std::string& name, std::string* value)
-{
- if (icompare(name, TEMP) == 0)
- {
- if (value) *value = Path::temp();
- }
- else if (icompare(name, TMP) == 0)
- {
- if (value) *value = Path::temp();
- }
- else if (icompare(name, HOMEPATH) == 0)
- {
- if (value) *value = Path::home();
- }
- else if (icompare(name, COMPUTERNAME) == 0)
- {
- if (value) *value = nodeNameImpl();
- }
- else if (icompare(name, OS) == 0)
- {
- if (value) *value = osNameImpl();
- }
- else if (icompare(name, NUMBER_OF_PROCESSORS) == 0)
- {
- if (value) *value = NumberFormatter::format(processorCountImpl());
- }
- else if (icompare(name, PROCESSOR_ARCHITECTURE) == 0)
- {
- if (value) *value = osArchitectureImpl();
- }
- else return false;
- return true;
-}
-
-
-} // namespace Poco
+//
+// Environment_WINCE.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: Environment
+//
+// Copyright (c) 2009-2010, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Environment_WINCE.h"
+#include "Poco/Exception.h"
+#include "Poco/UnicodeConverter.h"
+#include "Poco/String.h"
+#include "Poco/Path.h"
+#include "Poco/NumberFormatter.h"
+#include <sstream>
+#include <cstring>
+#include <windows.h>
+#include <iphlpapi.h>
+
+
+namespace Poco {
+
+
+const std::string EnvironmentImpl::TEMP("TEMP");
+const std::string EnvironmentImpl::TMP("TMP");
+const std::string EnvironmentImpl::HOMEPATH("HOMEPATH");
+const std::string EnvironmentImpl::COMPUTERNAME("COMPUTERNAME");
+const std::string EnvironmentImpl::OS("OS");
+const std::string EnvironmentImpl::NUMBER_OF_PROCESSORS("NUMBER_OF_PROCESSORS");
+const std::string EnvironmentImpl::PROCESSOR_ARCHITECTURE("PROCESSOR_ARCHITECTURE");
+
+
+std::string EnvironmentImpl::getImpl(const std::string& name)
+{
+ std::string value;
+ if (!envVar(name, &value)) throw NotFoundException(name);
+ return value;
+}
+
+
+bool EnvironmentImpl::hasImpl(const std::string& name)
+{
+ return envVar(name, 0);
+}
+
+
+void EnvironmentImpl::setImpl(const std::string& name, const std::string& value)
+{
+ throw NotImplementedException("Cannot set environment variables on Windows CE");
+}
+
+
+std::string EnvironmentImpl::osNameImpl()
+{
+ return "Windows CE";
+}
+
+
+std::string EnvironmentImpl::osDisplayNameImpl()
+{
+ return osNameImpl();
+}
+
+
+std::string EnvironmentImpl::osVersionImpl()
+{
+ OSVERSIONINFOW vi;
+ vi.dwOSVersionInfoSize = sizeof(vi);
+ if (GetVersionExW(&vi) == 0) throw SystemException("Cannot get OS version information");
+ std::ostringstream str;
+ str << vi.dwMajorVersion << "." << vi.dwMinorVersion << " (Build " << (vi.dwBuildNumber & 0xFFFF);
+ std::string version;
+ UnicodeConverter::toUTF8(vi.szCSDVersion, version);
+ if (!version.empty()) str << ": " << version;
+ str << ")";
+ return str.str();
+}
+
+
+std::string EnvironmentImpl::osArchitectureImpl()
+{
+ SYSTEM_INFO si;
+ GetSystemInfo(&si);
+ switch (si.wProcessorArchitecture)
+ {
+ case PROCESSOR_ARCHITECTURE_INTEL:
+ return "IA32";
+ case PROCESSOR_ARCHITECTURE_MIPS:
+ return "MIPS";
+ case PROCESSOR_ARCHITECTURE_ALPHA:
+ return "ALPHA";
+ case PROCESSOR_ARCHITECTURE_PPC:
+ return "PPC";
+ case PROCESSOR_ARCHITECTURE_IA64:
+ return "IA64";
+#ifdef PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
+ case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
+ return "IA64/32";
+#endif
+#ifdef PROCESSOR_ARCHITECTURE_AMD64
+ case PROCESSOR_ARCHITECTURE_AMD64:
+ return "AMD64";
+#endif
+ case PROCESSOR_ARCHITECTURE_SHX:
+ return "SHX";
+ case PROCESSOR_ARCHITECTURE_ARM:
+ return "ARM";
+ default:
+ return "Unknown";
+ }
+}
+
+
+std::string EnvironmentImpl::nodeNameImpl()
+{
+ HKEY hKey;
+ DWORD dwDisposition;
+ 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;
+ DWORD dwType;
+ BYTE bData[1026];
+ DWORD dwData = sizeof(bData);
+ if (RegQueryValueExW(hKey, L"Name", 0, &dwType, bData, &dwData) == ERROR_SUCCESS)
+ {
+ switch (dwType)
+ {
+ case REG_SZ:
+ UnicodeConverter::toUTF8(reinterpret_cast<wchar_t*>(bData), value);
+ break;
+
+ default:
+ RegCloseKey(hKey);
+ throw SystemException("Cannot get node name", "registry value has wrong type");
+ }
+ }
+ else
+ {
+ RegCloseKey(hKey);
+ throw SystemException("Cannot get node name", "registry value not found");
+ }
+ RegCloseKey(hKey);
+ return value;
+}
+
+
+void EnvironmentImpl::nodeIdImpl(NodeId& id)
+{
+ PIP_ADAPTER_INFO pAdapterInfo;
+ PIP_ADAPTER_INFO pAdapter = 0;
+ ULONG len = sizeof(IP_ADAPTER_INFO);
+ pAdapterInfo = reinterpret_cast<IP_ADAPTER_INFO*>(new char[len]);
+ // Make an initial call to GetAdaptersInfo to get
+ // the necessary size into len
+ DWORD rc = GetAdaptersInfo(pAdapterInfo, &len);
+ if (rc == ERROR_BUFFER_OVERFLOW)
+ {
+ delete [] reinterpret_cast<char*>(pAdapterInfo);
+ pAdapterInfo = reinterpret_cast<IP_ADAPTER_INFO*>(new char[len]);
+ }
+ else if (rc != ERROR_SUCCESS)
+ {
+ throw SystemException("cannot get network adapter list");
+ }
+ try
+ {
+ bool found = false;
+ if (GetAdaptersInfo(pAdapterInfo, &len) == NO_ERROR)
+ {
+ pAdapter = pAdapterInfo;
+ while (pAdapter && !found)
+ {
+ if (pAdapter->Type == MIB_IF_TYPE_ETHERNET && pAdapter->AddressLength == sizeof(id))
+ {
+ std::memcpy(&id, pAdapter->Address, pAdapter->AddressLength);
+ found = true;
+ }
+ pAdapter = pAdapter->Next;
+ }
+ }
+ else throw SystemException("cannot get network adapter list");
+ if (!found) throw SystemException("no Ethernet adapter found");
+ }
+ catch (Exception&)
+ {
+ delete [] reinterpret_cast<char*>(pAdapterInfo);
+ throw;
+ }
+ delete [] reinterpret_cast<char*>(pAdapterInfo);
+}
+
+
+unsigned EnvironmentImpl::processorCountImpl()
+{
+ SYSTEM_INFO si;
+ GetSystemInfo(&si);
+ return si.dwNumberOfProcessors;
+}
+
+
+bool EnvironmentImpl::envVar(const std::string& name, std::string* value)
+{
+ if (icompare(name, TEMP) == 0)
+ {
+ if (value) *value = Path::temp();
+ }
+ else if (icompare(name, TMP) == 0)
+ {
+ if (value) *value = Path::temp();
+ }
+ else if (icompare(name, HOMEPATH) == 0)
+ {
+ if (value) *value = Path::home();
+ }
+ else if (icompare(name, COMPUTERNAME) == 0)
+ {
+ if (value) *value = nodeNameImpl();
+ }
+ else if (icompare(name, OS) == 0)
+ {
+ if (value) *value = osNameImpl();
+ }
+ else if (icompare(name, NUMBER_OF_PROCESSORS) == 0)
+ {
+ if (value) *value = NumberFormatter::format(processorCountImpl());
+ }
+ else if (icompare(name, PROCESSOR_ARCHITECTURE) == 0)
+ {
+ if (value) *value = osArchitectureImpl();
+ }
+ else return false;
+ return true;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Error.cpp b/contrib/libs/poco/Foundation/src/Error.cpp
index fbd3673f6b..758f143264 100644
--- a/contrib/libs/poco/Foundation/src/Error.cpp
+++ b/contrib/libs/poco/Foundation/src/Error.cpp
@@ -1,117 +1,117 @@
-//
-// Error.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: Error
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Foundation.h"
-#include "Poco/UnicodeConverter.h"
-#include "Poco/Error.h"
-#include <string>
-#include <string.h>
-#include <errno.h>
-
-
-namespace Poco {
-
-
-#ifdef POCO_OS_FAMILY_WINDOWS
-
-
- DWORD Error::last()
- {
- return GetLastError();
- }
-
-
- std::string Error::getMessage(DWORD errorCode)
- {
- std::string errMsg;
- DWORD dwFlg = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
- #if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
- LPWSTR lpMsgBuf = 0;
- if (FormatMessageW(dwFlg, 0, errorCode, 0, (LPWSTR) & lpMsgBuf, 0, NULL))
- UnicodeConverter::toUTF8(lpMsgBuf, errMsg);
- #else
- LPTSTR lpMsgBuf = 0;
- if (FormatMessageA(dwFlg, 0, errorCode, 0, (LPTSTR) & lpMsgBuf, 0, NULL))
- errMsg = lpMsgBuf;
- #endif
- LocalFree(lpMsgBuf);
- return errMsg;
- }
-
-
-#else
-
-
- int Error::last()
- {
- return errno;
- }
-
-
- class StrErrorHelper
- /// This little hack magically handles all variants
- /// of strerror_r() (POSIX and GLIBC) and strerror().
- {
- public:
- explicit StrErrorHelper(int err)
- {
- _buffer[0] = 0;
-
-#if (_XOPEN_SOURCE >= 600) || POCO_OS == POCO_OS_ANDROID || __APPLE__
- setMessage(strerror_r(err, _buffer, sizeof(_buffer)));
-#elif _GNU_SOURCE
- setMessage(strerror_r(err, _buffer, sizeof(_buffer)));
-#else
- setMessage(strerror(err));
-#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;
- };
-
- std::string Error::getMessage(int errorCode)
- {
- StrErrorHelper helper(errorCode);
- return helper.message();
- }
-
-
-#endif
-
-
-} // namespace Poco
+//
+// Error.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: Error
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Foundation.h"
+#include "Poco/UnicodeConverter.h"
+#include "Poco/Error.h"
+#include <string>
+#include <string.h>
+#include <errno.h>
+
+
+namespace Poco {
+
+
+#ifdef POCO_OS_FAMILY_WINDOWS
+
+
+ DWORD Error::last()
+ {
+ return GetLastError();
+ }
+
+
+ std::string Error::getMessage(DWORD errorCode)
+ {
+ std::string errMsg;
+ DWORD dwFlg = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
+ #if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
+ LPWSTR lpMsgBuf = 0;
+ if (FormatMessageW(dwFlg, 0, errorCode, 0, (LPWSTR) & lpMsgBuf, 0, NULL))
+ UnicodeConverter::toUTF8(lpMsgBuf, errMsg);
+ #else
+ LPTSTR lpMsgBuf = 0;
+ if (FormatMessageA(dwFlg, 0, errorCode, 0, (LPTSTR) & lpMsgBuf, 0, NULL))
+ errMsg = lpMsgBuf;
+ #endif
+ LocalFree(lpMsgBuf);
+ return errMsg;
+ }
+
+
+#else
+
+
+ int Error::last()
+ {
+ return errno;
+ }
+
+
+ class StrErrorHelper
+ /// This little hack magically handles all variants
+ /// of strerror_r() (POSIX and GLIBC) and strerror().
+ {
+ public:
+ explicit StrErrorHelper(int err)
+ {
+ _buffer[0] = 0;
+
+#if (_XOPEN_SOURCE >= 600) || POCO_OS == POCO_OS_ANDROID || __APPLE__
+ setMessage(strerror_r(err, _buffer, sizeof(_buffer)));
+#elif _GNU_SOURCE
+ setMessage(strerror_r(err, _buffer, sizeof(_buffer)));
+#else
+ setMessage(strerror(err));
+#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;
+ };
+
+ std::string Error::getMessage(int errorCode)
+ {
+ StrErrorHelper helper(errorCode);
+ return helper.message();
+ }
+
+
+#endif
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/ErrorHandler.cpp b/contrib/libs/poco/Foundation/src/ErrorHandler.cpp
index d0af8ea8a1..582565dc3f 100644
--- a/contrib/libs/poco/Foundation/src/ErrorHandler.cpp
+++ b/contrib/libs/poco/Foundation/src/ErrorHandler.cpp
@@ -1,114 +1,114 @@
-//
-// ErrorHandler.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: ErrorHandler
-//
-// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/ErrorHandler.h"
-#include "Poco/SingletonHolder.h"
-
-
-namespace Poco {
-
-
-ErrorHandler* ErrorHandler::_pHandler = ErrorHandler::defaultHandler();
-FastMutex ErrorHandler::_mutex;
-
-
-ErrorHandler::ErrorHandler()
-{
-}
-
-
-ErrorHandler::~ErrorHandler()
-{
-}
-
-
-void ErrorHandler::exception(const Exception& exc)
-{
- poco_debugger_msg(exc.what());
-}
-
-
-void ErrorHandler::exception(const std::exception& exc)
-{
- poco_debugger_msg(exc.what());
-}
-
-
-void ErrorHandler::exception()
-{
- poco_debugger_msg("unknown exception");
-}
-
-
-void ErrorHandler::handle(const Exception& exc)
-{
- FastMutex::ScopedLock lock(_mutex);
- try
- {
- _pHandler->exception(exc);
- }
- catch (...)
- {
- }
-}
-
-
-void ErrorHandler::handle(const std::exception& exc)
-{
- FastMutex::ScopedLock lock(_mutex);
- try
- {
- _pHandler->exception(exc);
- }
- catch (...)
- {
- }
-}
-
-
-void ErrorHandler::handle()
-{
- FastMutex::ScopedLock lock(_mutex);
- try
- {
- _pHandler->exception();
- }
- catch (...)
- {
- }
-}
-
-
-ErrorHandler* ErrorHandler::set(ErrorHandler* pHandler)
-{
- poco_check_ptr(pHandler);
-
- FastMutex::ScopedLock lock(_mutex);
- ErrorHandler* pOld = _pHandler;
- _pHandler = pHandler;
- return pOld;
-}
-
-
-ErrorHandler* ErrorHandler::defaultHandler()
-{
- // NOTE: Since this is called to initialize the static _pHandler
- // variable, sh has to be a local static, otherwise we run
- // into static initialization order issues.
- static SingletonHolder<ErrorHandler> sh;
- return sh.get();
-}
-
-
-} // namespace Poco
+//
+// ErrorHandler.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: ErrorHandler
+//
+// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/ErrorHandler.h"
+#include "Poco/SingletonHolder.h"
+
+
+namespace Poco {
+
+
+ErrorHandler* ErrorHandler::_pHandler = ErrorHandler::defaultHandler();
+FastMutex ErrorHandler::_mutex;
+
+
+ErrorHandler::ErrorHandler()
+{
+}
+
+
+ErrorHandler::~ErrorHandler()
+{
+}
+
+
+void ErrorHandler::exception(const Exception& exc)
+{
+ poco_debugger_msg(exc.what());
+}
+
+
+void ErrorHandler::exception(const std::exception& exc)
+{
+ poco_debugger_msg(exc.what());
+}
+
+
+void ErrorHandler::exception()
+{
+ poco_debugger_msg("unknown exception");
+}
+
+
+void ErrorHandler::handle(const Exception& exc)
+{
+ FastMutex::ScopedLock lock(_mutex);
+ try
+ {
+ _pHandler->exception(exc);
+ }
+ catch (...)
+ {
+ }
+}
+
+
+void ErrorHandler::handle(const std::exception& exc)
+{
+ FastMutex::ScopedLock lock(_mutex);
+ try
+ {
+ _pHandler->exception(exc);
+ }
+ catch (...)
+ {
+ }
+}
+
+
+void ErrorHandler::handle()
+{
+ FastMutex::ScopedLock lock(_mutex);
+ try
+ {
+ _pHandler->exception();
+ }
+ catch (...)
+ {
+ }
+}
+
+
+ErrorHandler* ErrorHandler::set(ErrorHandler* pHandler)
+{
+ poco_check_ptr(pHandler);
+
+ FastMutex::ScopedLock lock(_mutex);
+ ErrorHandler* pOld = _pHandler;
+ _pHandler = pHandler;
+ return pOld;
+}
+
+
+ErrorHandler* ErrorHandler::defaultHandler()
+{
+ // NOTE: Since this is called to initialize the static _pHandler
+ // variable, sh has to be a local static, otherwise we run
+ // into static initialization order issues.
+ static SingletonHolder<ErrorHandler> sh;
+ return sh.get();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Event.cpp b/contrib/libs/poco/Foundation/src/Event.cpp
index c8e8fa0b9e..790c107f47 100644
--- a/contrib/libs/poco/Foundation/src/Event.cpp
+++ b/contrib/libs/poco/Foundation/src/Event.cpp
@@ -1,40 +1,40 @@
-//
-// Event.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: Event
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Event.h"
-
-
-#if defined(POCO_OS_FAMILY_WINDOWS)
-#include "Event_WIN32.cpp"
-#elif defined(POCO_VXWORKS)
-#include "Event_VX.cpp"
-#else
-#include "Event_POSIX.cpp"
-#endif
-
-
-namespace Poco {
-
-
-Event::Event(bool autoReset): EventImpl(autoReset)
-{
-}
-
-
-Event::~Event()
-{
-}
-
-
-} // namespace Poco
+//
+// Event.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: Event
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Event.h"
+
+
+#if defined(POCO_OS_FAMILY_WINDOWS)
+#include "Event_WIN32.cpp"
+#elif defined(POCO_VXWORKS)
+#include "Event_VX.cpp"
+#else
+#include "Event_POSIX.cpp"
+#endif
+
+
+namespace Poco {
+
+
+Event::Event(bool autoReset): EventImpl(autoReset)
+{
+}
+
+
+Event::~Event()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/EventArgs.cpp b/contrib/libs/poco/Foundation/src/EventArgs.cpp
index f5be955ddf..3e006ef775 100644
--- a/contrib/libs/poco/Foundation/src/EventArgs.cpp
+++ b/contrib/libs/poco/Foundation/src/EventArgs.cpp
@@ -1,33 +1,33 @@
-//
-// EventArgs.cpp
-//
-// Library: Foundation
-// Package: Events
-// Module: EventArgs
-//
-// Implementation of EventArgs
-//
-// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/EventArgs.h"
-
-
-namespace Poco {
-
-
-EventArgs::EventArgs()
-{
-}
-
-
-EventArgs::~EventArgs()
-{
-}
-
-
-} // namespace Poco
+//
+// EventArgs.cpp
+//
+// Library: Foundation
+// Package: Events
+// Module: EventArgs
+//
+// Implementation of EventArgs
+//
+// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/EventArgs.h"
+
+
+namespace Poco {
+
+
+EventArgs::EventArgs()
+{
+}
+
+
+EventArgs::~EventArgs()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/EventChannel.cpp b/contrib/libs/poco/Foundation/src/EventChannel.cpp
index dc5bce726a..05250bfde0 100644
--- a/contrib/libs/poco/Foundation/src/EventChannel.cpp
+++ b/contrib/libs/poco/Foundation/src/EventChannel.cpp
@@ -1,37 +1,37 @@
-//
-// EventChannel.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: EventChannel
-//
-// Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/EventChannel.h"
-
-
-namespace Poco {
-
-
-EventChannel::EventChannel()
-{
-}
-
-
-EventChannel::~EventChannel()
-{
-}
-
-
-void EventChannel::log(const Message& msg)
-{
- messageLogged(this, msg);
-}
-
-
-} // namespace Poco
+//
+// EventChannel.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: EventChannel
+//
+// Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/EventChannel.h"
+
+
+namespace Poco {
+
+
+EventChannel::EventChannel()
+{
+}
+
+
+EventChannel::~EventChannel()
+{
+}
+
+
+void EventChannel::log(const Message& msg)
+{
+ messageLogged(this, msg);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/EventLogChannel.cpp b/contrib/libs/poco/Foundation/src/EventLogChannel.cpp
index 5e95f6d1b6..afc69ebf46 100644
--- a/contrib/libs/poco/Foundation/src/EventLogChannel.cpp
+++ b/contrib/libs/poco/Foundation/src/EventLogChannel.cpp
@@ -1,327 +1,327 @@
-//
-// EventLogChannel.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: EventLogChannel
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/EventLogChannel.h"
-#include "Poco/Message.h"
-#include "Poco/String.h"
-#include "pocomsg.h"
-#if defined(POCO_WIN32_UTF8)
-#include "Poco/UnicodeConverter.h"
-#endif
-
-
-namespace Poco {
-
-
-const std::string EventLogChannel::PROP_NAME = "name";
-const std::string EventLogChannel::PROP_HOST = "host";
-const std::string EventLogChannel::PROP_LOGHOST = "loghost";
-const std::string EventLogChannel::PROP_LOGFILE = "logfile";
-
-
-EventLogChannel::EventLogChannel():
- _logFile("Application"),
- _h(0)
-{
- const DWORD maxPathLen = MAX_PATH + 1;
-#if defined(POCO_WIN32_UTF8)
- wchar_t name[maxPathLen];
- int n = GetModuleFileNameW(NULL, name, maxPathLen);
- if (n > 0)
- {
- wchar_t* end = name + n - 1;
- while (end > name && *end != '\\') --end;
- if (*end == '\\') ++end;
- std::wstring uname(end);
- UnicodeConverter::toUTF8(uname, _name);
- }
-#else
- char name[maxPathLen];
- int n = GetModuleFileNameA(NULL, name, maxPathLen);
- if (n > 0)
- {
- char* end = name + n - 1;
- while (end > name && *end != '\\') --end;
- if (*end == '\\') ++end;
- _name = end;
- }
-#endif
-}
-
-
-EventLogChannel::EventLogChannel(const std::string& name):
- _name(name),
- _logFile("Application"),
- _h(0)
-{
-}
-
-
-EventLogChannel::EventLogChannel(const std::string& name, const std::string& host):
- _name(name),
- _host(host),
- _logFile("Application"),
- _h(0)
-{
-}
-
-
-EventLogChannel::~EventLogChannel()
-{
- try
- {
- close();
- }
- catch (...)
- {
- poco_unexpected();
- }
-}
-
-
-void EventLogChannel::open()
-{
- setUpRegistry();
-#if defined(POCO_WIN32_UTF8)
- std::wstring uhost;
- UnicodeConverter::toUTF16(_host, uhost);
- std::wstring uname;
- UnicodeConverter::toUTF16(_name, uname);
- _h = RegisterEventSourceW(uhost.empty() ? NULL : uhost.c_str(), uname.c_str());
-#else
- _h = RegisterEventSource(_host.empty() ? NULL : _host.c_str(), _name.c_str());
-#endif
- if (!_h) throw SystemException("cannot register event source");
-}
-
-
-void EventLogChannel::close()
-{
- if (_h) DeregisterEventSource(_h);
- _h = 0;
-}
-
-
-void EventLogChannel::log(const Message& msg)
-{
- if (!_h) open();
-#if defined(POCO_WIN32_UTF8)
- std::wstring utext;
- UnicodeConverter::toUTF16(msg.getText(), utext);
- const wchar_t* pMsg = utext.c_str();
- ReportEventW(_h,
- static_cast<WORD>(getType(msg)),
- static_cast<WORD>(getCategory(msg)),
- POCO_MSG_LOG,
- NULL,
- 1,
- 0,
- &pMsg,
- NULL);
-#else
- const char* pMsg = msg.getText().c_str();
- ReportEvent(_h, getType(msg), getCategory(msg), POCO_MSG_LOG, NULL, 1, 0, &pMsg, NULL);
-#endif
-}
-
-
-void EventLogChannel::setProperty(const std::string& name, const std::string& value)
-{
- if (icompare(name, PROP_NAME) == 0)
- _name = value;
- else if (icompare(name, PROP_HOST) == 0)
- _host = value;
- else if (icompare(name, PROP_LOGHOST) == 0)
- _host = value;
- else if (icompare(name, PROP_LOGFILE) == 0)
- _logFile = value;
- else
- Channel::setProperty(name, value);
-}
-
-
-std::string EventLogChannel::getProperty(const std::string& name) const
-{
- if (icompare(name, PROP_NAME) == 0)
- return _name;
- else if (icompare(name, PROP_HOST) == 0)
- return _host;
- else if (icompare(name, PROP_LOGHOST) == 0)
- return _host;
- else if (icompare(name, PROP_LOGFILE) == 0)
- return _logFile;
- else
- return Channel::getProperty(name);
-}
-
-
-int EventLogChannel::getType(const Message& msg)
-{
- switch (msg.getPriority())
- {
- case Message::PRIO_TRACE:
- case Message::PRIO_DEBUG:
- case Message::PRIO_INFORMATION:
- return EVENTLOG_INFORMATION_TYPE;
- case Message::PRIO_NOTICE:
- case Message::PRIO_WARNING:
- return EVENTLOG_WARNING_TYPE;
- default:
- return EVENTLOG_ERROR_TYPE;
- }
-}
-
-
-int EventLogChannel::getCategory(const Message& msg)
-{
- switch (msg.getPriority())
- {
- case Message::PRIO_TRACE:
- return POCO_CTG_TRACE;
- case Message::PRIO_DEBUG:
- return POCO_CTG_DEBUG;
- case Message::PRIO_INFORMATION:
- return POCO_CTG_INFORMATION;
- case Message::PRIO_NOTICE:
- return POCO_CTG_NOTICE;
- case Message::PRIO_WARNING:
- return POCO_CTG_WARNING;
- case Message::PRIO_ERROR:
- return POCO_CTG_ERROR;
- case Message::PRIO_CRITICAL:
- return POCO_CTG_CRITICAL;
- case Message::PRIO_FATAL:
- return POCO_CTG_FATAL;
- default:
- return 0;
- }
-}
-
-
-void EventLogChannel::setUpRegistry() const
-{
- std::string key = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\";
- key.append(_logFile);
- key.append("\\");
- key.append(_name);
- HKEY hKey;
- DWORD disp;
-#if defined(POCO_WIN32_UTF8)
- std::wstring ukey;
- 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);
-#else
- DWORD rc = RegCreateKeyEx(HKEY_LOCAL_MACHINE, key.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &disp);
-#endif
- if (rc != ERROR_SUCCESS) return;
-
- if (disp == REG_CREATED_NEW_KEY)
- {
-#if defined(POCO_WIN32_UTF8)
- std::wstring path;
- #if defined(POCO_DLL)
- #if defined(_DEBUG)
- #if defined(_WIN64)
- path = findLibrary(L"PocoFoundation64d.dll");
- #else
- path = findLibrary(L"PocoFoundationd.dll");
- #endif
- #else
- #if defined(_WIN64)
- path = findLibrary(L"PocoFoundation64.dll");
- #else
- path = findLibrary(L"PocoFoundation.dll");
- #endif
- #endif
- #endif
-
- if (path.empty())
- path = findLibrary(L"PocoMsg.dll");
-#else
- std::string path;
- #if defined(POCO_DLL)
- #if defined(_DEBUG)
- #if defined(_WIN64)
- path = findLibrary("PocoFoundation64d.dll");
- #else
- path = findLibrary("PocoFoundationd.dll");
- #endif
- #else
- #if defined(_WIN64)
- path = findLibrary("PocoFoundation64.dll");
- #else
- path = findLibrary("PocoFoundation.dll");
- #endif
- #endif
- #endif
-
- if (path.empty())
- path = findLibrary("PocoMsg.dll");
-#endif
-
- if (!path.empty())
- {
- DWORD count = 8;
- DWORD types = 7;
-#if defined(POCO_WIN32_UTF8)
- RegSetValueExW(hKey, L"CategoryMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), static_cast<DWORD>(sizeof(wchar_t)*(path.size() + 1)));
- RegSetValueExW(hKey, L"EventMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), static_cast<DWORD>(sizeof(wchar_t)*(path.size() + 1)));
- RegSetValueExW(hKey, L"CategoryCount", 0, REG_DWORD, (const BYTE*) &count, static_cast<DWORD>(sizeof(count)));
- RegSetValueExW(hKey, L"TypesSupported", 0, REG_DWORD, (const BYTE*) &types, static_cast<DWORD>(sizeof(types)));
-#else
- RegSetValueEx(hKey, "CategoryMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), static_cast<DWORD>(path.size() + 1));
- RegSetValueEx(hKey, "EventMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), static_cast<DWORD>(path.size() + 1));
- RegSetValueEx(hKey, "CategoryCount", 0, REG_DWORD, (const BYTE*) &count, static_cast<DWORD>(sizeof(count)));
- RegSetValueEx(hKey, "TypesSupported", 0, REG_DWORD, (const BYTE*) &types, static_cast<DWORD>(sizeof(types)));
-#endif
- }
- }
- RegCloseKey(hKey);
-}
-
-
-#if defined(POCO_WIN32_UTF8)
-std::wstring EventLogChannel::findLibrary(const wchar_t* name)
-{
- std::wstring path;
- HMODULE dll = LoadLibraryW(name);
- if (dll)
- {
- const DWORD maxPathLen = MAX_PATH + 1;
- wchar_t moduleName[maxPathLen];
- int n = GetModuleFileNameW(dll, moduleName, maxPathLen);
- if (n > 0) path = moduleName;
- FreeLibrary(dll);
- }
- return path;
-}
-#else
-std::string EventLogChannel::findLibrary(const char* name)
-{
- std::string path;
- HMODULE dll = LoadLibraryA(name);
- if (dll)
- {
- const DWORD maxPathLen = MAX_PATH + 1;
- char name[maxPathLen];
- int n = GetModuleFileNameA(dll, name, maxPathLen);
- if (n > 0) path = name;
- FreeLibrary(dll);
- }
- return path;
-}
-#endif
-
-
-} // namespace Poco
+//
+// EventLogChannel.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: EventLogChannel
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/EventLogChannel.h"
+#include "Poco/Message.h"
+#include "Poco/String.h"
+#include "pocomsg.h"
+#if defined(POCO_WIN32_UTF8)
+#include "Poco/UnicodeConverter.h"
+#endif
+
+
+namespace Poco {
+
+
+const std::string EventLogChannel::PROP_NAME = "name";
+const std::string EventLogChannel::PROP_HOST = "host";
+const std::string EventLogChannel::PROP_LOGHOST = "loghost";
+const std::string EventLogChannel::PROP_LOGFILE = "logfile";
+
+
+EventLogChannel::EventLogChannel():
+ _logFile("Application"),
+ _h(0)
+{
+ const DWORD maxPathLen = MAX_PATH + 1;
+#if defined(POCO_WIN32_UTF8)
+ wchar_t name[maxPathLen];
+ int n = GetModuleFileNameW(NULL, name, maxPathLen);
+ if (n > 0)
+ {
+ wchar_t* end = name + n - 1;
+ while (end > name && *end != '\\') --end;
+ if (*end == '\\') ++end;
+ std::wstring uname(end);
+ UnicodeConverter::toUTF8(uname, _name);
+ }
+#else
+ char name[maxPathLen];
+ int n = GetModuleFileNameA(NULL, name, maxPathLen);
+ if (n > 0)
+ {
+ char* end = name + n - 1;
+ while (end > name && *end != '\\') --end;
+ if (*end == '\\') ++end;
+ _name = end;
+ }
+#endif
+}
+
+
+EventLogChannel::EventLogChannel(const std::string& name):
+ _name(name),
+ _logFile("Application"),
+ _h(0)
+{
+}
+
+
+EventLogChannel::EventLogChannel(const std::string& name, const std::string& host):
+ _name(name),
+ _host(host),
+ _logFile("Application"),
+ _h(0)
+{
+}
+
+
+EventLogChannel::~EventLogChannel()
+{
+ try
+ {
+ close();
+ }
+ catch (...)
+ {
+ poco_unexpected();
+ }
+}
+
+
+void EventLogChannel::open()
+{
+ setUpRegistry();
+#if defined(POCO_WIN32_UTF8)
+ std::wstring uhost;
+ UnicodeConverter::toUTF16(_host, uhost);
+ std::wstring uname;
+ UnicodeConverter::toUTF16(_name, uname);
+ _h = RegisterEventSourceW(uhost.empty() ? NULL : uhost.c_str(), uname.c_str());
+#else
+ _h = RegisterEventSource(_host.empty() ? NULL : _host.c_str(), _name.c_str());
+#endif
+ if (!_h) throw SystemException("cannot register event source");
+}
+
+
+void EventLogChannel::close()
+{
+ if (_h) DeregisterEventSource(_h);
+ _h = 0;
+}
+
+
+void EventLogChannel::log(const Message& msg)
+{
+ if (!_h) open();
+#if defined(POCO_WIN32_UTF8)
+ std::wstring utext;
+ UnicodeConverter::toUTF16(msg.getText(), utext);
+ const wchar_t* pMsg = utext.c_str();
+ ReportEventW(_h,
+ static_cast<WORD>(getType(msg)),
+ static_cast<WORD>(getCategory(msg)),
+ POCO_MSG_LOG,
+ NULL,
+ 1,
+ 0,
+ &pMsg,
+ NULL);
+#else
+ const char* pMsg = msg.getText().c_str();
+ ReportEvent(_h, getType(msg), getCategory(msg), POCO_MSG_LOG, NULL, 1, 0, &pMsg, NULL);
+#endif
+}
+
+
+void EventLogChannel::setProperty(const std::string& name, const std::string& value)
+{
+ if (icompare(name, PROP_NAME) == 0)
+ _name = value;
+ else if (icompare(name, PROP_HOST) == 0)
+ _host = value;
+ else if (icompare(name, PROP_LOGHOST) == 0)
+ _host = value;
+ else if (icompare(name, PROP_LOGFILE) == 0)
+ _logFile = value;
+ else
+ Channel::setProperty(name, value);
+}
+
+
+std::string EventLogChannel::getProperty(const std::string& name) const
+{
+ if (icompare(name, PROP_NAME) == 0)
+ return _name;
+ else if (icompare(name, PROP_HOST) == 0)
+ return _host;
+ else if (icompare(name, PROP_LOGHOST) == 0)
+ return _host;
+ else if (icompare(name, PROP_LOGFILE) == 0)
+ return _logFile;
+ else
+ return Channel::getProperty(name);
+}
+
+
+int EventLogChannel::getType(const Message& msg)
+{
+ switch (msg.getPriority())
+ {
+ case Message::PRIO_TRACE:
+ case Message::PRIO_DEBUG:
+ case Message::PRIO_INFORMATION:
+ return EVENTLOG_INFORMATION_TYPE;
+ case Message::PRIO_NOTICE:
+ case Message::PRIO_WARNING:
+ return EVENTLOG_WARNING_TYPE;
+ default:
+ return EVENTLOG_ERROR_TYPE;
+ }
+}
+
+
+int EventLogChannel::getCategory(const Message& msg)
+{
+ switch (msg.getPriority())
+ {
+ case Message::PRIO_TRACE:
+ return POCO_CTG_TRACE;
+ case Message::PRIO_DEBUG:
+ return POCO_CTG_DEBUG;
+ case Message::PRIO_INFORMATION:
+ return POCO_CTG_INFORMATION;
+ case Message::PRIO_NOTICE:
+ return POCO_CTG_NOTICE;
+ case Message::PRIO_WARNING:
+ return POCO_CTG_WARNING;
+ case Message::PRIO_ERROR:
+ return POCO_CTG_ERROR;
+ case Message::PRIO_CRITICAL:
+ return POCO_CTG_CRITICAL;
+ case Message::PRIO_FATAL:
+ return POCO_CTG_FATAL;
+ default:
+ return 0;
+ }
+}
+
+
+void EventLogChannel::setUpRegistry() const
+{
+ std::string key = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\";
+ key.append(_logFile);
+ key.append("\\");
+ key.append(_name);
+ HKEY hKey;
+ DWORD disp;
+#if defined(POCO_WIN32_UTF8)
+ std::wstring ukey;
+ 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);
+#else
+ DWORD rc = RegCreateKeyEx(HKEY_LOCAL_MACHINE, key.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &disp);
+#endif
+ if (rc != ERROR_SUCCESS) return;
+
+ if (disp == REG_CREATED_NEW_KEY)
+ {
+#if defined(POCO_WIN32_UTF8)
+ std::wstring path;
+ #if defined(POCO_DLL)
+ #if defined(_DEBUG)
+ #if defined(_WIN64)
+ path = findLibrary(L"PocoFoundation64d.dll");
+ #else
+ path = findLibrary(L"PocoFoundationd.dll");
+ #endif
+ #else
+ #if defined(_WIN64)
+ path = findLibrary(L"PocoFoundation64.dll");
+ #else
+ path = findLibrary(L"PocoFoundation.dll");
+ #endif
+ #endif
+ #endif
+
+ if (path.empty())
+ path = findLibrary(L"PocoMsg.dll");
+#else
+ std::string path;
+ #if defined(POCO_DLL)
+ #if defined(_DEBUG)
+ #if defined(_WIN64)
+ path = findLibrary("PocoFoundation64d.dll");
+ #else
+ path = findLibrary("PocoFoundationd.dll");
+ #endif
+ #else
+ #if defined(_WIN64)
+ path = findLibrary("PocoFoundation64.dll");
+ #else
+ path = findLibrary("PocoFoundation.dll");
+ #endif
+ #endif
+ #endif
+
+ if (path.empty())
+ path = findLibrary("PocoMsg.dll");
+#endif
+
+ if (!path.empty())
+ {
+ DWORD count = 8;
+ DWORD types = 7;
+#if defined(POCO_WIN32_UTF8)
+ RegSetValueExW(hKey, L"CategoryMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), static_cast<DWORD>(sizeof(wchar_t)*(path.size() + 1)));
+ RegSetValueExW(hKey, L"EventMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), static_cast<DWORD>(sizeof(wchar_t)*(path.size() + 1)));
+ RegSetValueExW(hKey, L"CategoryCount", 0, REG_DWORD, (const BYTE*) &count, static_cast<DWORD>(sizeof(count)));
+ RegSetValueExW(hKey, L"TypesSupported", 0, REG_DWORD, (const BYTE*) &types, static_cast<DWORD>(sizeof(types)));
+#else
+ RegSetValueEx(hKey, "CategoryMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), static_cast<DWORD>(path.size() + 1));
+ RegSetValueEx(hKey, "EventMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), static_cast<DWORD>(path.size() + 1));
+ RegSetValueEx(hKey, "CategoryCount", 0, REG_DWORD, (const BYTE*) &count, static_cast<DWORD>(sizeof(count)));
+ RegSetValueEx(hKey, "TypesSupported", 0, REG_DWORD, (const BYTE*) &types, static_cast<DWORD>(sizeof(types)));
+#endif
+ }
+ }
+ RegCloseKey(hKey);
+}
+
+
+#if defined(POCO_WIN32_UTF8)
+std::wstring EventLogChannel::findLibrary(const wchar_t* name)
+{
+ std::wstring path;
+ HMODULE dll = LoadLibraryW(name);
+ if (dll)
+ {
+ const DWORD maxPathLen = MAX_PATH + 1;
+ wchar_t moduleName[maxPathLen];
+ int n = GetModuleFileNameW(dll, moduleName, maxPathLen);
+ if (n > 0) path = moduleName;
+ FreeLibrary(dll);
+ }
+ return path;
+}
+#else
+std::string EventLogChannel::findLibrary(const char* name)
+{
+ std::string path;
+ HMODULE dll = LoadLibraryA(name);
+ if (dll)
+ {
+ const DWORD maxPathLen = MAX_PATH + 1;
+ char name[maxPathLen];
+ int n = GetModuleFileNameA(dll, name, maxPathLen);
+ if (n > 0) path = name;
+ FreeLibrary(dll);
+ }
+ return path;
+}
+#endif
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Event_POSIX.cpp b/contrib/libs/poco/Foundation/src/Event_POSIX.cpp
index 50fb6f78a8..de726f6db8 100644
--- a/contrib/libs/poco/Foundation/src/Event_POSIX.cpp
+++ b/contrib/libs/poco/Foundation/src/Event_POSIX.cpp
@@ -1,170 +1,170 @@
-//
-// Event_POSIX.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: Event
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Event_POSIX.h"
-#if defined(POCO_VXWORKS)
-#include <timers.h>
-#include <cstring>
-#else
-#include <time.h>
-#include <sys/time.h>
-#endif
-
-
-//
-// Note: pthread_cond_timedwait() with CLOCK_MONOTONIC is supported
-// on Linux and QNX, as well as on Android >= 5.0 (API level 21).
-// On Android < 5.0, HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC is defined
-// to indicate availability of non-standard pthread_cond_timedwait_monotonic().
-//
-#ifndef POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT
- #if (defined(__linux__) || defined(__QNX__)) && !(defined(__ANDROID__) && (defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC) || __ANDROID_API__ <= 21))
- #define POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT 1
- #endif
-#endif
-
-
-#ifndef POCO_HAVE_CLOCK_GETTIME
- #if (defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME)) || defined(POCO_VXWORKS) || defined(__QNX__)
- #ifndef __APPLE__ // See GitHub issue #1453 - not available before Mac OS 10.12/iOS 10
- #define POCO_HAVE_CLOCK_GETTIME
- #endif
- #endif
-#endif
-
-
-namespace Poco {
-
-
-EventImpl::EventImpl(bool autoReset): _auto(autoReset), _state(false)
-{
-#if defined(POCO_VXWORKS)
- // This workaround is for VxWorks 5.x where
- // pthread_mutex_init() won't properly initialize the mutex
- // resulting in a subsequent freeze in pthread_mutex_destroy()
- // if the mutex has never been used.
- std::memset(&_mutex, 0, sizeof(_mutex));
-#endif
-
- if (pthread_mutex_init(&_mutex, NULL))
- throw SystemException("cannot create event (mutex)");
-
-#if defined(POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT)
- pthread_condattr_t attr;
- if (pthread_condattr_init(&attr))
- {
- pthread_mutex_destroy(&_mutex);
- throw SystemException("cannot create event (condition attribute)");
- }
- if (pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
- {
- pthread_condattr_destroy(&attr);
- pthread_mutex_destroy(&_mutex);
- throw SystemException("cannot create event (condition attribute clock)");
- }
- if (pthread_cond_init(&_cond, &attr))
- {
- pthread_condattr_destroy(&attr);
- pthread_mutex_destroy(&_mutex);
- throw SystemException("cannot create event (condition)");
- }
- pthread_condattr_destroy(&attr);
-#else
- if (pthread_cond_init(&_cond, NULL))
- {
- pthread_mutex_destroy(&_mutex);
- throw SystemException("cannot create event (condition)");
- }
-#endif
-}
-
-
-EventImpl::~EventImpl()
-{
- pthread_cond_destroy(&_cond);
- pthread_mutex_destroy(&_mutex);
-}
-
-
-void EventImpl::waitImpl()
-{
- if (pthread_mutex_lock(&_mutex))
- throw SystemException("wait for event failed (lock)");
- while (!_state)
- {
- if (pthread_cond_wait(&_cond, &_mutex))
- {
- pthread_mutex_unlock(&_mutex);
- throw SystemException("wait for event failed");
- }
- }
- if (_auto)
- _state = false;
- pthread_mutex_unlock(&_mutex);
-}
-
-
-bool EventImpl::waitImpl(long milliseconds)
-{
- int rc = 0;
- struct timespec abstime;
-
-#if defined(POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT)
- clock_gettime(CLOCK_MONOTONIC, &abstime);
- abstime.tv_sec += milliseconds / 1000;
- abstime.tv_nsec += (milliseconds % 1000)*1000000;
- if (abstime.tv_nsec >= 1000000000)
- {
- abstime.tv_nsec -= 1000000000;
- abstime.tv_sec++;
- }
-#elif defined(POCO_HAVE_CLOCK_GETTIME)
- clock_gettime(CLOCK_REALTIME, &abstime);
- abstime.tv_sec += milliseconds / 1000;
- abstime.tv_nsec += (milliseconds % 1000)*1000000;
- if (abstime.tv_nsec >= 1000000000)
- {
- abstime.tv_nsec -= 1000000000;
- abstime.tv_sec++;
- }
-#else
- struct timeval tv;
- gettimeofday(&tv, NULL);
- abstime.tv_sec = tv.tv_sec + milliseconds / 1000;
- abstime.tv_nsec = tv.tv_usec*1000 + (milliseconds % 1000)*1000000;
- if (abstime.tv_nsec >= 1000000000)
- {
- abstime.tv_nsec -= 1000000000;
- abstime.tv_sec++;
- }
-#endif
-
- if (pthread_mutex_lock(&_mutex) != 0)
- throw SystemException("wait for event failed (lock)");
- while (!_state)
- {
- if ((rc = pthread_cond_timedwait(&_cond, &_mutex, &abstime)))
- {
- if (rc == ETIMEDOUT) break;
- pthread_mutex_unlock(&_mutex);
- throw SystemException("cannot wait for event");
- }
- }
- if (rc == 0 && _auto) _state = false;
- pthread_mutex_unlock(&_mutex);
- return rc == 0;
-}
-
-
-} // namespace Poco
+//
+// Event_POSIX.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: Event
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Event_POSIX.h"
+#if defined(POCO_VXWORKS)
+#include <timers.h>
+#include <cstring>
+#else
+#include <time.h>
+#include <sys/time.h>
+#endif
+
+
+//
+// Note: pthread_cond_timedwait() with CLOCK_MONOTONIC is supported
+// on Linux and QNX, as well as on Android >= 5.0 (API level 21).
+// On Android < 5.0, HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC is defined
+// to indicate availability of non-standard pthread_cond_timedwait_monotonic().
+//
+#ifndef POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT
+ #if (defined(__linux__) || defined(__QNX__)) && !(defined(__ANDROID__) && (defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC) || __ANDROID_API__ <= 21))
+ #define POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT 1
+ #endif
+#endif
+
+
+#ifndef POCO_HAVE_CLOCK_GETTIME
+ #if (defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME)) || defined(POCO_VXWORKS) || defined(__QNX__)
+ #ifndef __APPLE__ // See GitHub issue #1453 - not available before Mac OS 10.12/iOS 10
+ #define POCO_HAVE_CLOCK_GETTIME
+ #endif
+ #endif
+#endif
+
+
+namespace Poco {
+
+
+EventImpl::EventImpl(bool autoReset): _auto(autoReset), _state(false)
+{
+#if defined(POCO_VXWORKS)
+ // This workaround is for VxWorks 5.x where
+ // pthread_mutex_init() won't properly initialize the mutex
+ // resulting in a subsequent freeze in pthread_mutex_destroy()
+ // if the mutex has never been used.
+ std::memset(&_mutex, 0, sizeof(_mutex));
+#endif
+
+ if (pthread_mutex_init(&_mutex, NULL))
+ throw SystemException("cannot create event (mutex)");
+
+#if defined(POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT)
+ pthread_condattr_t attr;
+ if (pthread_condattr_init(&attr))
+ {
+ pthread_mutex_destroy(&_mutex);
+ throw SystemException("cannot create event (condition attribute)");
+ }
+ if (pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
+ {
+ pthread_condattr_destroy(&attr);
+ pthread_mutex_destroy(&_mutex);
+ throw SystemException("cannot create event (condition attribute clock)");
+ }
+ if (pthread_cond_init(&_cond, &attr))
+ {
+ pthread_condattr_destroy(&attr);
+ pthread_mutex_destroy(&_mutex);
+ throw SystemException("cannot create event (condition)");
+ }
+ pthread_condattr_destroy(&attr);
+#else
+ if (pthread_cond_init(&_cond, NULL))
+ {
+ pthread_mutex_destroy(&_mutex);
+ throw SystemException("cannot create event (condition)");
+ }
+#endif
+}
+
+
+EventImpl::~EventImpl()
+{
+ pthread_cond_destroy(&_cond);
+ pthread_mutex_destroy(&_mutex);
+}
+
+
+void EventImpl::waitImpl()
+{
+ if (pthread_mutex_lock(&_mutex))
+ throw SystemException("wait for event failed (lock)");
+ while (!_state)
+ {
+ if (pthread_cond_wait(&_cond, &_mutex))
+ {
+ pthread_mutex_unlock(&_mutex);
+ throw SystemException("wait for event failed");
+ }
+ }
+ if (_auto)
+ _state = false;
+ pthread_mutex_unlock(&_mutex);
+}
+
+
+bool EventImpl::waitImpl(long milliseconds)
+{
+ int rc = 0;
+ struct timespec abstime;
+
+#if defined(POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT)
+ clock_gettime(CLOCK_MONOTONIC, &abstime);
+ abstime.tv_sec += milliseconds / 1000;
+ abstime.tv_nsec += (milliseconds % 1000)*1000000;
+ if (abstime.tv_nsec >= 1000000000)
+ {
+ abstime.tv_nsec -= 1000000000;
+ abstime.tv_sec++;
+ }
+#elif defined(POCO_HAVE_CLOCK_GETTIME)
+ clock_gettime(CLOCK_REALTIME, &abstime);
+ abstime.tv_sec += milliseconds / 1000;
+ abstime.tv_nsec += (milliseconds % 1000)*1000000;
+ if (abstime.tv_nsec >= 1000000000)
+ {
+ abstime.tv_nsec -= 1000000000;
+ abstime.tv_sec++;
+ }
+#else
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ abstime.tv_sec = tv.tv_sec + milliseconds / 1000;
+ abstime.tv_nsec = tv.tv_usec*1000 + (milliseconds % 1000)*1000000;
+ if (abstime.tv_nsec >= 1000000000)
+ {
+ abstime.tv_nsec -= 1000000000;
+ abstime.tv_sec++;
+ }
+#endif
+
+ if (pthread_mutex_lock(&_mutex) != 0)
+ throw SystemException("wait for event failed (lock)");
+ while (!_state)
+ {
+ if ((rc = pthread_cond_timedwait(&_cond, &_mutex, &abstime)))
+ {
+ if (rc == ETIMEDOUT) break;
+ pthread_mutex_unlock(&_mutex);
+ throw SystemException("cannot wait for event");
+ }
+ }
+ if (rc == 0 && _auto) _state = false;
+ pthread_mutex_unlock(&_mutex);
+ return rc == 0;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Event_VX.cpp b/contrib/libs/poco/Foundation/src/Event_VX.cpp
index 18f667156e..52732683ee 100644
--- a/contrib/libs/poco/Foundation/src/Event_VX.cpp
+++ b/contrib/libs/poco/Foundation/src/Event_VX.cpp
@@ -1,79 +1,79 @@
-//
-// Event_POSIX.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: Event
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Event_VX.h"
-#include <sysLib.h>
-
-
-namespace Poco {
-
-
-EventImpl::EventImpl(bool autoReset): _auto(autoReset), _state(false)
-{
- _sem = semCCreate(SEM_Q_PRIORITY, 0);
- if (_sem == 0)
- throw Poco::SystemException("cannot create event");
-}
-
-
-EventImpl::~EventImpl()
-{
- semDelete(_sem);
-}
-
-
-void EventImpl::setImpl()
-{
- if (_auto)
- {
- if (semGive(_sem) != OK)
- throw SystemException("cannot set event");
- }
- else
- {
- _state = true;
- if (semFlush(_sem) != OK)
- throw SystemException("cannot set event");
- }
-}
-
-
-void EventImpl::resetImpl()
-{
- _state = false;
-}
-
-
-void EventImpl::waitImpl()
-{
- if (!_state)
- {
- if (semTake(_sem, WAIT_FOREVER) != OK)
- throw SystemException("cannot wait for event");
- }
-}
-
-
-bool EventImpl::waitImpl(long milliseconds)
-{
- if (!_state)
- {
- int ticks = milliseconds*sysClkRateGet()/1000;
- return semTake(_sem, ticks) == OK;
- }
- else return true;
-}
-
-
-} // namespace Poco
+//
+// Event_POSIX.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: Event
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Event_VX.h"
+#include <sysLib.h>
+
+
+namespace Poco {
+
+
+EventImpl::EventImpl(bool autoReset): _auto(autoReset), _state(false)
+{
+ _sem = semCCreate(SEM_Q_PRIORITY, 0);
+ if (_sem == 0)
+ throw Poco::SystemException("cannot create event");
+}
+
+
+EventImpl::~EventImpl()
+{
+ semDelete(_sem);
+}
+
+
+void EventImpl::setImpl()
+{
+ if (_auto)
+ {
+ if (semGive(_sem) != OK)
+ throw SystemException("cannot set event");
+ }
+ else
+ {
+ _state = true;
+ if (semFlush(_sem) != OK)
+ throw SystemException("cannot set event");
+ }
+}
+
+
+void EventImpl::resetImpl()
+{
+ _state = false;
+}
+
+
+void EventImpl::waitImpl()
+{
+ if (!_state)
+ {
+ if (semTake(_sem, WAIT_FOREVER) != OK)
+ throw SystemException("cannot wait for event");
+ }
+}
+
+
+bool EventImpl::waitImpl(long milliseconds)
+{
+ if (!_state)
+ {
+ int ticks = milliseconds*sysClkRateGet()/1000;
+ return semTake(_sem, ticks) == OK;
+ }
+ else return true;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Event_WIN32.cpp b/contrib/libs/poco/Foundation/src/Event_WIN32.cpp
index 256951870a..dd77764998 100644
--- a/contrib/libs/poco/Foundation/src/Event_WIN32.cpp
+++ b/contrib/libs/poco/Foundation/src/Event_WIN32.cpp
@@ -1,61 +1,61 @@
-//
-// Event_WIN32.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: Event
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Event_WIN32.h"
-
-
-namespace Poco {
-
-
-EventImpl::EventImpl(bool autoReset)
-{
- _event = CreateEventW(NULL, autoReset ? FALSE : TRUE, FALSE, NULL);
- if (!_event)
- throw SystemException("cannot create event");
-}
-
-
-EventImpl::~EventImpl()
-{
- CloseHandle(_event);
-}
-
-
-void EventImpl::waitImpl()
-{
- switch (WaitForSingleObject(_event, INFINITE))
- {
- case WAIT_OBJECT_0:
- return;
- default:
- throw SystemException("wait for event failed");
- }
-}
-
-
-bool EventImpl::waitImpl(long milliseconds)
-{
- switch (WaitForSingleObject(_event, milliseconds + 1))
- {
- case WAIT_TIMEOUT:
- return false;
- case WAIT_OBJECT_0:
- return true;
- default:
- throw SystemException("wait for event failed");
- }
-}
-
-
-} // namespace Poco
+//
+// Event_WIN32.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: Event
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Event_WIN32.h"
+
+
+namespace Poco {
+
+
+EventImpl::EventImpl(bool autoReset)
+{
+ _event = CreateEventW(NULL, autoReset ? FALSE : TRUE, FALSE, NULL);
+ if (!_event)
+ throw SystemException("cannot create event");
+}
+
+
+EventImpl::~EventImpl()
+{
+ CloseHandle(_event);
+}
+
+
+void EventImpl::waitImpl()
+{
+ switch (WaitForSingleObject(_event, INFINITE))
+ {
+ case WAIT_OBJECT_0:
+ return;
+ default:
+ throw SystemException("wait for event failed");
+ }
+}
+
+
+bool EventImpl::waitImpl(long milliseconds)
+{
+ switch (WaitForSingleObject(_event, milliseconds + 1))
+ {
+ case WAIT_TIMEOUT:
+ return false;
+ case WAIT_OBJECT_0:
+ return true;
+ default:
+ throw SystemException("wait for event failed");
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Exception.cpp b/contrib/libs/poco/Foundation/src/Exception.cpp
index 1f0fe6fbcb..3ebf5077a0 100644
--- a/contrib/libs/poco/Foundation/src/Exception.cpp
+++ b/contrib/libs/poco/Foundation/src/Exception.cpp
@@ -1,181 +1,181 @@
-//
-// Exception.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: Exception
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Exception.h"
-#include <typeinfo>
-
-
-namespace Poco {
-
-
-Exception::Exception(int otherCode): _pNested(0), _code(otherCode)
-{
-}
-
-
-Exception::Exception(const std::string& msg, int otherCode): _msg(msg), _pNested(0), _code(otherCode)
-{
-}
-
-
-Exception::Exception(const std::string& msg, const std::string& arg, int otherCode): _msg(msg), _pNested(0), _code(otherCode)
-{
- if (!arg.empty())
- {
- _msg.append(": ");
- _msg.append(arg);
- }
-}
-
-
-Exception::Exception(const std::string& msg, const Exception& nestedException, int otherCode): _msg(msg), _pNested(nestedException.clone()), _code(otherCode)
-{
-}
-
-
-Exception::Exception(const Exception& exc):
- std::exception(exc),
- _msg(exc._msg),
- _code(exc._code)
-{
- _pNested = exc._pNested ? exc._pNested->clone() : 0;
-}
-
-
-Exception::~Exception() noexcept
-{
- delete _pNested;
-}
-
-
-Exception& Exception::operator = (const Exception& exc)
-{
- if (&exc != this)
- {
- Exception* newPNested = exc._pNested ? exc._pNested->clone() : 0;
- delete _pNested;
- _msg = exc._msg;
- _pNested = newPNested;
- _code = exc._code;
- }
- return *this;
-}
-
-
+//
+// Exception.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: Exception
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Exception.h"
+#include <typeinfo>
+
+
+namespace Poco {
+
+
+Exception::Exception(int otherCode): _pNested(0), _code(otherCode)
+{
+}
+
+
+Exception::Exception(const std::string& msg, int otherCode): _msg(msg), _pNested(0), _code(otherCode)
+{
+}
+
+
+Exception::Exception(const std::string& msg, const std::string& arg, int otherCode): _msg(msg), _pNested(0), _code(otherCode)
+{
+ if (!arg.empty())
+ {
+ _msg.append(": ");
+ _msg.append(arg);
+ }
+}
+
+
+Exception::Exception(const std::string& msg, const Exception& nestedException, int otherCode): _msg(msg), _pNested(nestedException.clone()), _code(otherCode)
+{
+}
+
+
+Exception::Exception(const Exception& exc):
+ std::exception(exc),
+ _msg(exc._msg),
+ _code(exc._code)
+{
+ _pNested = exc._pNested ? exc._pNested->clone() : 0;
+}
+
+
+Exception::~Exception() noexcept
+{
+ delete _pNested;
+}
+
+
+Exception& Exception::operator = (const Exception& exc)
+{
+ if (&exc != this)
+ {
+ Exception* newPNested = exc._pNested ? exc._pNested->clone() : 0;
+ delete _pNested;
+ _msg = exc._msg;
+ _pNested = newPNested;
+ _code = exc._code;
+ }
+ return *this;
+}
+
+
const char* Exception::name() const noexcept
-{
- return "Exception";
-}
-
-
+{
+ return "Exception";
+}
+
+
const char* Exception::className() const noexcept
-{
- return typeid(*this).name();
-}
-
-
+{
+ return typeid(*this).name();
+}
+
+
const char* Exception::what() const noexcept
-{
- return name();
-}
-
-
-std::string Exception::displayText() const
-{
- std::string txt = name();
- if (!_msg.empty())
- {
- txt.append(": ");
- txt.append(_msg);
- }
- return txt;
-}
-
-
-void Exception::extendedMessage(const std::string& arg)
-{
- if (!arg.empty())
- {
- if (!_msg.empty()) _msg.append(": ");
- _msg.append(arg);
- }
-}
-
-
-Exception* Exception::clone() const
-{
- return new Exception(*this);
-}
-
-
-void Exception::rethrow() const
-{
- throw *this;
-}
-
-
-POCO_IMPLEMENT_EXCEPTION(LogicException, Exception, "Logic exception")
-POCO_IMPLEMENT_EXCEPTION(AssertionViolationException, LogicException, "Assertion violation")
-POCO_IMPLEMENT_EXCEPTION(NullPointerException, LogicException, "Null pointer")
-POCO_IMPLEMENT_EXCEPTION(NullValueException, LogicException, "Null value")
-POCO_IMPLEMENT_EXCEPTION(BugcheckException, LogicException, "Bugcheck")
-POCO_IMPLEMENT_EXCEPTION(InvalidArgumentException, LogicException, "Invalid argument")
-POCO_IMPLEMENT_EXCEPTION(NotImplementedException, LogicException, "Not implemented")
-POCO_IMPLEMENT_EXCEPTION(RangeException, LogicException, "Out of range")
-POCO_IMPLEMENT_EXCEPTION(IllegalStateException, LogicException, "Illegal state")
-POCO_IMPLEMENT_EXCEPTION(InvalidAccessException, LogicException, "Invalid access")
-POCO_IMPLEMENT_EXCEPTION(SignalException, LogicException, "Signal received")
-POCO_IMPLEMENT_EXCEPTION(UnhandledException, LogicException, "Unhandled exception")
-
-POCO_IMPLEMENT_EXCEPTION(RuntimeException, Exception, "Runtime exception")
-POCO_IMPLEMENT_EXCEPTION(NotFoundException, RuntimeException, "Not found")
-POCO_IMPLEMENT_EXCEPTION(ExistsException, RuntimeException, "Exists")
-POCO_IMPLEMENT_EXCEPTION(TimeoutException, RuntimeException, "Timeout")
-POCO_IMPLEMENT_EXCEPTION(SystemException, RuntimeException, "System exception")
-POCO_IMPLEMENT_EXCEPTION(RegularExpressionException, RuntimeException, "Error in regular expression")
-POCO_IMPLEMENT_EXCEPTION(LibraryLoadException, RuntimeException, "Cannot load library")
-POCO_IMPLEMENT_EXCEPTION(LibraryAlreadyLoadedException, RuntimeException, "Library already loaded")
-POCO_IMPLEMENT_EXCEPTION(NoThreadAvailableException, RuntimeException, "No thread available")
-POCO_IMPLEMENT_EXCEPTION(PropertyNotSupportedException, RuntimeException, "Property not supported")
-POCO_IMPLEMENT_EXCEPTION(PoolOverflowException, RuntimeException, "Pool overflow")
-POCO_IMPLEMENT_EXCEPTION(NoPermissionException, RuntimeException, "No permission")
-POCO_IMPLEMENT_EXCEPTION(OutOfMemoryException, RuntimeException, "Out of memory")
-POCO_IMPLEMENT_EXCEPTION(DataException, RuntimeException, "Data error")
-
-POCO_IMPLEMENT_EXCEPTION(DataFormatException, DataException, "Bad data format")
-POCO_IMPLEMENT_EXCEPTION(SyntaxException, DataException, "Syntax error")
-POCO_IMPLEMENT_EXCEPTION(CircularReferenceException, DataException, "Circular reference")
-POCO_IMPLEMENT_EXCEPTION(PathSyntaxException, SyntaxException, "Bad path syntax")
-POCO_IMPLEMENT_EXCEPTION(IOException, RuntimeException, "I/O error")
-POCO_IMPLEMENT_EXCEPTION(ProtocolException, IOException, "Protocol error")
-POCO_IMPLEMENT_EXCEPTION(FileException, IOException, "File access error")
-POCO_IMPLEMENT_EXCEPTION(FileExistsException, FileException, "File exists")
-POCO_IMPLEMENT_EXCEPTION(FileNotFoundException, FileException, "File not found")
-POCO_IMPLEMENT_EXCEPTION(PathNotFoundException, FileException, "Path not found")
-POCO_IMPLEMENT_EXCEPTION(FileReadOnlyException, FileException, "File is read-only")
-POCO_IMPLEMENT_EXCEPTION(FileAccessDeniedException, FileException, "Access to file denied")
-POCO_IMPLEMENT_EXCEPTION(CreateFileException, FileException, "Cannot create file")
-POCO_IMPLEMENT_EXCEPTION(OpenFileException, FileException, "Cannot open file")
-POCO_IMPLEMENT_EXCEPTION(WriteFileException, FileException, "Cannot write file")
-POCO_IMPLEMENT_EXCEPTION(ReadFileException, FileException, "Cannot read file")
-POCO_IMPLEMENT_EXCEPTION(DirectoryNotEmptyException, FileException, "Directory not empty")
-POCO_IMPLEMENT_EXCEPTION(UnknownURISchemeException, RuntimeException, "Unknown URI scheme")
-POCO_IMPLEMENT_EXCEPTION(TooManyURIRedirectsException, RuntimeException, "Too many URI redirects")
-POCO_IMPLEMENT_EXCEPTION(URISyntaxException, SyntaxException, "Bad URI syntax")
-
-POCO_IMPLEMENT_EXCEPTION(ApplicationException, Exception, "Application exception")
-POCO_IMPLEMENT_EXCEPTION(BadCastException, RuntimeException, "Bad cast exception")
-
-
-} // namespace Poco
+{
+ return name();
+}
+
+
+std::string Exception::displayText() const
+{
+ std::string txt = name();
+ if (!_msg.empty())
+ {
+ txt.append(": ");
+ txt.append(_msg);
+ }
+ return txt;
+}
+
+
+void Exception::extendedMessage(const std::string& arg)
+{
+ if (!arg.empty())
+ {
+ if (!_msg.empty()) _msg.append(": ");
+ _msg.append(arg);
+ }
+}
+
+
+Exception* Exception::clone() const
+{
+ return new Exception(*this);
+}
+
+
+void Exception::rethrow() const
+{
+ throw *this;
+}
+
+
+POCO_IMPLEMENT_EXCEPTION(LogicException, Exception, "Logic exception")
+POCO_IMPLEMENT_EXCEPTION(AssertionViolationException, LogicException, "Assertion violation")
+POCO_IMPLEMENT_EXCEPTION(NullPointerException, LogicException, "Null pointer")
+POCO_IMPLEMENT_EXCEPTION(NullValueException, LogicException, "Null value")
+POCO_IMPLEMENT_EXCEPTION(BugcheckException, LogicException, "Bugcheck")
+POCO_IMPLEMENT_EXCEPTION(InvalidArgumentException, LogicException, "Invalid argument")
+POCO_IMPLEMENT_EXCEPTION(NotImplementedException, LogicException, "Not implemented")
+POCO_IMPLEMENT_EXCEPTION(RangeException, LogicException, "Out of range")
+POCO_IMPLEMENT_EXCEPTION(IllegalStateException, LogicException, "Illegal state")
+POCO_IMPLEMENT_EXCEPTION(InvalidAccessException, LogicException, "Invalid access")
+POCO_IMPLEMENT_EXCEPTION(SignalException, LogicException, "Signal received")
+POCO_IMPLEMENT_EXCEPTION(UnhandledException, LogicException, "Unhandled exception")
+
+POCO_IMPLEMENT_EXCEPTION(RuntimeException, Exception, "Runtime exception")
+POCO_IMPLEMENT_EXCEPTION(NotFoundException, RuntimeException, "Not found")
+POCO_IMPLEMENT_EXCEPTION(ExistsException, RuntimeException, "Exists")
+POCO_IMPLEMENT_EXCEPTION(TimeoutException, RuntimeException, "Timeout")
+POCO_IMPLEMENT_EXCEPTION(SystemException, RuntimeException, "System exception")
+POCO_IMPLEMENT_EXCEPTION(RegularExpressionException, RuntimeException, "Error in regular expression")
+POCO_IMPLEMENT_EXCEPTION(LibraryLoadException, RuntimeException, "Cannot load library")
+POCO_IMPLEMENT_EXCEPTION(LibraryAlreadyLoadedException, RuntimeException, "Library already loaded")
+POCO_IMPLEMENT_EXCEPTION(NoThreadAvailableException, RuntimeException, "No thread available")
+POCO_IMPLEMENT_EXCEPTION(PropertyNotSupportedException, RuntimeException, "Property not supported")
+POCO_IMPLEMENT_EXCEPTION(PoolOverflowException, RuntimeException, "Pool overflow")
+POCO_IMPLEMENT_EXCEPTION(NoPermissionException, RuntimeException, "No permission")
+POCO_IMPLEMENT_EXCEPTION(OutOfMemoryException, RuntimeException, "Out of memory")
+POCO_IMPLEMENT_EXCEPTION(DataException, RuntimeException, "Data error")
+
+POCO_IMPLEMENT_EXCEPTION(DataFormatException, DataException, "Bad data format")
+POCO_IMPLEMENT_EXCEPTION(SyntaxException, DataException, "Syntax error")
+POCO_IMPLEMENT_EXCEPTION(CircularReferenceException, DataException, "Circular reference")
+POCO_IMPLEMENT_EXCEPTION(PathSyntaxException, SyntaxException, "Bad path syntax")
+POCO_IMPLEMENT_EXCEPTION(IOException, RuntimeException, "I/O error")
+POCO_IMPLEMENT_EXCEPTION(ProtocolException, IOException, "Protocol error")
+POCO_IMPLEMENT_EXCEPTION(FileException, IOException, "File access error")
+POCO_IMPLEMENT_EXCEPTION(FileExistsException, FileException, "File exists")
+POCO_IMPLEMENT_EXCEPTION(FileNotFoundException, FileException, "File not found")
+POCO_IMPLEMENT_EXCEPTION(PathNotFoundException, FileException, "Path not found")
+POCO_IMPLEMENT_EXCEPTION(FileReadOnlyException, FileException, "File is read-only")
+POCO_IMPLEMENT_EXCEPTION(FileAccessDeniedException, FileException, "Access to file denied")
+POCO_IMPLEMENT_EXCEPTION(CreateFileException, FileException, "Cannot create file")
+POCO_IMPLEMENT_EXCEPTION(OpenFileException, FileException, "Cannot open file")
+POCO_IMPLEMENT_EXCEPTION(WriteFileException, FileException, "Cannot write file")
+POCO_IMPLEMENT_EXCEPTION(ReadFileException, FileException, "Cannot read file")
+POCO_IMPLEMENT_EXCEPTION(DirectoryNotEmptyException, FileException, "Directory not empty")
+POCO_IMPLEMENT_EXCEPTION(UnknownURISchemeException, RuntimeException, "Unknown URI scheme")
+POCO_IMPLEMENT_EXCEPTION(TooManyURIRedirectsException, RuntimeException, "Too many URI redirects")
+POCO_IMPLEMENT_EXCEPTION(URISyntaxException, SyntaxException, "Bad URI syntax")
+
+POCO_IMPLEMENT_EXCEPTION(ApplicationException, Exception, "Application exception")
+POCO_IMPLEMENT_EXCEPTION(BadCastException, RuntimeException, "Bad cast exception")
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/FIFOBufferStream.cpp b/contrib/libs/poco/Foundation/src/FIFOBufferStream.cpp
index 35f3e9f8b9..617d3a15ff 100644
--- a/contrib/libs/poco/Foundation/src/FIFOBufferStream.cpp
+++ b/contrib/libs/poco/Foundation/src/FIFOBufferStream.cpp
@@ -1,186 +1,186 @@
-//
-// FIFOBufferStream.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: FIFOBufferStream
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/FIFOBufferStream.h"
-
-
-namespace Poco {
-
-
-//
-// FIFOBufferStreamBuf
-//
-
-
-FIFOBufferStreamBuf::FIFOBufferStreamBuf():
- BufferedBidirectionalStreamBuf(STREAM_BUFFER_SIZE + 4, std::ios::in | std::ios::out),
- _pFIFOBuffer(new FIFOBuffer(STREAM_BUFFER_SIZE, true)),
- _fifoBuffer(*_pFIFOBuffer)
-{
-}
-
-
-FIFOBufferStreamBuf::FIFOBufferStreamBuf(FIFOBuffer& rFifoBuffer):
- BufferedBidirectionalStreamBuf(rFifoBuffer.size() + 4, std::ios::in | std::ios::out),
- _pFIFOBuffer(0),
- _fifoBuffer(rFifoBuffer)
-{
- rFifoBuffer.setNotify(true);
-}
-
-
-FIFOBufferStreamBuf::FIFOBufferStreamBuf(char* pBuffer, std::size_t length):
- BufferedBidirectionalStreamBuf(length + 4, std::ios::in | std::ios::out),
- _pFIFOBuffer(new FIFOBuffer(pBuffer, length, true)),
- _fifoBuffer(*_pFIFOBuffer)
-{
-}
-
-
-FIFOBufferStreamBuf::FIFOBufferStreamBuf(const char* pBuffer, std::size_t length):
- BufferedBidirectionalStreamBuf(length + 4, std::ios::in | std::ios::out),
- _pFIFOBuffer(new FIFOBuffer(pBuffer, length, true)),
- _fifoBuffer(*_pFIFOBuffer)
-{
-}
-
-
-FIFOBufferStreamBuf::FIFOBufferStreamBuf(std::size_t length):
- BufferedBidirectionalStreamBuf(length + 4, std::ios::in | std::ios::out),
- _pFIFOBuffer(new FIFOBuffer(length, true)),
- _fifoBuffer(*_pFIFOBuffer)
-{
-}
-
-
-FIFOBufferStreamBuf::~FIFOBufferStreamBuf()
-{
- delete _pFIFOBuffer;
-}
-
-
-int FIFOBufferStreamBuf::readFromDevice(char* buffer, std::streamsize length)
-{
- poco_assert (length > 0);
- return static_cast<int>(_fifoBuffer.read(buffer, static_cast<std::size_t>(length)));
-}
-
-
-int FIFOBufferStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
-{
- poco_assert (length > 0);
- return static_cast<int>(_fifoBuffer.write(buffer, static_cast<std::size_t>(length)));
-}
-
-
-//
-// FIFOIOS
-//
-
-
-FIFOIOS::FIFOIOS(FIFOBuffer& fifoBuffer): _buf(fifoBuffer)
-{
- poco_ios_init(&_buf);
-}
-
-
-FIFOIOS::FIFOIOS(char* pBuffer, std::size_t length): _buf(pBuffer, length)
-{
- poco_ios_init(&_buf);
-}
-
-
-FIFOIOS::FIFOIOS(const char* pBuffer, std::size_t length): _buf(pBuffer, length)
-{
- poco_ios_init(&_buf);
-}
-
-
-FIFOIOS::FIFOIOS(std::size_t length): _buf(length)
-{
- poco_ios_init(&_buf);
-}
-
-
-FIFOIOS::~FIFOIOS()
-{
- try
- {
- _buf.sync();
- }
- catch (...)
- {
- }
-}
-
-
-FIFOBufferStreamBuf* FIFOIOS::rdbuf()
-{
- return &_buf;
-}
-
-
-void FIFOIOS::close()
-{
- _buf.sync();
-}
-
-
-//
-// FIFOBufferStream
-//
-
-
-FIFOBufferStream::FIFOBufferStream(FIFOBuffer& fifoBuffer):
- FIFOIOS(fifoBuffer),
- std::iostream(&_buf),
- readable(_buf.fifoBuffer().readable),
- writable(_buf.fifoBuffer().writable)
-{
-}
-
-
-FIFOBufferStream::FIFOBufferStream(char* pBuffer, std::size_t length):
- FIFOIOS(pBuffer, length),
- std::iostream(&_buf),
- readable(_buf.fifoBuffer().readable),
- writable(_buf.fifoBuffer().writable)
-{
-}
-
-
-FIFOBufferStream::FIFOBufferStream(const char* pBuffer, std::size_t length):
- FIFOIOS(pBuffer, length),
- std::iostream(&_buf),
- readable(_buf.fifoBuffer().readable),
- writable(_buf.fifoBuffer().writable)
-{
-}
-
-
-FIFOBufferStream::FIFOBufferStream(std::size_t length):
- FIFOIOS(length),
- std::iostream(&_buf),
- readable(_buf.fifoBuffer().readable),
- writable(_buf.fifoBuffer().writable)
-{
-}
-
-
-FIFOBufferStream::~FIFOBufferStream()
-{
-}
-
-
-} // namespace Poco
+//
+// FIFOBufferStream.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: FIFOBufferStream
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/FIFOBufferStream.h"
+
+
+namespace Poco {
+
+
+//
+// FIFOBufferStreamBuf
+//
+
+
+FIFOBufferStreamBuf::FIFOBufferStreamBuf():
+ BufferedBidirectionalStreamBuf(STREAM_BUFFER_SIZE + 4, std::ios::in | std::ios::out),
+ _pFIFOBuffer(new FIFOBuffer(STREAM_BUFFER_SIZE, true)),
+ _fifoBuffer(*_pFIFOBuffer)
+{
+}
+
+
+FIFOBufferStreamBuf::FIFOBufferStreamBuf(FIFOBuffer& rFifoBuffer):
+ BufferedBidirectionalStreamBuf(rFifoBuffer.size() + 4, std::ios::in | std::ios::out),
+ _pFIFOBuffer(0),
+ _fifoBuffer(rFifoBuffer)
+{
+ rFifoBuffer.setNotify(true);
+}
+
+
+FIFOBufferStreamBuf::FIFOBufferStreamBuf(char* pBuffer, std::size_t length):
+ BufferedBidirectionalStreamBuf(length + 4, std::ios::in | std::ios::out),
+ _pFIFOBuffer(new FIFOBuffer(pBuffer, length, true)),
+ _fifoBuffer(*_pFIFOBuffer)
+{
+}
+
+
+FIFOBufferStreamBuf::FIFOBufferStreamBuf(const char* pBuffer, std::size_t length):
+ BufferedBidirectionalStreamBuf(length + 4, std::ios::in | std::ios::out),
+ _pFIFOBuffer(new FIFOBuffer(pBuffer, length, true)),
+ _fifoBuffer(*_pFIFOBuffer)
+{
+}
+
+
+FIFOBufferStreamBuf::FIFOBufferStreamBuf(std::size_t length):
+ BufferedBidirectionalStreamBuf(length + 4, std::ios::in | std::ios::out),
+ _pFIFOBuffer(new FIFOBuffer(length, true)),
+ _fifoBuffer(*_pFIFOBuffer)
+{
+}
+
+
+FIFOBufferStreamBuf::~FIFOBufferStreamBuf()
+{
+ delete _pFIFOBuffer;
+}
+
+
+int FIFOBufferStreamBuf::readFromDevice(char* buffer, std::streamsize length)
+{
+ poco_assert (length > 0);
+ return static_cast<int>(_fifoBuffer.read(buffer, static_cast<std::size_t>(length)));
+}
+
+
+int FIFOBufferStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
+{
+ poco_assert (length > 0);
+ return static_cast<int>(_fifoBuffer.write(buffer, static_cast<std::size_t>(length)));
+}
+
+
+//
+// FIFOIOS
+//
+
+
+FIFOIOS::FIFOIOS(FIFOBuffer& fifoBuffer): _buf(fifoBuffer)
+{
+ poco_ios_init(&_buf);
+}
+
+
+FIFOIOS::FIFOIOS(char* pBuffer, std::size_t length): _buf(pBuffer, length)
+{
+ poco_ios_init(&_buf);
+}
+
+
+FIFOIOS::FIFOIOS(const char* pBuffer, std::size_t length): _buf(pBuffer, length)
+{
+ poco_ios_init(&_buf);
+}
+
+
+FIFOIOS::FIFOIOS(std::size_t length): _buf(length)
+{
+ poco_ios_init(&_buf);
+}
+
+
+FIFOIOS::~FIFOIOS()
+{
+ try
+ {
+ _buf.sync();
+ }
+ catch (...)
+ {
+ }
+}
+
+
+FIFOBufferStreamBuf* FIFOIOS::rdbuf()
+{
+ return &_buf;
+}
+
+
+void FIFOIOS::close()
+{
+ _buf.sync();
+}
+
+
+//
+// FIFOBufferStream
+//
+
+
+FIFOBufferStream::FIFOBufferStream(FIFOBuffer& fifoBuffer):
+ FIFOIOS(fifoBuffer),
+ std::iostream(&_buf),
+ readable(_buf.fifoBuffer().readable),
+ writable(_buf.fifoBuffer().writable)
+{
+}
+
+
+FIFOBufferStream::FIFOBufferStream(char* pBuffer, std::size_t length):
+ FIFOIOS(pBuffer, length),
+ std::iostream(&_buf),
+ readable(_buf.fifoBuffer().readable),
+ writable(_buf.fifoBuffer().writable)
+{
+}
+
+
+FIFOBufferStream::FIFOBufferStream(const char* pBuffer, std::size_t length):
+ FIFOIOS(pBuffer, length),
+ std::iostream(&_buf),
+ readable(_buf.fifoBuffer().readable),
+ writable(_buf.fifoBuffer().writable)
+{
+}
+
+
+FIFOBufferStream::FIFOBufferStream(std::size_t length):
+ FIFOIOS(length),
+ std::iostream(&_buf),
+ readable(_buf.fifoBuffer().readable),
+ writable(_buf.fifoBuffer().writable)
+{
+}
+
+
+FIFOBufferStream::~FIFOBufferStream()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/FPEnvironment.cpp b/contrib/libs/poco/Foundation/src/FPEnvironment.cpp
index 4617b7841a..8f0e2bdd9b 100644
--- a/contrib/libs/poco/Foundation/src/FPEnvironment.cpp
+++ b/contrib/libs/poco/Foundation/src/FPEnvironment.cpp
@@ -1,83 +1,83 @@
-//
-// FPEnvironment.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: FPEnvironment
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-// pull in platform identification macros needed below
-#include "Poco/Platform.h"
-#include "Poco/FPEnvironment.h"
-
-
-#if defined(POCO_NO_FPENVIRONMENT)
-#include "FPEnvironment_DUMMY.cpp"
-#elif defined(__osf__)
-#include "FPEnvironment_DEC.cpp"
-#elif defined(sun) || defined(__sun)
-#include "FPEnvironment_SUN.cpp"
-#elif defined(__QNX__)
-#include "FPEnvironment_QNX.cpp"
-#elif defined(POCO_OS_FAMILY_UNIX)
-#include "FPEnvironment_C99.cpp"
-#elif defined(POCO_OS_FAMILY_WINDOWS)
-#include "FPEnvironment_WIN32.cpp"
-#else
-#include "FPEnvironment_DUMMY.cpp"
-#endif
-
-
-namespace Poco {
-
-
-FPEnvironment::FPEnvironment()
-{
-}
-
-
-FPEnvironment::FPEnvironment(RoundingMode rm)
-{
- setRoundingMode(rm);
-}
-
-
-FPEnvironment::FPEnvironment(const FPEnvironment& env): FPEnvironmentImpl(env)
-{
-}
-
-
-FPEnvironment::~FPEnvironment()
-{
-}
-
-
-FPEnvironment& FPEnvironment::operator = (const FPEnvironment& env)
-{
- if (&env != this)
- {
- FPEnvironmentImpl::operator = (env);
- }
- return *this;
-}
-
-
-void FPEnvironment::keepCurrent()
-{
- keepCurrentImpl();
-}
-
-
-void FPEnvironment::clearFlags()
-{
- clearFlagsImpl();
-}
-
-
-} // namespace Poco
+//
+// FPEnvironment.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: FPEnvironment
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+// pull in platform identification macros needed below
+#include "Poco/Platform.h"
+#include "Poco/FPEnvironment.h"
+
+
+#if defined(POCO_NO_FPENVIRONMENT)
+#include "FPEnvironment_DUMMY.cpp"
+#elif defined(__osf__)
+#include "FPEnvironment_DEC.cpp"
+#elif defined(sun) || defined(__sun)
+#include "FPEnvironment_SUN.cpp"
+#elif defined(__QNX__)
+#include "FPEnvironment_QNX.cpp"
+#elif defined(POCO_OS_FAMILY_UNIX)
+#include "FPEnvironment_C99.cpp"
+#elif defined(POCO_OS_FAMILY_WINDOWS)
+#include "FPEnvironment_WIN32.cpp"
+#else
+#include "FPEnvironment_DUMMY.cpp"
+#endif
+
+
+namespace Poco {
+
+
+FPEnvironment::FPEnvironment()
+{
+}
+
+
+FPEnvironment::FPEnvironment(RoundingMode rm)
+{
+ setRoundingMode(rm);
+}
+
+
+FPEnvironment::FPEnvironment(const FPEnvironment& env): FPEnvironmentImpl(env)
+{
+}
+
+
+FPEnvironment::~FPEnvironment()
+{
+}
+
+
+FPEnvironment& FPEnvironment::operator = (const FPEnvironment& env)
+{
+ if (&env != this)
+ {
+ FPEnvironmentImpl::operator = (env);
+ }
+ return *this;
+}
+
+
+void FPEnvironment::keepCurrent()
+{
+ keepCurrentImpl();
+}
+
+
+void FPEnvironment::clearFlags()
+{
+ clearFlagsImpl();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/FPEnvironment_C99.cpp b/contrib/libs/poco/Foundation/src/FPEnvironment_C99.cpp
index 4bd3e31ba9..7fb948d16f 100644
--- a/contrib/libs/poco/Foundation/src/FPEnvironment_C99.cpp
+++ b/contrib/libs/poco/Foundation/src/FPEnvironment_C99.cpp
@@ -1,82 +1,82 @@
-//
-// FPEnvironment_C99.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: FPEnvironment
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/FPEnvironment_C99.h"
-
-
-namespace Poco {
-
-
-FPEnvironmentImpl::FPEnvironmentImpl()
-{
- fegetenv(&_env);
-}
-
-
-FPEnvironmentImpl::FPEnvironmentImpl(const FPEnvironmentImpl& env)
-{
- _env = env._env;
-}
-
-
-FPEnvironmentImpl::~FPEnvironmentImpl()
-{
- fesetenv(&_env);
-}
-
-
-FPEnvironmentImpl& FPEnvironmentImpl::operator = (const FPEnvironmentImpl& env)
-{
- _env = env._env;
- return *this;
-}
-
-
-void FPEnvironmentImpl::keepCurrentImpl()
-{
- fegetenv(&_env);
-}
-
-
-void FPEnvironmentImpl::clearFlagsImpl()
-{
- feclearexcept(FE_ALL_EXCEPT);
-}
-
-
-bool FPEnvironmentImpl::isFlagImpl(FlagImpl flag)
-{
- return fetestexcept(flag) != 0;
-}
-
-
-void FPEnvironmentImpl::setRoundingModeImpl(RoundingModeImpl mode)
-{
- fesetround(mode);
-}
-
-
-FPEnvironmentImpl::RoundingModeImpl FPEnvironmentImpl::getRoundingModeImpl()
-{
- return (RoundingModeImpl) fegetround();
-}
-
-
-long double FPEnvironmentImpl::copySignImpl(long double target, long double source)
-{
- return (source >= 0 && target >= 0) || (source < 0 && target < 0) ? target : -target;
-}
-
-
-} // namespace Poco
+//
+// FPEnvironment_C99.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: FPEnvironment
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/FPEnvironment_C99.h"
+
+
+namespace Poco {
+
+
+FPEnvironmentImpl::FPEnvironmentImpl()
+{
+ fegetenv(&_env);
+}
+
+
+FPEnvironmentImpl::FPEnvironmentImpl(const FPEnvironmentImpl& env)
+{
+ _env = env._env;
+}
+
+
+FPEnvironmentImpl::~FPEnvironmentImpl()
+{
+ fesetenv(&_env);
+}
+
+
+FPEnvironmentImpl& FPEnvironmentImpl::operator = (const FPEnvironmentImpl& env)
+{
+ _env = env._env;
+ return *this;
+}
+
+
+void FPEnvironmentImpl::keepCurrentImpl()
+{
+ fegetenv(&_env);
+}
+
+
+void FPEnvironmentImpl::clearFlagsImpl()
+{
+ feclearexcept(FE_ALL_EXCEPT);
+}
+
+
+bool FPEnvironmentImpl::isFlagImpl(FlagImpl flag)
+{
+ return fetestexcept(flag) != 0;
+}
+
+
+void FPEnvironmentImpl::setRoundingModeImpl(RoundingModeImpl mode)
+{
+ fesetround(mode);
+}
+
+
+FPEnvironmentImpl::RoundingModeImpl FPEnvironmentImpl::getRoundingModeImpl()
+{
+ return (RoundingModeImpl) fegetround();
+}
+
+
+long double FPEnvironmentImpl::copySignImpl(long double target, long double source)
+{
+ return (source >= 0 && target >= 0) || (source < 0 && target < 0) ? target : -target;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/FPEnvironment_DEC.cpp b/contrib/libs/poco/Foundation/src/FPEnvironment_DEC.cpp
index 037e28df76..12516f44f1 100644
--- a/contrib/libs/poco/Foundation/src/FPEnvironment_DEC.cpp
+++ b/contrib/libs/poco/Foundation/src/FPEnvironment_DEC.cpp
@@ -1,195 +1,195 @@
-//
-// FPEnvironment_DEC.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: FPEnvironment
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-//
-// _XOPEN_SOURCE disables the ieee fp functions
-// in <math.h>, therefore we undefine it for this file.
-//
-#undef _XOPEN_SOURCE
-
-
-#include <math.h>
-#include <fp.h>
-#include <fp_class.h>
-#if defined(__VMS)
-#include <starlet.h>
-#endif
-#include "Poco/FPEnvironment_DEC.h"
-
-
-namespace Poco {
-
-
-FPEnvironmentImpl::FPEnvironmentImpl()
-{
-#if defined(__VMS)
- #pragma pointer_size save
- #pragma pointer_size 32
- struct _ieee env;
- sys$ieee_set_fp_control(0, 0, &env);
- #pragma pointer_size restore
- _env = env;
-#else
- _env = ieee_get_fp_control();
-#endif
-}
-
-
-FPEnvironmentImpl::FPEnvironmentImpl(const FPEnvironmentImpl& env)
-{
- _env = env._env;
-}
-
-
-FPEnvironmentImpl::~FPEnvironmentImpl()
-{
-#if defined(__VMS)
- #pragma pointer_size save
- #pragma pointer_size 32
- struct _ieee mask;
- mask.ieee$q_flags = 0xFFFFFFFFFFFFFFFF;
- struct _ieee env = _env;
- sys$ieee_set_fp_control(&mask, &env, 0);
- #pragma pointer_size restore
-#else
- ieee_set_fp_control(_env);
-#endif
-}
-
-
-FPEnvironmentImpl& FPEnvironmentImpl::operator = (const FPEnvironmentImpl& env)
-{
- _env = env._env;
- return *this;
-}
-
-
-bool FPEnvironmentImpl::isInfiniteImpl(float value)
-{
- int cls = fp_classf(value);
- return cls == FP_POS_INF || cls == FP_NEG_INF;
-}
-
-
-bool FPEnvironmentImpl::isInfiniteImpl(double value)
-{
- int cls = fp_class(value);
- return cls == FP_POS_INF || cls == FP_NEG_INF;
-}
-
-
-bool FPEnvironmentImpl::isInfiniteImpl(long double value)
-{
- int cls = fp_classl(value);
- return cls == FP_POS_INF || cls == FP_NEG_INF;
-}
-
-
-bool FPEnvironmentImpl::isNaNImpl(float value)
-{
- return isnanf(value) != 0;
-}
-
-
-bool FPEnvironmentImpl::isNaNImpl(double value)
-{
- return isnan(value) != 0;
-}
-
-
-bool FPEnvironmentImpl::isNaNImpl(long double value)
-{
- return isnanl(value) != 0;
-}
-
-
-float FPEnvironmentImpl::copySignImpl(float target, float source)
-{
- return copysignf(target, source);
-}
-
-
-double FPEnvironmentImpl::copySignImpl(double target, double source)
-{
- return copysign(target, source);
-}
-
-
-long double FPEnvironmentImpl::copySignImpl(long double target, long double source)
-{
- return copysignl(target, source);
-}
-
-
-void FPEnvironmentImpl::keepCurrentImpl()
-{
-#if defined(__VMS)
- #pragma pointer_size save
- #pragma pointer_size 32
- struct _ieee env;
- sys$ieee_set_fp_control(0, 0, &env);
- #pragma pointer_size restore
- _env = env;
-#else
- ieee_set_fp_control(_env);
-#endif
-}
-
-
-void FPEnvironmentImpl::clearFlagsImpl()
-{
-#if defined(__VMS)
- #pragma pointer_size save
- #pragma pointer_size 32
- struct _ieee mask;
- mask.ieee$q_flags = 0xFFFFFFFFFFFFFFFF;
- struct _ieee clr;
- clr.ieee$q_flags = 0;
- sys$ieee_set_fp_control(&mask, &clr, 0);
- #pragma pointer_size restore
-#else
- ieee_set_fp_control(0);
-#endif
-}
-
-
-bool FPEnvironmentImpl::isFlagImpl(FlagImpl flag)
-{
-#if defined(__VMS)
- #pragma pointer_size save
- #pragma pointer_size 32
- struct _ieee flags;
- sys$ieee_set_fp_control(0, 0, &flags);
- return (flags.ieee$q_flags & flag) != 0;
- #pragma pointer_size restore
-#else
- return (ieee_get_fp_control() & flag) != 0;
-#endif
-}
-
-
-void FPEnvironmentImpl::setRoundingModeImpl(RoundingModeImpl mode)
-{
- // not supported
-}
-
-
-FPEnvironmentImpl::RoundingModeImpl FPEnvironmentImpl::getRoundingModeImpl()
-{
- // not supported
- return FPEnvironmentImpl::RoundingModeImpl(0);
-}
-
-
-} // namespace Poco
+//
+// FPEnvironment_DEC.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: FPEnvironment
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+//
+// _XOPEN_SOURCE disables the ieee fp functions
+// in <math.h>, therefore we undefine it for this file.
+//
+#undef _XOPEN_SOURCE
+
+
+#include <math.h>
+#include <fp.h>
+#include <fp_class.h>
+#if defined(__VMS)
+#include <starlet.h>
+#endif
+#include "Poco/FPEnvironment_DEC.h"
+
+
+namespace Poco {
+
+
+FPEnvironmentImpl::FPEnvironmentImpl()
+{
+#if defined(__VMS)
+ #pragma pointer_size save
+ #pragma pointer_size 32
+ struct _ieee env;
+ sys$ieee_set_fp_control(0, 0, &env);
+ #pragma pointer_size restore
+ _env = env;
+#else
+ _env = ieee_get_fp_control();
+#endif
+}
+
+
+FPEnvironmentImpl::FPEnvironmentImpl(const FPEnvironmentImpl& env)
+{
+ _env = env._env;
+}
+
+
+FPEnvironmentImpl::~FPEnvironmentImpl()
+{
+#if defined(__VMS)
+ #pragma pointer_size save
+ #pragma pointer_size 32
+ struct _ieee mask;
+ mask.ieee$q_flags = 0xFFFFFFFFFFFFFFFF;
+ struct _ieee env = _env;
+ sys$ieee_set_fp_control(&mask, &env, 0);
+ #pragma pointer_size restore
+#else
+ ieee_set_fp_control(_env);
+#endif
+}
+
+
+FPEnvironmentImpl& FPEnvironmentImpl::operator = (const FPEnvironmentImpl& env)
+{
+ _env = env._env;
+ return *this;
+}
+
+
+bool FPEnvironmentImpl::isInfiniteImpl(float value)
+{
+ int cls = fp_classf(value);
+ return cls == FP_POS_INF || cls == FP_NEG_INF;
+}
+
+
+bool FPEnvironmentImpl::isInfiniteImpl(double value)
+{
+ int cls = fp_class(value);
+ return cls == FP_POS_INF || cls == FP_NEG_INF;
+}
+
+
+bool FPEnvironmentImpl::isInfiniteImpl(long double value)
+{
+ int cls = fp_classl(value);
+ return cls == FP_POS_INF || cls == FP_NEG_INF;
+}
+
+
+bool FPEnvironmentImpl::isNaNImpl(float value)
+{
+ return isnanf(value) != 0;
+}
+
+
+bool FPEnvironmentImpl::isNaNImpl(double value)
+{
+ return isnan(value) != 0;
+}
+
+
+bool FPEnvironmentImpl::isNaNImpl(long double value)
+{
+ return isnanl(value) != 0;
+}
+
+
+float FPEnvironmentImpl::copySignImpl(float target, float source)
+{
+ return copysignf(target, source);
+}
+
+
+double FPEnvironmentImpl::copySignImpl(double target, double source)
+{
+ return copysign(target, source);
+}
+
+
+long double FPEnvironmentImpl::copySignImpl(long double target, long double source)
+{
+ return copysignl(target, source);
+}
+
+
+void FPEnvironmentImpl::keepCurrentImpl()
+{
+#if defined(__VMS)
+ #pragma pointer_size save
+ #pragma pointer_size 32
+ struct _ieee env;
+ sys$ieee_set_fp_control(0, 0, &env);
+ #pragma pointer_size restore
+ _env = env;
+#else
+ ieee_set_fp_control(_env);
+#endif
+}
+
+
+void FPEnvironmentImpl::clearFlagsImpl()
+{
+#if defined(__VMS)
+ #pragma pointer_size save
+ #pragma pointer_size 32
+ struct _ieee mask;
+ mask.ieee$q_flags = 0xFFFFFFFFFFFFFFFF;
+ struct _ieee clr;
+ clr.ieee$q_flags = 0;
+ sys$ieee_set_fp_control(&mask, &clr, 0);
+ #pragma pointer_size restore
+#else
+ ieee_set_fp_control(0);
+#endif
+}
+
+
+bool FPEnvironmentImpl::isFlagImpl(FlagImpl flag)
+{
+#if defined(__VMS)
+ #pragma pointer_size save
+ #pragma pointer_size 32
+ struct _ieee flags;
+ sys$ieee_set_fp_control(0, 0, &flags);
+ return (flags.ieee$q_flags & flag) != 0;
+ #pragma pointer_size restore
+#else
+ return (ieee_get_fp_control() & flag) != 0;
+#endif
+}
+
+
+void FPEnvironmentImpl::setRoundingModeImpl(RoundingModeImpl mode)
+{
+ // not supported
+}
+
+
+FPEnvironmentImpl::RoundingModeImpl FPEnvironmentImpl::getRoundingModeImpl()
+{
+ // not supported
+ return FPEnvironmentImpl::RoundingModeImpl(0);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/FPEnvironment_DUMMY.cpp b/contrib/libs/poco/Foundation/src/FPEnvironment_DUMMY.cpp
index b473d0dfb9..1681bc7cc4 100644
--- a/contrib/libs/poco/Foundation/src/FPEnvironment_DUMMY.cpp
+++ b/contrib/libs/poco/Foundation/src/FPEnvironment_DUMMY.cpp
@@ -1,79 +1,79 @@
-//
-// FPEnvironment_C99.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: FPEnvironment
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/FPEnvironment_DUMMY.h"
-
-
-namespace Poco {
-
-
-FPEnvironmentImpl::RoundingModeImpl FPEnvironmentImpl::_roundingMode;
-
-
-FPEnvironmentImpl::FPEnvironmentImpl()
-{
-}
-
-
-FPEnvironmentImpl::FPEnvironmentImpl(const FPEnvironmentImpl& env)
-{
-}
-
-
-FPEnvironmentImpl::~FPEnvironmentImpl()
-{
-}
-
-
-FPEnvironmentImpl& FPEnvironmentImpl::operator = (const FPEnvironmentImpl& env)
-{
- return *this;
-}
-
-
-void FPEnvironmentImpl::keepCurrentImpl()
-{
-}
-
-
-void FPEnvironmentImpl::clearFlagsImpl()
-{
-}
-
-
-bool FPEnvironmentImpl::isFlagImpl(FlagImpl flag)
-{
- return false;
-}
-
-
-void FPEnvironmentImpl::setRoundingModeImpl(RoundingModeImpl mode)
-{
- _roundingMode = mode;
-}
-
-
-FPEnvironmentImpl::RoundingModeImpl FPEnvironmentImpl::getRoundingModeImpl()
-{
- return _roundingMode;
-}
-
-
-long double FPEnvironmentImpl::copySignImpl(long double target, long double source)
-{
- return (source >= 0 && target >= 0) || (source < 0 && target < 0) ? target : -target;
-}
-
-
-} // namespace Poco
+//
+// FPEnvironment_C99.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: FPEnvironment
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/FPEnvironment_DUMMY.h"
+
+
+namespace Poco {
+
+
+FPEnvironmentImpl::RoundingModeImpl FPEnvironmentImpl::_roundingMode;
+
+
+FPEnvironmentImpl::FPEnvironmentImpl()
+{
+}
+
+
+FPEnvironmentImpl::FPEnvironmentImpl(const FPEnvironmentImpl& env)
+{
+}
+
+
+FPEnvironmentImpl::~FPEnvironmentImpl()
+{
+}
+
+
+FPEnvironmentImpl& FPEnvironmentImpl::operator = (const FPEnvironmentImpl& env)
+{
+ return *this;
+}
+
+
+void FPEnvironmentImpl::keepCurrentImpl()
+{
+}
+
+
+void FPEnvironmentImpl::clearFlagsImpl()
+{
+}
+
+
+bool FPEnvironmentImpl::isFlagImpl(FlagImpl flag)
+{
+ return false;
+}
+
+
+void FPEnvironmentImpl::setRoundingModeImpl(RoundingModeImpl mode)
+{
+ _roundingMode = mode;
+}
+
+
+FPEnvironmentImpl::RoundingModeImpl FPEnvironmentImpl::getRoundingModeImpl()
+{
+ return _roundingMode;
+}
+
+
+long double FPEnvironmentImpl::copySignImpl(long double target, long double source)
+{
+ return (source >= 0 && target >= 0) || (source < 0 && target < 0) ? target : -target;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/FPEnvironment_QNX.cpp b/contrib/libs/poco/Foundation/src/FPEnvironment_QNX.cpp
index 057eb8eb7b..8959d5007a 100644
--- a/contrib/libs/poco/Foundation/src/FPEnvironment_QNX.cpp
+++ b/contrib/libs/poco/Foundation/src/FPEnvironment_QNX.cpp
@@ -1,82 +1,82 @@
-//
-// FPEnvironment_QNX.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: FPEnvironment
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/FPEnvironment_QNX.h"
-
-
-namespace Poco {
-
-
-FPEnvironmentImpl::FPEnvironmentImpl()
-{
- fegetenv(&_env);
-}
-
-
-FPEnvironmentImpl::FPEnvironmentImpl(const FPEnvironmentImpl& env)
-{
- _env = env._env;
-}
-
-
-FPEnvironmentImpl::~FPEnvironmentImpl()
-{
- fesetenv(&_env);
-}
-
-
-FPEnvironmentImpl& FPEnvironmentImpl::operator = (const FPEnvironmentImpl& env)
-{
- _env = env._env;
- return *this;
-}
-
-
-void FPEnvironmentImpl::keepCurrentImpl()
-{
- fegetenv(&_env);
-}
-
-
-void FPEnvironmentImpl::clearFlagsImpl()
-{
- feclearexcept(FE_ALL_EXCEPT);
-}
-
-
-bool FPEnvironmentImpl::isFlagImpl(FlagImpl flag)
-{
- return fetestexcept(flag) != 0;
-}
-
-
-void FPEnvironmentImpl::setRoundingModeImpl(RoundingModeImpl mode)
-{
- fesetround(mode);
-}
-
-
-FPEnvironmentImpl::RoundingModeImpl FPEnvironmentImpl::getRoundingModeImpl()
-{
- return (RoundingModeImpl) fegetround();
-}
-
-
-long double FPEnvironmentImpl::copySignImpl(long double target, long double source)
-{
- return (source >= 0 && target >= 0) || (source < 0 && target < 0) ? target : -target;
-}
-
-
-} // namespace Poco
+//
+// FPEnvironment_QNX.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: FPEnvironment
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/FPEnvironment_QNX.h"
+
+
+namespace Poco {
+
+
+FPEnvironmentImpl::FPEnvironmentImpl()
+{
+ fegetenv(&_env);
+}
+
+
+FPEnvironmentImpl::FPEnvironmentImpl(const FPEnvironmentImpl& env)
+{
+ _env = env._env;
+}
+
+
+FPEnvironmentImpl::~FPEnvironmentImpl()
+{
+ fesetenv(&_env);
+}
+
+
+FPEnvironmentImpl& FPEnvironmentImpl::operator = (const FPEnvironmentImpl& env)
+{
+ _env = env._env;
+ return *this;
+}
+
+
+void FPEnvironmentImpl::keepCurrentImpl()
+{
+ fegetenv(&_env);
+}
+
+
+void FPEnvironmentImpl::clearFlagsImpl()
+{
+ feclearexcept(FE_ALL_EXCEPT);
+}
+
+
+bool FPEnvironmentImpl::isFlagImpl(FlagImpl flag)
+{
+ return fetestexcept(flag) != 0;
+}
+
+
+void FPEnvironmentImpl::setRoundingModeImpl(RoundingModeImpl mode)
+{
+ fesetround(mode);
+}
+
+
+FPEnvironmentImpl::RoundingModeImpl FPEnvironmentImpl::getRoundingModeImpl()
+{
+ return (RoundingModeImpl) fegetround();
+}
+
+
+long double FPEnvironmentImpl::copySignImpl(long double target, long double source)
+{
+ return (source >= 0 && target >= 0) || (source < 0 && target < 0) ? target : -target;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/FPEnvironment_SUN.cpp b/contrib/libs/poco/Foundation/src/FPEnvironment_SUN.cpp
index 36ee36431d..d0bea41971 100644
--- a/contrib/libs/poco/Foundation/src/FPEnvironment_SUN.cpp
+++ b/contrib/libs/poco/Foundation/src/FPEnvironment_SUN.cpp
@@ -1,139 +1,139 @@
-//
-// FPEnvironment_SUN.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: FPEnvironment
-//
-// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include <math.h>
-#include "Poco/FPEnvironment_SUN.h"
-
-
-namespace Poco {
-
-
-FPEnvironmentImpl::FPEnvironmentImpl()
-{
- _rnd = fpgetround();
- _exc = fpgetmask();
-}
-
-
-FPEnvironmentImpl::FPEnvironmentImpl(const FPEnvironmentImpl& env)
-{
- _rnd = env._rnd;
- _exc = env._exc;
-}
-
-
-FPEnvironmentImpl::~FPEnvironmentImpl()
-{
- fpsetround(_rnd);
- fpsetmask(_exc);
-}
-
-
-FPEnvironmentImpl& FPEnvironmentImpl::operator = (const FPEnvironmentImpl& env)
-{
- _rnd = env._rnd;
- _exc = env._exc;
- return *this;
-}
-
-
-bool FPEnvironmentImpl::isInfiniteImpl(float value)
-{
- int cls = fpclass(value);
- return cls == FP_PINF || cls == FP_NINF;
-}
-
-
-bool FPEnvironmentImpl::isInfiniteImpl(double value)
-{
- int cls = fpclass(value);
- return cls == FP_PINF || cls == FP_NINF;
-}
-
-
-bool FPEnvironmentImpl::isInfiniteImpl(long double value)
-{
- int cls = fpclass(value);
- return cls == FP_PINF || cls == FP_NINF;
-}
-
-
-bool FPEnvironmentImpl::isNaNImpl(float value)
-{
- return isnanf(value) != 0;
-}
-
-
-bool FPEnvironmentImpl::isNaNImpl(double value)
-{
- return isnan(value) != 0;
-}
-
-
-bool FPEnvironmentImpl::isNaNImpl(long double value)
-{
- return isnan((double) value) != 0;
-}
-
-
-float FPEnvironmentImpl::copySignImpl(float target, float source)
-{
- return (float) copysign(target, source);
-}
-
-
-double FPEnvironmentImpl::copySignImpl(double target, double source)
-{
- return (float) copysign(target, source);
-}
-
-
-long double FPEnvironmentImpl::copySignImpl(long double target, long double source)
-{
- return (source > 0 && target > 0) || (source < 0 && target < 0) ? target : -target;
-}
-
-
-void FPEnvironmentImpl::keepCurrentImpl()
-{
- fpsetround(_rnd);
- fpsetmask(_exc);
-}
-
-
-void FPEnvironmentImpl::clearFlagsImpl()
-{
- fpsetsticky(0);
-}
-
-
-bool FPEnvironmentImpl::isFlagImpl(FlagImpl flag)
-{
- return (fpgetsticky() & flag) != 0;
-}
-
-
-void FPEnvironmentImpl::setRoundingModeImpl(RoundingModeImpl mode)
-{
- fpsetround((fp_rnd) mode);
-}
-
-
-FPEnvironmentImpl::RoundingModeImpl FPEnvironmentImpl::getRoundingModeImpl()
-{
- return (FPEnvironmentImpl::RoundingModeImpl) fpgetround();
-}
-
-
-} // namespace Poco
+//
+// FPEnvironment_SUN.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: FPEnvironment
+//
+// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include <math.h>
+#include "Poco/FPEnvironment_SUN.h"
+
+
+namespace Poco {
+
+
+FPEnvironmentImpl::FPEnvironmentImpl()
+{
+ _rnd = fpgetround();
+ _exc = fpgetmask();
+}
+
+
+FPEnvironmentImpl::FPEnvironmentImpl(const FPEnvironmentImpl& env)
+{
+ _rnd = env._rnd;
+ _exc = env._exc;
+}
+
+
+FPEnvironmentImpl::~FPEnvironmentImpl()
+{
+ fpsetround(_rnd);
+ fpsetmask(_exc);
+}
+
+
+FPEnvironmentImpl& FPEnvironmentImpl::operator = (const FPEnvironmentImpl& env)
+{
+ _rnd = env._rnd;
+ _exc = env._exc;
+ return *this;
+}
+
+
+bool FPEnvironmentImpl::isInfiniteImpl(float value)
+{
+ int cls = fpclass(value);
+ return cls == FP_PINF || cls == FP_NINF;
+}
+
+
+bool FPEnvironmentImpl::isInfiniteImpl(double value)
+{
+ int cls = fpclass(value);
+ return cls == FP_PINF || cls == FP_NINF;
+}
+
+
+bool FPEnvironmentImpl::isInfiniteImpl(long double value)
+{
+ int cls = fpclass(value);
+ return cls == FP_PINF || cls == FP_NINF;
+}
+
+
+bool FPEnvironmentImpl::isNaNImpl(float value)
+{
+ return isnanf(value) != 0;
+}
+
+
+bool FPEnvironmentImpl::isNaNImpl(double value)
+{
+ return isnan(value) != 0;
+}
+
+
+bool FPEnvironmentImpl::isNaNImpl(long double value)
+{
+ return isnan((double) value) != 0;
+}
+
+
+float FPEnvironmentImpl::copySignImpl(float target, float source)
+{
+ return (float) copysign(target, source);
+}
+
+
+double FPEnvironmentImpl::copySignImpl(double target, double source)
+{
+ return (float) copysign(target, source);
+}
+
+
+long double FPEnvironmentImpl::copySignImpl(long double target, long double source)
+{
+ return (source > 0 && target > 0) || (source < 0 && target < 0) ? target : -target;
+}
+
+
+void FPEnvironmentImpl::keepCurrentImpl()
+{
+ fpsetround(_rnd);
+ fpsetmask(_exc);
+}
+
+
+void FPEnvironmentImpl::clearFlagsImpl()
+{
+ fpsetsticky(0);
+}
+
+
+bool FPEnvironmentImpl::isFlagImpl(FlagImpl flag)
+{
+ return (fpgetsticky() & flag) != 0;
+}
+
+
+void FPEnvironmentImpl::setRoundingModeImpl(RoundingModeImpl mode)
+{
+ fpsetround((fp_rnd) mode);
+}
+
+
+FPEnvironmentImpl::RoundingModeImpl FPEnvironmentImpl::getRoundingModeImpl()
+{
+ return (FPEnvironmentImpl::RoundingModeImpl) fpgetround();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/FPEnvironment_WIN32.cpp b/contrib/libs/poco/Foundation/src/FPEnvironment_WIN32.cpp
index 32c7f65e7b..efd65c23c9 100644
--- a/contrib/libs/poco/Foundation/src/FPEnvironment_WIN32.cpp
+++ b/contrib/libs/poco/Foundation/src/FPEnvironment_WIN32.cpp
@@ -1,76 +1,76 @@
-//
-// FPEnvironment_WIN32.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: FPEnvironment
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/FPEnvironment_WIN32.h"
-
-
-namespace Poco {
-
-
-FPEnvironmentImpl::FPEnvironmentImpl()
-{
- _env = _controlfp(0, 0);
-}
-
-
-FPEnvironmentImpl::FPEnvironmentImpl(const FPEnvironmentImpl& env)
-{
- _env = env._env;
-}
-
-
-FPEnvironmentImpl::~FPEnvironmentImpl()
-{
- _controlfp(_env, _MCW_RC);
-}
-
-
-FPEnvironmentImpl& FPEnvironmentImpl::operator = (const FPEnvironmentImpl& env)
-{
- _env = env._env;
- return *this;
-}
-
-
-void FPEnvironmentImpl::keepCurrentImpl()
-{
- _env = _controlfp(0, 0);
-}
-
-
-void FPEnvironmentImpl::clearFlagsImpl()
-{
- _clearfp();
-}
-
-
-bool FPEnvironmentImpl::isFlagImpl(FlagImpl flag)
-{
- return (_statusfp() & flag) != 0;
-}
-
-
-void FPEnvironmentImpl::setRoundingModeImpl(RoundingModeImpl mode)
-{
- _controlfp(mode, _MCW_RC);
-}
-
-
-FPEnvironmentImpl::RoundingModeImpl FPEnvironmentImpl::getRoundingModeImpl()
-{
- return RoundingModeImpl(_controlfp(0, 0) & _MCW_RC);
-}
-
-
-} // namespace Poco
+//
+// FPEnvironment_WIN32.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: FPEnvironment
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/FPEnvironment_WIN32.h"
+
+
+namespace Poco {
+
+
+FPEnvironmentImpl::FPEnvironmentImpl()
+{
+ _env = _controlfp(0, 0);
+}
+
+
+FPEnvironmentImpl::FPEnvironmentImpl(const FPEnvironmentImpl& env)
+{
+ _env = env._env;
+}
+
+
+FPEnvironmentImpl::~FPEnvironmentImpl()
+{
+ _controlfp(_env, _MCW_RC);
+}
+
+
+FPEnvironmentImpl& FPEnvironmentImpl::operator = (const FPEnvironmentImpl& env)
+{
+ _env = env._env;
+ return *this;
+}
+
+
+void FPEnvironmentImpl::keepCurrentImpl()
+{
+ _env = _controlfp(0, 0);
+}
+
+
+void FPEnvironmentImpl::clearFlagsImpl()
+{
+ _clearfp();
+}
+
+
+bool FPEnvironmentImpl::isFlagImpl(FlagImpl flag)
+{
+ return (_statusfp() & flag) != 0;
+}
+
+
+void FPEnvironmentImpl::setRoundingModeImpl(RoundingModeImpl mode)
+{
+ _controlfp(mode, _MCW_RC);
+}
+
+
+FPEnvironmentImpl::RoundingModeImpl FPEnvironmentImpl::getRoundingModeImpl()
+{
+ return RoundingModeImpl(_controlfp(0, 0) & _MCW_RC);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/File.cpp b/contrib/libs/poco/Foundation/src/File.cpp
index c3bfc13946..86d5b18490 100644
--- a/contrib/libs/poco/Foundation/src/File.cpp
+++ b/contrib/libs/poco/Foundation/src/File.cpp
@@ -1,394 +1,394 @@
-//
-// File.cpp
-//
-// Library: Foundation
-// Package: Filesystem
-// Module: File
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/File.h"
-#include "Poco/Path.h"
-#include "Poco/DirectoryIterator.h"
-
-
-#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
-#if defined(_WIN32_WCE)
-#include "File_WINCE.cpp"
-#else
-#include "File_WIN32U.cpp"
-#endif
-#elif defined(POCO_OS_FAMILY_WINDOWS)
-#include "File_WIN32.cpp"
-#elif defined(POCO_VXWORKS)
-#include "File_VX.cpp"
-#elif defined(POCO_OS_FAMILY_UNIX)
-#include "File_UNIX.cpp"
-#endif
-#include "Poco/Thread.h"
-
-
-namespace Poco {
-
-
-File::File()
-{
-}
-
-
-File::File(const std::string& rPath): FileImpl(rPath)
-{
-}
-
-
-File::File(const char* pPath): FileImpl(std::string(pPath))
-{
-}
-
-
-File::File(const Path& rPath): FileImpl(rPath.toString())
-{
-}
-
-
-File::File(const File& file): FileImpl(file.getPathImpl())
-{
-}
-
-
-File::~File()
-{
-}
-
-
-File& File::operator = (const File& file)
-{
- setPathImpl(file.getPathImpl());
- return *this;
-}
-
-
-File& File::operator = (const std::string& rPath)
-{
- setPathImpl(rPath);
- return *this;
-}
-
-
-File& File::operator = (const char* pPath)
-{
- poco_check_ptr (pPath);
- setPathImpl(pPath);
- return *this;
-}
-
-
-File& File::operator = (const Path& rPath)
-{
- setPathImpl(rPath.toString());
- return *this;
-}
-
-
-void File::swap(File& file)
-{
- swapImpl(file);
-}
-
-
-bool File::exists() const
-{
- return existsImpl();
-}
-
-
-bool File::canRead() const
-{
- return canReadImpl();
-}
-
-
-bool File::canWrite() const
-{
- return canWriteImpl();
-}
-
-
-bool File::canExecute() const
-{
- return canExecuteImpl();
-}
-
-
-bool File::isFile() const
-{
- return isFileImpl();
-}
-
-
-bool File::isDirectory() const
-{
- return isDirectoryImpl();
-}
-
-
-bool File::isLink() const
-{
- return isLinkImpl();
-}
-
-
-bool File::isDevice() const
-{
- return isDeviceImpl();
-}
-
-
-bool File::isHidden() const
-{
- return isHiddenImpl();
-}
-
-
-Timestamp File::created() const
-{
- return createdImpl();
-}
-
-
-Timestamp File::getLastModified() const
-{
- return getLastModifiedImpl();
-}
-
-
-File& File::setLastModified(const Timestamp& ts)
-{
- setLastModifiedImpl(ts);
- return *this;
-}
-
-
-File::FileSize File::getSize() const
-{
- return getSizeImpl();
-}
-
-
-File& File::setSize(FileSizeImpl size)
-{
- setSizeImpl(size);
- return *this;
-}
-
-
-File& File::setWriteable(bool flag)
-{
- setWriteableImpl(flag);
- return *this;
-}
-
-
-File& File::setReadOnly(bool flag)
-{
- setWriteableImpl(!flag);
- return *this;
-}
-
-
-File& File::setExecutable(bool flag)
-{
- setExecutableImpl(flag);
- return *this;
-}
-
-
-void File::copyTo(const std::string& rPath) const
-{
- Path src(getPathImpl());
- Path dest(rPath);
- File destFile(rPath);
- if ((destFile.exists() && destFile.isDirectory()) || dest.isDirectory())
- {
- dest.makeDirectory();
- dest.setFileName(src.getFileName());
- }
- if (isDirectory())
- copyDirectory(dest.toString());
- else
- copyToImpl(dest.toString());
-}
-
-
-void File::copyDirectory(const std::string& rPath) const
-{
- File target(rPath);
- target.createDirectories();
-
- Path src(getPathImpl());
- src.makeFile();
- DirectoryIterator it(src);
- DirectoryIterator end;
- for (; it != end; ++it)
- {
- it->copyTo(rPath);
- }
-}
-
-
-void File::moveTo(const std::string& rPath)
-{
- copyTo(rPath);
- remove(true);
- setPathImpl(rPath);
-}
-
-
-void File::renameTo(const std::string& rPath)
-{
- renameToImpl(rPath);
- setPathImpl(rPath);
-}
-
-
-void File::linkTo(const std::string& path, LinkType type) const
-{
- linkToImpl(path, type);
-}
-
-
-void File::remove(bool recursive)
-{
- if (recursive && !isLink() && isDirectory())
- {
- std::vector<File> files;
- list(files);
- for (std::vector<File>::iterator it = files.begin(); it != files.end(); ++it)
- {
- it->remove(true);
- }
-
- // Note: On Windows, removing a directory may not succeed at first
- // try because deleting files is not a synchronous operation. Files
- // are merely marked as deleted, and actually removed at a later time.
- //
- // An alternate strategy would be moving files to a different directory
- // first (on the same drive, but outside the deleted tree), and marking
- // them as hidden, before deleting them, but this could lead to other issues.
- // So we simply retry after some time until we succeed, or give up.
-
- int retry = 8;
- long sleep = 10;
- while (retry > 0)
- {
- try
- {
- removeImpl();
- retry = 0;
- }
- catch (DirectoryNotEmptyException&)
- {
- if (--retry == 0) throw;
- Poco::Thread::sleep(sleep);
- sleep *= 2;
- }
- }
- }
- else
- {
- removeImpl();
- }
-}
-
-
-bool File::createFile()
-{
- return createFileImpl();
-}
-
-
-bool File::createDirectory()
-{
- return createDirectoryImpl();
-}
-
-
-void File::createDirectories()
-{
- if (!exists())
- {
- Path p(getPathImpl());
- p.makeDirectory();
- if (p.depth() > 1)
- {
- p.makeParent();
- File f(p);
- f.createDirectories();
- }
- try
- {
- createDirectoryImpl();
- }
- catch (FileExistsException&)
- {
- }
- }
-}
-
-
-void File::list(std::vector<std::string>& files) const
-{
- files.clear();
- DirectoryIterator it(*this);
- DirectoryIterator end;
- while (it != end)
- {
- files.push_back(it.name());
- ++it;
- }
-}
-
-
-File::FileSize File::totalSpace() const
-{
- return totalSpaceImpl();
-}
-
-
-File::FileSize File::usableSpace() const
-{
- return usableSpaceImpl();
-}
-
-
-File::FileSize File::freeSpace() const
-{
- return freeSpaceImpl();
-}
-
-
-void File::list(std::vector<File>& files) const
-{
- files.clear();
- DirectoryIterator it(*this);
- DirectoryIterator end;
- while (it != end)
- {
- files.push_back(*it);
- ++it;
- }
-}
-
-
-void File::handleLastError(const std::string& path)
-{
- handleLastErrorImpl(path);
-}
-
-
-} // namespace Poco
+//
+// File.cpp
+//
+// Library: Foundation
+// Package: Filesystem
+// Module: File
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/File.h"
+#include "Poco/Path.h"
+#include "Poco/DirectoryIterator.h"
+
+
+#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
+#if defined(_WIN32_WCE)
+#include "File_WINCE.cpp"
+#else
+#include "File_WIN32U.cpp"
+#endif
+#elif defined(POCO_OS_FAMILY_WINDOWS)
+#include "File_WIN32.cpp"
+#elif defined(POCO_VXWORKS)
+#include "File_VX.cpp"
+#elif defined(POCO_OS_FAMILY_UNIX)
+#include "File_UNIX.cpp"
+#endif
+#include "Poco/Thread.h"
+
+
+namespace Poco {
+
+
+File::File()
+{
+}
+
+
+File::File(const std::string& rPath): FileImpl(rPath)
+{
+}
+
+
+File::File(const char* pPath): FileImpl(std::string(pPath))
+{
+}
+
+
+File::File(const Path& rPath): FileImpl(rPath.toString())
+{
+}
+
+
+File::File(const File& file): FileImpl(file.getPathImpl())
+{
+}
+
+
+File::~File()
+{
+}
+
+
+File& File::operator = (const File& file)
+{
+ setPathImpl(file.getPathImpl());
+ return *this;
+}
+
+
+File& File::operator = (const std::string& rPath)
+{
+ setPathImpl(rPath);
+ return *this;
+}
+
+
+File& File::operator = (const char* pPath)
+{
+ poco_check_ptr (pPath);
+ setPathImpl(pPath);
+ return *this;
+}
+
+
+File& File::operator = (const Path& rPath)
+{
+ setPathImpl(rPath.toString());
+ return *this;
+}
+
+
+void File::swap(File& file)
+{
+ swapImpl(file);
+}
+
+
+bool File::exists() const
+{
+ return existsImpl();
+}
+
+
+bool File::canRead() const
+{
+ return canReadImpl();
+}
+
+
+bool File::canWrite() const
+{
+ return canWriteImpl();
+}
+
+
+bool File::canExecute() const
+{
+ return canExecuteImpl();
+}
+
+
+bool File::isFile() const
+{
+ return isFileImpl();
+}
+
+
+bool File::isDirectory() const
+{
+ return isDirectoryImpl();
+}
+
+
+bool File::isLink() const
+{
+ return isLinkImpl();
+}
+
+
+bool File::isDevice() const
+{
+ return isDeviceImpl();
+}
+
+
+bool File::isHidden() const
+{
+ return isHiddenImpl();
+}
+
+
+Timestamp File::created() const
+{
+ return createdImpl();
+}
+
+
+Timestamp File::getLastModified() const
+{
+ return getLastModifiedImpl();
+}
+
+
+File& File::setLastModified(const Timestamp& ts)
+{
+ setLastModifiedImpl(ts);
+ return *this;
+}
+
+
+File::FileSize File::getSize() const
+{
+ return getSizeImpl();
+}
+
+
+File& File::setSize(FileSizeImpl size)
+{
+ setSizeImpl(size);
+ return *this;
+}
+
+
+File& File::setWriteable(bool flag)
+{
+ setWriteableImpl(flag);
+ return *this;
+}
+
+
+File& File::setReadOnly(bool flag)
+{
+ setWriteableImpl(!flag);
+ return *this;
+}
+
+
+File& File::setExecutable(bool flag)
+{
+ setExecutableImpl(flag);
+ return *this;
+}
+
+
+void File::copyTo(const std::string& rPath) const
+{
+ Path src(getPathImpl());
+ Path dest(rPath);
+ File destFile(rPath);
+ if ((destFile.exists() && destFile.isDirectory()) || dest.isDirectory())
+ {
+ dest.makeDirectory();
+ dest.setFileName(src.getFileName());
+ }
+ if (isDirectory())
+ copyDirectory(dest.toString());
+ else
+ copyToImpl(dest.toString());
+}
+
+
+void File::copyDirectory(const std::string& rPath) const
+{
+ File target(rPath);
+ target.createDirectories();
+
+ Path src(getPathImpl());
+ src.makeFile();
+ DirectoryIterator it(src);
+ DirectoryIterator end;
+ for (; it != end; ++it)
+ {
+ it->copyTo(rPath);
+ }
+}
+
+
+void File::moveTo(const std::string& rPath)
+{
+ copyTo(rPath);
+ remove(true);
+ setPathImpl(rPath);
+}
+
+
+void File::renameTo(const std::string& rPath)
+{
+ renameToImpl(rPath);
+ setPathImpl(rPath);
+}
+
+
+void File::linkTo(const std::string& path, LinkType type) const
+{
+ linkToImpl(path, type);
+}
+
+
+void File::remove(bool recursive)
+{
+ if (recursive && !isLink() && isDirectory())
+ {
+ std::vector<File> files;
+ list(files);
+ for (std::vector<File>::iterator it = files.begin(); it != files.end(); ++it)
+ {
+ it->remove(true);
+ }
+
+ // Note: On Windows, removing a directory may not succeed at first
+ // try because deleting files is not a synchronous operation. Files
+ // are merely marked as deleted, and actually removed at a later time.
+ //
+ // An alternate strategy would be moving files to a different directory
+ // first (on the same drive, but outside the deleted tree), and marking
+ // them as hidden, before deleting them, but this could lead to other issues.
+ // So we simply retry after some time until we succeed, or give up.
+
+ int retry = 8;
+ long sleep = 10;
+ while (retry > 0)
+ {
+ try
+ {
+ removeImpl();
+ retry = 0;
+ }
+ catch (DirectoryNotEmptyException&)
+ {
+ if (--retry == 0) throw;
+ Poco::Thread::sleep(sleep);
+ sleep *= 2;
+ }
+ }
+ }
+ else
+ {
+ removeImpl();
+ }
+}
+
+
+bool File::createFile()
+{
+ return createFileImpl();
+}
+
+
+bool File::createDirectory()
+{
+ return createDirectoryImpl();
+}
+
+
+void File::createDirectories()
+{
+ if (!exists())
+ {
+ Path p(getPathImpl());
+ p.makeDirectory();
+ if (p.depth() > 1)
+ {
+ p.makeParent();
+ File f(p);
+ f.createDirectories();
+ }
+ try
+ {
+ createDirectoryImpl();
+ }
+ catch (FileExistsException&)
+ {
+ }
+ }
+}
+
+
+void File::list(std::vector<std::string>& files) const
+{
+ files.clear();
+ DirectoryIterator it(*this);
+ DirectoryIterator end;
+ while (it != end)
+ {
+ files.push_back(it.name());
+ ++it;
+ }
+}
+
+
+File::FileSize File::totalSpace() const
+{
+ return totalSpaceImpl();
+}
+
+
+File::FileSize File::usableSpace() const
+{
+ return usableSpaceImpl();
+}
+
+
+File::FileSize File::freeSpace() const
+{
+ return freeSpaceImpl();
+}
+
+
+void File::list(std::vector<File>& files) const
+{
+ files.clear();
+ DirectoryIterator it(*this);
+ DirectoryIterator end;
+ while (it != end)
+ {
+ files.push_back(*it);
+ ++it;
+ }
+}
+
+
+void File::handleLastError(const std::string& path)
+{
+ handleLastErrorImpl(path);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/FileChannel.cpp b/contrib/libs/poco/Foundation/src/FileChannel.cpp
index c2b2f6ee88..e6f62210e3 100644
--- a/contrib/libs/poco/Foundation/src/FileChannel.cpp
+++ b/contrib/libs/poco/Foundation/src/FileChannel.cpp
@@ -1,456 +1,456 @@
-//
-// FileChannel.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: FileChannel
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/FileChannel.h"
-#include "Poco/ArchiveStrategy.h"
-#include "Poco/RotateStrategy.h"
-#include "Poco/PurgeStrategy.h"
-#include "Poco/Message.h"
-#include "Poco/NumberParser.h"
-#include "Poco/DateTimeFormatter.h"
-#include "Poco/DateTime.h"
-#include "Poco/LocalDateTime.h"
-#include "Poco/String.h"
-#include "Poco/Exception.h"
-#include "Poco/Ascii.h"
-
-
-namespace Poco {
-
-
-const std::string FileChannel::PROP_PATH = "path";
-const std::string FileChannel::PROP_ROTATION = "rotation";
-const std::string FileChannel::PROP_ARCHIVE = "archive";
-const std::string FileChannel::PROP_TIMES = "times";
-const std::string FileChannel::PROP_COMPRESS = "compress";
-const std::string FileChannel::PROP_PURGEAGE = "purgeAge";
-const std::string FileChannel::PROP_PURGECOUNT = "purgeCount";
-const std::string FileChannel::PROP_FLUSH = "flush";
-const std::string FileChannel::PROP_ROTATEONOPEN = "rotateOnOpen";
-
-FileChannel::FileChannel():
- _times("utc"),
- _compress(false),
- _flush(true),
- _rotateOnOpen(false),
- _pFile(0),
- _pRotateStrategy(0),
- _pArchiveStrategy(new ArchiveByNumberStrategy),
- _pPurgeStrategy(0)
-{
-}
-
-
-FileChannel::FileChannel(const std::string& rPath):
- _path(rPath),
- _times("utc"),
- _compress(false),
- _flush(true),
- _rotateOnOpen(false),
- _pFile(0),
- _pRotateStrategy(0),
- _pArchiveStrategy(new ArchiveByNumberStrategy),
- _pPurgeStrategy(0)
-{
-}
-
-
-FileChannel::~FileChannel()
-{
- try
- {
- close();
- delete _pRotateStrategy;
- delete _pArchiveStrategy;
- delete _pPurgeStrategy;
- }
- catch (...)
- {
- poco_unexpected();
- }
-}
-
-
-void FileChannel::open()
-{
- FastMutex::ScopedLock lock(_mutex);
-
- unsafeOpen();
-}
-
-
-void FileChannel::close()
-{
- FastMutex::ScopedLock lock(_mutex);
-
- delete _pFile;
- _pFile = 0;
-}
-
-
-void FileChannel::log(const Message& msg)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- unsafeOpen();
-
- if (_pRotateStrategy && _pArchiveStrategy && _pRotateStrategy->mustRotate(_pFile))
- {
- try
- {
- _pFile = _pArchiveStrategy->archive(_pFile);
- purge();
- }
- catch (...)
- {
- _pFile = new LogFile(_path);
- }
- // we must call mustRotate() again to give the
- // RotateByIntervalStrategy a chance to write its timestamp
- // to the new file.
- _pRotateStrategy->mustRotate(_pFile);
- }
-
- try
- {
- _pFile->write(msg.getText(), _flush);
- }
+//
+// FileChannel.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: FileChannel
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/FileChannel.h"
+#include "Poco/ArchiveStrategy.h"
+#include "Poco/RotateStrategy.h"
+#include "Poco/PurgeStrategy.h"
+#include "Poco/Message.h"
+#include "Poco/NumberParser.h"
+#include "Poco/DateTimeFormatter.h"
+#include "Poco/DateTime.h"
+#include "Poco/LocalDateTime.h"
+#include "Poco/String.h"
+#include "Poco/Exception.h"
+#include "Poco/Ascii.h"
+
+
+namespace Poco {
+
+
+const std::string FileChannel::PROP_PATH = "path";
+const std::string FileChannel::PROP_ROTATION = "rotation";
+const std::string FileChannel::PROP_ARCHIVE = "archive";
+const std::string FileChannel::PROP_TIMES = "times";
+const std::string FileChannel::PROP_COMPRESS = "compress";
+const std::string FileChannel::PROP_PURGEAGE = "purgeAge";
+const std::string FileChannel::PROP_PURGECOUNT = "purgeCount";
+const std::string FileChannel::PROP_FLUSH = "flush";
+const std::string FileChannel::PROP_ROTATEONOPEN = "rotateOnOpen";
+
+FileChannel::FileChannel():
+ _times("utc"),
+ _compress(false),
+ _flush(true),
+ _rotateOnOpen(false),
+ _pFile(0),
+ _pRotateStrategy(0),
+ _pArchiveStrategy(new ArchiveByNumberStrategy),
+ _pPurgeStrategy(0)
+{
+}
+
+
+FileChannel::FileChannel(const std::string& rPath):
+ _path(rPath),
+ _times("utc"),
+ _compress(false),
+ _flush(true),
+ _rotateOnOpen(false),
+ _pFile(0),
+ _pRotateStrategy(0),
+ _pArchiveStrategy(new ArchiveByNumberStrategy),
+ _pPurgeStrategy(0)
+{
+}
+
+
+FileChannel::~FileChannel()
+{
+ try
+ {
+ close();
+ delete _pRotateStrategy;
+ delete _pArchiveStrategy;
+ delete _pPurgeStrategy;
+ }
+ catch (...)
+ {
+ poco_unexpected();
+ }
+}
+
+
+void FileChannel::open()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ unsafeOpen();
+}
+
+
+void FileChannel::close()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ delete _pFile;
+ _pFile = 0;
+}
+
+
+void FileChannel::log(const Message& msg)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ unsafeOpen();
+
+ if (_pRotateStrategy && _pArchiveStrategy && _pRotateStrategy->mustRotate(_pFile))
+ {
+ try
+ {
+ _pFile = _pArchiveStrategy->archive(_pFile);
+ purge();
+ }
+ catch (...)
+ {
+ _pFile = new LogFile(_path);
+ }
+ // we must call mustRotate() again to give the
+ // RotateByIntervalStrategy a chance to write its timestamp
+ // to the new file.
+ _pRotateStrategy->mustRotate(_pFile);
+ }
+
+ try
+ {
+ _pFile->write(msg.getText(), _flush);
+ }
catch (const WriteFileException &)
- {
- // In case of no space left on device,
- // we try to purge old files or truncate current file.
-
- // NOTE: error reason is not preserved in WriteFileException, we need to check errno manually.
- // NOTE: other reasons like quota exceeded are not handled.
- // NOTE: current log message will be lost.
-
- if (errno == ENOSPC)
- {
- PurgeOneFileStrategy().purge(_path);
- }
+ {
+ // In case of no space left on device,
+ // we try to purge old files or truncate current file.
+
+ // NOTE: error reason is not preserved in WriteFileException, we need to check errno manually.
+ // NOTE: other reasons like quota exceeded are not handled.
+ // NOTE: current log message will be lost.
+
+ if (errno == ENOSPC)
+ {
+ PurgeOneFileStrategy().purge(_path);
+ }
delete _pFile;
_pFile = 0;
_pFile = new LogFile(_path);
- }
-}
-
-
-void FileChannel::setProperty(const std::string& name, const std::string& value)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- if (name == PROP_TIMES)
- {
- _times = value;
-
- if (!_rotation.empty())
- setRotation(_rotation);
-
- if (!_archive.empty())
- setArchive(_archive);
- }
- else if (name == PROP_PATH)
- _path = value;
- else if (name == PROP_ROTATION)
- setRotation(value);
- else if (name == PROP_ARCHIVE)
- setArchive(value);
- else if (name == PROP_COMPRESS)
- setCompress(value);
- else if (name == PROP_PURGEAGE)
- setPurgeAge(value);
- else if (name == PROP_PURGECOUNT)
- setPurgeCount(value);
- else if (name == PROP_FLUSH)
- setFlush(value);
- else if (name == PROP_ROTATEONOPEN)
- setRotateOnOpen(value);
- else
- Channel::setProperty(name, value);
-}
-
-
-std::string FileChannel::getProperty(const std::string& name) const
-{
- if (name == PROP_TIMES)
- return _times;
- else if (name == PROP_PATH)
- return _path;
- else if (name == PROP_ROTATION)
- return _rotation;
- else if (name == PROP_ARCHIVE)
- return _archive;
- else if (name == PROP_COMPRESS)
- return std::string(_compress ? "true" : "false");
- else if (name == PROP_PURGEAGE)
- return _purgeAge;
- else if (name == PROP_PURGECOUNT)
- return _purgeCount;
- else if (name == PROP_FLUSH)
- return std::string(_flush ? "true" : "false");
- else if (name == PROP_ROTATEONOPEN)
- return std::string(_rotateOnOpen ? "true" : "false");
- else
- return Channel::getProperty(name);
-}
-
-
-Timestamp FileChannel::creationDate() const
-{
- if (_pFile)
- return _pFile->creationDate();
- else
- return 0;
-}
-
-
-UInt64 FileChannel::size() const
-{
- if (_pFile)
- return _pFile->size();
- else
- return 0;
-}
-
-
-const std::string& FileChannel::path() const
-{
- return _path;
-}
-
-
-void FileChannel::setRotation(const std::string& rotation)
-{
- std::string::const_iterator it = rotation.begin();
- std::string::const_iterator end = rotation.end();
- int n = 0;
- while (it != end && Ascii::isSpace(*it)) ++it;
- while (it != end && Ascii::isDigit(*it)) { n *= 10; n += *it++ - '0'; }
- 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")
- pStrategy = new RotateAtTimeStrategy<DateTime>(rotation);
- else if (_times == "local")
- pStrategy = new RotateAtTimeStrategy<LocalDateTime>(rotation);
- else
- throw PropertyNotSupportedException("times", _times);
- }
- else if (unit == "daily")
- pStrategy = new RotateByIntervalStrategy(Timespan(1*Timespan::DAYS));
- else if (unit == "weekly")
- pStrategy = new RotateByIntervalStrategy(Timespan(7*Timespan::DAYS));
- else if (unit == "monthly")
- pStrategy = new RotateByIntervalStrategy(Timespan(30*Timespan::DAYS));
- else if (unit == "seconds") // for testing only
- pStrategy = new RotateByIntervalStrategy(Timespan(n*Timespan::SECONDS));
- else if (unit == "minutes")
- pStrategy = new RotateByIntervalStrategy(Timespan(n*Timespan::MINUTES));
- else if (unit == "hours")
- pStrategy = new RotateByIntervalStrategy(Timespan(n*Timespan::HOURS));
- else if (unit == "days")
- pStrategy = new RotateByIntervalStrategy(Timespan(n*Timespan::DAYS));
- else if (unit == "weeks")
- pStrategy = new RotateByIntervalStrategy(Timespan(n*7*Timespan::DAYS));
- else if (unit == "months")
- pStrategy = new RotateByIntervalStrategy(Timespan(n*30*Timespan::DAYS));
- else if (unit == "K")
- pStrategy = new RotateBySizeStrategy(n*1024);
- else if (unit == "M")
- pStrategy = new RotateBySizeStrategy(n*1024*1024);
- else if (unit.empty())
- pStrategy = new RotateBySizeStrategy(n);
- else if (unit != "never")
- throw InvalidArgumentException("rotation", rotation);
- delete _pRotateStrategy;
- _pRotateStrategy = pStrategy;
- _rotation = rotation;
-}
-
-
-void FileChannel::setArchive(const std::string& archive)
-{
- 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);
- delete _pArchiveStrategy;
- pStrategy->compress(_compress);
- _pArchiveStrategy = pStrategy;
- _archive = archive;
-}
-
-
-void FileChannel::setCompress(const std::string& compress)
-{
- _compress = icompare(compress, "true") == 0;
- if (_pArchiveStrategy)
- _pArchiveStrategy->compress(_compress);
-}
-
-
-void FileChannel::setPurgeAge(const std::string& age)
-{
- if (setNoPurge(age)) return;
-
- std::string::const_iterator nextToDigit;
- int num = extractDigit(age, &nextToDigit);
- Timespan::TimeDiff factor = extractFactor(age, nextToDigit);
-
- setPurgeStrategy(new PurgeByAgeStrategy(Timespan(num * factor)));
- _purgeAge = age;
-}
-
-
-void FileChannel::setPurgeCount(const std::string& count)
-{
- if (setNoPurge(count)) return;
-
- setPurgeStrategy(new PurgeByCountStrategy(extractDigit(count)));
- _purgeCount = count;
-}
-
-
-void FileChannel::setFlush(const std::string& flush)
-{
- _flush = icompare(flush, "true") == 0;
-}
-
-
-void FileChannel::setRotateOnOpen(const std::string& rotateOnOpen)
-{
- _rotateOnOpen = icompare(rotateOnOpen, "true") == 0;
-}
-
-
-void FileChannel::purge()
-{
- if (_pPurgeStrategy)
- {
- try
- {
- _pPurgeStrategy->purge(_path);
- }
- catch (...)
- {
- }
- }
-}
-
-
-void FileChannel::unsafeOpen()
-{
- if (!_pFile)
- {
- _pFile = new LogFile(_path);
- if (_rotateOnOpen && _pFile->size() > 0)
- {
- try
- {
- _pFile = _pArchiveStrategy->archive(_pFile);
- purge();
- }
- catch (...)
- {
- _pFile = new LogFile(_path);
- }
- }
- }
-}
-
-
-bool FileChannel::setNoPurge(const std::string& value)
-{
- if (value.empty() || 0 == icompare(value, "none"))
- {
- delete _pPurgeStrategy;
- _pPurgeStrategy = 0;
- _purgeAge = "none";
- return true;
- }
- else return false;
-}
-
-
-int FileChannel::extractDigit(const std::string& value, std::string::const_iterator* nextToDigit) const
-{
- std::string::const_iterator it = value.begin();
- std::string::const_iterator end = value.end();
- int digit = 0;
-
- while (it != end && Ascii::isSpace(*it)) ++it;
- while (it != end && Ascii::isDigit(*it))
+ }
+}
+
+
+void FileChannel::setProperty(const std::string& name, const std::string& value)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (name == PROP_TIMES)
{
- digit *= 10;
- digit += *it++ - '0';
- }
-
- if (digit == 0)
- throw InvalidArgumentException("Zero is not valid purge age.");
-
- if (nextToDigit) *nextToDigit = it;
- return digit;
-}
-
-
-void FileChannel::setPurgeStrategy(PurgeStrategy* strategy)
-{
- delete _pPurgeStrategy;
- _pPurgeStrategy = strategy;
-}
-
-
-Timespan::TimeDiff FileChannel::extractFactor(const std::string& value, std::string::const_iterator start) const
-{
- while (start != value.end() && Ascii::isSpace(*start)) ++start;
-
- std::string unit;
- while (start != value.end() && Ascii::isAlpha(*start)) unit += *start++;
-
- if (unit == "seconds")
- return Timespan::SECONDS;
- if (unit == "minutes")
- return Timespan::MINUTES;
- else if (unit == "hours")
- return Timespan::HOURS;
- else if (unit == "days")
- return Timespan::DAYS;
- else if (unit == "weeks")
- return 7 * Timespan::DAYS;
- else if (unit == "months")
- return 30 * Timespan::DAYS;
- else throw InvalidArgumentException("purgeAge", value);
-
- return Timespan::TimeDiff();
-}
-
-
-
-} // namespace Poco
+ _times = value;
+
+ if (!_rotation.empty())
+ setRotation(_rotation);
+
+ if (!_archive.empty())
+ setArchive(_archive);
+ }
+ else if (name == PROP_PATH)
+ _path = value;
+ else if (name == PROP_ROTATION)
+ setRotation(value);
+ else if (name == PROP_ARCHIVE)
+ setArchive(value);
+ else if (name == PROP_COMPRESS)
+ setCompress(value);
+ else if (name == PROP_PURGEAGE)
+ setPurgeAge(value);
+ else if (name == PROP_PURGECOUNT)
+ setPurgeCount(value);
+ else if (name == PROP_FLUSH)
+ setFlush(value);
+ else if (name == PROP_ROTATEONOPEN)
+ setRotateOnOpen(value);
+ else
+ Channel::setProperty(name, value);
+}
+
+
+std::string FileChannel::getProperty(const std::string& name) const
+{
+ if (name == PROP_TIMES)
+ return _times;
+ else if (name == PROP_PATH)
+ return _path;
+ else if (name == PROP_ROTATION)
+ return _rotation;
+ else if (name == PROP_ARCHIVE)
+ return _archive;
+ else if (name == PROP_COMPRESS)
+ return std::string(_compress ? "true" : "false");
+ else if (name == PROP_PURGEAGE)
+ return _purgeAge;
+ else if (name == PROP_PURGECOUNT)
+ return _purgeCount;
+ else if (name == PROP_FLUSH)
+ return std::string(_flush ? "true" : "false");
+ else if (name == PROP_ROTATEONOPEN)
+ return std::string(_rotateOnOpen ? "true" : "false");
+ else
+ return Channel::getProperty(name);
+}
+
+
+Timestamp FileChannel::creationDate() const
+{
+ if (_pFile)
+ return _pFile->creationDate();
+ else
+ return 0;
+}
+
+
+UInt64 FileChannel::size() const
+{
+ if (_pFile)
+ return _pFile->size();
+ else
+ return 0;
+}
+
+
+const std::string& FileChannel::path() const
+{
+ return _path;
+}
+
+
+void FileChannel::setRotation(const std::string& rotation)
+{
+ std::string::const_iterator it = rotation.begin();
+ std::string::const_iterator end = rotation.end();
+ int n = 0;
+ while (it != end && Ascii::isSpace(*it)) ++it;
+ while (it != end && Ascii::isDigit(*it)) { n *= 10; n += *it++ - '0'; }
+ 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")
+ pStrategy = new RotateAtTimeStrategy<DateTime>(rotation);
+ else if (_times == "local")
+ pStrategy = new RotateAtTimeStrategy<LocalDateTime>(rotation);
+ else
+ throw PropertyNotSupportedException("times", _times);
+ }
+ else if (unit == "daily")
+ pStrategy = new RotateByIntervalStrategy(Timespan(1*Timespan::DAYS));
+ else if (unit == "weekly")
+ pStrategy = new RotateByIntervalStrategy(Timespan(7*Timespan::DAYS));
+ else if (unit == "monthly")
+ pStrategy = new RotateByIntervalStrategy(Timespan(30*Timespan::DAYS));
+ else if (unit == "seconds") // for testing only
+ pStrategy = new RotateByIntervalStrategy(Timespan(n*Timespan::SECONDS));
+ else if (unit == "minutes")
+ pStrategy = new RotateByIntervalStrategy(Timespan(n*Timespan::MINUTES));
+ else if (unit == "hours")
+ pStrategy = new RotateByIntervalStrategy(Timespan(n*Timespan::HOURS));
+ else if (unit == "days")
+ pStrategy = new RotateByIntervalStrategy(Timespan(n*Timespan::DAYS));
+ else if (unit == "weeks")
+ pStrategy = new RotateByIntervalStrategy(Timespan(n*7*Timespan::DAYS));
+ else if (unit == "months")
+ pStrategy = new RotateByIntervalStrategy(Timespan(n*30*Timespan::DAYS));
+ else if (unit == "K")
+ pStrategy = new RotateBySizeStrategy(n*1024);
+ else if (unit == "M")
+ pStrategy = new RotateBySizeStrategy(n*1024*1024);
+ else if (unit.empty())
+ pStrategy = new RotateBySizeStrategy(n);
+ else if (unit != "never")
+ throw InvalidArgumentException("rotation", rotation);
+ delete _pRotateStrategy;
+ _pRotateStrategy = pStrategy;
+ _rotation = rotation;
+}
+
+
+void FileChannel::setArchive(const std::string& archive)
+{
+ 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);
+ delete _pArchiveStrategy;
+ pStrategy->compress(_compress);
+ _pArchiveStrategy = pStrategy;
+ _archive = archive;
+}
+
+
+void FileChannel::setCompress(const std::string& compress)
+{
+ _compress = icompare(compress, "true") == 0;
+ if (_pArchiveStrategy)
+ _pArchiveStrategy->compress(_compress);
+}
+
+
+void FileChannel::setPurgeAge(const std::string& age)
+{
+ if (setNoPurge(age)) return;
+
+ std::string::const_iterator nextToDigit;
+ int num = extractDigit(age, &nextToDigit);
+ Timespan::TimeDiff factor = extractFactor(age, nextToDigit);
+
+ setPurgeStrategy(new PurgeByAgeStrategy(Timespan(num * factor)));
+ _purgeAge = age;
+}
+
+
+void FileChannel::setPurgeCount(const std::string& count)
+{
+ if (setNoPurge(count)) return;
+
+ setPurgeStrategy(new PurgeByCountStrategy(extractDigit(count)));
+ _purgeCount = count;
+}
+
+
+void FileChannel::setFlush(const std::string& flush)
+{
+ _flush = icompare(flush, "true") == 0;
+}
+
+
+void FileChannel::setRotateOnOpen(const std::string& rotateOnOpen)
+{
+ _rotateOnOpen = icompare(rotateOnOpen, "true") == 0;
+}
+
+
+void FileChannel::purge()
+{
+ if (_pPurgeStrategy)
+ {
+ try
+ {
+ _pPurgeStrategy->purge(_path);
+ }
+ catch (...)
+ {
+ }
+ }
+}
+
+
+void FileChannel::unsafeOpen()
+{
+ if (!_pFile)
+ {
+ _pFile = new LogFile(_path);
+ if (_rotateOnOpen && _pFile->size() > 0)
+ {
+ try
+ {
+ _pFile = _pArchiveStrategy->archive(_pFile);
+ purge();
+ }
+ catch (...)
+ {
+ _pFile = new LogFile(_path);
+ }
+ }
+ }
+}
+
+
+bool FileChannel::setNoPurge(const std::string& value)
+{
+ if (value.empty() || 0 == icompare(value, "none"))
+ {
+ delete _pPurgeStrategy;
+ _pPurgeStrategy = 0;
+ _purgeAge = "none";
+ return true;
+ }
+ else return false;
+}
+
+
+int FileChannel::extractDigit(const std::string& value, std::string::const_iterator* nextToDigit) const
+{
+ std::string::const_iterator it = value.begin();
+ std::string::const_iterator end = value.end();
+ int digit = 0;
+
+ while (it != end && Ascii::isSpace(*it)) ++it;
+ while (it != end && Ascii::isDigit(*it))
+ {
+ digit *= 10;
+ digit += *it++ - '0';
+ }
+
+ if (digit == 0)
+ throw InvalidArgumentException("Zero is not valid purge age.");
+
+ if (nextToDigit) *nextToDigit = it;
+ return digit;
+}
+
+
+void FileChannel::setPurgeStrategy(PurgeStrategy* strategy)
+{
+ delete _pPurgeStrategy;
+ _pPurgeStrategy = strategy;
+}
+
+
+Timespan::TimeDiff FileChannel::extractFactor(const std::string& value, std::string::const_iterator start) const
+{
+ while (start != value.end() && Ascii::isSpace(*start)) ++start;
+
+ std::string unit;
+ while (start != value.end() && Ascii::isAlpha(*start)) unit += *start++;
+
+ if (unit == "seconds")
+ return Timespan::SECONDS;
+ if (unit == "minutes")
+ return Timespan::MINUTES;
+ else if (unit == "hours")
+ return Timespan::HOURS;
+ else if (unit == "days")
+ return Timespan::DAYS;
+ else if (unit == "weeks")
+ return 7 * Timespan::DAYS;
+ else if (unit == "months")
+ return 30 * Timespan::DAYS;
+ else throw InvalidArgumentException("purgeAge", value);
+
+ return Timespan::TimeDiff();
+}
+
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/FileStream.cpp b/contrib/libs/poco/Foundation/src/FileStream.cpp
index 4f94a24908..bfa0d2836d 100644
--- a/contrib/libs/poco/Foundation/src/FileStream.cpp
+++ b/contrib/libs/poco/Foundation/src/FileStream.cpp
@@ -1,121 +1,121 @@
-//
-// FileStream.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: FileStream
-//
-// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/FileStream.h"
-#include "Poco/Exception.h"
-#if defined(POCO_OS_FAMILY_WINDOWS)
-#include "FileStream_WIN32.cpp"
-#else
-#include "FileStream_POSIX.cpp"
-#endif
-
-
-namespace Poco {
-
-
-FileIOS::FileIOS(std::ios::openmode defaultMode):
- _defaultMode(defaultMode)
-{
- poco_ios_init(&_buf);
-}
-
-
-FileIOS::~FileIOS()
-{
-}
-
-
-void FileIOS::open(const std::string& path, std::ios::openmode mode)
-{
- clear();
- _buf.open(path, mode | _defaultMode);
-}
-
-
-void FileIOS::close()
-{
- if (!_buf.close())
- {
- setstate(ios_base::badbit);
- }
-}
-
-
-FileStreamBuf* FileIOS::rdbuf()
-{
- return &_buf;
-}
-
-
-FileInputStream::FileInputStream():
- FileIOS(std::ios::in),
- std::istream(&_buf)
-{
-}
-
-
-FileInputStream::FileInputStream(const std::string& path, std::ios::openmode mode):
- FileIOS(std::ios::in),
- std::istream(&_buf)
-{
- open(path, mode);
-}
-
-
-FileInputStream::~FileInputStream()
-{
-}
-
-
-FileOutputStream::FileOutputStream():
- FileIOS(std::ios::out),
- std::ostream(&_buf)
-{
-}
-
-
-FileOutputStream::FileOutputStream(const std::string& path, std::ios::openmode mode):
- FileIOS(std::ios::out),
- std::ostream(&_buf)
-{
- open(path, mode);
-}
-
-
-FileOutputStream::~FileOutputStream()
-{
-}
-
-
-FileStream::FileStream():
- FileIOS(std::ios::in | std::ios::out),
- std::iostream(&_buf)
-{
-}
-
-
-FileStream::FileStream(const std::string& path, std::ios::openmode mode):
- FileIOS(std::ios::in | std::ios::out),
- std::iostream(&_buf)
-{
- open(path, mode);
-}
-
-
-FileStream::~FileStream()
-{
-}
-
-
-} // namespace Poco
+//
+// FileStream.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: FileStream
+//
+// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/FileStream.h"
+#include "Poco/Exception.h"
+#if defined(POCO_OS_FAMILY_WINDOWS)
+#include "FileStream_WIN32.cpp"
+#else
+#include "FileStream_POSIX.cpp"
+#endif
+
+
+namespace Poco {
+
+
+FileIOS::FileIOS(std::ios::openmode defaultMode):
+ _defaultMode(defaultMode)
+{
+ poco_ios_init(&_buf);
+}
+
+
+FileIOS::~FileIOS()
+{
+}
+
+
+void FileIOS::open(const std::string& path, std::ios::openmode mode)
+{
+ clear();
+ _buf.open(path, mode | _defaultMode);
+}
+
+
+void FileIOS::close()
+{
+ if (!_buf.close())
+ {
+ setstate(ios_base::badbit);
+ }
+}
+
+
+FileStreamBuf* FileIOS::rdbuf()
+{
+ return &_buf;
+}
+
+
+FileInputStream::FileInputStream():
+ FileIOS(std::ios::in),
+ std::istream(&_buf)
+{
+}
+
+
+FileInputStream::FileInputStream(const std::string& path, std::ios::openmode mode):
+ FileIOS(std::ios::in),
+ std::istream(&_buf)
+{
+ open(path, mode);
+}
+
+
+FileInputStream::~FileInputStream()
+{
+}
+
+
+FileOutputStream::FileOutputStream():
+ FileIOS(std::ios::out),
+ std::ostream(&_buf)
+{
+}
+
+
+FileOutputStream::FileOutputStream(const std::string& path, std::ios::openmode mode):
+ FileIOS(std::ios::out),
+ std::ostream(&_buf)
+{
+ open(path, mode);
+}
+
+
+FileOutputStream::~FileOutputStream()
+{
+}
+
+
+FileStream::FileStream():
+ FileIOS(std::ios::in | std::ios::out),
+ std::iostream(&_buf)
+{
+}
+
+
+FileStream::FileStream(const std::string& path, std::ios::openmode mode):
+ FileIOS(std::ios::in | std::ios::out),
+ std::iostream(&_buf)
+{
+ open(path, mode);
+}
+
+
+FileStream::~FileStream()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/FileStreamFactory.cpp b/contrib/libs/poco/Foundation/src/FileStreamFactory.cpp
index 472559c95a..4e344b5e6f 100644
--- a/contrib/libs/poco/Foundation/src/FileStreamFactory.cpp
+++ b/contrib/libs/poco/Foundation/src/FileStreamFactory.cpp
@@ -1,64 +1,64 @@
-//
-// FileStreamFactory.cpp
-//
-// Library: Foundation
-// Package: URI
-// Module: FileStreamFactory
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/FileStreamFactory.h"
-#include "Poco/URI.h"
-#include "Poco/Path.h"
-#include "Poco/File.h"
-#include "Poco/Exception.h"
-#include "Poco/FileStream.h"
-
-
-namespace Poco {
-
-
-FileStreamFactory::FileStreamFactory()
-{
-}
-
-
-FileStreamFactory::~FileStreamFactory()
-{
-}
-
-
-std::istream* FileStreamFactory::open(const URI& uri)
-{
- poco_assert (uri.isRelative() || uri.getScheme() == "file");
-
- std::string uriPath = uri.getPath();
- if (uriPath.substr(0, 2) == "./")
- uriPath.erase(0, 2);
- Path p(uriPath, Path::PATH_UNIX);
- p.setNode(uri.getHost());
- return open(p);
-}
-
-
-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;
-}
-
-
-} // namespace Poco
+//
+// FileStreamFactory.cpp
+//
+// Library: Foundation
+// Package: URI
+// Module: FileStreamFactory
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/FileStreamFactory.h"
+#include "Poco/URI.h"
+#include "Poco/Path.h"
+#include "Poco/File.h"
+#include "Poco/Exception.h"
+#include "Poco/FileStream.h"
+
+
+namespace Poco {
+
+
+FileStreamFactory::FileStreamFactory()
+{
+}
+
+
+FileStreamFactory::~FileStreamFactory()
+{
+}
+
+
+std::istream* FileStreamFactory::open(const URI& uri)
+{
+ poco_assert (uri.isRelative() || uri.getScheme() == "file");
+
+ std::string uriPath = uri.getPath();
+ if (uriPath.substr(0, 2) == "./")
+ uriPath.erase(0, 2);
+ Path p(uriPath, Path::PATH_UNIX);
+ p.setNode(uri.getHost());
+ return open(p);
+}
+
+
+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;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/FileStream_POSIX.cpp b/contrib/libs/poco/Foundation/src/FileStream_POSIX.cpp
index 848d7c367e..f43a9185d1 100644
--- a/contrib/libs/poco/Foundation/src/FileStream_POSIX.cpp
+++ b/contrib/libs/poco/Foundation/src/FileStream_POSIX.cpp
@@ -1,170 +1,170 @@
-//
-// FileStream_POSIX.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: FileStream
-//
-// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/FileStream.h"
-#include "Poco/File.h"
-#include "Poco/Exception.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-
-namespace Poco {
-
-
-FileStreamBuf::FileStreamBuf():
- BufferedBidirectionalStreamBuf(BUFFER_SIZE, std::ios::in | std::ios::out),
- _fd(-1),
- _pos(0)
-{
-}
-
-
-FileStreamBuf::~FileStreamBuf()
-{
- close();
-}
-
-
-void FileStreamBuf::open(const std::string& path, std::ios::openmode mode)
-{
- poco_assert (_fd == -1);
-
- _pos = 0;
- _path = path;
- setMode(mode);
- resetBuffers();
-
- int flags(0);
- if (mode & std::ios::trunc)
- flags |= O_TRUNC;
- if (mode & std::ios::app)
- flags |= O_APPEND;
- if (mode & std::ios::out)
- flags |= O_CREAT;
- if ((mode & std::ios::in) && (mode & std::ios::out))
- flags |= O_RDWR;
- else if (mode & std::ios::in)
- 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);
-}
-
-
-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);
- _pos += n;
- return n;
-}
-
-
-int FileStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
-{
- if (_fd == -1) return -1;
-
-#if defined(POCO_VXWORKS)
- int n = write(_fd, const_cast<char*>(buffer), length);
-#else
- int n = write(_fd, buffer, length);
-#endif
- if (n == -1)
- File::handleLastError(_path);
- _pos += n;
- return n;
-}
-
-
-bool FileStreamBuf::close()
-{
- bool success = true;
- if (_fd != -1)
- {
- try
- {
- sync();
- }
- catch (...)
- {
- success = false;
- }
- ::close(_fd);
- _fd = -1;
- }
- return success;
-}
-
-
-std::streampos FileStreamBuf::seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode)
-{
- if (_fd == -1 || !(getMode() & mode))
- return -1;
-
- if (getMode() & std::ios::out)
- sync();
-
- std::streamoff adj;
- if (mode & std::ios::in)
- adj = static_cast<std::streamoff>(egptr() - gptr());
- else
- adj = 0;
-
- resetBuffers();
-
- int whence = SEEK_SET;
- if (dir == std::ios::cur)
- {
- whence = SEEK_CUR;
- off -= adj;
- }
- else if (dir == std::ios::end)
- {
- whence = SEEK_END;
- }
- _pos = lseek(_fd, off, whence);
- return _pos;
-}
-
-
-std::streampos FileStreamBuf::seekpos(std::streampos pos, std::ios::openmode mode)
-{
- if (_fd == -1 || !(getMode() & mode))
- return -1;
-
- if (getMode() & std::ios::out)
- sync();
-
- resetBuffers();
-
- _pos = lseek(_fd, pos, SEEK_SET);
- return _pos;
-}
-
-
-} // namespace Poco
+//
+// FileStream_POSIX.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: FileStream
+//
+// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/FileStream.h"
+#include "Poco/File.h"
+#include "Poco/Exception.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+
+namespace Poco {
+
+
+FileStreamBuf::FileStreamBuf():
+ BufferedBidirectionalStreamBuf(BUFFER_SIZE, std::ios::in | std::ios::out),
+ _fd(-1),
+ _pos(0)
+{
+}
+
+
+FileStreamBuf::~FileStreamBuf()
+{
+ close();
+}
+
+
+void FileStreamBuf::open(const std::string& path, std::ios::openmode mode)
+{
+ poco_assert (_fd == -1);
+
+ _pos = 0;
+ _path = path;
+ setMode(mode);
+ resetBuffers();
+
+ int flags(0);
+ if (mode & std::ios::trunc)
+ flags |= O_TRUNC;
+ if (mode & std::ios::app)
+ flags |= O_APPEND;
+ if (mode & std::ios::out)
+ flags |= O_CREAT;
+ if ((mode & std::ios::in) && (mode & std::ios::out))
+ flags |= O_RDWR;
+ else if (mode & std::ios::in)
+ 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);
+}
+
+
+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);
+ _pos += n;
+ return n;
+}
+
+
+int FileStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
+{
+ if (_fd == -1) return -1;
+
+#if defined(POCO_VXWORKS)
+ int n = write(_fd, const_cast<char*>(buffer), length);
+#else
+ int n = write(_fd, buffer, length);
+#endif
+ if (n == -1)
+ File::handleLastError(_path);
+ _pos += n;
+ return n;
+}
+
+
+bool FileStreamBuf::close()
+{
+ bool success = true;
+ if (_fd != -1)
+ {
+ try
+ {
+ sync();
+ }
+ catch (...)
+ {
+ success = false;
+ }
+ ::close(_fd);
+ _fd = -1;
+ }
+ return success;
+}
+
+
+std::streampos FileStreamBuf::seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode)
+{
+ if (_fd == -1 || !(getMode() & mode))
+ return -1;
+
+ if (getMode() & std::ios::out)
+ sync();
+
+ std::streamoff adj;
+ if (mode & std::ios::in)
+ adj = static_cast<std::streamoff>(egptr() - gptr());
+ else
+ adj = 0;
+
+ resetBuffers();
+
+ int whence = SEEK_SET;
+ if (dir == std::ios::cur)
+ {
+ whence = SEEK_CUR;
+ off -= adj;
+ }
+ else if (dir == std::ios::end)
+ {
+ whence = SEEK_END;
+ }
+ _pos = lseek(_fd, off, whence);
+ return _pos;
+}
+
+
+std::streampos FileStreamBuf::seekpos(std::streampos pos, std::ios::openmode mode)
+{
+ if (_fd == -1 || !(getMode() & mode))
+ return -1;
+
+ if (getMode() & std::ios::out)
+ sync();
+
+ resetBuffers();
+
+ _pos = lseek(_fd, pos, SEEK_SET);
+ return _pos;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/FileStream_WIN32.cpp b/contrib/libs/poco/Foundation/src/FileStream_WIN32.cpp
index 28f53c9d40..051038a880 100644
--- a/contrib/libs/poco/Foundation/src/FileStream_WIN32.cpp
+++ b/contrib/libs/poco/Foundation/src/FileStream_WIN32.cpp
@@ -1,208 +1,208 @@
-//
-// FileStream.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: FileStream
-//
-// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/FileStream.h"
-#include "Poco/File.h"
-#include "Poco/Exception.h"
-#if defined (POCO_WIN32_UTF8)
-#include "Poco/UnicodeConverter.h"
-#endif
-
-
-namespace Poco {
-
-
-FileStreamBuf::FileStreamBuf():
- BufferedBidirectionalStreamBuf(BUFFER_SIZE, std::ios::in | std::ios::out),
- _handle(INVALID_HANDLE_VALUE),
- _pos(0)
-{
-}
-
-
-FileStreamBuf::~FileStreamBuf()
-{
- close();
-}
-
-
-void FileStreamBuf::open(const std::string& path, std::ios::openmode mode)
-{
- poco_assert (_handle == INVALID_HANDLE_VALUE);
-
- _path = path;
- _pos = 0;
- setMode(mode);
- resetBuffers();
-
- DWORD access = 0;
- if (mode & std::ios::in)
- access |= GENERIC_READ;
- if (mode & std::ios::out)
- access |= GENERIC_WRITE;
-
- 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;
- else if (mode & std::ios::out)
- creationDisp = OPEN_ALWAYS;
-
- DWORD flags = FILE_ATTRIBUTE_NORMAL;
-
-#if defined (POCO_WIN32_UTF8)
- std::wstring utf16Path;
- FileImpl::convertPath(path, utf16Path);
- _handle = CreateFileW(utf16Path.c_str(), access, shareMode, NULL, creationDisp, flags, NULL);
-#else
- _handle = CreateFileA(path.c_str(), access, shareMode, NULL, creationDisp, flags, NULL);
-#endif
-
- if (_handle == INVALID_HANDLE_VALUE)
- File::handleLastError(_path);
-
- if ((mode & std::ios::ate) || (mode & std::ios::app))
- seekoff(0, std::ios::end, mode);
-}
-
-
-int FileStreamBuf::readFromDevice(char* buffer, std::streamsize length)
-{
- if (INVALID_HANDLE_VALUE == _handle || !(getMode() & std::ios::in))
- return -1;
-
- if (getMode() & std::ios::out)
- sync();
-
- DWORD bytesRead(0);
- BOOL rc = ReadFile(_handle, buffer, static_cast<DWORD>(length), &bytesRead, NULL);
- if (rc == 0)
- File::handleLastError(_path);
-
- _pos += bytesRead;
-
- return static_cast<int>(bytesRead);
-}
-
-
-int FileStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
-{
- if (INVALID_HANDLE_VALUE == _handle || !(getMode() & std::ios::out))
- return -1;
-
- if (getMode() & std::ios::app)
- {
- LARGE_INTEGER li;
- li.QuadPart = 0;
- li.LowPart = SetFilePointer(_handle, li.LowPart, &li.HighPart, FILE_END);
- if (li.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR)
- File::handleLastError(_path);
- _pos = li.QuadPart;
- }
-
- DWORD bytesWritten(0);
- BOOL rc = WriteFile(_handle, buffer, static_cast<DWORD>(length), &bytesWritten, NULL);
- if (rc == 0)
- File::handleLastError(_path);
-
- _pos += bytesWritten;
-
- return static_cast<int>(bytesWritten);
-}
-
-
-bool FileStreamBuf::close()
-{
- bool success = true;
- if (_handle != INVALID_HANDLE_VALUE)
- {
- try
- {
- if (getMode() & std::ios::out)
- sync();
- }
- catch (...)
- {
- success = false;
- }
- CloseHandle(_handle);
- _handle = INVALID_HANDLE_VALUE;
- }
- return success;
-}
-
-
-std::streampos FileStreamBuf::seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode)
-{
- if (INVALID_HANDLE_VALUE == _handle || !(getMode() & mode))
- return -1;
-
- if (getMode() & std::ios::out)
- sync();
-
- std::streamoff adj;
- if (mode & std::ios::in)
- adj = static_cast<std::streamoff>(egptr() - gptr());
- else
- adj = 0;
-
- resetBuffers();
-
- DWORD offset = FILE_BEGIN;
- if (dir == std::ios::cur)
- {
- offset = FILE_CURRENT;
- off -= adj;
- }
- else if (dir == std::ios::end)
- {
- offset = FILE_END;
- }
-
- LARGE_INTEGER li;
- li.QuadPart = off;
- li.LowPart = SetFilePointer(_handle, li.LowPart, &li.HighPart, offset);
-
- if (li.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR)
- File::handleLastError(_path);
- _pos = li.QuadPart;
- return std::streampos(static_cast<std::streamoff>(_pos));
-}
-
-
-std::streampos FileStreamBuf::seekpos(std::streampos pos, std::ios::openmode mode)
-{
- if (INVALID_HANDLE_VALUE == _handle || !(getMode() & mode))
- return -1;
-
- if (getMode() & std::ios::out)
- sync();
-
- resetBuffers();
-
- LARGE_INTEGER li;
- li.QuadPart = pos;
- li.LowPart = SetFilePointer(_handle, li.LowPart, &li.HighPart, FILE_BEGIN);
-
- if (li.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR)
- File::handleLastError(_path);
- _pos = li.QuadPart;
- return std::streampos(static_cast<std::streamoff>(_pos));
-}
-
-
-} // namespace Poco
+//
+// FileStream.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: FileStream
+//
+// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/FileStream.h"
+#include "Poco/File.h"
+#include "Poco/Exception.h"
+#if defined (POCO_WIN32_UTF8)
+#include "Poco/UnicodeConverter.h"
+#endif
+
+
+namespace Poco {
+
+
+FileStreamBuf::FileStreamBuf():
+ BufferedBidirectionalStreamBuf(BUFFER_SIZE, std::ios::in | std::ios::out),
+ _handle(INVALID_HANDLE_VALUE),
+ _pos(0)
+{
+}
+
+
+FileStreamBuf::~FileStreamBuf()
+{
+ close();
+}
+
+
+void FileStreamBuf::open(const std::string& path, std::ios::openmode mode)
+{
+ poco_assert (_handle == INVALID_HANDLE_VALUE);
+
+ _path = path;
+ _pos = 0;
+ setMode(mode);
+ resetBuffers();
+
+ DWORD access = 0;
+ if (mode & std::ios::in)
+ access |= GENERIC_READ;
+ if (mode & std::ios::out)
+ access |= GENERIC_WRITE;
+
+ 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;
+ else if (mode & std::ios::out)
+ creationDisp = OPEN_ALWAYS;
+
+ DWORD flags = FILE_ATTRIBUTE_NORMAL;
+
+#if defined (POCO_WIN32_UTF8)
+ std::wstring utf16Path;
+ FileImpl::convertPath(path, utf16Path);
+ _handle = CreateFileW(utf16Path.c_str(), access, shareMode, NULL, creationDisp, flags, NULL);
+#else
+ _handle = CreateFileA(path.c_str(), access, shareMode, NULL, creationDisp, flags, NULL);
+#endif
+
+ if (_handle == INVALID_HANDLE_VALUE)
+ File::handleLastError(_path);
+
+ if ((mode & std::ios::ate) || (mode & std::ios::app))
+ seekoff(0, std::ios::end, mode);
+}
+
+
+int FileStreamBuf::readFromDevice(char* buffer, std::streamsize length)
+{
+ if (INVALID_HANDLE_VALUE == _handle || !(getMode() & std::ios::in))
+ return -1;
+
+ if (getMode() & std::ios::out)
+ sync();
+
+ DWORD bytesRead(0);
+ BOOL rc = ReadFile(_handle, buffer, static_cast<DWORD>(length), &bytesRead, NULL);
+ if (rc == 0)
+ File::handleLastError(_path);
+
+ _pos += bytesRead;
+
+ return static_cast<int>(bytesRead);
+}
+
+
+int FileStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
+{
+ if (INVALID_HANDLE_VALUE == _handle || !(getMode() & std::ios::out))
+ return -1;
+
+ if (getMode() & std::ios::app)
+ {
+ LARGE_INTEGER li;
+ li.QuadPart = 0;
+ li.LowPart = SetFilePointer(_handle, li.LowPart, &li.HighPart, FILE_END);
+ if (li.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR)
+ File::handleLastError(_path);
+ _pos = li.QuadPart;
+ }
+
+ DWORD bytesWritten(0);
+ BOOL rc = WriteFile(_handle, buffer, static_cast<DWORD>(length), &bytesWritten, NULL);
+ if (rc == 0)
+ File::handleLastError(_path);
+
+ _pos += bytesWritten;
+
+ return static_cast<int>(bytesWritten);
+}
+
+
+bool FileStreamBuf::close()
+{
+ bool success = true;
+ if (_handle != INVALID_HANDLE_VALUE)
+ {
+ try
+ {
+ if (getMode() & std::ios::out)
+ sync();
+ }
+ catch (...)
+ {
+ success = false;
+ }
+ CloseHandle(_handle);
+ _handle = INVALID_HANDLE_VALUE;
+ }
+ return success;
+}
+
+
+std::streampos FileStreamBuf::seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode)
+{
+ if (INVALID_HANDLE_VALUE == _handle || !(getMode() & mode))
+ return -1;
+
+ if (getMode() & std::ios::out)
+ sync();
+
+ std::streamoff adj;
+ if (mode & std::ios::in)
+ adj = static_cast<std::streamoff>(egptr() - gptr());
+ else
+ adj = 0;
+
+ resetBuffers();
+
+ DWORD offset = FILE_BEGIN;
+ if (dir == std::ios::cur)
+ {
+ offset = FILE_CURRENT;
+ off -= adj;
+ }
+ else if (dir == std::ios::end)
+ {
+ offset = FILE_END;
+ }
+
+ LARGE_INTEGER li;
+ li.QuadPart = off;
+ li.LowPart = SetFilePointer(_handle, li.LowPart, &li.HighPart, offset);
+
+ if (li.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR)
+ File::handleLastError(_path);
+ _pos = li.QuadPart;
+ return std::streampos(static_cast<std::streamoff>(_pos));
+}
+
+
+std::streampos FileStreamBuf::seekpos(std::streampos pos, std::ios::openmode mode)
+{
+ if (INVALID_HANDLE_VALUE == _handle || !(getMode() & mode))
+ return -1;
+
+ if (getMode() & std::ios::out)
+ sync();
+
+ resetBuffers();
+
+ LARGE_INTEGER li;
+ li.QuadPart = pos;
+ li.LowPart = SetFilePointer(_handle, li.LowPart, &li.HighPart, FILE_BEGIN);
+
+ if (li.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR)
+ File::handleLastError(_path);
+ _pos = li.QuadPart;
+ return std::streampos(static_cast<std::streamoff>(_pos));
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/File_UNIX.cpp b/contrib/libs/poco/Foundation/src/File_UNIX.cpp
index 6cebef2a51..df9a160068 100644
--- a/contrib/libs/poco/Foundation/src/File_UNIX.cpp
+++ b/contrib/libs/poco/Foundation/src/File_UNIX.cpp
@@ -1,527 +1,527 @@
-//
-// File_UNIX.cpp
-//
-// Library: Foundation
-// Package: Filesystem
-// Module: File
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/File_UNIX.h"
-#include "Poco/Buffer.h"
-#include "Poco/Exception.h"
-#include "Poco/Error.h"
-#include <algorithm>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#if defined(POCO_OS_FAMILY_BSD)
-#include <sys/param.h>
-#include <sys/mount.h>
-#elif (POCO_OS == POCO_OS_SOLARIS)
-#include <sys/statvfs.h>
-#else
-#include <sys/statfs.h>
-#endif
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <utime.h>
-#include <cstring>
-
-#if (POCO_OS == POCO_OS_SOLARIS)
-#define STATFSFN statvfs
-#define STATFSSTRUCT statvfs
-#else
-#define STATFSFN statfs
-#define STATFSSTRUCT statfs
-#endif
-
-
-namespace Poco {
-
-
-FileImpl::FileImpl()
-{
-}
-
-
-FileImpl::FileImpl(const std::string& path): _path(path)
-{
- std::string::size_type n = _path.size();
- if (n > 1 && _path[n - 1] == '/')
- _path.resize(n - 1);
-}
-
-
-FileImpl::~FileImpl()
-{
-}
-
-
-void FileImpl::swapImpl(FileImpl& file)
-{
- std::swap(_path, file._path);
-}
-
-
-void FileImpl::setPathImpl(const std::string& path)
-{
- _path = path;
- std::string::size_type n = _path.size();
- if (n > 1 && _path[n - 1] == '/')
- _path.resize(n - 1);
-}
-
-
-bool FileImpl::existsImpl() const
-{
- poco_assert (!_path.empty());
-
- struct stat st;
- return stat(_path.c_str(), &st) == 0;
-}
-
-
-bool FileImpl::canReadImpl() const
-{
- poco_assert (!_path.empty());
-
- struct stat st;
- if (stat(_path.c_str(), &st) == 0)
- {
- if (st.st_uid == geteuid())
- return (st.st_mode & S_IRUSR) != 0;
- else if (st.st_gid == getegid())
- return (st.st_mode & S_IRGRP) != 0;
- else
- return (st.st_mode & S_IROTH) != 0 || geteuid() == 0;
- }
- else handleLastErrorImpl(_path);
- return false;
-}
-
-
-bool FileImpl::canWriteImpl() const
-{
- poco_assert (!_path.empty());
-
- struct stat st;
- if (stat(_path.c_str(), &st) == 0)
- {
- if (st.st_uid == geteuid())
- return (st.st_mode & S_IWUSR) != 0;
- else if (st.st_gid == getegid())
- return (st.st_mode & S_IWGRP) != 0;
- else
- return (st.st_mode & S_IWOTH) != 0 || geteuid() == 0;
- }
- else handleLastErrorImpl(_path);
- return false;
-}
-
-
-bool FileImpl::canExecuteImpl() const
-{
- poco_assert (!_path.empty());
-
- struct stat st;
- if (stat(_path.c_str(), &st) == 0)
- {
- if (st.st_uid == geteuid() || geteuid() == 0)
- return (st.st_mode & S_IXUSR) != 0;
- else if (st.st_gid == getegid())
- return (st.st_mode & S_IXGRP) != 0;
- else
- return (st.st_mode & S_IXOTH) != 0;
- }
- else handleLastErrorImpl(_path);
- return false;
-}
-
-
-bool FileImpl::isFileImpl() const
-{
- poco_assert (!_path.empty());
-
- struct stat st;
- if (stat(_path.c_str(), &st) == 0)
- return S_ISREG(st.st_mode);
- else
- handleLastErrorImpl(_path);
- return false;
-}
-
-
-bool FileImpl::isDirectoryImpl() const
-{
- poco_assert (!_path.empty());
-
- struct stat st;
- if (stat(_path.c_str(), &st) == 0)
- return S_ISDIR(st.st_mode);
- else
- handleLastErrorImpl(_path);
- return false;
-}
-
-
-bool FileImpl::isLinkImpl() const
-{
- poco_assert (!_path.empty());
-
- struct stat st;
- if (lstat(_path.c_str(), &st) == 0)
- return S_ISLNK(st.st_mode);
- else
- handleLastErrorImpl(_path);
- return false;
-}
-
-
-bool FileImpl::isDeviceImpl() const
-{
- poco_assert (!_path.empty());
-
- struct stat st;
- if (stat(_path.c_str(), &st) == 0)
- return S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode);
- else
- handleLastErrorImpl(_path);
- return false;
-}
-
-
-bool FileImpl::isHiddenImpl() const
-{
- poco_assert (!_path.empty());
- Path p(_path);
- p.makeFile();
-
- return p.getFileName()[0] == '.';
-}
-
-
-Timestamp FileImpl::createdImpl() const
-{
- poco_assert (!_path.empty());
-
-#if defined(__APPLE__) && defined(st_birthtime) && !defined(POCO_NO_STAT64) // st_birthtime is available only on 10.5
- struct stat64 st;
- if (stat64(_path.c_str(), &st) == 0)
- return Timestamp::fromEpochTime(st.st_birthtime);
-#elif defined(__FreeBSD__)
- struct stat st;
- if (stat(_path.c_str(), &st) == 0)
- return Timestamp::fromEpochTime(st.st_birthtime);
-#else
- struct stat st;
- if (stat(_path.c_str(), &st) == 0)
- return Timestamp::fromEpochTime(st.st_ctime);
-#endif
- else
- handleLastErrorImpl(_path);
- return 0;
-}
-
-
-Timestamp FileImpl::getLastModifiedImpl() const
-{
- poco_assert (!_path.empty());
-
- struct stat st;
- if (stat(_path.c_str(), &st) == 0)
- return Timestamp::fromEpochTime(st.st_mtime);
- else
- handleLastErrorImpl(_path);
- return 0;
-}
-
-
-void FileImpl::setLastModifiedImpl(const Timestamp& ts)
-{
- poco_assert (!_path.empty());
-
- struct utimbuf tb;
- tb.actime = ts.epochTime();
- tb.modtime = ts.epochTime();
- if (utime(_path.c_str(), &tb) != 0)
- handleLastErrorImpl(_path);
-}
-
-
-FileImpl::FileSizeImpl FileImpl::getSizeImpl() const
-{
- poco_assert (!_path.empty());
-
- struct stat st;
- if (stat(_path.c_str(), &st) == 0)
- return st.st_size;
- else
- handleLastErrorImpl(_path);
- return 0;
-}
-
-
-void FileImpl::setSizeImpl(FileSizeImpl size)
-{
- poco_assert (!_path.empty());
-
- if (truncate(_path.c_str(), size) != 0)
- handleLastErrorImpl(_path);
-}
-
-
-void FileImpl::setWriteableImpl(bool flag)
-{
- poco_assert (!_path.empty());
-
- struct stat st;
- if (stat(_path.c_str(), &st) != 0)
- handleLastErrorImpl(_path);
- mode_t mode;
- if (flag)
- {
- mode = st.st_mode | S_IWUSR;
- }
- else
- {
- mode_t wmask = S_IWUSR | S_IWGRP | S_IWOTH;
- mode = st.st_mode & ~wmask;
- }
- if (chmod(_path.c_str(), mode) != 0)
- handleLastErrorImpl(_path);
-}
-
-
-void FileImpl::setExecutableImpl(bool flag)
-{
- poco_assert (!_path.empty());
-
- struct stat st;
- if (stat(_path.c_str(), &st) != 0)
- handleLastErrorImpl(_path);
- mode_t mode;
- if (flag)
- {
- mode = st.st_mode | S_IXUSR;
- if (st.st_mode & S_IRGRP)
- mode |= S_IXGRP;
- if (st.st_mode & S_IROTH)
- mode |= S_IXOTH;
- }
- else
- {
- mode_t wmask = S_IXUSR | S_IXGRP | S_IXOTH;
- mode = st.st_mode & ~wmask;
- }
- if (chmod(_path.c_str(), mode) != 0)
- handleLastErrorImpl(_path);
-}
-
-
-void FileImpl::copyToImpl(const std::string& path) const
-{
- poco_assert (!_path.empty());
-
- int sd = open(_path.c_str(), O_RDONLY);
- if (sd == -1) handleLastErrorImpl(_path);
-
- struct stat st;
- if (fstat(sd, &st) != 0)
- {
- close(sd);
- handleLastErrorImpl(_path);
- }
- const long blockSize = st.st_blksize;
-
- int dd = open(path.c_str(), O_CREAT | O_TRUNC | O_WRONLY, st.st_mode);
- if (dd == -1)
- {
- close(sd);
- handleLastErrorImpl(path);
- }
- Buffer<char> buffer(blockSize);
- try
- {
- int n;
- while ((n = read(sd, buffer.begin(), blockSize)) > 0)
- {
- if (write(dd, buffer.begin(), n) != n)
- handleLastErrorImpl(path);
- }
- if (n < 0)
- handleLastErrorImpl(_path);
- }
- catch (...)
- {
- close(sd);
- close(dd);
- throw;
- }
- close(sd);
- if (fsync(dd) != 0)
- {
- close(dd);
- handleLastErrorImpl(path);
- }
- if (close(dd) != 0)
- handleLastErrorImpl(path);
-}
-
-
-void FileImpl::renameToImpl(const std::string& path)
-{
- poco_assert (!_path.empty());
-
- if (rename(_path.c_str(), path.c_str()) != 0)
- handleLastErrorImpl(_path);
-}
-
-
-void FileImpl::linkToImpl(const std::string& path, int type) const
-{
- poco_assert (!_path.empty());
-
- if (type == 0)
- {
- if (link(_path.c_str(), path.c_str()) != 0)
- handleLastErrorImpl(_path);
- }
- else
- {
- if (symlink(_path.c_str(), path.c_str()) != 0)
- handleLastErrorImpl(_path);
- }
-}
-
-
-void FileImpl::removeImpl()
-{
- poco_assert (!_path.empty());
-
- int rc;
- if (!isLinkImpl() && isDirectoryImpl())
- rc = rmdir(_path.c_str());
- else
- rc = unlink(_path.c_str());
- if (rc) handleLastErrorImpl(_path);
-}
-
-
-bool FileImpl::createFileImpl()
-{
- poco_assert (!_path.empty());
-
- int n = open(_path.c_str(), O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
- if (n != -1)
- {
- close(n);
- return true;
- }
- if (n == -1 && errno == EEXIST)
- return false;
- else
- handleLastErrorImpl(_path);
- return false;
-}
-
-
-bool FileImpl::createDirectoryImpl()
-{
- poco_assert (!_path.empty());
-
- if (existsImpl() && isDirectoryImpl())
- return false;
- if (mkdir(_path.c_str(), S_IRWXU | S_IRWXG | S_IRWXO) != 0)
- {
- if (errno == EEXIST && isDirectoryImpl())
- return false;
- handleLastErrorImpl(_path);
- }
- return true;
-}
-
-
-FileImpl::FileSizeImpl FileImpl::totalSpaceImpl() const
-{
- poco_assert(!_path.empty());
-
- struct STATFSSTRUCT stats;
- if (STATFSFN(const_cast<char*>(_path.c_str()), &stats) != 0)
- handleLastErrorImpl(_path);
-
- return (FileSizeImpl)stats.f_blocks * (FileSizeImpl)stats.f_bsize;
-}
-
-
-FileImpl::FileSizeImpl FileImpl::usableSpaceImpl() const
-{
- poco_assert(!_path.empty());
-
- struct STATFSSTRUCT stats;
- if (STATFSFN(const_cast<char*>(_path.c_str()), &stats) != 0)
- handleLastErrorImpl(_path);
-
- return (FileSizeImpl)stats.f_bavail * (FileSizeImpl)stats.f_bsize;
-}
-
-
-FileImpl::FileSizeImpl FileImpl::freeSpaceImpl() const
-{
- poco_assert(!_path.empty());
-
- struct STATFSSTRUCT stats;
- if (STATFSFN(const_cast<char*>(_path.c_str()), &stats) != 0)
- handleLastErrorImpl(_path);
-
- return (FileSizeImpl)stats.f_bfree * (FileSizeImpl)stats.f_bsize;
-}
-
-
-void FileImpl::handleLastErrorImpl(const std::string& path)
-{
- switch (errno)
- {
- case EIO:
- throw IOException(path, errno);
- case EPERM:
- throw FileAccessDeniedException("insufficient permissions", path, errno);
- case EACCES:
- throw FileAccessDeniedException(path, errno);
- case ENOENT:
- throw FileNotFoundException(path, errno);
- case ENOTDIR:
- throw OpenFileException("not a directory", path, errno);
- case EISDIR:
- throw OpenFileException("not a file", path, errno);
- case EROFS:
- throw FileReadOnlyException(path, errno);
- case EEXIST:
- throw FileExistsException(path, errno);
- case ENOSPC:
- throw FileException("no space left on device", path, errno);
- case EDQUOT:
- throw FileException("disk quota exceeded", path, errno);
-#if !defined(_AIX)
- case ENOTEMPTY:
- throw DirectoryNotEmptyException(path, errno);
-#endif
- case ENAMETOOLONG:
- throw PathSyntaxException(path, errno);
- case ENFILE:
- case EMFILE:
- throw FileException("too many open files", path, errno);
- default:
- throw FileException(Error::getMessage(errno), path, errno);
- }
-}
-
-
-} // namespace Poco
+//
+// File_UNIX.cpp
+//
+// Library: Foundation
+// Package: Filesystem
+// Module: File
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/File_UNIX.h"
+#include "Poco/Buffer.h"
+#include "Poco/Exception.h"
+#include "Poco/Error.h"
+#include <algorithm>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#if defined(POCO_OS_FAMILY_BSD)
+#include <sys/param.h>
+#include <sys/mount.h>
+#elif (POCO_OS == POCO_OS_SOLARIS)
+#include <sys/statvfs.h>
+#else
+#include <sys/statfs.h>
+#endif
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <utime.h>
+#include <cstring>
+
+#if (POCO_OS == POCO_OS_SOLARIS)
+#define STATFSFN statvfs
+#define STATFSSTRUCT statvfs
+#else
+#define STATFSFN statfs
+#define STATFSSTRUCT statfs
+#endif
+
+
+namespace Poco {
+
+
+FileImpl::FileImpl()
+{
+}
+
+
+FileImpl::FileImpl(const std::string& path): _path(path)
+{
+ std::string::size_type n = _path.size();
+ if (n > 1 && _path[n - 1] == '/')
+ _path.resize(n - 1);
+}
+
+
+FileImpl::~FileImpl()
+{
+}
+
+
+void FileImpl::swapImpl(FileImpl& file)
+{
+ std::swap(_path, file._path);
+}
+
+
+void FileImpl::setPathImpl(const std::string& path)
+{
+ _path = path;
+ std::string::size_type n = _path.size();
+ if (n > 1 && _path[n - 1] == '/')
+ _path.resize(n - 1);
+}
+
+
+bool FileImpl::existsImpl() const
+{
+ poco_assert (!_path.empty());
+
+ struct stat st;
+ return stat(_path.c_str(), &st) == 0;
+}
+
+
+bool FileImpl::canReadImpl() const
+{
+ poco_assert (!_path.empty());
+
+ struct stat st;
+ if (stat(_path.c_str(), &st) == 0)
+ {
+ if (st.st_uid == geteuid())
+ return (st.st_mode & S_IRUSR) != 0;
+ else if (st.st_gid == getegid())
+ return (st.st_mode & S_IRGRP) != 0;
+ else
+ return (st.st_mode & S_IROTH) != 0 || geteuid() == 0;
+ }
+ else handleLastErrorImpl(_path);
+ return false;
+}
+
+
+bool FileImpl::canWriteImpl() const
+{
+ poco_assert (!_path.empty());
+
+ struct stat st;
+ if (stat(_path.c_str(), &st) == 0)
+ {
+ if (st.st_uid == geteuid())
+ return (st.st_mode & S_IWUSR) != 0;
+ else if (st.st_gid == getegid())
+ return (st.st_mode & S_IWGRP) != 0;
+ else
+ return (st.st_mode & S_IWOTH) != 0 || geteuid() == 0;
+ }
+ else handleLastErrorImpl(_path);
+ return false;
+}
+
+
+bool FileImpl::canExecuteImpl() const
+{
+ poco_assert (!_path.empty());
+
+ struct stat st;
+ if (stat(_path.c_str(), &st) == 0)
+ {
+ if (st.st_uid == geteuid() || geteuid() == 0)
+ return (st.st_mode & S_IXUSR) != 0;
+ else if (st.st_gid == getegid())
+ return (st.st_mode & S_IXGRP) != 0;
+ else
+ return (st.st_mode & S_IXOTH) != 0;
+ }
+ else handleLastErrorImpl(_path);
+ return false;
+}
+
+
+bool FileImpl::isFileImpl() const
+{
+ poco_assert (!_path.empty());
+
+ struct stat st;
+ if (stat(_path.c_str(), &st) == 0)
+ return S_ISREG(st.st_mode);
+ else
+ handleLastErrorImpl(_path);
+ return false;
+}
+
+
+bool FileImpl::isDirectoryImpl() const
+{
+ poco_assert (!_path.empty());
+
+ struct stat st;
+ if (stat(_path.c_str(), &st) == 0)
+ return S_ISDIR(st.st_mode);
+ else
+ handleLastErrorImpl(_path);
+ return false;
+}
+
+
+bool FileImpl::isLinkImpl() const
+{
+ poco_assert (!_path.empty());
+
+ struct stat st;
+ if (lstat(_path.c_str(), &st) == 0)
+ return S_ISLNK(st.st_mode);
+ else
+ handleLastErrorImpl(_path);
+ return false;
+}
+
+
+bool FileImpl::isDeviceImpl() const
+{
+ poco_assert (!_path.empty());
+
+ struct stat st;
+ if (stat(_path.c_str(), &st) == 0)
+ return S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode);
+ else
+ handleLastErrorImpl(_path);
+ return false;
+}
+
+
+bool FileImpl::isHiddenImpl() const
+{
+ poco_assert (!_path.empty());
+ Path p(_path);
+ p.makeFile();
+
+ return p.getFileName()[0] == '.';
+}
+
+
+Timestamp FileImpl::createdImpl() const
+{
+ poco_assert (!_path.empty());
+
+#if defined(__APPLE__) && defined(st_birthtime) && !defined(POCO_NO_STAT64) // st_birthtime is available only on 10.5
+ struct stat64 st;
+ if (stat64(_path.c_str(), &st) == 0)
+ return Timestamp::fromEpochTime(st.st_birthtime);
+#elif defined(__FreeBSD__)
+ struct stat st;
+ if (stat(_path.c_str(), &st) == 0)
+ return Timestamp::fromEpochTime(st.st_birthtime);
+#else
+ struct stat st;
+ if (stat(_path.c_str(), &st) == 0)
+ return Timestamp::fromEpochTime(st.st_ctime);
+#endif
+ else
+ handleLastErrorImpl(_path);
+ return 0;
+}
+
+
+Timestamp FileImpl::getLastModifiedImpl() const
+{
+ poco_assert (!_path.empty());
+
+ struct stat st;
+ if (stat(_path.c_str(), &st) == 0)
+ return Timestamp::fromEpochTime(st.st_mtime);
+ else
+ handleLastErrorImpl(_path);
+ return 0;
+}
+
+
+void FileImpl::setLastModifiedImpl(const Timestamp& ts)
+{
+ poco_assert (!_path.empty());
+
+ struct utimbuf tb;
+ tb.actime = ts.epochTime();
+ tb.modtime = ts.epochTime();
+ if (utime(_path.c_str(), &tb) != 0)
+ handleLastErrorImpl(_path);
+}
+
+
+FileImpl::FileSizeImpl FileImpl::getSizeImpl() const
+{
+ poco_assert (!_path.empty());
+
+ struct stat st;
+ if (stat(_path.c_str(), &st) == 0)
+ return st.st_size;
+ else
+ handleLastErrorImpl(_path);
+ return 0;
+}
+
+
+void FileImpl::setSizeImpl(FileSizeImpl size)
+{
+ poco_assert (!_path.empty());
+
+ if (truncate(_path.c_str(), size) != 0)
+ handleLastErrorImpl(_path);
+}
+
+
+void FileImpl::setWriteableImpl(bool flag)
+{
+ poco_assert (!_path.empty());
+
+ struct stat st;
+ if (stat(_path.c_str(), &st) != 0)
+ handleLastErrorImpl(_path);
+ mode_t mode;
+ if (flag)
+ {
+ mode = st.st_mode | S_IWUSR;
+ }
+ else
+ {
+ mode_t wmask = S_IWUSR | S_IWGRP | S_IWOTH;
+ mode = st.st_mode & ~wmask;
+ }
+ if (chmod(_path.c_str(), mode) != 0)
+ handleLastErrorImpl(_path);
+}
+
+
+void FileImpl::setExecutableImpl(bool flag)
+{
+ poco_assert (!_path.empty());
+
+ struct stat st;
+ if (stat(_path.c_str(), &st) != 0)
+ handleLastErrorImpl(_path);
+ mode_t mode;
+ if (flag)
+ {
+ mode = st.st_mode | S_IXUSR;
+ if (st.st_mode & S_IRGRP)
+ mode |= S_IXGRP;
+ if (st.st_mode & S_IROTH)
+ mode |= S_IXOTH;
+ }
+ else
+ {
+ mode_t wmask = S_IXUSR | S_IXGRP | S_IXOTH;
+ mode = st.st_mode & ~wmask;
+ }
+ if (chmod(_path.c_str(), mode) != 0)
+ handleLastErrorImpl(_path);
+}
+
+
+void FileImpl::copyToImpl(const std::string& path) const
+{
+ poco_assert (!_path.empty());
+
+ int sd = open(_path.c_str(), O_RDONLY);
+ if (sd == -1) handleLastErrorImpl(_path);
+
+ struct stat st;
+ if (fstat(sd, &st) != 0)
+ {
+ close(sd);
+ handleLastErrorImpl(_path);
+ }
+ const long blockSize = st.st_blksize;
+
+ int dd = open(path.c_str(), O_CREAT | O_TRUNC | O_WRONLY, st.st_mode);
+ if (dd == -1)
+ {
+ close(sd);
+ handleLastErrorImpl(path);
+ }
+ Buffer<char> buffer(blockSize);
+ try
+ {
+ int n;
+ while ((n = read(sd, buffer.begin(), blockSize)) > 0)
+ {
+ if (write(dd, buffer.begin(), n) != n)
+ handleLastErrorImpl(path);
+ }
+ if (n < 0)
+ handleLastErrorImpl(_path);
+ }
+ catch (...)
+ {
+ close(sd);
+ close(dd);
+ throw;
+ }
+ close(sd);
+ if (fsync(dd) != 0)
+ {
+ close(dd);
+ handleLastErrorImpl(path);
+ }
+ if (close(dd) != 0)
+ handleLastErrorImpl(path);
+}
+
+
+void FileImpl::renameToImpl(const std::string& path)
+{
+ poco_assert (!_path.empty());
+
+ if (rename(_path.c_str(), path.c_str()) != 0)
+ handleLastErrorImpl(_path);
+}
+
+
+void FileImpl::linkToImpl(const std::string& path, int type) const
+{
+ poco_assert (!_path.empty());
+
+ if (type == 0)
+ {
+ if (link(_path.c_str(), path.c_str()) != 0)
+ handleLastErrorImpl(_path);
+ }
+ else
+ {
+ if (symlink(_path.c_str(), path.c_str()) != 0)
+ handleLastErrorImpl(_path);
+ }
+}
+
+
+void FileImpl::removeImpl()
+{
+ poco_assert (!_path.empty());
+
+ int rc;
+ if (!isLinkImpl() && isDirectoryImpl())
+ rc = rmdir(_path.c_str());
+ else
+ rc = unlink(_path.c_str());
+ if (rc) handleLastErrorImpl(_path);
+}
+
+
+bool FileImpl::createFileImpl()
+{
+ poco_assert (!_path.empty());
+
+ int n = open(_path.c_str(), O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
+ if (n != -1)
+ {
+ close(n);
+ return true;
+ }
+ if (n == -1 && errno == EEXIST)
+ return false;
+ else
+ handleLastErrorImpl(_path);
+ return false;
+}
+
+
+bool FileImpl::createDirectoryImpl()
+{
+ poco_assert (!_path.empty());
+
+ if (existsImpl() && isDirectoryImpl())
+ return false;
+ if (mkdir(_path.c_str(), S_IRWXU | S_IRWXG | S_IRWXO) != 0)
+ {
+ if (errno == EEXIST && isDirectoryImpl())
+ return false;
+ handleLastErrorImpl(_path);
+ }
+ return true;
+}
+
+
+FileImpl::FileSizeImpl FileImpl::totalSpaceImpl() const
+{
+ poco_assert(!_path.empty());
+
+ struct STATFSSTRUCT stats;
+ if (STATFSFN(const_cast<char*>(_path.c_str()), &stats) != 0)
+ handleLastErrorImpl(_path);
+
+ return (FileSizeImpl)stats.f_blocks * (FileSizeImpl)stats.f_bsize;
+}
+
+
+FileImpl::FileSizeImpl FileImpl::usableSpaceImpl() const
+{
+ poco_assert(!_path.empty());
+
+ struct STATFSSTRUCT stats;
+ if (STATFSFN(const_cast<char*>(_path.c_str()), &stats) != 0)
+ handleLastErrorImpl(_path);
+
+ return (FileSizeImpl)stats.f_bavail * (FileSizeImpl)stats.f_bsize;
+}
+
+
+FileImpl::FileSizeImpl FileImpl::freeSpaceImpl() const
+{
+ poco_assert(!_path.empty());
+
+ struct STATFSSTRUCT stats;
+ if (STATFSFN(const_cast<char*>(_path.c_str()), &stats) != 0)
+ handleLastErrorImpl(_path);
+
+ return (FileSizeImpl)stats.f_bfree * (FileSizeImpl)stats.f_bsize;
+}
+
+
+void FileImpl::handleLastErrorImpl(const std::string& path)
+{
+ switch (errno)
+ {
+ case EIO:
+ throw IOException(path, errno);
+ case EPERM:
+ throw FileAccessDeniedException("insufficient permissions", path, errno);
+ case EACCES:
+ throw FileAccessDeniedException(path, errno);
+ case ENOENT:
+ throw FileNotFoundException(path, errno);
+ case ENOTDIR:
+ throw OpenFileException("not a directory", path, errno);
+ case EISDIR:
+ throw OpenFileException("not a file", path, errno);
+ case EROFS:
+ throw FileReadOnlyException(path, errno);
+ case EEXIST:
+ throw FileExistsException(path, errno);
+ case ENOSPC:
+ throw FileException("no space left on device", path, errno);
+ case EDQUOT:
+ throw FileException("disk quota exceeded", path, errno);
+#if !defined(_AIX)
+ case ENOTEMPTY:
+ throw DirectoryNotEmptyException(path, errno);
+#endif
+ case ENAMETOOLONG:
+ throw PathSyntaxException(path, errno);
+ case ENFILE:
+ case EMFILE:
+ throw FileException("too many open files", path, errno);
+ default:
+ throw FileException(Error::getMessage(errno), path, errno);
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/File_VX.cpp b/contrib/libs/poco/Foundation/src/File_VX.cpp
index 9f59b478a8..8dd012a42b 100644
--- a/contrib/libs/poco/Foundation/src/File_VX.cpp
+++ b/contrib/libs/poco/Foundation/src/File_VX.cpp
@@ -1,408 +1,408 @@
-//
-// File_VX.cpp
-//
-// Library: Foundation
-// Package: Filesystem
-// Module: File
-//
-// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/File_VX.h"
-#include "Poco/Buffer.h"
-#include "Poco/Exception.h"
-#include <algorithm>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <utime.h>
-#include <cstring>
-
-
-namespace Poco {
-
-
-FileImpl::FileImpl()
-{
-}
-
-
-FileImpl::FileImpl(const std::string& path): _path(path)
-{
- std::string::size_type n = _path.size();
- if (n > 1 && _path[n - 1] == '/')
- _path.resize(n - 1);
-}
-
-
-FileImpl::~FileImpl()
-{
-}
-
-
-void FileImpl::swapImpl(FileImpl& file)
-{
- std::swap(_path, file._path);
-}
-
-
-void FileImpl::setPathImpl(const std::string& path)
-{
- _path = path;
- std::string::size_type n = _path.size();
- if (n > 1 && _path[n - 1] == '/')
- _path.resize(n - 1);
-}
-
-
-bool FileImpl::existsImpl() const
-{
- poco_assert (!_path.empty());
-
- struct stat st;
- return stat(const_cast<char*>(_path.c_str()), &st) == 0;
-}
-
-
-bool FileImpl::canReadImpl() const
-{
- poco_assert (!_path.empty());
-
- return true;
-}
-
-
-bool FileImpl::canWriteImpl() const
-{
- poco_assert (!_path.empty());
-
- return true;
-}
-
-
-bool FileImpl::canExecuteImpl() const
-{
- return false;
-}
-
-
-bool FileImpl::isFileImpl() const
-{
- poco_assert (!_path.empty());
-
- struct stat st;
- if (stat(const_cast<char*>(_path.c_str()), &st) == 0)
- return S_ISREG(st.st_mode);
- else
- handleLastErrorImpl(_path);
- return false;
-}
-
-
-bool FileImpl::isDirectoryImpl() const
-{
- poco_assert (!_path.empty());
-
- struct stat st;
- if (stat(const_cast<char*>(_path.c_str()), &st) == 0)
- return S_ISDIR(st.st_mode);
- else
- handleLastErrorImpl(_path);
- return false;
-}
-
-
-bool FileImpl::isLinkImpl() const
-{
- return false;
-}
-
-
-bool FileImpl::isDeviceImpl() const
-{
- poco_assert (!_path.empty());
-
- struct stat st;
- if (stat(const_cast<char*>(_path.c_str()), &st) == 0)
- return S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode);
- else
- handleLastErrorImpl(_path);
- return false;
-}
-
-
-bool FileImpl::isHiddenImpl() const
-{
- poco_assert (!_path.empty());
- Path p(_path);
- p.makeFile();
-
- return p.getFileName()[0] == '.';
-}
-
-
-Timestamp FileImpl::createdImpl() const
-{
- poco_assert (!_path.empty());
-
- struct stat st;
- if (stat(const_cast<char*>(_path.c_str()), &st) == 0)
- return Timestamp::fromEpochTime(st.st_ctime);
- else
- handleLastErrorImpl(_path);
- return 0;
-}
-
-
-Timestamp FileImpl::getLastModifiedImpl() const
-{
- poco_assert (!_path.empty());
-
- struct stat st;
- if (stat(const_cast<char*>(_path.c_str()), &st) == 0)
- return Timestamp::fromEpochTime(st.st_mtime);
- else
- handleLastErrorImpl(_path);
- return 0;
-}
-
-
-void FileImpl::setLastModifiedImpl(const Timestamp& ts)
-{
- poco_assert (!_path.empty());
-
- struct utimbuf tb;
- tb.actime = ts.epochTime();
- tb.modtime = ts.epochTime();
- if (utime(const_cast<char*>(_path.c_str()), &tb) != 0)
- handleLastErrorImpl(_path);
-}
-
-
-FileImpl::FileSizeImpl FileImpl::getSizeImpl() const
-{
- poco_assert (!_path.empty());
-
- struct stat st;
- if (stat(const_cast<char*>(_path.c_str()), &st) == 0)
- return st.st_size;
- else
- handleLastErrorImpl(_path);
- return 0;
-}
-
-
-void FileImpl::setSizeImpl(FileSizeImpl size)
-{
- poco_assert (!_path.empty());
-
- int fd = open(_path.c_str(), O_WRONLY, S_IRWXU);
- if (fd != -1)
- {
- try
- {
- if (ftruncate(fd, size) != 0)
- handleLastErrorImpl(_path);
- }
- catch (...)
- {
- close(fd);
- throw;
- }
- }
-}
-
-
-void FileImpl::setWriteableImpl(bool flag)
-{
- poco_assert (!_path.empty());
-}
-
-
-void FileImpl::setExecutableImpl(bool flag)
-{
- poco_assert (!_path.empty());
-}
-
-
-void FileImpl::copyToImpl(const std::string& path) const
-{
- poco_assert (!_path.empty());
-
- int sd = open(_path.c_str(), O_RDONLY, 0);
- if (sd == -1) handleLastErrorImpl(_path);
-
- struct stat st;
- if (fstat(sd, &st) != 0)
- {
- close(sd);
- handleLastErrorImpl(_path);
- }
- const long blockSize = st.st_blksize;
-
- int dd = open(path.c_str(), O_CREAT | O_TRUNC | O_WRONLY, st.st_mode & S_IRWXU);
- if (dd == -1)
- {
- close(sd);
- handleLastErrorImpl(path);
- }
- Buffer<char> buffer(blockSize);
- try
- {
- int n;
- while ((n = read(sd, buffer.begin(), blockSize)) > 0)
- {
- if (write(dd, buffer.begin(), n) != n)
- handleLastErrorImpl(path);
- }
- if (n < 0)
- handleLastErrorImpl(_path);
- }
- catch (...)
- {
- close(sd);
- close(dd);
- throw;
- }
- close(sd);
- close(dd);
-}
-
-
-void FileImpl::renameToImpl(const std::string& path)
-{
- poco_assert (!_path.empty());
-
- if (rename(_path.c_str(), path.c_str()) != 0)
- handleLastErrorImpl(_path);
-}
-
-
-void FileImpl::linkToImpl(const std::string& path, int type) const
-{
- throw Poco::NotImplementedException("File::linkTo() is not available on this platform");
-}
-
-
-void FileImpl::removeImpl()
-{
- poco_assert (!_path.empty());
-
- int rc;
- if (!isLinkImpl() && isDirectoryImpl())
- rc = rmdir(_path.c_str());
- else
- rc = unlink(const_cast<char*>(_path.c_str()));
- if (rc) handleLastErrorImpl(_path);
-}
-
-
-bool FileImpl::createFileImpl()
-{
- poco_assert (!_path.empty());
-
- int n = open(_path.c_str(), O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
- if (n != -1)
- {
- close(n);
- return true;
- }
- if (n == -1 && errno == EEXIST)
- return false;
- else
- handleLastErrorImpl(_path);
- return false;
-}
-
-
-bool FileImpl::createDirectoryImpl()
-{
- poco_assert (!_path.empty());
-
- if (existsImpl() && isDirectoryImpl())
- return false;
- if (mkdir(_path.c_str()) != 0)
- handleLastErrorImpl(_path);
- return true;
-}
-
-
-FileImpl::FileSizeImpl FileImpl::totalSpaceImpl() const
-{
- poco_assert(!_path.empty());
-
- struct statfs stats;
- if (statfs(_path.c_str(), &stats) != 0)
- handleLastErrorImpl(_path);
-
- return (FileSizeImpl)stats.f_blocks * (FileSizeImpl)stats.f_bsize;
-}
-
-
-FileImpl::FileSizeImpl FileImpl::usableSpaceImpl() const
-{
- poco_assert(!_path.empty());
-
- struct statfs stats;
- if (statfs(_path.c_str(), &stats) != 0)
- handleLastErrorImpl(_path);
-
- return (FileSizeImpl)stats.f_bavail * (FileSizeImpl)stats.f_bsize;
-}
-
-
-FileImpl::FileSizeImpl FileImpl::freeSpaceImpl() const
-{
- poco_assert(!_path.empty());
-
- struct statfs stats;
- if (statfs(_path.c_str(), &stats) != 0)
- handleLastErrorImpl(_path);
-
- return (FileSizeImpl)stats.f_bfree * (FileSizeImpl)stats.f_bsize;
-}
-
-
-void FileImpl::handleLastErrorImpl(const std::string& path)
-{
- switch (errno)
- {
- case EIO:
- throw IOException(path);
- case EPERM:
- throw FileAccessDeniedException("insufficient permissions", path);
- case EACCES:
- throw FileAccessDeniedException(path);
- case ENOENT:
- throw FileNotFoundException(path);
- case ENOTDIR:
- throw OpenFileException("not a directory", path);
- case EISDIR:
- throw OpenFileException("not a file", path);
- case EROFS:
- throw FileReadOnlyException(path);
- case EEXIST:
- throw FileExistsException(path);
- case ENOSPC:
- throw FileException("no space left on device", path);
- case ENOTEMPTY:
- throw DirectoryNotEmptyException(path);
- case ENAMETOOLONG:
- throw PathSyntaxException(path);
- case ENFILE:
- case EMFILE:
- throw FileException("too many open files", path);
- default:
- throw FileException(std::strerror(errno), path);
- }
-}
-
-
-} // namespace Poco
+//
+// File_VX.cpp
+//
+// Library: Foundation
+// Package: Filesystem
+// Module: File
+//
+// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/File_VX.h"
+#include "Poco/Buffer.h"
+#include "Poco/Exception.h"
+#include <algorithm>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <utime.h>
+#include <cstring>
+
+
+namespace Poco {
+
+
+FileImpl::FileImpl()
+{
+}
+
+
+FileImpl::FileImpl(const std::string& path): _path(path)
+{
+ std::string::size_type n = _path.size();
+ if (n > 1 && _path[n - 1] == '/')
+ _path.resize(n - 1);
+}
+
+
+FileImpl::~FileImpl()
+{
+}
+
+
+void FileImpl::swapImpl(FileImpl& file)
+{
+ std::swap(_path, file._path);
+}
+
+
+void FileImpl::setPathImpl(const std::string& path)
+{
+ _path = path;
+ std::string::size_type n = _path.size();
+ if (n > 1 && _path[n - 1] == '/')
+ _path.resize(n - 1);
+}
+
+
+bool FileImpl::existsImpl() const
+{
+ poco_assert (!_path.empty());
+
+ struct stat st;
+ return stat(const_cast<char*>(_path.c_str()), &st) == 0;
+}
+
+
+bool FileImpl::canReadImpl() const
+{
+ poco_assert (!_path.empty());
+
+ return true;
+}
+
+
+bool FileImpl::canWriteImpl() const
+{
+ poco_assert (!_path.empty());
+
+ return true;
+}
+
+
+bool FileImpl::canExecuteImpl() const
+{
+ return false;
+}
+
+
+bool FileImpl::isFileImpl() const
+{
+ poco_assert (!_path.empty());
+
+ struct stat st;
+ if (stat(const_cast<char*>(_path.c_str()), &st) == 0)
+ return S_ISREG(st.st_mode);
+ else
+ handleLastErrorImpl(_path);
+ return false;
+}
+
+
+bool FileImpl::isDirectoryImpl() const
+{
+ poco_assert (!_path.empty());
+
+ struct stat st;
+ if (stat(const_cast<char*>(_path.c_str()), &st) == 0)
+ return S_ISDIR(st.st_mode);
+ else
+ handleLastErrorImpl(_path);
+ return false;
+}
+
+
+bool FileImpl::isLinkImpl() const
+{
+ return false;
+}
+
+
+bool FileImpl::isDeviceImpl() const
+{
+ poco_assert (!_path.empty());
+
+ struct stat st;
+ if (stat(const_cast<char*>(_path.c_str()), &st) == 0)
+ return S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode);
+ else
+ handleLastErrorImpl(_path);
+ return false;
+}
+
+
+bool FileImpl::isHiddenImpl() const
+{
+ poco_assert (!_path.empty());
+ Path p(_path);
+ p.makeFile();
+
+ return p.getFileName()[0] == '.';
+}
+
+
+Timestamp FileImpl::createdImpl() const
+{
+ poco_assert (!_path.empty());
+
+ struct stat st;
+ if (stat(const_cast<char*>(_path.c_str()), &st) == 0)
+ return Timestamp::fromEpochTime(st.st_ctime);
+ else
+ handleLastErrorImpl(_path);
+ return 0;
+}
+
+
+Timestamp FileImpl::getLastModifiedImpl() const
+{
+ poco_assert (!_path.empty());
+
+ struct stat st;
+ if (stat(const_cast<char*>(_path.c_str()), &st) == 0)
+ return Timestamp::fromEpochTime(st.st_mtime);
+ else
+ handleLastErrorImpl(_path);
+ return 0;
+}
+
+
+void FileImpl::setLastModifiedImpl(const Timestamp& ts)
+{
+ poco_assert (!_path.empty());
+
+ struct utimbuf tb;
+ tb.actime = ts.epochTime();
+ tb.modtime = ts.epochTime();
+ if (utime(const_cast<char*>(_path.c_str()), &tb) != 0)
+ handleLastErrorImpl(_path);
+}
+
+
+FileImpl::FileSizeImpl FileImpl::getSizeImpl() const
+{
+ poco_assert (!_path.empty());
+
+ struct stat st;
+ if (stat(const_cast<char*>(_path.c_str()), &st) == 0)
+ return st.st_size;
+ else
+ handleLastErrorImpl(_path);
+ return 0;
+}
+
+
+void FileImpl::setSizeImpl(FileSizeImpl size)
+{
+ poco_assert (!_path.empty());
+
+ int fd = open(_path.c_str(), O_WRONLY, S_IRWXU);
+ if (fd != -1)
+ {
+ try
+ {
+ if (ftruncate(fd, size) != 0)
+ handleLastErrorImpl(_path);
+ }
+ catch (...)
+ {
+ close(fd);
+ throw;
+ }
+ }
+}
+
+
+void FileImpl::setWriteableImpl(bool flag)
+{
+ poco_assert (!_path.empty());
+}
+
+
+void FileImpl::setExecutableImpl(bool flag)
+{
+ poco_assert (!_path.empty());
+}
+
+
+void FileImpl::copyToImpl(const std::string& path) const
+{
+ poco_assert (!_path.empty());
+
+ int sd = open(_path.c_str(), O_RDONLY, 0);
+ if (sd == -1) handleLastErrorImpl(_path);
+
+ struct stat st;
+ if (fstat(sd, &st) != 0)
+ {
+ close(sd);
+ handleLastErrorImpl(_path);
+ }
+ const long blockSize = st.st_blksize;
+
+ int dd = open(path.c_str(), O_CREAT | O_TRUNC | O_WRONLY, st.st_mode & S_IRWXU);
+ if (dd == -1)
+ {
+ close(sd);
+ handleLastErrorImpl(path);
+ }
+ Buffer<char> buffer(blockSize);
+ try
+ {
+ int n;
+ while ((n = read(sd, buffer.begin(), blockSize)) > 0)
+ {
+ if (write(dd, buffer.begin(), n) != n)
+ handleLastErrorImpl(path);
+ }
+ if (n < 0)
+ handleLastErrorImpl(_path);
+ }
+ catch (...)
+ {
+ close(sd);
+ close(dd);
+ throw;
+ }
+ close(sd);
+ close(dd);
+}
+
+
+void FileImpl::renameToImpl(const std::string& path)
+{
+ poco_assert (!_path.empty());
+
+ if (rename(_path.c_str(), path.c_str()) != 0)
+ handleLastErrorImpl(_path);
+}
+
+
+void FileImpl::linkToImpl(const std::string& path, int type) const
+{
+ throw Poco::NotImplementedException("File::linkTo() is not available on this platform");
+}
+
+
+void FileImpl::removeImpl()
+{
+ poco_assert (!_path.empty());
+
+ int rc;
+ if (!isLinkImpl() && isDirectoryImpl())
+ rc = rmdir(_path.c_str());
+ else
+ rc = unlink(const_cast<char*>(_path.c_str()));
+ if (rc) handleLastErrorImpl(_path);
+}
+
+
+bool FileImpl::createFileImpl()
+{
+ poco_assert (!_path.empty());
+
+ int n = open(_path.c_str(), O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
+ if (n != -1)
+ {
+ close(n);
+ return true;
+ }
+ if (n == -1 && errno == EEXIST)
+ return false;
+ else
+ handleLastErrorImpl(_path);
+ return false;
+}
+
+
+bool FileImpl::createDirectoryImpl()
+{
+ poco_assert (!_path.empty());
+
+ if (existsImpl() && isDirectoryImpl())
+ return false;
+ if (mkdir(_path.c_str()) != 0)
+ handleLastErrorImpl(_path);
+ return true;
+}
+
+
+FileImpl::FileSizeImpl FileImpl::totalSpaceImpl() const
+{
+ poco_assert(!_path.empty());
+
+ struct statfs stats;
+ if (statfs(_path.c_str(), &stats) != 0)
+ handleLastErrorImpl(_path);
+
+ return (FileSizeImpl)stats.f_blocks * (FileSizeImpl)stats.f_bsize;
+}
+
+
+FileImpl::FileSizeImpl FileImpl::usableSpaceImpl() const
+{
+ poco_assert(!_path.empty());
+
+ struct statfs stats;
+ if (statfs(_path.c_str(), &stats) != 0)
+ handleLastErrorImpl(_path);
+
+ return (FileSizeImpl)stats.f_bavail * (FileSizeImpl)stats.f_bsize;
+}
+
+
+FileImpl::FileSizeImpl FileImpl::freeSpaceImpl() const
+{
+ poco_assert(!_path.empty());
+
+ struct statfs stats;
+ if (statfs(_path.c_str(), &stats) != 0)
+ handleLastErrorImpl(_path);
+
+ return (FileSizeImpl)stats.f_bfree * (FileSizeImpl)stats.f_bsize;
+}
+
+
+void FileImpl::handleLastErrorImpl(const std::string& path)
+{
+ switch (errno)
+ {
+ case EIO:
+ throw IOException(path);
+ case EPERM:
+ throw FileAccessDeniedException("insufficient permissions", path);
+ case EACCES:
+ throw FileAccessDeniedException(path);
+ case ENOENT:
+ throw FileNotFoundException(path);
+ case ENOTDIR:
+ throw OpenFileException("not a directory", path);
+ case EISDIR:
+ throw OpenFileException("not a file", path);
+ case EROFS:
+ throw FileReadOnlyException(path);
+ case EEXIST:
+ throw FileExistsException(path);
+ case ENOSPC:
+ throw FileException("no space left on device", path);
+ case ENOTEMPTY:
+ throw DirectoryNotEmptyException(path);
+ case ENAMETOOLONG:
+ throw PathSyntaxException(path);
+ case ENFILE:
+ case EMFILE:
+ throw FileException("too many open files", path);
+ default:
+ throw FileException(std::strerror(errno), path);
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/File_WIN32.cpp b/contrib/libs/poco/Foundation/src/File_WIN32.cpp
index 2ab9605c8c..4efb144c3f 100644
--- a/contrib/libs/poco/Foundation/src/File_WIN32.cpp
+++ b/contrib/libs/poco/Foundation/src/File_WIN32.cpp
@@ -1,465 +1,465 @@
-//
-// File_WIN32.cpp
-//
-// Library: Foundation
-// Package: Filesystem
-// Module: File
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/File_WIN32.h"
-#include "Poco/Exception.h"
-#include "Poco/String.h"
-#include "Poco/UnWindows.h"
-
-
-namespace Poco {
-
-
-class FileHandle
-{
-public:
- FileHandle(const std::string& path, DWORD access, DWORD share, DWORD disp)
- {
- _h = CreateFileA(path.c_str(), access, share, 0, disp, 0, 0);
- if (_h == INVALID_HANDLE_VALUE)
- {
- FileImpl::handleLastErrorImpl(path);
- }
- }
-
- ~FileHandle()
- {
- if (_h != INVALID_HANDLE_VALUE) CloseHandle(_h);
- }
-
- HANDLE get() const
- {
- return _h;
- }
-
-private:
- HANDLE _h;
-};
-
-
-FileImpl::FileImpl()
-{
-}
-
-
-FileImpl::FileImpl(const std::string& path): _path(path)
-{
- std::string::size_type n = _path.size();
- if (n > 1 && (_path[n - 1] == '\\' || _path[n - 1] == '/') && !((n == 3 && _path[1]==':')))
- {
- _path.resize(n - 1);
- }
-}
-
-
-FileImpl::~FileImpl()
-{
-}
-
-
-void FileImpl::swapImpl(FileImpl& file)
-{
- std::swap(_path, file._path);
-}
-
-
-void FileImpl::setPathImpl(const std::string& path)
-{
- _path = path;
- std::string::size_type n = _path.size();
- if (n > 1 && (_path[n - 1] == '\\' || _path[n - 1] == '/') && !((n == 3 && _path[1]==':')))
- {
- _path.resize(n - 1);
- }
-}
-
-
-bool FileImpl::existsImpl() const
-{
- poco_assert (!_path.empty());
-
- DWORD attr = GetFileAttributes(_path.c_str());
- if (attr == INVALID_FILE_ATTRIBUTES)
- {
- switch (GetLastError())
- {
- case ERROR_FILE_NOT_FOUND:
- case ERROR_PATH_NOT_FOUND:
- case ERROR_NOT_READY:
- case ERROR_INVALID_DRIVE:
- return false;
- default:
- handleLastErrorImpl(_path);
- }
- }
- return true;
-}
-
-
-bool FileImpl::canReadImpl() const
-{
- poco_assert (!_path.empty());
-
- DWORD attr = GetFileAttributes(_path.c_str());
- if (attr == INVALID_FILE_ATTRIBUTES)
- {
- switch (GetLastError())
- {
- case ERROR_ACCESS_DENIED:
- return false;
- default:
- handleLastErrorImpl(_path);
- }
- }
- return true;
-}
-
-
-bool FileImpl::canWriteImpl() const
-{
- poco_assert (!_path.empty());
-
- DWORD attr = GetFileAttributes(_path.c_str());
- if (attr == INVALID_FILE_ATTRIBUTES)
- handleLastErrorImpl(_path);
- return (attr & FILE_ATTRIBUTE_READONLY) == 0;
-}
-
-
-bool FileImpl::canExecuteImpl() const
-{
- Path p(_path);
- return icompare(p.getExtension(), "exe") == 0;
-}
-
-
-bool FileImpl::isFileImpl() const
-{
- return !isDirectoryImpl() && !isDeviceImpl();
-}
-
-
-bool FileImpl::isDirectoryImpl() const
-{
- poco_assert (!_path.empty());
-
- DWORD attr = GetFileAttributes(_path.c_str());
- if (attr == INVALID_FILE_ATTRIBUTES)
- handleLastErrorImpl(_path);
- return (attr & FILE_ATTRIBUTE_DIRECTORY) != 0;
-}
-
-
-bool FileImpl::isLinkImpl() const
-{
- poco_assert (!_path.empty());
-
- DWORD attr = GetFileAttributes(_path.c_str());
- if (attr == INVALID_FILE_ATTRIBUTES)
- handleLastErrorImpl(_path);
- return (attr & FILE_ATTRIBUTE_DIRECTORY) == 0 && (attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0;
-}
-
-
-
-bool FileImpl::isDeviceImpl() const
-{
- return
- _path.compare(0, 4, "\\\\.\\") == 0 ||
- icompare(_path, "CON") == 0 ||
- icompare(_path, "PRN") == 0 ||
- icompare(_path, "AUX") == 0 ||
- icompare(_path, "NUL") == 0 ||
- ( (icompare(_path, 0, 3, "LPT") == 0 || icompare(_path, 0, 3, "COM") == 0) &&
- _path.size() == 4 &&
- _path[3] > 0x30 &&
- isdigit(_path[3])
- );
-}
-
-
-bool FileImpl::isHiddenImpl() const
-{
- poco_assert (!_path.empty());
-
- DWORD attr = GetFileAttributes(_path.c_str());
- if (attr == INVALID_FILE_ATTRIBUTES)
- handleLastErrorImpl(_path);
- return (attr & FILE_ATTRIBUTE_HIDDEN) != 0;
-}
-
-
-Timestamp FileImpl::createdImpl() const
-{
- poco_assert (!_path.empty());
-
- WIN32_FILE_ATTRIBUTE_DATA fad;
- if (GetFileAttributesEx(_path.c_str(), GetFileExInfoStandard, &fad) == 0)
- handleLastErrorImpl(_path);
- return Timestamp::fromFileTimeNP(fad.ftCreationTime.dwLowDateTime, fad.ftCreationTime.dwHighDateTime);
-}
-
-
-Timestamp FileImpl::getLastModifiedImpl() const
-{
- poco_assert (!_path.empty());
-
- WIN32_FILE_ATTRIBUTE_DATA fad;
- if (GetFileAttributesEx(_path.c_str(), GetFileExInfoStandard, &fad) == 0)
- handleLastErrorImpl(_path);
- return Timestamp::fromFileTimeNP(fad.ftLastWriteTime.dwLowDateTime, fad.ftLastWriteTime.dwHighDateTime);
-}
-
-
-void FileImpl::setLastModifiedImpl(const Timestamp& ts)
-{
- poco_assert (!_path.empty());
-
- UInt32 low;
- UInt32 high;
- ts.toFileTimeNP(low, high);
- FILETIME ft;
- ft.dwLowDateTime = low;
- ft.dwHighDateTime = high;
- FileHandle fh(_path, FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING);
- if (SetFileTime(fh.get(), 0, &ft, &ft) == 0)
- handleLastErrorImpl(_path);
-}
-
-
-FileImpl::FileSizeImpl FileImpl::getSizeImpl() const
-{
- poco_assert (!_path.empty());
-
- WIN32_FILE_ATTRIBUTE_DATA fad;
- if (GetFileAttributesEx(_path.c_str(), GetFileExInfoStandard, &fad) == 0)
- handleLastErrorImpl(_path);
- LARGE_INTEGER li;
- li.LowPart = fad.nFileSizeLow;
- li.HighPart = fad.nFileSizeHigh;
- return li.QuadPart;
-}
-
-
-void FileImpl::setSizeImpl(FileSizeImpl size)
-{
- poco_assert (!_path.empty());
-
- FileHandle fh(_path, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING);
- LARGE_INTEGER li;
- li.QuadPart = size;
- if (SetFilePointer(fh.get(), li.LowPart, &li.HighPart, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
- handleLastErrorImpl(_path);
- if (SetEndOfFile(fh.get()) == 0)
- handleLastErrorImpl(_path);
-}
-
-
-void FileImpl::setWriteableImpl(bool flag)
-{
- poco_assert (!_path.empty());
-
- DWORD attr = GetFileAttributes(_path.c_str());
- if (attr == -1)
- handleLastErrorImpl(_path);
- if (flag)
- attr &= ~FILE_ATTRIBUTE_READONLY;
- else
- attr |= FILE_ATTRIBUTE_READONLY;
- if (SetFileAttributes(_path.c_str(), attr) == 0)
- handleLastErrorImpl(_path);
-}
-
-
-void FileImpl::setExecutableImpl(bool /*flag*/)
-{
- // not supported
-}
-
-
-void FileImpl::copyToImpl(const std::string& path) const
-{
- poco_assert (!_path.empty());
-
- if (CopyFileA(_path.c_str(), path.c_str(), FALSE) == 0)
- handleLastErrorImpl(_path);
-}
-
-
-void FileImpl::renameToImpl(const std::string& path)
-{
- poco_assert (!_path.empty());
-
- if (MoveFileExA(_path.c_str(), path.c_str(), MOVEFILE_REPLACE_EXISTING) == 0)
- handleLastErrorImpl(_path);
-}
-
-
-void FileImpl::linkToImpl(const std::string& path, int type) const
-{
- poco_assert (!_path.empty());
-
- if (type == 0)
- {
- if (CreateHardLinkA(path.c_str(), _path.c_str(), NULL) == 0)
- handleLastErrorImpl(_path);
- }
- else
- {
-#if _WIN32_WINNT >= 0x0600 && defined(SYMBOLIC_LINK_FLAG_DIRECTORY)
- DWORD flags = 0;
- if (isDirectoryImpl()) flags |= SYMBOLIC_LINK_FLAG_DIRECTORY;
-#ifdef SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE
- flags |= SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE;
-#endif
- if (CreateSymbolicLinkA(path.c_str(), _path.c_str(), flags) == 0)
- handleLastErrorImpl(_path);
-#else
- throw Poco::NotImplementedException("Symbolic link support not available in used version of the Windows SDK")
-#endif
-
- }
-}
-
-
-void FileImpl::removeImpl()
-{
- poco_assert (!_path.empty());
-
- if (isDirectoryImpl())
- {
- if (RemoveDirectoryA(_path.c_str()) == 0)
- handleLastErrorImpl(_path);
- }
- else
- {
- if (DeleteFileA(_path.c_str()) == 0)
- handleLastErrorImpl(_path);
- }
-}
-
-
-bool FileImpl::createFileImpl()
-{
- poco_assert (!_path.empty());
-
- HANDLE hFile = CreateFileA(_path.c_str(), GENERIC_WRITE, 0, 0, CREATE_NEW, 0, 0);
- if (hFile != INVALID_HANDLE_VALUE)
- {
- CloseHandle(hFile);
- return true;
- }
- else if (GetLastError() == ERROR_FILE_EXISTS)
- return false;
- else
- handleLastErrorImpl(_path);
- return false;
-}
-
-
-bool FileImpl::createDirectoryImpl()
-{
- poco_assert (!_path.empty());
-
- if (existsImpl() && isDirectoryImpl())
- return false;
- if (CreateDirectoryA(_path.c_str(), 0) == 0)
- handleLastErrorImpl(_path);
- return true;
-}
-
-
-FileImpl::FileSizeImpl FileImpl::totalSpaceImpl() const
-{
- poco_assert(!_path.empty());
-
- ULARGE_INTEGER space;
- if (!GetDiskFreeSpaceExA(_path.c_str(), NULL, &space, NULL))
- handleLastErrorImpl(_path);
- return space.QuadPart;
-}
-
-
-FileImpl::FileSizeImpl FileImpl::usableSpaceImpl() const
-{
- poco_assert(!_path.empty());
-
- ULARGE_INTEGER space;
- if (!GetDiskFreeSpaceExA(upath.c_str(), &space, NULL, NULL))
- handleLastErrorImpl(_path);
- return space.QuadPart;
-}
-
-
-FileImpl::FileSizeImpl FileImpl::freeSpaceImpl() const
-{
- poco_assert(!_path.empty());
-
- ULARGE_INTEGER space;
- if (!GetDiskFreeSpaceExA(_path.c_str(), NULL, NULL, &space))
- handleLastErrorImpl(_path);
- return space.QuadPart;
-}
-
-
-void FileImpl::handleLastErrorImpl(const std::string& path)
-{
- DWORD err = GetLastError();
- switch (err)
- {
- case ERROR_FILE_NOT_FOUND:
- throw FileNotFoundException(path, err);
- case ERROR_PATH_NOT_FOUND:
- case ERROR_BAD_NETPATH:
- case ERROR_CANT_RESOLVE_FILENAME:
- case ERROR_INVALID_DRIVE:
- throw PathNotFoundException(path, err);
- case ERROR_ACCESS_DENIED:
- throw FileAccessDeniedException(path, err);
- case ERROR_ALREADY_EXISTS:
- case ERROR_FILE_EXISTS:
- throw FileExistsException(path, err);
- case ERROR_INVALID_NAME:
- case ERROR_DIRECTORY:
- case ERROR_FILENAME_EXCED_RANGE:
- case ERROR_BAD_PATHNAME:
- throw PathSyntaxException(path, err);
- case ERROR_FILE_READ_ONLY:
- throw FileReadOnlyException(path, err);
- case ERROR_CANNOT_MAKE:
- throw CreateFileException(path, err);
- case ERROR_DIR_NOT_EMPTY:
- throw DirectoryNotEmptyException(path, err);
- case ERROR_WRITE_FAULT:
- throw WriteFileException(path, err);
- case ERROR_READ_FAULT:
- throw ReadFileException(path, err);
- case ERROR_SHARING_VIOLATION:
- throw FileException("sharing violation", path, err);
- case ERROR_LOCK_VIOLATION:
- throw FileException("lock violation", path, err);
- case ERROR_HANDLE_EOF:
- throw ReadFileException("EOF reached", path, err);
- case ERROR_HANDLE_DISK_FULL:
- case ERROR_DISK_FULL:
- throw WriteFileException("disk is full", path, err);
- case ERROR_NEGATIVE_SEEK:
- throw FileException("negative seek", path, err);
- default:
- throw FileException(path, err);
- }
-}
-
-
-} // namespace Poco
+//
+// File_WIN32.cpp
+//
+// Library: Foundation
+// Package: Filesystem
+// Module: File
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/File_WIN32.h"
+#include "Poco/Exception.h"
+#include "Poco/String.h"
+#include "Poco/UnWindows.h"
+
+
+namespace Poco {
+
+
+class FileHandle
+{
+public:
+ FileHandle(const std::string& path, DWORD access, DWORD share, DWORD disp)
+ {
+ _h = CreateFileA(path.c_str(), access, share, 0, disp, 0, 0);
+ if (_h == INVALID_HANDLE_VALUE)
+ {
+ FileImpl::handleLastErrorImpl(path);
+ }
+ }
+
+ ~FileHandle()
+ {
+ if (_h != INVALID_HANDLE_VALUE) CloseHandle(_h);
+ }
+
+ HANDLE get() const
+ {
+ return _h;
+ }
+
+private:
+ HANDLE _h;
+};
+
+
+FileImpl::FileImpl()
+{
+}
+
+
+FileImpl::FileImpl(const std::string& path): _path(path)
+{
+ std::string::size_type n = _path.size();
+ if (n > 1 && (_path[n - 1] == '\\' || _path[n - 1] == '/') && !((n == 3 && _path[1]==':')))
+ {
+ _path.resize(n - 1);
+ }
+}
+
+
+FileImpl::~FileImpl()
+{
+}
+
+
+void FileImpl::swapImpl(FileImpl& file)
+{
+ std::swap(_path, file._path);
+}
+
+
+void FileImpl::setPathImpl(const std::string& path)
+{
+ _path = path;
+ std::string::size_type n = _path.size();
+ if (n > 1 && (_path[n - 1] == '\\' || _path[n - 1] == '/') && !((n == 3 && _path[1]==':')))
+ {
+ _path.resize(n - 1);
+ }
+}
+
+
+bool FileImpl::existsImpl() const
+{
+ poco_assert (!_path.empty());
+
+ DWORD attr = GetFileAttributes(_path.c_str());
+ if (attr == INVALID_FILE_ATTRIBUTES)
+ {
+ switch (GetLastError())
+ {
+ case ERROR_FILE_NOT_FOUND:
+ case ERROR_PATH_NOT_FOUND:
+ case ERROR_NOT_READY:
+ case ERROR_INVALID_DRIVE:
+ return false;
+ default:
+ handleLastErrorImpl(_path);
+ }
+ }
+ return true;
+}
+
+
+bool FileImpl::canReadImpl() const
+{
+ poco_assert (!_path.empty());
+
+ DWORD attr = GetFileAttributes(_path.c_str());
+ if (attr == INVALID_FILE_ATTRIBUTES)
+ {
+ switch (GetLastError())
+ {
+ case ERROR_ACCESS_DENIED:
+ return false;
+ default:
+ handleLastErrorImpl(_path);
+ }
+ }
+ return true;
+}
+
+
+bool FileImpl::canWriteImpl() const
+{
+ poco_assert (!_path.empty());
+
+ DWORD attr = GetFileAttributes(_path.c_str());
+ if (attr == INVALID_FILE_ATTRIBUTES)
+ handleLastErrorImpl(_path);
+ return (attr & FILE_ATTRIBUTE_READONLY) == 0;
+}
+
+
+bool FileImpl::canExecuteImpl() const
+{
+ Path p(_path);
+ return icompare(p.getExtension(), "exe") == 0;
+}
+
+
+bool FileImpl::isFileImpl() const
+{
+ return !isDirectoryImpl() && !isDeviceImpl();
+}
+
+
+bool FileImpl::isDirectoryImpl() const
+{
+ poco_assert (!_path.empty());
+
+ DWORD attr = GetFileAttributes(_path.c_str());
+ if (attr == INVALID_FILE_ATTRIBUTES)
+ handleLastErrorImpl(_path);
+ return (attr & FILE_ATTRIBUTE_DIRECTORY) != 0;
+}
+
+
+bool FileImpl::isLinkImpl() const
+{
+ poco_assert (!_path.empty());
+
+ DWORD attr = GetFileAttributes(_path.c_str());
+ if (attr == INVALID_FILE_ATTRIBUTES)
+ handleLastErrorImpl(_path);
+ return (attr & FILE_ATTRIBUTE_DIRECTORY) == 0 && (attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0;
+}
+
+
+
+bool FileImpl::isDeviceImpl() const
+{
+ return
+ _path.compare(0, 4, "\\\\.\\") == 0 ||
+ icompare(_path, "CON") == 0 ||
+ icompare(_path, "PRN") == 0 ||
+ icompare(_path, "AUX") == 0 ||
+ icompare(_path, "NUL") == 0 ||
+ ( (icompare(_path, 0, 3, "LPT") == 0 || icompare(_path, 0, 3, "COM") == 0) &&
+ _path.size() == 4 &&
+ _path[3] > 0x30 &&
+ isdigit(_path[3])
+ );
+}
+
+
+bool FileImpl::isHiddenImpl() const
+{
+ poco_assert (!_path.empty());
+
+ DWORD attr = GetFileAttributes(_path.c_str());
+ if (attr == INVALID_FILE_ATTRIBUTES)
+ handleLastErrorImpl(_path);
+ return (attr & FILE_ATTRIBUTE_HIDDEN) != 0;
+}
+
+
+Timestamp FileImpl::createdImpl() const
+{
+ poco_assert (!_path.empty());
+
+ WIN32_FILE_ATTRIBUTE_DATA fad;
+ if (GetFileAttributesEx(_path.c_str(), GetFileExInfoStandard, &fad) == 0)
+ handleLastErrorImpl(_path);
+ return Timestamp::fromFileTimeNP(fad.ftCreationTime.dwLowDateTime, fad.ftCreationTime.dwHighDateTime);
+}
+
+
+Timestamp FileImpl::getLastModifiedImpl() const
+{
+ poco_assert (!_path.empty());
+
+ WIN32_FILE_ATTRIBUTE_DATA fad;
+ if (GetFileAttributesEx(_path.c_str(), GetFileExInfoStandard, &fad) == 0)
+ handleLastErrorImpl(_path);
+ return Timestamp::fromFileTimeNP(fad.ftLastWriteTime.dwLowDateTime, fad.ftLastWriteTime.dwHighDateTime);
+}
+
+
+void FileImpl::setLastModifiedImpl(const Timestamp& ts)
+{
+ poco_assert (!_path.empty());
+
+ UInt32 low;
+ UInt32 high;
+ ts.toFileTimeNP(low, high);
+ FILETIME ft;
+ ft.dwLowDateTime = low;
+ ft.dwHighDateTime = high;
+ FileHandle fh(_path, FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING);
+ if (SetFileTime(fh.get(), 0, &ft, &ft) == 0)
+ handleLastErrorImpl(_path);
+}
+
+
+FileImpl::FileSizeImpl FileImpl::getSizeImpl() const
+{
+ poco_assert (!_path.empty());
+
+ WIN32_FILE_ATTRIBUTE_DATA fad;
+ if (GetFileAttributesEx(_path.c_str(), GetFileExInfoStandard, &fad) == 0)
+ handleLastErrorImpl(_path);
+ LARGE_INTEGER li;
+ li.LowPart = fad.nFileSizeLow;
+ li.HighPart = fad.nFileSizeHigh;
+ return li.QuadPart;
+}
+
+
+void FileImpl::setSizeImpl(FileSizeImpl size)
+{
+ poco_assert (!_path.empty());
+
+ FileHandle fh(_path, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING);
+ LARGE_INTEGER li;
+ li.QuadPart = size;
+ if (SetFilePointer(fh.get(), li.LowPart, &li.HighPart, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
+ handleLastErrorImpl(_path);
+ if (SetEndOfFile(fh.get()) == 0)
+ handleLastErrorImpl(_path);
+}
+
+
+void FileImpl::setWriteableImpl(bool flag)
+{
+ poco_assert (!_path.empty());
+
+ DWORD attr = GetFileAttributes(_path.c_str());
+ if (attr == -1)
+ handleLastErrorImpl(_path);
+ if (flag)
+ attr &= ~FILE_ATTRIBUTE_READONLY;
+ else
+ attr |= FILE_ATTRIBUTE_READONLY;
+ if (SetFileAttributes(_path.c_str(), attr) == 0)
+ handleLastErrorImpl(_path);
+}
+
+
+void FileImpl::setExecutableImpl(bool /*flag*/)
+{
+ // not supported
+}
+
+
+void FileImpl::copyToImpl(const std::string& path) const
+{
+ poco_assert (!_path.empty());
+
+ if (CopyFileA(_path.c_str(), path.c_str(), FALSE) == 0)
+ handleLastErrorImpl(_path);
+}
+
+
+void FileImpl::renameToImpl(const std::string& path)
+{
+ poco_assert (!_path.empty());
+
+ if (MoveFileExA(_path.c_str(), path.c_str(), MOVEFILE_REPLACE_EXISTING) == 0)
+ handleLastErrorImpl(_path);
+}
+
+
+void FileImpl::linkToImpl(const std::string& path, int type) const
+{
+ poco_assert (!_path.empty());
+
+ if (type == 0)
+ {
+ if (CreateHardLinkA(path.c_str(), _path.c_str(), NULL) == 0)
+ handleLastErrorImpl(_path);
+ }
+ else
+ {
+#if _WIN32_WINNT >= 0x0600 && defined(SYMBOLIC_LINK_FLAG_DIRECTORY)
+ DWORD flags = 0;
+ if (isDirectoryImpl()) flags |= SYMBOLIC_LINK_FLAG_DIRECTORY;
+#ifdef SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE
+ flags |= SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE;
+#endif
+ if (CreateSymbolicLinkA(path.c_str(), _path.c_str(), flags) == 0)
+ handleLastErrorImpl(_path);
+#else
+ throw Poco::NotImplementedException("Symbolic link support not available in used version of the Windows SDK")
+#endif
+
+ }
+}
+
+
+void FileImpl::removeImpl()
+{
+ poco_assert (!_path.empty());
+
+ if (isDirectoryImpl())
+ {
+ if (RemoveDirectoryA(_path.c_str()) == 0)
+ handleLastErrorImpl(_path);
+ }
+ else
+ {
+ if (DeleteFileA(_path.c_str()) == 0)
+ handleLastErrorImpl(_path);
+ }
+}
+
+
+bool FileImpl::createFileImpl()
+{
+ poco_assert (!_path.empty());
+
+ HANDLE hFile = CreateFileA(_path.c_str(), GENERIC_WRITE, 0, 0, CREATE_NEW, 0, 0);
+ if (hFile != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle(hFile);
+ return true;
+ }
+ else if (GetLastError() == ERROR_FILE_EXISTS)
+ return false;
+ else
+ handleLastErrorImpl(_path);
+ return false;
+}
+
+
+bool FileImpl::createDirectoryImpl()
+{
+ poco_assert (!_path.empty());
+
+ if (existsImpl() && isDirectoryImpl())
+ return false;
+ if (CreateDirectoryA(_path.c_str(), 0) == 0)
+ handleLastErrorImpl(_path);
+ return true;
+}
+
+
+FileImpl::FileSizeImpl FileImpl::totalSpaceImpl() const
+{
+ poco_assert(!_path.empty());
+
+ ULARGE_INTEGER space;
+ if (!GetDiskFreeSpaceExA(_path.c_str(), NULL, &space, NULL))
+ handleLastErrorImpl(_path);
+ return space.QuadPart;
+}
+
+
+FileImpl::FileSizeImpl FileImpl::usableSpaceImpl() const
+{
+ poco_assert(!_path.empty());
+
+ ULARGE_INTEGER space;
+ if (!GetDiskFreeSpaceExA(upath.c_str(), &space, NULL, NULL))
+ handleLastErrorImpl(_path);
+ return space.QuadPart;
+}
+
+
+FileImpl::FileSizeImpl FileImpl::freeSpaceImpl() const
+{
+ poco_assert(!_path.empty());
+
+ ULARGE_INTEGER space;
+ if (!GetDiskFreeSpaceExA(_path.c_str(), NULL, NULL, &space))
+ handleLastErrorImpl(_path);
+ return space.QuadPart;
+}
+
+
+void FileImpl::handleLastErrorImpl(const std::string& path)
+{
+ DWORD err = GetLastError();
+ switch (err)
+ {
+ case ERROR_FILE_NOT_FOUND:
+ throw FileNotFoundException(path, err);
+ case ERROR_PATH_NOT_FOUND:
+ case ERROR_BAD_NETPATH:
+ case ERROR_CANT_RESOLVE_FILENAME:
+ case ERROR_INVALID_DRIVE:
+ throw PathNotFoundException(path, err);
+ case ERROR_ACCESS_DENIED:
+ throw FileAccessDeniedException(path, err);
+ case ERROR_ALREADY_EXISTS:
+ case ERROR_FILE_EXISTS:
+ throw FileExistsException(path, err);
+ case ERROR_INVALID_NAME:
+ case ERROR_DIRECTORY:
+ case ERROR_FILENAME_EXCED_RANGE:
+ case ERROR_BAD_PATHNAME:
+ throw PathSyntaxException(path, err);
+ case ERROR_FILE_READ_ONLY:
+ throw FileReadOnlyException(path, err);
+ case ERROR_CANNOT_MAKE:
+ throw CreateFileException(path, err);
+ case ERROR_DIR_NOT_EMPTY:
+ throw DirectoryNotEmptyException(path, err);
+ case ERROR_WRITE_FAULT:
+ throw WriteFileException(path, err);
+ case ERROR_READ_FAULT:
+ throw ReadFileException(path, err);
+ case ERROR_SHARING_VIOLATION:
+ throw FileException("sharing violation", path, err);
+ case ERROR_LOCK_VIOLATION:
+ throw FileException("lock violation", path, err);
+ case ERROR_HANDLE_EOF:
+ throw ReadFileException("EOF reached", path, err);
+ case ERROR_HANDLE_DISK_FULL:
+ case ERROR_DISK_FULL:
+ throw WriteFileException("disk is full", path, err);
+ case ERROR_NEGATIVE_SEEK:
+ throw FileException("negative seek", path, err);
+ default:
+ throw FileException(path, err);
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/File_WIN32U.cpp b/contrib/libs/poco/Foundation/src/File_WIN32U.cpp
index f8609f17c0..15b80276cd 100644
--- a/contrib/libs/poco/Foundation/src/File_WIN32U.cpp
+++ b/contrib/libs/poco/Foundation/src/File_WIN32U.cpp
@@ -1,492 +1,492 @@
-//
-// File_WIN32U.cpp
-//
-// Library: Foundation
-// Package: Filesystem
-// Module: File
-//
-// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/File_WIN32U.h"
-#include "Poco/Exception.h"
-#include "Poco/String.h"
-#include "Poco/UnicodeConverter.h"
-#include "Poco/UnWindows.h"
-
-
-namespace Poco {
-
-
-class FileHandle
-{
-public:
- FileHandle(const std::string& path, const std::wstring& upath, DWORD access, DWORD share, DWORD disp)
- {
- _h = CreateFileW(upath.c_str(), access, share, 0, disp, 0, 0);
- if (_h == INVALID_HANDLE_VALUE)
- {
- FileImpl::handleLastErrorImpl(path);
- }
- }
-
- ~FileHandle()
- {
- if (_h != INVALID_HANDLE_VALUE) CloseHandle(_h);
- }
-
- HANDLE get() const
- {
- return _h;
- }
-
-private:
- HANDLE _h;
-};
-
-
-FileImpl::FileImpl()
-{
-}
-
-
-FileImpl::FileImpl(const std::string& path): _path(path)
-{
- std::string::size_type n = _path.size();
- if (n > 1 && (_path[n - 1] == '\\' || _path[n - 1] == '/') && !((n == 3 && _path[1]==':')))
- {
- _path.resize(n - 1);
- }
- convertPath(_path, _upath);
-}
-
-
-FileImpl::~FileImpl()
-{
-}
-
-
-void FileImpl::swapImpl(FileImpl& file)
-{
- std::swap(_path, file._path);
- std::swap(_upath, file._upath);
-}
-
-
-void FileImpl::setPathImpl(const std::string& path)
-{
- _path = path;
- std::string::size_type n = _path.size();
- if (n > 1 && (_path[n - 1] == '\\' || _path[n - 1] == '/') && !((n == 3 && _path[1]==':')))
- {
- _path.resize(n - 1);
- }
- convertPath(_path, _upath);
-}
-
-
-bool FileImpl::existsImpl() const
-{
- poco_assert (!_path.empty());
-
- DWORD attr = GetFileAttributesW(_upath.c_str());
- if (attr == INVALID_FILE_ATTRIBUTES)
- {
- switch (GetLastError())
- {
- case ERROR_FILE_NOT_FOUND:
- case ERROR_PATH_NOT_FOUND:
- case ERROR_NOT_READY:
- case ERROR_INVALID_DRIVE:
- return false;
- default:
- handleLastErrorImpl(_path);
- }
- }
- return true;
-}
-
-
-bool FileImpl::canReadImpl() const
-{
- poco_assert (!_path.empty());
-
- DWORD attr = GetFileAttributesW(_upath.c_str());
- if (attr == INVALID_FILE_ATTRIBUTES)
- {
- switch (GetLastError())
- {
- case ERROR_ACCESS_DENIED:
- return false;
- default:
- handleLastErrorImpl(_path);
- }
- }
- return true;
-}
-
-
-bool FileImpl::canWriteImpl() const
-{
- poco_assert (!_path.empty());
-
- DWORD attr = GetFileAttributesW(_upath.c_str());
- if (attr == INVALID_FILE_ATTRIBUTES)
- handleLastErrorImpl(_path);
- return (attr & FILE_ATTRIBUTE_READONLY) == 0;
-}
-
-
-bool FileImpl::canExecuteImpl() const
-{
- Path p(_path);
- return icompare(p.getExtension(), "exe") == 0;
-}
-
-
-bool FileImpl::isFileImpl() const
-{
- return !isDirectoryImpl() && !isDeviceImpl();
-}
-
-
-bool FileImpl::isDirectoryImpl() const
-{
- poco_assert (!_path.empty());
-
- DWORD attr = GetFileAttributesW(_upath.c_str());
- if (attr == INVALID_FILE_ATTRIBUTES)
- handleLastErrorImpl(_path);
- return (attr & FILE_ATTRIBUTE_DIRECTORY) != 0;
-}
-
-
-bool FileImpl::isLinkImpl() const
-{
- poco_assert (!_path.empty());
-
- DWORD attr = GetFileAttributesW(_upath.c_str());
- if (attr == INVALID_FILE_ATTRIBUTES)
- handleLastErrorImpl(_path);
- return (attr & FILE_ATTRIBUTE_DIRECTORY) == 0 && (attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0;
-}
-
-
-bool FileImpl::isDeviceImpl() const
-{
- return
- _path.compare(0, 4, "\\\\.\\") == 0 ||
- icompare(_path, "CON") == 0 ||
- icompare(_path, "PRN") == 0 ||
- icompare(_path, "AUX") == 0 ||
- icompare(_path, "NUL") == 0 ||
- ( (icompare(_path, 0, 3, "LPT") == 0 || icompare(_path, 0, 3, "COM") == 0) &&
- _path.size() == 4 &&
- _path[3] > 0x30 &&
- isdigit(_path[3])
- );
-}
-
-
-bool FileImpl::isHiddenImpl() const
-{
- poco_assert (!_path.empty());
-
- DWORD attr = GetFileAttributesW(_upath.c_str());
- if (attr == INVALID_FILE_ATTRIBUTES)
- handleLastErrorImpl(_path);
- return (attr & FILE_ATTRIBUTE_HIDDEN) != 0;
-}
-
-
-Timestamp FileImpl::createdImpl() const
-{
- poco_assert (!_path.empty());
-
- WIN32_FILE_ATTRIBUTE_DATA fad;
- if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0)
- handleLastErrorImpl(_path);
- return Timestamp::fromFileTimeNP(fad.ftCreationTime.dwLowDateTime, fad.ftCreationTime.dwHighDateTime);
-}
-
-
-Timestamp FileImpl::getLastModifiedImpl() const
-{
- poco_assert (!_path.empty());
-
- WIN32_FILE_ATTRIBUTE_DATA fad;
- if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0)
- handleLastErrorImpl(_path);
- return Timestamp::fromFileTimeNP(fad.ftLastWriteTime.dwLowDateTime, fad.ftLastWriteTime.dwHighDateTime);
-}
-
-
-void FileImpl::setLastModifiedImpl(const Timestamp& ts)
-{
- poco_assert (!_path.empty());
-
- UInt32 low;
- UInt32 high;
- ts.toFileTimeNP(low, high);
- FILETIME ft;
- ft.dwLowDateTime = low;
- ft.dwHighDateTime = high;
- FileHandle fh(_path, _upath, FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING);
- if (SetFileTime(fh.get(), 0, &ft, &ft) == 0)
- handleLastErrorImpl(_path);
-}
-
-
-FileImpl::FileSizeImpl FileImpl::getSizeImpl() const
-{
- poco_assert (!_path.empty());
-
- WIN32_FILE_ATTRIBUTE_DATA fad;
- if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0)
- handleLastErrorImpl(_path);
- LARGE_INTEGER li;
- li.LowPart = fad.nFileSizeLow;
- li.HighPart = fad.nFileSizeHigh;
- return li.QuadPart;
-}
-
-
-void FileImpl::setSizeImpl(FileSizeImpl size)
-{
- poco_assert (!_path.empty());
-
- FileHandle fh(_path, _upath, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING);
- LARGE_INTEGER li;
- li.QuadPart = size;
- if (SetFilePointer(fh.get(), li.LowPart, &li.HighPart, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
- handleLastErrorImpl(_path);
- if (SetEndOfFile(fh.get()) == 0)
- handleLastErrorImpl(_path);
-}
-
-
-void FileImpl::setWriteableImpl(bool flag)
-{
- poco_assert (!_path.empty());
-
- DWORD attr = GetFileAttributesW(_upath.c_str());
- if (attr == -1)
- handleLastErrorImpl(_path);
- if (flag)
- attr &= ~FILE_ATTRIBUTE_READONLY;
- else
- attr |= FILE_ATTRIBUTE_READONLY;
- if (SetFileAttributesW(_upath.c_str(), attr) == 0)
- handleLastErrorImpl(_path);
-}
-
-
-void FileImpl::setExecutableImpl(bool flag)
-{
- // not supported
-}
-
-
-void FileImpl::copyToImpl(const std::string& path) const
-{
- poco_assert (!_path.empty());
-
- std::wstring upath;
- convertPath(path, upath);
- if (CopyFileW(_upath.c_str(), upath.c_str(), FALSE) == 0)
- handleLastErrorImpl(_path);
-}
-
-
-void FileImpl::renameToImpl(const std::string& path)
-{
- poco_assert (!_path.empty());
-
- std::wstring upath;
- convertPath(path, upath);
- if (MoveFileExW(_upath.c_str(), upath.c_str(), MOVEFILE_REPLACE_EXISTING) == 0)
- handleLastErrorImpl(_path);
-}
-
-
-void FileImpl::linkToImpl(const std::string& path, int type) const
-{
- poco_assert (!_path.empty());
-
- std::wstring upath;
- convertPath(path, upath);
-
- if (type == 0)
- {
- if (CreateHardLinkW(upath.c_str(), _upath.c_str(), NULL) == 0)
- handleLastErrorImpl(_path);
- }
- else
- {
-#if _WIN32_WINNT >= 0x0600 && defined(SYMBOLIC_LINK_FLAG_DIRECTORY)
- DWORD flags = 0;
- if (isDirectoryImpl()) flags |= SYMBOLIC_LINK_FLAG_DIRECTORY;
-#ifdef SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE
- flags |= SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE;
-#endif
- if (CreateSymbolicLinkW(upath.c_str(), _upath.c_str(), flags) == 0)
- handleLastErrorImpl(_path);
-#else
- throw Poco::NotImplementedException("Symbolic link support not available in used version of the Windows SDK");
-#endif
- }
-}
-
-
-void FileImpl::removeImpl()
-{
- poco_assert (!_path.empty());
-
- if (isDirectoryImpl())
- {
- if (RemoveDirectoryW(_upath.c_str()) == 0)
- handleLastErrorImpl(_path);
- }
- else
- {
- if (DeleteFileW(_upath.c_str()) == 0)
- handleLastErrorImpl(_path);
- }
-}
-
-
-bool FileImpl::createFileImpl()
-{
- poco_assert (!_path.empty());
-
- HANDLE hFile = CreateFileW(_upath.c_str(), GENERIC_WRITE, 0, 0, CREATE_NEW, 0, 0);
- if (hFile != INVALID_HANDLE_VALUE)
- {
- CloseHandle(hFile);
- return true;
- }
- else if (GetLastError() == ERROR_FILE_EXISTS)
- return false;
- else
- handleLastErrorImpl(_path);
- return false;
-}
-
-
-bool FileImpl::createDirectoryImpl()
-{
- poco_assert (!_path.empty());
-
- if (existsImpl() && isDirectoryImpl())
- return false;
- if (CreateDirectoryW(_upath.c_str(), 0) == 0)
- handleLastErrorImpl(_path);
- return true;
-}
-
-
-FileImpl::FileSizeImpl FileImpl::totalSpaceImpl() const
-{
- poco_assert(!_path.empty());
-
- ULARGE_INTEGER space;
- if (!GetDiskFreeSpaceExW(_upath.c_str(), NULL, &space, NULL))
- handleLastErrorImpl(_path);
- return space.QuadPart;
-}
-
-
-FileImpl::FileSizeImpl FileImpl::usableSpaceImpl() const
-{
- poco_assert(!_path.empty());
-
- ULARGE_INTEGER space;
- if (!GetDiskFreeSpaceExW(_upath.c_str(), &space, NULL, NULL))
- handleLastErrorImpl(_path);
- return space.QuadPart;
-}
-
-
-FileImpl::FileSizeImpl FileImpl::freeSpaceImpl() const
-{
- poco_assert(!_path.empty());
-
- ULARGE_INTEGER space;
- if (!GetDiskFreeSpaceExW(_upath.c_str(), NULL, NULL, &space))
- handleLastErrorImpl(_path);
- return space.QuadPart;
-}
-
-
-void FileImpl::handleLastErrorImpl(const std::string& path)
-{
- DWORD err = GetLastError();
- switch (err)
- {
- case ERROR_FILE_NOT_FOUND:
- throw FileNotFoundException(path, err);
- case ERROR_PATH_NOT_FOUND:
- case ERROR_BAD_NETPATH:
- case ERROR_CANT_RESOLVE_FILENAME:
- case ERROR_INVALID_DRIVE:
- throw PathNotFoundException(path, err);
- case ERROR_ACCESS_DENIED:
- throw FileAccessDeniedException(path, err);
- case ERROR_ALREADY_EXISTS:
- case ERROR_FILE_EXISTS:
- throw FileExistsException(path, err);
- case ERROR_INVALID_NAME:
- case ERROR_DIRECTORY:
- case ERROR_FILENAME_EXCED_RANGE:
- case ERROR_BAD_PATHNAME:
- throw PathSyntaxException(path, err);
- case ERROR_FILE_READ_ONLY:
- throw FileReadOnlyException(path, err);
- case ERROR_CANNOT_MAKE:
- throw CreateFileException(path, err);
- case ERROR_DIR_NOT_EMPTY:
- throw DirectoryNotEmptyException(path, err);
- case ERROR_WRITE_FAULT:
- throw WriteFileException(path, err);
- case ERROR_READ_FAULT:
- throw ReadFileException(path, err);
- case ERROR_SHARING_VIOLATION:
- throw FileException("sharing violation", path, err);
- case ERROR_LOCK_VIOLATION:
- throw FileException("lock violation", path, err);
- case ERROR_HANDLE_EOF:
- throw ReadFileException("EOF reached", path, err);
- case ERROR_HANDLE_DISK_FULL:
- case ERROR_DISK_FULL:
- throw WriteFileException("disk is full", path, err);
- case ERROR_NEGATIVE_SEEK:
- throw FileException("negative seek", path, err);
- default:
- throw FileException(path, err);
- }
-}
-
-
-void FileImpl::convertPath(const std::string& utf8Path, std::wstring& utf16Path)
-{
- UnicodeConverter::toUTF16(utf8Path, utf16Path);
- if (utf16Path.size() > MAX_PATH - 12) // Note: CreateDirectory has a limit of MAX_PATH - 12 (room for 8.3 file name)
- {
- if (utf16Path[0] == '\\' || utf16Path[1] == ':')
- {
- if (utf16Path.compare(0, 4, L"\\\\?\\", 4) != 0)
- {
- if (utf16Path[1] == '\\')
- utf16Path.insert(0, L"\\\\?\\UNC\\", 8);
- else
- utf16Path.insert(0, L"\\\\?\\", 4);
- }
- }
- }
-}
-
-} // namespace Poco
+//
+// File_WIN32U.cpp
+//
+// Library: Foundation
+// Package: Filesystem
+// Module: File
+//
+// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/File_WIN32U.h"
+#include "Poco/Exception.h"
+#include "Poco/String.h"
+#include "Poco/UnicodeConverter.h"
+#include "Poco/UnWindows.h"
+
+
+namespace Poco {
+
+
+class FileHandle
+{
+public:
+ FileHandle(const std::string& path, const std::wstring& upath, DWORD access, DWORD share, DWORD disp)
+ {
+ _h = CreateFileW(upath.c_str(), access, share, 0, disp, 0, 0);
+ if (_h == INVALID_HANDLE_VALUE)
+ {
+ FileImpl::handleLastErrorImpl(path);
+ }
+ }
+
+ ~FileHandle()
+ {
+ if (_h != INVALID_HANDLE_VALUE) CloseHandle(_h);
+ }
+
+ HANDLE get() const
+ {
+ return _h;
+ }
+
+private:
+ HANDLE _h;
+};
+
+
+FileImpl::FileImpl()
+{
+}
+
+
+FileImpl::FileImpl(const std::string& path): _path(path)
+{
+ std::string::size_type n = _path.size();
+ if (n > 1 && (_path[n - 1] == '\\' || _path[n - 1] == '/') && !((n == 3 && _path[1]==':')))
+ {
+ _path.resize(n - 1);
+ }
+ convertPath(_path, _upath);
+}
+
+
+FileImpl::~FileImpl()
+{
+}
+
+
+void FileImpl::swapImpl(FileImpl& file)
+{
+ std::swap(_path, file._path);
+ std::swap(_upath, file._upath);
+}
+
+
+void FileImpl::setPathImpl(const std::string& path)
+{
+ _path = path;
+ std::string::size_type n = _path.size();
+ if (n > 1 && (_path[n - 1] == '\\' || _path[n - 1] == '/') && !((n == 3 && _path[1]==':')))
+ {
+ _path.resize(n - 1);
+ }
+ convertPath(_path, _upath);
+}
+
+
+bool FileImpl::existsImpl() const
+{
+ poco_assert (!_path.empty());
+
+ DWORD attr = GetFileAttributesW(_upath.c_str());
+ if (attr == INVALID_FILE_ATTRIBUTES)
+ {
+ switch (GetLastError())
+ {
+ case ERROR_FILE_NOT_FOUND:
+ case ERROR_PATH_NOT_FOUND:
+ case ERROR_NOT_READY:
+ case ERROR_INVALID_DRIVE:
+ return false;
+ default:
+ handleLastErrorImpl(_path);
+ }
+ }
+ return true;
+}
+
+
+bool FileImpl::canReadImpl() const
+{
+ poco_assert (!_path.empty());
+
+ DWORD attr = GetFileAttributesW(_upath.c_str());
+ if (attr == INVALID_FILE_ATTRIBUTES)
+ {
+ switch (GetLastError())
+ {
+ case ERROR_ACCESS_DENIED:
+ return false;
+ default:
+ handleLastErrorImpl(_path);
+ }
+ }
+ return true;
+}
+
+
+bool FileImpl::canWriteImpl() const
+{
+ poco_assert (!_path.empty());
+
+ DWORD attr = GetFileAttributesW(_upath.c_str());
+ if (attr == INVALID_FILE_ATTRIBUTES)
+ handleLastErrorImpl(_path);
+ return (attr & FILE_ATTRIBUTE_READONLY) == 0;
+}
+
+
+bool FileImpl::canExecuteImpl() const
+{
+ Path p(_path);
+ return icompare(p.getExtension(), "exe") == 0;
+}
+
+
+bool FileImpl::isFileImpl() const
+{
+ return !isDirectoryImpl() && !isDeviceImpl();
+}
+
+
+bool FileImpl::isDirectoryImpl() const
+{
+ poco_assert (!_path.empty());
+
+ DWORD attr = GetFileAttributesW(_upath.c_str());
+ if (attr == INVALID_FILE_ATTRIBUTES)
+ handleLastErrorImpl(_path);
+ return (attr & FILE_ATTRIBUTE_DIRECTORY) != 0;
+}
+
+
+bool FileImpl::isLinkImpl() const
+{
+ poco_assert (!_path.empty());
+
+ DWORD attr = GetFileAttributesW(_upath.c_str());
+ if (attr == INVALID_FILE_ATTRIBUTES)
+ handleLastErrorImpl(_path);
+ return (attr & FILE_ATTRIBUTE_DIRECTORY) == 0 && (attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0;
+}
+
+
+bool FileImpl::isDeviceImpl() const
+{
+ return
+ _path.compare(0, 4, "\\\\.\\") == 0 ||
+ icompare(_path, "CON") == 0 ||
+ icompare(_path, "PRN") == 0 ||
+ icompare(_path, "AUX") == 0 ||
+ icompare(_path, "NUL") == 0 ||
+ ( (icompare(_path, 0, 3, "LPT") == 0 || icompare(_path, 0, 3, "COM") == 0) &&
+ _path.size() == 4 &&
+ _path[3] > 0x30 &&
+ isdigit(_path[3])
+ );
+}
+
+
+bool FileImpl::isHiddenImpl() const
+{
+ poco_assert (!_path.empty());
+
+ DWORD attr = GetFileAttributesW(_upath.c_str());
+ if (attr == INVALID_FILE_ATTRIBUTES)
+ handleLastErrorImpl(_path);
+ return (attr & FILE_ATTRIBUTE_HIDDEN) != 0;
+}
+
+
+Timestamp FileImpl::createdImpl() const
+{
+ poco_assert (!_path.empty());
+
+ WIN32_FILE_ATTRIBUTE_DATA fad;
+ if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0)
+ handleLastErrorImpl(_path);
+ return Timestamp::fromFileTimeNP(fad.ftCreationTime.dwLowDateTime, fad.ftCreationTime.dwHighDateTime);
+}
+
+
+Timestamp FileImpl::getLastModifiedImpl() const
+{
+ poco_assert (!_path.empty());
+
+ WIN32_FILE_ATTRIBUTE_DATA fad;
+ if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0)
+ handleLastErrorImpl(_path);
+ return Timestamp::fromFileTimeNP(fad.ftLastWriteTime.dwLowDateTime, fad.ftLastWriteTime.dwHighDateTime);
+}
+
+
+void FileImpl::setLastModifiedImpl(const Timestamp& ts)
+{
+ poco_assert (!_path.empty());
+
+ UInt32 low;
+ UInt32 high;
+ ts.toFileTimeNP(low, high);
+ FILETIME ft;
+ ft.dwLowDateTime = low;
+ ft.dwHighDateTime = high;
+ FileHandle fh(_path, _upath, FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING);
+ if (SetFileTime(fh.get(), 0, &ft, &ft) == 0)
+ handleLastErrorImpl(_path);
+}
+
+
+FileImpl::FileSizeImpl FileImpl::getSizeImpl() const
+{
+ poco_assert (!_path.empty());
+
+ WIN32_FILE_ATTRIBUTE_DATA fad;
+ if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0)
+ handleLastErrorImpl(_path);
+ LARGE_INTEGER li;
+ li.LowPart = fad.nFileSizeLow;
+ li.HighPart = fad.nFileSizeHigh;
+ return li.QuadPart;
+}
+
+
+void FileImpl::setSizeImpl(FileSizeImpl size)
+{
+ poco_assert (!_path.empty());
+
+ FileHandle fh(_path, _upath, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING);
+ LARGE_INTEGER li;
+ li.QuadPart = size;
+ if (SetFilePointer(fh.get(), li.LowPart, &li.HighPart, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
+ handleLastErrorImpl(_path);
+ if (SetEndOfFile(fh.get()) == 0)
+ handleLastErrorImpl(_path);
+}
+
+
+void FileImpl::setWriteableImpl(bool flag)
+{
+ poco_assert (!_path.empty());
+
+ DWORD attr = GetFileAttributesW(_upath.c_str());
+ if (attr == -1)
+ handleLastErrorImpl(_path);
+ if (flag)
+ attr &= ~FILE_ATTRIBUTE_READONLY;
+ else
+ attr |= FILE_ATTRIBUTE_READONLY;
+ if (SetFileAttributesW(_upath.c_str(), attr) == 0)
+ handleLastErrorImpl(_path);
+}
+
+
+void FileImpl::setExecutableImpl(bool flag)
+{
+ // not supported
+}
+
+
+void FileImpl::copyToImpl(const std::string& path) const
+{
+ poco_assert (!_path.empty());
+
+ std::wstring upath;
+ convertPath(path, upath);
+ if (CopyFileW(_upath.c_str(), upath.c_str(), FALSE) == 0)
+ handleLastErrorImpl(_path);
+}
+
+
+void FileImpl::renameToImpl(const std::string& path)
+{
+ poco_assert (!_path.empty());
+
+ std::wstring upath;
+ convertPath(path, upath);
+ if (MoveFileExW(_upath.c_str(), upath.c_str(), MOVEFILE_REPLACE_EXISTING) == 0)
+ handleLastErrorImpl(_path);
+}
+
+
+void FileImpl::linkToImpl(const std::string& path, int type) const
+{
+ poco_assert (!_path.empty());
+
+ std::wstring upath;
+ convertPath(path, upath);
+
+ if (type == 0)
+ {
+ if (CreateHardLinkW(upath.c_str(), _upath.c_str(), NULL) == 0)
+ handleLastErrorImpl(_path);
+ }
+ else
+ {
+#if _WIN32_WINNT >= 0x0600 && defined(SYMBOLIC_LINK_FLAG_DIRECTORY)
+ DWORD flags = 0;
+ if (isDirectoryImpl()) flags |= SYMBOLIC_LINK_FLAG_DIRECTORY;
+#ifdef SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE
+ flags |= SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE;
+#endif
+ if (CreateSymbolicLinkW(upath.c_str(), _upath.c_str(), flags) == 0)
+ handleLastErrorImpl(_path);
+#else
+ throw Poco::NotImplementedException("Symbolic link support not available in used version of the Windows SDK");
+#endif
+ }
+}
+
+
+void FileImpl::removeImpl()
+{
+ poco_assert (!_path.empty());
+
+ if (isDirectoryImpl())
+ {
+ if (RemoveDirectoryW(_upath.c_str()) == 0)
+ handleLastErrorImpl(_path);
+ }
+ else
+ {
+ if (DeleteFileW(_upath.c_str()) == 0)
+ handleLastErrorImpl(_path);
+ }
+}
+
+
+bool FileImpl::createFileImpl()
+{
+ poco_assert (!_path.empty());
+
+ HANDLE hFile = CreateFileW(_upath.c_str(), GENERIC_WRITE, 0, 0, CREATE_NEW, 0, 0);
+ if (hFile != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle(hFile);
+ return true;
+ }
+ else if (GetLastError() == ERROR_FILE_EXISTS)
+ return false;
+ else
+ handleLastErrorImpl(_path);
+ return false;
+}
+
+
+bool FileImpl::createDirectoryImpl()
+{
+ poco_assert (!_path.empty());
+
+ if (existsImpl() && isDirectoryImpl())
+ return false;
+ if (CreateDirectoryW(_upath.c_str(), 0) == 0)
+ handleLastErrorImpl(_path);
+ return true;
+}
+
+
+FileImpl::FileSizeImpl FileImpl::totalSpaceImpl() const
+{
+ poco_assert(!_path.empty());
+
+ ULARGE_INTEGER space;
+ if (!GetDiskFreeSpaceExW(_upath.c_str(), NULL, &space, NULL))
+ handleLastErrorImpl(_path);
+ return space.QuadPart;
+}
+
+
+FileImpl::FileSizeImpl FileImpl::usableSpaceImpl() const
+{
+ poco_assert(!_path.empty());
+
+ ULARGE_INTEGER space;
+ if (!GetDiskFreeSpaceExW(_upath.c_str(), &space, NULL, NULL))
+ handleLastErrorImpl(_path);
+ return space.QuadPart;
+}
+
+
+FileImpl::FileSizeImpl FileImpl::freeSpaceImpl() const
+{
+ poco_assert(!_path.empty());
+
+ ULARGE_INTEGER space;
+ if (!GetDiskFreeSpaceExW(_upath.c_str(), NULL, NULL, &space))
+ handleLastErrorImpl(_path);
+ return space.QuadPart;
+}
+
+
+void FileImpl::handleLastErrorImpl(const std::string& path)
+{
+ DWORD err = GetLastError();
+ switch (err)
+ {
+ case ERROR_FILE_NOT_FOUND:
+ throw FileNotFoundException(path, err);
+ case ERROR_PATH_NOT_FOUND:
+ case ERROR_BAD_NETPATH:
+ case ERROR_CANT_RESOLVE_FILENAME:
+ case ERROR_INVALID_DRIVE:
+ throw PathNotFoundException(path, err);
+ case ERROR_ACCESS_DENIED:
+ throw FileAccessDeniedException(path, err);
+ case ERROR_ALREADY_EXISTS:
+ case ERROR_FILE_EXISTS:
+ throw FileExistsException(path, err);
+ case ERROR_INVALID_NAME:
+ case ERROR_DIRECTORY:
+ case ERROR_FILENAME_EXCED_RANGE:
+ case ERROR_BAD_PATHNAME:
+ throw PathSyntaxException(path, err);
+ case ERROR_FILE_READ_ONLY:
+ throw FileReadOnlyException(path, err);
+ case ERROR_CANNOT_MAKE:
+ throw CreateFileException(path, err);
+ case ERROR_DIR_NOT_EMPTY:
+ throw DirectoryNotEmptyException(path, err);
+ case ERROR_WRITE_FAULT:
+ throw WriteFileException(path, err);
+ case ERROR_READ_FAULT:
+ throw ReadFileException(path, err);
+ case ERROR_SHARING_VIOLATION:
+ throw FileException("sharing violation", path, err);
+ case ERROR_LOCK_VIOLATION:
+ throw FileException("lock violation", path, err);
+ case ERROR_HANDLE_EOF:
+ throw ReadFileException("EOF reached", path, err);
+ case ERROR_HANDLE_DISK_FULL:
+ case ERROR_DISK_FULL:
+ throw WriteFileException("disk is full", path, err);
+ case ERROR_NEGATIVE_SEEK:
+ throw FileException("negative seek", path, err);
+ default:
+ throw FileException(path, err);
+ }
+}
+
+
+void FileImpl::convertPath(const std::string& utf8Path, std::wstring& utf16Path)
+{
+ UnicodeConverter::toUTF16(utf8Path, utf16Path);
+ if (utf16Path.size() > MAX_PATH - 12) // Note: CreateDirectory has a limit of MAX_PATH - 12 (room for 8.3 file name)
+ {
+ if (utf16Path[0] == '\\' || utf16Path[1] == ':')
+ {
+ if (utf16Path.compare(0, 4, L"\\\\?\\", 4) != 0)
+ {
+ if (utf16Path[1] == '\\')
+ utf16Path.insert(0, L"\\\\?\\UNC\\", 8);
+ else
+ utf16Path.insert(0, L"\\\\?\\", 4);
+ }
+ }
+ }
+}
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/File_WINCE.cpp b/contrib/libs/poco/Foundation/src/File_WINCE.cpp
index ea726c4bcf..dd1b1c9748 100644
--- a/contrib/libs/poco/Foundation/src/File_WINCE.cpp
+++ b/contrib/libs/poco/Foundation/src/File_WINCE.cpp
@@ -1,441 +1,441 @@
-//
-// File_WIN32U.cpp
-//
-// Library: Foundation
-// Package: Filesystem
-// Module: File
-//
-// Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/File_WINCE.h"
-#include "Poco/Exception.h"
-#include "Poco/String.h"
-#include "Poco/UnicodeConverter.h"
-#include "Poco/Path.h"
-#include "Poco/UnWindows.h"
-
-
-namespace Poco {
-
-
-class FileHandle
-{
-public:
- FileHandle(const std::string& path, const std::wstring& upath, DWORD access, DWORD share, DWORD disp)
- {
- _h = CreateFileW(upath.c_str(), access, share, 0, disp, 0, 0);
- if (_h == INVALID_HANDLE_VALUE)
- {
- FileImpl::handleLastErrorImpl(path);
- }
- }
-
- ~FileHandle()
- {
- if (_h != INVALID_HANDLE_VALUE) CloseHandle(_h);
- }
-
- HANDLE get() const
- {
- return _h;
- }
-
-private:
- HANDLE _h;
-};
-
-
-FileImpl::FileImpl()
-{
-}
-
-
-FileImpl::FileImpl(const std::string& path): _path(path)
-{
- std::string::size_type n = _path.size();
- if (n > 1 && (_path[n - 1] == '\\' || _path[n - 1] == '/') && !((n == 3 && _path[1]==':')))
- {
- _path.resize(n - 1);
- }
- convertPath(_path, _upath);
-}
-
-
-FileImpl::~FileImpl()
-{
-}
-
-
-void FileImpl::swapImpl(FileImpl& file)
-{
- std::swap(_path, file._path);
- std::swap(_upath, file._upath);
-}
-
-
-void FileImpl::setPathImpl(const std::string& path)
-{
- _path = path;
- std::string::size_type n = _path.size();
- if (n > 1 && (_path[n - 1] == '\\' || _path[n - 1] == '/') && !((n == 3 && _path[1]==':')))
- {
- _path.resize(n - 1);
- }
- convertPath(_path, _upath);
-}
-
-
-bool FileImpl::existsImpl() const
-{
- poco_assert (!_path.empty());
-
- DWORD attr = GetFileAttributesW(_upath.c_str());
- if (attr == INVALID_FILE_ATTRIBUTES)
- {
- switch (GetLastError())
- {
- case ERROR_FILE_NOT_FOUND:
- case ERROR_PATH_NOT_FOUND:
- case ERROR_NOT_READY:
- case ERROR_INVALID_DRIVE:
- return false;
- default:
- handleLastErrorImpl(_path);
- }
- }
- return true;
-}
-
-
-bool FileImpl::canReadImpl() const
-{
- poco_assert (!_path.empty());
-
- DWORD attr = GetFileAttributesW(_upath.c_str());
- if (attr == INVALID_FILE_ATTRIBUTES)
- {
- switch (GetLastError())
- {
- case ERROR_ACCESS_DENIED:
- return false;
- default:
- handleLastErrorImpl(_path);
- }
- }
- return true;
-}
-
-
-bool FileImpl::canWriteImpl() const
-{
- poco_assert (!_path.empty());
-
- DWORD attr = GetFileAttributesW(_upath.c_str());
- if (attr == INVALID_FILE_ATTRIBUTES)
- handleLastErrorImpl(_path);
- return (attr & FILE_ATTRIBUTE_READONLY) == 0;
-}
-
-
-bool FileImpl::canExecuteImpl() const
-{
- Path p(_path);
- return icompare(p.getExtension(), "exe") == 0;
-}
-
-
-bool FileImpl::isFileImpl() const
-{
- return !isDirectoryImpl() && !isDeviceImpl();
-}
-
-
-bool FileImpl::isDirectoryImpl() const
-{
- poco_assert (!_path.empty());
-
- DWORD attr = GetFileAttributesW(_upath.c_str());
- if (attr == INVALID_FILE_ATTRIBUTES)
- handleLastErrorImpl(_path);
- return (attr & FILE_ATTRIBUTE_DIRECTORY) != 0;
-}
-
-
-bool FileImpl::isLinkImpl() const
-{
- return false;
-}
-
-
-bool FileImpl::isDeviceImpl() const
-{
- return false;
-}
-
-
-bool FileImpl::isHiddenImpl() const
-{
- poco_assert (!_path.empty());
-
- DWORD attr = GetFileAttributesW(_upath.c_str());
- if (attr == INVALID_FILE_ATTRIBUTES)
- handleLastErrorImpl(_path);
- return (attr & FILE_ATTRIBUTE_HIDDEN) != 0;
-}
-
-
-Timestamp FileImpl::createdImpl() const
-{
- poco_assert (!_path.empty());
-
- WIN32_FILE_ATTRIBUTE_DATA fad;
- if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0)
- handleLastErrorImpl(_path);
- return Timestamp::fromFileTimeNP(fad.ftCreationTime.dwLowDateTime, fad.ftCreationTime.dwHighDateTime);
-}
-
-
-Timestamp FileImpl::getLastModifiedImpl() const
-{
- poco_assert (!_path.empty());
-
- WIN32_FILE_ATTRIBUTE_DATA fad;
- if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0)
- handleLastErrorImpl(_path);
- return Timestamp::fromFileTimeNP(fad.ftLastWriteTime.dwLowDateTime, fad.ftLastWriteTime.dwHighDateTime);
-}
-
-
-void FileImpl::setLastModifiedImpl(const Timestamp& ts)
-{
- poco_assert (!_path.empty());
-
- UInt32 low;
- UInt32 high;
- ts.toFileTimeNP(low, high);
- FILETIME ft;
- ft.dwLowDateTime = low;
- ft.dwHighDateTime = high;
- FileHandle fh(_path, _upath, GENERIC_WRITE, FILE_SHARE_WRITE, OPEN_EXISTING);
- if (SetFileTime(fh.get(), 0, &ft, &ft) == 0)
- handleLastErrorImpl(_path);
-}
-
-
-FileImpl::FileSizeImpl FileImpl::getSizeImpl() const
-{
- poco_assert (!_path.empty());
-
- WIN32_FILE_ATTRIBUTE_DATA fad;
- if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0)
- handleLastErrorImpl(_path);
- LARGE_INTEGER li;
- li.LowPart = fad.nFileSizeLow;
- li.HighPart = fad.nFileSizeHigh;
- return li.QuadPart;
-}
-
-
-void FileImpl::setSizeImpl(FileSizeImpl size)
-{
- poco_assert (!_path.empty());
-
- FileHandle fh(_path, _upath, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING);
- LARGE_INTEGER li;
- li.QuadPart = size;
- if (SetFilePointer(fh.get(), li.LowPart, &li.HighPart, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
- handleLastErrorImpl(_path);
- if (SetEndOfFile(fh.get()) == 0)
- handleLastErrorImpl(_path);
-}
-
-
-void FileImpl::setWriteableImpl(bool flag)
-{
- poco_assert (!_path.empty());
-
- DWORD attr = GetFileAttributesW(_upath.c_str());
- if (attr == -1)
- handleLastErrorImpl(_path);
- if (flag)
- attr &= ~FILE_ATTRIBUTE_READONLY;
- else
- attr |= FILE_ATTRIBUTE_READONLY;
- if (SetFileAttributesW(_upath.c_str(), attr) == 0)
- handleLastErrorImpl(_path);
-}
-
-
-void FileImpl::setExecutableImpl(bool flag)
-{
- // not supported
-}
-
-
-void FileImpl::copyToImpl(const std::string& path) const
-{
- poco_assert (!_path.empty());
-
- std::wstring upath;
- convertPath(path, upath);
- if (CopyFileW(_upath.c_str(), upath.c_str(), FALSE) == 0)
- handleLastErrorImpl(_path);
-}
-
-
-void FileImpl::renameToImpl(const std::string& path)
-{
- poco_assert (!_path.empty());
-
- std::wstring upath;
- convertPath(path, upath);
- if (MoveFileW(_upath.c_str(), upath.c_str()) == 0)
- handleLastErrorImpl(_path);
-}
-
-
-void FileImpl::linkToImpl(const std::string& path, int type) const
-{
- throw Poco::NotImplementedException("File::linkTo() is not available on this platform");
-}
-
-
-void FileImpl::removeImpl()
-{
- poco_assert (!_path.empty());
-
- if (isDirectoryImpl())
- {
- if (RemoveDirectoryW(_upath.c_str()) == 0)
- handleLastErrorImpl(_path);
- }
- else
- {
- if (DeleteFileW(_upath.c_str()) == 0)
- handleLastErrorImpl(_path);
- }
-}
-
-
-bool FileImpl::createFileImpl()
-{
- poco_assert (!_path.empty());
-
- HANDLE hFile = CreateFileW(_upath.c_str(), GENERIC_WRITE, 0, 0, CREATE_NEW, 0, 0);
- if (hFile != INVALID_HANDLE_VALUE)
- {
- CloseHandle(hFile);
- return true;
- }
- else if (GetLastError() == ERROR_FILE_EXISTS)
- return false;
- else
- handleLastErrorImpl(_path);
- return false;
-}
-
-
-bool FileImpl::createDirectoryImpl()
-{
- poco_assert (!_path.empty());
-
- if (existsImpl() && isDirectoryImpl())
- return false;
- if (CreateDirectoryW(_upath.c_str(), 0) == 0)
- handleLastErrorImpl(_path);
- return true;
-}
-
-
-FileImpl::FileSizeImpl FileImpl::totalSpaceImpl() const
-{
- poco_assert(!_path.empty());
-
- ULARGE_INTEGER space;
- if (!GetDiskFreeSpaceExW(_upath.c_str(), NULL, &space, NULL))
- handleLastErrorImpl(_path);
- return space.QuadPart;
-}
-
-
-FileImpl::FileSizeImpl FileImpl::usableSpaceImpl() const
-{
- poco_assert(!_path.empty());
-
- ULARGE_INTEGER space;
- if (!GetDiskFreeSpaceExW(_upath.c_str(), &space, NULL, NULL))
- handleLastErrorImpl(_path);
- return space.QuadPart;
-}
-
-
-FileImpl::FileSizeImpl FileImpl::freeSpaceImpl() const
-{
- poco_assert(!_path.empty());
-
- ULARGE_INTEGER space;
- if (!GetDiskFreeSpaceExW(_upath.c_str(), NULL, NULL, &space))
- handleLastErrorImpl(_path);
- return space.QuadPart;
-}
-
-
-void FileImpl::handleLastErrorImpl(const std::string& path)
-{
- switch (GetLastError())
- {
- case ERROR_FILE_NOT_FOUND:
- throw FileNotFoundException(path);
- case ERROR_PATH_NOT_FOUND:
- case ERROR_BAD_NETPATH:
- case ERROR_CANT_RESOLVE_FILENAME:
- case ERROR_INVALID_DRIVE:
- throw PathNotFoundException(path);
- case ERROR_ACCESS_DENIED:
- throw FileAccessDeniedException(path);
- case ERROR_ALREADY_EXISTS:
- case ERROR_FILE_EXISTS:
- throw FileExistsException(path);
- case ERROR_INVALID_NAME:
- case ERROR_DIRECTORY:
- case ERROR_FILENAME_EXCED_RANGE:
- case ERROR_BAD_PATHNAME:
- throw PathSyntaxException(path);
- case ERROR_FILE_READ_ONLY:
- throw FileReadOnlyException(path);
- case ERROR_CANNOT_MAKE:
- throw CreateFileException(path);
- case ERROR_DIR_NOT_EMPTY:
- throw DirectoryNotEmptyException(path);
- case ERROR_WRITE_FAULT:
- throw WriteFileException(path);
- case ERROR_READ_FAULT:
- throw ReadFileException(path);
- case ERROR_SHARING_VIOLATION:
- throw FileException("sharing violation", path);
- case ERROR_LOCK_VIOLATION:
- throw FileException("lock violation", path);
- case ERROR_HANDLE_EOF:
- throw ReadFileException("EOF reached", path);
- case ERROR_HANDLE_DISK_FULL:
- case ERROR_DISK_FULL:
- throw WriteFileException("disk is full", path);
- case ERROR_NEGATIVE_SEEK:
- throw FileException("negative seek", path);
- default:
- throw FileException(path);
- }
-}
-
-
-void FileImpl::convertPath(const std::string& utf8Path, std::wstring& utf16Path)
-{
- UnicodeConverter::toUTF16(utf8Path, utf16Path);
-}
-
-} // namespace Poco
+//
+// File_WIN32U.cpp
+//
+// Library: Foundation
+// Package: Filesystem
+// Module: File
+//
+// Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/File_WINCE.h"
+#include "Poco/Exception.h"
+#include "Poco/String.h"
+#include "Poco/UnicodeConverter.h"
+#include "Poco/Path.h"
+#include "Poco/UnWindows.h"
+
+
+namespace Poco {
+
+
+class FileHandle
+{
+public:
+ FileHandle(const std::string& path, const std::wstring& upath, DWORD access, DWORD share, DWORD disp)
+ {
+ _h = CreateFileW(upath.c_str(), access, share, 0, disp, 0, 0);
+ if (_h == INVALID_HANDLE_VALUE)
+ {
+ FileImpl::handleLastErrorImpl(path);
+ }
+ }
+
+ ~FileHandle()
+ {
+ if (_h != INVALID_HANDLE_VALUE) CloseHandle(_h);
+ }
+
+ HANDLE get() const
+ {
+ return _h;
+ }
+
+private:
+ HANDLE _h;
+};
+
+
+FileImpl::FileImpl()
+{
+}
+
+
+FileImpl::FileImpl(const std::string& path): _path(path)
+{
+ std::string::size_type n = _path.size();
+ if (n > 1 && (_path[n - 1] == '\\' || _path[n - 1] == '/') && !((n == 3 && _path[1]==':')))
+ {
+ _path.resize(n - 1);
+ }
+ convertPath(_path, _upath);
+}
+
+
+FileImpl::~FileImpl()
+{
+}
+
+
+void FileImpl::swapImpl(FileImpl& file)
+{
+ std::swap(_path, file._path);
+ std::swap(_upath, file._upath);
+}
+
+
+void FileImpl::setPathImpl(const std::string& path)
+{
+ _path = path;
+ std::string::size_type n = _path.size();
+ if (n > 1 && (_path[n - 1] == '\\' || _path[n - 1] == '/') && !((n == 3 && _path[1]==':')))
+ {
+ _path.resize(n - 1);
+ }
+ convertPath(_path, _upath);
+}
+
+
+bool FileImpl::existsImpl() const
+{
+ poco_assert (!_path.empty());
+
+ DWORD attr = GetFileAttributesW(_upath.c_str());
+ if (attr == INVALID_FILE_ATTRIBUTES)
+ {
+ switch (GetLastError())
+ {
+ case ERROR_FILE_NOT_FOUND:
+ case ERROR_PATH_NOT_FOUND:
+ case ERROR_NOT_READY:
+ case ERROR_INVALID_DRIVE:
+ return false;
+ default:
+ handleLastErrorImpl(_path);
+ }
+ }
+ return true;
+}
+
+
+bool FileImpl::canReadImpl() const
+{
+ poco_assert (!_path.empty());
+
+ DWORD attr = GetFileAttributesW(_upath.c_str());
+ if (attr == INVALID_FILE_ATTRIBUTES)
+ {
+ switch (GetLastError())
+ {
+ case ERROR_ACCESS_DENIED:
+ return false;
+ default:
+ handleLastErrorImpl(_path);
+ }
+ }
+ return true;
+}
+
+
+bool FileImpl::canWriteImpl() const
+{
+ poco_assert (!_path.empty());
+
+ DWORD attr = GetFileAttributesW(_upath.c_str());
+ if (attr == INVALID_FILE_ATTRIBUTES)
+ handleLastErrorImpl(_path);
+ return (attr & FILE_ATTRIBUTE_READONLY) == 0;
+}
+
+
+bool FileImpl::canExecuteImpl() const
+{
+ Path p(_path);
+ return icompare(p.getExtension(), "exe") == 0;
+}
+
+
+bool FileImpl::isFileImpl() const
+{
+ return !isDirectoryImpl() && !isDeviceImpl();
+}
+
+
+bool FileImpl::isDirectoryImpl() const
+{
+ poco_assert (!_path.empty());
+
+ DWORD attr = GetFileAttributesW(_upath.c_str());
+ if (attr == INVALID_FILE_ATTRIBUTES)
+ handleLastErrorImpl(_path);
+ return (attr & FILE_ATTRIBUTE_DIRECTORY) != 0;
+}
+
+
+bool FileImpl::isLinkImpl() const
+{
+ return false;
+}
+
+
+bool FileImpl::isDeviceImpl() const
+{
+ return false;
+}
+
+
+bool FileImpl::isHiddenImpl() const
+{
+ poco_assert (!_path.empty());
+
+ DWORD attr = GetFileAttributesW(_upath.c_str());
+ if (attr == INVALID_FILE_ATTRIBUTES)
+ handleLastErrorImpl(_path);
+ return (attr & FILE_ATTRIBUTE_HIDDEN) != 0;
+}
+
+
+Timestamp FileImpl::createdImpl() const
+{
+ poco_assert (!_path.empty());
+
+ WIN32_FILE_ATTRIBUTE_DATA fad;
+ if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0)
+ handleLastErrorImpl(_path);
+ return Timestamp::fromFileTimeNP(fad.ftCreationTime.dwLowDateTime, fad.ftCreationTime.dwHighDateTime);
+}
+
+
+Timestamp FileImpl::getLastModifiedImpl() const
+{
+ poco_assert (!_path.empty());
+
+ WIN32_FILE_ATTRIBUTE_DATA fad;
+ if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0)
+ handleLastErrorImpl(_path);
+ return Timestamp::fromFileTimeNP(fad.ftLastWriteTime.dwLowDateTime, fad.ftLastWriteTime.dwHighDateTime);
+}
+
+
+void FileImpl::setLastModifiedImpl(const Timestamp& ts)
+{
+ poco_assert (!_path.empty());
+
+ UInt32 low;
+ UInt32 high;
+ ts.toFileTimeNP(low, high);
+ FILETIME ft;
+ ft.dwLowDateTime = low;
+ ft.dwHighDateTime = high;
+ FileHandle fh(_path, _upath, GENERIC_WRITE, FILE_SHARE_WRITE, OPEN_EXISTING);
+ if (SetFileTime(fh.get(), 0, &ft, &ft) == 0)
+ handleLastErrorImpl(_path);
+}
+
+
+FileImpl::FileSizeImpl FileImpl::getSizeImpl() const
+{
+ poco_assert (!_path.empty());
+
+ WIN32_FILE_ATTRIBUTE_DATA fad;
+ if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0)
+ handleLastErrorImpl(_path);
+ LARGE_INTEGER li;
+ li.LowPart = fad.nFileSizeLow;
+ li.HighPart = fad.nFileSizeHigh;
+ return li.QuadPart;
+}
+
+
+void FileImpl::setSizeImpl(FileSizeImpl size)
+{
+ poco_assert (!_path.empty());
+
+ FileHandle fh(_path, _upath, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING);
+ LARGE_INTEGER li;
+ li.QuadPart = size;
+ if (SetFilePointer(fh.get(), li.LowPart, &li.HighPart, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
+ handleLastErrorImpl(_path);
+ if (SetEndOfFile(fh.get()) == 0)
+ handleLastErrorImpl(_path);
+}
+
+
+void FileImpl::setWriteableImpl(bool flag)
+{
+ poco_assert (!_path.empty());
+
+ DWORD attr = GetFileAttributesW(_upath.c_str());
+ if (attr == -1)
+ handleLastErrorImpl(_path);
+ if (flag)
+ attr &= ~FILE_ATTRIBUTE_READONLY;
+ else
+ attr |= FILE_ATTRIBUTE_READONLY;
+ if (SetFileAttributesW(_upath.c_str(), attr) == 0)
+ handleLastErrorImpl(_path);
+}
+
+
+void FileImpl::setExecutableImpl(bool flag)
+{
+ // not supported
+}
+
+
+void FileImpl::copyToImpl(const std::string& path) const
+{
+ poco_assert (!_path.empty());
+
+ std::wstring upath;
+ convertPath(path, upath);
+ if (CopyFileW(_upath.c_str(), upath.c_str(), FALSE) == 0)
+ handleLastErrorImpl(_path);
+}
+
+
+void FileImpl::renameToImpl(const std::string& path)
+{
+ poco_assert (!_path.empty());
+
+ std::wstring upath;
+ convertPath(path, upath);
+ if (MoveFileW(_upath.c_str(), upath.c_str()) == 0)
+ handleLastErrorImpl(_path);
+}
+
+
+void FileImpl::linkToImpl(const std::string& path, int type) const
+{
+ throw Poco::NotImplementedException("File::linkTo() is not available on this platform");
+}
+
+
+void FileImpl::removeImpl()
+{
+ poco_assert (!_path.empty());
+
+ if (isDirectoryImpl())
+ {
+ if (RemoveDirectoryW(_upath.c_str()) == 0)
+ handleLastErrorImpl(_path);
+ }
+ else
+ {
+ if (DeleteFileW(_upath.c_str()) == 0)
+ handleLastErrorImpl(_path);
+ }
+}
+
+
+bool FileImpl::createFileImpl()
+{
+ poco_assert (!_path.empty());
+
+ HANDLE hFile = CreateFileW(_upath.c_str(), GENERIC_WRITE, 0, 0, CREATE_NEW, 0, 0);
+ if (hFile != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle(hFile);
+ return true;
+ }
+ else if (GetLastError() == ERROR_FILE_EXISTS)
+ return false;
+ else
+ handleLastErrorImpl(_path);
+ return false;
+}
+
+
+bool FileImpl::createDirectoryImpl()
+{
+ poco_assert (!_path.empty());
+
+ if (existsImpl() && isDirectoryImpl())
+ return false;
+ if (CreateDirectoryW(_upath.c_str(), 0) == 0)
+ handleLastErrorImpl(_path);
+ return true;
+}
+
+
+FileImpl::FileSizeImpl FileImpl::totalSpaceImpl() const
+{
+ poco_assert(!_path.empty());
+
+ ULARGE_INTEGER space;
+ if (!GetDiskFreeSpaceExW(_upath.c_str(), NULL, &space, NULL))
+ handleLastErrorImpl(_path);
+ return space.QuadPart;
+}
+
+
+FileImpl::FileSizeImpl FileImpl::usableSpaceImpl() const
+{
+ poco_assert(!_path.empty());
+
+ ULARGE_INTEGER space;
+ if (!GetDiskFreeSpaceExW(_upath.c_str(), &space, NULL, NULL))
+ handleLastErrorImpl(_path);
+ return space.QuadPart;
+}
+
+
+FileImpl::FileSizeImpl FileImpl::freeSpaceImpl() const
+{
+ poco_assert(!_path.empty());
+
+ ULARGE_INTEGER space;
+ if (!GetDiskFreeSpaceExW(_upath.c_str(), NULL, NULL, &space))
+ handleLastErrorImpl(_path);
+ return space.QuadPart;
+}
+
+
+void FileImpl::handleLastErrorImpl(const std::string& path)
+{
+ switch (GetLastError())
+ {
+ case ERROR_FILE_NOT_FOUND:
+ throw FileNotFoundException(path);
+ case ERROR_PATH_NOT_FOUND:
+ case ERROR_BAD_NETPATH:
+ case ERROR_CANT_RESOLVE_FILENAME:
+ case ERROR_INVALID_DRIVE:
+ throw PathNotFoundException(path);
+ case ERROR_ACCESS_DENIED:
+ throw FileAccessDeniedException(path);
+ case ERROR_ALREADY_EXISTS:
+ case ERROR_FILE_EXISTS:
+ throw FileExistsException(path);
+ case ERROR_INVALID_NAME:
+ case ERROR_DIRECTORY:
+ case ERROR_FILENAME_EXCED_RANGE:
+ case ERROR_BAD_PATHNAME:
+ throw PathSyntaxException(path);
+ case ERROR_FILE_READ_ONLY:
+ throw FileReadOnlyException(path);
+ case ERROR_CANNOT_MAKE:
+ throw CreateFileException(path);
+ case ERROR_DIR_NOT_EMPTY:
+ throw DirectoryNotEmptyException(path);
+ case ERROR_WRITE_FAULT:
+ throw WriteFileException(path);
+ case ERROR_READ_FAULT:
+ throw ReadFileException(path);
+ case ERROR_SHARING_VIOLATION:
+ throw FileException("sharing violation", path);
+ case ERROR_LOCK_VIOLATION:
+ throw FileException("lock violation", path);
+ case ERROR_HANDLE_EOF:
+ throw ReadFileException("EOF reached", path);
+ case ERROR_HANDLE_DISK_FULL:
+ case ERROR_DISK_FULL:
+ throw WriteFileException("disk is full", path);
+ case ERROR_NEGATIVE_SEEK:
+ throw FileException("negative seek", path);
+ default:
+ throw FileException(path);
+ }
+}
+
+
+void FileImpl::convertPath(const std::string& utf8Path, std::wstring& utf16Path)
+{
+ UnicodeConverter::toUTF16(utf8Path, utf16Path);
+}
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Format.cpp b/contrib/libs/poco/Foundation/src/Format.cpp
index ed5db5c21b..cd40db41d6 100644
--- a/contrib/libs/poco/Foundation/src/Format.cpp
+++ b/contrib/libs/poco/Foundation/src/Format.cpp
@@ -1,476 +1,476 @@
-//
-// Format.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: Format
-//
-// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Format.h"
-#include "Poco/Exception.h"
-#include "Poco/Ascii.h"
-#include <sstream>
-#if !defined(POCO_NO_LOCALE)
-#include <locale>
-#endif
-#include <cstddef>
-
-
-namespace Poco {
-
-
-namespace
-{
- void parseFlags(std::ostream& str, std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt)
- {
- bool isFlag = true;
- while (isFlag && itFmt != endFmt)
- {
- switch (*itFmt)
- {
- case '-': str.setf(std::ios::left); ++itFmt; break;
- case '+': str.setf(std::ios::showpos); ++itFmt; break;
- case '0': str.fill('0'); str.setf(std::ios::internal); ++itFmt; break;
- case '#': str.setf(std::ios::showpoint | std::ios::showbase); ++itFmt; break;
- default: isFlag = false; break;
- }
- }
- }
-
-
- void parseWidth(std::ostream& str, std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt)
- {
- int width = 0;
- while (itFmt != endFmt && Ascii::isDigit(*itFmt))
- {
- width = 10*width + *itFmt - '0';
- ++itFmt;
- }
- if (width != 0) str.width(width);
- }
-
-
- void parsePrec(std::ostream& str, std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt)
- {
- if (itFmt != endFmt && *itFmt == '.')
- {
- ++itFmt;
- int prec = 0;
- while (itFmt != endFmt && Ascii::isDigit(*itFmt))
- {
- prec = 10*prec + *itFmt - '0';
- ++itFmt;
- }
- if (prec >= 0) str.precision(prec);
- }
- }
-
- char parseMod(std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt)
- {
- char mod = 0;
- if (itFmt != endFmt)
- {
- switch (*itFmt)
- {
- case 'l':
- case 'h':
- 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;
- while (itFmt != endFmt && Ascii::isDigit(*itFmt))
- {
- index = 10*index + *itFmt - '0';
- ++itFmt;
- }
- if (itFmt != endFmt && *itFmt == ']') ++itFmt;
- return index;
- }
-
- void prepareFormat(std::ostream& str, char type)
- {
- switch (type)
- {
- case 'd':
- case 'i': str << std::dec; break;
- case 'o': str << std::oct; break;
- case 'x': str << std::hex; break;
- case 'X': str << std::hex << std::uppercase; break;
- case 'e': str << std::scientific; break;
- case 'E': str << std::scientific << std::uppercase; break;
- case 'f': str << std::fixed; break;
- }
- }
-
-
- void writeAnyInt(std::ostream& str, const Any& any)
- {
- if (any.type() == typeid(char))
- str << static_cast<int>(AnyCast<char>(any));
- else if (any.type() == typeid(signed char))
- str << static_cast<int>(AnyCast<signed char>(any));
- else if (any.type() == typeid(unsigned char))
- str << static_cast<unsigned>(AnyCast<unsigned char>(any));
- else if (any.type() == typeid(short))
- str << AnyCast<short>(any);
- else if (any.type() == typeid(unsigned short))
- str << AnyCast<unsigned short>(any);
- else if (any.type() == typeid(int))
- str << AnyCast<int>(any);
- else if (any.type() == typeid(unsigned int))
- str << AnyCast<unsigned int>(any);
- else if (any.type() == typeid(long))
- str << AnyCast<long>(any);
- else if (any.type() == typeid(unsigned long))
- str << AnyCast<unsigned long>(any);
- else if (any.type() == typeid(Int64))
- str << AnyCast<Int64>(any);
- else if (any.type() == typeid(UInt64))
- str << AnyCast<UInt64>(any);
- else if (any.type() == typeid(bool))
- str << AnyCast<bool>(any);
- }
-
-
- void formatOne(std::string& result, std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt, std::vector<Any>::const_iterator& itVal)
- {
- std::ostringstream str;
-#if !defined(POCO_NO_LOCALE)
- str.imbue(std::locale::classic());
-#endif
- try
- {
- parseFlags(str, itFmt, endFmt);
- parseWidth(str, itFmt, endFmt);
- parsePrec(str, itFmt, endFmt);
- char mod = parseMod(itFmt, endFmt);
- if (itFmt != endFmt)
- {
- char type = *itFmt++;
- prepareFormat(str, type);
- switch (type)
- {
- case 'b':
- str << AnyCast<bool>(*itVal++);
- break;
- case 'c':
- str << AnyCast<char>(*itVal++);
- break;
- case 'd':
- case 'i':
- switch (mod)
- {
- case 'l': str << AnyCast<long>(*itVal++); break;
- case 'L': str << AnyCast<Int64>(*itVal++); break;
- case 'h': str << AnyCast<short>(*itVal++); break;
- case '?': writeAnyInt(str, *itVal++); break;
- default: str << AnyCast<int>(*itVal++); break;
- }
- break;
- case 'o':
- case 'u':
- case 'x':
- case 'X':
- switch (mod)
- {
- case 'l': str << AnyCast<unsigned long>(*itVal++); break;
- case 'L': str << AnyCast<UInt64>(*itVal++); break;
- case 'h': str << AnyCast<unsigned short>(*itVal++); break;
- case '?': writeAnyInt(str, *itVal++); break;
- default: str << AnyCast<unsigned>(*itVal++); break;
- }
- break;
- case 'e':
- case 'E':
- case 'f':
- switch (mod)
- {
- case 'l': str << AnyCast<long double>(*itVal++); break;
- case 'L': str << AnyCast<long double>(*itVal++); break;
- case 'h': str << AnyCast<float>(*itVal++); break;
- default: str << AnyCast<double>(*itVal++); break;
- }
- break;
- case 's':
- str << RefAnyCast<std::string>(*itVal++);
- break;
- case 'z':
- str << AnyCast<std::size_t>(*itVal++);
- break;
- case 'I':
- case 'D':
- default:
- str << type;
- }
- }
- }
- catch (Poco::BadCastException&)
- {
- str << "[ERRFMT]";
- }
- result.append(str.str());
- }
-}
-
-
-std::string format(const std::string& fmt, const Any& value)
-{
- std::string result;
- format(result, fmt, value);
- return result;
-}
-
-
-std::string format(const std::string& fmt, const Any& value1, const Any& value2)
-{
- std::string result;
- format(result, fmt, value1, value2);
- return result;
-}
-
-
-std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3)
-{
- std::string result;
- format(result, fmt, value1, value2, value3);
- return result;
-}
-
-
-std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4)
-{
- std::string result;
- format(result, fmt, value1, value2, value3, value4);
- return result;
-}
-
-
-std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5)
-{
- std::string result;
- format(result, fmt, value1, value2, value3, value4, value5);
- return result;
-}
-
-
-std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6)
-{
- std::string result;
- format(result, fmt, value1, value2, value3, value4, value5, value6);
- return result;
-}
-
-
-std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7)
-{
- std::string result;
- format(result, fmt, value1, value2, value3, value4, value5, value6, value7);
- return result;
-}
-
-
-std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8)
-{
- std::string result;
- format(result, fmt, value1, value2, value3, value4, value5, value6, value7, value8);
- return result;
-}
-
-
-std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9)
-{
- std::string result;
- format(result, fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9);
- return result;
-}
-
-
-std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10)
-{
- std::string result;
- format(result, fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10);
- return result;
-}
-
-
-void format(std::string& result, const std::string& fmt, const Any& value)
-{
- std::vector<Any> args;
- args.push_back(value);
- format(result, fmt, args);
-}
-
-
-void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2)
-{
- std::vector<Any> args;
- args.push_back(value1);
- args.push_back(value2);
- format(result, fmt, args);
-}
-
-
-void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3)
-{
- std::vector<Any> args;
- args.push_back(value1);
- args.push_back(value2);
- args.push_back(value3);
- format(result, fmt, args);
-}
-
-
-void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4)
-{
- std::vector<Any> args;
- args.push_back(value1);
- args.push_back(value2);
- args.push_back(value3);
- args.push_back(value4);
- format(result, fmt, args);
-}
-
-
-void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5)
-{
- std::vector<Any> args;
- args.push_back(value1);
- args.push_back(value2);
- args.push_back(value3);
- args.push_back(value4);
- args.push_back(value5);
- format(result, fmt, args);
-}
-
-
-void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6)
-{
- std::vector<Any> args;
- args.push_back(value1);
- args.push_back(value2);
- args.push_back(value3);
- args.push_back(value4);
- args.push_back(value5);
- args.push_back(value6);
- format(result, fmt, args);
-}
-
-
-void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7)
-{
- std::vector<Any> args;
- args.push_back(value1);
- args.push_back(value2);
- args.push_back(value3);
- args.push_back(value4);
- args.push_back(value5);
- args.push_back(value6);
- args.push_back(value7);
- format(result, fmt, args);
-}
-
-
-void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8)
-{
- std::vector<Any> args;
- args.push_back(value1);
- args.push_back(value2);
- args.push_back(value3);
- args.push_back(value4);
- args.push_back(value5);
- args.push_back(value6);
- args.push_back(value7);
- args.push_back(value8);
- format(result, fmt, args);
-}
-
-
-void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9)
-{
- std::vector<Any> args;
- args.push_back(value1);
- args.push_back(value2);
- args.push_back(value3);
- args.push_back(value4);
- args.push_back(value5);
- args.push_back(value6);
- args.push_back(value7);
- args.push_back(value8);
- args.push_back(value9);
- format(result, fmt, args);
-}
-
-
-void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10)
-{
- std::vector<Any> args;
- args.push_back(value1);
- args.push_back(value2);
- args.push_back(value3);
- args.push_back(value4);
- args.push_back(value5);
- args.push_back(value6);
- args.push_back(value7);
- args.push_back(value8);
- args.push_back(value9);
- args.push_back(value10);
- format(result, fmt, args);
-}
-
-
-void format(std::string& result, const std::string& fmt, const std::vector<Any>& values)
-{
- 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();
- while (itFmt != endFmt)
- {
- switch (*itFmt)
- {
- case '%':
- ++itFmt;
- if (itFmt != endFmt && (itVal != endVal || *itFmt == '['))
- {
- if (*itFmt == '[')
- {
- ++itFmt;
- std::size_t index = parseIndex(itFmt, endFmt);
- if (index < values.size())
- {
- std::vector<Any>::const_iterator it = values.begin() + index;
- formatOne(result, itFmt, endFmt, it);
- }
- else throw InvalidArgumentException("format argument index out of range", fmt);
- }
- else
- {
- formatOne(result, itFmt, endFmt, itVal);
- }
- }
- else if (itFmt != endFmt)
- {
- result += *itFmt++;
- }
- break;
- default:
- result += *itFmt;
- ++itFmt;
- }
- }
-}
-
-
-} // namespace Poco
+//
+// Format.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: Format
+//
+// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Format.h"
+#include "Poco/Exception.h"
+#include "Poco/Ascii.h"
+#include <sstream>
+#if !defined(POCO_NO_LOCALE)
+#include <locale>
+#endif
+#include <cstddef>
+
+
+namespace Poco {
+
+
+namespace
+{
+ void parseFlags(std::ostream& str, std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt)
+ {
+ bool isFlag = true;
+ while (isFlag && itFmt != endFmt)
+ {
+ switch (*itFmt)
+ {
+ case '-': str.setf(std::ios::left); ++itFmt; break;
+ case '+': str.setf(std::ios::showpos); ++itFmt; break;
+ case '0': str.fill('0'); str.setf(std::ios::internal); ++itFmt; break;
+ case '#': str.setf(std::ios::showpoint | std::ios::showbase); ++itFmt; break;
+ default: isFlag = false; break;
+ }
+ }
+ }
+
+
+ void parseWidth(std::ostream& str, std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt)
+ {
+ int width = 0;
+ while (itFmt != endFmt && Ascii::isDigit(*itFmt))
+ {
+ width = 10*width + *itFmt - '0';
+ ++itFmt;
+ }
+ if (width != 0) str.width(width);
+ }
+
+
+ void parsePrec(std::ostream& str, std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt)
+ {
+ if (itFmt != endFmt && *itFmt == '.')
+ {
+ ++itFmt;
+ int prec = 0;
+ while (itFmt != endFmt && Ascii::isDigit(*itFmt))
+ {
+ prec = 10*prec + *itFmt - '0';
+ ++itFmt;
+ }
+ if (prec >= 0) str.precision(prec);
+ }
+ }
+
+ char parseMod(std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt)
+ {
+ char mod = 0;
+ if (itFmt != endFmt)
+ {
+ switch (*itFmt)
+ {
+ case 'l':
+ case 'h':
+ 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;
+ while (itFmt != endFmt && Ascii::isDigit(*itFmt))
+ {
+ index = 10*index + *itFmt - '0';
+ ++itFmt;
+ }
+ if (itFmt != endFmt && *itFmt == ']') ++itFmt;
+ return index;
+ }
+
+ void prepareFormat(std::ostream& str, char type)
+ {
+ switch (type)
+ {
+ case 'd':
+ case 'i': str << std::dec; break;
+ case 'o': str << std::oct; break;
+ case 'x': str << std::hex; break;
+ case 'X': str << std::hex << std::uppercase; break;
+ case 'e': str << std::scientific; break;
+ case 'E': str << std::scientific << std::uppercase; break;
+ case 'f': str << std::fixed; break;
+ }
+ }
+
+
+ void writeAnyInt(std::ostream& str, const Any& any)
+ {
+ if (any.type() == typeid(char))
+ str << static_cast<int>(AnyCast<char>(any));
+ else if (any.type() == typeid(signed char))
+ str << static_cast<int>(AnyCast<signed char>(any));
+ else if (any.type() == typeid(unsigned char))
+ str << static_cast<unsigned>(AnyCast<unsigned char>(any));
+ else if (any.type() == typeid(short))
+ str << AnyCast<short>(any);
+ else if (any.type() == typeid(unsigned short))
+ str << AnyCast<unsigned short>(any);
+ else if (any.type() == typeid(int))
+ str << AnyCast<int>(any);
+ else if (any.type() == typeid(unsigned int))
+ str << AnyCast<unsigned int>(any);
+ else if (any.type() == typeid(long))
+ str << AnyCast<long>(any);
+ else if (any.type() == typeid(unsigned long))
+ str << AnyCast<unsigned long>(any);
+ else if (any.type() == typeid(Int64))
+ str << AnyCast<Int64>(any);
+ else if (any.type() == typeid(UInt64))
+ str << AnyCast<UInt64>(any);
+ else if (any.type() == typeid(bool))
+ str << AnyCast<bool>(any);
+ }
+
+
+ void formatOne(std::string& result, std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt, std::vector<Any>::const_iterator& itVal)
+ {
+ std::ostringstream str;
+#if !defined(POCO_NO_LOCALE)
+ str.imbue(std::locale::classic());
+#endif
+ try
+ {
+ parseFlags(str, itFmt, endFmt);
+ parseWidth(str, itFmt, endFmt);
+ parsePrec(str, itFmt, endFmt);
+ char mod = parseMod(itFmt, endFmt);
+ if (itFmt != endFmt)
+ {
+ char type = *itFmt++;
+ prepareFormat(str, type);
+ switch (type)
+ {
+ case 'b':
+ str << AnyCast<bool>(*itVal++);
+ break;
+ case 'c':
+ str << AnyCast<char>(*itVal++);
+ break;
+ case 'd':
+ case 'i':
+ switch (mod)
+ {
+ case 'l': str << AnyCast<long>(*itVal++); break;
+ case 'L': str << AnyCast<Int64>(*itVal++); break;
+ case 'h': str << AnyCast<short>(*itVal++); break;
+ case '?': writeAnyInt(str, *itVal++); break;
+ default: str << AnyCast<int>(*itVal++); break;
+ }
+ break;
+ case 'o':
+ case 'u':
+ case 'x':
+ case 'X':
+ switch (mod)
+ {
+ case 'l': str << AnyCast<unsigned long>(*itVal++); break;
+ case 'L': str << AnyCast<UInt64>(*itVal++); break;
+ case 'h': str << AnyCast<unsigned short>(*itVal++); break;
+ case '?': writeAnyInt(str, *itVal++); break;
+ default: str << AnyCast<unsigned>(*itVal++); break;
+ }
+ break;
+ case 'e':
+ case 'E':
+ case 'f':
+ switch (mod)
+ {
+ case 'l': str << AnyCast<long double>(*itVal++); break;
+ case 'L': str << AnyCast<long double>(*itVal++); break;
+ case 'h': str << AnyCast<float>(*itVal++); break;
+ default: str << AnyCast<double>(*itVal++); break;
+ }
+ break;
+ case 's':
+ str << RefAnyCast<std::string>(*itVal++);
+ break;
+ case 'z':
+ str << AnyCast<std::size_t>(*itVal++);
+ break;
+ case 'I':
+ case 'D':
+ default:
+ str << type;
+ }
+ }
+ }
+ catch (Poco::BadCastException&)
+ {
+ str << "[ERRFMT]";
+ }
+ result.append(str.str());
+ }
+}
+
+
+std::string format(const std::string& fmt, const Any& value)
+{
+ std::string result;
+ format(result, fmt, value);
+ return result;
+}
+
+
+std::string format(const std::string& fmt, const Any& value1, const Any& value2)
+{
+ std::string result;
+ format(result, fmt, value1, value2);
+ return result;
+}
+
+
+std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3)
+{
+ std::string result;
+ format(result, fmt, value1, value2, value3);
+ return result;
+}
+
+
+std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4)
+{
+ std::string result;
+ format(result, fmt, value1, value2, value3, value4);
+ return result;
+}
+
+
+std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5)
+{
+ std::string result;
+ format(result, fmt, value1, value2, value3, value4, value5);
+ return result;
+}
+
+
+std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6)
+{
+ std::string result;
+ format(result, fmt, value1, value2, value3, value4, value5, value6);
+ return result;
+}
+
+
+std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7)
+{
+ std::string result;
+ format(result, fmt, value1, value2, value3, value4, value5, value6, value7);
+ return result;
+}
+
+
+std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8)
+{
+ std::string result;
+ format(result, fmt, value1, value2, value3, value4, value5, value6, value7, value8);
+ return result;
+}
+
+
+std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9)
+{
+ std::string result;
+ format(result, fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9);
+ return result;
+}
+
+
+std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10)
+{
+ std::string result;
+ format(result, fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10);
+ return result;
+}
+
+
+void format(std::string& result, const std::string& fmt, const Any& value)
+{
+ std::vector<Any> args;
+ args.push_back(value);
+ format(result, fmt, args);
+}
+
+
+void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2)
+{
+ std::vector<Any> args;
+ args.push_back(value1);
+ args.push_back(value2);
+ format(result, fmt, args);
+}
+
+
+void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3)
+{
+ std::vector<Any> args;
+ args.push_back(value1);
+ args.push_back(value2);
+ args.push_back(value3);
+ format(result, fmt, args);
+}
+
+
+void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4)
+{
+ std::vector<Any> args;
+ args.push_back(value1);
+ args.push_back(value2);
+ args.push_back(value3);
+ args.push_back(value4);
+ format(result, fmt, args);
+}
+
+
+void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5)
+{
+ std::vector<Any> args;
+ args.push_back(value1);
+ args.push_back(value2);
+ args.push_back(value3);
+ args.push_back(value4);
+ args.push_back(value5);
+ format(result, fmt, args);
+}
+
+
+void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6)
+{
+ std::vector<Any> args;
+ args.push_back(value1);
+ args.push_back(value2);
+ args.push_back(value3);
+ args.push_back(value4);
+ args.push_back(value5);
+ args.push_back(value6);
+ format(result, fmt, args);
+}
+
+
+void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7)
+{
+ std::vector<Any> args;
+ args.push_back(value1);
+ args.push_back(value2);
+ args.push_back(value3);
+ args.push_back(value4);
+ args.push_back(value5);
+ args.push_back(value6);
+ args.push_back(value7);
+ format(result, fmt, args);
+}
+
+
+void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8)
+{
+ std::vector<Any> args;
+ args.push_back(value1);
+ args.push_back(value2);
+ args.push_back(value3);
+ args.push_back(value4);
+ args.push_back(value5);
+ args.push_back(value6);
+ args.push_back(value7);
+ args.push_back(value8);
+ format(result, fmt, args);
+}
+
+
+void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9)
+{
+ std::vector<Any> args;
+ args.push_back(value1);
+ args.push_back(value2);
+ args.push_back(value3);
+ args.push_back(value4);
+ args.push_back(value5);
+ args.push_back(value6);
+ args.push_back(value7);
+ args.push_back(value8);
+ args.push_back(value9);
+ format(result, fmt, args);
+}
+
+
+void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10)
+{
+ std::vector<Any> args;
+ args.push_back(value1);
+ args.push_back(value2);
+ args.push_back(value3);
+ args.push_back(value4);
+ args.push_back(value5);
+ args.push_back(value6);
+ args.push_back(value7);
+ args.push_back(value8);
+ args.push_back(value9);
+ args.push_back(value10);
+ format(result, fmt, args);
+}
+
+
+void format(std::string& result, const std::string& fmt, const std::vector<Any>& values)
+{
+ 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();
+ while (itFmt != endFmt)
+ {
+ switch (*itFmt)
+ {
+ case '%':
+ ++itFmt;
+ if (itFmt != endFmt && (itVal != endVal || *itFmt == '['))
+ {
+ if (*itFmt == '[')
+ {
+ ++itFmt;
+ std::size_t index = parseIndex(itFmt, endFmt);
+ if (index < values.size())
+ {
+ std::vector<Any>::const_iterator it = values.begin() + index;
+ formatOne(result, itFmt, endFmt, it);
+ }
+ else throw InvalidArgumentException("format argument index out of range", fmt);
+ }
+ else
+ {
+ formatOne(result, itFmt, endFmt, itVal);
+ }
+ }
+ else if (itFmt != endFmt)
+ {
+ result += *itFmt++;
+ }
+ break;
+ default:
+ result += *itFmt;
+ ++itFmt;
+ }
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Formatter.cpp b/contrib/libs/poco/Foundation/src/Formatter.cpp
index e14e46e873..e57c094a34 100644
--- a/contrib/libs/poco/Foundation/src/Formatter.cpp
+++ b/contrib/libs/poco/Foundation/src/Formatter.cpp
@@ -1,44 +1,44 @@
-//
-// Formatter.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: Formatter
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Formatter.h"
-#include "Poco/Exception.h"
-
-
-namespace Poco {
-
-
-Formatter::Formatter()
-{
-}
-
-
-Formatter::~Formatter()
-{
-}
-
-
-void Formatter::setProperty(const std::string& /*name*/, const std::string& /*value*/)
-{
- throw PropertyNotSupportedException();
-}
-
-
-std::string Formatter::getProperty(const std::string& /*name*/) const
-{
- throw PropertyNotSupportedException();
-}
-
-
-} // namespace Poco
+//
+// Formatter.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: Formatter
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Formatter.h"
+#include "Poco/Exception.h"
+
+
+namespace Poco {
+
+
+Formatter::Formatter()
+{
+}
+
+
+Formatter::~Formatter()
+{
+}
+
+
+void Formatter::setProperty(const std::string& /*name*/, const std::string& /*value*/)
+{
+ throw PropertyNotSupportedException();
+}
+
+
+std::string Formatter::getProperty(const std::string& /*name*/) const
+{
+ throw PropertyNotSupportedException();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/FormattingChannel.cpp b/contrib/libs/poco/Foundation/src/FormattingChannel.cpp
index be6c0ae180..065811b790 100644
--- a/contrib/libs/poco/Foundation/src/FormattingChannel.cpp
+++ b/contrib/libs/poco/Foundation/src/FormattingChannel.cpp
@@ -1,126 +1,126 @@
-//
-// FormattingChannel.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: Formatter
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/FormattingChannel.h"
-#include "Poco/Formatter.h"
-#include "Poco/Message.h"
-#include "Poco/LoggingRegistry.h"
-
-
-namespace Poco {
-
-
-FormattingChannel::FormattingChannel():
- _pFormatter(0),
- _pChannel(0)
-{
-}
-
-
-FormattingChannel::FormattingChannel(Formatter* pFormatter):
- _pFormatter(pFormatter),
- _pChannel(0)
-{
- if (_pFormatter) _pFormatter->duplicate();
-}
-
-
-FormattingChannel::FormattingChannel(Formatter* pFormatter, Channel* pChannel):
- _pFormatter(pFormatter),
- _pChannel(pChannel)
-{
- if (_pFormatter) _pFormatter->duplicate();
- if (_pChannel) _pChannel->duplicate();
-}
-
-
-FormattingChannel::~FormattingChannel()
-{
- if (_pChannel) _pChannel->release();
- if (_pFormatter) _pFormatter->release();
-}
-
-
-void FormattingChannel::setFormatter(Formatter* pFormatter)
-{
- if (_pFormatter) _pFormatter->release();
- _pFormatter = pFormatter;
- if (_pFormatter) _pFormatter->duplicate();
-}
-
-
-Formatter* FormattingChannel::getFormatter() const
-{
- return _pFormatter;
-}
-
-
-void FormattingChannel::setChannel(Channel* pChannel)
-{
- if (_pChannel) _pChannel->release();
- _pChannel = pChannel;
- if (_pChannel) _pChannel->duplicate();
-}
-
-
-Channel* FormattingChannel::getChannel() const
-{
- return _pChannel;
-}
-
-
-void FormattingChannel::log(const Message& msg)
-{
- if (_pChannel)
- {
- if (_pFormatter)
- {
- std::string text;
- _pFormatter->format(msg, text);
- _pChannel->log(Message(msg, text));
- }
- else
- {
- _pChannel->log(msg);
- }
- }
-}
-
-
-void FormattingChannel::setProperty(const std::string& name, const std::string& value)
-{
- if (name == "channel")
- setChannel(LoggingRegistry::defaultRegistry().channelForName(value));
- else if (name == "formatter")
- setFormatter(LoggingRegistry::defaultRegistry().formatterForName(value));
- else if (_pChannel)
- _pChannel->setProperty(name, value);
-}
-
-
-void FormattingChannel::open()
-{
- if (_pChannel)
- _pChannel->open();
-}
-
-
-void FormattingChannel::close()
-{
- if (_pChannel)
- _pChannel->close();
-}
-
-
-} // namespace Poco
+//
+// FormattingChannel.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: Formatter
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/FormattingChannel.h"
+#include "Poco/Formatter.h"
+#include "Poco/Message.h"
+#include "Poco/LoggingRegistry.h"
+
+
+namespace Poco {
+
+
+FormattingChannel::FormattingChannel():
+ _pFormatter(0),
+ _pChannel(0)
+{
+}
+
+
+FormattingChannel::FormattingChannel(Formatter* pFormatter):
+ _pFormatter(pFormatter),
+ _pChannel(0)
+{
+ if (_pFormatter) _pFormatter->duplicate();
+}
+
+
+FormattingChannel::FormattingChannel(Formatter* pFormatter, Channel* pChannel):
+ _pFormatter(pFormatter),
+ _pChannel(pChannel)
+{
+ if (_pFormatter) _pFormatter->duplicate();
+ if (_pChannel) _pChannel->duplicate();
+}
+
+
+FormattingChannel::~FormattingChannel()
+{
+ if (_pChannel) _pChannel->release();
+ if (_pFormatter) _pFormatter->release();
+}
+
+
+void FormattingChannel::setFormatter(Formatter* pFormatter)
+{
+ if (_pFormatter) _pFormatter->release();
+ _pFormatter = pFormatter;
+ if (_pFormatter) _pFormatter->duplicate();
+}
+
+
+Formatter* FormattingChannel::getFormatter() const
+{
+ return _pFormatter;
+}
+
+
+void FormattingChannel::setChannel(Channel* pChannel)
+{
+ if (_pChannel) _pChannel->release();
+ _pChannel = pChannel;
+ if (_pChannel) _pChannel->duplicate();
+}
+
+
+Channel* FormattingChannel::getChannel() const
+{
+ return _pChannel;
+}
+
+
+void FormattingChannel::log(const Message& msg)
+{
+ if (_pChannel)
+ {
+ if (_pFormatter)
+ {
+ std::string text;
+ _pFormatter->format(msg, text);
+ _pChannel->log(Message(msg, text));
+ }
+ else
+ {
+ _pChannel->log(msg);
+ }
+ }
+}
+
+
+void FormattingChannel::setProperty(const std::string& name, const std::string& value)
+{
+ if (name == "channel")
+ setChannel(LoggingRegistry::defaultRegistry().channelForName(value));
+ else if (name == "formatter")
+ setFormatter(LoggingRegistry::defaultRegistry().formatterForName(value));
+ else if (_pChannel)
+ _pChannel->setProperty(name, value);
+}
+
+
+void FormattingChannel::open()
+{
+ if (_pChannel)
+ _pChannel->open();
+}
+
+
+void FormattingChannel::close()
+{
+ if (_pChannel)
+ _pChannel->close();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Glob.cpp b/contrib/libs/poco/Foundation/src/Glob.cpp
index 4ca64debc9..14d24e0649 100644
--- a/contrib/libs/poco/Foundation/src/Glob.cpp
+++ b/contrib/libs/poco/Foundation/src/Glob.cpp
@@ -1,285 +1,285 @@
-//
-// Glob.cpp
-//
-// Library: Foundation
-// Package: Filesystem
-// Module: Glob
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Glob.h"
-#include "Poco/Path.h"
-#include "Poco/Exception.h"
-#include "Poco/DirectoryIterator.h"
-#include "Poco/File.h"
-#include "Poco/UTF8Encoding.h"
-#include "Poco/Unicode.h"
-
-
-namespace Poco {
-
-
-Glob::Glob(const std::string& pattern, int options)
- : _pattern(pattern), _options(options)
-{
-}
-
-
-Glob::~Glob()
-{
-}
-
-
-bool Glob::match(const std::string& subject)
-{
- UTF8Encoding utf8;
- TextIterator itp(_pattern, utf8);
- TextIterator endp(_pattern);
- TextIterator its(subject, utf8);
- TextIterator ends(subject);
-
- if ((_options & GLOB_DOT_SPECIAL) && its != ends && *its == '.' && (*itp == '?' || *itp == '*'))
- return false;
- else
- return match(itp, endp, its, ends);
-}
-
-
-void Glob::glob(const std::string& pathPattern, std::set<std::string>& files, int options)
-{
- glob(Path(Path::expand(pathPattern), Path::PATH_GUESS), files, options);
-}
-
-
-void Glob::glob(const char* pathPattern, std::set<std::string>& files, int options)
-{
- glob(Path(Path::expand(pathPattern), Path::PATH_GUESS), files, options);
-}
-
-
-void Glob::glob(const Path& pathPattern, std::set<std::string>& files, int options)
-{
- Path pattern(pathPattern);
- pattern.makeDirectory(); // to simplify pattern handling later on
- Path base(pattern);
- Path absBase(base);
- absBase.makeAbsolute();
- // In case of UNC paths we must not pop the topmost directory
- // (which must not contain wildcards), otherwise collect() will fail
- // as one cannot create a DirectoryIterator with only a node name ("\\srv\").
- int minDepth = base.getNode().empty() ? 0 : 1;
- while (base.depth() > minDepth && base[base.depth() - 1] != "..")
- {
- base.popDirectory();
- absBase.popDirectory();
- }
- if (pathPattern.isDirectory())
- options |= GLOB_DIRS_ONLY;
- collect(pattern, absBase, base, pathPattern[base.depth()], files, options);
-}
-
-
-void Glob::glob(const Path& pathPattern, const Path& basePath, std::set<std::string>& files, int options)
-{
- Path pattern(pathPattern);
- pattern.makeDirectory(); // to simplify pattern handling later on
- Path absBase(basePath);
- absBase.makeAbsolute();
- if (pathPattern.isDirectory())
- options |= GLOB_DIRS_ONLY;
- collect(pattern, absBase, basePath, pathPattern[basePath.depth()], files, options);
-}
-
-
-bool Glob::match(TextIterator& itp, const TextIterator& endp, TextIterator& its, const TextIterator& ends)
-{
- while (itp != endp)
- {
- if (its == ends)
- {
- while (itp != endp && *itp == '*') ++itp;
- break;
- }
- switch (*itp)
- {
- case '?':
- ++itp; ++its;
- break;
- case '*':
- if (++itp != endp)
- {
- while (its != ends && !matchAfterAsterisk(itp, endp, its, ends)) ++its;
- return its != ends;
- }
- return true;
- case '[':
+//
+// Glob.cpp
+//
+// Library: Foundation
+// Package: Filesystem
+// Module: Glob
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Glob.h"
+#include "Poco/Path.h"
+#include "Poco/Exception.h"
+#include "Poco/DirectoryIterator.h"
+#include "Poco/File.h"
+#include "Poco/UTF8Encoding.h"
+#include "Poco/Unicode.h"
+
+
+namespace Poco {
+
+
+Glob::Glob(const std::string& pattern, int options)
+ : _pattern(pattern), _options(options)
+{
+}
+
+
+Glob::~Glob()
+{
+}
+
+
+bool Glob::match(const std::string& subject)
+{
+ UTF8Encoding utf8;
+ TextIterator itp(_pattern, utf8);
+ TextIterator endp(_pattern);
+ TextIterator its(subject, utf8);
+ TextIterator ends(subject);
+
+ if ((_options & GLOB_DOT_SPECIAL) && its != ends && *its == '.' && (*itp == '?' || *itp == '*'))
+ return false;
+ else
+ return match(itp, endp, its, ends);
+}
+
+
+void Glob::glob(const std::string& pathPattern, std::set<std::string>& files, int options)
+{
+ glob(Path(Path::expand(pathPattern), Path::PATH_GUESS), files, options);
+}
+
+
+void Glob::glob(const char* pathPattern, std::set<std::string>& files, int options)
+{
+ glob(Path(Path::expand(pathPattern), Path::PATH_GUESS), files, options);
+}
+
+
+void Glob::glob(const Path& pathPattern, std::set<std::string>& files, int options)
+{
+ Path pattern(pathPattern);
+ pattern.makeDirectory(); // to simplify pattern handling later on
+ Path base(pattern);
+ Path absBase(base);
+ absBase.makeAbsolute();
+ // In case of UNC paths we must not pop the topmost directory
+ // (which must not contain wildcards), otherwise collect() will fail
+ // as one cannot create a DirectoryIterator with only a node name ("\\srv\").
+ int minDepth = base.getNode().empty() ? 0 : 1;
+ while (base.depth() > minDepth && base[base.depth() - 1] != "..")
+ {
+ base.popDirectory();
+ absBase.popDirectory();
+ }
+ if (pathPattern.isDirectory())
+ options |= GLOB_DIRS_ONLY;
+ collect(pattern, absBase, base, pathPattern[base.depth()], files, options);
+}
+
+
+void Glob::glob(const Path& pathPattern, const Path& basePath, std::set<std::string>& files, int options)
+{
+ Path pattern(pathPattern);
+ pattern.makeDirectory(); // to simplify pattern handling later on
+ Path absBase(basePath);
+ absBase.makeAbsolute();
+ if (pathPattern.isDirectory())
+ options |= GLOB_DIRS_ONLY;
+ collect(pattern, absBase, basePath, pathPattern[basePath.depth()], files, options);
+}
+
+
+bool Glob::match(TextIterator& itp, const TextIterator& endp, TextIterator& its, const TextIterator& ends)
+{
+ while (itp != endp)
+ {
+ if (its == ends)
+ {
+ while (itp != endp && *itp == '*') ++itp;
+ break;
+ }
+ switch (*itp)
+ {
+ case '?':
+ ++itp; ++its;
+ break;
+ case '*':
if (++itp != endp)
- {
- bool invert = *itp == '!';
- if (invert) ++itp;
- if (itp != endp)
- {
- bool mtch = matchSet(itp, endp, *its++);
- if ((invert && mtch) || (!invert && !mtch)) return false;
- break;
- }
- }
- throw SyntaxException("bad range syntax in glob pattern");
- case '\\':
- if (++itp == endp) throw SyntaxException("backslash must be followed by character in glob pattern");
- // fallthrough
- default:
- if (_options & GLOB_CASELESS)
- {
- if (Unicode::toLower(*itp) != Unicode::toLower(*its)) return false;
- }
- else
- {
- if (*itp != *its) return false;
- }
- ++itp; ++its;
- }
- }
- return itp == endp && its == ends;
-}
-
-
-bool Glob::matchAfterAsterisk(TextIterator itp, const TextIterator& endp, TextIterator its, const TextIterator& ends)
-{
- return match(itp, endp, its, ends);
-}
-
-
-bool Glob::matchSet(TextIterator& itp, const TextIterator& endp, int c)
-{
- if (_options & GLOB_CASELESS)
- c = Unicode::toLower(c);
-
- while (itp != endp)
- {
- switch (*itp)
- {
- case ']':
- ++itp;
- return false;
- case '\\':
- if (++itp == endp) throw SyntaxException("backslash must be followed by character in glob pattern");
- }
- int first = *itp;
- int last = first;
- if (++itp != endp && *itp == '-')
- {
- if (++itp != endp)
- last = *itp++;
- else
- throw SyntaxException("bad range syntax in glob pattern");
- }
- if (_options & GLOB_CASELESS)
- {
- first = Unicode::toLower(first);
- last = Unicode::toLower(last);
- }
- if (first <= c && c <= last)
- {
- while (itp != endp)
- {
- switch (*itp)
- {
- case ']':
- ++itp;
- return true;
- case '\\':
- if (++itp == endp) break;
- default:
- ++itp;
- }
- }
- throw SyntaxException("range must be terminated by closing bracket in glob pattern");
- }
- }
- return false;
-}
-
-
-void Glob::collect(const Path& pathPattern, const Path& base, const Path& current, const std::string& pattern, std::set<std::string>& files, int options)
-{
- try
- {
- std::string pp = pathPattern.toString();
- std::string basep = base.toString();
- std::string curp = current.toString();
- Glob g(pattern, options);
- DirectoryIterator it(base);
- DirectoryIterator end;
- while (it != end)
- {
- const std::string& name = it.name();
- if (g.match(name))
- {
- Path p(current);
- if (p.depth() < pathPattern.depth() - 1)
- {
- p.pushDirectory(name);
- collect(pathPattern, it.path(), p, pathPattern[p.depth()], files, options);
- }
- else
- {
- p.setFileName(name);
- if (isDirectory(p, (options & GLOB_FOLLOW_SYMLINKS) != 0))
- {
- p.makeDirectory();
- files.insert(p.toString());
- }
- else if (!(options & GLOB_DIRS_ONLY))
- {
- files.insert(p.toString());
- }
- }
- }
- ++it;
- }
- }
- catch (Exception&)
- {
- }
-}
-
-
-bool Glob::isDirectory(const Path& path, bool followSymlink)
-{
- File f(path);
- bool isDir = false;
- try
- {
- isDir = f.isDirectory();
- }
- catch (Poco::Exception&)
- {
- return false;
- }
- if (isDir)
- {
- return true;
- }
- else if (followSymlink && f.isLink())
- {
- try
- {
- // Test if link resolves to a directory.
- DirectoryIterator it(f);
- return true;
- }
- catch (Exception&)
- {
- }
- }
- return false;
-}
-
-
-} // namespace Poco
+ {
+ while (its != ends && !matchAfterAsterisk(itp, endp, its, ends)) ++its;
+ return its != ends;
+ }
+ return true;
+ case '[':
+ if (++itp != endp)
+ {
+ bool invert = *itp == '!';
+ if (invert) ++itp;
+ if (itp != endp)
+ {
+ bool mtch = matchSet(itp, endp, *its++);
+ if ((invert && mtch) || (!invert && !mtch)) return false;
+ break;
+ }
+ }
+ throw SyntaxException("bad range syntax in glob pattern");
+ case '\\':
+ if (++itp == endp) throw SyntaxException("backslash must be followed by character in glob pattern");
+ // fallthrough
+ default:
+ if (_options & GLOB_CASELESS)
+ {
+ if (Unicode::toLower(*itp) != Unicode::toLower(*its)) return false;
+ }
+ else
+ {
+ if (*itp != *its) return false;
+ }
+ ++itp; ++its;
+ }
+ }
+ return itp == endp && its == ends;
+}
+
+
+bool Glob::matchAfterAsterisk(TextIterator itp, const TextIterator& endp, TextIterator its, const TextIterator& ends)
+{
+ return match(itp, endp, its, ends);
+}
+
+
+bool Glob::matchSet(TextIterator& itp, const TextIterator& endp, int c)
+{
+ if (_options & GLOB_CASELESS)
+ c = Unicode::toLower(c);
+
+ while (itp != endp)
+ {
+ switch (*itp)
+ {
+ case ']':
+ ++itp;
+ return false;
+ case '\\':
+ if (++itp == endp) throw SyntaxException("backslash must be followed by character in glob pattern");
+ }
+ int first = *itp;
+ int last = first;
+ if (++itp != endp && *itp == '-')
+ {
+ if (++itp != endp)
+ last = *itp++;
+ else
+ throw SyntaxException("bad range syntax in glob pattern");
+ }
+ if (_options & GLOB_CASELESS)
+ {
+ first = Unicode::toLower(first);
+ last = Unicode::toLower(last);
+ }
+ if (first <= c && c <= last)
+ {
+ while (itp != endp)
+ {
+ switch (*itp)
+ {
+ case ']':
+ ++itp;
+ return true;
+ case '\\':
+ if (++itp == endp) break;
+ default:
+ ++itp;
+ }
+ }
+ throw SyntaxException("range must be terminated by closing bracket in glob pattern");
+ }
+ }
+ return false;
+}
+
+
+void Glob::collect(const Path& pathPattern, const Path& base, const Path& current, const std::string& pattern, std::set<std::string>& files, int options)
+{
+ try
+ {
+ std::string pp = pathPattern.toString();
+ std::string basep = base.toString();
+ std::string curp = current.toString();
+ Glob g(pattern, options);
+ DirectoryIterator it(base);
+ DirectoryIterator end;
+ while (it != end)
+ {
+ const std::string& name = it.name();
+ if (g.match(name))
+ {
+ Path p(current);
+ if (p.depth() < pathPattern.depth() - 1)
+ {
+ p.pushDirectory(name);
+ collect(pathPattern, it.path(), p, pathPattern[p.depth()], files, options);
+ }
+ else
+ {
+ p.setFileName(name);
+ if (isDirectory(p, (options & GLOB_FOLLOW_SYMLINKS) != 0))
+ {
+ p.makeDirectory();
+ files.insert(p.toString());
+ }
+ else if (!(options & GLOB_DIRS_ONLY))
+ {
+ files.insert(p.toString());
+ }
+ }
+ }
+ ++it;
+ }
+ }
+ catch (Exception&)
+ {
+ }
+}
+
+
+bool Glob::isDirectory(const Path& path, bool followSymlink)
+{
+ File f(path);
+ bool isDir = false;
+ try
+ {
+ isDir = f.isDirectory();
+ }
+ catch (Poco::Exception&)
+ {
+ return false;
+ }
+ if (isDir)
+ {
+ return true;
+ }
+ else if (followSymlink && f.isLink())
+ {
+ try
+ {
+ // Test if link resolves to a directory.
+ DirectoryIterator it(f);
+ return true;
+ }
+ catch (Exception&)
+ {
+ }
+ }
+ return false;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Hash.cpp b/contrib/libs/poco/Foundation/src/Hash.cpp
index c8a2772f59..be9c0bc462 100644
--- a/contrib/libs/poco/Foundation/src/Hash.cpp
+++ b/contrib/libs/poco/Foundation/src/Hash.cpp
@@ -1,34 +1,34 @@
-//
-// Hash.cpp
-//
-// Library: Foundation
-// Package: Hashing
-// Module: Hash
-//
-// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Hash.h"
-
-
-namespace Poco {
-
-
-std::size_t hash(const std::string& str)
-{
- std::size_t h = 0;
- std::string::const_iterator it = str.begin();
- std::string::const_iterator end = str.end();
- while (it != end)
- {
- h = h * 0xf4243 ^ *it++;
- }
- return h;
-}
-
-
-} // namespace Poco
+//
+// Hash.cpp
+//
+// Library: Foundation
+// Package: Hashing
+// Module: Hash
+//
+// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Hash.h"
+
+
+namespace Poco {
+
+
+std::size_t hash(const std::string& str)
+{
+ std::size_t h = 0;
+ std::string::const_iterator it = str.begin();
+ std::string::const_iterator end = str.end();
+ while (it != end)
+ {
+ h = h * 0xf4243 ^ *it++;
+ }
+ return h;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/HashStatistic.cpp b/contrib/libs/poco/Foundation/src/HashStatistic.cpp
index 52f618d7aa..a7adca3ba1 100644
--- a/contrib/libs/poco/Foundation/src/HashStatistic.cpp
+++ b/contrib/libs/poco/Foundation/src/HashStatistic.cpp
@@ -1,64 +1,64 @@
-//
-// HashStatistic.cpp
-//
-// Library: Foundation
-// Package: Hashing
-// Module: HashStatistic
-//
-// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/HashStatistic.h"
-#include <sstream>
-
-namespace Poco {
-
-
-HashStatistic::HashStatistic(
- UInt32 tableSize,
- UInt32 numEntries,
- UInt32 numZeroEntries,
- UInt32 maxEntry,
- std::vector<UInt32> details):
- _sizeOfTable(tableSize),
- _numberOfEntries(numEntries),
- _numZeroEntries(numZeroEntries),
- _maxEntriesPerHash(maxEntry),
- _detailedEntriesPerHash(details)
-{
-}
-
-
-HashStatistic::~HashStatistic()
-{
-}
-
-
-std::string HashStatistic::toString() const
-{
- std::ostringstream str;
- str << "HashTable of size " << _sizeOfTable << " containing " << _numberOfEntries << " entries:\n";
- str << " NumberOfZeroEntries: " << _numZeroEntries << "\n";
- str << " MaxEntry: " << _maxEntriesPerHash << "\n";
- str << " AvgEntry: " << avgEntriesPerHash() << ", excl Zero slots: " << avgEntriesPerHashExclZeroEntries() << "\n";
- str << " DetailedStatistics: \n";
- for (int i = 0; i < _detailedEntriesPerHash.size(); ++i)
- {
- // 10 entries per line
- if (i % 10 == 0)
- {
- str << "\n " << i << ":";
- }
- str << " " << _detailedEntriesPerHash[i];
- }
- str << "\n";
- str.flush();
- return str.str();
-}
-
-
-} // namespace Poco
+//
+// HashStatistic.cpp
+//
+// Library: Foundation
+// Package: Hashing
+// Module: HashStatistic
+//
+// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/HashStatistic.h"
+#include <sstream>
+
+namespace Poco {
+
+
+HashStatistic::HashStatistic(
+ UInt32 tableSize,
+ UInt32 numEntries,
+ UInt32 numZeroEntries,
+ UInt32 maxEntry,
+ std::vector<UInt32> details):
+ _sizeOfTable(tableSize),
+ _numberOfEntries(numEntries),
+ _numZeroEntries(numZeroEntries),
+ _maxEntriesPerHash(maxEntry),
+ _detailedEntriesPerHash(details)
+{
+}
+
+
+HashStatistic::~HashStatistic()
+{
+}
+
+
+std::string HashStatistic::toString() const
+{
+ std::ostringstream str;
+ str << "HashTable of size " << _sizeOfTable << " containing " << _numberOfEntries << " entries:\n";
+ str << " NumberOfZeroEntries: " << _numZeroEntries << "\n";
+ str << " MaxEntry: " << _maxEntriesPerHash << "\n";
+ str << " AvgEntry: " << avgEntriesPerHash() << ", excl Zero slots: " << avgEntriesPerHashExclZeroEntries() << "\n";
+ str << " DetailedStatistics: \n";
+ for (int i = 0; i < _detailedEntriesPerHash.size(); ++i)
+ {
+ // 10 entries per line
+ if (i % 10 == 0)
+ {
+ str << "\n " << i << ":";
+ }
+ str << " " << _detailedEntriesPerHash[i];
+ }
+ str << "\n";
+ str.flush();
+ return str.str();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/HexBinaryDecoder.cpp b/contrib/libs/poco/Foundation/src/HexBinaryDecoder.cpp
index 7c80ac8338..15cdbeb43b 100644
--- a/contrib/libs/poco/Foundation/src/HexBinaryDecoder.cpp
+++ b/contrib/libs/poco/Foundation/src/HexBinaryDecoder.cpp
@@ -1,94 +1,94 @@
-//
-// HexBinaryDecoder.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: HexBinary
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/HexBinaryDecoder.h"
-#include "Poco/Exception.h"
-
-
-namespace Poco {
-
-
-HexBinaryDecoderBuf::HexBinaryDecoderBuf(std::istream& istr):
- _buf(*istr.rdbuf())
-{
-}
-
-
-HexBinaryDecoderBuf::~HexBinaryDecoderBuf()
-{
-}
-
-
-int HexBinaryDecoderBuf::readFromDevice()
-{
- int c;
- int n;
- if ((n = readOne()) == -1) return -1;
- if (n >= '0' && n <= '9')
- c = n - '0';
- else if (n >= 'A' && n <= 'F')
- c = n - 'A' + 10;
- else if (n >= 'a' && n <= 'f')
- c = n - 'a' + 10;
- else throw DataFormatException();
- c <<= 4;
- if ((n = readOne()) == -1) throw DataFormatException();
- if (n >= '0' && n <= '9')
- c |= n - '0';
- else if (n >= 'A' && n <= 'F')
- c |= n - 'A' + 10;
- else if (n >= 'a' && n <= 'f')
- c |= n - 'a' + 10;
- else throw DataFormatException();
- return c;
-}
-
-
-int HexBinaryDecoderBuf::readOne()
-{
- int ch = _buf.sbumpc();
- while (ch == ' ' || ch == '\r' || ch == '\t' || ch == '\n')
- ch = _buf.sbumpc();
- return ch;
-}
-
-
-HexBinaryDecoderIOS::HexBinaryDecoderIOS(std::istream& istr): _buf(istr)
-{
- poco_ios_init(&_buf);
-}
-
-
-HexBinaryDecoderIOS::~HexBinaryDecoderIOS()
-{
-}
-
-
-HexBinaryDecoderBuf* HexBinaryDecoderIOS::rdbuf()
-{
- return &_buf;
-}
-
-
-HexBinaryDecoder::HexBinaryDecoder(std::istream& istr): HexBinaryDecoderIOS(istr), std::istream(&_buf)
-{
-}
-
-
-HexBinaryDecoder::~HexBinaryDecoder()
-{
-}
-
-
-} // namespace Poco
+//
+// HexBinaryDecoder.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: HexBinary
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/HexBinaryDecoder.h"
+#include "Poco/Exception.h"
+
+
+namespace Poco {
+
+
+HexBinaryDecoderBuf::HexBinaryDecoderBuf(std::istream& istr):
+ _buf(*istr.rdbuf())
+{
+}
+
+
+HexBinaryDecoderBuf::~HexBinaryDecoderBuf()
+{
+}
+
+
+int HexBinaryDecoderBuf::readFromDevice()
+{
+ int c;
+ int n;
+ if ((n = readOne()) == -1) return -1;
+ if (n >= '0' && n <= '9')
+ c = n - '0';
+ else if (n >= 'A' && n <= 'F')
+ c = n - 'A' + 10;
+ else if (n >= 'a' && n <= 'f')
+ c = n - 'a' + 10;
+ else throw DataFormatException();
+ c <<= 4;
+ if ((n = readOne()) == -1) throw DataFormatException();
+ if (n >= '0' && n <= '9')
+ c |= n - '0';
+ else if (n >= 'A' && n <= 'F')
+ c |= n - 'A' + 10;
+ else if (n >= 'a' && n <= 'f')
+ c |= n - 'a' + 10;
+ else throw DataFormatException();
+ return c;
+}
+
+
+int HexBinaryDecoderBuf::readOne()
+{
+ int ch = _buf.sbumpc();
+ while (ch == ' ' || ch == '\r' || ch == '\t' || ch == '\n')
+ ch = _buf.sbumpc();
+ return ch;
+}
+
+
+HexBinaryDecoderIOS::HexBinaryDecoderIOS(std::istream& istr): _buf(istr)
+{
+ poco_ios_init(&_buf);
+}
+
+
+HexBinaryDecoderIOS::~HexBinaryDecoderIOS()
+{
+}
+
+
+HexBinaryDecoderBuf* HexBinaryDecoderIOS::rdbuf()
+{
+ return &_buf;
+}
+
+
+HexBinaryDecoder::HexBinaryDecoder(std::istream& istr): HexBinaryDecoderIOS(istr), std::istream(&_buf)
+{
+}
+
+
+HexBinaryDecoder::~HexBinaryDecoder()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/HexBinaryEncoder.cpp b/contrib/libs/poco/Foundation/src/HexBinaryEncoder.cpp
index 728a2bfdfc..e19ac6a8e3 100644
--- a/contrib/libs/poco/Foundation/src/HexBinaryEncoder.cpp
+++ b/contrib/libs/poco/Foundation/src/HexBinaryEncoder.cpp
@@ -1,117 +1,117 @@
-//
-// HexBinaryEncoder.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: HexBinary
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/HexBinaryEncoder.h"
-
-
-namespace Poco {
-
-
-HexBinaryEncoderBuf::HexBinaryEncoderBuf(std::ostream& ostr):
- _pos(0),
- _lineLength(72),
- _uppercase(0),
- _buf(*ostr.rdbuf())
-{
-}
-
-
-HexBinaryEncoderBuf::~HexBinaryEncoderBuf()
-{
- try
- {
- close();
- }
- catch (...)
- {
- }
-}
-
-
-void HexBinaryEncoderBuf::setLineLength(int lineLength)
-{
- _lineLength = lineLength;
-}
-
-
-int HexBinaryEncoderBuf::getLineLength() const
-{
- return _lineLength;
-}
-
-
-void HexBinaryEncoderBuf::setUppercase(bool flag)
-{
- _uppercase = flag ? 16 : 0;
-}
-
-
-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 (_buf.sputc('\n') == eof) return eof;
- _pos = 0;
- }
- return charToInt(c);
-}
-
-
-int HexBinaryEncoderBuf::close()
-{
- sync();
- return _buf.pubsync();
-}
-
-
-HexBinaryEncoderIOS::HexBinaryEncoderIOS(std::ostream& ostr): _buf(ostr)
-{
- poco_ios_init(&_buf);
-}
-
-
-HexBinaryEncoderIOS::~HexBinaryEncoderIOS()
-{
-}
-
-
-int HexBinaryEncoderIOS::close()
-{
- return _buf.close();
-}
-
-
-HexBinaryEncoderBuf* HexBinaryEncoderIOS::rdbuf()
-{
- return &_buf;
-}
-
-
-HexBinaryEncoder::HexBinaryEncoder(std::ostream& ostr): HexBinaryEncoderIOS(ostr), std::ostream(&_buf)
-{
-}
-
-
-HexBinaryEncoder::~HexBinaryEncoder()
-{
-}
-
-
-} // namespace Poco
+//
+// HexBinaryEncoder.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: HexBinary
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/HexBinaryEncoder.h"
+
+
+namespace Poco {
+
+
+HexBinaryEncoderBuf::HexBinaryEncoderBuf(std::ostream& ostr):
+ _pos(0),
+ _lineLength(72),
+ _uppercase(0),
+ _buf(*ostr.rdbuf())
+{
+}
+
+
+HexBinaryEncoderBuf::~HexBinaryEncoderBuf()
+{
+ try
+ {
+ close();
+ }
+ catch (...)
+ {
+ }
+}
+
+
+void HexBinaryEncoderBuf::setLineLength(int lineLength)
+{
+ _lineLength = lineLength;
+}
+
+
+int HexBinaryEncoderBuf::getLineLength() const
+{
+ return _lineLength;
+}
+
+
+void HexBinaryEncoderBuf::setUppercase(bool flag)
+{
+ _uppercase = flag ? 16 : 0;
+}
+
+
+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 (_buf.sputc('\n') == eof) return eof;
+ _pos = 0;
+ }
+ return charToInt(c);
+}
+
+
+int HexBinaryEncoderBuf::close()
+{
+ sync();
+ return _buf.pubsync();
+}
+
+
+HexBinaryEncoderIOS::HexBinaryEncoderIOS(std::ostream& ostr): _buf(ostr)
+{
+ poco_ios_init(&_buf);
+}
+
+
+HexBinaryEncoderIOS::~HexBinaryEncoderIOS()
+{
+}
+
+
+int HexBinaryEncoderIOS::close()
+{
+ return _buf.close();
+}
+
+
+HexBinaryEncoderBuf* HexBinaryEncoderIOS::rdbuf()
+{
+ return &_buf;
+}
+
+
+HexBinaryEncoder::HexBinaryEncoder(std::ostream& ostr): HexBinaryEncoderIOS(ostr), std::ostream(&_buf)
+{
+}
+
+
+HexBinaryEncoder::~HexBinaryEncoder()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/InflatingStream.cpp b/contrib/libs/poco/Foundation/src/InflatingStream.cpp
index 68ba17763a..52fb0ddfed 100644
--- a/contrib/libs/poco/Foundation/src/InflatingStream.cpp
+++ b/contrib/libs/poco/Foundation/src/InflatingStream.cpp
@@ -1,360 +1,360 @@
-//
-// InflatingStream.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: ZLibStream
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/InflatingStream.h"
-#include "Poco/Exception.h"
-#include <cstring>
-
-
-namespace Poco {
-
-
-InflatingStreamBuf::InflatingStreamBuf(std::istream& istr, StreamType type):
- BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::in),
- _pIstr(&istr),
- _pOstr(0),
- _eof(false),
- _check(type != STREAM_ZIP)
-{
- _zstr.next_in = 0;
- _zstr.avail_in = 0;
- _zstr.total_in = 0;
- _zstr.next_out = 0;
- _zstr.avail_out = 0;
- _zstr.total_out = 0;
- _zstr.msg = 0;
- _zstr.state = 0;
- _zstr.zalloc = Z_NULL;
- _zstr.zfree = Z_NULL;
- _zstr.opaque = Z_NULL;
- _zstr.data_type = 0;
- _zstr.adler = 0;
- _zstr.reserved = 0;
-
- _buffer = new char[INFLATE_BUFFER_SIZE];
-
- int rc = inflateInit2(&_zstr, 15 + (type == STREAM_GZIP ? 16 : 0));
- if (rc != Z_OK)
- {
- delete [] _buffer;
+//
+// InflatingStream.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: ZLibStream
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/InflatingStream.h"
+#include "Poco/Exception.h"
+#include <cstring>
+
+
+namespace Poco {
+
+
+InflatingStreamBuf::InflatingStreamBuf(std::istream& istr, StreamType type):
+ BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::in),
+ _pIstr(&istr),
+ _pOstr(0),
+ _eof(false),
+ _check(type != STREAM_ZIP)
+{
+ _zstr.next_in = 0;
+ _zstr.avail_in = 0;
+ _zstr.total_in = 0;
+ _zstr.next_out = 0;
+ _zstr.avail_out = 0;
+ _zstr.total_out = 0;
+ _zstr.msg = 0;
+ _zstr.state = 0;
+ _zstr.zalloc = Z_NULL;
+ _zstr.zfree = Z_NULL;
+ _zstr.opaque = Z_NULL;
+ _zstr.data_type = 0;
+ _zstr.adler = 0;
+ _zstr.reserved = 0;
+
+ _buffer = new char[INFLATE_BUFFER_SIZE];
+
+ int rc = inflateInit2(&_zstr, 15 + (type == STREAM_GZIP ? 16 : 0));
+ if (rc != Z_OK)
+ {
+ delete [] _buffer;
+ throw IOException(zError(rc));
+ }
+}
+
+
+InflatingStreamBuf::InflatingStreamBuf(std::istream& istr, int windowBits):
+ BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::in),
+ _pIstr(&istr),
+ _pOstr(0),
+ _eof(false),
+ _check(false)
+{
+ _zstr.zalloc = Z_NULL;
+ _zstr.zfree = Z_NULL;
+ _zstr.opaque = Z_NULL;
+ _zstr.next_in = 0;
+ _zstr.avail_in = 0;
+ _zstr.next_out = 0;
+ _zstr.avail_out = 0;
+
+ _buffer = new char[INFLATE_BUFFER_SIZE];
+
+ int rc = inflateInit2(&_zstr, windowBits);
+ if (rc != Z_OK)
+ {
+ delete [] _buffer;
+ throw IOException(zError(rc));
+ }
+}
+
+
+InflatingStreamBuf::InflatingStreamBuf(std::ostream& ostr, StreamType type):
+ BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::out),
+ _pIstr(0),
+ _pOstr(&ostr),
+ _eof(false),
+ _check(type != STREAM_ZIP)
+{
+ _zstr.zalloc = Z_NULL;
+ _zstr.zfree = Z_NULL;
+ _zstr.opaque = Z_NULL;
+ _zstr.next_in = 0;
+ _zstr.avail_in = 0;
+ _zstr.next_out = 0;
+ _zstr.avail_out = 0;
+
+ _buffer = new char[INFLATE_BUFFER_SIZE];
+
+ int rc = inflateInit2(&_zstr, 15 + (type == STREAM_GZIP ? 16 : 0));
+ if (rc != Z_OK)
+ {
+ delete [] _buffer;
throw IOException(zError(rc));
- }
-}
-
-
-InflatingStreamBuf::InflatingStreamBuf(std::istream& istr, int windowBits):
- BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::in),
- _pIstr(&istr),
- _pOstr(0),
- _eof(false),
- _check(false)
-{
- _zstr.zalloc = Z_NULL;
- _zstr.zfree = Z_NULL;
- _zstr.opaque = Z_NULL;
- _zstr.next_in = 0;
- _zstr.avail_in = 0;
- _zstr.next_out = 0;
- _zstr.avail_out = 0;
-
- _buffer = new char[INFLATE_BUFFER_SIZE];
-
- int rc = inflateInit2(&_zstr, windowBits);
- if (rc != Z_OK)
- {
- delete [] _buffer;
+ }
+}
+
+
+InflatingStreamBuf::InflatingStreamBuf(std::ostream& ostr, int windowBits):
+ BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::out),
+ _pIstr(0),
+ _pOstr(&ostr),
+ _eof(false),
+ _check(false)
+{
+ _zstr.zalloc = Z_NULL;
+ _zstr.zfree = Z_NULL;
+ _zstr.opaque = Z_NULL;
+ _zstr.next_in = 0;
+ _zstr.avail_in = 0;
+ _zstr.next_out = 0;
+ _zstr.avail_out = 0;
+
+ _buffer = new char[INFLATE_BUFFER_SIZE];
+
+ int rc = inflateInit2(&_zstr, windowBits);
+ if (rc != Z_OK)
+ {
+ delete [] _buffer;
throw IOException(zError(rc));
- }
-}
-
-
-InflatingStreamBuf::InflatingStreamBuf(std::ostream& ostr, StreamType type):
- BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::out),
- _pIstr(0),
- _pOstr(&ostr),
- _eof(false),
- _check(type != STREAM_ZIP)
-{
- _zstr.zalloc = Z_NULL;
- _zstr.zfree = Z_NULL;
- _zstr.opaque = Z_NULL;
- _zstr.next_in = 0;
- _zstr.avail_in = 0;
- _zstr.next_out = 0;
- _zstr.avail_out = 0;
-
- _buffer = new char[INFLATE_BUFFER_SIZE];
-
- int rc = inflateInit2(&_zstr, 15 + (type == STREAM_GZIP ? 16 : 0));
- if (rc != Z_OK)
- {
- delete [] _buffer;
- throw IOException(zError(rc));
- }
-}
-
-
-InflatingStreamBuf::InflatingStreamBuf(std::ostream& ostr, int windowBits):
- BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::out),
- _pIstr(0),
- _pOstr(&ostr),
- _eof(false),
- _check(false)
-{
- _zstr.zalloc = Z_NULL;
- _zstr.zfree = Z_NULL;
- _zstr.opaque = Z_NULL;
- _zstr.next_in = 0;
- _zstr.avail_in = 0;
- _zstr.next_out = 0;
- _zstr.avail_out = 0;
-
- _buffer = new char[INFLATE_BUFFER_SIZE];
-
- int rc = inflateInit2(&_zstr, windowBits);
- if (rc != Z_OK)
- {
- delete [] _buffer;
- throw IOException(zError(rc));
- }
-}
-
-
-InflatingStreamBuf::~InflatingStreamBuf()
-{
- try
- {
- close();
- }
- catch (...)
- {
- }
- delete [] _buffer;
- inflateEnd(&_zstr);
-}
-
-
-int InflatingStreamBuf::close()
-{
- sync();
- _pIstr = 0;
- _pOstr = 0;
- return 0;
-}
-
-
-void InflatingStreamBuf::reset()
-{
- int rc = inflateReset(&_zstr);
- if (rc == Z_OK)
- _eof = false;
- else
- throw IOException(zError(rc));
-}
-
-
-int InflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length)
-{
- if (_eof || !_pIstr) return 0;
-
- if (_zstr.avail_in == 0)
- {
- int n = 0;
- if (_pIstr->good())
- {
- _pIstr->read(_buffer, INFLATE_BUFFER_SIZE);
- n = static_cast<int>(_pIstr->gcount());
- }
- _zstr.next_in = (unsigned char*) _buffer;
- _zstr.avail_in = n;
- }
- _zstr.next_out = (unsigned char*) buffer;
- _zstr.avail_out = static_cast<unsigned>(length);
- for (;;)
- {
- int rc = inflate(&_zstr, Z_NO_FLUSH);
- if (rc == Z_DATA_ERROR && !_check)
- {
- if (_zstr.avail_in == 0)
- {
- if (_pIstr->good())
- rc = Z_OK;
- else
- rc = Z_STREAM_END;
- }
- }
- if (rc == Z_STREAM_END)
- {
- _eof = true;
- return static_cast<int>(length) - _zstr.avail_out;
- }
- if (rc != Z_OK) throw IOException(zError(rc));
- if (_zstr.avail_out == 0)
- return static_cast<int>(length);
- if (_zstr.avail_in == 0)
- {
- int n = 0;
- if (_pIstr->good())
- {
- _pIstr->read(_buffer, INFLATE_BUFFER_SIZE);
- n = static_cast<int>(_pIstr->gcount());
- }
- if (n > 0)
- {
- _zstr.next_in = (unsigned char*) _buffer;
- _zstr.avail_in = n;
+ }
+}
+
+
+InflatingStreamBuf::~InflatingStreamBuf()
+{
+ try
+ {
+ close();
+ }
+ catch (...)
+ {
+ }
+ delete [] _buffer;
+ inflateEnd(&_zstr);
+}
+
+
+int InflatingStreamBuf::close()
+{
+ sync();
+ _pIstr = 0;
+ _pOstr = 0;
+ return 0;
+}
+
+
+void InflatingStreamBuf::reset()
+{
+ int rc = inflateReset(&_zstr);
+ if (rc == Z_OK)
+ _eof = false;
+ else
+ throw IOException(zError(rc));
+}
+
+
+int InflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length)
+{
+ if (_eof || !_pIstr) return 0;
+
+ if (_zstr.avail_in == 0)
+ {
+ int n = 0;
+ if (_pIstr->good())
+ {
+ _pIstr->read(_buffer, INFLATE_BUFFER_SIZE);
+ n = static_cast<int>(_pIstr->gcount());
+ }
+ _zstr.next_in = (unsigned char*) _buffer;
+ _zstr.avail_in = n;
+ }
+ _zstr.next_out = (unsigned char*) buffer;
+ _zstr.avail_out = static_cast<unsigned>(length);
+ for (;;)
+ {
+ int rc = inflate(&_zstr, Z_NO_FLUSH);
+ if (rc == Z_DATA_ERROR && !_check)
+ {
+ if (_zstr.avail_in == 0)
+ {
+ if (_pIstr->good())
+ rc = Z_OK;
+ else
+ rc = Z_STREAM_END;
}
- else return static_cast<int>(length) - _zstr.avail_out;
- }
- }
-}
-
-
-int InflatingStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
-{
- if (length == 0 || !_pOstr) return 0;
-
- _zstr.next_in = (unsigned char*) buffer;
- _zstr.avail_in = static_cast<unsigned>(length);
- _zstr.next_out = (unsigned char*) _buffer;
- _zstr.avail_out = INFLATE_BUFFER_SIZE;
- for (;;)
- {
- int rc = inflate(&_zstr, Z_NO_FLUSH);
- if (rc == Z_STREAM_END)
- {
- _pOstr->write(_buffer, INFLATE_BUFFER_SIZE - _zstr.avail_out);
- if (!_pOstr->good()) throw IOException(zError(rc));
- break;
- }
+ }
+ if (rc == Z_STREAM_END)
+ {
+ _eof = true;
+ return static_cast<int>(length) - _zstr.avail_out;
+ }
if (rc != Z_OK) throw IOException(zError(rc));
- if (_zstr.avail_out == 0)
- {
- _pOstr->write(_buffer, INFLATE_BUFFER_SIZE);
- if (!_pOstr->good()) throw IOException(zError(rc));
- _zstr.next_out = (unsigned char*) _buffer;
- _zstr.avail_out = INFLATE_BUFFER_SIZE;
- }
- if (_zstr.avail_in == 0)
- {
- _pOstr->write(_buffer, INFLATE_BUFFER_SIZE - _zstr.avail_out);
+ if (_zstr.avail_out == 0)
+ return static_cast<int>(length);
+ if (_zstr.avail_in == 0)
+ {
+ int n = 0;
+ if (_pIstr->good())
+ {
+ _pIstr->read(_buffer, INFLATE_BUFFER_SIZE);
+ n = static_cast<int>(_pIstr->gcount());
+ }
+ if (n > 0)
+ {
+ _zstr.next_in = (unsigned char*) _buffer;
+ _zstr.avail_in = n;
+ }
+ else return static_cast<int>(length) - _zstr.avail_out;
+ }
+ }
+}
+
+
+int InflatingStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
+{
+ if (length == 0 || !_pOstr) return 0;
+
+ _zstr.next_in = (unsigned char*) buffer;
+ _zstr.avail_in = static_cast<unsigned>(length);
+ _zstr.next_out = (unsigned char*) _buffer;
+ _zstr.avail_out = INFLATE_BUFFER_SIZE;
+ for (;;)
+ {
+ int rc = inflate(&_zstr, Z_NO_FLUSH);
+ if (rc == Z_STREAM_END)
+ {
+ _pOstr->write(_buffer, INFLATE_BUFFER_SIZE - _zstr.avail_out);
+ if (!_pOstr->good()) throw IOException(zError(rc));
+ break;
+ }
+ if (rc != Z_OK) throw IOException(zError(rc));
+ if (_zstr.avail_out == 0)
+ {
+ _pOstr->write(_buffer, INFLATE_BUFFER_SIZE);
if (!_pOstr->good()) throw IOException(zError(rc));
- _zstr.next_out = (unsigned char*) _buffer;
- _zstr.avail_out = INFLATE_BUFFER_SIZE;
- break;
- }
- }
- return static_cast<int>(length);
-}
-
-
-int InflatingStreamBuf::sync()
-{
- int n = BufferedStreamBuf::sync();
- if (!n && _pOstr) _pOstr->flush();
- return n;
-}
-
-
-InflatingIOS::InflatingIOS(std::ostream& ostr, InflatingStreamBuf::StreamType type):
- _buf(ostr, type)
-{
- poco_ios_init(&_buf);
-}
-
-
-InflatingIOS::InflatingIOS(std::ostream& ostr, int windowBits):
- _buf(ostr, windowBits)
-{
- poco_ios_init(&_buf);
-}
-
-
-InflatingIOS::InflatingIOS(std::istream& istr, InflatingStreamBuf::StreamType type):
- _buf(istr, type)
-{
- poco_ios_init(&_buf);
-}
-
-
-InflatingIOS::InflatingIOS(std::istream& istr, int windowBits):
- _buf(istr, windowBits)
-{
- poco_ios_init(&_buf);
-}
-
-
-InflatingIOS::~InflatingIOS()
-{
-}
-
-
-InflatingStreamBuf* InflatingIOS::rdbuf()
-{
- return &_buf;
-}
-
-
-InflatingOutputStream::InflatingOutputStream(std::ostream& ostr, InflatingStreamBuf::StreamType type):
- std::ostream(&_buf),
- InflatingIOS(ostr, type)
-{
-}
-
-
-InflatingOutputStream::InflatingOutputStream(std::ostream& ostr, int windowBits):
- std::ostream(&_buf),
- InflatingIOS(ostr, windowBits)
-{
-}
-
-
-InflatingOutputStream::~InflatingOutputStream()
-{
-}
-
-
-int InflatingOutputStream::close()
-{
- return _buf.close();
-}
-
-
-InflatingInputStream::InflatingInputStream(std::istream& istr, InflatingStreamBuf::StreamType type):
- std::istream(&_buf),
- InflatingIOS(istr, type)
-{
-}
-
-
-InflatingInputStream::InflatingInputStream(std::istream& istr, int windowBits):
- std::istream(&_buf),
- InflatingIOS(istr, windowBits)
-{
-}
-
-
-InflatingInputStream::~InflatingInputStream()
-{
-}
-
-
-void InflatingInputStream::reset()
-{
- _buf.reset();
- clear();
-}
-
-
-} // namespace Poco
+ _zstr.next_out = (unsigned char*) _buffer;
+ _zstr.avail_out = INFLATE_BUFFER_SIZE;
+ }
+ if (_zstr.avail_in == 0)
+ {
+ _pOstr->write(_buffer, INFLATE_BUFFER_SIZE - _zstr.avail_out);
+ if (!_pOstr->good()) throw IOException(zError(rc));
+ _zstr.next_out = (unsigned char*) _buffer;
+ _zstr.avail_out = INFLATE_BUFFER_SIZE;
+ break;
+ }
+ }
+ return static_cast<int>(length);
+}
+
+
+int InflatingStreamBuf::sync()
+{
+ int n = BufferedStreamBuf::sync();
+ if (!n && _pOstr) _pOstr->flush();
+ return n;
+}
+
+
+InflatingIOS::InflatingIOS(std::ostream& ostr, InflatingStreamBuf::StreamType type):
+ _buf(ostr, type)
+{
+ poco_ios_init(&_buf);
+}
+
+
+InflatingIOS::InflatingIOS(std::ostream& ostr, int windowBits):
+ _buf(ostr, windowBits)
+{
+ poco_ios_init(&_buf);
+}
+
+
+InflatingIOS::InflatingIOS(std::istream& istr, InflatingStreamBuf::StreamType type):
+ _buf(istr, type)
+{
+ poco_ios_init(&_buf);
+}
+
+
+InflatingIOS::InflatingIOS(std::istream& istr, int windowBits):
+ _buf(istr, windowBits)
+{
+ poco_ios_init(&_buf);
+}
+
+
+InflatingIOS::~InflatingIOS()
+{
+}
+
+
+InflatingStreamBuf* InflatingIOS::rdbuf()
+{
+ return &_buf;
+}
+
+
+InflatingOutputStream::InflatingOutputStream(std::ostream& ostr, InflatingStreamBuf::StreamType type):
+ std::ostream(&_buf),
+ InflatingIOS(ostr, type)
+{
+}
+
+
+InflatingOutputStream::InflatingOutputStream(std::ostream& ostr, int windowBits):
+ std::ostream(&_buf),
+ InflatingIOS(ostr, windowBits)
+{
+}
+
+
+InflatingOutputStream::~InflatingOutputStream()
+{
+}
+
+
+int InflatingOutputStream::close()
+{
+ return _buf.close();
+}
+
+
+InflatingInputStream::InflatingInputStream(std::istream& istr, InflatingStreamBuf::StreamType type):
+ std::istream(&_buf),
+ InflatingIOS(istr, type)
+{
+}
+
+
+InflatingInputStream::InflatingInputStream(std::istream& istr, int windowBits):
+ std::istream(&_buf),
+ InflatingIOS(istr, windowBits)
+{
+}
+
+
+InflatingInputStream::~InflatingInputStream()
+{
+}
+
+
+void InflatingInputStream::reset()
+{
+ _buf.reset();
+ clear();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/JSONString.cpp b/contrib/libs/poco/Foundation/src/JSONString.cpp
index 16049765d5..318d8c067c 100644
--- a/contrib/libs/poco/Foundation/src/JSONString.cpp
+++ b/contrib/libs/poco/Foundation/src/JSONString.cpp
@@ -1,101 +1,101 @@
-//
-// String.h
-//
-// Library: Foundation
-// Package: Core
-// Module: String
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-#include "Poco/JSONString.h"
-#include "Poco/UTF8String.h"
-#include <ostream>
-
-
-namespace {
-
-
-template<typename T, typename S>
-struct WriteFunc
-{
- typedef T& (T::*Type)(const char* s, S n);
-};
-
-
-
-template<typename T, typename S>
-void writeString(const std::string &value, T& obj, typename WriteFunc<T, S>::Type write, int options)
-{
- bool wrap = ((options & Poco::JSON_WRAP_STRINGS) != 0);
- bool escapeAllUnicode = ((options & Poco::JSON_ESCAPE_UNICODE) != 0);
-
- if (value.size() == 0)
- {
- if(wrap) (obj.*write)("\"\"", 2);
- return;
- }
-
- if(wrap) (obj.*write)("\"", 1);
- if(escapeAllUnicode)
- {
- std::string str = Poco::UTF8::escape(value.begin(), value.end(), true);
- (obj.*write)(str.c_str(), str.size());
- }
- else
- {
- for(std::string::const_iterator it = value.begin(), end = value.end(); it != end; ++it)
- {
- // Forward slash isn't strictly required by JSON spec, but some parsers expect it
- if((*it >= 0 && *it <= 31) || (*it == '"') || (*it == '\\') || (*it == '/'))
- {
- std::string str = Poco::UTF8::escape(it, it + 1, true);
- (obj.*write)(str.c_str(), str.size());
- }else (obj.*write)(&(*it), 1);
- }
- }
- if(wrap) (obj.*write)("\"", 1);
-};
-
-
-}
-
-
-namespace Poco {
-
-
-void toJSON(const std::string& value, std::ostream& out, bool wrap)
-{
- int options = (wrap ? Poco::JSON_WRAP_STRINGS : 0);
- writeString<std::ostream, std::streamsize>(value, out, &std::ostream::write, options);
-}
-
-
-std::string toJSON(const std::string& value, bool wrap)
-{
- int options = (wrap ? Poco::JSON_WRAP_STRINGS : 0);
- std::string ret;
- writeString<std::string,
- std::string::size_type>(value, ret, &std::string::append, options);
- return ret;
-}
-
-
-void toJSON(const std::string& value, std::ostream& out, int options)
-{
- writeString<std::ostream, std::streamsize>(value, out, &std::ostream::write, options);
-}
-
-
-std::string toJSON(const std::string& value, int options)
-{
- std::string ret;
- writeString<std::string, std::string::size_type>(value, ret, &std::string::append, options);
- return ret;
-}
-
-
-} // namespace Poco
+//
+// String.h
+//
+// Library: Foundation
+// Package: Core
+// Module: String
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+#include "Poco/JSONString.h"
+#include "Poco/UTF8String.h"
+#include <ostream>
+
+
+namespace {
+
+
+template<typename T, typename S>
+struct WriteFunc
+{
+ typedef T& (T::*Type)(const char* s, S n);
+};
+
+
+
+template<typename T, typename S>
+void writeString(const std::string &value, T& obj, typename WriteFunc<T, S>::Type write, int options)
+{
+ bool wrap = ((options & Poco::JSON_WRAP_STRINGS) != 0);
+ bool escapeAllUnicode = ((options & Poco::JSON_ESCAPE_UNICODE) != 0);
+
+ if (value.size() == 0)
+ {
+ if(wrap) (obj.*write)("\"\"", 2);
+ return;
+ }
+
+ if(wrap) (obj.*write)("\"", 1);
+ if(escapeAllUnicode)
+ {
+ std::string str = Poco::UTF8::escape(value.begin(), value.end(), true);
+ (obj.*write)(str.c_str(), str.size());
+ }
+ else
+ {
+ for(std::string::const_iterator it = value.begin(), end = value.end(); it != end; ++it)
+ {
+ // Forward slash isn't strictly required by JSON spec, but some parsers expect it
+ if((*it >= 0 && *it <= 31) || (*it == '"') || (*it == '\\') || (*it == '/'))
+ {
+ std::string str = Poco::UTF8::escape(it, it + 1, true);
+ (obj.*write)(str.c_str(), str.size());
+ }else (obj.*write)(&(*it), 1);
+ }
+ }
+ if(wrap) (obj.*write)("\"", 1);
+};
+
+
+}
+
+
+namespace Poco {
+
+
+void toJSON(const std::string& value, std::ostream& out, bool wrap)
+{
+ int options = (wrap ? Poco::JSON_WRAP_STRINGS : 0);
+ writeString<std::ostream, std::streamsize>(value, out, &std::ostream::write, options);
+}
+
+
+std::string toJSON(const std::string& value, bool wrap)
+{
+ int options = (wrap ? Poco::JSON_WRAP_STRINGS : 0);
+ std::string ret;
+ writeString<std::string,
+ std::string::size_type>(value, ret, &std::string::append, options);
+ return ret;
+}
+
+
+void toJSON(const std::string& value, std::ostream& out, int options)
+{
+ writeString<std::ostream, std::streamsize>(value, out, &std::ostream::write, options);
+}
+
+
+std::string toJSON(const std::string& value, int options)
+{
+ std::string ret;
+ writeString<std::string, std::string::size_type>(value, ret, &std::string::append, options);
+ return ret;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Latin1Encoding.cpp b/contrib/libs/poco/Foundation/src/Latin1Encoding.cpp
index 507fb7a5ce..5667168853 100644
--- a/contrib/libs/poco/Foundation/src/Latin1Encoding.cpp
+++ b/contrib/libs/poco/Foundation/src/Latin1Encoding.cpp
@@ -1,119 +1,119 @@
-//
-// Latin1Encoding.cpp
-//
-// Library: Foundation
-// Package: Text
-// Module: Latin1Encoding
-//
-// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Latin1Encoding.h"
-#include "Poco/String.h"
-
-
-namespace Poco {
-
-
-const char* Latin1Encoding::_names[] =
-{
- "ISO-8859-1",
- "Latin1",
- "Latin-1",
- NULL
-};
-
-
-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,
-};
-
-
-Latin1Encoding::Latin1Encoding()
-{
-}
-
-
-Latin1Encoding::~Latin1Encoding()
-{
-}
-
-
-const char* Latin1Encoding::canonicalName() const
-{
- return _names[0];
-}
-
-
-bool Latin1Encoding::isA(const std::string& encodingName) const
-{
- for (const char** name = _names; *name; ++name)
- {
- if (Poco::icompare(encodingName, *name) == 0)
- return true;
- }
- return false;
-}
-
-
-const TextEncoding::CharacterMap& Latin1Encoding::characterMap() const
-{
- return _charMap;
-}
-
-
-int Latin1Encoding::convert(const unsigned char* bytes) const
-{
- return *bytes;
-}
-
-
-int Latin1Encoding::convert(int ch, unsigned char* bytes, int length) const
-{
- if (ch >= 0 && ch <= 255)
- {
- if (bytes && length >= 1)
- *bytes = (unsigned char) ch;
- return 1;
- }
- else return 0;
-}
-
-
-int Latin1Encoding::queryConvert(const unsigned char* bytes, int length) const
-{
- if (1 <= length)
- return *bytes;
- else
- return -1;
-}
-
-
-int Latin1Encoding::sequenceLength(const unsigned char* /*bytes*/, int /*length*/) const
-{
- return 1;
-}
-
-
-} // namespace Poco
+//
+// Latin1Encoding.cpp
+//
+// Library: Foundation
+// Package: Text
+// Module: Latin1Encoding
+//
+// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Latin1Encoding.h"
+#include "Poco/String.h"
+
+
+namespace Poco {
+
+
+const char* Latin1Encoding::_names[] =
+{
+ "ISO-8859-1",
+ "Latin1",
+ "Latin-1",
+ NULL
+};
+
+
+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,
+};
+
+
+Latin1Encoding::Latin1Encoding()
+{
+}
+
+
+Latin1Encoding::~Latin1Encoding()
+{
+}
+
+
+const char* Latin1Encoding::canonicalName() const
+{
+ return _names[0];
+}
+
+
+bool Latin1Encoding::isA(const std::string& encodingName) const
+{
+ for (const char** name = _names; *name; ++name)
+ {
+ if (Poco::icompare(encodingName, *name) == 0)
+ return true;
+ }
+ return false;
+}
+
+
+const TextEncoding::CharacterMap& Latin1Encoding::characterMap() const
+{
+ return _charMap;
+}
+
+
+int Latin1Encoding::convert(const unsigned char* bytes) const
+{
+ return *bytes;
+}
+
+
+int Latin1Encoding::convert(int ch, unsigned char* bytes, int length) const
+{
+ if (ch >= 0 && ch <= 255)
+ {
+ if (bytes && length >= 1)
+ *bytes = (unsigned char) ch;
+ return 1;
+ }
+ else return 0;
+}
+
+
+int Latin1Encoding::queryConvert(const unsigned char* bytes, int length) const
+{
+ if (1 <= length)
+ return *bytes;
+ else
+ return -1;
+}
+
+
+int Latin1Encoding::sequenceLength(const unsigned char* /*bytes*/, int /*length*/) const
+{
+ return 1;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Latin2Encoding.cpp b/contrib/libs/poco/Foundation/src/Latin2Encoding.cpp
index daf98af678..074ea3dd85 100644
--- a/contrib/libs/poco/Foundation/src/Latin2Encoding.cpp
+++ b/contrib/libs/poco/Foundation/src/Latin2Encoding.cpp
@@ -1,179 +1,179 @@
-//
-// Latin2Encoding.cpp
-//
-// Library: Foundation
-// Package: Text
-// Module: Latin2Encoding
-//
-// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Latin2Encoding.h"
-#include "Poco/String.h"
-
-
-namespace Poco {
-
-
-const char* Latin2Encoding::_names[] =
-{
- "ISO-8859-2",
- "Latin2",
- "Latin-2",
- NULL
-};
-
-
-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,
- /* 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,
- /* d0 */ 0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7, 0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df,
- /* e0 */ 0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7, 0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f,
- /* f0 */ 0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7, 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9,
-};
-
-
-Latin2Encoding::Latin2Encoding()
-{
-}
-
-
-Latin2Encoding::~Latin2Encoding()
-{
-}
-
-
-const char* Latin2Encoding::canonicalName() const
-{
- return _names[0];
-}
-
-
-bool Latin2Encoding::isA(const std::string& encodingName) const
-{
- for (const char** name = _names; *name; ++name)
- {
- if (Poco::icompare(encodingName, *name) == 0)
- return true;
- }
- return false;
-}
-
-
-const TextEncoding::CharacterMap& Latin2Encoding::characterMap() const
-{
- return _charMap;
-}
-
-
-int Latin2Encoding::convert(const unsigned char* bytes) const
-{
- return _charMap[*bytes];
-}
-
-
-int Latin2Encoding::convert(int ch, unsigned char* bytes, int length) const
-{
- if (ch >= 0 && ch <= 255 && _charMap[ch] == ch)
- {
- if (bytes && length >= 1)
- *bytes = (unsigned char) ch;
- return 1;
- }
- switch(ch)
- {
- case 0x0104: if (bytes && length >= 1) *bytes = 0xa1; return 1;
- case 0x02d8: if (bytes && length >= 1) *bytes = 0xa2; return 1;
- case 0x0141: if (bytes && length >= 1) *bytes = 0xa3; return 1;
- case 0x013d: if (bytes && length >= 1) *bytes = 0xa5; return 1;
- case 0x015a: if (bytes && length >= 1) *bytes = 0xa6; return 1;
- case 0x0160: if (bytes && length >= 1) *bytes = 0xa9; return 1;
- case 0x015e: if (bytes && length >= 1) *bytes = 0xaa; return 1;
- case 0x0164: if (bytes && length >= 1) *bytes = 0xab; return 1;
- case 0x0179: if (bytes && length >= 1) *bytes = 0xac; return 1;
- case 0x017d: if (bytes && length >= 1) *bytes = 0xae; return 1;
- case 0x017b: if (bytes && length >= 1) *bytes = 0xaf; return 1;
- case 0x0105: if (bytes && length >= 1) *bytes = 0xb1; return 1;
- case 0x02db: if (bytes && length >= 1) *bytes = 0xb2; return 1;
- case 0x0142: if (bytes && length >= 1) *bytes = 0xb3; return 1;
- case 0x013e: if (bytes && length >= 1) *bytes = 0xb5; return 1;
- case 0x015b: if (bytes && length >= 1) *bytes = 0xb6; return 1;
- case 0x02c7: if (bytes && length >= 1) *bytes = 0xb7; return 1;
- case 0x0161: if (bytes && length >= 1) *bytes = 0xb9; return 1;
- case 0x015f: if (bytes && length >= 1) *bytes = 0xba; return 1;
- case 0x0165: if (bytes && length >= 1) *bytes = 0xbb; return 1;
- case 0x017a: if (bytes && length >= 1) *bytes = 0xbc; return 1;
- case 0x02dd: if (bytes && length >= 1) *bytes = 0xbd; return 1;
- case 0x017e: if (bytes && length >= 1) *bytes = 0xbe; return 1;
- case 0x017c: if (bytes && length >= 1) *bytes = 0xbf; return 1;
- case 0x0154: if (bytes && length >= 1) *bytes = 0xc0; return 1;
- case 0x0102: if (bytes && length >= 1) *bytes = 0xc3; return 1;
- case 0x0139: if (bytes && length >= 1) *bytes = 0xc5; return 1;
- case 0x0106: if (bytes && length >= 1) *bytes = 0xc6; return 1;
- case 0x010c: if (bytes && length >= 1) *bytes = 0xc8; return 1;
- case 0x0118: if (bytes && length >= 1) *bytes = 0xca; return 1;
- case 0x011a: if (bytes && length >= 1) *bytes = 0xcc; return 1;
- case 0x010e: if (bytes && length >= 1) *bytes = 0xcf; return 1;
- case 0x0110: if (bytes && length >= 1) *bytes = 0xd0; return 1;
- case 0x0143: if (bytes && length >= 1) *bytes = 0xd1; return 1;
- case 0x0147: if (bytes && length >= 1) *bytes = 0xd2; return 1;
- case 0x0150: if (bytes && length >= 1) *bytes = 0xd5; return 1;
- case 0x0158: if (bytes && length >= 1) *bytes = 0xd8; return 1;
- case 0x016e: if (bytes && length >= 1) *bytes = 0xd9; return 1;
- case 0x0170: if (bytes && length >= 1) *bytes = 0xdb; return 1;
- case 0x0162: if (bytes && length >= 1) *bytes = 0xde; return 1;
- case 0x0155: if (bytes && length >= 1) *bytes = 0xe0; return 1;
- case 0x0103: if (bytes && length >= 1) *bytes = 0xe3; return 1;
- case 0x013a: if (bytes && length >= 1) *bytes = 0xe5; return 1;
- case 0x0107: if (bytes && length >= 1) *bytes = 0xe6; return 1;
- case 0x010d: if (bytes && length >= 1) *bytes = 0xe8; return 1;
- case 0x0119: if (bytes && length >= 1) *bytes = 0xea; return 1;
- case 0x011b: if (bytes && length >= 1) *bytes = 0xec; return 1;
- case 0x010f: if (bytes && length >= 1) *bytes = 0xef; return 1;
- case 0x0111: if (bytes && length >= 1) *bytes = 0xf0; return 1;
- case 0x0144: if (bytes && length >= 1) *bytes = 0xf1; return 1;
- case 0x0148: if (bytes && length >= 1) *bytes = 0xf2; return 1;
- case 0x0151: if (bytes && length >= 1) *bytes = 0xf5; return 1;
- case 0x0159: if (bytes && length >= 1) *bytes = 0xf8; return 1;
- case 0x016f: if (bytes && length >= 1) *bytes = 0xf9; return 1;
- case 0x0171: if (bytes && length >= 1) *bytes = 0xfb; return 1;
- case 0x0163: if (bytes && length >= 1) *bytes = 0xfe; return 1;
- case 0x02d9: if (bytes && length >= 1) *bytes = 0xff; return 1;
- default: return 0;
- }
-}
-
-
-int Latin2Encoding::queryConvert(const unsigned char* bytes, int length) const
-{
- if (1 <= length)
- return _charMap[*bytes];
- else
- return -1;
-}
-
-
-int Latin2Encoding::sequenceLength(const unsigned char* /*bytes*/, int /*length*/) const
-{
- return 1;
-}
-
-
-} // namespace Poco
+//
+// Latin2Encoding.cpp
+//
+// Library: Foundation
+// Package: Text
+// Module: Latin2Encoding
+//
+// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Latin2Encoding.h"
+#include "Poco/String.h"
+
+
+namespace Poco {
+
+
+const char* Latin2Encoding::_names[] =
+{
+ "ISO-8859-2",
+ "Latin2",
+ "Latin-2",
+ NULL
+};
+
+
+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,
+ /* 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,
+ /* d0 */ 0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7, 0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df,
+ /* e0 */ 0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7, 0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f,
+ /* f0 */ 0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7, 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9,
+};
+
+
+Latin2Encoding::Latin2Encoding()
+{
+}
+
+
+Latin2Encoding::~Latin2Encoding()
+{
+}
+
+
+const char* Latin2Encoding::canonicalName() const
+{
+ return _names[0];
+}
+
+
+bool Latin2Encoding::isA(const std::string& encodingName) const
+{
+ for (const char** name = _names; *name; ++name)
+ {
+ if (Poco::icompare(encodingName, *name) == 0)
+ return true;
+ }
+ return false;
+}
+
+
+const TextEncoding::CharacterMap& Latin2Encoding::characterMap() const
+{
+ return _charMap;
+}
+
+
+int Latin2Encoding::convert(const unsigned char* bytes) const
+{
+ return _charMap[*bytes];
+}
+
+
+int Latin2Encoding::convert(int ch, unsigned char* bytes, int length) const
+{
+ if (ch >= 0 && ch <= 255 && _charMap[ch] == ch)
+ {
+ if (bytes && length >= 1)
+ *bytes = (unsigned char) ch;
+ return 1;
+ }
+ switch(ch)
+ {
+ case 0x0104: if (bytes && length >= 1) *bytes = 0xa1; return 1;
+ case 0x02d8: if (bytes && length >= 1) *bytes = 0xa2; return 1;
+ case 0x0141: if (bytes && length >= 1) *bytes = 0xa3; return 1;
+ case 0x013d: if (bytes && length >= 1) *bytes = 0xa5; return 1;
+ case 0x015a: if (bytes && length >= 1) *bytes = 0xa6; return 1;
+ case 0x0160: if (bytes && length >= 1) *bytes = 0xa9; return 1;
+ case 0x015e: if (bytes && length >= 1) *bytes = 0xaa; return 1;
+ case 0x0164: if (bytes && length >= 1) *bytes = 0xab; return 1;
+ case 0x0179: if (bytes && length >= 1) *bytes = 0xac; return 1;
+ case 0x017d: if (bytes && length >= 1) *bytes = 0xae; return 1;
+ case 0x017b: if (bytes && length >= 1) *bytes = 0xaf; return 1;
+ case 0x0105: if (bytes && length >= 1) *bytes = 0xb1; return 1;
+ case 0x02db: if (bytes && length >= 1) *bytes = 0xb2; return 1;
+ case 0x0142: if (bytes && length >= 1) *bytes = 0xb3; return 1;
+ case 0x013e: if (bytes && length >= 1) *bytes = 0xb5; return 1;
+ case 0x015b: if (bytes && length >= 1) *bytes = 0xb6; return 1;
+ case 0x02c7: if (bytes && length >= 1) *bytes = 0xb7; return 1;
+ case 0x0161: if (bytes && length >= 1) *bytes = 0xb9; return 1;
+ case 0x015f: if (bytes && length >= 1) *bytes = 0xba; return 1;
+ case 0x0165: if (bytes && length >= 1) *bytes = 0xbb; return 1;
+ case 0x017a: if (bytes && length >= 1) *bytes = 0xbc; return 1;
+ case 0x02dd: if (bytes && length >= 1) *bytes = 0xbd; return 1;
+ case 0x017e: if (bytes && length >= 1) *bytes = 0xbe; return 1;
+ case 0x017c: if (bytes && length >= 1) *bytes = 0xbf; return 1;
+ case 0x0154: if (bytes && length >= 1) *bytes = 0xc0; return 1;
+ case 0x0102: if (bytes && length >= 1) *bytes = 0xc3; return 1;
+ case 0x0139: if (bytes && length >= 1) *bytes = 0xc5; return 1;
+ case 0x0106: if (bytes && length >= 1) *bytes = 0xc6; return 1;
+ case 0x010c: if (bytes && length >= 1) *bytes = 0xc8; return 1;
+ case 0x0118: if (bytes && length >= 1) *bytes = 0xca; return 1;
+ case 0x011a: if (bytes && length >= 1) *bytes = 0xcc; return 1;
+ case 0x010e: if (bytes && length >= 1) *bytes = 0xcf; return 1;
+ case 0x0110: if (bytes && length >= 1) *bytes = 0xd0; return 1;
+ case 0x0143: if (bytes && length >= 1) *bytes = 0xd1; return 1;
+ case 0x0147: if (bytes && length >= 1) *bytes = 0xd2; return 1;
+ case 0x0150: if (bytes && length >= 1) *bytes = 0xd5; return 1;
+ case 0x0158: if (bytes && length >= 1) *bytes = 0xd8; return 1;
+ case 0x016e: if (bytes && length >= 1) *bytes = 0xd9; return 1;
+ case 0x0170: if (bytes && length >= 1) *bytes = 0xdb; return 1;
+ case 0x0162: if (bytes && length >= 1) *bytes = 0xde; return 1;
+ case 0x0155: if (bytes && length >= 1) *bytes = 0xe0; return 1;
+ case 0x0103: if (bytes && length >= 1) *bytes = 0xe3; return 1;
+ case 0x013a: if (bytes && length >= 1) *bytes = 0xe5; return 1;
+ case 0x0107: if (bytes && length >= 1) *bytes = 0xe6; return 1;
+ case 0x010d: if (bytes && length >= 1) *bytes = 0xe8; return 1;
+ case 0x0119: if (bytes && length >= 1) *bytes = 0xea; return 1;
+ case 0x011b: if (bytes && length >= 1) *bytes = 0xec; return 1;
+ case 0x010f: if (bytes && length >= 1) *bytes = 0xef; return 1;
+ case 0x0111: if (bytes && length >= 1) *bytes = 0xf0; return 1;
+ case 0x0144: if (bytes && length >= 1) *bytes = 0xf1; return 1;
+ case 0x0148: if (bytes && length >= 1) *bytes = 0xf2; return 1;
+ case 0x0151: if (bytes && length >= 1) *bytes = 0xf5; return 1;
+ case 0x0159: if (bytes && length >= 1) *bytes = 0xf8; return 1;
+ case 0x016f: if (bytes && length >= 1) *bytes = 0xf9; return 1;
+ case 0x0171: if (bytes && length >= 1) *bytes = 0xfb; return 1;
+ case 0x0163: if (bytes && length >= 1) *bytes = 0xfe; return 1;
+ case 0x02d9: if (bytes && length >= 1) *bytes = 0xff; return 1;
+ default: return 0;
+ }
+}
+
+
+int Latin2Encoding::queryConvert(const unsigned char* bytes, int length) const
+{
+ if (1 <= length)
+ return _charMap[*bytes];
+ else
+ return -1;
+}
+
+
+int Latin2Encoding::sequenceLength(const unsigned char* /*bytes*/, int /*length*/) const
+{
+ return 1;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Latin9Encoding.cpp b/contrib/libs/poco/Foundation/src/Latin9Encoding.cpp
index 7a99b5c636..64d5bc1bd9 100644
--- a/contrib/libs/poco/Foundation/src/Latin9Encoding.cpp
+++ b/contrib/libs/poco/Foundation/src/Latin9Encoding.cpp
@@ -1,130 +1,130 @@
-//
-// Latin9Encoding.cpp
-//
-// Library: Foundation
-// Package: Text
-// Module: Latin9Encoding
-//
-// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Latin9Encoding.h"
-#include "Poco/String.h"
-
-
-namespace Poco {
-
-
-const char* Latin9Encoding::_names[] =
-{
- "ISO-8859-15",
- "Latin9",
- "Latin-9",
- NULL
-};
-
-
-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,
-};
-
-
-Latin9Encoding::Latin9Encoding()
-{
-}
-
-
-Latin9Encoding::~Latin9Encoding()
-{
-}
-
-
-const char* Latin9Encoding::canonicalName() const
-{
- return _names[0];
-}
-
-
-bool Latin9Encoding::isA(const std::string& encodingName) const
-{
- for (const char** name = _names; *name; ++name)
- {
- if (Poco::icompare(encodingName, *name) == 0)
- return true;
- }
- return false;
-}
-
-
-const TextEncoding::CharacterMap& Latin9Encoding::characterMap() const
-{
- return _charMap;
-}
-
-
-int Latin9Encoding::convert(const unsigned char* bytes) const
-{
- return _charMap[*bytes];
-}
-
-
-int Latin9Encoding::convert(int ch, unsigned char* bytes, int length) const
-{
- if (ch >= 0 && ch <= 255 && _charMap[ch] == ch)
- {
- if (bytes && length >= 1)
- *bytes = static_cast<UInt8>(ch);
- return 1;
- }
- else switch (ch)
- {
- case 0x0152: if (bytes && length >= 1) *bytes = 0xbc; return 1;
- case 0x0153: if (bytes && length >= 1) *bytes = 0xbd; return 1;
- case 0x0160: if (bytes && length >= 1) *bytes = 0xa6; return 1;
- case 0x0161: if (bytes && length >= 1) *bytes = 0xa8; return 1;
- case 0x017d: if (bytes && length >= 1) *bytes = 0xb4; return 1;
- case 0x017e: if (bytes && length >= 1) *bytes = 0xb8; return 1;
- case 0x0178: if (bytes && length >= 1) *bytes = 0xbe; return 1;
- case 0x20ac: if (bytes && length >= 1) *bytes = 0xa4; return 1;
- default: return 0;
- }
-}
-
-
-int Latin9Encoding::queryConvert(const unsigned char* bytes, int length) const
-{
- if (1 <= length)
- return _charMap[*bytes];
- else
- return -1;
-}
-
-
-int Latin9Encoding::sequenceLength(const unsigned char* /*bytes*/, int /*length*/) const
-{
- return 1;
-}
-
-
-} // namespace Poco
+//
+// Latin9Encoding.cpp
+//
+// Library: Foundation
+// Package: Text
+// Module: Latin9Encoding
+//
+// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Latin9Encoding.h"
+#include "Poco/String.h"
+
+
+namespace Poco {
+
+
+const char* Latin9Encoding::_names[] =
+{
+ "ISO-8859-15",
+ "Latin9",
+ "Latin-9",
+ NULL
+};
+
+
+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,
+};
+
+
+Latin9Encoding::Latin9Encoding()
+{
+}
+
+
+Latin9Encoding::~Latin9Encoding()
+{
+}
+
+
+const char* Latin9Encoding::canonicalName() const
+{
+ return _names[0];
+}
+
+
+bool Latin9Encoding::isA(const std::string& encodingName) const
+{
+ for (const char** name = _names; *name; ++name)
+ {
+ if (Poco::icompare(encodingName, *name) == 0)
+ return true;
+ }
+ return false;
+}
+
+
+const TextEncoding::CharacterMap& Latin9Encoding::characterMap() const
+{
+ return _charMap;
+}
+
+
+int Latin9Encoding::convert(const unsigned char* bytes) const
+{
+ return _charMap[*bytes];
+}
+
+
+int Latin9Encoding::convert(int ch, unsigned char* bytes, int length) const
+{
+ if (ch >= 0 && ch <= 255 && _charMap[ch] == ch)
+ {
+ if (bytes && length >= 1)
+ *bytes = static_cast<UInt8>(ch);
+ return 1;
+ }
+ else switch (ch)
+ {
+ case 0x0152: if (bytes && length >= 1) *bytes = 0xbc; return 1;
+ case 0x0153: if (bytes && length >= 1) *bytes = 0xbd; return 1;
+ case 0x0160: if (bytes && length >= 1) *bytes = 0xa6; return 1;
+ case 0x0161: if (bytes && length >= 1) *bytes = 0xa8; return 1;
+ case 0x017d: if (bytes && length >= 1) *bytes = 0xb4; return 1;
+ case 0x017e: if (bytes && length >= 1) *bytes = 0xb8; return 1;
+ case 0x0178: if (bytes && length >= 1) *bytes = 0xbe; return 1;
+ case 0x20ac: if (bytes && length >= 1) *bytes = 0xa4; return 1;
+ default: return 0;
+ }
+}
+
+
+int Latin9Encoding::queryConvert(const unsigned char* bytes, int length) const
+{
+ if (1 <= length)
+ return _charMap[*bytes];
+ else
+ return -1;
+}
+
+
+int Latin9Encoding::sequenceLength(const unsigned char* /*bytes*/, int /*length*/) const
+{
+ return 1;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/LineEndingConverter.cpp b/contrib/libs/poco/Foundation/src/LineEndingConverter.cpp
index 49b4b71229..4d5ad7d2ae 100644
--- a/contrib/libs/poco/Foundation/src/LineEndingConverter.cpp
+++ b/contrib/libs/poco/Foundation/src/LineEndingConverter.cpp
@@ -1,175 +1,175 @@
-//
-// LineEndingConverter.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: LineEndingConverter
-//
-// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/LineEndingConverter.h"
-
-
-namespace Poco {
-
-
-const std::string LineEnding::NEWLINE_DEFAULT(POCO_DEFAULT_NEWLINE_CHARS);
-const std::string LineEnding::NEWLINE_CR("\r");
-const std::string LineEnding::NEWLINE_CRLF("\r\n");
-const std::string LineEnding::NEWLINE_LF("\n");
-
-
-LineEndingConverterStreamBuf::LineEndingConverterStreamBuf(std::istream& istr):
- _pIstr(&istr),
- _pOstr(0),
- _newLine(LineEnding::NEWLINE_DEFAULT),
- _lastChar(0)
-{
- _it = _newLine.end();
-}
-
-
-LineEndingConverterStreamBuf::LineEndingConverterStreamBuf(std::ostream& ostr):
- _pIstr(0),
- _pOstr(&ostr),
- _newLine(LineEnding::NEWLINE_DEFAULT),
- _lastChar(0)
-{
- _it = _newLine.end();
-}
-
-
-LineEndingConverterStreamBuf::~LineEndingConverterStreamBuf()
-{
-}
-
-
-void LineEndingConverterStreamBuf::setNewLine(const std::string& newLineCharacters)
-{
- _newLine = newLineCharacters;
- _it = _newLine.end();
-}
-
-
-const std::string& LineEndingConverterStreamBuf::getNewLine() const
-{
- return _newLine;
-}
-
-
-int LineEndingConverterStreamBuf::readFromDevice()
-{
- poco_assert_dbg (_pIstr);
-
- while (_it == _newLine.end())
- {
- int c = _pIstr->get();
- if (c == '\r')
- {
- if (_pIstr->peek() == '\n') _pIstr->get();
- _it = _newLine.begin();
- }
- else if (c == '\n')
- {
- _it = _newLine.begin();
- }
- else return c;
- }
- return *_it++;
-}
-
-
-int LineEndingConverterStreamBuf::writeToDevice(char c)
-{
- poco_assert_dbg (_pOstr);
-
- if (c == '\r' || (c == '\n' && _lastChar != '\r'))
- _pOstr->write(_newLine.data(), (std::streamsize) _newLine.length());
- if (c != '\n' && c != '\r')
- _pOstr->put(c);
- _lastChar = c;
- return charToInt(c);
-}
-
-
-LineEndingConverterIOS::LineEndingConverterIOS(std::istream& istr): _buf(istr)
-{
- poco_ios_init(&_buf);
-}
-
-
-LineEndingConverterIOS::LineEndingConverterIOS(std::ostream& ostr): _buf(ostr)
-{
- poco_ios_init(&_buf);
-}
-
-
-LineEndingConverterIOS::~LineEndingConverterIOS()
-{
-}
-
-
-void LineEndingConverterIOS::setNewLine(const std::string& newLineCharacters)
-{
- _buf.setNewLine(newLineCharacters);
-}
-
-
-const std::string& LineEndingConverterIOS::getNewLine() const
-{
- return _buf.getNewLine();
-}
-
-
-LineEndingConverterStreamBuf* LineEndingConverterIOS::rdbuf()
-{
- return &_buf;
-}
-
-
-InputLineEndingConverter::InputLineEndingConverter(std::istream& istr):
- LineEndingConverterIOS(istr),
- std::istream(&_buf)
-{
-}
-
-
-InputLineEndingConverter::InputLineEndingConverter(std::istream& istr, const std::string& newLineCharacters):
- LineEndingConverterIOS(istr),
- std::istream(&_buf)
-{
- setNewLine(newLineCharacters);
-}
-
-
-InputLineEndingConverter::~InputLineEndingConverter()
-{
-}
-
-
-OutputLineEndingConverter::OutputLineEndingConverter(std::ostream& ostr):
- LineEndingConverterIOS(ostr),
- std::ostream(&_buf)
-{
-}
-
-
-OutputLineEndingConverter::OutputLineEndingConverter(std::ostream& ostr, const std::string& newLineCharacters):
- LineEndingConverterIOS(ostr),
- std::ostream(&_buf)
-{
- setNewLine(newLineCharacters);
-}
-
-
-OutputLineEndingConverter::~OutputLineEndingConverter()
-{
-}
-
-
-} // namespace Poco
+//
+// LineEndingConverter.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: LineEndingConverter
+//
+// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/LineEndingConverter.h"
+
+
+namespace Poco {
+
+
+const std::string LineEnding::NEWLINE_DEFAULT(POCO_DEFAULT_NEWLINE_CHARS);
+const std::string LineEnding::NEWLINE_CR("\r");
+const std::string LineEnding::NEWLINE_CRLF("\r\n");
+const std::string LineEnding::NEWLINE_LF("\n");
+
+
+LineEndingConverterStreamBuf::LineEndingConverterStreamBuf(std::istream& istr):
+ _pIstr(&istr),
+ _pOstr(0),
+ _newLine(LineEnding::NEWLINE_DEFAULT),
+ _lastChar(0)
+{
+ _it = _newLine.end();
+}
+
+
+LineEndingConverterStreamBuf::LineEndingConverterStreamBuf(std::ostream& ostr):
+ _pIstr(0),
+ _pOstr(&ostr),
+ _newLine(LineEnding::NEWLINE_DEFAULT),
+ _lastChar(0)
+{
+ _it = _newLine.end();
+}
+
+
+LineEndingConverterStreamBuf::~LineEndingConverterStreamBuf()
+{
+}
+
+
+void LineEndingConverterStreamBuf::setNewLine(const std::string& newLineCharacters)
+{
+ _newLine = newLineCharacters;
+ _it = _newLine.end();
+}
+
+
+const std::string& LineEndingConverterStreamBuf::getNewLine() const
+{
+ return _newLine;
+}
+
+
+int LineEndingConverterStreamBuf::readFromDevice()
+{
+ poco_assert_dbg (_pIstr);
+
+ while (_it == _newLine.end())
+ {
+ int c = _pIstr->get();
+ if (c == '\r')
+ {
+ if (_pIstr->peek() == '\n') _pIstr->get();
+ _it = _newLine.begin();
+ }
+ else if (c == '\n')
+ {
+ _it = _newLine.begin();
+ }
+ else return c;
+ }
+ return *_it++;
+}
+
+
+int LineEndingConverterStreamBuf::writeToDevice(char c)
+{
+ poco_assert_dbg (_pOstr);
+
+ if (c == '\r' || (c == '\n' && _lastChar != '\r'))
+ _pOstr->write(_newLine.data(), (std::streamsize) _newLine.length());
+ if (c != '\n' && c != '\r')
+ _pOstr->put(c);
+ _lastChar = c;
+ return charToInt(c);
+}
+
+
+LineEndingConverterIOS::LineEndingConverterIOS(std::istream& istr): _buf(istr)
+{
+ poco_ios_init(&_buf);
+}
+
+
+LineEndingConverterIOS::LineEndingConverterIOS(std::ostream& ostr): _buf(ostr)
+{
+ poco_ios_init(&_buf);
+}
+
+
+LineEndingConverterIOS::~LineEndingConverterIOS()
+{
+}
+
+
+void LineEndingConverterIOS::setNewLine(const std::string& newLineCharacters)
+{
+ _buf.setNewLine(newLineCharacters);
+}
+
+
+const std::string& LineEndingConverterIOS::getNewLine() const
+{
+ return _buf.getNewLine();
+}
+
+
+LineEndingConverterStreamBuf* LineEndingConverterIOS::rdbuf()
+{
+ return &_buf;
+}
+
+
+InputLineEndingConverter::InputLineEndingConverter(std::istream& istr):
+ LineEndingConverterIOS(istr),
+ std::istream(&_buf)
+{
+}
+
+
+InputLineEndingConverter::InputLineEndingConverter(std::istream& istr, const std::string& newLineCharacters):
+ LineEndingConverterIOS(istr),
+ std::istream(&_buf)
+{
+ setNewLine(newLineCharacters);
+}
+
+
+InputLineEndingConverter::~InputLineEndingConverter()
+{
+}
+
+
+OutputLineEndingConverter::OutputLineEndingConverter(std::ostream& ostr):
+ LineEndingConverterIOS(ostr),
+ std::ostream(&_buf)
+{
+}
+
+
+OutputLineEndingConverter::OutputLineEndingConverter(std::ostream& ostr, const std::string& newLineCharacters):
+ LineEndingConverterIOS(ostr),
+ std::ostream(&_buf)
+{
+ setNewLine(newLineCharacters);
+}
+
+
+OutputLineEndingConverter::~OutputLineEndingConverter()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/LocalDateTime.cpp b/contrib/libs/poco/Foundation/src/LocalDateTime.cpp
index cfdb4e1a3a..fcce3a8480 100644
--- a/contrib/libs/poco/Foundation/src/LocalDateTime.cpp
+++ b/contrib/libs/poco/Foundation/src/LocalDateTime.cpp
@@ -1,317 +1,317 @@
-//
-// LocalDateTime.cpp
-//
-// Library: Foundation
-// Package: DateTime
-// Module: LocalDateTime
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/LocalDateTime.h"
-#include "Poco/Timezone.h"
-#include "Poco/Timespan.h"
-#include "Poco/Exception.h"
-#include <algorithm>
-#include <ctime>
-#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
-#error #include "wce_time.h"
-#endif
-
-
-namespace Poco {
-
-
-LocalDateTime::LocalDateTime()
-{
- determineTzd(true);
-}
-
-
-LocalDateTime::LocalDateTime(int otherYear, int otherMonth, int otherDay, int otherHour, int otherMinute, int otherSecond, int otherMillisecond, int otherMicrosecond):
- _dateTime(otherYear, otherMonth, otherDay, otherHour, otherMinute, otherSecond, otherMillisecond, otherMicrosecond)
-{
- determineTzd();
-}
-
-
-LocalDateTime::LocalDateTime(int otherTzd, int otherYear, int otherMonth, int otherDay, int otherHour, int otherMinute, int otherSecond, int otherMillisecond, int otherMicrosecond):
- _dateTime(otherYear, otherMonth, otherDay, otherHour, otherMinute, otherSecond, otherMillisecond, otherMicrosecond),
- _tzd(otherTzd)
-{
-}
-
-
-LocalDateTime::LocalDateTime(double otherJulianDay):
- _dateTime(otherJulianDay)
-{
- determineTzd(true);
-}
-
-
-LocalDateTime::LocalDateTime(int otherTzd, double otherJulianDay):
- _dateTime(otherJulianDay),
- _tzd(otherTzd)
-{
- adjustForTzd();
-}
-
-
-LocalDateTime::LocalDateTime(const DateTime& dateTime):
- _dateTime(dateTime)
-{
- determineTzd(true);
-}
-
-
-LocalDateTime::LocalDateTime(int otherTzd, const DateTime& otherDateTime):
- _dateTime(otherDateTime),
- _tzd(otherTzd)
-{
- adjustForTzd();
-}
-
-
-LocalDateTime::LocalDateTime(int otherTzd, const DateTime& otherDateTime, bool adjust):
- _dateTime(otherDateTime),
- _tzd(otherTzd)
-{
- if (adjust)
- adjustForTzd();
-}
-
-
-LocalDateTime::LocalDateTime(const LocalDateTime& dateTime):
- _dateTime(dateTime._dateTime),
- _tzd(dateTime._tzd)
-{
-}
-
-
-LocalDateTime::LocalDateTime(Timestamp::UtcTimeVal utcTimeVal, Timestamp::TimeDiff diff, int otherTzd):
- _dateTime(utcTimeVal, diff),
- _tzd(otherTzd)
-{
- adjustForTzd();
-}
-
-
-LocalDateTime::~LocalDateTime()
-{
-}
-
-
-LocalDateTime& LocalDateTime::operator = (const LocalDateTime& dateTime)
-{
- if (&dateTime != this)
- {
- _dateTime = dateTime._dateTime;
- _tzd = dateTime._tzd;
- }
- return *this;
-}
-
-
-LocalDateTime& LocalDateTime::operator = (const Timestamp& otherTimestamp)
-{
- if (otherTimestamp != timestamp())
- {
- _dateTime = otherTimestamp;
- determineTzd(true);
- }
- return *this;
-}
-
-
-LocalDateTime& LocalDateTime::operator = (double otherJulianDay)
-{
- _dateTime = otherJulianDay;
- determineTzd(true);
- return *this;
-}
-
-
-LocalDateTime& LocalDateTime::assign(int otherYear, int otherMonth, int otherDay, int otherHour, int otherMinute, int otherSecond, int otherMillisecond, int otherMicroseconds)
-{
- _dateTime.assign(otherYear, otherMonth, otherDay, otherHour, otherMinute, otherSecond, otherMillisecond, otherMicroseconds);
- determineTzd(false);
- return *this;
-}
-
-
-LocalDateTime& LocalDateTime::assign(int otherTzd, int otherYear, int otherMonth, int otherDay, int otherHour, int otherMinute, int otherSecond, int otherMillisecond, int otherMicroseconds)
-{
- _dateTime.assign(otherYear, otherMonth, otherDay, otherHour, otherMinute, otherSecond, otherMillisecond, otherMicroseconds);
- _tzd = otherTzd;
- return *this;
-}
-
-
-LocalDateTime& LocalDateTime::assign(int otherTzd, double otherJulianDay)
-{
- _tzd = otherTzd;
- _dateTime = otherJulianDay;
- adjustForTzd();
- return *this;
-}
-
-
-void LocalDateTime::swap(LocalDateTime& dateTime)
-{
- _dateTime.swap(dateTime._dateTime);
- std::swap(_tzd, dateTime._tzd);
-}
-
-
-DateTime LocalDateTime::utc() const
-{
- return DateTime(_dateTime.utcTime(), -((Timestamp::TimeDiff) _tzd)*Timespan::SECONDS);
-}
-
-
-bool LocalDateTime::operator == (const LocalDateTime& dateTime) const
-{
- return utcTime() == dateTime.utcTime();
-}
-
-
-bool LocalDateTime::operator != (const LocalDateTime& dateTime) const
-{
- return utcTime() != dateTime.utcTime();
-}
-
-
-bool LocalDateTime::operator < (const LocalDateTime& dateTime) const
-{
- return utcTime() < dateTime.utcTime();
-}
-
-
-bool LocalDateTime::operator <= (const LocalDateTime& dateTime) const
-{
- return utcTime() <= dateTime.utcTime();
-}
-
-
-bool LocalDateTime::operator > (const LocalDateTime& dateTime) const
-{
- return utcTime() > dateTime.utcTime();
-}
-
-
-bool LocalDateTime::operator >= (const LocalDateTime& dateTime) const
-{
- return utcTime() >= dateTime.utcTime();
-}
-
-
-LocalDateTime LocalDateTime::operator + (const Timespan& span) const
-{
- // First calculate the adjusted UTC time, then calculate the
- // locally adjusted time by constructing a new LocalDateTime.
- DateTime tmp(utcTime(), span.totalMicroseconds());
- return LocalDateTime(tmp);
-}
-
-
-LocalDateTime LocalDateTime::operator - (const Timespan& span) const
-{
- // First calculate the adjusted UTC time, then calculate the
- // locally adjusted time by constructing a new LocalDateTime.
- DateTime tmp(utcTime(), -span.totalMicroseconds());
- return LocalDateTime(tmp);
-}
-
-
-Timespan LocalDateTime::operator - (const LocalDateTime& dateTime) const
-{
- return Timespan((utcTime() - dateTime.utcTime())/10);
-}
-
-
-LocalDateTime& LocalDateTime::operator += (const Timespan& span)
-{
- // Use the same trick as in operator+. Create a UTC time, adjust
- // it for the span, and convert back to LocalDateTime. This will
- // recalculate the tzd correctly in the case where the addition
- // crosses a DST boundary.
- *this = DateTime(utcTime(), span.totalMicroseconds());
- return *this;
-}
-
-
-LocalDateTime& LocalDateTime::operator -= (const Timespan& span)
-{
- // Use the same trick as in operator-. Create a UTC time, adjust
- // it for the span, and convert back to LocalDateTime. This will
- // recalculate the tzd correctly in the case where the subtraction
- // crosses a DST boundary.
- *this = DateTime(utcTime(), -span.totalMicroseconds());
- return *this;
-}
-
-
-void LocalDateTime::determineTzd(bool adjust)
-{
- if (adjust)
- {
- std::time_t epochTime = _dateTime.timestamp().epochTime();
-#if defined(_WIN32) || defined(POCO_NO_POSIX_TSF)
-#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
- std::tm* broken = wceex_localtime(&epochTime);
-#else
- std::tm* broken = std::localtime(&epochTime);
-#endif
- if (!broken) throw Poco::SystemException("cannot get local time");
- _tzd = (Timezone::utcOffset() + ((broken->tm_isdst == 1) ? 3600 : 0));
-#else
- std::tm broken;
-#if defined(POCO_VXWORKS)
- if (localtime_r(&epochTime, &broken) != OK)
- throw Poco::SystemException("cannot get local time");
-#else
- if (!localtime_r(&epochTime, &broken))
- throw Poco::SystemException("cannot get local time");
-#endif
- _tzd = (Timezone::utcOffset() + ((broken.tm_isdst == 1) ? 3600 : 0));
-#endif
- adjustForTzd();
- }
- else
- {
- int dst;
- dstOffset(dst);
- _tzd = (Timezone::utcOffset() + dst);
- }
-}
-
-
-std::time_t LocalDateTime::dstOffset(int& rDstOffset) const
-{
- std::time_t local;
- std::tm broken;
-
- 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();
- broken.tm_sec = _dateTime.second();
- broken.tm_isdst = -1;
-#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
- local = wceex_mktime(&broken);
-#else
- local = std::mktime(&broken);
-#endif
-
- rDstOffset = (broken.tm_isdst == 1) ? 3600 : 0;
- return local;
-}
-
-
-} // namespace Poco
-
+//
+// LocalDateTime.cpp
+//
+// Library: Foundation
+// Package: DateTime
+// Module: LocalDateTime
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/LocalDateTime.h"
+#include "Poco/Timezone.h"
+#include "Poco/Timespan.h"
+#include "Poco/Exception.h"
+#include <algorithm>
+#include <ctime>
+#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
+#error #include "wce_time.h"
+#endif
+
+
+namespace Poco {
+
+
+LocalDateTime::LocalDateTime()
+{
+ determineTzd(true);
+}
+
+
+LocalDateTime::LocalDateTime(int otherYear, int otherMonth, int otherDay, int otherHour, int otherMinute, int otherSecond, int otherMillisecond, int otherMicrosecond):
+ _dateTime(otherYear, otherMonth, otherDay, otherHour, otherMinute, otherSecond, otherMillisecond, otherMicrosecond)
+{
+ determineTzd();
+}
+
+
+LocalDateTime::LocalDateTime(int otherTzd, int otherYear, int otherMonth, int otherDay, int otherHour, int otherMinute, int otherSecond, int otherMillisecond, int otherMicrosecond):
+ _dateTime(otherYear, otherMonth, otherDay, otherHour, otherMinute, otherSecond, otherMillisecond, otherMicrosecond),
+ _tzd(otherTzd)
+{
+}
+
+
+LocalDateTime::LocalDateTime(double otherJulianDay):
+ _dateTime(otherJulianDay)
+{
+ determineTzd(true);
+}
+
+
+LocalDateTime::LocalDateTime(int otherTzd, double otherJulianDay):
+ _dateTime(otherJulianDay),
+ _tzd(otherTzd)
+{
+ adjustForTzd();
+}
+
+
+LocalDateTime::LocalDateTime(const DateTime& dateTime):
+ _dateTime(dateTime)
+{
+ determineTzd(true);
+}
+
+
+LocalDateTime::LocalDateTime(int otherTzd, const DateTime& otherDateTime):
+ _dateTime(otherDateTime),
+ _tzd(otherTzd)
+{
+ adjustForTzd();
+}
+
+
+LocalDateTime::LocalDateTime(int otherTzd, const DateTime& otherDateTime, bool adjust):
+ _dateTime(otherDateTime),
+ _tzd(otherTzd)
+{
+ if (adjust)
+ adjustForTzd();
+}
+
+
+LocalDateTime::LocalDateTime(const LocalDateTime& dateTime):
+ _dateTime(dateTime._dateTime),
+ _tzd(dateTime._tzd)
+{
+}
+
+
+LocalDateTime::LocalDateTime(Timestamp::UtcTimeVal utcTimeVal, Timestamp::TimeDiff diff, int otherTzd):
+ _dateTime(utcTimeVal, diff),
+ _tzd(otherTzd)
+{
+ adjustForTzd();
+}
+
+
+LocalDateTime::~LocalDateTime()
+{
+}
+
+
+LocalDateTime& LocalDateTime::operator = (const LocalDateTime& dateTime)
+{
+ if (&dateTime != this)
+ {
+ _dateTime = dateTime._dateTime;
+ _tzd = dateTime._tzd;
+ }
+ return *this;
+}
+
+
+LocalDateTime& LocalDateTime::operator = (const Timestamp& otherTimestamp)
+{
+ if (otherTimestamp != timestamp())
+ {
+ _dateTime = otherTimestamp;
+ determineTzd(true);
+ }
+ return *this;
+}
+
+
+LocalDateTime& LocalDateTime::operator = (double otherJulianDay)
+{
+ _dateTime = otherJulianDay;
+ determineTzd(true);
+ return *this;
+}
+
+
+LocalDateTime& LocalDateTime::assign(int otherYear, int otherMonth, int otherDay, int otherHour, int otherMinute, int otherSecond, int otherMillisecond, int otherMicroseconds)
+{
+ _dateTime.assign(otherYear, otherMonth, otherDay, otherHour, otherMinute, otherSecond, otherMillisecond, otherMicroseconds);
+ determineTzd(false);
+ return *this;
+}
+
+
+LocalDateTime& LocalDateTime::assign(int otherTzd, int otherYear, int otherMonth, int otherDay, int otherHour, int otherMinute, int otherSecond, int otherMillisecond, int otherMicroseconds)
+{
+ _dateTime.assign(otherYear, otherMonth, otherDay, otherHour, otherMinute, otherSecond, otherMillisecond, otherMicroseconds);
+ _tzd = otherTzd;
+ return *this;
+}
+
+
+LocalDateTime& LocalDateTime::assign(int otherTzd, double otherJulianDay)
+{
+ _tzd = otherTzd;
+ _dateTime = otherJulianDay;
+ adjustForTzd();
+ return *this;
+}
+
+
+void LocalDateTime::swap(LocalDateTime& dateTime)
+{
+ _dateTime.swap(dateTime._dateTime);
+ std::swap(_tzd, dateTime._tzd);
+}
+
+
+DateTime LocalDateTime::utc() const
+{
+ return DateTime(_dateTime.utcTime(), -((Timestamp::TimeDiff) _tzd)*Timespan::SECONDS);
+}
+
+
+bool LocalDateTime::operator == (const LocalDateTime& dateTime) const
+{
+ return utcTime() == dateTime.utcTime();
+}
+
+
+bool LocalDateTime::operator != (const LocalDateTime& dateTime) const
+{
+ return utcTime() != dateTime.utcTime();
+}
+
+
+bool LocalDateTime::operator < (const LocalDateTime& dateTime) const
+{
+ return utcTime() < dateTime.utcTime();
+}
+
+
+bool LocalDateTime::operator <= (const LocalDateTime& dateTime) const
+{
+ return utcTime() <= dateTime.utcTime();
+}
+
+
+bool LocalDateTime::operator > (const LocalDateTime& dateTime) const
+{
+ return utcTime() > dateTime.utcTime();
+}
+
+
+bool LocalDateTime::operator >= (const LocalDateTime& dateTime) const
+{
+ return utcTime() >= dateTime.utcTime();
+}
+
+
+LocalDateTime LocalDateTime::operator + (const Timespan& span) const
+{
+ // First calculate the adjusted UTC time, then calculate the
+ // locally adjusted time by constructing a new LocalDateTime.
+ DateTime tmp(utcTime(), span.totalMicroseconds());
+ return LocalDateTime(tmp);
+}
+
+
+LocalDateTime LocalDateTime::operator - (const Timespan& span) const
+{
+ // First calculate the adjusted UTC time, then calculate the
+ // locally adjusted time by constructing a new LocalDateTime.
+ DateTime tmp(utcTime(), -span.totalMicroseconds());
+ return LocalDateTime(tmp);
+}
+
+
+Timespan LocalDateTime::operator - (const LocalDateTime& dateTime) const
+{
+ return Timespan((utcTime() - dateTime.utcTime())/10);
+}
+
+
+LocalDateTime& LocalDateTime::operator += (const Timespan& span)
+{
+ // Use the same trick as in operator+. Create a UTC time, adjust
+ // it for the span, and convert back to LocalDateTime. This will
+ // recalculate the tzd correctly in the case where the addition
+ // crosses a DST boundary.
+ *this = DateTime(utcTime(), span.totalMicroseconds());
+ return *this;
+}
+
+
+LocalDateTime& LocalDateTime::operator -= (const Timespan& span)
+{
+ // Use the same trick as in operator-. Create a UTC time, adjust
+ // it for the span, and convert back to LocalDateTime. This will
+ // recalculate the tzd correctly in the case where the subtraction
+ // crosses a DST boundary.
+ *this = DateTime(utcTime(), -span.totalMicroseconds());
+ return *this;
+}
+
+
+void LocalDateTime::determineTzd(bool adjust)
+{
+ if (adjust)
+ {
+ std::time_t epochTime = _dateTime.timestamp().epochTime();
+#if defined(_WIN32) || defined(POCO_NO_POSIX_TSF)
+#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
+ std::tm* broken = wceex_localtime(&epochTime);
+#else
+ std::tm* broken = std::localtime(&epochTime);
+#endif
+ if (!broken) throw Poco::SystemException("cannot get local time");
+ _tzd = (Timezone::utcOffset() + ((broken->tm_isdst == 1) ? 3600 : 0));
+#else
+ std::tm broken;
+#if defined(POCO_VXWORKS)
+ if (localtime_r(&epochTime, &broken) != OK)
+ throw Poco::SystemException("cannot get local time");
+#else
+ if (!localtime_r(&epochTime, &broken))
+ throw Poco::SystemException("cannot get local time");
+#endif
+ _tzd = (Timezone::utcOffset() + ((broken.tm_isdst == 1) ? 3600 : 0));
+#endif
+ adjustForTzd();
+ }
+ else
+ {
+ int dst;
+ dstOffset(dst);
+ _tzd = (Timezone::utcOffset() + dst);
+ }
+}
+
+
+std::time_t LocalDateTime::dstOffset(int& rDstOffset) const
+{
+ std::time_t local;
+ std::tm broken;
+
+ 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();
+ broken.tm_sec = _dateTime.second();
+ broken.tm_isdst = -1;
+#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
+ local = wceex_mktime(&broken);
+#else
+ local = std::mktime(&broken);
+#endif
+
+ rDstOffset = (broken.tm_isdst == 1) ? 3600 : 0;
+ return local;
+}
+
+
+} // namespace Poco
+
diff --git a/contrib/libs/poco/Foundation/src/LogFile.cpp b/contrib/libs/poco/Foundation/src/LogFile.cpp
index 5ce9b05a9d..b22c422f94 100644
--- a/contrib/libs/poco/Foundation/src/LogFile.cpp
+++ b/contrib/libs/poco/Foundation/src/LogFile.cpp
@@ -1,40 +1,40 @@
-//
-// LogFile.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: LogFile
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/LogFile.h"
-
-
-#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
-#include "LogFile_WIN32U.cpp"
-#elif defined(POCO_OS_FAMILY_WINDOWS)
-#include "LogFile_WIN32.cpp"
-#else
-#include "LogFile_STD.cpp"
-#endif
-
-
-namespace Poco {
-
-
-LogFile::LogFile(const std::string& rPath): LogFileImpl(rPath)
-{
-}
-
-
-LogFile::~LogFile()
-{
-}
-
-
-} // namespace Poco
+//
+// LogFile.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: LogFile
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/LogFile.h"
+
+
+#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
+#include "LogFile_WIN32U.cpp"
+#elif defined(POCO_OS_FAMILY_WINDOWS)
+#include "LogFile_WIN32.cpp"
+#else
+#include "LogFile_STD.cpp"
+#endif
+
+
+namespace Poco {
+
+
+LogFile::LogFile(const std::string& rPath): LogFileImpl(rPath)
+{
+}
+
+
+LogFile::~LogFile()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/LogFile_STD.cpp b/contrib/libs/poco/Foundation/src/LogFile_STD.cpp
index 66dc45bf24..45558b1b2e 100644
--- a/contrib/libs/poco/Foundation/src/LogFile_STD.cpp
+++ b/contrib/libs/poco/Foundation/src/LogFile_STD.cpp
@@ -1,68 +1,68 @@
-//
-// LogFile_STD.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: LogFile
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/LogFile_STD.h"
-#include "Poco/File.h"
-#include "Poco/Exception.h"
-
-
-namespace Poco {
-
-
-LogFileImpl::LogFileImpl(const std::string& path):
- _path(path),
- _str(_path, std::ios::app)
-{
- if (sizeImpl() == 0)
- _creationDate = File(path).getLastModified();
- else
- _creationDate = File(path).created();
-}
-
-
-LogFileImpl::~LogFileImpl()
-{
-}
-
-
-void LogFileImpl::writeImpl(const std::string& text, bool flush)
-{
- _str << text;
- if (flush)
- _str << std::endl;
- else
- _str << "\n";
- if (!_str.good()) throw WriteFileException(_path);
-}
-
-
-UInt64 LogFileImpl::sizeImpl() const
-{
- return (UInt64) _str.tellp();
-}
-
-
-Timestamp LogFileImpl::creationDateImpl() const
-{
- return _creationDate;
-}
-
-
-const std::string& LogFileImpl::pathImpl() const
-{
- return _path;
-}
-
-
-} // namespace Poco
+//
+// LogFile_STD.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: LogFile
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/LogFile_STD.h"
+#include "Poco/File.h"
+#include "Poco/Exception.h"
+
+
+namespace Poco {
+
+
+LogFileImpl::LogFileImpl(const std::string& path):
+ _path(path),
+ _str(_path, std::ios::app)
+{
+ if (sizeImpl() == 0)
+ _creationDate = File(path).getLastModified();
+ else
+ _creationDate = File(path).created();
+}
+
+
+LogFileImpl::~LogFileImpl()
+{
+}
+
+
+void LogFileImpl::writeImpl(const std::string& text, bool flush)
+{
+ _str << text;
+ if (flush)
+ _str << std::endl;
+ else
+ _str << "\n";
+ if (!_str.good()) throw WriteFileException(_path);
+}
+
+
+UInt64 LogFileImpl::sizeImpl() const
+{
+ return (UInt64) _str.tellp();
+}
+
+
+Timestamp LogFileImpl::creationDateImpl() const
+{
+ return _creationDate;
+}
+
+
+const std::string& LogFileImpl::pathImpl() const
+{
+ return _path;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/LogFile_WIN32.cpp b/contrib/libs/poco/Foundation/src/LogFile_WIN32.cpp
index 6a5c47a29c..f1efce887b 100644
--- a/contrib/libs/poco/Foundation/src/LogFile_WIN32.cpp
+++ b/contrib/libs/poco/Foundation/src/LogFile_WIN32.cpp
@@ -1,111 +1,111 @@
-//
-// LogFile_WIN32.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: LogFile
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/LogFile_WIN32.h"
-#include "Poco/File.h"
-#include "Poco/Exception.h"
-
-
-namespace Poco {
-
-
-LogFileImpl::LogFileImpl(const std::string& path): _path(path), _hFile(INVALID_HANDLE_VALUE)
-{
- File file(path);
- if (file.exists())
- {
- if (0 == sizeImpl())
- _creationDate = file.getLastModified();
- else
- _creationDate = file.created();
- }
-}
-
-
-LogFileImpl::~LogFileImpl()
-{
- CloseHandle(_hFile);
-}
-
-
-void LogFileImpl::writeImpl(const std::string& text, bool flush)
-{
- if (INVALID_HANDLE_VALUE == _hFile) createFile();
-
- DWORD bytesWritten;
- BOOL res = WriteFile(_hFile, text.data(), (DWORD) text.size(), &bytesWritten, NULL);
- if (!res) throw WriteFileException(_path);
- res = WriteFile(_hFile, "\r\n", 2, &bytesWritten, NULL);
- if (!res) throw WriteFileException(_path);
- if (flush)
- {
- res = FlushFileBuffers(_hFile);
- if (!res) throw WriteFileException(_path);
- }
-}
-
-
-UInt64 LogFileImpl::sizeImpl() const
-{
- if (INVALID_HANDLE_VALUE == _hFile)
- {
- File file(_path);
- if (file.exists()) return file.getSize();
- else return 0;
- }
-
- LARGE_INTEGER li;
- li.HighPart = 0;
- li.LowPart = SetFilePointer(_hFile, 0, &li.HighPart, FILE_CURRENT);
- return li.QuadPart;
-}
-
-
-Timestamp LogFileImpl::creationDateImpl() const
-{
- return _creationDate;
-}
-
-
-const std::string& LogFileImpl::pathImpl() const
-{
- return _path;
-}
-
-
-void LogFileImpl::createFile()
-{
- _hFile = CreateFileA(_path.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);
- // There seems to be a strange "optimization" in the Windows NTFS
- // filesystem that causes it to reuse directory entries of deleted
- // files. Example:
- // 1. create a file named "test.dat"
- // note the file's creation date
- // 2. delete the file "test.dat"
- // 3. wait a few seconds
- // 4. create a file named "test.dat"
- // the new file will have the same creation
- // date as the old one.
- // We work around this bug by taking the file's
- // modification date as a reference when the
- // file is empty.
- if (sizeImpl() == 0)
- _creationDate = File(_path).getLastModified();
- else
- _creationDate = File(_path).created();
-}
-
-} // namespace Poco
+//
+// LogFile_WIN32.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: LogFile
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/LogFile_WIN32.h"
+#include "Poco/File.h"
+#include "Poco/Exception.h"
+
+
+namespace Poco {
+
+
+LogFileImpl::LogFileImpl(const std::string& path): _path(path), _hFile(INVALID_HANDLE_VALUE)
+{
+ File file(path);
+ if (file.exists())
+ {
+ if (0 == sizeImpl())
+ _creationDate = file.getLastModified();
+ else
+ _creationDate = file.created();
+ }
+}
+
+
+LogFileImpl::~LogFileImpl()
+{
+ CloseHandle(_hFile);
+}
+
+
+void LogFileImpl::writeImpl(const std::string& text, bool flush)
+{
+ if (INVALID_HANDLE_VALUE == _hFile) createFile();
+
+ DWORD bytesWritten;
+ BOOL res = WriteFile(_hFile, text.data(), (DWORD) text.size(), &bytesWritten, NULL);
+ if (!res) throw WriteFileException(_path);
+ res = WriteFile(_hFile, "\r\n", 2, &bytesWritten, NULL);
+ if (!res) throw WriteFileException(_path);
+ if (flush)
+ {
+ res = FlushFileBuffers(_hFile);
+ if (!res) throw WriteFileException(_path);
+ }
+}
+
+
+UInt64 LogFileImpl::sizeImpl() const
+{
+ if (INVALID_HANDLE_VALUE == _hFile)
+ {
+ File file(_path);
+ if (file.exists()) return file.getSize();
+ else return 0;
+ }
+
+ LARGE_INTEGER li;
+ li.HighPart = 0;
+ li.LowPart = SetFilePointer(_hFile, 0, &li.HighPart, FILE_CURRENT);
+ return li.QuadPart;
+}
+
+
+Timestamp LogFileImpl::creationDateImpl() const
+{
+ return _creationDate;
+}
+
+
+const std::string& LogFileImpl::pathImpl() const
+{
+ return _path;
+}
+
+
+void LogFileImpl::createFile()
+{
+ _hFile = CreateFileA(_path.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);
+ // There seems to be a strange "optimization" in the Windows NTFS
+ // filesystem that causes it to reuse directory entries of deleted
+ // files. Example:
+ // 1. create a file named "test.dat"
+ // note the file's creation date
+ // 2. delete the file "test.dat"
+ // 3. wait a few seconds
+ // 4. create a file named "test.dat"
+ // the new file will have the same creation
+ // date as the old one.
+ // We work around this bug by taking the file's
+ // modification date as a reference when the
+ // file is empty.
+ if (sizeImpl() == 0)
+ _creationDate = File(_path).getLastModified();
+ else
+ _creationDate = File(_path).created();
+}
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/LogFile_WIN32U.cpp b/contrib/libs/poco/Foundation/src/LogFile_WIN32U.cpp
index b89bf8ec03..37f1b71b58 100644
--- a/contrib/libs/poco/Foundation/src/LogFile_WIN32U.cpp
+++ b/contrib/libs/poco/Foundation/src/LogFile_WIN32U.cpp
@@ -1,116 +1,116 @@
-//
-// LogFile_WIN32U.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: LogFile
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/LogFile_WIN32U.h"
-#include "Poco/File.h"
-#include "Poco/Exception.h"
-#include "Poco/UnicodeConverter.h"
-
-
-namespace Poco {
-
-
-LogFileImpl::LogFileImpl(const std::string& path): _path(path), _hFile(INVALID_HANDLE_VALUE)
-{
- File file(path);
- if (file.exists())
- {
- if (0 == sizeImpl())
- _creationDate = file.getLastModified();
- else
- _creationDate = file.created();
- }
-}
-
-
-LogFileImpl::~LogFileImpl()
-{
- CloseHandle(_hFile);
-}
-
-
-void LogFileImpl::writeImpl(const std::string& text, bool flush)
-{
- if (INVALID_HANDLE_VALUE == _hFile) createFile();
-
- DWORD bytesWritten;
- BOOL res = WriteFile(_hFile, text.data(), (DWORD) text.size(), &bytesWritten, NULL);
- if (!res) throw WriteFileException(_path);
- res = WriteFile(_hFile, "\r\n", 2, &bytesWritten, NULL);
- if (!res) throw WriteFileException(_path);
- if (flush)
- {
- res = FlushFileBuffers(_hFile);
- if (!res) throw WriteFileException(_path);
- }
-}
-
-
-UInt64 LogFileImpl::sizeImpl() const
-{
- if (INVALID_HANDLE_VALUE == _hFile)
- {
- File file(_path);
- if (file.exists()) return file.getSize();
- else return 0;
- }
-
- LARGE_INTEGER li;
- li.HighPart = 0;
- li.LowPart = SetFilePointer(_hFile, 0, &li.HighPart, FILE_CURRENT);
- return li.QuadPart;
-}
-
-
-Timestamp LogFileImpl::creationDateImpl() const
-{
- return _creationDate;
-}
-
-
-const std::string& LogFileImpl::pathImpl() const
-{
- return _path;
-}
-
-
-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);
- // There seems to be a strange "optimization" in the Windows NTFS
- // filesystem that causes it to reuse directory entries of deleted
- // files. Example:
- // 1. create a file named "test.dat"
- // note the file's creation date
- // 2. delete the file "test.dat"
- // 3. wait a few seconds
- // 4. create a file named "test.dat"
- // the new file will have the same creation
- // date as the old one.
- // We work around this bug by taking the file's
- // modification date as a reference when the
- // file is empty.
- if (sizeImpl() == 0)
- _creationDate = File(_path).getLastModified();
- else
- _creationDate = File(_path).created();
-}
-
-
-} // namespace Poco
+//
+// LogFile_WIN32U.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: LogFile
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/LogFile_WIN32U.h"
+#include "Poco/File.h"
+#include "Poco/Exception.h"
+#include "Poco/UnicodeConverter.h"
+
+
+namespace Poco {
+
+
+LogFileImpl::LogFileImpl(const std::string& path): _path(path), _hFile(INVALID_HANDLE_VALUE)
+{
+ File file(path);
+ if (file.exists())
+ {
+ if (0 == sizeImpl())
+ _creationDate = file.getLastModified();
+ else
+ _creationDate = file.created();
+ }
+}
+
+
+LogFileImpl::~LogFileImpl()
+{
+ CloseHandle(_hFile);
+}
+
+
+void LogFileImpl::writeImpl(const std::string& text, bool flush)
+{
+ if (INVALID_HANDLE_VALUE == _hFile) createFile();
+
+ DWORD bytesWritten;
+ BOOL res = WriteFile(_hFile, text.data(), (DWORD) text.size(), &bytesWritten, NULL);
+ if (!res) throw WriteFileException(_path);
+ res = WriteFile(_hFile, "\r\n", 2, &bytesWritten, NULL);
+ if (!res) throw WriteFileException(_path);
+ if (flush)
+ {
+ res = FlushFileBuffers(_hFile);
+ if (!res) throw WriteFileException(_path);
+ }
+}
+
+
+UInt64 LogFileImpl::sizeImpl() const
+{
+ if (INVALID_HANDLE_VALUE == _hFile)
+ {
+ File file(_path);
+ if (file.exists()) return file.getSize();
+ else return 0;
+ }
+
+ LARGE_INTEGER li;
+ li.HighPart = 0;
+ li.LowPart = SetFilePointer(_hFile, 0, &li.HighPart, FILE_CURRENT);
+ return li.QuadPart;
+}
+
+
+Timestamp LogFileImpl::creationDateImpl() const
+{
+ return _creationDate;
+}
+
+
+const std::string& LogFileImpl::pathImpl() const
+{
+ return _path;
+}
+
+
+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);
+ // There seems to be a strange "optimization" in the Windows NTFS
+ // filesystem that causes it to reuse directory entries of deleted
+ // files. Example:
+ // 1. create a file named "test.dat"
+ // note the file's creation date
+ // 2. delete the file "test.dat"
+ // 3. wait a few seconds
+ // 4. create a file named "test.dat"
+ // the new file will have the same creation
+ // date as the old one.
+ // We work around this bug by taking the file's
+ // modification date as a reference when the
+ // file is empty.
+ if (sizeImpl() == 0)
+ _creationDate = File(_path).getLastModified();
+ else
+ _creationDate = File(_path).created();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/LogStream.cpp b/contrib/libs/poco/Foundation/src/LogStream.cpp
index 5377beb9d0..fc138f2879 100644
--- a/contrib/libs/poco/Foundation/src/LogStream.cpp
+++ b/contrib/libs/poco/Foundation/src/LogStream.cpp
@@ -1,213 +1,213 @@
-//
-// LogStream.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: LogStream
-//
-// Copyright (c) 2006-2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/LogStream.h"
-
-
-namespace Poco {
-
-
-//
-// LogStreamBuf
-//
-
-
-LogStreamBuf::LogStreamBuf(Logger& rLogger, Message::Priority priority):
- _logger(rLogger),
- _priority(priority)
-{
-}
-
-
-LogStreamBuf::~LogStreamBuf()
-{
-}
-
-
-void LogStreamBuf::setPriority(Message::Priority priority)
-{
- _priority = priority;
-}
-
-
-int LogStreamBuf::writeToDevice(char c)
-{
- if (c == '\n' || c == '\r')
- {
- if (_message.find_first_not_of("\r\n") != std::string::npos)
- {
- Message msg(_logger.name(), _message, _priority);
- _message.clear();
- _logger.log(msg);
- }
- }
- else _message += c;
- return c;
-}
-
-
-//
-// LogIOS
-//
-
-
-LogIOS::LogIOS(Logger& logger, Message::Priority priority):
- _buf(logger, priority)
-{
- poco_ios_init(&_buf);
-}
-
-
-LogIOS::~LogIOS()
-{
-}
-
-
-LogStreamBuf* LogIOS::rdbuf()
-{
- return &_buf;
-}
-
-
-//
-// LogStream
-//
-
-
-LogStream::LogStream(Logger& logger, Message::Priority messagePriority):
- LogIOS(logger, messagePriority),
- std::ostream(&_buf)
-{
-}
-
-
-LogStream::LogStream(const std::string& loggerName, Message::Priority messagePriority):
- LogIOS(Logger::get(loggerName), messagePriority),
- std::ostream(&_buf)
-{
-}
-
-
-LogStream::~LogStream()
-{
-}
-
-
-LogStream& LogStream::fatal()
-{
- return priority(Message::PRIO_FATAL);
-}
-
-
-LogStream& LogStream::fatal(const std::string& message)
-{
- _buf.logger().fatal(message);
- return priority(Message::PRIO_FATAL);
-}
-
-
-LogStream& LogStream::critical()
-{
- return priority(Message::PRIO_CRITICAL);
-}
-
-
-LogStream& LogStream::critical(const std::string& message)
-{
- _buf.logger().critical(message);
- return priority(Message::PRIO_CRITICAL);
-}
-
-
-LogStream& LogStream::error()
-{
- return priority(Message::PRIO_ERROR);
-}
-
-
-LogStream& LogStream::error(const std::string& message)
-{
- _buf.logger().error(message);
- return priority(Message::PRIO_ERROR);
-}
-
-
-LogStream& LogStream::warning()
-{
- return priority(Message::PRIO_WARNING);
-}
-
-
-LogStream& LogStream::warning(const std::string& message)
-{
- _buf.logger().warning(message);
- return priority(Message::PRIO_WARNING);
-}
-
-
-LogStream& LogStream::notice()
-{
- return priority(Message::PRIO_NOTICE);
-}
-
-
-LogStream& LogStream::notice(const std::string& message)
-{
- _buf.logger().notice(message);
- return priority(Message::PRIO_NOTICE);
-}
-
-
-LogStream& LogStream::information()
-{
- return priority(Message::PRIO_INFORMATION);
-}
-
-
-LogStream& LogStream::information(const std::string& message)
-{
- _buf.logger().information(message);
- return priority(Message::PRIO_INFORMATION);
-}
-
-
-LogStream& LogStream::debug()
-{
- return priority(Message::PRIO_DEBUG);
-}
-
-
-LogStream& LogStream::debug(const std::string& message)
-{
- _buf.logger().debug(message);
- return priority(Message::PRIO_DEBUG);
-}
-
-
-LogStream& LogStream::trace()
-{
- return priority(Message::PRIO_TRACE);
-}
-
-
-LogStream& LogStream::trace(const std::string& message)
-{
- _buf.logger().trace(message);
- return priority(Message::PRIO_TRACE);
-}
-
-
+//
+// LogStream.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: LogStream
+//
+// Copyright (c) 2006-2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/LogStream.h"
+
+
+namespace Poco {
+
+
+//
+// LogStreamBuf
+//
+
+
+LogStreamBuf::LogStreamBuf(Logger& rLogger, Message::Priority priority):
+ _logger(rLogger),
+ _priority(priority)
+{
+}
+
+
+LogStreamBuf::~LogStreamBuf()
+{
+}
+
+
+void LogStreamBuf::setPriority(Message::Priority priority)
+{
+ _priority = priority;
+}
+
+
+int LogStreamBuf::writeToDevice(char c)
+{
+ if (c == '\n' || c == '\r')
+ {
+ if (_message.find_first_not_of("\r\n") != std::string::npos)
+ {
+ Message msg(_logger.name(), _message, _priority);
+ _message.clear();
+ _logger.log(msg);
+ }
+ }
+ else _message += c;
+ return c;
+}
+
+
+//
+// LogIOS
+//
+
+
+LogIOS::LogIOS(Logger& logger, Message::Priority priority):
+ _buf(logger, priority)
+{
+ poco_ios_init(&_buf);
+}
+
+
+LogIOS::~LogIOS()
+{
+}
+
+
+LogStreamBuf* LogIOS::rdbuf()
+{
+ return &_buf;
+}
+
+
+//
+// LogStream
+//
+
+
+LogStream::LogStream(Logger& logger, Message::Priority messagePriority):
+ LogIOS(logger, messagePriority),
+ std::ostream(&_buf)
+{
+}
+
+
+LogStream::LogStream(const std::string& loggerName, Message::Priority messagePriority):
+ LogIOS(Logger::get(loggerName), messagePriority),
+ std::ostream(&_buf)
+{
+}
+
+
+LogStream::~LogStream()
+{
+}
+
+
+LogStream& LogStream::fatal()
+{
+ return priority(Message::PRIO_FATAL);
+}
+
+
+LogStream& LogStream::fatal(const std::string& message)
+{
+ _buf.logger().fatal(message);
+ return priority(Message::PRIO_FATAL);
+}
+
+
+LogStream& LogStream::critical()
+{
+ return priority(Message::PRIO_CRITICAL);
+}
+
+
+LogStream& LogStream::critical(const std::string& message)
+{
+ _buf.logger().critical(message);
+ return priority(Message::PRIO_CRITICAL);
+}
+
+
+LogStream& LogStream::error()
+{
+ return priority(Message::PRIO_ERROR);
+}
+
+
+LogStream& LogStream::error(const std::string& message)
+{
+ _buf.logger().error(message);
+ return priority(Message::PRIO_ERROR);
+}
+
+
+LogStream& LogStream::warning()
+{
+ return priority(Message::PRIO_WARNING);
+}
+
+
+LogStream& LogStream::warning(const std::string& message)
+{
+ _buf.logger().warning(message);
+ return priority(Message::PRIO_WARNING);
+}
+
+
+LogStream& LogStream::notice()
+{
+ return priority(Message::PRIO_NOTICE);
+}
+
+
+LogStream& LogStream::notice(const std::string& message)
+{
+ _buf.logger().notice(message);
+ return priority(Message::PRIO_NOTICE);
+}
+
+
+LogStream& LogStream::information()
+{
+ return priority(Message::PRIO_INFORMATION);
+}
+
+
+LogStream& LogStream::information(const std::string& message)
+{
+ _buf.logger().information(message);
+ return priority(Message::PRIO_INFORMATION);
+}
+
+
+LogStream& LogStream::debug()
+{
+ return priority(Message::PRIO_DEBUG);
+}
+
+
+LogStream& LogStream::debug(const std::string& message)
+{
+ _buf.logger().debug(message);
+ return priority(Message::PRIO_DEBUG);
+}
+
+
+LogStream& LogStream::trace()
+{
+ return priority(Message::PRIO_TRACE);
+}
+
+
+LogStream& LogStream::trace(const std::string& message)
+{
+ _buf.logger().trace(message);
+ return priority(Message::PRIO_TRACE);
+}
+
+
LogStream& LogStream::test()
{
return priority(Message::PRIO_TEST);
@@ -221,11 +221,11 @@ LogStream& LogStream::test(const std::string& message)
}
-LogStream& LogStream::priority(Message::Priority messagePriority)
-{
- _buf.setPriority(messagePriority);
- return *this;
-}
-
-
-} // namespace Poco
+LogStream& LogStream::priority(Message::Priority messagePriority)
+{
+ _buf.setPriority(messagePriority);
+ return *this;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Logger.cpp b/contrib/libs/poco/Foundation/src/Logger.cpp
index 741dac5f19..517f6b5f1d 100644
--- a/contrib/libs/poco/Foundation/src/Logger.cpp
+++ b/contrib/libs/poco/Foundation/src/Logger.cpp
@@ -1,485 +1,485 @@
-//
-// Logger.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: Logger
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Logger.h"
-#include "Poco/Formatter.h"
-#include "Poco/LoggingRegistry.h"
-#include "Poco/Exception.h"
-#include "Poco/NumberFormatter.h"
-#include "Poco/NumberParser.h"
-#include "Poco/String.h"
-
-
-namespace Poco {
-
-
-Logger::LoggerMap* Logger::_pLoggerMap = 0;
-Mutex Logger::_mapMtx;
-const std::string Logger::ROOT;
-
-
-Logger::Logger(const std::string& rName, Channel* pChannel, int level): _name(rName), _pChannel(pChannel), _level(level)
-{
- if (pChannel) pChannel->duplicate();
-}
-
-
-Logger::~Logger()
-{
- if (_pChannel) _pChannel->release();
-}
-
-
-void Logger::setChannel(Channel* pChannel)
-{
- if (_pChannel) _pChannel->release();
- _pChannel = pChannel;
- if (_pChannel) _pChannel->duplicate();
-}
-
-
-Channel* Logger::getChannel() const
-{
- return _pChannel;
-}
-
-
-void Logger::setLevel(int level)
-{
- _level = level;
-}
-
-
-void Logger::setLevel(const std::string& level)
-{
- setLevel(parseLevel(level));
-}
-
-
-void Logger::setProperty(const std::string& rName, const std::string& rValue)
-{
- if (rName == "channel")
- setChannel(LoggingRegistry::defaultRegistry().channelForName(rValue));
- else if (rName == "level")
- setLevel(rValue);
- else
- Channel::setProperty(rName, rValue);
-}
-
-
-void Logger::log(const Message& msg)
-{
- if (_level >= msg.getPriority() && _pChannel)
- {
- _pChannel->log(msg);
- }
-}
-
-
-void Logger::log(const Exception& exc)
-{
- error(exc.displayText());
-}
-
-
-void Logger::log(const Exception& exc, const char* file, int line)
-{
- error(exc.displayText(), file, line);
-}
-
-
-void Logger::dump(const std::string& msg, const void* buffer, std::size_t length, Message::Priority prio)
-{
- if (_level >= prio && _pChannel)
- {
- std::string text(msg);
- formatDump(text, buffer, length);
- _pChannel->log(Message(_name, text, prio));
- }
-}
-
-
-void Logger::setLevel(const std::string& name, int level)
-{
- Mutex::ScopedLock lock(_mapMtx);
-
- if (_pLoggerMap)
- {
- std::string::size_type len = name.length();
- for (LoggerMap::iterator it = _pLoggerMap->begin(); it != _pLoggerMap->end(); ++it)
- {
+//
+// Logger.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: Logger
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Logger.h"
+#include "Poco/Formatter.h"
+#include "Poco/LoggingRegistry.h"
+#include "Poco/Exception.h"
+#include "Poco/NumberFormatter.h"
+#include "Poco/NumberParser.h"
+#include "Poco/String.h"
+
+
+namespace Poco {
+
+
+Logger::LoggerMap* Logger::_pLoggerMap = 0;
+Mutex Logger::_mapMtx;
+const std::string Logger::ROOT;
+
+
+Logger::Logger(const std::string& rName, Channel* pChannel, int level): _name(rName), _pChannel(pChannel), _level(level)
+{
+ if (pChannel) pChannel->duplicate();
+}
+
+
+Logger::~Logger()
+{
+ if (_pChannel) _pChannel->release();
+}
+
+
+void Logger::setChannel(Channel* pChannel)
+{
+ if (_pChannel) _pChannel->release();
+ _pChannel = pChannel;
+ if (_pChannel) _pChannel->duplicate();
+}
+
+
+Channel* Logger::getChannel() const
+{
+ return _pChannel;
+}
+
+
+void Logger::setLevel(int level)
+{
+ _level = level;
+}
+
+
+void Logger::setLevel(const std::string& level)
+{
+ setLevel(parseLevel(level));
+}
+
+
+void Logger::setProperty(const std::string& rName, const std::string& rValue)
+{
+ if (rName == "channel")
+ setChannel(LoggingRegistry::defaultRegistry().channelForName(rValue));
+ else if (rName == "level")
+ setLevel(rValue);
+ else
+ Channel::setProperty(rName, rValue);
+}
+
+
+void Logger::log(const Message& msg)
+{
+ if (_level >= msg.getPriority() && _pChannel)
+ {
+ _pChannel->log(msg);
+ }
+}
+
+
+void Logger::log(const Exception& exc)
+{
+ error(exc.displayText());
+}
+
+
+void Logger::log(const Exception& exc, const char* file, int line)
+{
+ error(exc.displayText(), file, line);
+}
+
+
+void Logger::dump(const std::string& msg, const void* buffer, std::size_t length, Message::Priority prio)
+{
+ if (_level >= prio && _pChannel)
+ {
+ std::string text(msg);
+ formatDump(text, buffer, length);
+ _pChannel->log(Message(_name, text, prio));
+ }
+}
+
+
+void Logger::setLevel(const std::string& name, int level)
+{
+ Mutex::ScopedLock lock(_mapMtx);
+
+ if (_pLoggerMap)
+ {
+ std::string::size_type len = name.length();
+ for (LoggerMap::iterator it = _pLoggerMap->begin(); it != _pLoggerMap->end(); ++it)
+ {
+ if (len == 0 ||
+ (it->first.compare(0, len, name) == 0 && (it->first.length() == len || it->first[len] == '.')))
+ {
+ it->second->setLevel(level);
+ }
+ }
+ }
+}
+
+
+void Logger::setChannel(const std::string& name, Channel* pChannel)
+{
+ Mutex::ScopedLock lock(_mapMtx);
+
+ if (_pLoggerMap)
+ {
+ std::string::size_type len = name.length();
+ for (LoggerMap::iterator it = _pLoggerMap->begin(); it != _pLoggerMap->end(); ++it)
+ {
+ if (len == 0 ||
+ (it->first.compare(0, len, name) == 0 && (it->first.length() == len || it->first[len] == '.')))
+ {
+ it->second->setChannel(pChannel);
+ }
+ }
+ }
+}
+
+
+void Logger::setProperty(const std::string& loggerName, const std::string& propertyName, const std::string& value)
+{
+ Mutex::ScopedLock lock(_mapMtx);
+
+ if (_pLoggerMap)
+ {
+ std::string::size_type len = loggerName.length();
+ for (LoggerMap::iterator it = _pLoggerMap->begin(); it != _pLoggerMap->end(); ++it)
+ {
if (len == 0 ||
- (it->first.compare(0, len, name) == 0 && (it->first.length() == len || it->first[len] == '.')))
- {
- it->second->setLevel(level);
- }
- }
- }
-}
-
-
-void Logger::setChannel(const std::string& name, Channel* pChannel)
-{
- Mutex::ScopedLock lock(_mapMtx);
-
- if (_pLoggerMap)
- {
- std::string::size_type len = name.length();
- for (LoggerMap::iterator it = _pLoggerMap->begin(); it != _pLoggerMap->end(); ++it)
- {
- if (len == 0 ||
- (it->first.compare(0, len, name) == 0 && (it->first.length() == len || it->first[len] == '.')))
- {
- it->second->setChannel(pChannel);
- }
- }
- }
-}
-
-
-void Logger::setProperty(const std::string& loggerName, const std::string& propertyName, const std::string& value)
-{
- Mutex::ScopedLock lock(_mapMtx);
-
- if (_pLoggerMap)
- {
- std::string::size_type len = loggerName.length();
- for (LoggerMap::iterator it = _pLoggerMap->begin(); it != _pLoggerMap->end(); ++it)
- {
- if (len == 0 ||
- (it->first.compare(0, len, loggerName) == 0 && (it->first.length() == len || it->first[len] == '.')))
- {
- it->second->setProperty(propertyName, value);
- }
- }
- }
-}
-
-
-std::string Logger::format(const std::string& fmt, const std::string& arg)
-{
- std::string args[] =
- {
- arg
- };
- return format(fmt, 1, args);
-}
-
-
-std::string Logger::format(const std::string& fmt, const std::string& arg0, const std::string& arg1)
-{
- std::string args[] =
- {
- arg0,
- arg1
- };
- return format(fmt, 2, args);
-}
-
-
-std::string Logger::format(const std::string& fmt, const std::string& arg0, const std::string& arg1, const std::string& arg2)
-{
- std::string args[] =
- {
- arg0,
- arg1,
- arg2
- };
- return format(fmt, 3, args);
-}
-
-
-std::string Logger::format(const std::string& fmt, const std::string& arg0, const std::string& arg1, const std::string& arg2, const std::string& arg3)
-{
- std::string args[] =
- {
- arg0,
- arg1,
- arg2,
- arg3
- };
- return format(fmt, 4, args);
-}
-
-
-std::string Logger::format(const std::string& fmt, int argc, std::string argv[])
-{
- std::string result;
- std::string::const_iterator it = fmt.begin();
- while (it != fmt.end())
- {
- if (*it == '$')
- {
- ++it;
- if (*it == '$')
- {
- result += '$';
- }
- else if (*it >= '0' && *it <= '9')
- {
- int i = *it - '0';
- if (i < argc)
- result += argv[i];
- }
- else
- {
- result += '$';
- result += *it;
- }
- }
- else result += *it;
- ++it;
- }
- return result;
-}
-
-
-void Logger::formatDump(std::string& message, const void* buffer, std::size_t length)
-{
- const int BYTES_PER_LINE = 16;
-
- message.reserve(message.size() + length*6);
- if (!message.empty()) message.append("\n");
- unsigned char* base = (unsigned char*) buffer;
- int addr = 0;
- while (addr < length)
- {
- if (addr > 0) message.append("\n");
- message.append(NumberFormatter::formatHex(addr, 4));
- message.append(" ");
- int offset = 0;
- while (addr + offset < length && offset < BYTES_PER_LINE)
- {
- message.append(NumberFormatter::formatHex(base[addr + offset], 2));
- message.append(offset == 7 ? " " : " ");
- ++offset;
- }
- if (offset < 7) message.append(" ");
- while (offset < BYTES_PER_LINE) { message.append(" "); ++offset; }
- message.append(" ");
- offset = 0;
- while (addr + offset < length && offset < BYTES_PER_LINE)
- {
- unsigned char c = base[addr + offset];
- message += (c >= 32 && c < 127) ? (char) c : '.';
- ++offset;
- }
- addr += BYTES_PER_LINE;
- }
-}
-
-
-Logger& Logger::get(const std::string& name)
-{
- Mutex::ScopedLock lock(_mapMtx);
-
- return unsafeGet(name);
-}
-
-
-Logger& Logger::unsafeGet(const std::string& name)
-{
- Logger* pLogger = find(name);
- if (!pLogger)
- {
- if (name == ROOT)
- {
- pLogger = new Logger(name, 0, Message::PRIO_INFORMATION);
- }
- else
- {
- Logger& par = parent(name);
- pLogger = new Logger(name, par.getChannel(), par.getLevel());
- }
- add(pLogger);
- }
- return *pLogger;
-}
-
-
-Logger& Logger::create(const std::string& name, Channel* pChannel, int level)
-{
- Mutex::ScopedLock lock(_mapMtx);
-
- if (find(name)) throw ExistsException();
- Logger* pLogger = new Logger(name, pChannel, level);
- add(pLogger);
- return *pLogger;
-}
-
-
-Logger& Logger::root()
-{
- Mutex::ScopedLock lock(_mapMtx);
-
- return unsafeGet(ROOT);
-}
-
-
-Logger* Logger::has(const std::string& name)
-{
- Mutex::ScopedLock lock(_mapMtx);
-
- return find(name);
-}
-
-
-void Logger::shutdown()
-{
- Mutex::ScopedLock lock(_mapMtx);
-
- if (_pLoggerMap)
- {
- for (LoggerMap::iterator it = _pLoggerMap->begin(); it != _pLoggerMap->end(); ++it)
- {
- it->second->release();
- }
- delete _pLoggerMap;
- _pLoggerMap = 0;
- }
-}
-
-
-Logger* Logger::find(const std::string& name)
-{
- if (_pLoggerMap)
- {
- LoggerMap::iterator it = _pLoggerMap->find(name);
- if (it != _pLoggerMap->end())
- return it->second;
- }
- return 0;
-}
-
-
-void Logger::destroy(const std::string& name)
-{
- Mutex::ScopedLock lock(_mapMtx);
-
- if (_pLoggerMap)
- {
- LoggerMap::iterator it = _pLoggerMap->find(name);
- if (it != _pLoggerMap->end())
- {
- it->second->release();
- _pLoggerMap->erase(it);
- }
- }
-}
-
-
-void Logger::names(std::vector<std::string>& names)
-{
- Mutex::ScopedLock lock(_mapMtx);
-
- names.clear();
- if (_pLoggerMap)
- {
- for (LoggerMap::const_iterator it = _pLoggerMap->begin(); it != _pLoggerMap->end(); ++it)
- {
- names.push_back(it->first);
- }
- }
-}
-
-
-Logger& Logger::parent(const std::string& name)
-{
- std::string::size_type pos = name.rfind('.');
- if (pos != std::string::npos)
- {
- std::string pname = name.substr(0, pos);
- Logger* pParent = find(pname);
- if (pParent)
- return *pParent;
- else
- return parent(pname);
- }
- else return unsafeGet(ROOT);
-}
-
-
-int Logger::parseLevel(const std::string& level)
-{
- if (icompare(level, "none") == 0)
- return 0;
- else if (icompare(level, "fatal") == 0)
- return Message::PRIO_FATAL;
- else if (icompare(level, "critical") == 0)
- return Message::PRIO_CRITICAL;
- else if (icompare(level, "error") == 0)
- return Message::PRIO_ERROR;
- else if (icompare(level, "warning") == 0)
- return Message::PRIO_WARNING;
- else if (icompare(level, "notice") == 0)
- return Message::PRIO_NOTICE;
- else if (icompare(level, "information") == 0)
- return Message::PRIO_INFORMATION;
- else if (icompare(level, "debug") == 0)
- return Message::PRIO_DEBUG;
- else if (icompare(level, "trace") == 0)
- return Message::PRIO_TRACE;
+ (it->first.compare(0, len, loggerName) == 0 && (it->first.length() == len || it->first[len] == '.')))
+ {
+ it->second->setProperty(propertyName, value);
+ }
+ }
+ }
+}
+
+
+std::string Logger::format(const std::string& fmt, const std::string& arg)
+{
+ std::string args[] =
+ {
+ arg
+ };
+ return format(fmt, 1, args);
+}
+
+
+std::string Logger::format(const std::string& fmt, const std::string& arg0, const std::string& arg1)
+{
+ std::string args[] =
+ {
+ arg0,
+ arg1
+ };
+ return format(fmt, 2, args);
+}
+
+
+std::string Logger::format(const std::string& fmt, const std::string& arg0, const std::string& arg1, const std::string& arg2)
+{
+ std::string args[] =
+ {
+ arg0,
+ arg1,
+ arg2
+ };
+ return format(fmt, 3, args);
+}
+
+
+std::string Logger::format(const std::string& fmt, const std::string& arg0, const std::string& arg1, const std::string& arg2, const std::string& arg3)
+{
+ std::string args[] =
+ {
+ arg0,
+ arg1,
+ arg2,
+ arg3
+ };
+ return format(fmt, 4, args);
+}
+
+
+std::string Logger::format(const std::string& fmt, int argc, std::string argv[])
+{
+ std::string result;
+ std::string::const_iterator it = fmt.begin();
+ while (it != fmt.end())
+ {
+ if (*it == '$')
+ {
+ ++it;
+ if (*it == '$')
+ {
+ result += '$';
+ }
+ else if (*it >= '0' && *it <= '9')
+ {
+ int i = *it - '0';
+ if (i < argc)
+ result += argv[i];
+ }
+ else
+ {
+ result += '$';
+ result += *it;
+ }
+ }
+ else result += *it;
+ ++it;
+ }
+ return result;
+}
+
+
+void Logger::formatDump(std::string& message, const void* buffer, std::size_t length)
+{
+ const int BYTES_PER_LINE = 16;
+
+ message.reserve(message.size() + length*6);
+ if (!message.empty()) message.append("\n");
+ unsigned char* base = (unsigned char*) buffer;
+ int addr = 0;
+ while (addr < length)
+ {
+ if (addr > 0) message.append("\n");
+ message.append(NumberFormatter::formatHex(addr, 4));
+ message.append(" ");
+ int offset = 0;
+ while (addr + offset < length && offset < BYTES_PER_LINE)
+ {
+ message.append(NumberFormatter::formatHex(base[addr + offset], 2));
+ message.append(offset == 7 ? " " : " ");
+ ++offset;
+ }
+ if (offset < 7) message.append(" ");
+ while (offset < BYTES_PER_LINE) { message.append(" "); ++offset; }
+ message.append(" ");
+ offset = 0;
+ while (addr + offset < length && offset < BYTES_PER_LINE)
+ {
+ unsigned char c = base[addr + offset];
+ message += (c >= 32 && c < 127) ? (char) c : '.';
+ ++offset;
+ }
+ addr += BYTES_PER_LINE;
+ }
+}
+
+
+Logger& Logger::get(const std::string& name)
+{
+ Mutex::ScopedLock lock(_mapMtx);
+
+ return unsafeGet(name);
+}
+
+
+Logger& Logger::unsafeGet(const std::string& name)
+{
+ Logger* pLogger = find(name);
+ if (!pLogger)
+ {
+ if (name == ROOT)
+ {
+ pLogger = new Logger(name, 0, Message::PRIO_INFORMATION);
+ }
+ else
+ {
+ Logger& par = parent(name);
+ pLogger = new Logger(name, par.getChannel(), par.getLevel());
+ }
+ add(pLogger);
+ }
+ return *pLogger;
+}
+
+
+Logger& Logger::create(const std::string& name, Channel* pChannel, int level)
+{
+ Mutex::ScopedLock lock(_mapMtx);
+
+ if (find(name)) throw ExistsException();
+ Logger* pLogger = new Logger(name, pChannel, level);
+ add(pLogger);
+ return *pLogger;
+}
+
+
+Logger& Logger::root()
+{
+ Mutex::ScopedLock lock(_mapMtx);
+
+ return unsafeGet(ROOT);
+}
+
+
+Logger* Logger::has(const std::string& name)
+{
+ Mutex::ScopedLock lock(_mapMtx);
+
+ return find(name);
+}
+
+
+void Logger::shutdown()
+{
+ Mutex::ScopedLock lock(_mapMtx);
+
+ if (_pLoggerMap)
+ {
+ for (LoggerMap::iterator it = _pLoggerMap->begin(); it != _pLoggerMap->end(); ++it)
+ {
+ it->second->release();
+ }
+ delete _pLoggerMap;
+ _pLoggerMap = 0;
+ }
+}
+
+
+Logger* Logger::find(const std::string& name)
+{
+ if (_pLoggerMap)
+ {
+ LoggerMap::iterator it = _pLoggerMap->find(name);
+ if (it != _pLoggerMap->end())
+ return it->second;
+ }
+ return 0;
+}
+
+
+void Logger::destroy(const std::string& name)
+{
+ Mutex::ScopedLock lock(_mapMtx);
+
+ if (_pLoggerMap)
+ {
+ LoggerMap::iterator it = _pLoggerMap->find(name);
+ if (it != _pLoggerMap->end())
+ {
+ it->second->release();
+ _pLoggerMap->erase(it);
+ }
+ }
+}
+
+
+void Logger::names(std::vector<std::string>& names)
+{
+ Mutex::ScopedLock lock(_mapMtx);
+
+ names.clear();
+ if (_pLoggerMap)
+ {
+ for (LoggerMap::const_iterator it = _pLoggerMap->begin(); it != _pLoggerMap->end(); ++it)
+ {
+ names.push_back(it->first);
+ }
+ }
+}
+
+
+Logger& Logger::parent(const std::string& name)
+{
+ std::string::size_type pos = name.rfind('.');
+ if (pos != std::string::npos)
+ {
+ std::string pname = name.substr(0, pos);
+ Logger* pParent = find(pname);
+ if (pParent)
+ return *pParent;
+ else
+ return parent(pname);
+ }
+ else return unsafeGet(ROOT);
+}
+
+
+int Logger::parseLevel(const std::string& level)
+{
+ if (icompare(level, "none") == 0)
+ return 0;
+ else if (icompare(level, "fatal") == 0)
+ return Message::PRIO_FATAL;
+ else if (icompare(level, "critical") == 0)
+ return Message::PRIO_CRITICAL;
+ else if (icompare(level, "error") == 0)
+ return Message::PRIO_ERROR;
+ else if (icompare(level, "warning") == 0)
+ return Message::PRIO_WARNING;
+ else if (icompare(level, "notice") == 0)
+ return Message::PRIO_NOTICE;
+ else if (icompare(level, "information") == 0)
+ return Message::PRIO_INFORMATION;
+ else if (icompare(level, "debug") == 0)
+ return Message::PRIO_DEBUG;
+ else if (icompare(level, "trace") == 0)
+ return Message::PRIO_TRACE;
else if (icompare(level, "test") == 0)
return Message::PRIO_TEST;
- else
- {
- int numLevel;
- if (Poco::NumberParser::tryParse(level, numLevel))
- {
+ else
+ {
+ int numLevel;
+ if (Poco::NumberParser::tryParse(level, numLevel))
+ {
if (numLevel > 0 && numLevel < 10)
- return numLevel;
- else
- throw InvalidArgumentException("Log level out of range ", level);
- }
- else
- throw InvalidArgumentException("Not a valid log level", level);
- }
-}
-
-
-class AutoLoggerShutdown
-{
-public:
- AutoLoggerShutdown()
- {
- }
- ~AutoLoggerShutdown()
- {
- try
- {
- Logger::shutdown();
- }
- catch (...)
- {
- poco_unexpected();
- }
- }
-};
-
-
-namespace
-{
- static AutoLoggerShutdown als;
-}
-
-
-void Logger::add(Logger* pLogger)
-{
- if (!_pLoggerMap)
- _pLoggerMap = new LoggerMap;
- _pLoggerMap->insert(LoggerMap::value_type(pLogger->name(), pLogger));
-}
-
-
-} // namespace Poco
+ return numLevel;
+ else
+ throw InvalidArgumentException("Log level out of range ", level);
+ }
+ else
+ throw InvalidArgumentException("Not a valid log level", level);
+ }
+}
+
+
+class AutoLoggerShutdown
+{
+public:
+ AutoLoggerShutdown()
+ {
+ }
+ ~AutoLoggerShutdown()
+ {
+ try
+ {
+ Logger::shutdown();
+ }
+ catch (...)
+ {
+ poco_unexpected();
+ }
+ }
+};
+
+
+namespace
+{
+ static AutoLoggerShutdown als;
+}
+
+
+void Logger::add(Logger* pLogger)
+{
+ if (!_pLoggerMap)
+ _pLoggerMap = new LoggerMap;
+ _pLoggerMap->insert(LoggerMap::value_type(pLogger->name(), pLogger));
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/LoggingFactory.cpp b/contrib/libs/poco/Foundation/src/LoggingFactory.cpp
index f3e067a611..7c53bfe4e9 100644
--- a/contrib/libs/poco/Foundation/src/LoggingFactory.cpp
+++ b/contrib/libs/poco/Foundation/src/LoggingFactory.cpp
@@ -1,117 +1,117 @@
-//
-// LoggingFactory.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: LoggingFactory
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/LoggingFactory.h"
-#include "Poco/SingletonHolder.h"
-#include "Poco/AsyncChannel.h"
-#include "Poco/ConsoleChannel.h"
-#include "Poco/FileChannel.h"
-#include "Poco/FormattingChannel.h"
-#include "Poco/SplitterChannel.h"
-#include "Poco/NullChannel.h"
-#include "Poco/EventChannel.h"
-#if defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_NO_SYSLOGCHANNEL)
-#include "Poco/SyslogChannel.h"
-#endif
-#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(_WIN32_WCE)
-#include "Poco/EventLogChannel.h"
-#include "Poco/WindowsConsoleChannel.h"
-#endif
-#include "Poco/PatternFormatter.h"
-
-
-namespace Poco {
-
-
-LoggingFactory::LoggingFactory()
-{
- registerBuiltins();
-}
-
-
-LoggingFactory::~LoggingFactory()
-{
-}
-
-
-void LoggingFactory::registerChannelClass(const std::string& className, ChannelInstantiator* pFactory)
-{
- _channelFactory.registerClass(className, pFactory);
-}
-
-
-void LoggingFactory::registerFormatterClass(const std::string& className, FormatterFactory* pFactory)
-{
- _formatterFactory.registerClass(className, pFactory);
-}
-
-
-Channel* LoggingFactory::createChannel(const std::string& className) const
-{
- return _channelFactory.createInstance(className);
-}
-
-
-Formatter* LoggingFactory::createFormatter(const std::string& className) const
-{
- return _formatterFactory.createInstance(className);
-}
-
-
-namespace
-{
- static SingletonHolder<LoggingFactory> sh;
-}
-
-
-LoggingFactory& LoggingFactory::defaultFactory()
-{
- return *sh.get();
-}
-
-
-void LoggingFactory::registerBuiltins()
-{
- _channelFactory.registerClass("AsyncChannel", new Instantiator<AsyncChannel, Channel>);
-#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(_WIN32_WCE)
- _channelFactory.registerClass("ConsoleChannel", new Instantiator<WindowsConsoleChannel, Channel>);
- _channelFactory.registerClass("ColorConsoleChannel", new Instantiator<WindowsColorConsoleChannel, Channel>);
-#else
- _channelFactory.registerClass("ConsoleChannel", new Instantiator<ConsoleChannel, Channel>);
- _channelFactory.registerClass("ColorConsoleChannel", new Instantiator<ColorConsoleChannel, Channel>);
-#endif
-#ifndef POCO_NO_FILECHANNEL
- _channelFactory.registerClass("FileChannel", new Instantiator<FileChannel, Channel>);
-#endif
- _channelFactory.registerClass("FormattingChannel", new Instantiator<FormattingChannel, Channel>);
-#ifndef POCO_NO_SPLITTERCHANNEL
- _channelFactory.registerClass("SplitterChannel", new Instantiator<SplitterChannel, Channel>);
-#endif
- _channelFactory.registerClass("NullChannel", new Instantiator<NullChannel, Channel>);
- _channelFactory.registerClass("EventChannel", new Instantiator<EventChannel, Channel>);
-
-#if defined(POCO_OS_FAMILY_UNIX)
-#ifndef POCO_NO_SYSLOGCHANNEL
- _channelFactory.registerClass("SyslogChannel", new Instantiator<SyslogChannel, Channel>);
-#endif
-#endif
-#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(_WIN32_WCE)
- _channelFactory.registerClass("EventLogChannel", new Instantiator<EventLogChannel, Channel>);
-#endif
-
- _formatterFactory.registerClass("PatternFormatter", new Instantiator<PatternFormatter, Formatter>);
-}
-
-
-} // namespace Poco
+//
+// LoggingFactory.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: LoggingFactory
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/LoggingFactory.h"
+#include "Poco/SingletonHolder.h"
+#include "Poco/AsyncChannel.h"
+#include "Poco/ConsoleChannel.h"
+#include "Poco/FileChannel.h"
+#include "Poco/FormattingChannel.h"
+#include "Poco/SplitterChannel.h"
+#include "Poco/NullChannel.h"
+#include "Poco/EventChannel.h"
+#if defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_NO_SYSLOGCHANNEL)
+#include "Poco/SyslogChannel.h"
+#endif
+#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(_WIN32_WCE)
+#include "Poco/EventLogChannel.h"
+#include "Poco/WindowsConsoleChannel.h"
+#endif
+#include "Poco/PatternFormatter.h"
+
+
+namespace Poco {
+
+
+LoggingFactory::LoggingFactory()
+{
+ registerBuiltins();
+}
+
+
+LoggingFactory::~LoggingFactory()
+{
+}
+
+
+void LoggingFactory::registerChannelClass(const std::string& className, ChannelInstantiator* pFactory)
+{
+ _channelFactory.registerClass(className, pFactory);
+}
+
+
+void LoggingFactory::registerFormatterClass(const std::string& className, FormatterFactory* pFactory)
+{
+ _formatterFactory.registerClass(className, pFactory);
+}
+
+
+Channel* LoggingFactory::createChannel(const std::string& className) const
+{
+ return _channelFactory.createInstance(className);
+}
+
+
+Formatter* LoggingFactory::createFormatter(const std::string& className) const
+{
+ return _formatterFactory.createInstance(className);
+}
+
+
+namespace
+{
+ static SingletonHolder<LoggingFactory> sh;
+}
+
+
+LoggingFactory& LoggingFactory::defaultFactory()
+{
+ return *sh.get();
+}
+
+
+void LoggingFactory::registerBuiltins()
+{
+ _channelFactory.registerClass("AsyncChannel", new Instantiator<AsyncChannel, Channel>);
+#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(_WIN32_WCE)
+ _channelFactory.registerClass("ConsoleChannel", new Instantiator<WindowsConsoleChannel, Channel>);
+ _channelFactory.registerClass("ColorConsoleChannel", new Instantiator<WindowsColorConsoleChannel, Channel>);
+#else
+ _channelFactory.registerClass("ConsoleChannel", new Instantiator<ConsoleChannel, Channel>);
+ _channelFactory.registerClass("ColorConsoleChannel", new Instantiator<ColorConsoleChannel, Channel>);
+#endif
+#ifndef POCO_NO_FILECHANNEL
+ _channelFactory.registerClass("FileChannel", new Instantiator<FileChannel, Channel>);
+#endif
+ _channelFactory.registerClass("FormattingChannel", new Instantiator<FormattingChannel, Channel>);
+#ifndef POCO_NO_SPLITTERCHANNEL
+ _channelFactory.registerClass("SplitterChannel", new Instantiator<SplitterChannel, Channel>);
+#endif
+ _channelFactory.registerClass("NullChannel", new Instantiator<NullChannel, Channel>);
+ _channelFactory.registerClass("EventChannel", new Instantiator<EventChannel, Channel>);
+
+#if defined(POCO_OS_FAMILY_UNIX)
+#ifndef POCO_NO_SYSLOGCHANNEL
+ _channelFactory.registerClass("SyslogChannel", new Instantiator<SyslogChannel, Channel>);
+#endif
+#endif
+#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(_WIN32_WCE)
+ _channelFactory.registerClass("EventLogChannel", new Instantiator<EventLogChannel, Channel>);
+#endif
+
+ _formatterFactory.registerClass("PatternFormatter", new Instantiator<PatternFormatter, Formatter>);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/LoggingRegistry.cpp b/contrib/libs/poco/Foundation/src/LoggingRegistry.cpp
index 9d7edfef47..2fa1845c4c 100644
--- a/contrib/libs/poco/Foundation/src/LoggingRegistry.cpp
+++ b/contrib/libs/poco/Foundation/src/LoggingRegistry.cpp
@@ -1,117 +1,117 @@
-//
-// LoggingRegistry.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: LoggingRegistry
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/LoggingRegistry.h"
-#include "Poco/SingletonHolder.h"
-
-
-namespace Poco {
-
-
-LoggingRegistry::LoggingRegistry()
-{
-}
-
-
-LoggingRegistry::~LoggingRegistry()
-{
-}
-
-
-Channel* LoggingRegistry::channelForName(const std::string& name) const
-{
- FastMutex::ScopedLock lock(_mutex);
-
- ChannelMap::const_iterator it = _channelMap.find(name);
- if (it != _channelMap.end())
- return const_cast<Channel*>(it->second.get());
- else
- throw NotFoundException("logging channel", name);
-}
-
-
-Formatter* LoggingRegistry::formatterForName(const std::string& name) const
-{
- FastMutex::ScopedLock lock(_mutex);
-
- FormatterMap::const_iterator it = _formatterMap.find(name);
- if (it != _formatterMap.end())
- return const_cast<Formatter*>(it->second.get());
- else
- throw NotFoundException("logging formatter", name);
-}
-
-
-void LoggingRegistry::registerChannel(const std::string& name, Channel* pChannel)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- _channelMap[name] = ChannelPtr(pChannel, true);
-}
-
-
-void LoggingRegistry::registerFormatter(const std::string& name, Formatter* pFormatter)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- _formatterMap[name] = FormatterPtr(pFormatter, true);
-}
-
-
-void LoggingRegistry::unregisterChannel(const std::string& name)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- ChannelMap::iterator it = _channelMap.find(name);
- if (it != _channelMap.end())
- _channelMap.erase(it);
- else
- throw NotFoundException("logging channel", name);
-}
-
-
-void LoggingRegistry::unregisterFormatter(const std::string& name)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- FormatterMap::iterator it = _formatterMap.find(name);
- if (it != _formatterMap.end())
- _formatterMap.erase(it);
- else
- throw NotFoundException("logging formatter", name);
-}
-
-
-void LoggingRegistry::clear()
-{
- FastMutex::ScopedLock lock(_mutex);
-
- _channelMap.clear();
- _formatterMap.clear();
-}
-
-
-namespace
-{
- static SingletonHolder<LoggingRegistry> sh;
-}
-
-
-LoggingRegistry& LoggingRegistry::defaultRegistry()
-{
- return *sh.get();
-}
-
-
-} // namespace Poco
+//
+// LoggingRegistry.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: LoggingRegistry
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/LoggingRegistry.h"
+#include "Poco/SingletonHolder.h"
+
+
+namespace Poco {
+
+
+LoggingRegistry::LoggingRegistry()
+{
+}
+
+
+LoggingRegistry::~LoggingRegistry()
+{
+}
+
+
+Channel* LoggingRegistry::channelForName(const std::string& name) const
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ ChannelMap::const_iterator it = _channelMap.find(name);
+ if (it != _channelMap.end())
+ return const_cast<Channel*>(it->second.get());
+ else
+ throw NotFoundException("logging channel", name);
+}
+
+
+Formatter* LoggingRegistry::formatterForName(const std::string& name) const
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ FormatterMap::const_iterator it = _formatterMap.find(name);
+ if (it != _formatterMap.end())
+ return const_cast<Formatter*>(it->second.get());
+ else
+ throw NotFoundException("logging formatter", name);
+}
+
+
+void LoggingRegistry::registerChannel(const std::string& name, Channel* pChannel)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ _channelMap[name] = ChannelPtr(pChannel, true);
+}
+
+
+void LoggingRegistry::registerFormatter(const std::string& name, Formatter* pFormatter)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ _formatterMap[name] = FormatterPtr(pFormatter, true);
+}
+
+
+void LoggingRegistry::unregisterChannel(const std::string& name)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ ChannelMap::iterator it = _channelMap.find(name);
+ if (it != _channelMap.end())
+ _channelMap.erase(it);
+ else
+ throw NotFoundException("logging channel", name);
+}
+
+
+void LoggingRegistry::unregisterFormatter(const std::string& name)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ FormatterMap::iterator it = _formatterMap.find(name);
+ if (it != _formatterMap.end())
+ _formatterMap.erase(it);
+ else
+ throw NotFoundException("logging formatter", name);
+}
+
+
+void LoggingRegistry::clear()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ _channelMap.clear();
+ _formatterMap.clear();
+}
+
+
+namespace
+{
+ static SingletonHolder<LoggingRegistry> sh;
+}
+
+
+LoggingRegistry& LoggingRegistry::defaultRegistry()
+{
+ return *sh.get();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/MD4Engine.cpp b/contrib/libs/poco/Foundation/src/MD4Engine.cpp
index 779d756e23..857a9539ab 100644
--- a/contrib/libs/poco/Foundation/src/MD4Engine.cpp
+++ b/contrib/libs/poco/Foundation/src/MD4Engine.cpp
@@ -1,278 +1,278 @@
-//
-// MD4Engine.cpp
-//
-// Library: Foundation
-// Package: Crypt
-// Module: MD4Engine
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-//
-// MD4 (RFC 1320) 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. MD4 Message-Digest
-// Algorithm" in all material mentioning or referencing this software
-// or this function.
-//
-// License is also granted to make and use derivative works provided
-// that such works are identified as "derived from the RSA Data
-// Security, Inc. MD4 Message-Digest Algorithm" in all material
-// mentioning or referencing the derived work.
-//
-// RSA Data Security, Inc. makes no representations concerning either
-// the merchantability of this software or the suitability of this
-// software for any particular purpose. It is provided "as is"
-// without express or implied warranty of any kind.
-//
-// These notices must be retained in any copies of any part of this
-// documentation and/or software.
-//
-
-
-#include "Poco/MD4Engine.h"
-#include <cstring>
-
-
-namespace Poco {
-
-
-MD4Engine::MD4Engine()
-{
- _digest.reserve(16);
- reset();
-}
-
-
-MD4Engine::~MD4Engine()
-{
- reset();
-}
-
-
-void MD4Engine::updateImpl(const void* input_, std::size_t inputLen)
-{
- const unsigned char* input = (const unsigned char*) input_;
- unsigned int i, index, partLen;
-
- /* Compute number of bytes mod 64 */
- index = (unsigned int)((_context.count[0] >> 3) & 0x3F);
-
- /* Update number of bits */
- if ((_context.count[0] += ((UInt32) inputLen << 3)) < ((UInt32) inputLen << 3))
- _context.count[1]++;
- _context.count[1] += ((UInt32) inputLen >> 29);
-
- partLen = 64 - index;
-
- /* Transform as many times as possible. */
- if (inputLen >= partLen)
- {
- std::memcpy(&_context.buffer[index], input, partLen);
- transform(_context.state, _context.buffer);
-
- for (i = partLen; i + 63 < inputLen; i += 64)
- transform(_context.state, &input[i]);
-
- index = 0;
- }
- else i = 0;
-
- /* Buffer remaining input */
- std::memcpy(&_context.buffer[index], &input[i], inputLen-i);
-}
-
-
-std::size_t MD4Engine::digestLength() const
-{
- return DIGEST_SIZE;
-}
-
-
-void MD4Engine::reset()
-{
- std::memset(&_context, 0, sizeof(_context));
- _context.count[0] = _context.count[1] = 0;
- _context.state[0] = 0x67452301;
- _context.state[1] = 0xefcdab89;
- _context.state[2] = 0x98badcfe;
- _context.state[3] = 0x10325476;
-}
-
-
-const DigestEngine::Digest& MD4Engine::digest()
-{
- 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,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
- unsigned char bits[8];
- unsigned int index, padLen;
-
- /* Save number of bits */
- encode(bits, _context.count, 8);
-
- /* Pad out to 56 mod 64. */
- index = (unsigned int)((_context.count[0] >> 3) & 0x3f);
- padLen = (index < 56) ? (56 - index) : (120 - index);
- update(PADDING, padLen);
-
- /* Append length (before padding) */
- update(bits, 8);
-
- /* Store state in digestArray */
- unsigned char digestArray[16];
- encode(digestArray, _context.state, 16);
- _digest.clear();
- _digest.insert(_digest.begin(), digestArray, digestArray + sizeof(digestArray));
-
- /* Zeroize sensitive information. */
- std::memset(&_context, 0, sizeof (_context));
- reset();
- return _digest;
-}
-
-
-/* Constants for MD4Transform routine. */
-#define S11 3
-#define S12 7
-#define S13 11
-#define S14 19
-#define S21 3
-#define S22 5
-#define S23 9
-#define S24 13
-#define S31 3
-#define S32 9
-#define S33 11
-#define S34 15
-
-
-/* F, G and H are basic MD4 functions. */
-#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
-#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
-#define H(x, y, z) ((x) ^ (y) ^ (z))
-
-
-/* ROTATE_LEFT rotates x left n bits. */
-#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
-
-
-/* FF, GG and HH are transformations for rounds 1, 2 and 3 */
-/* Rotation is separate from addition to prevent recomputation */
-#define FF(a, b, c, d, x, s) { \
- (a) += F ((b), (c), (d)) + (x); \
- (a) = ROTATE_LEFT ((a), (s)); \
- }
-#define GG(a, b, c, d, x, s) { \
- (a) += G ((b), (c), (d)) + (x) + (UInt32)0x5a827999; \
- (a) = ROTATE_LEFT ((a), (s)); \
- }
-#define HH(a, b, c, d, x, s) { \
- (a) += H ((b), (c), (d)) + (x) + (UInt32)0x6ed9eba1; \
- (a) = ROTATE_LEFT ((a), (s)); \
- }
-
-
-void MD4Engine::transform (UInt32 state[4], const unsigned char block[64])
-{
- UInt32 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
-
- decode(x, block, 64);
-
- /* Round 1 */
- FF (a, b, c, d, x[ 0], S11); /* 1 */
- FF (d, a, b, c, x[ 1], S12); /* 2 */
- FF (c, d, a, b, x[ 2], S13); /* 3 */
- FF (b, c, d, a, x[ 3], S14); /* 4 */
- FF (a, b, c, d, x[ 4], S11); /* 5 */
- FF (d, a, b, c, x[ 5], S12); /* 6 */
- FF (c, d, a, b, x[ 6], S13); /* 7 */
- FF (b, c, d, a, x[ 7], S14); /* 8 */
- FF (a, b, c, d, x[ 8], S11); /* 9 */
- FF (d, a, b, c, x[ 9], S12); /* 10 */
- FF (c, d, a, b, x[10], S13); /* 11 */
- FF (b, c, d, a, x[11], S14); /* 12 */
- FF (a, b, c, d, x[12], S11); /* 13 */
- FF (d, a, b, c, x[13], S12); /* 14 */
- FF (c, d, a, b, x[14], S13); /* 15 */
- FF (b, c, d, a, x[15], S14); /* 16 */
-
- /* Round 2 */
- GG (a, b, c, d, x[ 0], S21); /* 17 */
- GG (d, a, b, c, x[ 4], S22); /* 18 */
- GG (c, d, a, b, x[ 8], S23); /* 19 */
- GG (b, c, d, a, x[12], S24); /* 20 */
- GG (a, b, c, d, x[ 1], S21); /* 21 */
- GG (d, a, b, c, x[ 5], S22); /* 22 */
- GG (c, d, a, b, x[ 9], S23); /* 23 */
- GG (b, c, d, a, x[13], S24); /* 24 */
- GG (a, b, c, d, x[ 2], S21); /* 25 */
- GG (d, a, b, c, x[ 6], S22); /* 26 */
- GG (c, d, a, b, x[10], S23); /* 27 */
- GG (b, c, d, a, x[14], S24); /* 28 */
- GG (a, b, c, d, x[ 3], S21); /* 29 */
- GG (d, a, b, c, x[ 7], S22); /* 30 */
- GG (c, d, a, b, x[11], S23); /* 31 */
- GG (b, c, d, a, x[15], S24); /* 32 */
-
- /* Round 3 */
- HH (a, b, c, d, x[ 0], S31); /* 33 */
- HH (d, a, b, c, x[ 8], S32); /* 34 */
- HH (c, d, a, b, x[ 4], S33); /* 35 */
- HH (b, c, d, a, x[12], S34); /* 36 */
- HH (a, b, c, d, x[ 2], S31); /* 37 */
- HH (d, a, b, c, x[10], S32); /* 38 */
- HH (c, d, a, b, x[ 6], S33); /* 39 */
- HH (b, c, d, a, x[14], S34); /* 40 */
- HH (a, b, c, d, x[ 1], S31); /* 41 */
- HH (d, a, b, c, x[ 9], S32); /* 42 */
- HH (c, d, a, b, x[ 5], S33); /* 43 */
- HH (b, c, d, a, x[13], S34); /* 44 */
- HH (a, b, c, d, x[ 3], S31); /* 45 */
- HH (d, a, b, c, x[11], S32); /* 46 */
- HH (c, d, a, b, x[ 7], S33); /* 47 */
- HH (b, c, d, a, x[15], S34); /* 48 */
-
- state[0] += a;
- state[1] += b;
- state[2] += c;
- state[3] += d;
-
- /* Zeroize sensitive information. */
- std::memset(x, 0, sizeof(x));
-}
-
-
-void MD4Engine::encode(unsigned char* output, const UInt32* input, std::size_t len)
-{
- unsigned int i, j;
-
- 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);
- output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
- output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
- }
-}
-
-
-void MD4Engine::decode(UInt32* output, const unsigned char* input, std::size_t len)
-{
- unsigned int i, j;
-
- for (i = 0, j = 0; j < len; i++, j += 4)
- output[i] = ((UInt32)input[j]) | (((UInt32)input[j+1]) << 8) |
- (((UInt32)input[j+2]) << 16) | (((UInt32)input[j+3]) << 24);
-}
-
-
-} // namespace Poco
+//
+// MD4Engine.cpp
+//
+// Library: Foundation
+// Package: Crypt
+// Module: MD4Engine
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+//
+// MD4 (RFC 1320) 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. MD4 Message-Digest
+// Algorithm" in all material mentioning or referencing this software
+// or this function.
+//
+// License is also granted to make and use derivative works provided
+// that such works are identified as "derived from the RSA Data
+// Security, Inc. MD4 Message-Digest Algorithm" in all material
+// mentioning or referencing the derived work.
+//
+// RSA Data Security, Inc. makes no representations concerning either
+// the merchantability of this software or the suitability of this
+// software for any particular purpose. It is provided "as is"
+// without express or implied warranty of any kind.
+//
+// These notices must be retained in any copies of any part of this
+// documentation and/or software.
+//
+
+
+#include "Poco/MD4Engine.h"
+#include <cstring>
+
+
+namespace Poco {
+
+
+MD4Engine::MD4Engine()
+{
+ _digest.reserve(16);
+ reset();
+}
+
+
+MD4Engine::~MD4Engine()
+{
+ reset();
+}
+
+
+void MD4Engine::updateImpl(const void* input_, std::size_t inputLen)
+{
+ const unsigned char* input = (const unsigned char*) input_;
+ unsigned int i, index, partLen;
+
+ /* Compute number of bytes mod 64 */
+ index = (unsigned int)((_context.count[0] >> 3) & 0x3F);
+
+ /* Update number of bits */
+ if ((_context.count[0] += ((UInt32) inputLen << 3)) < ((UInt32) inputLen << 3))
+ _context.count[1]++;
+ _context.count[1] += ((UInt32) inputLen >> 29);
+
+ partLen = 64 - index;
+
+ /* Transform as many times as possible. */
+ if (inputLen >= partLen)
+ {
+ std::memcpy(&_context.buffer[index], input, partLen);
+ transform(_context.state, _context.buffer);
+
+ for (i = partLen; i + 63 < inputLen; i += 64)
+ transform(_context.state, &input[i]);
+
+ index = 0;
+ }
+ else i = 0;
+
+ /* Buffer remaining input */
+ std::memcpy(&_context.buffer[index], &input[i], inputLen-i);
+}
+
+
+std::size_t MD4Engine::digestLength() const
+{
+ return DIGEST_SIZE;
+}
+
+
+void MD4Engine::reset()
+{
+ std::memset(&_context, 0, sizeof(_context));
+ _context.count[0] = _context.count[1] = 0;
+ _context.state[0] = 0x67452301;
+ _context.state[1] = 0xefcdab89;
+ _context.state[2] = 0x98badcfe;
+ _context.state[3] = 0x10325476;
+}
+
+
+const DigestEngine::Digest& MD4Engine::digest()
+{
+ 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
+ unsigned char bits[8];
+ unsigned int index, padLen;
+
+ /* Save number of bits */
+ encode(bits, _context.count, 8);
+
+ /* Pad out to 56 mod 64. */
+ index = (unsigned int)((_context.count[0] >> 3) & 0x3f);
+ padLen = (index < 56) ? (56 - index) : (120 - index);
+ update(PADDING, padLen);
+
+ /* Append length (before padding) */
+ update(bits, 8);
+
+ /* Store state in digestArray */
+ unsigned char digestArray[16];
+ encode(digestArray, _context.state, 16);
+ _digest.clear();
+ _digest.insert(_digest.begin(), digestArray, digestArray + sizeof(digestArray));
+
+ /* Zeroize sensitive information. */
+ std::memset(&_context, 0, sizeof (_context));
+ reset();
+ return _digest;
+}
+
+
+/* Constants for MD4Transform routine. */
+#define S11 3
+#define S12 7
+#define S13 11
+#define S14 19
+#define S21 3
+#define S22 5
+#define S23 9
+#define S24 13
+#define S31 3
+#define S32 9
+#define S33 11
+#define S34 15
+
+
+/* F, G and H are basic MD4 functions. */
+#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
+#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+
+
+/* ROTATE_LEFT rotates x left n bits. */
+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+
+
+/* FF, GG and HH are transformations for rounds 1, 2 and 3 */
+/* Rotation is separate from addition to prevent recomputation */
+#define FF(a, b, c, d, x, s) { \
+ (a) += F ((b), (c), (d)) + (x); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ }
+#define GG(a, b, c, d, x, s) { \
+ (a) += G ((b), (c), (d)) + (x) + (UInt32)0x5a827999; \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ }
+#define HH(a, b, c, d, x, s) { \
+ (a) += H ((b), (c), (d)) + (x) + (UInt32)0x6ed9eba1; \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ }
+
+
+void MD4Engine::transform (UInt32 state[4], const unsigned char block[64])
+{
+ UInt32 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
+
+ decode(x, block, 64);
+
+ /* Round 1 */
+ FF (a, b, c, d, x[ 0], S11); /* 1 */
+ FF (d, a, b, c, x[ 1], S12); /* 2 */
+ FF (c, d, a, b, x[ 2], S13); /* 3 */
+ FF (b, c, d, a, x[ 3], S14); /* 4 */
+ FF (a, b, c, d, x[ 4], S11); /* 5 */
+ FF (d, a, b, c, x[ 5], S12); /* 6 */
+ FF (c, d, a, b, x[ 6], S13); /* 7 */
+ FF (b, c, d, a, x[ 7], S14); /* 8 */
+ FF (a, b, c, d, x[ 8], S11); /* 9 */
+ FF (d, a, b, c, x[ 9], S12); /* 10 */
+ FF (c, d, a, b, x[10], S13); /* 11 */
+ FF (b, c, d, a, x[11], S14); /* 12 */
+ FF (a, b, c, d, x[12], S11); /* 13 */
+ FF (d, a, b, c, x[13], S12); /* 14 */
+ FF (c, d, a, b, x[14], S13); /* 15 */
+ FF (b, c, d, a, x[15], S14); /* 16 */
+
+ /* Round 2 */
+ GG (a, b, c, d, x[ 0], S21); /* 17 */
+ GG (d, a, b, c, x[ 4], S22); /* 18 */
+ GG (c, d, a, b, x[ 8], S23); /* 19 */
+ GG (b, c, d, a, x[12], S24); /* 20 */
+ GG (a, b, c, d, x[ 1], S21); /* 21 */
+ GG (d, a, b, c, x[ 5], S22); /* 22 */
+ GG (c, d, a, b, x[ 9], S23); /* 23 */
+ GG (b, c, d, a, x[13], S24); /* 24 */
+ GG (a, b, c, d, x[ 2], S21); /* 25 */
+ GG (d, a, b, c, x[ 6], S22); /* 26 */
+ GG (c, d, a, b, x[10], S23); /* 27 */
+ GG (b, c, d, a, x[14], S24); /* 28 */
+ GG (a, b, c, d, x[ 3], S21); /* 29 */
+ GG (d, a, b, c, x[ 7], S22); /* 30 */
+ GG (c, d, a, b, x[11], S23); /* 31 */
+ GG (b, c, d, a, x[15], S24); /* 32 */
+
+ /* Round 3 */
+ HH (a, b, c, d, x[ 0], S31); /* 33 */
+ HH (d, a, b, c, x[ 8], S32); /* 34 */
+ HH (c, d, a, b, x[ 4], S33); /* 35 */
+ HH (b, c, d, a, x[12], S34); /* 36 */
+ HH (a, b, c, d, x[ 2], S31); /* 37 */
+ HH (d, a, b, c, x[10], S32); /* 38 */
+ HH (c, d, a, b, x[ 6], S33); /* 39 */
+ HH (b, c, d, a, x[14], S34); /* 40 */
+ HH (a, b, c, d, x[ 1], S31); /* 41 */
+ HH (d, a, b, c, x[ 9], S32); /* 42 */
+ HH (c, d, a, b, x[ 5], S33); /* 43 */
+ HH (b, c, d, a, x[13], S34); /* 44 */
+ HH (a, b, c, d, x[ 3], S31); /* 45 */
+ HH (d, a, b, c, x[11], S32); /* 46 */
+ HH (c, d, a, b, x[ 7], S33); /* 47 */
+ HH (b, c, d, a, x[15], S34); /* 48 */
+
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+
+ /* Zeroize sensitive information. */
+ std::memset(x, 0, sizeof(x));
+}
+
+
+void MD4Engine::encode(unsigned char* output, const UInt32* input, std::size_t len)
+{
+ unsigned int i, j;
+
+ 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);
+ output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
+ output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
+ }
+}
+
+
+void MD4Engine::decode(UInt32* output, const unsigned char* input, std::size_t len)
+{
+ unsigned int i, j;
+
+ for (i = 0, j = 0; j < len; i++, j += 4)
+ output[i] = ((UInt32)input[j]) | (((UInt32)input[j+1]) << 8) |
+ (((UInt32)input[j+2]) << 16) | (((UInt32)input[j+3]) << 24);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/MD5Engine.cpp b/contrib/libs/poco/Foundation/src/MD5Engine.cpp
index 6127c31dc3..e6af41775e 100644
--- a/contrib/libs/poco/Foundation/src/MD5Engine.cpp
+++ b/contrib/libs/poco/Foundation/src/MD5Engine.cpp
@@ -1,309 +1,309 @@
-//
-// MD5Engine.cpp
-//
-// Library: Foundation
-// Package: Crypt
-// Module: MD5Engine
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-//
-// 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
-// or this function.
-//
-// License is also granted to make and use derivative works provided
-// that such works are identified as "derived from the RSA Data
-// Security, Inc. MD5 Message-Digest Algorithm" in all material
-// mentioning or referencing the derived work.
-//
-// RSA Data Security, Inc. makes no representations concerning either
-// the merchantability of this software or the suitability of this
-// software for any particular purpose. It is provided "as is"
-// without express or implied warranty of any kind.
-//
-// These notices must be retained in any copies of any part of this
-// documentation and/or software.
-//
-
-
-#include "Poco/MD5Engine.h"
-#include <cstring>
-
-
-namespace Poco {
-
-
-MD5Engine::MD5Engine()
-{
- _digest.reserve(16);
- reset();
-}
-
-
-MD5Engine::~MD5Engine()
-{
- reset();
-}
-
-
-void MD5Engine::updateImpl(const void* input_, std::size_t inputLen)
-{
- const unsigned char* input = (const unsigned char*) input_;
- unsigned int i, index, partLen;
-
- /* Compute number of bytes mod 64 */
- index = (unsigned int)((_context.count[0] >> 3) & 0x3F);
-
- /* Update number of bits */
- if ((_context.count[0] += ((UInt32) inputLen << 3)) < ((UInt32) inputLen << 3))
- _context.count[1]++;
- _context.count[1] += ((UInt32) inputLen >> 29);
-
- partLen = 64 - index;
-
- /* Transform as many times as possible. */
- if (inputLen >= partLen)
- {
- std::memcpy(&_context.buffer[index], input, partLen);
- transform(_context.state, _context.buffer);
-
- for (i = partLen; i + 63 < inputLen; i += 64)
- transform(_context.state, &input[i]);
-
- index = 0;
- }
- else i = 0;
-
- /* Buffer remaining input */
- std::memcpy(&_context.buffer[index], &input[i],inputLen-i);
-}
-
-
-std::size_t MD5Engine::digestLength() const
-{
- return DIGEST_SIZE;
-}
-
-
-void MD5Engine::reset()
-{
- std::memset(&_context, 0, sizeof(_context));
- _context.count[0] = _context.count[1] = 0;
- _context.state[0] = 0x67452301;
- _context.state[1] = 0xefcdab89;
- _context.state[2] = 0x98badcfe;
- _context.state[3] = 0x10325476;
-}
-
-
-const DigestEngine::Digest& MD5Engine::digest()
-{
- 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,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
- unsigned char bits[8];
- unsigned int index, padLen;
-
- /* Save number of bits */
- encode(bits, _context.count, 8);
-
- /* Pad out to 56 mod 64. */
- index = (unsigned int)((_context.count[0] >> 3) & 0x3f);
- padLen = (index < 56) ? (56 - index) : (120 - index);
- update(PADDING, padLen);
-
- /* Append length (before padding) */
- update(bits, 8);
-
- /* Store state in digestArray */
- unsigned char digestArray[16];
- encode(digestArray, _context.state, 16);
- _digest.clear();
- _digest.insert(_digest.begin(), digestArray, digestArray + sizeof(digestArray));
-
- /* Zeroize sensitive information. */
- std::memset(&_context, 0, sizeof (_context));
- reset();
- return _digest;
-}
-
-
-/* Constants for MD5Transform routine. */
-#define S11 7
-#define S12 12
-#define S13 17
-#define S14 22
-#define S21 5
-#define S22 9
-#define S23 14
-#define S24 20
-#define S31 4
-#define S32 11
-#define S33 16
-#define S34 23
-#define S41 6
-#define S42 10
-#define S43 15
-#define S44 21
-
-
-/* F, G, H and I are basic MD5 functions. */
-#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
-#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
-#define H(x, y, z) ((x) ^ (y) ^ (z))
-#define I(x, y, z) ((y) ^ ((x) | (~z)))
-
-
-/* ROTATE_LEFT rotates x left n bits. */
-#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
-
-
-/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
- Rotation is separate from addition to prevent recomputation. */
-#define FF(a, b, c, d, x, s, ac) { \
- (a) += F ((b), (c), (d)) + (x) + (UInt32)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define GG(a, b, c, d, x, s, ac) { \
- (a) += G ((b), (c), (d)) + (x) + (UInt32)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define HH(a, b, c, d, x, s, ac) { \
- (a) += H ((b), (c), (d)) + (x) + (UInt32)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define II(a, b, c, d, x, s, ac) { \
- (a) += I ((b), (c), (d)) + (x) + (UInt32)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-
-
-void MD5Engine::transform (UInt32 state[4], const unsigned char block[64])
-{
- UInt32 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
-
- decode(x, block, 64);
-
- /* Round 1 */
- FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
- FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
- FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
- FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
- FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
- FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
- FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
- FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
- FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
- FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
- FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
- FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
- FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
- FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
- FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
- FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
-
- /* Round 2 */
- GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
- GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
- GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
- GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
- GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
- GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
- GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
- GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
- GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
- GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
- GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
- GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
- GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
- GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
- GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
- GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
-
- /* Round 3 */
- HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
- HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
- HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
- HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
- HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
- HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
- HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
- HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
- HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
- HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
- HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
- HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
- HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
- HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
- HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
- HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
-
- /* Round 4 */
- II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
- II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
- II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
- II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
- II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
- II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
- II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
- II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
- II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
- II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
- II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
- II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
- II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
- II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
- II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
- II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
-
- state[0] += a;
- state[1] += b;
- state[2] += c;
- state[3] += d;
-
- /* Zeroize sensitive information. */
- std::memset(x, 0, sizeof(x));
-}
-
-
-void MD5Engine::encode(unsigned char* output, const UInt32* input, std::size_t len)
-{
- unsigned int i, j;
-
+// MD5Engine.cpp
+//
+// Library: Foundation
+// Package: Crypt
+// Module: MD5Engine
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+//
+// 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
+// or this function.
+//
+// License is also granted to make and use derivative works provided
+// that such works are identified as "derived from the RSA Data
+// Security, Inc. MD5 Message-Digest Algorithm" in all material
+// mentioning or referencing the derived work.
+//
+// RSA Data Security, Inc. makes no representations concerning either
+// the merchantability of this software or the suitability of this
+// software for any particular purpose. It is provided "as is"
+// without express or implied warranty of any kind.
+//
+// These notices must be retained in any copies of any part of this
+// documentation and/or software.
+//
+
+
+#include "Poco/MD5Engine.h"
+#include <cstring>
+
+
+namespace Poco {
+
+
+MD5Engine::MD5Engine()
+{
+ _digest.reserve(16);
+ reset();
+}
+
+
+MD5Engine::~MD5Engine()
+{
+ reset();
+}
+
+
+void MD5Engine::updateImpl(const void* input_, std::size_t inputLen)
+{
+ const unsigned char* input = (const unsigned char*) input_;
+ unsigned int i, index, partLen;
+
+ /* Compute number of bytes mod 64 */
+ index = (unsigned int)((_context.count[0] >> 3) & 0x3F);
+
+ /* Update number of bits */
+ if ((_context.count[0] += ((UInt32) inputLen << 3)) < ((UInt32) inputLen << 3))
+ _context.count[1]++;
+ _context.count[1] += ((UInt32) inputLen >> 29);
+
+ partLen = 64 - index;
+
+ /* Transform as many times as possible. */
+ if (inputLen >= partLen)
+ {
+ std::memcpy(&_context.buffer[index], input, partLen);
+ transform(_context.state, _context.buffer);
+
+ for (i = partLen; i + 63 < inputLen; i += 64)
+ transform(_context.state, &input[i]);
+
+ index = 0;
+ }
+ else i = 0;
+
+ /* Buffer remaining input */
+ std::memcpy(&_context.buffer[index], &input[i],inputLen-i);
+}
+
+
+std::size_t MD5Engine::digestLength() const
+{
+ return DIGEST_SIZE;
+}
+
+
+void MD5Engine::reset()
+{
+ std::memset(&_context, 0, sizeof(_context));
+ _context.count[0] = _context.count[1] = 0;
+ _context.state[0] = 0x67452301;
+ _context.state[1] = 0xefcdab89;
+ _context.state[2] = 0x98badcfe;
+ _context.state[3] = 0x10325476;
+}
+
+
+const DigestEngine::Digest& MD5Engine::digest()
+{
+ 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,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
+ unsigned char bits[8];
+ unsigned int index, padLen;
+
+ /* Save number of bits */
+ encode(bits, _context.count, 8);
+
+ /* Pad out to 56 mod 64. */
+ index = (unsigned int)((_context.count[0] >> 3) & 0x3f);
+ padLen = (index < 56) ? (56 - index) : (120 - index);
+ update(PADDING, padLen);
+
+ /* Append length (before padding) */
+ update(bits, 8);
+
+ /* Store state in digestArray */
+ unsigned char digestArray[16];
+ encode(digestArray, _context.state, 16);
+ _digest.clear();
+ _digest.insert(_digest.begin(), digestArray, digestArray + sizeof(digestArray));
+
+ /* Zeroize sensitive information. */
+ std::memset(&_context, 0, sizeof (_context));
+ reset();
+ return _digest;
+}
+
+
+/* Constants for MD5Transform routine. */
+#define S11 7
+#define S12 12
+#define S13 17
+#define S14 22
+#define S21 5
+#define S22 9
+#define S23 14
+#define S24 20
+#define S31 4
+#define S32 11
+#define S33 16
+#define S34 23
+#define S41 6
+#define S42 10
+#define S43 15
+#define S44 21
+
+
+/* F, G, H and I are basic MD5 functions. */
+#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
+#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+#define I(x, y, z) ((y) ^ ((x) | (~z)))
+
+
+/* ROTATE_LEFT rotates x left n bits. */
+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+
+
+/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
+ Rotation is separate from addition to prevent recomputation. */
+#define FF(a, b, c, d, x, s, ac) { \
+ (a) += F ((b), (c), (d)) + (x) + (UInt32)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define GG(a, b, c, d, x, s, ac) { \
+ (a) += G ((b), (c), (d)) + (x) + (UInt32)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define HH(a, b, c, d, x, s, ac) { \
+ (a) += H ((b), (c), (d)) + (x) + (UInt32)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define II(a, b, c, d, x, s, ac) { \
+ (a) += I ((b), (c), (d)) + (x) + (UInt32)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+
+
+void MD5Engine::transform (UInt32 state[4], const unsigned char block[64])
+{
+ UInt32 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
+
+ decode(x, block, 64);
+
+ /* Round 1 */
+ FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
+ FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
+ FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
+ FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
+ FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
+ FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
+ FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
+ FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
+ FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
+ FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
+ FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
+ FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
+ FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
+ FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
+ FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
+ FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
+
+ /* Round 2 */
+ GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
+ GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
+ GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
+ GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
+ GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
+ GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
+ GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
+ GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
+ GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
+ GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
+ GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
+ GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
+ GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
+ GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
+ GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
+ GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
+
+ /* Round 3 */
+ HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
+ HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
+ HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
+ HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
+ HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
+ HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
+ HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
+ HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
+ HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
+ HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
+ HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
+ HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
+ HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
+ HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
+ HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
+ HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
+
+ /* Round 4 */
+ II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
+ II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
+ II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
+ II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
+ II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
+ II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
+ II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
+ II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
+ II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
+ II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
+ II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
+ II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
+ II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
+ II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
+ II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
+ II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
+
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+
+ /* Zeroize sensitive information. */
+ std::memset(x, 0, sizeof(x));
+}
+
+
+void MD5Engine::encode(unsigned char* output, const UInt32* input, std::size_t len)
+{
+ unsigned int i, j;
+
+ 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);
+ output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
+ output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
+ }
+}
+
+
+void MD5Engine::decode(UInt32* output, const unsigned char* input, std::size_t len)
+{
+ unsigned int i, j;
+
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);
- output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
- output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
- }
-}
-
-
-void MD5Engine::decode(UInt32* output, const unsigned char* input, std::size_t len)
-{
- unsigned int i, j;
-
- for (i = 0, j = 0; j < len; i++, j += 4)
- output[i] = ((UInt32)input[j]) | (((UInt32)input[j+1]) << 8) |
- (((UInt32)input[j+2]) << 16) | (((UInt32)input[j+3]) << 24);
-}
-
-
-} // namespace Poco
+ output[i] = ((UInt32)input[j]) | (((UInt32)input[j+1]) << 8) |
+ (((UInt32)input[j+2]) << 16) | (((UInt32)input[j+3]) << 24);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Manifest.cpp b/contrib/libs/poco/Foundation/src/Manifest.cpp
index c4e828c5e9..67dfef57a8 100644
--- a/contrib/libs/poco/Foundation/src/Manifest.cpp
+++ b/contrib/libs/poco/Foundation/src/Manifest.cpp
@@ -1,31 +1,31 @@
-//
-// Manifest.cpp
-//
-// Library: Foundation
-// Package: SharedLibrary
-// Module: ClassLoader
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Manifest.h"
-
-
-namespace Poco {
-
-
-ManifestBase::ManifestBase()
-{
-}
-
-
-ManifestBase::~ManifestBase()
-{
-}
-
-
-} // namespace Poco
+//
+// Manifest.cpp
+//
+// Library: Foundation
+// Package: SharedLibrary
+// Module: ClassLoader
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Manifest.h"
+
+
+namespace Poco {
+
+
+ManifestBase::ManifestBase()
+{
+}
+
+
+ManifestBase::~ManifestBase()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/MemoryPool.cpp b/contrib/libs/poco/Foundation/src/MemoryPool.cpp
index ecd155a409..e885c6a718 100644
--- a/contrib/libs/poco/Foundation/src/MemoryPool.cpp
+++ b/contrib/libs/poco/Foundation/src/MemoryPool.cpp
@@ -1,105 +1,105 @@
-//
-// MemoryPool.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: MemoryPool
-//
-// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/MemoryPool.h"
-#include "Poco/Exception.h"
-
-
-namespace Poco {
-
-
-MemoryPool::MemoryPool(std::size_t blockLength, int preAlloc, int maxAlloc):
- _blockSize(blockLength),
- _maxAlloc(maxAlloc),
- _allocated(preAlloc)
-{
- poco_assert (maxAlloc == 0 || maxAlloc >= preAlloc);
- poco_assert (preAlloc >= 0 && maxAlloc >= 0);
-
- int r = BLOCK_RESERVE;
- if (preAlloc > r)
- r = preAlloc;
- if (maxAlloc > 0 && maxAlloc < r)
- r = maxAlloc;
- _blocks.reserve(r);
-
- try
- {
- for (int i = 0; i < preAlloc; ++i)
- {
- _blocks.push_back(new char[_blockSize]);
- }
- }
- catch (...)
- {
- clear();
- throw;
- }
-}
-
-
-MemoryPool::~MemoryPool()
-{
- clear();
-}
-
-
-void MemoryPool::clear()
-{
- for (BlockVec::iterator it = _blocks.begin(); it != _blocks.end(); ++it)
- {
- delete [] *it;
- }
- _blocks.clear();
-}
-
-
-void* MemoryPool::get()
-{
- FastMutex::ScopedLock lock(_mutex);
-
- if (_blocks.empty())
- {
- if (_maxAlloc == 0 || _allocated < _maxAlloc)
- {
- ++_allocated;
- return new char[_blockSize];
- }
- else throw OutOfMemoryException("MemoryPool exhausted");
- }
- else
- {
- char* ptr = _blocks.back();
- _blocks.pop_back();
- return ptr;
- }
-}
-
-
-void MemoryPool::release(void* ptr)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- try
- {
- _blocks.push_back(reinterpret_cast<char*>(ptr));
- }
- catch (...)
- {
- delete [] reinterpret_cast<char*>(ptr);
- }
-}
-
-
-} // namespace Poco
+//
+// MemoryPool.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: MemoryPool
+//
+// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/MemoryPool.h"
+#include "Poco/Exception.h"
+
+
+namespace Poco {
+
+
+MemoryPool::MemoryPool(std::size_t blockLength, int preAlloc, int maxAlloc):
+ _blockSize(blockLength),
+ _maxAlloc(maxAlloc),
+ _allocated(preAlloc)
+{
+ poco_assert (maxAlloc == 0 || maxAlloc >= preAlloc);
+ poco_assert (preAlloc >= 0 && maxAlloc >= 0);
+
+ int r = BLOCK_RESERVE;
+ if (preAlloc > r)
+ r = preAlloc;
+ if (maxAlloc > 0 && maxAlloc < r)
+ r = maxAlloc;
+ _blocks.reserve(r);
+
+ try
+ {
+ for (int i = 0; i < preAlloc; ++i)
+ {
+ _blocks.push_back(new char[_blockSize]);
+ }
+ }
+ catch (...)
+ {
+ clear();
+ throw;
+ }
+}
+
+
+MemoryPool::~MemoryPool()
+{
+ clear();
+}
+
+
+void MemoryPool::clear()
+{
+ for (BlockVec::iterator it = _blocks.begin(); it != _blocks.end(); ++it)
+ {
+ delete [] *it;
+ }
+ _blocks.clear();
+}
+
+
+void* MemoryPool::get()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (_blocks.empty())
+ {
+ if (_maxAlloc == 0 || _allocated < _maxAlloc)
+ {
+ ++_allocated;
+ return new char[_blockSize];
+ }
+ else throw OutOfMemoryException("MemoryPool exhausted");
+ }
+ else
+ {
+ char* ptr = _blocks.back();
+ _blocks.pop_back();
+ return ptr;
+ }
+}
+
+
+void MemoryPool::release(void* ptr)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ try
+ {
+ _blocks.push_back(reinterpret_cast<char*>(ptr));
+ }
+ catch (...)
+ {
+ delete [] reinterpret_cast<char*>(ptr);
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/MemoryStream.cpp b/contrib/libs/poco/Foundation/src/MemoryStream.cpp
index cf3f4c3256..8acc0b198f 100644
--- a/contrib/libs/poco/Foundation/src/MemoryStream.cpp
+++ b/contrib/libs/poco/Foundation/src/MemoryStream.cpp
@@ -1,57 +1,57 @@
-//
-// MemoryStream.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: MemoryStream
-//
-// Copyright (c) 2009, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/MemoryStream.h"
-
-
-namespace Poco {
-
-
-MemoryIOS::MemoryIOS(char* pBuffer, std::streamsize bufferSize):
- _buf(pBuffer, bufferSize)
-{
- poco_ios_init(&_buf);
-}
-
-
-MemoryIOS::~MemoryIOS()
-{
-}
-
-
-MemoryInputStream::MemoryInputStream(const char* pBuffer, std::streamsize bufferSize):
- MemoryIOS(const_cast<char*>(pBuffer), bufferSize),
- std::istream(&_buf)
-{
-}
-
-
-MemoryInputStream::~MemoryInputStream()
-{
-}
-
-
-MemoryOutputStream::MemoryOutputStream(char* pBuffer, std::streamsize bufferSize):
- MemoryIOS(pBuffer, bufferSize),
- std::ostream(&_buf)
-{
-}
-
-
-MemoryOutputStream::~MemoryOutputStream()
-{
-}
-
-
-} // namespace Poco
+//
+// MemoryStream.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: MemoryStream
+//
+// Copyright (c) 2009, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/MemoryStream.h"
+
+
+namespace Poco {
+
+
+MemoryIOS::MemoryIOS(char* pBuffer, std::streamsize bufferSize):
+ _buf(pBuffer, bufferSize)
+{
+ poco_ios_init(&_buf);
+}
+
+
+MemoryIOS::~MemoryIOS()
+{
+}
+
+
+MemoryInputStream::MemoryInputStream(const char* pBuffer, std::streamsize bufferSize):
+ MemoryIOS(const_cast<char*>(pBuffer), bufferSize),
+ std::istream(&_buf)
+{
+}
+
+
+MemoryInputStream::~MemoryInputStream()
+{
+}
+
+
+MemoryOutputStream::MemoryOutputStream(char* pBuffer, std::streamsize bufferSize):
+ MemoryIOS(pBuffer, bufferSize),
+ std::ostream(&_buf)
+{
+}
+
+
+MemoryOutputStream::~MemoryOutputStream()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Message.cpp b/contrib/libs/poco/Foundation/src/Message.cpp
index a93943571e..5c35969c40 100644
--- a/contrib/libs/poco/Foundation/src/Message.cpp
+++ b/contrib/libs/poco/Foundation/src/Message.cpp
@@ -1,267 +1,267 @@
-//
-// Message.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: Message
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Message.h"
-#include "Poco/Exception.h"
-#if !defined(POCO_VXWORKS)
-#include "Poco/Process.h"
-#endif
-#include "Poco/Thread.h"
-#include <algorithm>
-
-
-namespace Poco {
-
-
-Message::Message():
- _prio(PRIO_FATAL),
+//
+// Message.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: Message
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Message.h"
+#include "Poco/Exception.h"
+#if !defined(POCO_VXWORKS)
+#include "Poco/Process.h"
+#endif
+#include "Poco/Thread.h"
+#include <algorithm>
+
+
+namespace Poco {
+
+
+Message::Message():
+ _prio(PRIO_FATAL),
+ _tid(0),
+ _pid(0),
+ _file(0),
+ _line(0),
+ _pMap(0)
+{
+ init();
+}
+
+
+Message::Message(const std::string& source, const std::string& text, Priority prio):
+ _source(source),
+ _text(text),
+ _prio(prio),
_tid(0),
- _pid(0),
- _file(0),
- _line(0),
- _pMap(0)
-{
- init();
-}
-
-
-Message::Message(const std::string& source, const std::string& text, Priority prio):
- _source(source),
- _text(text),
- _prio(prio),
- _tid(0),
- _pid(0),
- _file(0),
- _line(0),
- _pMap(0)
-{
- init();
-}
-
-
-Message::Message(const std::string& source, const std::string& text, Priority prio, const char* file, int line):
- _source(source),
+ _pid(0),
+ _file(0),
+ _line(0),
+ _pMap(0)
+{
+ init();
+}
+
+
+Message::Message(const std::string& source, const std::string& text, Priority prio, const char* file, int line):
+ _source(source),
+ _text(text),
+ _prio(prio),
+ _tid(0),
+ _pid(0),
+ _file(file),
+ _line(line),
+ _pMap(0)
+{
+ init();
+}
+
+
+Message::Message(const Message& msg):
+ _source(msg._source),
+ _text(msg._text),
+ _prio(msg._prio),
+ _time(msg._time),
+ _tid(msg._tid),
+ _thread(msg._thread),
+ _pid(msg._pid),
+ _file(msg._file),
+ _line(msg._line)
+{
+ if (msg._pMap)
+ _pMap = new StringMap(*msg._pMap);
+ else
+ _pMap = 0;
+}
+
+
+Message::Message(const Message& msg, const std::string& text):
+ _source(msg._source),
_text(text),
- _prio(prio),
- _tid(0),
- _pid(0),
- _file(file),
- _line(line),
- _pMap(0)
-{
- init();
-}
-
-
-Message::Message(const Message& msg):
- _source(msg._source),
- _text(msg._text),
- _prio(msg._prio),
- _time(msg._time),
- _tid(msg._tid),
- _thread(msg._thread),
- _pid(msg._pid),
- _file(msg._file),
- _line(msg._line)
-{
- if (msg._pMap)
- _pMap = new StringMap(*msg._pMap);
- else
- _pMap = 0;
-}
-
-
-Message::Message(const Message& msg, const std::string& text):
- _source(msg._source),
- _text(text),
- _prio(msg._prio),
- _time(msg._time),
- _tid(msg._tid),
- _thread(msg._thread),
- _pid(msg._pid),
- _file(msg._file),
- _line(msg._line)
-{
- if (msg._pMap)
- _pMap = new StringMap(*msg._pMap);
- else
- _pMap = 0;
-}
-
-
-Message::~Message()
-{
- delete _pMap;
-}
-
-
-void Message::init()
-{
-#if !defined(POCO_VXWORKS)
- _pid = Process::id();
-#endif
- Thread* pThread = Thread::current();
- if (pThread)
- {
- _tid = pThread->id();
- _thread = pThread->name();
- }
-}
-
-
-Message& Message::operator = (const Message& msg)
-{
- if (&msg != this)
- {
- Message tmp(msg);
- swap(tmp);
- }
- return *this;
-}
-
-
-void Message::swap(Message& msg)
-{
- using std::swap;
- swap(_source, msg._source);
- swap(_text, msg._text);
- swap(_prio, msg._prio);
- swap(_time, msg._time);
- swap(_tid, msg._tid);
- swap(_thread, msg._thread);
- swap(_pid, msg._pid);
- swap(_file, msg._file);
- swap(_line, msg._line);
- swap(_pMap, msg._pMap);
-}
-
-
-void Message::setSource(const std::string& src)
-{
- _source = src;
-}
-
-
-void Message::setText(const std::string& text)
-{
- _text = text;
-}
-
-
-void Message::setPriority(Priority prio)
-{
- _prio = prio;
-}
-
-
-void Message::setTime(const Timestamp& t)
-{
- _time = t;
-}
-
-
-void Message::setThread(const std::string& thread)
-{
- _thread = thread;
-}
-
-
-void Message::setTid(long tid)
-{
- _tid = tid;
-}
-
-
-void Message::setPid(long pid)
-{
- _pid = pid;
-}
-
-
-void Message::setSourceFile(const char* file)
-{
- _file = file;
-}
-
-
-void Message::setSourceLine(int line)
-{
- _line = line;
-}
-
-
-bool Message::has(const std::string& param) const
-{
- return _pMap && (_pMap->find(param) != _pMap->end());
-}
-
-
-const std::string& Message::get(const std::string& param) const
-{
- if (_pMap)
- {
- StringMap::const_iterator it = _pMap->find(param);
- if (it != _pMap->end())
- return it->second;
- }
-
- throw NotFoundException();
-}
-
-
-const std::string& Message::get(const std::string& param, const std::string& defaultValue) const
-{
- if (_pMap)
- {
- StringMap::const_iterator it = _pMap->find(param);
- if (it != _pMap->end())
- return it->second;
- }
-
- return defaultValue;
-}
-
-
-void Message::set(const std::string& param, const std::string& value)
-{
- if (!_pMap)
- _pMap = new StringMap;
-
- std::pair<StringMap::iterator, bool> result =
- _pMap->insert(std::make_pair(param, value));
- if (!result.second)
- {
- result.first->second = value;
- }
-}
-
-
-const std::string& Message::operator [] (const std::string& param) const
-{
- if (_pMap)
- return (*_pMap)[param];
- else
- throw NotFoundException();
-}
-
-
-std::string& Message::operator [] (const std::string& param)
-{
- if (!_pMap)
- _pMap = new StringMap;
- return (*_pMap)[param];
-}
-
-
-} // namespace Poco
+ _prio(msg._prio),
+ _time(msg._time),
+ _tid(msg._tid),
+ _thread(msg._thread),
+ _pid(msg._pid),
+ _file(msg._file),
+ _line(msg._line)
+{
+ if (msg._pMap)
+ _pMap = new StringMap(*msg._pMap);
+ else
+ _pMap = 0;
+}
+
+
+Message::~Message()
+{
+ delete _pMap;
+}
+
+
+void Message::init()
+{
+#if !defined(POCO_VXWORKS)
+ _pid = Process::id();
+#endif
+ Thread* pThread = Thread::current();
+ if (pThread)
+ {
+ _tid = pThread->id();
+ _thread = pThread->name();
+ }
+}
+
+
+Message& Message::operator = (const Message& msg)
+{
+ if (&msg != this)
+ {
+ Message tmp(msg);
+ swap(tmp);
+ }
+ return *this;
+}
+
+
+void Message::swap(Message& msg)
+{
+ using std::swap;
+ swap(_source, msg._source);
+ swap(_text, msg._text);
+ swap(_prio, msg._prio);
+ swap(_time, msg._time);
+ swap(_tid, msg._tid);
+ swap(_thread, msg._thread);
+ swap(_pid, msg._pid);
+ swap(_file, msg._file);
+ swap(_line, msg._line);
+ swap(_pMap, msg._pMap);
+}
+
+
+void Message::setSource(const std::string& src)
+{
+ _source = src;
+}
+
+
+void Message::setText(const std::string& text)
+{
+ _text = text;
+}
+
+
+void Message::setPriority(Priority prio)
+{
+ _prio = prio;
+}
+
+
+void Message::setTime(const Timestamp& t)
+{
+ _time = t;
+}
+
+
+void Message::setThread(const std::string& thread)
+{
+ _thread = thread;
+}
+
+
+void Message::setTid(long tid)
+{
+ _tid = tid;
+}
+
+
+void Message::setPid(long pid)
+{
+ _pid = pid;
+}
+
+
+void Message::setSourceFile(const char* file)
+{
+ _file = file;
+}
+
+
+void Message::setSourceLine(int line)
+{
+ _line = line;
+}
+
+
+bool Message::has(const std::string& param) const
+{
+ return _pMap && (_pMap->find(param) != _pMap->end());
+}
+
+
+const std::string& Message::get(const std::string& param) const
+{
+ if (_pMap)
+ {
+ StringMap::const_iterator it = _pMap->find(param);
+ if (it != _pMap->end())
+ return it->second;
+ }
+
+ throw NotFoundException();
+}
+
+
+const std::string& Message::get(const std::string& param, const std::string& defaultValue) const
+{
+ if (_pMap)
+ {
+ StringMap::const_iterator it = _pMap->find(param);
+ if (it != _pMap->end())
+ return it->second;
+ }
+
+ return defaultValue;
+}
+
+
+void Message::set(const std::string& param, const std::string& value)
+{
+ if (!_pMap)
+ _pMap = new StringMap;
+
+ std::pair<StringMap::iterator, bool> result =
+ _pMap->insert(std::make_pair(param, value));
+ if (!result.second)
+ {
+ result.first->second = value;
+ }
+}
+
+
+const std::string& Message::operator [] (const std::string& param) const
+{
+ if (_pMap)
+ return (*_pMap)[param];
+ else
+ throw NotFoundException();
+}
+
+
+std::string& Message::operator [] (const std::string& param)
+{
+ if (!_pMap)
+ _pMap = new StringMap;
+ return (*_pMap)[param];
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Mutex.cpp b/contrib/libs/poco/Foundation/src/Mutex.cpp
index cb10115088..4a4c5f807e 100644
--- a/contrib/libs/poco/Foundation/src/Mutex.cpp
+++ b/contrib/libs/poco/Foundation/src/Mutex.cpp
@@ -1,54 +1,54 @@
-//
-// Mutex.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: Mutex
-//
-// Copyright (c) 2004-2008, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Mutex.h"
-
-
-#if defined(POCO_OS_FAMILY_WINDOWS)
-#if defined(_WIN32_WCE)
-#include "Mutex_WINCE.cpp"
-#else
-#include "Mutex_WIN32.cpp"
-#endif
-#elif defined(POCO_VXWORKS)
-#include "Mutex_VX.cpp"
-#else
-#include "Mutex_POSIX.cpp"
-#endif
-
-
-namespace Poco {
-
-
-Mutex::Mutex()
-{
-}
-
-
-Mutex::~Mutex()
-{
-}
-
-
-FastMutex::FastMutex()
-{
-}
-
-
-FastMutex::~FastMutex()
-{
-}
-
-
-} // namespace Poco
+//
+// Mutex.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: Mutex
+//
+// Copyright (c) 2004-2008, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Mutex.h"
+
+
+#if defined(POCO_OS_FAMILY_WINDOWS)
+#if defined(_WIN32_WCE)
+#include "Mutex_WINCE.cpp"
+#else
+#include "Mutex_WIN32.cpp"
+#endif
+#elif defined(POCO_VXWORKS)
+#include "Mutex_VX.cpp"
+#else
+#include "Mutex_POSIX.cpp"
+#endif
+
+
+namespace Poco {
+
+
+Mutex::Mutex()
+{
+}
+
+
+Mutex::~Mutex()
+{
+}
+
+
+FastMutex::FastMutex()
+{
+}
+
+
+FastMutex::~FastMutex()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Mutex_POSIX.cpp b/contrib/libs/poco/Foundation/src/Mutex_POSIX.cpp
index 56132ef5d5..f0bb875167 100644
--- a/contrib/libs/poco/Foundation/src/Mutex_POSIX.cpp
+++ b/contrib/libs/poco/Foundation/src/Mutex_POSIX.cpp
@@ -1,175 +1,175 @@
-//
-// Mutex_POSIX.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: Mutex
-//
-// Copyright (c) 2004-2008, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Mutex_POSIX.h"
-#include "Poco/Timestamp.h"
-#if !defined(POCO_NO_SYS_SELECT_H)
-#include <sys/select.h>
-#endif
-#include <unistd.h>
-#if defined(POCO_VXWORKS)
-#include <timers.h>
-#include <cstring>
-#else
-#include <sys/time.h>
-#endif
-
-
-#if defined(_POSIX_TIMEOUTS) && (_POSIX_TIMEOUTS - 200112L) >= 0L
- #if defined(_POSIX_THREADS) && (_POSIX_THREADS - 200112L) >= 0L
- #define POCO_HAVE_MUTEX_TIMEOUT
- #endif
-#endif
-
-
-#ifndef POCO_HAVE_CLOCK_GETTIME
- #if (defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME)) || defined(POCO_VXWORKS) || defined(__QNX__)
- #ifndef __APPLE__ // See GitHub issue #1453 - not available before Mac OS 10.12/iOS 10
- #define POCO_HAVE_CLOCK_GETTIME
- #endif
- #endif
-#endif
-
-
-namespace Poco {
-
-
-MutexImpl::MutexImpl()
-{
-#if defined(POCO_VXWORKS)
- // This workaround is for VxWorks 5.x where
- // pthread_mutex_init() won't properly initialize the mutex
- // resulting in a subsequent freeze in pthread_mutex_destroy()
- // if the mutex has never been used.
- std::memset(&_mutex, 0, sizeof(_mutex));
-#endif
- pthread_mutexattr_t attr;
- pthread_mutexattr_init(&attr);
-#if defined(PTHREAD_MUTEX_RECURSIVE_NP)
- pthread_mutexattr_settype_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
-#elif !defined(POCO_VXWORKS)
- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
-#endif
- if (pthread_mutex_init(&_mutex, &attr))
- {
- pthread_mutexattr_destroy(&attr);
- throw SystemException("cannot create mutex");
- }
- pthread_mutexattr_destroy(&attr);
-}
-
-
-MutexImpl::MutexImpl(bool fast)
-{
-#if defined(POCO_VXWORKS)
- // This workaround is for VxWorks 5.x where
- // pthread_mutex_init() won't properly initialize the mutex
- // resulting in a subsequent freeze in pthread_mutex_destroy()
- // if the mutex has never been used.
- std::memset(&_mutex, 0, sizeof(_mutex));
-#endif
- pthread_mutexattr_t attr;
- pthread_mutexattr_init(&attr);
-#if defined(PTHREAD_MUTEX_RECURSIVE_NP)
- pthread_mutexattr_settype_np(&attr, fast ? PTHREAD_MUTEX_NORMAL_NP : PTHREAD_MUTEX_RECURSIVE_NP);
-#elif !defined(POCO_VXWORKS)
- pthread_mutexattr_settype(&attr, fast ? PTHREAD_MUTEX_NORMAL : PTHREAD_MUTEX_RECURSIVE);
-#endif
- if (pthread_mutex_init(&_mutex, &attr))
- {
- pthread_mutexattr_destroy(&attr);
- throw SystemException("cannot create mutex");
- }
- pthread_mutexattr_destroy(&attr);
-}
-
-
-MutexImpl::~MutexImpl()
-{
- pthread_mutex_destroy(&_mutex);
-}
-
-
-bool MutexImpl::tryLockImpl(long milliseconds)
-{
-#if defined(POCO_HAVE_MUTEX_TIMEOUT)
- struct timespec abstime;
-#if defined(POCO_HAVE_CLOCK_GETTIME)
- clock_gettime(CLOCK_REALTIME, &abstime);
- abstime.tv_sec += milliseconds / 1000;
- abstime.tv_nsec += (milliseconds % 1000)*1000000;
- if (abstime.tv_nsec >= 1000000000)
- {
- abstime.tv_nsec -= 1000000000;
- abstime.tv_sec++;
- }
-#else
- struct timeval tv;
- gettimeofday(&tv, NULL);
- abstime.tv_sec = tv.tv_sec + milliseconds / 1000;
- abstime.tv_nsec = tv.tv_usec*1000 + (milliseconds % 1000)*1000000;
- if (abstime.tv_nsec >= 1000000000)
- {
- abstime.tv_nsec -= 1000000000;
- abstime.tv_sec++;
- }
-#endif
- int rc = pthread_mutex_timedlock(&_mutex, &abstime);
- if (rc == 0)
- return true;
- else if (rc == ETIMEDOUT)
- return false;
- else
- throw SystemException("cannot lock mutex");
-#else
- const int sleepMillis = 5;
- Timestamp now;
- Timestamp::TimeDiff diff(Timestamp::TimeDiff(milliseconds)*1000);
- do
- {
- int rc = pthread_mutex_trylock(&_mutex);
- if (rc == 0)
- return true;
- else if (rc != EBUSY)
- throw SystemException("cannot lock mutex");
-#if defined(POCO_VXWORKS)
- struct timespec ts;
- ts.tv_sec = 0;
- ts.tv_nsec = sleepMillis*1000000;
- nanosleep(&ts, NULL);
-
-#else
- struct timeval tv;
- tv.tv_sec = 0;
- tv.tv_usec = sleepMillis * 1000;
- select(0, NULL, NULL, NULL, &tv);
-#endif
- }
- while (!now.isElapsed(diff));
- return false;
-#endif
-}
-
-
-FastMutexImpl::FastMutexImpl(): MutexImpl(true)
-{
-}
-
-
-FastMutexImpl::~FastMutexImpl()
-{
-}
-
-
-} // namespace Poco
+//
+// Mutex_POSIX.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: Mutex
+//
+// Copyright (c) 2004-2008, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Mutex_POSIX.h"
+#include "Poco/Timestamp.h"
+#if !defined(POCO_NO_SYS_SELECT_H)
+#include <sys/select.h>
+#endif
+#include <unistd.h>
+#if defined(POCO_VXWORKS)
+#include <timers.h>
+#include <cstring>
+#else
+#include <sys/time.h>
+#endif
+
+
+#if defined(_POSIX_TIMEOUTS) && (_POSIX_TIMEOUTS - 200112L) >= 0L
+ #if defined(_POSIX_THREADS) && (_POSIX_THREADS - 200112L) >= 0L
+ #define POCO_HAVE_MUTEX_TIMEOUT
+ #endif
+#endif
+
+
+#ifndef POCO_HAVE_CLOCK_GETTIME
+ #if (defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME)) || defined(POCO_VXWORKS) || defined(__QNX__)
+ #ifndef __APPLE__ // See GitHub issue #1453 - not available before Mac OS 10.12/iOS 10
+ #define POCO_HAVE_CLOCK_GETTIME
+ #endif
+ #endif
+#endif
+
+
+namespace Poco {
+
+
+MutexImpl::MutexImpl()
+{
+#if defined(POCO_VXWORKS)
+ // This workaround is for VxWorks 5.x where
+ // pthread_mutex_init() won't properly initialize the mutex
+ // resulting in a subsequent freeze in pthread_mutex_destroy()
+ // if the mutex has never been used.
+ std::memset(&_mutex, 0, sizeof(_mutex));
+#endif
+ pthread_mutexattr_t attr;
+ pthread_mutexattr_init(&attr);
+#if defined(PTHREAD_MUTEX_RECURSIVE_NP)
+ pthread_mutexattr_settype_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
+#elif !defined(POCO_VXWORKS)
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+#endif
+ if (pthread_mutex_init(&_mutex, &attr))
+ {
+ pthread_mutexattr_destroy(&attr);
+ throw SystemException("cannot create mutex");
+ }
+ pthread_mutexattr_destroy(&attr);
+}
+
+
+MutexImpl::MutexImpl(bool fast)
+{
+#if defined(POCO_VXWORKS)
+ // This workaround is for VxWorks 5.x where
+ // pthread_mutex_init() won't properly initialize the mutex
+ // resulting in a subsequent freeze in pthread_mutex_destroy()
+ // if the mutex has never been used.
+ std::memset(&_mutex, 0, sizeof(_mutex));
+#endif
+ pthread_mutexattr_t attr;
+ pthread_mutexattr_init(&attr);
+#if defined(PTHREAD_MUTEX_RECURSIVE_NP)
+ pthread_mutexattr_settype_np(&attr, fast ? PTHREAD_MUTEX_NORMAL_NP : PTHREAD_MUTEX_RECURSIVE_NP);
+#elif !defined(POCO_VXWORKS)
+ pthread_mutexattr_settype(&attr, fast ? PTHREAD_MUTEX_NORMAL : PTHREAD_MUTEX_RECURSIVE);
+#endif
+ if (pthread_mutex_init(&_mutex, &attr))
+ {
+ pthread_mutexattr_destroy(&attr);
+ throw SystemException("cannot create mutex");
+ }
+ pthread_mutexattr_destroy(&attr);
+}
+
+
+MutexImpl::~MutexImpl()
+{
+ pthread_mutex_destroy(&_mutex);
+}
+
+
+bool MutexImpl::tryLockImpl(long milliseconds)
+{
+#if defined(POCO_HAVE_MUTEX_TIMEOUT)
+ struct timespec abstime;
+#if defined(POCO_HAVE_CLOCK_GETTIME)
+ clock_gettime(CLOCK_REALTIME, &abstime);
+ abstime.tv_sec += milliseconds / 1000;
+ abstime.tv_nsec += (milliseconds % 1000)*1000000;
+ if (abstime.tv_nsec >= 1000000000)
+ {
+ abstime.tv_nsec -= 1000000000;
+ abstime.tv_sec++;
+ }
+#else
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ abstime.tv_sec = tv.tv_sec + milliseconds / 1000;
+ abstime.tv_nsec = tv.tv_usec*1000 + (milliseconds % 1000)*1000000;
+ if (abstime.tv_nsec >= 1000000000)
+ {
+ abstime.tv_nsec -= 1000000000;
+ abstime.tv_sec++;
+ }
+#endif
+ int rc = pthread_mutex_timedlock(&_mutex, &abstime);
+ if (rc == 0)
+ return true;
+ else if (rc == ETIMEDOUT)
+ return false;
+ else
+ throw SystemException("cannot lock mutex");
+#else
+ const int sleepMillis = 5;
+ Timestamp now;
+ Timestamp::TimeDiff diff(Timestamp::TimeDiff(milliseconds)*1000);
+ do
+ {
+ int rc = pthread_mutex_trylock(&_mutex);
+ if (rc == 0)
+ return true;
+ else if (rc != EBUSY)
+ throw SystemException("cannot lock mutex");
+#if defined(POCO_VXWORKS)
+ struct timespec ts;
+ ts.tv_sec = 0;
+ ts.tv_nsec = sleepMillis*1000000;
+ nanosleep(&ts, NULL);
+
+#else
+ struct timeval tv;
+ tv.tv_sec = 0;
+ tv.tv_usec = sleepMillis * 1000;
+ select(0, NULL, NULL, NULL, &tv);
+#endif
+ }
+ while (!now.isElapsed(diff));
+ return false;
+#endif
+}
+
+
+FastMutexImpl::FastMutexImpl(): MutexImpl(true)
+{
+}
+
+
+FastMutexImpl::~FastMutexImpl()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Mutex_VX.cpp b/contrib/libs/poco/Foundation/src/Mutex_VX.cpp
index a4b32acbbf..d36c457332 100644
--- a/contrib/libs/poco/Foundation/src/Mutex_VX.cpp
+++ b/contrib/libs/poco/Foundation/src/Mutex_VX.cpp
@@ -1,68 +1,68 @@
-//
-// Mutex_VX.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: Mutex
-//
-// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Mutex_VX.h"
-#include <sysLib.h>
-
-
-namespace Poco {
-
-
-MutexImpl::MutexImpl()
-{
- _sem = semMCreate(SEM_INVERSION_SAFE | SEM_Q_PRIORITY);
- if (_sem == 0)
- throw Poco::SystemException("cannot create mutex");
-}
-
-
-MutexImpl::MutexImpl(bool fast)
-{
- if (fast)
- {
- _sem = semBCreate(SEM_Q_PRIORITY, SEM_FULL);
- }
- else
- {
- _sem = semMCreate(SEM_INVERSION_SAFE | SEM_Q_PRIORITY);
- }
- if (_sem == 0)
- throw Poco::SystemException("cannot create mutex");
-}
-
-
-MutexImpl::~MutexImpl()
-{
- semDelete(_sem);
-}
-
-
-bool MutexImpl::tryLockImpl(long milliseconds)
-{
- int ticks = milliseconds*sysClkRateGet()/1000;
- return semTake(_sem, ticks) == OK;
-}
-
-
-FastMutexImpl::FastMutexImpl(): MutexImpl(true)
-{
-}
-
-
-FastMutexImpl::~FastMutexImpl()
-{
-}
-
-
-} // namespace Poco
+//
+// Mutex_VX.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: Mutex
+//
+// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Mutex_VX.h"
+#include <sysLib.h>
+
+
+namespace Poco {
+
+
+MutexImpl::MutexImpl()
+{
+ _sem = semMCreate(SEM_INVERSION_SAFE | SEM_Q_PRIORITY);
+ if (_sem == 0)
+ throw Poco::SystemException("cannot create mutex");
+}
+
+
+MutexImpl::MutexImpl(bool fast)
+{
+ if (fast)
+ {
+ _sem = semBCreate(SEM_Q_PRIORITY, SEM_FULL);
+ }
+ else
+ {
+ _sem = semMCreate(SEM_INVERSION_SAFE | SEM_Q_PRIORITY);
+ }
+ if (_sem == 0)
+ throw Poco::SystemException("cannot create mutex");
+}
+
+
+MutexImpl::~MutexImpl()
+{
+ semDelete(_sem);
+}
+
+
+bool MutexImpl::tryLockImpl(long milliseconds)
+{
+ int ticks = milliseconds*sysClkRateGet()/1000;
+ return semTake(_sem, ticks) == OK;
+}
+
+
+FastMutexImpl::FastMutexImpl(): MutexImpl(true)
+{
+}
+
+
+FastMutexImpl::~FastMutexImpl()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Mutex_WIN32.cpp b/contrib/libs/poco/Foundation/src/Mutex_WIN32.cpp
index 446f4affce..21c7f06a1a 100644
--- a/contrib/libs/poco/Foundation/src/Mutex_WIN32.cpp
+++ b/contrib/libs/poco/Foundation/src/Mutex_WIN32.cpp
@@ -1,59 +1,59 @@
-//
-// Mutex_WIN32.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: Mutex
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Mutex_WIN32.h"
-#include "Poco/Timestamp.h"
-
-
-namespace Poco {
-
-
-MutexImpl::MutexImpl()
-{
- // the fct has a boolean return value under WInnNt/2000/XP but not on Win98
- // the return only checks if the input address of &_cs was valid, so it is safe to omit it
- InitializeCriticalSectionAndSpinCount(&_cs, 4000);
-}
-
-
-MutexImpl::~MutexImpl()
-{
- DeleteCriticalSection(&_cs);
-}
-
-
-bool MutexImpl::tryLockImpl(long milliseconds)
-{
- const int sleepMillis = 5;
- Timestamp now;
- Timestamp::TimeDiff diff(Timestamp::TimeDiff(milliseconds)*1000);
- do
- {
- try
- {
- if (TryEnterCriticalSection(&_cs) == TRUE)
- return true;
- }
- catch (...)
- {
- throw SystemException("cannot lock mutex");
- }
- Sleep(sleepMillis);
- }
- while (!now.isElapsed(diff));
- return false;
-}
-
-
-} // namespace Poco
+//
+// Mutex_WIN32.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: Mutex
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Mutex_WIN32.h"
+#include "Poco/Timestamp.h"
+
+
+namespace Poco {
+
+
+MutexImpl::MutexImpl()
+{
+ // the fct has a boolean return value under WInnNt/2000/XP but not on Win98
+ // the return only checks if the input address of &_cs was valid, so it is safe to omit it
+ InitializeCriticalSectionAndSpinCount(&_cs, 4000);
+}
+
+
+MutexImpl::~MutexImpl()
+{
+ DeleteCriticalSection(&_cs);
+}
+
+
+bool MutexImpl::tryLockImpl(long milliseconds)
+{
+ const int sleepMillis = 5;
+ Timestamp now;
+ Timestamp::TimeDiff diff(Timestamp::TimeDiff(milliseconds)*1000);
+ do
+ {
+ try
+ {
+ if (TryEnterCriticalSection(&_cs) == TRUE)
+ return true;
+ }
+ catch (...)
+ {
+ throw SystemException("cannot lock mutex");
+ }
+ Sleep(sleepMillis);
+ }
+ while (!now.isElapsed(diff));
+ return false;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Mutex_WINCE.cpp b/contrib/libs/poco/Foundation/src/Mutex_WINCE.cpp
index 90ea6956d8..e71fcf988e 100644
--- a/contrib/libs/poco/Foundation/src/Mutex_WINCE.cpp
+++ b/contrib/libs/poco/Foundation/src/Mutex_WINCE.cpp
@@ -1,80 +1,80 @@
-//
-// Mutex_WINCE.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: Mutex
-//
-// Copyright (c) 2004-2010, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Mutex_WINCE.h"
-
-
-namespace Poco {
-
-
-MutexImpl::MutexImpl()
-{
- _mutex = CreateMutexW(NULL, FALSE, NULL);
- if (!_mutex) throw SystemException("cannot create mutex");
-}
-
-
-MutexImpl::~MutexImpl()
-{
- CloseHandle(_mutex);
-}
-
-
-void MutexImpl::lockImpl()
-{
- switch (WaitForSingleObject(_mutex, INFINITE))
- {
- case WAIT_OBJECT_0:
- return;
- default:
- throw SystemException("cannot lock mutex");
- }
-}
-
-
-bool MutexImpl::tryLockImpl()
-{
- switch (WaitForSingleObject(_mutex, 0))
- {
- case WAIT_TIMEOUT:
- return false;
- case WAIT_OBJECT_0:
- return true;
- default:
- throw SystemException("cannot lock mutex");
- }
-}
-
-
-bool MutexImpl::tryLockImpl(long milliseconds)
-{
- switch (WaitForSingleObject(_mutex, milliseconds + 1))
- {
- case WAIT_TIMEOUT:
- return false;
- case WAIT_OBJECT_0:
- return true;
- default:
- throw SystemException("cannot lock mutex");
- }
-}
-
-
-void MutexImpl::unlockImpl()
-{
- ReleaseMutex(_mutex);
-}
-
-
-} // namespace Poco
+//
+// Mutex_WINCE.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: Mutex
+//
+// Copyright (c) 2004-2010, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Mutex_WINCE.h"
+
+
+namespace Poco {
+
+
+MutexImpl::MutexImpl()
+{
+ _mutex = CreateMutexW(NULL, FALSE, NULL);
+ if (!_mutex) throw SystemException("cannot create mutex");
+}
+
+
+MutexImpl::~MutexImpl()
+{
+ CloseHandle(_mutex);
+}
+
+
+void MutexImpl::lockImpl()
+{
+ switch (WaitForSingleObject(_mutex, INFINITE))
+ {
+ case WAIT_OBJECT_0:
+ return;
+ default:
+ throw SystemException("cannot lock mutex");
+ }
+}
+
+
+bool MutexImpl::tryLockImpl()
+{
+ switch (WaitForSingleObject(_mutex, 0))
+ {
+ case WAIT_TIMEOUT:
+ return false;
+ case WAIT_OBJECT_0:
+ return true;
+ default:
+ throw SystemException("cannot lock mutex");
+ }
+}
+
+
+bool MutexImpl::tryLockImpl(long milliseconds)
+{
+ switch (WaitForSingleObject(_mutex, milliseconds + 1))
+ {
+ case WAIT_TIMEOUT:
+ return false;
+ case WAIT_OBJECT_0:
+ return true;
+ default:
+ throw SystemException("cannot lock mutex");
+ }
+}
+
+
+void MutexImpl::unlockImpl()
+{
+ ReleaseMutex(_mutex);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/NamedEvent.cpp b/contrib/libs/poco/Foundation/src/NamedEvent.cpp
index 6615ca8f04..1490bad541 100644
--- a/contrib/libs/poco/Foundation/src/NamedEvent.cpp
+++ b/contrib/libs/poco/Foundation/src/NamedEvent.cpp
@@ -1,43 +1,43 @@
-//
-// NamedEvent.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: NamedEvent
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/NamedEvent.h"
-
-
-#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
-#include "NamedEvent_WIN32U.cpp"
-#elif defined(POCO_OS_FAMILY_WINDOWS)
-#include "NamedEvent_WIN32.cpp"
-#elif POCO_OS == POCO_OS_ANDROID
-#include "NamedEvent_Android.cpp"
-#elif defined(POCO_OS_FAMILY_UNIX)
-#include "NamedEvent_UNIX.cpp"
-#endif
-
-
-namespace Poco {
-
-
-NamedEvent::NamedEvent(const std::string& name):
- NamedEventImpl(name)
-{
-}
-
-
-NamedEvent::~NamedEvent()
-{
-}
-
-
-} // namespace Poco
+//
+// NamedEvent.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: NamedEvent
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/NamedEvent.h"
+
+
+#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
+#include "NamedEvent_WIN32U.cpp"
+#elif defined(POCO_OS_FAMILY_WINDOWS)
+#include "NamedEvent_WIN32.cpp"
+#elif POCO_OS == POCO_OS_ANDROID
+#include "NamedEvent_Android.cpp"
+#elif defined(POCO_OS_FAMILY_UNIX)
+#include "NamedEvent_UNIX.cpp"
+#endif
+
+
+namespace Poco {
+
+
+NamedEvent::NamedEvent(const std::string& name):
+ NamedEventImpl(name)
+{
+}
+
+
+NamedEvent::~NamedEvent()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/NamedEvent_Android.cpp b/contrib/libs/poco/Foundation/src/NamedEvent_Android.cpp
index f8dfb0468b..8b53762e40 100644
--- a/contrib/libs/poco/Foundation/src/NamedEvent_Android.cpp
+++ b/contrib/libs/poco/Foundation/src/NamedEvent_Android.cpp
@@ -1,44 +1,44 @@
-//
-// NamedEvent_Android.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: NamedEvent
-//
-// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/NamedEvent_Android.h"
-#include "Poco/Exception.h"
-
-
-namespace Poco {
-
-
-NamedEventImpl::NamedEventImpl(const std::string&)
-{
-}
-
-
-NamedEventImpl::~NamedEventImpl()
-{
-}
-
-
-void NamedEventImpl::setImpl()
-{
- throw NotImplementedException("NamedEvent::set() not available on Android");
-}
-
-
-void NamedEventImpl::waitImpl()
-{
- throw NotImplementedException("NamedEvent::wait() not available on Android");
-}
-
-
-} // namespace Poco
+//
+// NamedEvent_Android.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: NamedEvent
+//
+// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/NamedEvent_Android.h"
+#include "Poco/Exception.h"
+
+
+namespace Poco {
+
+
+NamedEventImpl::NamedEventImpl(const std::string&)
+{
+}
+
+
+NamedEventImpl::~NamedEventImpl()
+{
+}
+
+
+void NamedEventImpl::setImpl()
+{
+ throw NotImplementedException("NamedEvent::set() not available on Android");
+}
+
+
+void NamedEventImpl::waitImpl()
+{
+ throw NotImplementedException("NamedEvent::wait() not available on Android");
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/NamedEvent_UNIX.cpp b/contrib/libs/poco/Foundation/src/NamedEvent_UNIX.cpp
index 978e6e0bc0..c35127aa8a 100644
--- a/contrib/libs/poco/Foundation/src/NamedEvent_UNIX.cpp
+++ b/contrib/libs/poco/Foundation/src/NamedEvent_UNIX.cpp
@@ -1,148 +1,148 @@
-//
-// NamedEvent_UNIX.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: NamedEvent
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/NamedEvent_UNIX.h"
-#include "Poco/Format.h"
-#include "Poco/Exception.h"
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <errno.h>
-#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
-#include <semaphore.h>
-#else
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/sem.h>
-#endif
-
-
-namespace Poco {
-
-
-#if (POCO_OS == POCO_OS_LINUX) || (POCO_OS == POCO_OS_ANDROID) || (POCO_OS == POCO_OS_CYGWIN) || (POCO_OS == POCO_OS_FREE_BSD)
- union semun
- {
- int val;
- struct semid_ds* buf;
- unsigned short int* array;
- struct seminfo* __buf;
- };
-#elif (POCO_OS == POCO_OS_HPUX)
- union semun
- {
- int val;
- struct semid_ds* buf;
- ushort* array;
- };
-#endif
-
-
-NamedEventImpl::NamedEventImpl(const std::string& name):
- _name(name)
-{
- std::string fileName = getFileName();
-#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
- _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);
- if (fd != -1)
- close(fd);
- else
- throw SystemException(Poco::format("cannot create named event %s (lockfile)", fileName), _name);
- key_t key = ftok(fileName.c_str(), 'p');
- if (key == -1)
- throw SystemException(Poco::format("cannot create named mutex %s (ftok() failed, errno=%d)", fileName, errno), _name);
- _semid = semget(key, 1, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | IPC_CREAT | IPC_EXCL);
- if (_semid >= 0)
- {
- union semun arg;
- arg.val = 0;
- semctl(_semid, 0, SETVAL, arg);
- }
- else if (errno == EEXIST)
- {
- _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)
-}
-
-
-NamedEventImpl::~NamedEventImpl()
-{
-#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
- sem_close(_sem);
-#endif
-}
-
-
-void NamedEventImpl::setImpl()
-{
-#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
- if (sem_post(_sem) != 0)
- throw SystemException("cannot set named event", _name);
-#else
- struct sembuf op;
- op.sem_num = 0;
- op.sem_op = 1;
- op.sem_flg = 0;
- if (semop(_semid, &op, 1) != 0)
- throw SystemException("cannot set named event", _name);
-#endif
-}
-
-
-void NamedEventImpl::waitImpl()
-{
-#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
- int err;
- do
- {
- err = sem_wait(_sem);
- }
- while (err && errno == EINTR);
- if (err) throw SystemException("cannot wait for named event", _name);
-#else
- struct sembuf op;
- op.sem_num = 0;
- op.sem_op = -1;
- op.sem_flg = 0;
- int err;
- do
- {
- err = semop(_semid, &op, 1);
- }
- while (err && errno == EINTR);
- if (err) throw SystemException("cannot wait for named event", _name);
-#endif
-}
-
-
-std::string NamedEventImpl::getFileName()
-{
-#if defined(sun) || defined(__APPLE__) || defined(__QNX__)
- std::string fn = "/";
-#else
- std::string fn = "/tmp/";
-#endif
- fn.append(_name);
- fn.append(".event");
- return fn;
-}
-
-
-} // namespace Poco
+//
+// NamedEvent_UNIX.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: NamedEvent
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/NamedEvent_UNIX.h"
+#include "Poco/Format.h"
+#include "Poco/Exception.h"
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <errno.h>
+#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
+#include <semaphore.h>
+#else
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/sem.h>
+#endif
+
+
+namespace Poco {
+
+
+#if (POCO_OS == POCO_OS_LINUX) || (POCO_OS == POCO_OS_ANDROID) || (POCO_OS == POCO_OS_CYGWIN) || (POCO_OS == POCO_OS_FREE_BSD)
+ union semun
+ {
+ int val;
+ struct semid_ds* buf;
+ unsigned short int* array;
+ struct seminfo* __buf;
+ };
+#elif (POCO_OS == POCO_OS_HPUX)
+ union semun
+ {
+ int val;
+ struct semid_ds* buf;
+ ushort* array;
+ };
+#endif
+
+
+NamedEventImpl::NamedEventImpl(const std::string& name):
+ _name(name)
+{
+ std::string fileName = getFileName();
+#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
+ _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);
+ if (fd != -1)
+ close(fd);
+ else
+ throw SystemException(Poco::format("cannot create named event %s (lockfile)", fileName), _name);
+ key_t key = ftok(fileName.c_str(), 'p');
+ if (key == -1)
+ throw SystemException(Poco::format("cannot create named mutex %s (ftok() failed, errno=%d)", fileName, errno), _name);
+ _semid = semget(key, 1, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | IPC_CREAT | IPC_EXCL);
+ if (_semid >= 0)
+ {
+ union semun arg;
+ arg.val = 0;
+ semctl(_semid, 0, SETVAL, arg);
+ }
+ else if (errno == EEXIST)
+ {
+ _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)
+}
+
+
+NamedEventImpl::~NamedEventImpl()
+{
+#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
+ sem_close(_sem);
+#endif
+}
+
+
+void NamedEventImpl::setImpl()
+{
+#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
+ if (sem_post(_sem) != 0)
+ throw SystemException("cannot set named event", _name);
+#else
+ struct sembuf op;
+ op.sem_num = 0;
+ op.sem_op = 1;
+ op.sem_flg = 0;
+ if (semop(_semid, &op, 1) != 0)
+ throw SystemException("cannot set named event", _name);
+#endif
+}
+
+
+void NamedEventImpl::waitImpl()
+{
+#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
+ int err;
+ do
+ {
+ err = sem_wait(_sem);
+ }
+ while (err && errno == EINTR);
+ if (err) throw SystemException("cannot wait for named event", _name);
+#else
+ struct sembuf op;
+ op.sem_num = 0;
+ op.sem_op = -1;
+ op.sem_flg = 0;
+ int err;
+ do
+ {
+ err = semop(_semid, &op, 1);
+ }
+ while (err && errno == EINTR);
+ if (err) throw SystemException("cannot wait for named event", _name);
+#endif
+}
+
+
+std::string NamedEventImpl::getFileName()
+{
+#if defined(sun) || defined(__APPLE__) || defined(__QNX__)
+ std::string fn = "/";
+#else
+ std::string fn = "/tmp/";
+#endif
+ fn.append(_name);
+ fn.append(".event");
+ return fn;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/NamedEvent_WIN32.cpp b/contrib/libs/poco/Foundation/src/NamedEvent_WIN32.cpp
index 0aee72c5fb..0453f62995 100644
--- a/contrib/libs/poco/Foundation/src/NamedEvent_WIN32.cpp
+++ b/contrib/libs/poco/Foundation/src/NamedEvent_WIN32.cpp
@@ -1,61 +1,61 @@
-//
-// NamedEvent_WIN32.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: NamedEvent
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/NamedEvent_WIN32.h"
-#include "Poco/Error.h"
-#include "Poco/Exception.h"
-#include "Poco/Format.h"
-
-
-namespace Poco {
-
-
-NamedEventImpl::NamedEventImpl(const std::string& name):
- _name(name)
-{
- _event = CreateEventA(NULL, FALSE, FALSE, _name.c_str());
- if (!_event)
- {
- DWORD dwRetVal = GetLastError();
- throw SystemException(format("cannot create named event %s [Error %d: %s]", _name, (int)dwRetVal, Error::getMessage(dwRetVal)));
- }
-}
-
-
-NamedEventImpl::~NamedEventImpl()
-{
- CloseHandle(_event);
-}
-
-
-void NamedEventImpl::setImpl()
-{
- if (!SetEvent(_event))
- throw SystemException("cannot signal named event", _name);
-}
-
-
-void NamedEventImpl::waitImpl()
-{
- switch (WaitForSingleObject(_event, INFINITE))
- {
- case WAIT_OBJECT_0:
- return;
- default:
- throw SystemException("wait for named event failed", _name);
- }
-}
-
-
-} // namespace Poco
+//
+// NamedEvent_WIN32.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: NamedEvent
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/NamedEvent_WIN32.h"
+#include "Poco/Error.h"
+#include "Poco/Exception.h"
+#include "Poco/Format.h"
+
+
+namespace Poco {
+
+
+NamedEventImpl::NamedEventImpl(const std::string& name):
+ _name(name)
+{
+ _event = CreateEventA(NULL, FALSE, FALSE, _name.c_str());
+ if (!_event)
+ {
+ DWORD dwRetVal = GetLastError();
+ throw SystemException(format("cannot create named event %s [Error %d: %s]", _name, (int)dwRetVal, Error::getMessage(dwRetVal)));
+ }
+}
+
+
+NamedEventImpl::~NamedEventImpl()
+{
+ CloseHandle(_event);
+}
+
+
+void NamedEventImpl::setImpl()
+{
+ if (!SetEvent(_event))
+ throw SystemException("cannot signal named event", _name);
+}
+
+
+void NamedEventImpl::waitImpl()
+{
+ switch (WaitForSingleObject(_event, INFINITE))
+ {
+ case WAIT_OBJECT_0:
+ return;
+ default:
+ throw SystemException("wait for named event failed", _name);
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/NamedEvent_WIN32U.cpp b/contrib/libs/poco/Foundation/src/NamedEvent_WIN32U.cpp
index 8a7ad1c182..6d043f3360 100644
--- a/contrib/libs/poco/Foundation/src/NamedEvent_WIN32U.cpp
+++ b/contrib/libs/poco/Foundation/src/NamedEvent_WIN32U.cpp
@@ -1,63 +1,63 @@
-//
-// NamedEvent_WIN32.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: NamedEvent
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/NamedEvent_WIN32U.h"
-#include "Poco/Error.h"
-#include "Poco/Exception.h"
-#include "Poco/Format.h"
-#include "Poco/UnicodeConverter.h"
-
-
-namespace Poco {
-
-
-NamedEventImpl::NamedEventImpl(const std::string& name):
- _name(name)
-{
- UnicodeConverter::toUTF16(_name, _uname);
- _event = CreateEventW(NULL, FALSE, FALSE, _uname.c_str());
- if (!_event)
- {
- DWORD dwRetVal = GetLastError();
- throw SystemException(format("cannot create named event %s [Error %d: %s]", _name, (int)dwRetVal, Error::getMessage(dwRetVal)));
- }
-}
-
-
-NamedEventImpl::~NamedEventImpl()
-{
- CloseHandle(_event);
-}
-
-
-void NamedEventImpl::setImpl()
-{
- if (!SetEvent(_event))
- throw SystemException("cannot signal named event", _name);
-}
-
-
-void NamedEventImpl::waitImpl()
-{
- switch (WaitForSingleObject(_event, INFINITE))
- {
- case WAIT_OBJECT_0:
- return;
- default:
- throw SystemException("wait for named event failed", _name);
- }
-}
-
-
-} // namespace Poco
+//
+// NamedEvent_WIN32.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: NamedEvent
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/NamedEvent_WIN32U.h"
+#include "Poco/Error.h"
+#include "Poco/Exception.h"
+#include "Poco/Format.h"
+#include "Poco/UnicodeConverter.h"
+
+
+namespace Poco {
+
+
+NamedEventImpl::NamedEventImpl(const std::string& name):
+ _name(name)
+{
+ UnicodeConverter::toUTF16(_name, _uname);
+ _event = CreateEventW(NULL, FALSE, FALSE, _uname.c_str());
+ if (!_event)
+ {
+ DWORD dwRetVal = GetLastError();
+ throw SystemException(format("cannot create named event %s [Error %d: %s]", _name, (int)dwRetVal, Error::getMessage(dwRetVal)));
+ }
+}
+
+
+NamedEventImpl::~NamedEventImpl()
+{
+ CloseHandle(_event);
+}
+
+
+void NamedEventImpl::setImpl()
+{
+ if (!SetEvent(_event))
+ throw SystemException("cannot signal named event", _name);
+}
+
+
+void NamedEventImpl::waitImpl()
+{
+ switch (WaitForSingleObject(_event, INFINITE))
+ {
+ case WAIT_OBJECT_0:
+ return;
+ default:
+ throw SystemException("wait for named event failed", _name);
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/NamedMutex.cpp b/contrib/libs/poco/Foundation/src/NamedMutex.cpp
index 77fd672c64..82a3ac1a4e 100644
--- a/contrib/libs/poco/Foundation/src/NamedMutex.cpp
+++ b/contrib/libs/poco/Foundation/src/NamedMutex.cpp
@@ -1,43 +1,43 @@
-//
-// NamedMutex.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: NamedMutex
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/NamedMutex.h"
-
-
-#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
-#include "NamedMutex_WIN32U.cpp"
-#elif defined(POCO_OS_FAMILY_WINDOWS)
-#include "NamedMutex_WIN32.cpp"
-#elif POCO_OS == POCO_OS_ANDROID
-#include "NamedMutex_Android.cpp"
-#elif defined(POCO_OS_FAMILY_UNIX)
-#include "NamedMutex_UNIX.cpp"
-#endif
-
-
-namespace Poco {
-
-
-NamedMutex::NamedMutex(const std::string& name):
- NamedMutexImpl(name)
-{
-}
-
-
-NamedMutex::~NamedMutex()
-{
-}
-
-
-} // namespace Poco
+//
+// NamedMutex.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: NamedMutex
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/NamedMutex.h"
+
+
+#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
+#include "NamedMutex_WIN32U.cpp"
+#elif defined(POCO_OS_FAMILY_WINDOWS)
+#include "NamedMutex_WIN32.cpp"
+#elif POCO_OS == POCO_OS_ANDROID
+#include "NamedMutex_Android.cpp"
+#elif defined(POCO_OS_FAMILY_UNIX)
+#include "NamedMutex_UNIX.cpp"
+#endif
+
+
+namespace Poco {
+
+
+NamedMutex::NamedMutex(const std::string& name):
+ NamedMutexImpl(name)
+{
+}
+
+
+NamedMutex::~NamedMutex()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/NamedMutex_Android.cpp b/contrib/libs/poco/Foundation/src/NamedMutex_Android.cpp
index 892839cd86..78e781d1c9 100644
--- a/contrib/libs/poco/Foundation/src/NamedMutex_Android.cpp
+++ b/contrib/libs/poco/Foundation/src/NamedMutex_Android.cpp
@@ -1,50 +1,50 @@
-//
-// NamedMutex_Android.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: NamedMutex
-//
-// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/NamedMutex_Android.h"
-#include "Poco/Exception.h"
-
-
-namespace Poco {
-
-
-NamedMutexImpl::NamedMutexImpl(const std::string&)
-{
-}
-
-
-NamedMutexImpl::~NamedMutexImpl()
-{
-}
-
-
-void NamedMutexImpl::lockImpl()
-{
- throw NotImplementedException("NamedMutex::lock() is not supported on Android");
-}
-
-
-bool NamedMutexImpl::tryLockImpl()
-{
- throw NotImplementedException("NamedMutex::tryLock() is not supported on Android");
-}
-
-
-void NamedMutexImpl::unlockImpl()
-{
- throw NotImplementedException("NamedMutex::unlock() is not supported on Android");
-}
-
-
-} // namespace Poco
+//
+// NamedMutex_Android.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: NamedMutex
+//
+// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/NamedMutex_Android.h"
+#include "Poco/Exception.h"
+
+
+namespace Poco {
+
+
+NamedMutexImpl::NamedMutexImpl(const std::string&)
+{
+}
+
+
+NamedMutexImpl::~NamedMutexImpl()
+{
+}
+
+
+void NamedMutexImpl::lockImpl()
+{
+ throw NotImplementedException("NamedMutex::lock() is not supported on Android");
+}
+
+
+bool NamedMutexImpl::tryLockImpl()
+{
+ throw NotImplementedException("NamedMutex::tryLock() is not supported on Android");
+}
+
+
+void NamedMutexImpl::unlockImpl()
+{
+ throw NotImplementedException("NamedMutex::unlock() is not supported on Android");
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/NamedMutex_UNIX.cpp b/contrib/libs/poco/Foundation/src/NamedMutex_UNIX.cpp
index 6cfa1369c9..5a4d439758 100644
--- a/contrib/libs/poco/Foundation/src/NamedMutex_UNIX.cpp
+++ b/contrib/libs/poco/Foundation/src/NamedMutex_UNIX.cpp
@@ -1,170 +1,170 @@
-//
-// NamedMutex_UNIX.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: NamedMutex
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/NamedMutex_UNIX.h"
-#include "Poco/Format.h"
-#include "Poco/Exception.h"
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <errno.h>
-#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(_AIX)
-#include <semaphore.h>
-#else
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/sem.h>
-#endif
-
-
-namespace Poco {
-
-
-#if (POCO_OS == POCO_OS_LINUX) || (POCO_OS == POCO_OS_ANDROID) || (POCO_OS == POCO_OS_CYGWIN) || (POCO_OS == POCO_OS_FREE_BSD)
- union semun
- {
- int val;
- struct semid_ds* buf;
- unsigned short int* array;
- struct seminfo* __buf;
- };
-#elif (POCO_OS == POCO_OS_HPUX)
- union semun
- {
- int val;
- struct semid_ds* buf;
- ushort* array;
- };
-#endif
-
-
-NamedMutexImpl::NamedMutexImpl(const std::string& name):
- _name(name)
-{
- std::string fileName = getFileName();
-#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
- _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);
- if (fd != -1)
- close(fd);
- else
- throw SystemException(Poco::format("cannot create named mutex %s (lockfile)", fileName), _name);
- key_t key = ftok(fileName.c_str(), 'p');
- if (key == -1)
- throw SystemException(Poco::format("cannot create named mutex %s (ftok() failed, errno=%d)", fileName, errno), _name);
- _semid = semget(key, 1, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | IPC_CREAT | IPC_EXCL);
- if (_semid >= 0)
- {
- union semun arg;
- arg.val = 1;
- semctl(_semid, 0, SETVAL, arg);
- _owned = true;
- return;
- }
- else if (errno == EEXIST)
- {
- _semid = semget(key, 1, 0);
- _owned = false;
- if (_semid >= 0) return;
- }
-
- 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)
-}
-
-
-NamedMutexImpl::~NamedMutexImpl()
-{
-#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
- sem_close(_sem);
-#else
- if (_owned) semctl(_semid, 0, IPC_RMID, 0);
-#endif
-}
-
-
-void NamedMutexImpl::lockImpl()
-{
-#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
- int err;
- do
- {
- err = sem_wait(_sem);
- }
- while (err && errno == EINTR);
- if (err) throw SystemException("cannot lock named mutex", _name);
-#else
- struct sembuf op;
- op.sem_num = 0;
- op.sem_op = -1;
- op.sem_flg = SEM_UNDO;
- int err;
- do
- {
- err = semop(_semid, &op, 1);
- }
- while (err && errno == EINTR);
- if (err) throw SystemException("cannot lock named mutex", _name);
-#endif
-}
-
-
-bool NamedMutexImpl::tryLockImpl()
-{
-#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
- return sem_trywait(_sem) == 0;
-#else
- struct sembuf op;
- op.sem_num = 0;
- op.sem_op = -1;
- op.sem_flg = SEM_UNDO | IPC_NOWAIT;
- return semop(_semid, &op, 1) == 0;
-#endif
-}
-
-
-void NamedMutexImpl::unlockImpl()
-{
-#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
- if (sem_post(_sem) != 0)
- throw SystemException("cannot unlock named mutex", _name);
-#else
- struct sembuf op;
- op.sem_num = 0;
- op.sem_op = 1;
- op.sem_flg = SEM_UNDO;
- if (semop(_semid, &op, 1) != 0)
- throw SystemException("cannot unlock named mutex", _name);
-#endif
-}
-
-
-std::string NamedMutexImpl::getFileName()
-{
-#if defined(sun) || defined(__APPLE__) || defined(__QNX__)
- std::string fn = "/";
-#else
- std::string fn = "/tmp/";
-#endif
- fn.append(_name);
- fn.append(".mutex");
- return fn;
-}
-
-
-} // namespace Poco
-
+//
+// NamedMutex_UNIX.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: NamedMutex
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/NamedMutex_UNIX.h"
+#include "Poco/Format.h"
+#include "Poco/Exception.h"
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <errno.h>
+#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(_AIX)
+#include <semaphore.h>
+#else
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/sem.h>
+#endif
+
+
+namespace Poco {
+
+
+#if (POCO_OS == POCO_OS_LINUX) || (POCO_OS == POCO_OS_ANDROID) || (POCO_OS == POCO_OS_CYGWIN) || (POCO_OS == POCO_OS_FREE_BSD)
+ union semun
+ {
+ int val;
+ struct semid_ds* buf;
+ unsigned short int* array;
+ struct seminfo* __buf;
+ };
+#elif (POCO_OS == POCO_OS_HPUX)
+ union semun
+ {
+ int val;
+ struct semid_ds* buf;
+ ushort* array;
+ };
+#endif
+
+
+NamedMutexImpl::NamedMutexImpl(const std::string& name):
+ _name(name)
+{
+ std::string fileName = getFileName();
+#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
+ _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);
+ if (fd != -1)
+ close(fd);
+ else
+ throw SystemException(Poco::format("cannot create named mutex %s (lockfile)", fileName), _name);
+ key_t key = ftok(fileName.c_str(), 'p');
+ if (key == -1)
+ throw SystemException(Poco::format("cannot create named mutex %s (ftok() failed, errno=%d)", fileName, errno), _name);
+ _semid = semget(key, 1, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | IPC_CREAT | IPC_EXCL);
+ if (_semid >= 0)
+ {
+ union semun arg;
+ arg.val = 1;
+ semctl(_semid, 0, SETVAL, arg);
+ _owned = true;
+ return;
+ }
+ else if (errno == EEXIST)
+ {
+ _semid = semget(key, 1, 0);
+ _owned = false;
+ if (_semid >= 0) return;
+ }
+
+ 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)
+}
+
+
+NamedMutexImpl::~NamedMutexImpl()
+{
+#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
+ sem_close(_sem);
+#else
+ if (_owned) semctl(_semid, 0, IPC_RMID, 0);
+#endif
+}
+
+
+void NamedMutexImpl::lockImpl()
+{
+#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
+ int err;
+ do
+ {
+ err = sem_wait(_sem);
+ }
+ while (err && errno == EINTR);
+ if (err) throw SystemException("cannot lock named mutex", _name);
+#else
+ struct sembuf op;
+ op.sem_num = 0;
+ op.sem_op = -1;
+ op.sem_flg = SEM_UNDO;
+ int err;
+ do
+ {
+ err = semop(_semid, &op, 1);
+ }
+ while (err && errno == EINTR);
+ if (err) throw SystemException("cannot lock named mutex", _name);
+#endif
+}
+
+
+bool NamedMutexImpl::tryLockImpl()
+{
+#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
+ return sem_trywait(_sem) == 0;
+#else
+ struct sembuf op;
+ op.sem_num = 0;
+ op.sem_op = -1;
+ op.sem_flg = SEM_UNDO | IPC_NOWAIT;
+ return semop(_semid, &op, 1) == 0;
+#endif
+}
+
+
+void NamedMutexImpl::unlockImpl()
+{
+#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX)
+ if (sem_post(_sem) != 0)
+ throw SystemException("cannot unlock named mutex", _name);
+#else
+ struct sembuf op;
+ op.sem_num = 0;
+ op.sem_op = 1;
+ op.sem_flg = SEM_UNDO;
+ if (semop(_semid, &op, 1) != 0)
+ throw SystemException("cannot unlock named mutex", _name);
+#endif
+}
+
+
+std::string NamedMutexImpl::getFileName()
+{
+#if defined(sun) || defined(__APPLE__) || defined(__QNX__)
+ std::string fn = "/";
+#else
+ std::string fn = "/tmp/";
+#endif
+ fn.append(_name);
+ fn.append(".mutex");
+ return fn;
+}
+
+
+} // namespace Poco
+
diff --git a/contrib/libs/poco/Foundation/src/NamedMutex_WIN32.cpp b/contrib/libs/poco/Foundation/src/NamedMutex_WIN32.cpp
index 6d2a5c383f..17992f2c2a 100644
--- a/contrib/libs/poco/Foundation/src/NamedMutex_WIN32.cpp
+++ b/contrib/libs/poco/Foundation/src/NamedMutex_WIN32.cpp
@@ -1,73 +1,73 @@
-//
-// NamedMutex_WIN32.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: NamedMutex
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/NamedMutex_WIN32.h"
-#include "Poco/Exception.h"
-
-
-namespace Poco {
-
-
-NamedMutexImpl::NamedMutexImpl(const std::string& name):
- _name(name)
-{
- _mutex = CreateMutexA(NULL, FALSE, _name.c_str());
- if (!_mutex)
- throw SystemException("cannot create named mutex", _name);
-}
-
-
-NamedMutexImpl::~NamedMutexImpl()
-{
- CloseHandle(_mutex);
-}
-
-
-void NamedMutexImpl::lockImpl()
-{
- switch (WaitForSingleObject(_mutex, INFINITE))
- {
- case WAIT_OBJECT_0:
- return;
- case WAIT_ABANDONED:
- throw SystemException("cannot lock named mutex (abadoned)", _name);
- default:
- throw SystemException("cannot lock named mutex", _name);
- }
-}
-
-
-bool NamedMutexImpl::tryLockImpl()
-{
- switch (WaitForSingleObject(_mutex, 0))
- {
- case WAIT_OBJECT_0:
- return true;
- case WAIT_TIMEOUT:
- return false;
- case WAIT_ABANDONED:
- throw SystemException("cannot lock named mutex (abadoned)", _name);
- default:
- throw SystemException("cannot lock named mutex", _name);
- }
-}
-
-
-void NamedMutexImpl::unlockImpl()
-{
- ReleaseMutex(_mutex);
-}
-
-
-} // namespace Poco
+//
+// NamedMutex_WIN32.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: NamedMutex
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/NamedMutex_WIN32.h"
+#include "Poco/Exception.h"
+
+
+namespace Poco {
+
+
+NamedMutexImpl::NamedMutexImpl(const std::string& name):
+ _name(name)
+{
+ _mutex = CreateMutexA(NULL, FALSE, _name.c_str());
+ if (!_mutex)
+ throw SystemException("cannot create named mutex", _name);
+}
+
+
+NamedMutexImpl::~NamedMutexImpl()
+{
+ CloseHandle(_mutex);
+}
+
+
+void NamedMutexImpl::lockImpl()
+{
+ switch (WaitForSingleObject(_mutex, INFINITE))
+ {
+ case WAIT_OBJECT_0:
+ return;
+ case WAIT_ABANDONED:
+ throw SystemException("cannot lock named mutex (abadoned)", _name);
+ default:
+ throw SystemException("cannot lock named mutex", _name);
+ }
+}
+
+
+bool NamedMutexImpl::tryLockImpl()
+{
+ switch (WaitForSingleObject(_mutex, 0))
+ {
+ case WAIT_OBJECT_0:
+ return true;
+ case WAIT_TIMEOUT:
+ return false;
+ case WAIT_ABANDONED:
+ throw SystemException("cannot lock named mutex (abadoned)", _name);
+ default:
+ throw SystemException("cannot lock named mutex", _name);
+ }
+}
+
+
+void NamedMutexImpl::unlockImpl()
+{
+ ReleaseMutex(_mutex);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/NamedMutex_WIN32U.cpp b/contrib/libs/poco/Foundation/src/NamedMutex_WIN32U.cpp
index 1358658b96..e0d6a5a193 100644
--- a/contrib/libs/poco/Foundation/src/NamedMutex_WIN32U.cpp
+++ b/contrib/libs/poco/Foundation/src/NamedMutex_WIN32U.cpp
@@ -1,75 +1,75 @@
-//
-// NamedMutex_WIN32.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: NamedMutex
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/NamedMutex_WIN32U.h"
-#include "Poco/Exception.h"
-#include "Poco/UnicodeConverter.h"
-
-
-namespace Poco {
-
-
-NamedMutexImpl::NamedMutexImpl(const std::string& name):
- _name(name)
-{
- UnicodeConverter::toUTF16(_name, _uname);
- _mutex = CreateMutexW(NULL, FALSE, _uname.c_str());
- if (!_mutex)
- throw SystemException("cannot create named mutex", _name);
-}
-
-
-NamedMutexImpl::~NamedMutexImpl()
-{
- CloseHandle(_mutex);
-}
-
-
-void NamedMutexImpl::lockImpl()
-{
- switch (WaitForSingleObject(_mutex, INFINITE))
- {
- case WAIT_OBJECT_0:
- return;
- case WAIT_ABANDONED:
- throw SystemException("cannot lock named mutex (abadoned)", _name);
- default:
- throw SystemException("cannot lock named mutex", _name);
- }
-}
-
-
-bool NamedMutexImpl::tryLockImpl()
-{
- switch (WaitForSingleObject(_mutex, 0))
- {
- case WAIT_OBJECT_0:
- return true;
- case WAIT_TIMEOUT:
- return false;
- case WAIT_ABANDONED:
- throw SystemException("cannot lock named mutex (abadoned)", _name);
- default:
- throw SystemException("cannot lock named mutex", _name);
- }
-}
-
-
-void NamedMutexImpl::unlockImpl()
-{
- ReleaseMutex(_mutex);
-}
-
-
-} // namespace Poco
+//
+// NamedMutex_WIN32.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: NamedMutex
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/NamedMutex_WIN32U.h"
+#include "Poco/Exception.h"
+#include "Poco/UnicodeConverter.h"
+
+
+namespace Poco {
+
+
+NamedMutexImpl::NamedMutexImpl(const std::string& name):
+ _name(name)
+{
+ UnicodeConverter::toUTF16(_name, _uname);
+ _mutex = CreateMutexW(NULL, FALSE, _uname.c_str());
+ if (!_mutex)
+ throw SystemException("cannot create named mutex", _name);
+}
+
+
+NamedMutexImpl::~NamedMutexImpl()
+{
+ CloseHandle(_mutex);
+}
+
+
+void NamedMutexImpl::lockImpl()
+{
+ switch (WaitForSingleObject(_mutex, INFINITE))
+ {
+ case WAIT_OBJECT_0:
+ return;
+ case WAIT_ABANDONED:
+ throw SystemException("cannot lock named mutex (abadoned)", _name);
+ default:
+ throw SystemException("cannot lock named mutex", _name);
+ }
+}
+
+
+bool NamedMutexImpl::tryLockImpl()
+{
+ switch (WaitForSingleObject(_mutex, 0))
+ {
+ case WAIT_OBJECT_0:
+ return true;
+ case WAIT_TIMEOUT:
+ return false;
+ case WAIT_ABANDONED:
+ throw SystemException("cannot lock named mutex (abadoned)", _name);
+ default:
+ throw SystemException("cannot lock named mutex", _name);
+ }
+}
+
+
+void NamedMutexImpl::unlockImpl()
+{
+ ReleaseMutex(_mutex);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/NestedDiagnosticContext.cpp b/contrib/libs/poco/Foundation/src/NestedDiagnosticContext.cpp
index dcbae13a0a..020f5f0620 100644
--- a/contrib/libs/poco/Foundation/src/NestedDiagnosticContext.cpp
+++ b/contrib/libs/poco/Foundation/src/NestedDiagnosticContext.cpp
@@ -1,129 +1,129 @@
-//
-// NestedDiagnosticContext.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: NestedDiagnosticContext
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/NestedDiagnosticContext.h"
-#include "Poco/SingletonHolder.h"
-#include "Poco/ThreadLocal.h"
-
-
-namespace Poco {
-
-
-NestedDiagnosticContext::NestedDiagnosticContext()
-{
-}
-
-
-NestedDiagnosticContext::NestedDiagnosticContext(const NestedDiagnosticContext& ctx)
-{
- _stack = ctx._stack;
-}
-
-
-NestedDiagnosticContext::~NestedDiagnosticContext()
-{
-}
-
-
-NestedDiagnosticContext& NestedDiagnosticContext::operator = (const NestedDiagnosticContext& ctx)
-{
- if (&ctx != this)
- _stack = ctx._stack;
- return *this;
-}
-
-
-void NestedDiagnosticContext::push(const std::string& info)
-{
- Context ctx;
- ctx.info = info;
- ctx.line = -1;
- ctx.file = 0;
- _stack.push_back(ctx);
-}
-
-
-void NestedDiagnosticContext::push(const std::string& info, int line, const char* filename)
-{
- Context ctx;
- ctx.info = info;
- ctx.line = line;
- ctx.file = filename;
- _stack.push_back(ctx);
-}
-
-
-void NestedDiagnosticContext::pop()
-{
- if (!_stack.empty())
- _stack.pop_back();
-}
-
-
-int NestedDiagnosticContext::depth() const
-{
- return int(_stack.size());
-}
-
-
-std::string NestedDiagnosticContext::toString() const
-{
- std::string result;
- for (Stack::const_iterator it = _stack.begin(); it != _stack.end(); ++it)
- {
- if (!result.empty())
- result.append(":");
- result.append(it->info);
- }
- return result;
-}
-
-
-void NestedDiagnosticContext::dump(std::ostream& ostr) const
-{
- dump(ostr, "\n");
-}
-
-
-void NestedDiagnosticContext::dump(std::ostream& ostr, const std::string& delimiter) const
-{
- for (Stack::const_iterator it = _stack.begin(); it != _stack.end(); ++it)
- {
- ostr << it->info;
- if (it->file)
- ostr << " (in \"" << it->file << "\", line " << it->line << ")";
- ostr << delimiter;
- }
-}
-
-
-void NestedDiagnosticContext::clear()
-{
- _stack.clear();
-}
-
-
-namespace
-{
- static ThreadLocal<NestedDiagnosticContext> ndc;
-}
-
-
-NestedDiagnosticContext& NestedDiagnosticContext::current()
-{
- return ndc.get();
-}
-
-
-} // namespace Poco
+//
+// NestedDiagnosticContext.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: NestedDiagnosticContext
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/NestedDiagnosticContext.h"
+#include "Poco/SingletonHolder.h"
+#include "Poco/ThreadLocal.h"
+
+
+namespace Poco {
+
+
+NestedDiagnosticContext::NestedDiagnosticContext()
+{
+}
+
+
+NestedDiagnosticContext::NestedDiagnosticContext(const NestedDiagnosticContext& ctx)
+{
+ _stack = ctx._stack;
+}
+
+
+NestedDiagnosticContext::~NestedDiagnosticContext()
+{
+}
+
+
+NestedDiagnosticContext& NestedDiagnosticContext::operator = (const NestedDiagnosticContext& ctx)
+{
+ if (&ctx != this)
+ _stack = ctx._stack;
+ return *this;
+}
+
+
+void NestedDiagnosticContext::push(const std::string& info)
+{
+ Context ctx;
+ ctx.info = info;
+ ctx.line = -1;
+ ctx.file = 0;
+ _stack.push_back(ctx);
+}
+
+
+void NestedDiagnosticContext::push(const std::string& info, int line, const char* filename)
+{
+ Context ctx;
+ ctx.info = info;
+ ctx.line = line;
+ ctx.file = filename;
+ _stack.push_back(ctx);
+}
+
+
+void NestedDiagnosticContext::pop()
+{
+ if (!_stack.empty())
+ _stack.pop_back();
+}
+
+
+int NestedDiagnosticContext::depth() const
+{
+ return int(_stack.size());
+}
+
+
+std::string NestedDiagnosticContext::toString() const
+{
+ std::string result;
+ for (Stack::const_iterator it = _stack.begin(); it != _stack.end(); ++it)
+ {
+ if (!result.empty())
+ result.append(":");
+ result.append(it->info);
+ }
+ return result;
+}
+
+
+void NestedDiagnosticContext::dump(std::ostream& ostr) const
+{
+ dump(ostr, "\n");
+}
+
+
+void NestedDiagnosticContext::dump(std::ostream& ostr, const std::string& delimiter) const
+{
+ for (Stack::const_iterator it = _stack.begin(); it != _stack.end(); ++it)
+ {
+ ostr << it->info;
+ if (it->file)
+ ostr << " (in \"" << it->file << "\", line " << it->line << ")";
+ ostr << delimiter;
+ }
+}
+
+
+void NestedDiagnosticContext::clear()
+{
+ _stack.clear();
+}
+
+
+namespace
+{
+ static ThreadLocal<NestedDiagnosticContext> ndc;
+}
+
+
+NestedDiagnosticContext& NestedDiagnosticContext::current()
+{
+ return ndc.get();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Notification.cpp b/contrib/libs/poco/Foundation/src/Notification.cpp
index b2d6b489a6..c6151fb74e 100644
--- a/contrib/libs/poco/Foundation/src/Notification.cpp
+++ b/contrib/libs/poco/Foundation/src/Notification.cpp
@@ -1,38 +1,38 @@
-//
-// Notification.cpp
-//
-// Library: Foundation
-// Package: Notifications
-// Module: Notification
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Notification.h"
-#include <typeinfo>
-
-
-namespace Poco {
-
-
-Notification::Notification()
-{
-}
-
-
-Notification::~Notification()
-{
-}
-
-
-std::string Notification::name() const
-{
- return typeid(*this).name();
-}
-
-
-} // namespace Poco
+//
+// Notification.cpp
+//
+// Library: Foundation
+// Package: Notifications
+// Module: Notification
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Notification.h"
+#include <typeinfo>
+
+
+namespace Poco {
+
+
+Notification::Notification()
+{
+}
+
+
+Notification::~Notification()
+{
+}
+
+
+std::string Notification::name() const
+{
+ return typeid(*this).name();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/NotificationCenter.cpp b/contrib/libs/poco/Foundation/src/NotificationCenter.cpp
index 3b024fa730..124a4a9c2b 100644
--- a/contrib/libs/poco/Foundation/src/NotificationCenter.cpp
+++ b/contrib/libs/poco/Foundation/src/NotificationCenter.cpp
@@ -1,109 +1,109 @@
-//
-// NotificationCenter.cpp
-//
-// Library: Foundation
-// Package: Notifications
-// Module: NotificationCenter
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/NotificationCenter.h"
-#include "Poco/Notification.h"
-#include "Poco/Observer.h"
-#include "Poco/AutoPtr.h"
-#include "Poco/SingletonHolder.h"
-
-
-namespace Poco {
-
-
-NotificationCenter::NotificationCenter()
-{
-}
-
-
-NotificationCenter::~NotificationCenter()
-{
-}
-
-
-void NotificationCenter::addObserver(const AbstractObserver& observer)
-{
- Mutex::ScopedLock lock(_mutex);
- _observers.push_back(observer.clone());
-}
-
-
-void NotificationCenter::removeObserver(const AbstractObserver& observer)
-{
- Mutex::ScopedLock lock(_mutex);
- for (ObserverList::iterator it = _observers.begin(); it != _observers.end(); ++it)
- {
- if (observer.equals(**it))
- {
- (*it)->disable();
- _observers.erase(it);
- return;
- }
- }
-}
-
-
-bool NotificationCenter::hasObserver(const AbstractObserver& observer) const
-{
- Mutex::ScopedLock lock(_mutex);
- for (ObserverList::const_iterator it = _observers.begin(); it != _observers.end(); ++it)
- if (observer.equals(**it)) return true;
-
- return false;
-}
-
-
-void NotificationCenter::postNotification(Notification::Ptr pNotification)
-{
- poco_check_ptr (pNotification);
-
- ScopedLockWithUnlock<Mutex> lock(_mutex);
- ObserverList observersToNotify(_observers);
- lock.unlock();
- for (ObserverList::iterator it = observersToNotify.begin(); it != observersToNotify.end(); ++it)
- {
- (*it)->notify(pNotification);
- }
-}
-
-
-bool NotificationCenter::hasObservers() const
-{
- Mutex::ScopedLock lock(_mutex);
-
- return !_observers.empty();
-}
-
-
-std::size_t NotificationCenter::countObservers() const
-{
- Mutex::ScopedLock lock(_mutex);
-
- return _observers.size();
-}
-
-
-namespace
-{
- static SingletonHolder<NotificationCenter> sh;
-}
-
-
-NotificationCenter& NotificationCenter::defaultCenter()
-{
- return *sh.get();
-}
-
-
-} // namespace Poco
+//
+// NotificationCenter.cpp
+//
+// Library: Foundation
+// Package: Notifications
+// Module: NotificationCenter
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/NotificationCenter.h"
+#include "Poco/Notification.h"
+#include "Poco/Observer.h"
+#include "Poco/AutoPtr.h"
+#include "Poco/SingletonHolder.h"
+
+
+namespace Poco {
+
+
+NotificationCenter::NotificationCenter()
+{
+}
+
+
+NotificationCenter::~NotificationCenter()
+{
+}
+
+
+void NotificationCenter::addObserver(const AbstractObserver& observer)
+{
+ Mutex::ScopedLock lock(_mutex);
+ _observers.push_back(observer.clone());
+}
+
+
+void NotificationCenter::removeObserver(const AbstractObserver& observer)
+{
+ Mutex::ScopedLock lock(_mutex);
+ for (ObserverList::iterator it = _observers.begin(); it != _observers.end(); ++it)
+ {
+ if (observer.equals(**it))
+ {
+ (*it)->disable();
+ _observers.erase(it);
+ return;
+ }
+ }
+}
+
+
+bool NotificationCenter::hasObserver(const AbstractObserver& observer) const
+{
+ Mutex::ScopedLock lock(_mutex);
+ for (ObserverList::const_iterator it = _observers.begin(); it != _observers.end(); ++it)
+ if (observer.equals(**it)) return true;
+
+ return false;
+}
+
+
+void NotificationCenter::postNotification(Notification::Ptr pNotification)
+{
+ poco_check_ptr (pNotification);
+
+ ScopedLockWithUnlock<Mutex> lock(_mutex);
+ ObserverList observersToNotify(_observers);
+ lock.unlock();
+ for (ObserverList::iterator it = observersToNotify.begin(); it != observersToNotify.end(); ++it)
+ {
+ (*it)->notify(pNotification);
+ }
+}
+
+
+bool NotificationCenter::hasObservers() const
+{
+ Mutex::ScopedLock lock(_mutex);
+
+ return !_observers.empty();
+}
+
+
+std::size_t NotificationCenter::countObservers() const
+{
+ Mutex::ScopedLock lock(_mutex);
+
+ return _observers.size();
+}
+
+
+namespace
+{
+ static SingletonHolder<NotificationCenter> sh;
+}
+
+
+NotificationCenter& NotificationCenter::defaultCenter()
+{
+ return *sh.get();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/NotificationQueue.cpp b/contrib/libs/poco/Foundation/src/NotificationQueue.cpp
index 670d11ec3a..98b84dca9f 100644
--- a/contrib/libs/poco/Foundation/src/NotificationQueue.cpp
+++ b/contrib/libs/poco/Foundation/src/NotificationQueue.cpp
@@ -1,211 +1,211 @@
-//
-// NotificationQueue.cpp
-//
-// Library: Foundation
-// Package: Notifications
-// Module: NotificationQueue
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/NotificationQueue.h"
-#include "Poco/NotificationCenter.h"
-#include "Poco/Notification.h"
-#include "Poco/SingletonHolder.h"
-
-
-namespace Poco {
-
-
-NotificationQueue::NotificationQueue()
-{
-}
-
-
-NotificationQueue::~NotificationQueue()
-{
- try
- {
- clear();
- }
- catch (...)
- {
- poco_unexpected();
- }
-}
-
-
-void NotificationQueue::enqueueNotification(Notification::Ptr pNotification)
-{
- poco_check_ptr (pNotification);
- FastMutex::ScopedLock lock(_mutex);
- if (_waitQueue.empty())
- {
- _nfQueue.push_back(pNotification);
- }
- else
- {
- WaitInfo* pWI = _waitQueue.front();
- _waitQueue.pop_front();
- pWI->pNf = pNotification;
- pWI->nfAvailable.set();
- }
-}
-
-
-void NotificationQueue::enqueueUrgentNotification(Notification::Ptr pNotification)
-{
- poco_check_ptr (pNotification);
- FastMutex::ScopedLock lock(_mutex);
- if (_waitQueue.empty())
- {
- _nfQueue.push_front(pNotification);
- }
- else
- {
- WaitInfo* pWI = _waitQueue.front();
- _waitQueue.pop_front();
- pWI->pNf = pNotification;
- pWI->nfAvailable.set();
- }
-}
-
-
-Notification* NotificationQueue::dequeueNotification()
-{
- FastMutex::ScopedLock lock(_mutex);
- return dequeueOne().duplicate();
-}
-
-
-Notification* NotificationQueue::waitDequeueNotification()
-{
- Notification::Ptr pNf;
- WaitInfo* pWI = 0;
- {
- FastMutex::ScopedLock lock(_mutex);
- pNf = dequeueOne();
- if (pNf) return pNf.duplicate();
- pWI = new WaitInfo;
- _waitQueue.push_back(pWI);
- }
- pWI->nfAvailable.wait();
- pNf = pWI->pNf;
- delete pWI;
- return pNf.duplicate();
-}
-
-
-Notification* NotificationQueue::waitDequeueNotification(long milliseconds)
-{
- Notification::Ptr pNf;
- WaitInfo* pWI = 0;
- {
- FastMutex::ScopedLock lock(_mutex);
- pNf = dequeueOne();
- if (pNf) return pNf.duplicate();
- pWI = new WaitInfo;
- _waitQueue.push_back(pWI);
- }
- if (pWI->nfAvailable.tryWait(milliseconds))
- {
- pNf = pWI->pNf;
- }
- else
- {
- FastMutex::ScopedLock lock(_mutex);
- pNf = pWI->pNf;
- for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it)
- {
- if (*it == pWI)
- {
- _waitQueue.erase(it);
- break;
- }
- }
- }
- delete pWI;
- return pNf.duplicate();
-}
-
-
-void NotificationQueue::dispatch(NotificationCenter& notificationCenter)
-{
- FastMutex::ScopedLock lock(_mutex);
- Notification::Ptr pNf = dequeueOne();
- while (pNf)
- {
- notificationCenter.postNotification(pNf);
- pNf = dequeueOne();
- }
-}
-
-
-void NotificationQueue::wakeUpAll()
-{
- FastMutex::ScopedLock lock(_mutex);
- for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it)
- {
- (*it)->nfAvailable.set();
- }
- _waitQueue.clear();
-}
-
-
-bool NotificationQueue::empty() const
-{
- FastMutex::ScopedLock lock(_mutex);
- return _nfQueue.empty();
-}
-
-
-int NotificationQueue::size() const
-{
- FastMutex::ScopedLock lock(_mutex);
- return static_cast<int>(_nfQueue.size());
-}
-
-
-void NotificationQueue::clear()
-{
- FastMutex::ScopedLock lock(_mutex);
- _nfQueue.clear();
-}
-
-
-bool NotificationQueue::hasIdleThreads() const
-{
- FastMutex::ScopedLock lock(_mutex);
- return !_waitQueue.empty();
-}
-
-
-Notification::Ptr NotificationQueue::dequeueOne()
-{
- Notification::Ptr pNf;
- if (!_nfQueue.empty())
- {
- pNf = _nfQueue.front();
- _nfQueue.pop_front();
- }
- return pNf;
-}
-
-
-namespace
-{
- static SingletonHolder<NotificationQueue> sh;
-}
-
-
-NotificationQueue& NotificationQueue::defaultQueue()
-{
- return *sh.get();
-}
-
-
-} // namespace Poco
+//
+// NotificationQueue.cpp
+//
+// Library: Foundation
+// Package: Notifications
+// Module: NotificationQueue
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/NotificationQueue.h"
+#include "Poco/NotificationCenter.h"
+#include "Poco/Notification.h"
+#include "Poco/SingletonHolder.h"
+
+
+namespace Poco {
+
+
+NotificationQueue::NotificationQueue()
+{
+}
+
+
+NotificationQueue::~NotificationQueue()
+{
+ try
+ {
+ clear();
+ }
+ catch (...)
+ {
+ poco_unexpected();
+ }
+}
+
+
+void NotificationQueue::enqueueNotification(Notification::Ptr pNotification)
+{
+ poco_check_ptr (pNotification);
+ FastMutex::ScopedLock lock(_mutex);
+ if (_waitQueue.empty())
+ {
+ _nfQueue.push_back(pNotification);
+ }
+ else
+ {
+ WaitInfo* pWI = _waitQueue.front();
+ _waitQueue.pop_front();
+ pWI->pNf = pNotification;
+ pWI->nfAvailable.set();
+ }
+}
+
+
+void NotificationQueue::enqueueUrgentNotification(Notification::Ptr pNotification)
+{
+ poco_check_ptr (pNotification);
+ FastMutex::ScopedLock lock(_mutex);
+ if (_waitQueue.empty())
+ {
+ _nfQueue.push_front(pNotification);
+ }
+ else
+ {
+ WaitInfo* pWI = _waitQueue.front();
+ _waitQueue.pop_front();
+ pWI->pNf = pNotification;
+ pWI->nfAvailable.set();
+ }
+}
+
+
+Notification* NotificationQueue::dequeueNotification()
+{
+ FastMutex::ScopedLock lock(_mutex);
+ return dequeueOne().duplicate();
+}
+
+
+Notification* NotificationQueue::waitDequeueNotification()
+{
+ Notification::Ptr pNf;
+ WaitInfo* pWI = 0;
+ {
+ FastMutex::ScopedLock lock(_mutex);
+ pNf = dequeueOne();
+ if (pNf) return pNf.duplicate();
+ pWI = new WaitInfo;
+ _waitQueue.push_back(pWI);
+ }
+ pWI->nfAvailable.wait();
+ pNf = pWI->pNf;
+ delete pWI;
+ return pNf.duplicate();
+}
+
+
+Notification* NotificationQueue::waitDequeueNotification(long milliseconds)
+{
+ Notification::Ptr pNf;
+ WaitInfo* pWI = 0;
+ {
+ FastMutex::ScopedLock lock(_mutex);
+ pNf = dequeueOne();
+ if (pNf) return pNf.duplicate();
+ pWI = new WaitInfo;
+ _waitQueue.push_back(pWI);
+ }
+ if (pWI->nfAvailable.tryWait(milliseconds))
+ {
+ pNf = pWI->pNf;
+ }
+ else
+ {
+ FastMutex::ScopedLock lock(_mutex);
+ pNf = pWI->pNf;
+ for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it)
+ {
+ if (*it == pWI)
+ {
+ _waitQueue.erase(it);
+ break;
+ }
+ }
+ }
+ delete pWI;
+ return pNf.duplicate();
+}
+
+
+void NotificationQueue::dispatch(NotificationCenter& notificationCenter)
+{
+ FastMutex::ScopedLock lock(_mutex);
+ Notification::Ptr pNf = dequeueOne();
+ while (pNf)
+ {
+ notificationCenter.postNotification(pNf);
+ pNf = dequeueOne();
+ }
+}
+
+
+void NotificationQueue::wakeUpAll()
+{
+ FastMutex::ScopedLock lock(_mutex);
+ for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it)
+ {
+ (*it)->nfAvailable.set();
+ }
+ _waitQueue.clear();
+}
+
+
+bool NotificationQueue::empty() const
+{
+ FastMutex::ScopedLock lock(_mutex);
+ return _nfQueue.empty();
+}
+
+
+int NotificationQueue::size() const
+{
+ FastMutex::ScopedLock lock(_mutex);
+ return static_cast<int>(_nfQueue.size());
+}
+
+
+void NotificationQueue::clear()
+{
+ FastMutex::ScopedLock lock(_mutex);
+ _nfQueue.clear();
+}
+
+
+bool NotificationQueue::hasIdleThreads() const
+{
+ FastMutex::ScopedLock lock(_mutex);
+ return !_waitQueue.empty();
+}
+
+
+Notification::Ptr NotificationQueue::dequeueOne()
+{
+ Notification::Ptr pNf;
+ if (!_nfQueue.empty())
+ {
+ pNf = _nfQueue.front();
+ _nfQueue.pop_front();
+ }
+ return pNf;
+}
+
+
+namespace
+{
+ static SingletonHolder<NotificationQueue> sh;
+}
+
+
+NotificationQueue& NotificationQueue::defaultQueue()
+{
+ return *sh.get();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/NullChannel.cpp b/contrib/libs/poco/Foundation/src/NullChannel.cpp
index 605151cd54..fe1ca27a2c 100644
--- a/contrib/libs/poco/Foundation/src/NullChannel.cpp
+++ b/contrib/libs/poco/Foundation/src/NullChannel.cpp
@@ -1,41 +1,41 @@
-//
-// NullChannel.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: NullChannel
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/NullChannel.h"
-
-
-namespace Poco {
-
-
-NullChannel::NullChannel()
-{
-}
-
-
-NullChannel::~NullChannel()
-{
-}
-
-
-void NullChannel::log(const Message&)
-{
-}
-
-
-void NullChannel::setProperty(const std::string&, const std::string&)
-{
-}
-
-
-} // namespace Poco
+//
+// NullChannel.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: NullChannel
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/NullChannel.h"
+
+
+namespace Poco {
+
+
+NullChannel::NullChannel()
+{
+}
+
+
+NullChannel::~NullChannel()
+{
+}
+
+
+void NullChannel::log(const Message&)
+{
+}
+
+
+void NullChannel::setProperty(const std::string&, const std::string&)
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/NullStream.cpp b/contrib/libs/poco/Foundation/src/NullStream.cpp
index e27042587c..ac1fa644f0 100644
--- a/contrib/libs/poco/Foundation/src/NullStream.cpp
+++ b/contrib/libs/poco/Foundation/src/NullStream.cpp
@@ -1,74 +1,74 @@
-//
-// NullStream.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: NullStream
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/NullStream.h"
-
-
-namespace Poco {
-
-
-NullStreamBuf::NullStreamBuf()
-{
-}
-
-
-NullStreamBuf::~NullStreamBuf()
-{
-}
-
-
-int NullStreamBuf::readFromDevice()
-{
- return -1;
-}
-
-
-int NullStreamBuf::writeToDevice(char c)
-{
- return charToInt(c);
-}
-
-
-NullIOS::NullIOS()
-{
- poco_ios_init(&_buf);
-}
-
-
-NullIOS::~NullIOS()
-{
-}
-
-
-NullInputStream::NullInputStream(): std::istream(&_buf)
-{
-}
-
-
-NullInputStream::~NullInputStream()
-{
-}
-
-
-NullOutputStream::NullOutputStream(): std::ostream(&_buf)
-{
-}
-
-
-NullOutputStream::~NullOutputStream()
-{
-}
-
-
-} // namespace Poco
+//
+// NullStream.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: NullStream
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/NullStream.h"
+
+
+namespace Poco {
+
+
+NullStreamBuf::NullStreamBuf()
+{
+}
+
+
+NullStreamBuf::~NullStreamBuf()
+{
+}
+
+
+int NullStreamBuf::readFromDevice()
+{
+ return -1;
+}
+
+
+int NullStreamBuf::writeToDevice(char c)
+{
+ return charToInt(c);
+}
+
+
+NullIOS::NullIOS()
+{
+ poco_ios_init(&_buf);
+}
+
+
+NullIOS::~NullIOS()
+{
+}
+
+
+NullInputStream::NullInputStream(): std::istream(&_buf)
+{
+}
+
+
+NullInputStream::~NullInputStream()
+{
+}
+
+
+NullOutputStream::NullOutputStream(): std::ostream(&_buf)
+{
+}
+
+
+NullOutputStream::~NullOutputStream()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/NumberFormatter.cpp b/contrib/libs/poco/Foundation/src/NumberFormatter.cpp
index 5c8126e9b0..c0850857ec 100644
--- a/contrib/libs/poco/Foundation/src/NumberFormatter.cpp
+++ b/contrib/libs/poco/Foundation/src/NumberFormatter.cpp
@@ -1,492 +1,492 @@
-//
-// NumberFormatter.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: NumberFormatter
-//
-// Copyright (c) 2004-2008, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/NumberFormatter.h"
-#include "Poco/MemoryStream.h"
-#include <iomanip>
-#if !defined(POCO_NO_LOCALE)
-#include <locale>
-#endif
-#include <cstdio>
-
-
-#if defined(_MSC_VER) || defined(__MINGW32__)
- #define I64_FMT "I64"
-#elif defined(__APPLE__)
- #define I64_FMT "q"
-#else
- #define I64_FMT "ll"
-#endif
-
-
-namespace Poco {
-
-
-std::string NumberFormatter::format(bool value, BoolFormat format)
-{
- switch(format)
- {
- default:
- case FMT_TRUE_FALSE:
- if (value == true)
- return "true";
- return "false";
- case FMT_YES_NO:
- if (value == true)
- return "yes";
- return "no";
- case FMT_ON_OFF:
- if (value == true)
- return "on";
- return "off";
- }
-}
-
-
-void NumberFormatter::append(std::string& str, int value)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- intToStr(value, 10, result, sz);
- str.append(result, sz);
-}
-
-
-void NumberFormatter::append(std::string& str, int value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- intToStr(value, 10, result, sz, false, width);
- str.append(result, sz);
-}
-
-
-void NumberFormatter::append0(std::string& str, int value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- intToStr(value, 10, result, sz, false, width, '0');
- str.append(result, sz);
-}
-
-
-void NumberFormatter::appendHex(std::string& str, int value)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(static_cast<unsigned int>(value), 0x10, result, sz);
- str.append(result, sz);
-}
-
-
-void NumberFormatter::appendHex(std::string& str, int value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(static_cast<unsigned int>(value), 0x10, result, sz, false, width, '0');
- str.append(result, sz);
-}
-
-
-void NumberFormatter::append(std::string& str, unsigned value)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(value, 10, result, sz);
- str.append(result, sz);
-}
-
-
-void NumberFormatter::append(std::string& str, unsigned value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(value, 10, result, sz, false, width);
- str.append(result, sz);
-}
-
-
-void NumberFormatter::append0(std::string& str, unsigned int value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(value, 10, result, sz, false, width, '0');
- str.append(result, sz);
-}
-
-
-void NumberFormatter::appendHex(std::string& str, unsigned value)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(value, 0x10, result, sz);
- str.append(result, sz);
-}
-
-
-void NumberFormatter::appendHex(std::string& str, unsigned value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(value, 0x10, result, sz, false, width, '0');
- str.append(result, sz);
-}
-
-
-void NumberFormatter::append(std::string& str, long value)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- intToStr(value, 10, result, sz);
- str.append(result, sz);
-}
-
-
-void NumberFormatter::append(std::string& str, long value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- intToStr(value, 10, result, sz, false, width);
- str.append(result, sz);
-}
-
-
-void NumberFormatter::append0(std::string& str, long value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- intToStr(value, 10, result, sz, false, width, '0');
- str.append(result, sz);
-}
-
-
-void NumberFormatter::appendHex(std::string& str, long value)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(static_cast<unsigned long>(value), 0x10, result, sz);
- str.append(result, sz);
-}
-
-
-void NumberFormatter::appendHex(std::string& str, long value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(static_cast<unsigned long>(value), 0x10, result, sz, false, width, '0');
- str.append(result, sz);
-}
-
-
-void NumberFormatter::append(std::string& str, unsigned long value)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(value, 10, result, sz);
- str.append(result, sz);
-}
-
-
-void NumberFormatter::append(std::string& str, unsigned long value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(value, 10, result, sz, false, width, '0');
- str.append(result, sz);
-}
-
-
-void NumberFormatter::append0(std::string& str, unsigned long value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(value, 10, result, sz, false, width, '0');
- str.append(result, sz);
-}
-
-
-void NumberFormatter::appendHex(std::string& str, unsigned long value)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(value, 0x10, result, sz);
- str.append(result, sz);
-}
-
-
-void NumberFormatter::appendHex(std::string& str, unsigned long value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(value, 0x10, result, sz, false, width, '0');
- str.append(result, sz);
-}
-
-
-#ifdef POCO_HAVE_INT64
-
-#ifdef POCO_LONG_IS_64_BIT
-
-
-void NumberFormatter::append(std::string& str, long long value)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- intToStr(value, 10, result, sz);
- str.append(result, sz);
-}
-
-
-void NumberFormatter::append(std::string& str, long long value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- intToStr(value, 10, result, sz, false, width, '0');
- str.append(result, sz);
-}
-
-
-void NumberFormatter::append0(std::string& str, long long value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- intToStr(value, 10, result, sz, false, width, '0');
- str.append(result, sz);
-}
-
-
-void NumberFormatter::appendHex(std::string& str, long long value)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(static_cast<unsigned long long>(value), 0x10, result, sz);
- str.append(result, sz);
-}
-
-
-void NumberFormatter::appendHex(std::string& str, long long value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(static_cast<unsigned long long>(value), 0x10, result, sz, false, width, '0');
- str.append(result, sz);
-}
-
-
-void NumberFormatter::append(std::string& str, unsigned long long value)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(value, 10, result, sz);
- str.append(result, sz);
-}
-
-
-void NumberFormatter::append(std::string& str, unsigned long long value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(value, 10, result, sz, false, width, '0');
- str.append(result, sz);
-}
-
-
-void NumberFormatter::append0(std::string& str, unsigned long long value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(value, 10, result, sz, false, width, '0');
- str.append(result, sz);
-}
-
-
-void NumberFormatter::appendHex(std::string& str, unsigned long long value)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(value, 0x10, result, sz);
- str.append(result, sz);
-}
-
-
-void NumberFormatter::appendHex(std::string& str, unsigned long long value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(value, 0x10, result, sz, false, width, '0');
- str.append(result, sz);
-}
-
-
-#else // ifndef POCO_LONG_IS_64_BIT
-
-
-void NumberFormatter::append(std::string& str, Int64 value)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- intToStr(value, 10, result, sz);
- str.append(result, sz);
-}
-
-
-void NumberFormatter::append(std::string& str, Int64 value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- intToStr(value, 10, result, sz, false, width, '0');
- str.append(result, sz);
-}
-
-
-void NumberFormatter::append0(std::string& str, Int64 value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- intToStr(value, 10, result, sz, false, width, '0');
- str.append(result, sz);
-}
-
-
-void NumberFormatter::appendHex(std::string& str, Int64 value)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(static_cast<UInt64>(value), 0x10, result, sz);
- str.append(result, sz);
-}
-
-
-void NumberFormatter::appendHex(std::string& str, Int64 value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(static_cast<UInt64>(value), 0x10, result, sz, false, width, '0');
- str.append(result, sz);
-}
-
-
-void NumberFormatter::append(std::string& str, UInt64 value)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(value, 10, result, sz);
- str.append(result, sz);
-}
-
-
-void NumberFormatter::append(std::string& str, UInt64 value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(value, 10, result, sz, false, width, '0');
- str.append(result, sz);
-}
-
-
-void NumberFormatter::append0(std::string& str, UInt64 value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(value, 10, result, sz, false, width, '0');
- str.append(result, sz);
-}
-
-
-void NumberFormatter::appendHex(std::string& str, UInt64 value)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(value, 0x10, result, sz);
- str.append(result, sz);
-}
-
-
-void NumberFormatter::appendHex(std::string& str, UInt64 value, int width)
-{
- char result[NF_MAX_INT_STRING_LEN];
- std::size_t sz = NF_MAX_INT_STRING_LEN;
- uIntToStr(value, 0x10, result, sz, false, width, '0');
- str.append(result, sz);
-}
-
-
-#endif // ifdef POCO_LONG_IS_64_BIT
-
-#endif // ifdef POCO_HAVE_INT64
-
-
-void NumberFormatter::append(std::string& str, float value)
-{
- char buffer[NF_MAX_FLT_STRING_LEN];
- floatToStr(buffer, POCO_MAX_FLT_STRING_LEN, value);
- str.append(buffer);
-}
-
-
-void NumberFormatter::append(std::string& str, float value, int precision)
-{
- char buffer[NF_MAX_FLT_STRING_LEN];
- floatToFixedStr(buffer, POCO_MAX_FLT_STRING_LEN, value, precision);
- str.append(buffer);
-}
-
-
-void NumberFormatter::append(std::string& str, float value, int width, int precision)
-{
- std::string result;
- str.append(floatToFixedStr(result, value, precision, width));
-}
-
-
-void NumberFormatter::append(std::string& str, double value)
-{
- char buffer[NF_MAX_FLT_STRING_LEN];
- doubleToStr(buffer, POCO_MAX_FLT_STRING_LEN, value);
- str.append(buffer);
-}
-
-
-void NumberFormatter::append(std::string& str, double value, int precision)
-{
- char buffer[NF_MAX_FLT_STRING_LEN];
- doubleToFixedStr(buffer, POCO_MAX_FLT_STRING_LEN, value, precision);
- str.append(buffer);
-}
-
-
-void NumberFormatter::append(std::string& str, double value, int width, int precision)
-{
- std::string result;
- str.append(doubleToFixedStr(result, value, precision, width));
-}
-
-
-void NumberFormatter::append(std::string& str, const void* ptr)
-{
- char buffer[24];
-#if defined(POCO_PTR_IS_64_BIT)
- #if defined(POCO_LONG_IS_64_BIT)
- std::sprintf(buffer, "%016lX", (UIntPtr) ptr);
- #else
- std::sprintf(buffer, "%016" I64_FMT "X", (UIntPtr) ptr);
- #endif
-#else
- std::sprintf(buffer, "%08lX", (UIntPtr) ptr);
-#endif
- str.append(buffer);
-}
-
-
-} // namespace Poco
+//
+// NumberFormatter.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: NumberFormatter
+//
+// Copyright (c) 2004-2008, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/NumberFormatter.h"
+#include "Poco/MemoryStream.h"
+#include <iomanip>
+#if !defined(POCO_NO_LOCALE)
+#include <locale>
+#endif
+#include <cstdio>
+
+
+#if defined(_MSC_VER) || defined(__MINGW32__)
+ #define I64_FMT "I64"
+#elif defined(__APPLE__)
+ #define I64_FMT "q"
+#else
+ #define I64_FMT "ll"
+#endif
+
+
+namespace Poco {
+
+
+std::string NumberFormatter::format(bool value, BoolFormat format)
+{
+ switch(format)
+ {
+ default:
+ case FMT_TRUE_FALSE:
+ if (value == true)
+ return "true";
+ return "false";
+ case FMT_YES_NO:
+ if (value == true)
+ return "yes";
+ return "no";
+ case FMT_ON_OFF:
+ if (value == true)
+ return "on";
+ return "off";
+ }
+}
+
+
+void NumberFormatter::append(std::string& str, int value)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ intToStr(value, 10, result, sz);
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::append(std::string& str, int value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ intToStr(value, 10, result, sz, false, width);
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::append0(std::string& str, int value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ intToStr(value, 10, result, sz, false, width, '0');
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::appendHex(std::string& str, int value)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(static_cast<unsigned int>(value), 0x10, result, sz);
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::appendHex(std::string& str, int value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(static_cast<unsigned int>(value), 0x10, result, sz, false, width, '0');
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::append(std::string& str, unsigned value)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(value, 10, result, sz);
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::append(std::string& str, unsigned value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(value, 10, result, sz, false, width);
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::append0(std::string& str, unsigned int value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(value, 10, result, sz, false, width, '0');
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::appendHex(std::string& str, unsigned value)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(value, 0x10, result, sz);
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::appendHex(std::string& str, unsigned value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(value, 0x10, result, sz, false, width, '0');
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::append(std::string& str, long value)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ intToStr(value, 10, result, sz);
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::append(std::string& str, long value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ intToStr(value, 10, result, sz, false, width);
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::append0(std::string& str, long value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ intToStr(value, 10, result, sz, false, width, '0');
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::appendHex(std::string& str, long value)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(static_cast<unsigned long>(value), 0x10, result, sz);
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::appendHex(std::string& str, long value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(static_cast<unsigned long>(value), 0x10, result, sz, false, width, '0');
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::append(std::string& str, unsigned long value)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(value, 10, result, sz);
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::append(std::string& str, unsigned long value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(value, 10, result, sz, false, width, '0');
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::append0(std::string& str, unsigned long value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(value, 10, result, sz, false, width, '0');
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::appendHex(std::string& str, unsigned long value)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(value, 0x10, result, sz);
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::appendHex(std::string& str, unsigned long value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(value, 0x10, result, sz, false, width, '0');
+ str.append(result, sz);
+}
+
+
+#ifdef POCO_HAVE_INT64
+
+#ifdef POCO_LONG_IS_64_BIT
+
+
+void NumberFormatter::append(std::string& str, long long value)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ intToStr(value, 10, result, sz);
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::append(std::string& str, long long value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ intToStr(value, 10, result, sz, false, width, '0');
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::append0(std::string& str, long long value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ intToStr(value, 10, result, sz, false, width, '0');
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::appendHex(std::string& str, long long value)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(static_cast<unsigned long long>(value), 0x10, result, sz);
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::appendHex(std::string& str, long long value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(static_cast<unsigned long long>(value), 0x10, result, sz, false, width, '0');
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::append(std::string& str, unsigned long long value)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(value, 10, result, sz);
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::append(std::string& str, unsigned long long value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(value, 10, result, sz, false, width, '0');
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::append0(std::string& str, unsigned long long value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(value, 10, result, sz, false, width, '0');
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::appendHex(std::string& str, unsigned long long value)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(value, 0x10, result, sz);
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::appendHex(std::string& str, unsigned long long value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(value, 0x10, result, sz, false, width, '0');
+ str.append(result, sz);
+}
+
+
+#else // ifndef POCO_LONG_IS_64_BIT
+
+
+void NumberFormatter::append(std::string& str, Int64 value)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ intToStr(value, 10, result, sz);
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::append(std::string& str, Int64 value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ intToStr(value, 10, result, sz, false, width, '0');
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::append0(std::string& str, Int64 value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ intToStr(value, 10, result, sz, false, width, '0');
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::appendHex(std::string& str, Int64 value)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(static_cast<UInt64>(value), 0x10, result, sz);
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::appendHex(std::string& str, Int64 value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(static_cast<UInt64>(value), 0x10, result, sz, false, width, '0');
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::append(std::string& str, UInt64 value)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(value, 10, result, sz);
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::append(std::string& str, UInt64 value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(value, 10, result, sz, false, width, '0');
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::append0(std::string& str, UInt64 value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(value, 10, result, sz, false, width, '0');
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::appendHex(std::string& str, UInt64 value)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(value, 0x10, result, sz);
+ str.append(result, sz);
+}
+
+
+void NumberFormatter::appendHex(std::string& str, UInt64 value, int width)
+{
+ char result[NF_MAX_INT_STRING_LEN];
+ std::size_t sz = NF_MAX_INT_STRING_LEN;
+ uIntToStr(value, 0x10, result, sz, false, width, '0');
+ str.append(result, sz);
+}
+
+
+#endif // ifdef POCO_LONG_IS_64_BIT
+
+#endif // ifdef POCO_HAVE_INT64
+
+
+void NumberFormatter::append(std::string& str, float value)
+{
+ char buffer[NF_MAX_FLT_STRING_LEN];
+ floatToStr(buffer, POCO_MAX_FLT_STRING_LEN, value);
+ str.append(buffer);
+}
+
+
+void NumberFormatter::append(std::string& str, float value, int precision)
+{
+ char buffer[NF_MAX_FLT_STRING_LEN];
+ floatToFixedStr(buffer, POCO_MAX_FLT_STRING_LEN, value, precision);
+ str.append(buffer);
+}
+
+
+void NumberFormatter::append(std::string& str, float value, int width, int precision)
+{
+ std::string result;
+ str.append(floatToFixedStr(result, value, precision, width));
+}
+
+
+void NumberFormatter::append(std::string& str, double value)
+{
+ char buffer[NF_MAX_FLT_STRING_LEN];
+ doubleToStr(buffer, POCO_MAX_FLT_STRING_LEN, value);
+ str.append(buffer);
+}
+
+
+void NumberFormatter::append(std::string& str, double value, int precision)
+{
+ char buffer[NF_MAX_FLT_STRING_LEN];
+ doubleToFixedStr(buffer, POCO_MAX_FLT_STRING_LEN, value, precision);
+ str.append(buffer);
+}
+
+
+void NumberFormatter::append(std::string& str, double value, int width, int precision)
+{
+ std::string result;
+ str.append(doubleToFixedStr(result, value, precision, width));
+}
+
+
+void NumberFormatter::append(std::string& str, const void* ptr)
+{
+ char buffer[24];
+#if defined(POCO_PTR_IS_64_BIT)
+ #if defined(POCO_LONG_IS_64_BIT)
+ std::sprintf(buffer, "%016lX", (UIntPtr) ptr);
+ #else
+ std::sprintf(buffer, "%016" I64_FMT "X", (UIntPtr) ptr);
+ #endif
+#else
+ std::sprintf(buffer, "%08lX", (UIntPtr) ptr);
+#endif
+ str.append(buffer);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/NumberParser.cpp b/contrib/libs/poco/Foundation/src/NumberParser.cpp
index 56eeb16759..014176795a 100644
--- a/contrib/libs/poco/Foundation/src/NumberParser.cpp
+++ b/contrib/libs/poco/Foundation/src/NumberParser.cpp
@@ -1,250 +1,250 @@
-//
-// NumberParser.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: NumberParser
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/NumberParser.h"
-#include "Poco/Exception.h"
-#include "Poco/String.h"
-#include "Poco/NumericString.h"
-#include <cstdio>
-#include <cctype>
-#include <stdlib.h>
-#if !defined(POCO_NO_LOCALE)
- #include <locale>
-#endif
-
-
-#if defined(POCO_LONG_IS_64_BIT)
- #define I64_FMT "l"
-#elif defined(_MSC_VER) || defined(__MINGW32__)
- #define I64_FMT "I64"
-#elif defined(__APPLE__)
- #define I64_FMT "q"
-#else
- #define I64_FMT "ll"
-#endif
-
-
-namespace Poco {
-
-
-int NumberParser::parse(const std::string& s, char thSep)
-{
- int result;
- if (tryParse(s, result, thSep))
- return result;
- else
- throw SyntaxException("Not a valid integer", s);
-}
-
-
-bool NumberParser::tryParse(const std::string& s, int& value, char thSep)
-{
- return strToInt(s.c_str(), value, NUM_BASE_DEC, thSep);
-}
-
-
-unsigned NumberParser::parseUnsigned(const std::string& s, char thSep)
-{
- unsigned result;
- if (tryParseUnsigned(s, result, thSep))
- return result;
- else
- throw SyntaxException("Not a valid unsigned integer", s);
-}
-
-
-bool NumberParser::tryParseUnsigned(const std::string& s, unsigned& value, char thSep)
-{
- return strToInt(s.c_str(), value, NUM_BASE_DEC, thSep);
-}
-
-
-unsigned NumberParser::parseHex(const std::string& s)
-{
- unsigned result;
- if (tryParseHex(s, result))
- return result;
- else
- throw SyntaxException("Not a valid hexadecimal integer", s);
-}
-
-
-bool NumberParser::tryParseHex(const std::string& s, unsigned& value)
-{
- int offset = 0;
- if (s.size() > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) offset = 2;
- return strToInt(s.c_str() + offset, value, NUM_BASE_HEX);
-}
-
-
-unsigned NumberParser::parseOct(const std::string& s)
-{
- unsigned result;
- if (tryParseOct(s, result))
- return result;
- else
- throw SyntaxException("Not a valid hexadecimal integer", s);
-}
-
-
-bool NumberParser::tryParseOct(const std::string& s, unsigned& value)
-{
- return strToInt(s.c_str(), value, NUM_BASE_OCT);
-}
-
-
-#if defined(POCO_HAVE_INT64)
-
-
-Int64 NumberParser::parse64(const std::string& s, char thSep)
-{
- Int64 result;
- if (tryParse64(s, result, thSep))
- return result;
- else
- throw SyntaxException("Not a valid integer", s);
-}
-
-
-bool NumberParser::tryParse64(const std::string& s, Int64& value, char thSep)
-{
- return strToInt(s.c_str(), value, NUM_BASE_DEC, thSep);
-}
-
-
-UInt64 NumberParser::parseUnsigned64(const std::string& s, char thSep)
-{
- UInt64 result;
- if (tryParseUnsigned64(s, result, thSep))
- return result;
- else
- throw SyntaxException("Not a valid unsigned integer", s);
-}
-
-
-bool NumberParser::tryParseUnsigned64(const std::string& s, UInt64& value, char thSep)
-{
- return strToInt(s.c_str(), value, NUM_BASE_DEC, thSep);
-}
-
-
-UInt64 NumberParser::parseHex64(const std::string& s)
-{
- UInt64 result;
- if (tryParseHex64(s, result))
- return result;
- else
- throw SyntaxException("Not a valid hexadecimal integer", s);
-}
-
-
-bool NumberParser::tryParseHex64(const std::string& s, UInt64& value)
-{
- int offset = 0;
- if (s.size() > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) offset = 2;
- return strToInt(s.c_str() + offset, value, NUM_BASE_HEX);
-}
-
-
-UInt64 NumberParser::parseOct64(const std::string& s)
-{
- UInt64 result;
- if (tryParseOct64(s, result))
- return result;
- else
- throw SyntaxException("Not a valid hexadecimal integer", s);
-}
-
-
-bool NumberParser::tryParseOct64(const std::string& s, UInt64& value)
-{
- return strToInt(s.c_str(), value, NUM_BASE_OCT);
-}
-
-
-#endif // defined(POCO_HAVE_INT64)
-
-
-double NumberParser::parseFloat(const std::string& s, char decSep, char thSep)
-{
- double result;
- if (tryParseFloat(s, result, decSep, thSep))
- return result;
- else
- throw SyntaxException("Not a valid floating-point number", s);
-}
-
-
-bool NumberParser::tryParseFloat(const std::string& s, double& value, char decSep, char thSep)
-{
- return strToDouble(s.c_str(), value, decSep, thSep);
-}
-
-
-bool NumberParser::parseBool(const std::string& s)
-{
- bool result;
- if (tryParseBool(s, result))
- return result;
- else
- throw SyntaxException("Not a valid bool number", s);
-}
-
-
-bool NumberParser::tryParseBool(const std::string& s, bool& value)
-{
- int n;
- if (NumberParser::tryParse(s, n))
- {
- value = (n != 0);
- return true;
- }
-
- if (icompare(s, "true") == 0)
- {
- value = true;
- return true;
- }
- else if (icompare(s, "yes") == 0)
- {
- value = true;
- return true;
- }
- else if (icompare(s, "on") == 0)
- {
- value = true;
- return true;
- }
-
- if (icompare(s, "false") == 0)
- {
- value = false;
- return true;
- }
- else if (icompare(s, "no") == 0)
- {
- value = false;
- return true;
- }
- else if (icompare(s, "off") == 0)
- {
- value = false;
- return true;
- }
-
- return false;
-}
-
-
-} // namespace Poco
+//
+// NumberParser.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: NumberParser
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/NumberParser.h"
+#include "Poco/Exception.h"
+#include "Poco/String.h"
+#include "Poco/NumericString.h"
+#include <cstdio>
+#include <cctype>
+#include <stdlib.h>
+#if !defined(POCO_NO_LOCALE)
+ #include <locale>
+#endif
+
+
+#if defined(POCO_LONG_IS_64_BIT)
+ #define I64_FMT "l"
+#elif defined(_MSC_VER) || defined(__MINGW32__)
+ #define I64_FMT "I64"
+#elif defined(__APPLE__)
+ #define I64_FMT "q"
+#else
+ #define I64_FMT "ll"
+#endif
+
+
+namespace Poco {
+
+
+int NumberParser::parse(const std::string& s, char thSep)
+{
+ int result;
+ if (tryParse(s, result, thSep))
+ return result;
+ else
+ throw SyntaxException("Not a valid integer", s);
+}
+
+
+bool NumberParser::tryParse(const std::string& s, int& value, char thSep)
+{
+ return strToInt(s.c_str(), value, NUM_BASE_DEC, thSep);
+}
+
+
+unsigned NumberParser::parseUnsigned(const std::string& s, char thSep)
+{
+ unsigned result;
+ if (tryParseUnsigned(s, result, thSep))
+ return result;
+ else
+ throw SyntaxException("Not a valid unsigned integer", s);
+}
+
+
+bool NumberParser::tryParseUnsigned(const std::string& s, unsigned& value, char thSep)
+{
+ return strToInt(s.c_str(), value, NUM_BASE_DEC, thSep);
+}
+
+
+unsigned NumberParser::parseHex(const std::string& s)
+{
+ unsigned result;
+ if (tryParseHex(s, result))
+ return result;
+ else
+ throw SyntaxException("Not a valid hexadecimal integer", s);
+}
+
+
+bool NumberParser::tryParseHex(const std::string& s, unsigned& value)
+{
+ int offset = 0;
+ if (s.size() > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) offset = 2;
+ return strToInt(s.c_str() + offset, value, NUM_BASE_HEX);
+}
+
+
+unsigned NumberParser::parseOct(const std::string& s)
+{
+ unsigned result;
+ if (tryParseOct(s, result))
+ return result;
+ else
+ throw SyntaxException("Not a valid hexadecimal integer", s);
+}
+
+
+bool NumberParser::tryParseOct(const std::string& s, unsigned& value)
+{
+ return strToInt(s.c_str(), value, NUM_BASE_OCT);
+}
+
+
+#if defined(POCO_HAVE_INT64)
+
+
+Int64 NumberParser::parse64(const std::string& s, char thSep)
+{
+ Int64 result;
+ if (tryParse64(s, result, thSep))
+ return result;
+ else
+ throw SyntaxException("Not a valid integer", s);
+}
+
+
+bool NumberParser::tryParse64(const std::string& s, Int64& value, char thSep)
+{
+ return strToInt(s.c_str(), value, NUM_BASE_DEC, thSep);
+}
+
+
+UInt64 NumberParser::parseUnsigned64(const std::string& s, char thSep)
+{
+ UInt64 result;
+ if (tryParseUnsigned64(s, result, thSep))
+ return result;
+ else
+ throw SyntaxException("Not a valid unsigned integer", s);
+}
+
+
+bool NumberParser::tryParseUnsigned64(const std::string& s, UInt64& value, char thSep)
+{
+ return strToInt(s.c_str(), value, NUM_BASE_DEC, thSep);
+}
+
+
+UInt64 NumberParser::parseHex64(const std::string& s)
+{
+ UInt64 result;
+ if (tryParseHex64(s, result))
+ return result;
+ else
+ throw SyntaxException("Not a valid hexadecimal integer", s);
+}
+
+
+bool NumberParser::tryParseHex64(const std::string& s, UInt64& value)
+{
+ int offset = 0;
+ if (s.size() > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) offset = 2;
+ return strToInt(s.c_str() + offset, value, NUM_BASE_HEX);
+}
+
+
+UInt64 NumberParser::parseOct64(const std::string& s)
+{
+ UInt64 result;
+ if (tryParseOct64(s, result))
+ return result;
+ else
+ throw SyntaxException("Not a valid hexadecimal integer", s);
+}
+
+
+bool NumberParser::tryParseOct64(const std::string& s, UInt64& value)
+{
+ return strToInt(s.c_str(), value, NUM_BASE_OCT);
+}
+
+
+#endif // defined(POCO_HAVE_INT64)
+
+
+double NumberParser::parseFloat(const std::string& s, char decSep, char thSep)
+{
+ double result;
+ if (tryParseFloat(s, result, decSep, thSep))
+ return result;
+ else
+ throw SyntaxException("Not a valid floating-point number", s);
+}
+
+
+bool NumberParser::tryParseFloat(const std::string& s, double& value, char decSep, char thSep)
+{
+ return strToDouble(s.c_str(), value, decSep, thSep);
+}
+
+
+bool NumberParser::parseBool(const std::string& s)
+{
+ bool result;
+ if (tryParseBool(s, result))
+ return result;
+ else
+ throw SyntaxException("Not a valid bool number", s);
+}
+
+
+bool NumberParser::tryParseBool(const std::string& s, bool& value)
+{
+ int n;
+ if (NumberParser::tryParse(s, n))
+ {
+ value = (n != 0);
+ return true;
+ }
+
+ if (icompare(s, "true") == 0)
+ {
+ value = true;
+ return true;
+ }
+ else if (icompare(s, "yes") == 0)
+ {
+ value = true;
+ return true;
+ }
+ else if (icompare(s, "on") == 0)
+ {
+ value = true;
+ return true;
+ }
+
+ if (icompare(s, "false") == 0)
+ {
+ value = false;
+ return true;
+ }
+ else if (icompare(s, "no") == 0)
+ {
+ value = false;
+ return true;
+ }
+ else if (icompare(s, "off") == 0)
+ {
+ value = false;
+ return true;
+ }
+
+ return false;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/NumericString.cpp b/contrib/libs/poco/Foundation/src/NumericString.cpp
index f047c5db72..02171ab7cf 100644
--- a/contrib/libs/poco/Foundation/src/NumericString.cpp
+++ b/contrib/libs/poco/Foundation/src/NumericString.cpp
@@ -1,320 +1,320 @@
-//
-// NumericString.h
-//
-// Library: Foundation
-// Package: Core
-// Module: NumericString
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/NumericString.h"
-
-
-#if defined(POCO_UNBUNDLED)
-#include <double-conversion/double-conversion.h>
-#include <double-conversion/ieee.h>
-#else
-#include "Poco/Bugcheck.h"
-// +++ double conversion +++
-#define UNREACHABLE poco_bugcheck
-#define UNIMPLEMENTED poco_bugcheck
-#error #include "diy-fp.cc"
-#error #include "cached-powers.cc"
-#error #include "bignum-dtoa.cc"
-#error #include "bignum.cc"
-#error #include "fast-dtoa.cc"
-#error #include "fixed-dtoa.cc"
-#error #include "strtod.cc"
-#error #include "double-conversion.cc"
-// --- double conversion ---
-poco_static_assert(POCO_MAX_FLT_STRING_LEN == double_conversion::kMaxSignificantDecimalDigits);
-#endif
-
-#include "Poco/String.h"
-#include <memory>
-#include <cctype>
-
-
-namespace {
-
-
-void pad(std::string& str, int precision, int width, char prefix = ' ', char decSep = '.')
- /// Pads the string with prefix space and postfix 0.
- /// Alternative prefix (e.g. zero instead of space) can be supplied by caller.
- /// Used only internally.
-{
- // these cases should never happen, if they do, it's a library bug
- poco_assert_dbg (precision > 0);
- poco_assert_dbg (str.length());
-
- std::string::size_type decSepPos = str.find(decSep);
- if (decSepPos == std::string::npos)
- {
- str.append(1, '.');
- decSepPos = str.size() - 1;
- }
-
- std::string::size_type frac = str.length() - decSepPos - 1;
-
- std::string::size_type ePos = str.find_first_of("eE");
-#ifndef POCO_ENABLE_CPP11
- std::auto_ptr<std::string> eStr;
-#else
- std::unique_ptr<std::string> eStr;
-#endif // POCO_ENABLE_CPP11
- if (ePos != std::string::npos)
- {
- eStr.reset(new std::string(str.substr(ePos, std::string::npos)));
- frac -= eStr->length();
- str = str.substr(0, str.length() - eStr->length());
- }
-
- if (frac != precision)
- {
- if (frac < precision)
- str.append(precision - frac, '0');
- else if ((frac > precision) && (decSepPos != std::string::npos))
- str = str.substr(0, decSepPos + 1 + precision);
- }
-
- if (eStr.get()) str += *eStr;
-
- if (width && (str.length() < width)) str.insert(str.begin(), width - str.length(), prefix);
-}
-
-
-void insertThousandSep(std::string& str, char thSep, char decSep = '.')
- /// Inserts thousand separators.
- /// Used only internally.
-{
- poco_assert (decSep != thSep);
- if (str.size() == 0) return;
-
- std::string::size_type exPos = str.find('e');
- if (exPos == std::string::npos) exPos = str.find('E');
- std::string::size_type decPos = str.find(decSep);
- // there's no rinsert, using forward iterator to go backwards
- std::string::iterator it = str.end();
- if (exPos != std::string::npos) it -= str.size() - exPos;
-
- if (decPos != std::string::npos)
- {
- while (it != str.begin())
- {
- --it;
- if (*it == decSep) break;
- }
- }
- int thCount = 0;
- if (it == str.end()) --it;
- for (; it != str.begin();)
- {
- std::string::iterator pos = it;
- std::string::value_type chr = *it;
- std::string::value_type prevChr = *--it;
-
- if (!std::isdigit(chr)) continue;
-
- if (++thCount == 3 && std::isdigit(prevChr))
- it = str.insert(pos, thSep);
-
- if (thCount == 3) thCount = 0;
- }
-}
-
-
-} // namespace
-
-
-namespace Poco {
-
-
-void floatToStr(char* buffer, int bufferSize, float value, int lowDec, int highDec)
-{
- using namespace double_conversion;
-
- StringBuilder builder(buffer, bufferSize);
- int flags = DoubleToStringConverter::UNIQUE_ZERO |
- DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN;
- DoubleToStringConverter dc(flags, POCO_FLT_INF, POCO_FLT_NAN, POCO_FLT_EXP, lowDec, highDec, 0, 0);
- dc.ToShortestSingle(value, &builder);
- builder.Finalize();
-}
-
-
-void floatToFixedStr(char* buffer, int bufferSize, float value, int precision)
-{
- using namespace double_conversion;
-
- StringBuilder builder(buffer, bufferSize);
- int flags = DoubleToStringConverter::UNIQUE_ZERO |
- DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN;
- DoubleToStringConverter dc(flags, POCO_FLT_INF, POCO_FLT_NAN, POCO_FLT_EXP, -std::numeric_limits<float>::digits10, std::numeric_limits<float>::digits10, 0, 0);
- dc.ToFixed(value, precision, &builder);
- builder.Finalize();
-}
-
-
-std::string& floatToStr(std::string& str, float value, int precision, int width, char thSep, char decSep)
-{
- if (!decSep) decSep = '.';
- if (precision == 0) value = std::floor(value);
-
- char buffer[POCO_MAX_FLT_STRING_LEN];
- floatToStr(buffer, POCO_MAX_FLT_STRING_LEN, value);
- str = buffer;
-
- if (decSep && (decSep != '.') && (str.find('.') != std::string::npos))
- replaceInPlace(str, '.', decSep);
-
- if (thSep) insertThousandSep(str, thSep, decSep);
- if (precision > 0 || width) pad(str, precision, width, ' ', decSep ? decSep : '.');
- return str;
-}
-
-
-std::string& floatToFixedStr(std::string& str, float value, int precision, int width, char thSep, char decSep)
-{
- if (!decSep) decSep = '.';
- if (precision == 0) value = std::floor(value);
-
- char buffer[POCO_MAX_FLT_STRING_LEN];
- floatToFixedStr(buffer, POCO_MAX_FLT_STRING_LEN, value, precision);
- str = buffer;
-
- if (decSep && (decSep != '.') && (str.find('.') != std::string::npos))
- replaceInPlace(str, '.', decSep);
-
- if (thSep) insertThousandSep(str, thSep, decSep);
- if (precision > 0 || width) pad(str, precision, width, ' ', decSep ? decSep : '.');
- return str;
-}
-
-
-void doubleToStr(char* buffer, int bufferSize, double value, int lowDec, int highDec)
-{
- using namespace double_conversion;
-
- StringBuilder builder(buffer, bufferSize);
- int flags = DoubleToStringConverter::UNIQUE_ZERO |
- DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN;
- DoubleToStringConverter dc(flags, POCO_FLT_INF, POCO_FLT_NAN, POCO_FLT_EXP, lowDec, highDec, 0, 0);
- dc.ToShortest(value, &builder);
- builder.Finalize();
-}
-
-
-void doubleToFixedStr(char* buffer, int bufferSize, double value, int precision)
-{
- using namespace double_conversion;
-
- StringBuilder builder(buffer, bufferSize);
- int flags = DoubleToStringConverter::UNIQUE_ZERO |
- DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN;
- DoubleToStringConverter dc(flags, POCO_FLT_INF, POCO_FLT_NAN, POCO_FLT_EXP, -std::numeric_limits<double>::digits10, std::numeric_limits<double>::digits10, 0, 0);
- dc.ToFixed(value, precision, &builder);
- builder.Finalize();
-}
-
-
-std::string& doubleToStr(std::string& str, double value, int precision, int width, char thSep, char decSep)
-{
- if (!decSep) decSep = '.';
- if (precision == 0) value = std::floor(value);
-
- char buffer[POCO_MAX_FLT_STRING_LEN];
- doubleToStr(buffer, POCO_MAX_FLT_STRING_LEN, value);
-
- str = buffer;
-
- if (decSep && (decSep != '.') && (str.find('.') != std::string::npos))
- replaceInPlace(str, '.', decSep);
-
- if (thSep) insertThousandSep(str, thSep, decSep);
- if (precision > 0 || width) pad(str, precision, width, ' ', decSep ? decSep : '.');
- return str;
-}
-
-
-std::string& doubleToFixedStr(std::string& str, double value, int precision, int width, char thSep, char decSep)
-{
- if (!decSep) decSep = '.';
- if (precision == 0) value = std::floor(value);
-
- char buffer[POCO_MAX_FLT_STRING_LEN];
- doubleToFixedStr(buffer, POCO_MAX_FLT_STRING_LEN, value, precision);
-
- str = buffer;
-
- if (decSep && (decSep != '.') && (str.find('.') != std::string::npos))
- replaceInPlace(str, '.', decSep);
-
- if (thSep) insertThousandSep(str, thSep, decSep);
- if (precision > 0 || width) pad(str, precision, width, ' ', decSep ? decSep : '.');
- return str;
-}
-
-
-float strToFloat(const char* str)
-{
- using namespace double_conversion;
-
- int processed;
- int flags = StringToDoubleConverter::ALLOW_LEADING_SPACES |
- StringToDoubleConverter::ALLOW_TRAILING_SPACES;
- StringToDoubleConverter converter(flags, 0.0, Single::NaN(), POCO_FLT_INF, POCO_FLT_NAN);
- float result = converter.StringToFloat(str, static_cast<int>(strlen(str)), &processed);
- return result;
-}
-
-
-double strToDouble(const char* str)
-{
- using namespace double_conversion;
- int processed;
- int flags = StringToDoubleConverter::ALLOW_LEADING_SPACES |
- StringToDoubleConverter::ALLOW_TRAILING_SPACES;
- StringToDoubleConverter converter(flags, 0.0, Double::NaN(), POCO_FLT_INF, POCO_FLT_NAN);
- double result = converter.StringToDouble(str, static_cast<int>(strlen(str)), &processed);
- return result;
-}
-
-
-bool strToFloat(const std::string& str, float& result, char decSep, char thSep)
-{
- using namespace double_conversion;
-
- std::string tmp(str);
- trimInPlace(tmp);
- removeInPlace(tmp, thSep);
- removeInPlace(tmp, 'f');
- replaceInPlace(tmp, decSep, '.');
- result = strToFloat(tmp.c_str());
- return !FPEnvironment::isInfinite(result) &&
- !FPEnvironment::isNaN(result);
-}
-
-
-bool strToDouble(const std::string& str, double& result, char decSep, char thSep)
-{
- if (str.empty()) return false;
-
- using namespace double_conversion;
-
- std::string tmp(str);
- trimInPlace(tmp);
- removeInPlace(tmp, thSep);
- replaceInPlace(tmp, decSep, '.');
- removeInPlace(tmp, 'f');
- result = strToDouble(tmp.c_str());
- return !FPEnvironment::isInfinite(result) &&
- !FPEnvironment::isNaN(result);
-}
-
-
-} // namespace Poco
+//
+// NumericString.h
+//
+// Library: Foundation
+// Package: Core
+// Module: NumericString
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/NumericString.h"
+
+
+#if defined(POCO_UNBUNDLED)
+#include <double-conversion/double-conversion.h>
+#include <double-conversion/ieee.h>
+#else
+#include "Poco/Bugcheck.h"
+// +++ double conversion +++
+#define UNREACHABLE poco_bugcheck
+#define UNIMPLEMENTED poco_bugcheck
+#error #include "diy-fp.cc"
+#error #include "cached-powers.cc"
+#error #include "bignum-dtoa.cc"
+#error #include "bignum.cc"
+#error #include "fast-dtoa.cc"
+#error #include "fixed-dtoa.cc"
+#error #include "strtod.cc"
+#error #include "double-conversion.cc"
+// --- double conversion ---
+poco_static_assert(POCO_MAX_FLT_STRING_LEN == double_conversion::kMaxSignificantDecimalDigits);
+#endif
+
+#include "Poco/String.h"
+#include <memory>
+#include <cctype>
+
+
+namespace {
+
+
+void pad(std::string& str, int precision, int width, char prefix = ' ', char decSep = '.')
+ /// Pads the string with prefix space and postfix 0.
+ /// Alternative prefix (e.g. zero instead of space) can be supplied by caller.
+ /// Used only internally.
+{
+ // these cases should never happen, if they do, it's a library bug
+ poco_assert_dbg (precision > 0);
+ poco_assert_dbg (str.length());
+
+ std::string::size_type decSepPos = str.find(decSep);
+ if (decSepPos == std::string::npos)
+ {
+ str.append(1, '.');
+ decSepPos = str.size() - 1;
+ }
+
+ std::string::size_type frac = str.length() - decSepPos - 1;
+
+ std::string::size_type ePos = str.find_first_of("eE");
+#ifndef POCO_ENABLE_CPP11
+ std::auto_ptr<std::string> eStr;
+#else
+ std::unique_ptr<std::string> eStr;
+#endif // POCO_ENABLE_CPP11
+ if (ePos != std::string::npos)
+ {
+ eStr.reset(new std::string(str.substr(ePos, std::string::npos)));
+ frac -= eStr->length();
+ str = str.substr(0, str.length() - eStr->length());
+ }
+
+ if (frac != precision)
+ {
+ if (frac < precision)
+ str.append(precision - frac, '0');
+ else if ((frac > precision) && (decSepPos != std::string::npos))
+ str = str.substr(0, decSepPos + 1 + precision);
+ }
+
+ if (eStr.get()) str += *eStr;
+
+ if (width && (str.length() < width)) str.insert(str.begin(), width - str.length(), prefix);
+}
+
+
+void insertThousandSep(std::string& str, char thSep, char decSep = '.')
+ /// Inserts thousand separators.
+ /// Used only internally.
+{
+ poco_assert (decSep != thSep);
+ if (str.size() == 0) return;
+
+ std::string::size_type exPos = str.find('e');
+ if (exPos == std::string::npos) exPos = str.find('E');
+ std::string::size_type decPos = str.find(decSep);
+ // there's no rinsert, using forward iterator to go backwards
+ std::string::iterator it = str.end();
+ if (exPos != std::string::npos) it -= str.size() - exPos;
+
+ if (decPos != std::string::npos)
+ {
+ while (it != str.begin())
+ {
+ --it;
+ if (*it == decSep) break;
+ }
+ }
+ int thCount = 0;
+ if (it == str.end()) --it;
+ for (; it != str.begin();)
+ {
+ std::string::iterator pos = it;
+ std::string::value_type chr = *it;
+ std::string::value_type prevChr = *--it;
+
+ if (!std::isdigit(chr)) continue;
+
+ if (++thCount == 3 && std::isdigit(prevChr))
+ it = str.insert(pos, thSep);
+
+ if (thCount == 3) thCount = 0;
+ }
+}
+
+
+} // namespace
+
+
+namespace Poco {
+
+
+void floatToStr(char* buffer, int bufferSize, float value, int lowDec, int highDec)
+{
+ using namespace double_conversion;
+
+ StringBuilder builder(buffer, bufferSize);
+ int flags = DoubleToStringConverter::UNIQUE_ZERO |
+ DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN;
+ DoubleToStringConverter dc(flags, POCO_FLT_INF, POCO_FLT_NAN, POCO_FLT_EXP, lowDec, highDec, 0, 0);
+ dc.ToShortestSingle(value, &builder);
+ builder.Finalize();
+}
+
+
+void floatToFixedStr(char* buffer, int bufferSize, float value, int precision)
+{
+ using namespace double_conversion;
+
+ StringBuilder builder(buffer, bufferSize);
+ int flags = DoubleToStringConverter::UNIQUE_ZERO |
+ DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN;
+ DoubleToStringConverter dc(flags, POCO_FLT_INF, POCO_FLT_NAN, POCO_FLT_EXP, -std::numeric_limits<float>::digits10, std::numeric_limits<float>::digits10, 0, 0);
+ dc.ToFixed(value, precision, &builder);
+ builder.Finalize();
+}
+
+
+std::string& floatToStr(std::string& str, float value, int precision, int width, char thSep, char decSep)
+{
+ if (!decSep) decSep = '.';
+ if (precision == 0) value = std::floor(value);
+
+ char buffer[POCO_MAX_FLT_STRING_LEN];
+ floatToStr(buffer, POCO_MAX_FLT_STRING_LEN, value);
+ str = buffer;
+
+ if (decSep && (decSep != '.') && (str.find('.') != std::string::npos))
+ replaceInPlace(str, '.', decSep);
+
+ if (thSep) insertThousandSep(str, thSep, decSep);
+ if (precision > 0 || width) pad(str, precision, width, ' ', decSep ? decSep : '.');
+ return str;
+}
+
+
+std::string& floatToFixedStr(std::string& str, float value, int precision, int width, char thSep, char decSep)
+{
+ if (!decSep) decSep = '.';
+ if (precision == 0) value = std::floor(value);
+
+ char buffer[POCO_MAX_FLT_STRING_LEN];
+ floatToFixedStr(buffer, POCO_MAX_FLT_STRING_LEN, value, precision);
+ str = buffer;
+
+ if (decSep && (decSep != '.') && (str.find('.') != std::string::npos))
+ replaceInPlace(str, '.', decSep);
+
+ if (thSep) insertThousandSep(str, thSep, decSep);
+ if (precision > 0 || width) pad(str, precision, width, ' ', decSep ? decSep : '.');
+ return str;
+}
+
+
+void doubleToStr(char* buffer, int bufferSize, double value, int lowDec, int highDec)
+{
+ using namespace double_conversion;
+
+ StringBuilder builder(buffer, bufferSize);
+ int flags = DoubleToStringConverter::UNIQUE_ZERO |
+ DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN;
+ DoubleToStringConverter dc(flags, POCO_FLT_INF, POCO_FLT_NAN, POCO_FLT_EXP, lowDec, highDec, 0, 0);
+ dc.ToShortest(value, &builder);
+ builder.Finalize();
+}
+
+
+void doubleToFixedStr(char* buffer, int bufferSize, double value, int precision)
+{
+ using namespace double_conversion;
+
+ StringBuilder builder(buffer, bufferSize);
+ int flags = DoubleToStringConverter::UNIQUE_ZERO |
+ DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN;
+ DoubleToStringConverter dc(flags, POCO_FLT_INF, POCO_FLT_NAN, POCO_FLT_EXP, -std::numeric_limits<double>::digits10, std::numeric_limits<double>::digits10, 0, 0);
+ dc.ToFixed(value, precision, &builder);
+ builder.Finalize();
+}
+
+
+std::string& doubleToStr(std::string& str, double value, int precision, int width, char thSep, char decSep)
+{
+ if (!decSep) decSep = '.';
+ if (precision == 0) value = std::floor(value);
+
+ char buffer[POCO_MAX_FLT_STRING_LEN];
+ doubleToStr(buffer, POCO_MAX_FLT_STRING_LEN, value);
+
+ str = buffer;
+
+ if (decSep && (decSep != '.') && (str.find('.') != std::string::npos))
+ replaceInPlace(str, '.', decSep);
+
+ if (thSep) insertThousandSep(str, thSep, decSep);
+ if (precision > 0 || width) pad(str, precision, width, ' ', decSep ? decSep : '.');
+ return str;
+}
+
+
+std::string& doubleToFixedStr(std::string& str, double value, int precision, int width, char thSep, char decSep)
+{
+ if (!decSep) decSep = '.';
+ if (precision == 0) value = std::floor(value);
+
+ char buffer[POCO_MAX_FLT_STRING_LEN];
+ doubleToFixedStr(buffer, POCO_MAX_FLT_STRING_LEN, value, precision);
+
+ str = buffer;
+
+ if (decSep && (decSep != '.') && (str.find('.') != std::string::npos))
+ replaceInPlace(str, '.', decSep);
+
+ if (thSep) insertThousandSep(str, thSep, decSep);
+ if (precision > 0 || width) pad(str, precision, width, ' ', decSep ? decSep : '.');
+ return str;
+}
+
+
+float strToFloat(const char* str)
+{
+ using namespace double_conversion;
+
+ int processed;
+ int flags = StringToDoubleConverter::ALLOW_LEADING_SPACES |
+ StringToDoubleConverter::ALLOW_TRAILING_SPACES;
+ StringToDoubleConverter converter(flags, 0.0, Single::NaN(), POCO_FLT_INF, POCO_FLT_NAN);
+ float result = converter.StringToFloat(str, static_cast<int>(strlen(str)), &processed);
+ return result;
+}
+
+
+double strToDouble(const char* str)
+{
+ using namespace double_conversion;
+ int processed;
+ int flags = StringToDoubleConverter::ALLOW_LEADING_SPACES |
+ StringToDoubleConverter::ALLOW_TRAILING_SPACES;
+ StringToDoubleConverter converter(flags, 0.0, Double::NaN(), POCO_FLT_INF, POCO_FLT_NAN);
+ double result = converter.StringToDouble(str, static_cast<int>(strlen(str)), &processed);
+ return result;
+}
+
+
+bool strToFloat(const std::string& str, float& result, char decSep, char thSep)
+{
+ using namespace double_conversion;
+
+ std::string tmp(str);
+ trimInPlace(tmp);
+ removeInPlace(tmp, thSep);
+ removeInPlace(tmp, 'f');
+ replaceInPlace(tmp, decSep, '.');
+ result = strToFloat(tmp.c_str());
+ return !FPEnvironment::isInfinite(result) &&
+ !FPEnvironment::isNaN(result);
+}
+
+
+bool strToDouble(const std::string& str, double& result, char decSep, char thSep)
+{
+ if (str.empty()) return false;
+
+ using namespace double_conversion;
+
+ std::string tmp(str);
+ trimInPlace(tmp);
+ removeInPlace(tmp, thSep);
+ replaceInPlace(tmp, decSep, '.');
+ removeInPlace(tmp, 'f');
+ result = strToDouble(tmp.c_str());
+ return !FPEnvironment::isInfinite(result) &&
+ !FPEnvironment::isNaN(result);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Path.cpp b/contrib/libs/poco/Foundation/src/Path.cpp
index 6f15372979..c008ca3c42 100644
--- a/contrib/libs/poco/Foundation/src/Path.cpp
+++ b/contrib/libs/poco/Foundation/src/Path.cpp
@@ -1,1064 +1,1064 @@
-//
-// Path.cpp
-//
-// Library: Foundation
-// Package: Filesystem
-// Module: Path
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Path.h"
-#include "Poco/File.h"
-#include "Poco/Exception.h"
-#include "Poco/StringTokenizer.h"
-#if defined(_WIN32) && defined(POCO_WIN32_UTF8)
-#include "Poco/UnicodeConverter.h"
-#include "Poco/Buffer.h"
-#endif
-#include <algorithm>
-
-
-#if defined(POCO_OS_FAMILY_UNIX)
-#include "Path_UNIX.cpp"
-#elif defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
-#if defined(_WIN32_WCE)
-#include "Path_WINCE.cpp"
-#else
-#include "Path_WIN32U.cpp"
-#endif
-#elif defined(POCO_OS_FAMILY_WINDOWS)
-#include "Path_WIN32.cpp"
-#endif
-
-
-namespace Poco {
-
-
-Path::Path(): _absolute(false)
-{
-}
-
-
-Path::Path(bool absolutePath): _absolute(absolutePath)
-{
-}
-
-
-Path::Path(const std::string& path)
-{
- assign(path);
-}
-
-
-Path::Path(const std::string& path, Style style)
-{
- assign(path, style);
-}
-
-
-Path::Path(const char* path)
-{
- poco_check_ptr(path);
- assign(path);
-}
-
-
-Path::Path(const char* path, Style style)
-{
- poco_check_ptr(path);
- assign(path, style);
-}
-
-
-Path::Path(const Path& path):
- _node(path._node),
- _device(path._device),
- _name(path._name),
- _version(path._version),
- _dirs(path._dirs),
- _absolute(path._absolute)
-{
-}
-
-
-Path::Path(const Path& rParent, const std::string& fileName):
- _node(rParent._node),
- _device(rParent._device),
- _name(rParent._name),
- _version(rParent._version),
- _dirs(rParent._dirs),
- _absolute(rParent._absolute)
-{
- makeDirectory();
- _name = fileName;
-}
-
-
-Path::Path(const Path& rParent, const char* fileName):
- _node(rParent._node),
- _device(rParent._device),
- _name(rParent._name),
- _version(rParent._version),
- _dirs(rParent._dirs),
- _absolute(rParent._absolute)
-{
- makeDirectory();
- _name = fileName;
-}
-
-
-Path::Path(const Path& rParent, const Path& relative):
- _node(rParent._node),
- _device(rParent._device),
- _name(rParent._name),
- _version(rParent._version),
- _dirs(rParent._dirs),
- _absolute(rParent._absolute)
-{
- resolve(relative);
-}
-
-
-Path::~Path()
-{
-}
-
-
-Path& Path::operator = (const Path& path)
-{
- return assign(path);
-}
-
-
-Path& Path::operator = (const std::string& path)
-{
- return assign(path);
-}
-
-
-Path& Path::operator = (const char* path)
-{
- poco_check_ptr(path);
- return assign(path);
-}
-
-
-void Path::swap(Path& path)
-{
- std::swap(_node, path._node);
- std::swap(_device, path._device);
- std::swap(_name, path._name);
- std::swap(_version, path._version);
- std::swap(_dirs, path._dirs);
- std::swap(_absolute, path._absolute);
-}
-
-
-Path& Path::assign(const Path& path)
-{
- if (&path != this)
- {
- _node = path._node;
- _device = path._device;
- _name = path._name;
- _version = path._version;
- _dirs = path._dirs;
- _absolute = path._absolute;
- }
- return *this;
-}
-
-
-Path& Path::assign(const std::string& path)
-{
-#if defined(POCO_OS_FAMILY_WINDOWS)
- parseWindows(path);
-#else
- parseUnix(path);
-#endif
- return *this;
-}
-
-
-Path& Path::assign(const std::string& path, Style style)
-{
- switch (style)
- {
- case PATH_UNIX:
- parseUnix(path);
- break;
- case PATH_WINDOWS:
- parseWindows(path);
- break;
- case PATH_VMS:
- parseVMS(path);
- break;
- case PATH_NATIVE:
- assign(path);
- break;
- case PATH_GUESS:
- parseGuess(path);
- break;
- default:
- poco_bugcheck();
- }
- return *this;
-}
-
-
-Path& Path::assign(const char* path)
-{
- return assign(std::string(path));
-}
-
-
-std::string Path::toString() const
-{
-#if defined(POCO_OS_FAMILY_WINDOWS)
- return buildWindows();
-#else
- return buildUnix();
-#endif
-}
-
-
-std::string Path::toString(Style style) const
-{
- switch (style)
- {
- case PATH_UNIX:
- return buildUnix();
- case PATH_WINDOWS:
- return buildWindows();
- case PATH_VMS:
- return buildVMS();
- case PATH_NATIVE:
- case PATH_GUESS:
- return toString();
- default:
- poco_bugcheck();
- }
- return std::string();
-}
-
-
-bool Path::tryParse(const std::string& path)
-{
- try
- {
- Path p;
- p.parse(path);
- assign(p);
- return true;
- }
- catch (...)
- {
- return false;
- }
-}
-
-
-bool Path::tryParse(const std::string& path, Style style)
-{
- try
- {
- Path p;
- p.parse(path, style);
- assign(p);
- return true;
- }
- catch (...)
- {
- return false;
- }
-}
-
-
-Path& Path::parseDirectory(const std::string& path)
-{
- assign(path);
- return makeDirectory();
-}
-
-
-Path& Path::parseDirectory(const std::string& path, Style style)
-{
- assign(path, style);
- return makeDirectory();
-}
-
-
-Path& Path::makeDirectory()
-{
- pushDirectory(_name);
- _name.clear();
- _version.clear();
- return *this;
-}
-
-
-Path& Path::makeFile()
-{
- if (!_dirs.empty() && _name.empty())
- {
- _name = _dirs.back();
- _dirs.pop_back();
- }
- return *this;
-}
-
-
-Path& Path::makeAbsolute()
-{
- return makeAbsolute(current());
-}
-
-
-Path& Path::makeAbsolute(const Path& base)
-{
- if (!_absolute)
- {
- Path tmp = base;
- tmp.makeDirectory();
- for (StringVec::const_iterator it = _dirs.begin(); it != _dirs.end(); ++it)
- {
- tmp.pushDirectory(*it);
- }
- _node = tmp._node;
- _device = tmp._device;
- _dirs = tmp._dirs;
- _absolute = base._absolute;
- }
- return *this;
-}
-
-
-Path Path::absolute() const
-{
- Path result(*this);
- if (!result._absolute)
- {
- result.makeAbsolute();
- }
- return result;
-}
-
-
-Path Path::absolute(const Path& base) const
-{
- Path result(*this);
- if (!result._absolute)
- {
- result.makeAbsolute(base);
- }
- return result;
-}
-
-
-Path Path::parent() const
-{
- Path p(*this);
- return p.makeParent();
-}
-
-
-Path& Path::makeParent()
-{
- if (_name.empty())
- {
- if (_dirs.empty())
- {
- if (!_absolute)
- _dirs.push_back("..");
- }
- else
- {
- if (_dirs.back() == "..")
- _dirs.push_back("..");
- else
- _dirs.pop_back();
- }
- }
- else
- {
- _name.clear();
- _version.clear();
- }
- return *this;
-}
-
-
-Path& Path::append(const Path& path)
-{
- makeDirectory();
- _dirs.insert(_dirs.end(), path._dirs.begin(), path._dirs.end());
- _name = path._name;
- _version = path._version;
- return *this;
-}
-
-
-Path& Path::resolve(const Path& path)
-{
- if (path.isAbsolute())
- {
- assign(path);
- }
- else
- {
- for (int i = 0; i < path.depth(); ++i)
- pushDirectory(path[i]);
- _name = path._name;
- }
- return *this;
-}
-
-
-Path& Path::setNode(const std::string& node)
-{
- _node = node;
- _absolute = _absolute || !node.empty();
- return *this;
-}
-
-
-Path& Path::setDevice(const std::string& device)
-{
- _device = device;
- _absolute = _absolute || !device.empty();
- return *this;
-}
-
-
-const std::string& Path::directory(int n) const
-{
- poco_assert (0 <= n && n <= _dirs.size());
-
- if (n < _dirs.size())
- return _dirs[n];
- else
- return _name;
-}
-
-
-const std::string& Path::operator [] (int n) const
-{
- poco_assert (0 <= n && n <= _dirs.size());
-
- if (n < _dirs.size())
- return _dirs[n];
- else
- return _name;
-}
-
-
-Path& Path::pushDirectory(const std::string& dir)
-{
- if (!dir.empty() && dir != ".")
- {
- if (dir == "..")
- {
- if (!_dirs.empty() && _dirs.back() != "..")
- _dirs.pop_back();
- else if (!_absolute)
- _dirs.push_back(dir);
- }
- else _dirs.push_back(dir);
- }
- return *this;
-}
-
-
-Path& Path::popDirectory()
-{
- poco_assert (!_dirs.empty());
-
- _dirs.pop_back();
- return *this;
-}
-
-
-Path& Path::popFrontDirectory()
-{
- poco_assert (!_dirs.empty());
-
- StringVec::iterator it = _dirs.begin();
- _dirs.erase(it);
- return *this;
-}
-
-
-Path& Path::setFileName(const std::string& name)
-{
- _name = name;
- return *this;
-}
-
-
-Path& Path::setBaseName(const std::string& name)
-{
- std::string ext = getExtension();
- _name = name;
- if (!ext.empty())
- {
- _name.append(".");
- _name.append(ext);
- }
- return *this;
-}
-
-
-std::string Path::getBaseName() const
-{
- std::string::size_type pos = _name.rfind('.');
- if (pos != std::string::npos)
- return _name.substr(0, pos);
- else
- return _name;
-}
-
-
-Path& Path::setExtension(const std::string& extension)
-{
- _name = getBaseName();
- if (!extension.empty())
- {
- _name.append(".");
- _name.append(extension);
- }
- return *this;
-}
-
-
-std::string Path::getExtension() const
-{
- std::string::size_type pos = _name.rfind('.');
- if (pos != std::string::npos)
- return _name.substr(pos + 1);
- else
- return std::string();
-}
-
-
-Path& Path::clear()
-{
- _node.clear();
- _device.clear();
- _name.clear();
- _dirs.clear();
- _version.clear();
- _absolute = false;
- return *this;
-}
-
-
-std::string Path::current()
-{
- return PathImpl::currentImpl();
-}
-
-
-std::string Path::home()
-{
- return PathImpl::homeImpl();
-}
-
-
-std::string Path::configHome()
-{
-#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
- return PathImpl::configHomeImpl();
-#else
- return PathImpl::homeImpl();
-#endif
-}
-
-
-std::string Path::dataHome()
-{
-#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
- return PathImpl::dataHomeImpl();
-#else
- return PathImpl::homeImpl();
-#endif
-}
-
-
-std::string Path::tempHome()
-{
-#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
- return PathImpl::tempHomeImpl();
-#else
- return PathImpl::tempImpl();
-#endif
-}
-
-
-std::string Path::cacheHome()
-{
-#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
- return PathImpl::cacheHomeImpl();
-#else
- return PathImpl::homeImpl();
-#endif
-}
-
-
-std::string Path::temp()
-{
- return PathImpl::tempImpl();
-}
-
-
-std::string Path::config()
-{
-#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
- return PathImpl::configImpl();
-#else
- return PathImpl::currentImpl();
-#endif
-}
-
-
-std::string Path::null()
-{
- return PathImpl::nullImpl();
-}
-
-
-std::string Path::expand(const std::string& path)
-{
- return PathImpl::expandImpl(path);
-}
-
-
-void Path::listRoots(std::vector<std::string>& roots)
-{
- PathImpl::listRootsImpl(roots);
-}
-
-
-bool Path::find(StringVec::const_iterator it, StringVec::const_iterator end, const std::string& name, Path& path)
-{
- while (it != end)
- {
-#if defined(WIN32)
- std::string cleanPath(*it);
- if (cleanPath.size() > 1 && cleanPath[0] == '"' && cleanPath[cleanPath.size() - 1] == '"')
- {
- cleanPath = cleanPath.substr(1, cleanPath.size() - 2);
- }
- Path p(cleanPath);
-#else
- Path p(*it);
-#endif
- p.makeDirectory();
- p.resolve(Path(name));
- File f(p);
- if (f.exists())
- {
- path = p;
- return true;
- }
- ++it;
- }
- return false;
-}
-
-
-bool Path::find(const std::string& pathList, const std::string& name, Path& path)
-{
- StringTokenizer st(pathList, std::string(1, pathSeparator()), StringTokenizer::TOK_IGNORE_EMPTY + StringTokenizer::TOK_TRIM);
- return find(st.begin(), st.end(), name, path);
-}
-
-
-void Path::parseUnix(const std::string& path)
-{
- clear();
-
- std::string::const_iterator it = path.begin();
- std::string::const_iterator end = path.end();
-
- if (it != end)
- {
- if (*it == '/')
- {
- _absolute = true; ++it;
- }
- else if (*it == '~')
- {
- ++it;
- if (it == end || *it == '/')
- {
- Path cwd(home());
- _dirs = cwd._dirs;
- _absolute = true;
- }
- else --it;
- }
-
- while (it != end)
- {
- std::string name;
- while (it != end && *it != '/') name += *it++;
- if (it != end)
- {
- if (_dirs.empty())
- {
- if (!name.empty() && *(name.rbegin()) == ':')
- {
- _absolute = true;
- _device.assign(name, 0, name.length() - 1);
- }
- else
- {
- pushDirectory(name);
- }
- }
- else pushDirectory(name);
- }
- else _name = name;
- if (it != end) ++it;
- }
- }
-}
-
-
-void Path::parseWindows(const std::string& path)
-{
- clear();
-
- std::string::const_iterator it = path.begin();
- std::string::const_iterator end = path.end();
-
- if (it != end)
- {
- if (*it == '\\' || *it == '/') { _absolute = true; ++it; }
- if (_absolute && it != end && (*it == '\\' || *it == '/')) // UNC
- {
- ++it;
- while (it != end && *it != '\\' && *it != '/') _node += *it++;
- if (it != end) ++it;
- }
- else if (it != end)
- {
- char d = *it++;
- if (it != end && *it == ':') // drive letter
- {
- if (_absolute || !((d >= 'a' && d <= 'z') || (d >= 'A' && d <= 'Z'))) throw PathSyntaxException(path);
- _absolute = true;
- _device += d;
- ++it;
- if (it == end || (*it != '\\' && *it != '/')) throw PathSyntaxException(path);
- ++it;
- }
- else --it;
- }
- while (it != end)
- {
- std::string name;
- while (it != end && *it != '\\' && *it != '/') name += *it++;
- if (it != end)
- pushDirectory(name);
- else
- _name = name;
- if (it != end) ++it;
- }
- }
- if (!_node.empty() && _dirs.empty() && !_name.empty())
- makeDirectory();
-}
-
-
-void Path::parseVMS(const std::string& path)
-{
- clear();
-
- std::string::const_iterator it = path.begin();
- std::string::const_iterator end = path.end();
-
- if (it != end)
- {
- std::string name;
- while (it != end && *it != ':' && *it != '[' && *it != ';') name += *it++;
- if (it != end)
- {
- if (*it == ':')
- {
- ++it;
- if (it != end && *it == ':')
- {
- _node = name;
- ++it;
- }
- else _device = name;
- _absolute = true;
- name.clear();
- }
- if (it != end)
- {
- if (_device.empty() && *it != '[')
- {
- while (it != end && *it != ':' && *it != ';') name += *it++;
- if (it != end)
- {
- if (*it == ':')
- {
- _device = name;
- _absolute = true;
- name.clear();
- ++it;
- }
- }
- }
- }
- if (name.empty())
- {
- if (it != end && *it == '[')
- {
- ++it;
- if (it != end)
- {
- _absolute = true;
- if (*it == '.')
- { _absolute = false; ++it; }
- else if (*it == ']' || *it == '-')
- _absolute = false;
- while (it != end && *it != ']')
- {
- name.clear();
- if (*it == '-')
- name = "-";
- else
- while (it != end && *it != '.' && *it != ']') name += *it++;
- if (!name.empty())
- {
- if (name == "-")
- {
- if (_dirs.empty() || _dirs.back() == "..")
- _dirs.push_back("..");
- else
- _dirs.pop_back();
- }
- else _dirs.push_back(name);
- }
- if (it != end && *it != ']') ++it;
- }
- if (it == end) throw PathSyntaxException(path);
- ++it;
- if (it != end && *it == '[')
- {
- if (!_absolute) throw PathSyntaxException(path);
- ++it;
- if (it != end && *it == '.') throw PathSyntaxException(path);
- int d = int(_dirs.size());
- while (it != end && *it != ']')
- {
- name.clear();
- if (*it == '-')
- name = "-";
- else
- while (it != end && *it != '.' && *it != ']') name += *it++;
- if (!name.empty())
- {
- if (name == "-")
- {
- if (_dirs.size() > d)
- _dirs.pop_back();
- }
- else _dirs.push_back(name);
- }
- if (it != end && *it != ']') ++it;
- }
- if (it == end) throw PathSyntaxException(path);
- ++it;
- }
- }
- _name.clear();
- }
- while (it != end && *it != ';') _name += *it++;
- }
- else _name = name;
- if (it != end && *it == ';')
- {
- ++it;
- while (it != end) _version += *it++;
- }
- }
- else _name = name;
- }
-}
-
-
-void Path::parseGuess(const std::string& path)
-{
- bool hasBackslash = false;
- bool hasSlash = false;
- bool hasOpenBracket = false;
- bool hasClosBracket = false;
- bool isWindows = path.length() > 2 && path[1] == ':' && (path[2] == '/' || path[2] == '\\');
- std::string::const_iterator end = path.end();
- std::string::const_iterator semiIt = end;
- if (!isWindows)
- {
- for (std::string::const_iterator it = path.begin(); it != end; ++it)
- {
- switch (*it)
- {
- case '\\': hasBackslash = true; break;
- case '/': hasSlash = true; break;
- case '[': hasOpenBracket = true;
- case ']': hasClosBracket = hasOpenBracket;
- case ';': semiIt = it; break;
- }
- }
- }
- if (hasBackslash || isWindows)
- {
- parseWindows(path);
- }
- else if (hasSlash)
- {
- parseUnix(path);
- }
- else
- {
- bool isVMS = hasClosBracket;
- if (!isVMS && semiIt != end)
- {
- isVMS = true;
- ++semiIt;
- while (semiIt != end)
- {
- if (*semiIt < '0' || *semiIt > '9')
- {
- isVMS = false; break;
- }
- ++semiIt;
- }
- }
- if (isVMS)
- parseVMS(path);
- else
- parseUnix(path);
- }
-}
-
-
-std::string Path::buildUnix() const
-{
- std::string result;
- if (!_device.empty())
- {
- result.append("/");
- result.append(_device);
- result.append(":/");
- }
- else if (_absolute)
- {
- result.append("/");
- }
- for (StringVec::const_iterator it = _dirs.begin(); it != _dirs.end(); ++it)
- {
- result.append(*it);
- result.append("/");
- }
- result.append(_name);
- return result;
-}
-
-
-std::string Path::buildWindows() const
-{
- std::string result;
- if (!_node.empty())
- {
- result.append("\\\\");
- result.append(_node);
- result.append("\\");
- }
- else if (!_device.empty())
- {
- result.append(_device);
- result.append(":\\");
- }
- else if (_absolute)
- {
- result.append("\\");
- }
- for (StringVec::const_iterator it = _dirs.begin(); it != _dirs.end(); ++it)
- {
- result.append(*it);
- result.append("\\");
- }
- result.append(_name);
- return result;
-}
-
-
-std::string Path::buildVMS() const
-{
- std::string result;
- if (!_node.empty())
- {
- result.append(_node);
- result.append("::");
- }
- if (!_device.empty())
- {
- result.append(_device);
- result.append(":");
- }
- if (!_dirs.empty())
- {
- result.append("[");
- if (!_absolute && _dirs[0] != "..")
- result.append(".");
- for (StringVec::const_iterator it = _dirs.begin(); it != _dirs.end(); ++it)
- {
- if (it != _dirs.begin() && *it != "..")
- result.append(".");
- if (*it == "..")
- result.append("-");
- else
- result.append(*it);
- }
- result.append("]");
- }
- result.append(_name);
- if (!_version.empty())
- {
- result.append(";");
- result.append(_version);
- }
- return result;
-}
-
-
-std::string Path::transcode(const std::string& path)
-{
-#if defined(_WIN32) && defined(POCO_WIN32_UTF8)
- std::wstring uniPath;
- UnicodeConverter::toUTF16(path, uniPath);
- DWORD len = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, uniPath.c_str(), static_cast<int>(uniPath.length()), NULL, 0, NULL, NULL);
- if (len > 0)
- {
- Buffer<char> buffer(len);
- DWORD rc = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, uniPath.c_str(), static_cast<int>(uniPath.length()), buffer.begin(), static_cast<int>(buffer.size()), NULL, NULL);
- if (rc)
- {
- return std::string(buffer.begin(), buffer.size());
- }
- }
-#endif
- return path;
-}
-
-
-} // namespace Poco
+//
+// Path.cpp
+//
+// Library: Foundation
+// Package: Filesystem
+// Module: Path
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Path.h"
+#include "Poco/File.h"
+#include "Poco/Exception.h"
+#include "Poco/StringTokenizer.h"
+#if defined(_WIN32) && defined(POCO_WIN32_UTF8)
+#include "Poco/UnicodeConverter.h"
+#include "Poco/Buffer.h"
+#endif
+#include <algorithm>
+
+
+#if defined(POCO_OS_FAMILY_UNIX)
+#include "Path_UNIX.cpp"
+#elif defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
+#if defined(_WIN32_WCE)
+#include "Path_WINCE.cpp"
+#else
+#include "Path_WIN32U.cpp"
+#endif
+#elif defined(POCO_OS_FAMILY_WINDOWS)
+#include "Path_WIN32.cpp"
+#endif
+
+
+namespace Poco {
+
+
+Path::Path(): _absolute(false)
+{
+}
+
+
+Path::Path(bool absolutePath): _absolute(absolutePath)
+{
+}
+
+
+Path::Path(const std::string& path)
+{
+ assign(path);
+}
+
+
+Path::Path(const std::string& path, Style style)
+{
+ assign(path, style);
+}
+
+
+Path::Path(const char* path)
+{
+ poco_check_ptr(path);
+ assign(path);
+}
+
+
+Path::Path(const char* path, Style style)
+{
+ poco_check_ptr(path);
+ assign(path, style);
+}
+
+
+Path::Path(const Path& path):
+ _node(path._node),
+ _device(path._device),
+ _name(path._name),
+ _version(path._version),
+ _dirs(path._dirs),
+ _absolute(path._absolute)
+{
+}
+
+
+Path::Path(const Path& rParent, const std::string& fileName):
+ _node(rParent._node),
+ _device(rParent._device),
+ _name(rParent._name),
+ _version(rParent._version),
+ _dirs(rParent._dirs),
+ _absolute(rParent._absolute)
+{
+ makeDirectory();
+ _name = fileName;
+}
+
+
+Path::Path(const Path& rParent, const char* fileName):
+ _node(rParent._node),
+ _device(rParent._device),
+ _name(rParent._name),
+ _version(rParent._version),
+ _dirs(rParent._dirs),
+ _absolute(rParent._absolute)
+{
+ makeDirectory();
+ _name = fileName;
+}
+
+
+Path::Path(const Path& rParent, const Path& relative):
+ _node(rParent._node),
+ _device(rParent._device),
+ _name(rParent._name),
+ _version(rParent._version),
+ _dirs(rParent._dirs),
+ _absolute(rParent._absolute)
+{
+ resolve(relative);
+}
+
+
+Path::~Path()
+{
+}
+
+
+Path& Path::operator = (const Path& path)
+{
+ return assign(path);
+}
+
+
+Path& Path::operator = (const std::string& path)
+{
+ return assign(path);
+}
+
+
+Path& Path::operator = (const char* path)
+{
+ poco_check_ptr(path);
+ return assign(path);
+}
+
+
+void Path::swap(Path& path)
+{
+ std::swap(_node, path._node);
+ std::swap(_device, path._device);
+ std::swap(_name, path._name);
+ std::swap(_version, path._version);
+ std::swap(_dirs, path._dirs);
+ std::swap(_absolute, path._absolute);
+}
+
+
+Path& Path::assign(const Path& path)
+{
+ if (&path != this)
+ {
+ _node = path._node;
+ _device = path._device;
+ _name = path._name;
+ _version = path._version;
+ _dirs = path._dirs;
+ _absolute = path._absolute;
+ }
+ return *this;
+}
+
+
+Path& Path::assign(const std::string& path)
+{
+#if defined(POCO_OS_FAMILY_WINDOWS)
+ parseWindows(path);
+#else
+ parseUnix(path);
+#endif
+ return *this;
+}
+
+
+Path& Path::assign(const std::string& path, Style style)
+{
+ switch (style)
+ {
+ case PATH_UNIX:
+ parseUnix(path);
+ break;
+ case PATH_WINDOWS:
+ parseWindows(path);
+ break;
+ case PATH_VMS:
+ parseVMS(path);
+ break;
+ case PATH_NATIVE:
+ assign(path);
+ break;
+ case PATH_GUESS:
+ parseGuess(path);
+ break;
+ default:
+ poco_bugcheck();
+ }
+ return *this;
+}
+
+
+Path& Path::assign(const char* path)
+{
+ return assign(std::string(path));
+}
+
+
+std::string Path::toString() const
+{
+#if defined(POCO_OS_FAMILY_WINDOWS)
+ return buildWindows();
+#else
+ return buildUnix();
+#endif
+}
+
+
+std::string Path::toString(Style style) const
+{
+ switch (style)
+ {
+ case PATH_UNIX:
+ return buildUnix();
+ case PATH_WINDOWS:
+ return buildWindows();
+ case PATH_VMS:
+ return buildVMS();
+ case PATH_NATIVE:
+ case PATH_GUESS:
+ return toString();
+ default:
+ poco_bugcheck();
+ }
+ return std::string();
+}
+
+
+bool Path::tryParse(const std::string& path)
+{
+ try
+ {
+ Path p;
+ p.parse(path);
+ assign(p);
+ return true;
+ }
+ catch (...)
+ {
+ return false;
+ }
+}
+
+
+bool Path::tryParse(const std::string& path, Style style)
+{
+ try
+ {
+ Path p;
+ p.parse(path, style);
+ assign(p);
+ return true;
+ }
+ catch (...)
+ {
+ return false;
+ }
+}
+
+
+Path& Path::parseDirectory(const std::string& path)
+{
+ assign(path);
+ return makeDirectory();
+}
+
+
+Path& Path::parseDirectory(const std::string& path, Style style)
+{
+ assign(path, style);
+ return makeDirectory();
+}
+
+
+Path& Path::makeDirectory()
+{
+ pushDirectory(_name);
+ _name.clear();
+ _version.clear();
+ return *this;
+}
+
+
+Path& Path::makeFile()
+{
+ if (!_dirs.empty() && _name.empty())
+ {
+ _name = _dirs.back();
+ _dirs.pop_back();
+ }
+ return *this;
+}
+
+
+Path& Path::makeAbsolute()
+{
+ return makeAbsolute(current());
+}
+
+
+Path& Path::makeAbsolute(const Path& base)
+{
+ if (!_absolute)
+ {
+ Path tmp = base;
+ tmp.makeDirectory();
+ for (StringVec::const_iterator it = _dirs.begin(); it != _dirs.end(); ++it)
+ {
+ tmp.pushDirectory(*it);
+ }
+ _node = tmp._node;
+ _device = tmp._device;
+ _dirs = tmp._dirs;
+ _absolute = base._absolute;
+ }
+ return *this;
+}
+
+
+Path Path::absolute() const
+{
+ Path result(*this);
+ if (!result._absolute)
+ {
+ result.makeAbsolute();
+ }
+ return result;
+}
+
+
+Path Path::absolute(const Path& base) const
+{
+ Path result(*this);
+ if (!result._absolute)
+ {
+ result.makeAbsolute(base);
+ }
+ return result;
+}
+
+
+Path Path::parent() const
+{
+ Path p(*this);
+ return p.makeParent();
+}
+
+
+Path& Path::makeParent()
+{
+ if (_name.empty())
+ {
+ if (_dirs.empty())
+ {
+ if (!_absolute)
+ _dirs.push_back("..");
+ }
+ else
+ {
+ if (_dirs.back() == "..")
+ _dirs.push_back("..");
+ else
+ _dirs.pop_back();
+ }
+ }
+ else
+ {
+ _name.clear();
+ _version.clear();
+ }
+ return *this;
+}
+
+
+Path& Path::append(const Path& path)
+{
+ makeDirectory();
+ _dirs.insert(_dirs.end(), path._dirs.begin(), path._dirs.end());
+ _name = path._name;
+ _version = path._version;
+ return *this;
+}
+
+
+Path& Path::resolve(const Path& path)
+{
+ if (path.isAbsolute())
+ {
+ assign(path);
+ }
+ else
+ {
+ for (int i = 0; i < path.depth(); ++i)
+ pushDirectory(path[i]);
+ _name = path._name;
+ }
+ return *this;
+}
+
+
+Path& Path::setNode(const std::string& node)
+{
+ _node = node;
+ _absolute = _absolute || !node.empty();
+ return *this;
+}
+
+
+Path& Path::setDevice(const std::string& device)
+{
+ _device = device;
+ _absolute = _absolute || !device.empty();
+ return *this;
+}
+
+
+const std::string& Path::directory(int n) const
+{
+ poco_assert (0 <= n && n <= _dirs.size());
+
+ if (n < _dirs.size())
+ return _dirs[n];
+ else
+ return _name;
+}
+
+
+const std::string& Path::operator [] (int n) const
+{
+ poco_assert (0 <= n && n <= _dirs.size());
+
+ if (n < _dirs.size())
+ return _dirs[n];
+ else
+ return _name;
+}
+
+
+Path& Path::pushDirectory(const std::string& dir)
+{
+ if (!dir.empty() && dir != ".")
+ {
+ if (dir == "..")
+ {
+ if (!_dirs.empty() && _dirs.back() != "..")
+ _dirs.pop_back();
+ else if (!_absolute)
+ _dirs.push_back(dir);
+ }
+ else _dirs.push_back(dir);
+ }
+ return *this;
+}
+
+
+Path& Path::popDirectory()
+{
+ poco_assert (!_dirs.empty());
+
+ _dirs.pop_back();
+ return *this;
+}
+
+
+Path& Path::popFrontDirectory()
+{
+ poco_assert (!_dirs.empty());
+
+ StringVec::iterator it = _dirs.begin();
+ _dirs.erase(it);
+ return *this;
+}
+
+
+Path& Path::setFileName(const std::string& name)
+{
+ _name = name;
+ return *this;
+}
+
+
+Path& Path::setBaseName(const std::string& name)
+{
+ std::string ext = getExtension();
+ _name = name;
+ if (!ext.empty())
+ {
+ _name.append(".");
+ _name.append(ext);
+ }
+ return *this;
+}
+
+
+std::string Path::getBaseName() const
+{
+ std::string::size_type pos = _name.rfind('.');
+ if (pos != std::string::npos)
+ return _name.substr(0, pos);
+ else
+ return _name;
+}
+
+
+Path& Path::setExtension(const std::string& extension)
+{
+ _name = getBaseName();
+ if (!extension.empty())
+ {
+ _name.append(".");
+ _name.append(extension);
+ }
+ return *this;
+}
+
+
+std::string Path::getExtension() const
+{
+ std::string::size_type pos = _name.rfind('.');
+ if (pos != std::string::npos)
+ return _name.substr(pos + 1);
+ else
+ return std::string();
+}
+
+
+Path& Path::clear()
+{
+ _node.clear();
+ _device.clear();
+ _name.clear();
+ _dirs.clear();
+ _version.clear();
+ _absolute = false;
+ return *this;
+}
+
+
+std::string Path::current()
+{
+ return PathImpl::currentImpl();
+}
+
+
+std::string Path::home()
+{
+ return PathImpl::homeImpl();
+}
+
+
+std::string Path::configHome()
+{
+#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
+ return PathImpl::configHomeImpl();
+#else
+ return PathImpl::homeImpl();
+#endif
+}
+
+
+std::string Path::dataHome()
+{
+#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
+ return PathImpl::dataHomeImpl();
+#else
+ return PathImpl::homeImpl();
+#endif
+}
+
+
+std::string Path::tempHome()
+{
+#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
+ return PathImpl::tempHomeImpl();
+#else
+ return PathImpl::tempImpl();
+#endif
+}
+
+
+std::string Path::cacheHome()
+{
+#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
+ return PathImpl::cacheHomeImpl();
+#else
+ return PathImpl::homeImpl();
+#endif
+}
+
+
+std::string Path::temp()
+{
+ return PathImpl::tempImpl();
+}
+
+
+std::string Path::config()
+{
+#if defined(POCO_OS_FAMILY_UNIX) || defined(POCO_OS_FAMILY_WINDOWS)
+ return PathImpl::configImpl();
+#else
+ return PathImpl::currentImpl();
+#endif
+}
+
+
+std::string Path::null()
+{
+ return PathImpl::nullImpl();
+}
+
+
+std::string Path::expand(const std::string& path)
+{
+ return PathImpl::expandImpl(path);
+}
+
+
+void Path::listRoots(std::vector<std::string>& roots)
+{
+ PathImpl::listRootsImpl(roots);
+}
+
+
+bool Path::find(StringVec::const_iterator it, StringVec::const_iterator end, const std::string& name, Path& path)
+{
+ while (it != end)
+ {
+#if defined(WIN32)
+ std::string cleanPath(*it);
+ if (cleanPath.size() > 1 && cleanPath[0] == '"' && cleanPath[cleanPath.size() - 1] == '"')
+ {
+ cleanPath = cleanPath.substr(1, cleanPath.size() - 2);
+ }
+ Path p(cleanPath);
+#else
+ Path p(*it);
+#endif
+ p.makeDirectory();
+ p.resolve(Path(name));
+ File f(p);
+ if (f.exists())
+ {
+ path = p;
+ return true;
+ }
+ ++it;
+ }
+ return false;
+}
+
+
+bool Path::find(const std::string& pathList, const std::string& name, Path& path)
+{
+ StringTokenizer st(pathList, std::string(1, pathSeparator()), StringTokenizer::TOK_IGNORE_EMPTY + StringTokenizer::TOK_TRIM);
+ return find(st.begin(), st.end(), name, path);
+}
+
+
+void Path::parseUnix(const std::string& path)
+{
+ clear();
+
+ std::string::const_iterator it = path.begin();
+ std::string::const_iterator end = path.end();
+
+ if (it != end)
+ {
+ if (*it == '/')
+ {
+ _absolute = true; ++it;
+ }
+ else if (*it == '~')
+ {
+ ++it;
+ if (it == end || *it == '/')
+ {
+ Path cwd(home());
+ _dirs = cwd._dirs;
+ _absolute = true;
+ }
+ else --it;
+ }
+
+ while (it != end)
+ {
+ std::string name;
+ while (it != end && *it != '/') name += *it++;
+ if (it != end)
+ {
+ if (_dirs.empty())
+ {
+ if (!name.empty() && *(name.rbegin()) == ':')
+ {
+ _absolute = true;
+ _device.assign(name, 0, name.length() - 1);
+ }
+ else
+ {
+ pushDirectory(name);
+ }
+ }
+ else pushDirectory(name);
+ }
+ else _name = name;
+ if (it != end) ++it;
+ }
+ }
+}
+
+
+void Path::parseWindows(const std::string& path)
+{
+ clear();
+
+ std::string::const_iterator it = path.begin();
+ std::string::const_iterator end = path.end();
+
+ if (it != end)
+ {
+ if (*it == '\\' || *it == '/') { _absolute = true; ++it; }
+ if (_absolute && it != end && (*it == '\\' || *it == '/')) // UNC
+ {
+ ++it;
+ while (it != end && *it != '\\' && *it != '/') _node += *it++;
+ if (it != end) ++it;
+ }
+ else if (it != end)
+ {
+ char d = *it++;
+ if (it != end && *it == ':') // drive letter
+ {
+ if (_absolute || !((d >= 'a' && d <= 'z') || (d >= 'A' && d <= 'Z'))) throw PathSyntaxException(path);
+ _absolute = true;
+ _device += d;
+ ++it;
+ if (it == end || (*it != '\\' && *it != '/')) throw PathSyntaxException(path);
+ ++it;
+ }
+ else --it;
+ }
+ while (it != end)
+ {
+ std::string name;
+ while (it != end && *it != '\\' && *it != '/') name += *it++;
+ if (it != end)
+ pushDirectory(name);
+ else
+ _name = name;
+ if (it != end) ++it;
+ }
+ }
+ if (!_node.empty() && _dirs.empty() && !_name.empty())
+ makeDirectory();
+}
+
+
+void Path::parseVMS(const std::string& path)
+{
+ clear();
+
+ std::string::const_iterator it = path.begin();
+ std::string::const_iterator end = path.end();
+
+ if (it != end)
+ {
+ std::string name;
+ while (it != end && *it != ':' && *it != '[' && *it != ';') name += *it++;
+ if (it != end)
+ {
+ if (*it == ':')
+ {
+ ++it;
+ if (it != end && *it == ':')
+ {
+ _node = name;
+ ++it;
+ }
+ else _device = name;
+ _absolute = true;
+ name.clear();
+ }
+ if (it != end)
+ {
+ if (_device.empty() && *it != '[')
+ {
+ while (it != end && *it != ':' && *it != ';') name += *it++;
+ if (it != end)
+ {
+ if (*it == ':')
+ {
+ _device = name;
+ _absolute = true;
+ name.clear();
+ ++it;
+ }
+ }
+ }
+ }
+ if (name.empty())
+ {
+ if (it != end && *it == '[')
+ {
+ ++it;
+ if (it != end)
+ {
+ _absolute = true;
+ if (*it == '.')
+ { _absolute = false; ++it; }
+ else if (*it == ']' || *it == '-')
+ _absolute = false;
+ while (it != end && *it != ']')
+ {
+ name.clear();
+ if (*it == '-')
+ name = "-";
+ else
+ while (it != end && *it != '.' && *it != ']') name += *it++;
+ if (!name.empty())
+ {
+ if (name == "-")
+ {
+ if (_dirs.empty() || _dirs.back() == "..")
+ _dirs.push_back("..");
+ else
+ _dirs.pop_back();
+ }
+ else _dirs.push_back(name);
+ }
+ if (it != end && *it != ']') ++it;
+ }
+ if (it == end) throw PathSyntaxException(path);
+ ++it;
+ if (it != end && *it == '[')
+ {
+ if (!_absolute) throw PathSyntaxException(path);
+ ++it;
+ if (it != end && *it == '.') throw PathSyntaxException(path);
+ int d = int(_dirs.size());
+ while (it != end && *it != ']')
+ {
+ name.clear();
+ if (*it == '-')
+ name = "-";
+ else
+ while (it != end && *it != '.' && *it != ']') name += *it++;
+ if (!name.empty())
+ {
+ if (name == "-")
+ {
+ if (_dirs.size() > d)
+ _dirs.pop_back();
+ }
+ else _dirs.push_back(name);
+ }
+ if (it != end && *it != ']') ++it;
+ }
+ if (it == end) throw PathSyntaxException(path);
+ ++it;
+ }
+ }
+ _name.clear();
+ }
+ while (it != end && *it != ';') _name += *it++;
+ }
+ else _name = name;
+ if (it != end && *it == ';')
+ {
+ ++it;
+ while (it != end) _version += *it++;
+ }
+ }
+ else _name = name;
+ }
+}
+
+
+void Path::parseGuess(const std::string& path)
+{
+ bool hasBackslash = false;
+ bool hasSlash = false;
+ bool hasOpenBracket = false;
+ bool hasClosBracket = false;
+ bool isWindows = path.length() > 2 && path[1] == ':' && (path[2] == '/' || path[2] == '\\');
+ std::string::const_iterator end = path.end();
+ std::string::const_iterator semiIt = end;
+ if (!isWindows)
+ {
+ for (std::string::const_iterator it = path.begin(); it != end; ++it)
+ {
+ switch (*it)
+ {
+ case '\\': hasBackslash = true; break;
+ case '/': hasSlash = true; break;
+ case '[': hasOpenBracket = true;
+ case ']': hasClosBracket = hasOpenBracket;
+ case ';': semiIt = it; break;
+ }
+ }
+ }
+ if (hasBackslash || isWindows)
+ {
+ parseWindows(path);
+ }
+ else if (hasSlash)
+ {
+ parseUnix(path);
+ }
+ else
+ {
+ bool isVMS = hasClosBracket;
+ if (!isVMS && semiIt != end)
+ {
+ isVMS = true;
+ ++semiIt;
+ while (semiIt != end)
+ {
+ if (*semiIt < '0' || *semiIt > '9')
+ {
+ isVMS = false; break;
+ }
+ ++semiIt;
+ }
+ }
+ if (isVMS)
+ parseVMS(path);
+ else
+ parseUnix(path);
+ }
+}
+
+
+std::string Path::buildUnix() const
+{
+ std::string result;
+ if (!_device.empty())
+ {
+ result.append("/");
+ result.append(_device);
+ result.append(":/");
+ }
+ else if (_absolute)
+ {
+ result.append("/");
+ }
+ for (StringVec::const_iterator it = _dirs.begin(); it != _dirs.end(); ++it)
+ {
+ result.append(*it);
+ result.append("/");
+ }
+ result.append(_name);
+ return result;
+}
+
+
+std::string Path::buildWindows() const
+{
+ std::string result;
+ if (!_node.empty())
+ {
+ result.append("\\\\");
+ result.append(_node);
+ result.append("\\");
+ }
+ else if (!_device.empty())
+ {
+ result.append(_device);
+ result.append(":\\");
+ }
+ else if (_absolute)
+ {
+ result.append("\\");
+ }
+ for (StringVec::const_iterator it = _dirs.begin(); it != _dirs.end(); ++it)
+ {
+ result.append(*it);
+ result.append("\\");
+ }
+ result.append(_name);
+ return result;
+}
+
+
+std::string Path::buildVMS() const
+{
+ std::string result;
+ if (!_node.empty())
+ {
+ result.append(_node);
+ result.append("::");
+ }
+ if (!_device.empty())
+ {
+ result.append(_device);
+ result.append(":");
+ }
+ if (!_dirs.empty())
+ {
+ result.append("[");
+ if (!_absolute && _dirs[0] != "..")
+ result.append(".");
+ for (StringVec::const_iterator it = _dirs.begin(); it != _dirs.end(); ++it)
+ {
+ if (it != _dirs.begin() && *it != "..")
+ result.append(".");
+ if (*it == "..")
+ result.append("-");
+ else
+ result.append(*it);
+ }
+ result.append("]");
+ }
+ result.append(_name);
+ if (!_version.empty())
+ {
+ result.append(";");
+ result.append(_version);
+ }
+ return result;
+}
+
+
+std::string Path::transcode(const std::string& path)
+{
+#if defined(_WIN32) && defined(POCO_WIN32_UTF8)
+ std::wstring uniPath;
+ UnicodeConverter::toUTF16(path, uniPath);
+ DWORD len = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, uniPath.c_str(), static_cast<int>(uniPath.length()), NULL, 0, NULL, NULL);
+ if (len > 0)
+ {
+ Buffer<char> buffer(len);
+ DWORD rc = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, uniPath.c_str(), static_cast<int>(uniPath.length()), buffer.begin(), static_cast<int>(buffer.size()), NULL, NULL);
+ if (rc)
+ {
+ return std::string(buffer.begin(), buffer.size());
+ }
+ }
+#endif
+ return path;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Path_UNIX.cpp b/contrib/libs/poco/Foundation/src/Path_UNIX.cpp
index 583946c8b3..c89cb19f19 100644
--- a/contrib/libs/poco/Foundation/src/Path_UNIX.cpp
+++ b/contrib/libs/poco/Foundation/src/Path_UNIX.cpp
@@ -1,252 +1,252 @@
-//
-// Path_UNIX.cpp
-//
-// Library: Foundation
-// Package: Filesystem
-// Module: Path
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Path_UNIX.h"
-#include "Poco/Exception.h"
-#include "Poco/Environment_UNIX.h"
-#include "Poco/Ascii.h"
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#if !defined(POCO_VXWORKS)
-#include <pwd.h>
-#endif
-#include <climits>
-
-
-#ifndef PATH_MAX
-#define PATH_MAX 1024 // fallback
-#endif
-
-
-namespace Poco {
-
-
-std::string PathImpl::currentImpl()
-{
- std::string path;
- char cwd[PATH_MAX];
- if (getcwd(cwd, sizeof(cwd)))
- path = cwd;
- else
- throw SystemException("cannot get current directory");
- std::string::size_type n = path.size();
- if (n > 0 && path[n - 1] != '/') path.append("/");
- return path;
-}
-
-
-std::string PathImpl::homeImpl()
-{
-#if defined(POCO_VXWORKS)
- if (EnvironmentImpl::hasImpl("HOME"))
- return EnvironmentImpl::getImpl("HOME");
- else
- return "/";
-#else
- std::string path;
- struct passwd* pwd = getpwuid(getuid());
- if (pwd)
- path = pwd->pw_dir;
- else
- {
- pwd = getpwuid(geteuid());
- if (pwd)
- path = pwd->pw_dir;
- else
- path = EnvironmentImpl::getImpl("HOME");
- }
- std::string::size_type n = path.size();
- if (n > 0 && path[n - 1] != '/') path.append("/");
- return path;
-#endif
-}
-
-
-std::string PathImpl::configHomeImpl()
-{
-#if defined(POCO_VXWORKS)
- return PathImpl::homeImpl();
-#else
- std::string path = PathImpl::homeImpl();
- std::string::size_type n = path.size();
- if (n > 0 && path[n - 1] == '/')
-#if POCO_OS == POCO_OS_MAC_OS_X
- path.append("Library/Preferences/");
-#else
- path.append(".config/");
-#endif
-
- return path;
-#endif
-}
-
-
-std::string PathImpl::dataHomeImpl()
-{
-#if defined(POCO_VXWORKS)
- return PathImpl::homeImpl();
-#else
- std::string path = PathImpl::homeImpl();
- std::string::size_type n = path.size();
- if (n > 0 && path[n - 1] == '/')
-#if POCO_OS == POCO_OS_MAC_OS_X
- path.append("Library/Application Support/");
-#else
- path.append(".local/share/");
-#endif
-
- return path;
-#endif
-}
-
-
-std::string PathImpl::cacheHomeImpl()
-{
-#if defined(POCO_VXWORKS)
- return PathImpl::tempImpl();
-#else
- std::string path = PathImpl::homeImpl();
- std::string::size_type n = path.size();
- if (n > 0 && path[n - 1] == '/')
-#if POCO_OS == POCO_OS_MAC_OS_X
- path.append("Library/Caches/");
-#else
- path.append(".cache/");
-#endif
-
- return path;
-#endif
-}
-
-
-std::string PathImpl::tempHomeImpl()
-{
-#if defined(POCO_VXWORKS)
- return PathImpl::tempImpl();
-#else
- std::string path = PathImpl::homeImpl();
- std::string::size_type n = path.size();
- if (n > 0 && path[n - 1] == '/')
-#if POCO_OS == POCO_OS_MAC_OS_X
- path.append("Library/Caches/");
-#else
- path.append(".local/tmp/");
-#endif
-
- return path;
-#endif
-}
-
-
-std::string PathImpl::tempImpl()
-{
- std::string path;
- char* tmp = getenv("TMPDIR");
- if (tmp)
- {
- path = tmp;
- std::string::size_type n = path.size();
- if (n > 0 && path[n - 1] != '/') path.append("/");
- }
- else
- {
- path = "/tmp/";
- }
- return path;
-}
-
-
-std::string PathImpl::configImpl()
-{
- std::string path;
-
-#if POCO_OS == POCO_OS_MAC_OS_X
- path = "/Library/Preferences/";
-#else
- path = "/etc/";
-#endif
- return path;
-}
-
-
-std::string PathImpl::nullImpl()
-{
-#if defined(POCO_VXWORKS)
- return "/null";
-#else
- return "/dev/null";
-#endif
-}
-
-
-std::string PathImpl::expandImpl(const std::string& path)
-{
- std::string result;
- std::string::const_iterator it = path.begin();
- std::string::const_iterator end = path.end();
- if (it != end && *it == '~')
- {
- ++it;
- if (it != end && *it == '/')
- {
- const char* homeEnv = getenv("HOME");
- if (homeEnv)
- {
- result += homeEnv;
- std::string::size_type resultSize = result.size();
- if (resultSize > 0 && result[resultSize - 1] != '/')
- result.append("/");
- }
- else
- {
- result += homeImpl();
- }
- ++it;
- }
- else result += '~';
- }
- while (it != end)
- {
- if (*it == '$')
- {
- std::string var;
- ++it;
- if (it != end && *it == '{')
- {
- ++it;
- while (it != end && *it != '}') var += *it++;
- if (it != end) ++it;
- }
- else
- {
- while (it != end && (Ascii::isAlphaNumeric(*it) || *it == '_')) var += *it++;
- }
- char* val = getenv(var.c_str());
- if (val) result += val;
- }
- else result += *it++;
- }
- return result;
-}
-
-
-void PathImpl::listRootsImpl(std::vector<std::string>& roots)
-{
- roots.clear();
- roots.push_back("/");
-}
-
-
-} // namespace Poco
+//
+// Path_UNIX.cpp
+//
+// Library: Foundation
+// Package: Filesystem
+// Module: Path
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Path_UNIX.h"
+#include "Poco/Exception.h"
+#include "Poco/Environment_UNIX.h"
+#include "Poco/Ascii.h"
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#if !defined(POCO_VXWORKS)
+#include <pwd.h>
+#endif
+#include <climits>
+
+
+#ifndef PATH_MAX
+#define PATH_MAX 1024 // fallback
+#endif
+
+
+namespace Poco {
+
+
+std::string PathImpl::currentImpl()
+{
+ std::string path;
+ char cwd[PATH_MAX];
+ if (getcwd(cwd, sizeof(cwd)))
+ path = cwd;
+ else
+ throw SystemException("cannot get current directory");
+ std::string::size_type n = path.size();
+ if (n > 0 && path[n - 1] != '/') path.append("/");
+ return path;
+}
+
+
+std::string PathImpl::homeImpl()
+{
+#if defined(POCO_VXWORKS)
+ if (EnvironmentImpl::hasImpl("HOME"))
+ return EnvironmentImpl::getImpl("HOME");
+ else
+ return "/";
+#else
+ std::string path;
+ struct passwd* pwd = getpwuid(getuid());
+ if (pwd)
+ path = pwd->pw_dir;
+ else
+ {
+ pwd = getpwuid(geteuid());
+ if (pwd)
+ path = pwd->pw_dir;
+ else
+ path = EnvironmentImpl::getImpl("HOME");
+ }
+ std::string::size_type n = path.size();
+ if (n > 0 && path[n - 1] != '/') path.append("/");
+ return path;
+#endif
+}
+
+
+std::string PathImpl::configHomeImpl()
+{
+#if defined(POCO_VXWORKS)
+ return PathImpl::homeImpl();
+#else
+ std::string path = PathImpl::homeImpl();
+ std::string::size_type n = path.size();
+ if (n > 0 && path[n - 1] == '/')
+#if POCO_OS == POCO_OS_MAC_OS_X
+ path.append("Library/Preferences/");
+#else
+ path.append(".config/");
+#endif
+
+ return path;
+#endif
+}
+
+
+std::string PathImpl::dataHomeImpl()
+{
+#if defined(POCO_VXWORKS)
+ return PathImpl::homeImpl();
+#else
+ std::string path = PathImpl::homeImpl();
+ std::string::size_type n = path.size();
+ if (n > 0 && path[n - 1] == '/')
+#if POCO_OS == POCO_OS_MAC_OS_X
+ path.append("Library/Application Support/");
+#else
+ path.append(".local/share/");
+#endif
+
+ return path;
+#endif
+}
+
+
+std::string PathImpl::cacheHomeImpl()
+{
+#if defined(POCO_VXWORKS)
+ return PathImpl::tempImpl();
+#else
+ std::string path = PathImpl::homeImpl();
+ std::string::size_type n = path.size();
+ if (n > 0 && path[n - 1] == '/')
+#if POCO_OS == POCO_OS_MAC_OS_X
+ path.append("Library/Caches/");
+#else
+ path.append(".cache/");
+#endif
+
+ return path;
+#endif
+}
+
+
+std::string PathImpl::tempHomeImpl()
+{
+#if defined(POCO_VXWORKS)
+ return PathImpl::tempImpl();
+#else
+ std::string path = PathImpl::homeImpl();
+ std::string::size_type n = path.size();
+ if (n > 0 && path[n - 1] == '/')
+#if POCO_OS == POCO_OS_MAC_OS_X
+ path.append("Library/Caches/");
+#else
+ path.append(".local/tmp/");
+#endif
+
+ return path;
+#endif
+}
+
+
+std::string PathImpl::tempImpl()
+{
+ std::string path;
+ char* tmp = getenv("TMPDIR");
+ if (tmp)
+ {
+ path = tmp;
+ std::string::size_type n = path.size();
+ if (n > 0 && path[n - 1] != '/') path.append("/");
+ }
+ else
+ {
+ path = "/tmp/";
+ }
+ return path;
+}
+
+
+std::string PathImpl::configImpl()
+{
+ std::string path;
+
+#if POCO_OS == POCO_OS_MAC_OS_X
+ path = "/Library/Preferences/";
+#else
+ path = "/etc/";
+#endif
+ return path;
+}
+
+
+std::string PathImpl::nullImpl()
+{
+#if defined(POCO_VXWORKS)
+ return "/null";
+#else
+ return "/dev/null";
+#endif
+}
+
+
+std::string PathImpl::expandImpl(const std::string& path)
+{
+ std::string result;
+ std::string::const_iterator it = path.begin();
+ std::string::const_iterator end = path.end();
+ if (it != end && *it == '~')
+ {
+ ++it;
+ if (it != end && *it == '/')
+ {
+ const char* homeEnv = getenv("HOME");
+ if (homeEnv)
+ {
+ result += homeEnv;
+ std::string::size_type resultSize = result.size();
+ if (resultSize > 0 && result[resultSize - 1] != '/')
+ result.append("/");
+ }
+ else
+ {
+ result += homeImpl();
+ }
+ ++it;
+ }
+ else result += '~';
+ }
+ while (it != end)
+ {
+ if (*it == '$')
+ {
+ std::string var;
+ ++it;
+ if (it != end && *it == '{')
+ {
+ ++it;
+ while (it != end && *it != '}') var += *it++;
+ if (it != end) ++it;
+ }
+ else
+ {
+ while (it != end && (Ascii::isAlphaNumeric(*it) || *it == '_')) var += *it++;
+ }
+ char* val = getenv(var.c_str());
+ if (val) result += val;
+ }
+ else result += *it++;
+ }
+ return result;
+}
+
+
+void PathImpl::listRootsImpl(std::vector<std::string>& roots)
+{
+ roots.clear();
+ roots.push_back("/");
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Path_WIN32.cpp b/contrib/libs/poco/Foundation/src/Path_WIN32.cpp
index 9d8b357a31..a925e10833 100644
--- a/contrib/libs/poco/Foundation/src/Path_WIN32.cpp
+++ b/contrib/libs/poco/Foundation/src/Path_WIN32.cpp
@@ -1,203 +1,203 @@
-//
-// Path_WIN32.cpp
-//
-// Library: Foundation
-// Package: Filesystem
-// Module: Path
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Path_WIN32.h"
-#include "Poco/Environment_WIN32.h"
-#include "Poco/UnWindows.h"
-
-
-namespace Poco {
-
-
-std::string PathImpl::currentImpl()
-{
- char buffer[MAX_PATH];
- DWORD n = GetCurrentDirectoryA(sizeof(buffer), buffer);
- if (n > 0 && n < sizeof(buffer))
- {
- std::string result(buffer, n);
- if (result[n - 1] != '\\')
- result.append("\\");
- return result;
- }
- else throw SystemException("Cannot get current directory");
-}
-
-
-std::string PathImpl::systemImpl()
-{
- char buffer[MAX_PATH];
- DWORD n = GetSystemDirectoryA(buffer, sizeof(buffer));
- if (n > 0 && n < sizeof(buffer))
- {
- std::string result(buffer, n);
- if (result[n - 1] != '\\')
- result.append("\\");
- return result;
- }
- else throw SystemException("Cannot get system directory");
-}
-
-
-std::string PathImpl::homeImpl()
-{
- std::string result;
- if (EnvironmentImpl::hasImpl("USERPROFILE"))
- {
- result = EnvironmentImpl::getImpl("USERPROFILE");
- }
- else if (EnvironmentImpl::hasImpl("HOMEDRIVE") && EnvironmentImpl::hasImpl("HOMEPATH"))
- {
- result = EnvironmentImpl::getImpl("HOMEDRIVE");
- result.append(EnvironmentImpl::getImpl("HOMEPATH"));
- }
- else
- {
- result = systemImpl();
- }
-
- std::string::size_type n = result.size();
- if (n > 0 && result[n - 1] != '\\')
- result.append("\\");
- return result;
-}
-
-
-std::string PathImpl::configHomeImpl()
-{
- std::string result;
-
- // if APPDATA environment variable not exist, return home directory instead
- try
- {
- result = EnvironmentImpl::getImpl("APPDATA");
- }
- catch (NotFoundException&)
- {
- result = homeImpl();
- }
-
- std::string::size_type n = result.size();
- if (n > 0 && result[n - 1] != '\\')
- result.append("\\");
- return result;
-}
-
-
-std::string PathImpl::dataHomeImpl()
-{
- std::string result;
-
- // if LOCALAPPDATA environment variable not exist, return config home instead
- try
- {
- result = EnvironmentImpl::getImpl("LOCALAPPDATA");
- }
- catch (NotFoundException&)
- {
- result = configHomeImpl();
- }
-
- std::string::size_type n = result.size();
- if (n > 0 && result[n - 1] != '\\')
- result.append("\\");
- return result;
-}
-
-
-std::string PathImpl::cacheHomeImpl()
-{
- return tempImpl();
-}
-
-
-std::string PathImpl::tempHomeImpl()
-{
- return tempImpl();
-}
-
-
-std::string PathImpl::tempImpl()
-{
- char buffer[MAX_PATH];
- DWORD n = GetTempPathA(sizeof(buffer), buffer);
- if (n > 0 && n < sizeof(buffer))
- {
- n = GetLongPathNameA(buffer, buffer, static_cast<DWORD>(sizeof buffer));
- if (n <= 0) throw SystemException("Cannot get temporary directory long path name");
- std::string result(buffer, n);
- if (result[n - 1] != '\\')
- result.append("\\");
- return result;
- }
- else throw SystemException("Cannot get temporary directory");
-}
-
-
-std::string PathImpl::configImpl()
-{
- std::string result;
-
- // if PROGRAMDATA environment variable not exist, return system directory instead
- try
- {
- result = EnvironmentImpl::getImpl("PROGRAMDATA");
- }
- catch (NotFoundException&)
- {
- result = systemImpl();
- }
-
- std::string::size_type n = result.size();
- if (n > 0 && result[n - 1] != '\\')
- result.append("\\");
- return result;
-}
-
-
-std::string PathImpl::nullImpl()
-{
- return "NUL:";
-}
-
-
-std::string PathImpl::expandImpl(const std::string& path)
-{
- char buffer[MAX_PATH];
- DWORD n = ExpandEnvironmentStringsA(path.c_str(), buffer, sizeof(buffer));
- if (n > 0 && n < sizeof(buffer))
- return std::string(buffer, n - 1);
- else
- return path;
-}
-
-
-void PathImpl::listRootsImpl(std::vector<std::string>& roots)
-{
- roots.clear();
- char buffer[128];
- DWORD n = GetLogicalDriveStrings(sizeof(buffer) - 1, buffer);
- char* it = buffer;
- char* end = buffer + (n > sizeof(buffer) ? sizeof(buffer) : n);
- while (it < end)
- {
- std::string dev;
- while (it < end && *it) dev += *it++;
- roots.push_back(dev);
- ++it;
- }
-}
-
-
-} // namespace Poco
+//
+// Path_WIN32.cpp
+//
+// Library: Foundation
+// Package: Filesystem
+// Module: Path
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Path_WIN32.h"
+#include "Poco/Environment_WIN32.h"
+#include "Poco/UnWindows.h"
+
+
+namespace Poco {
+
+
+std::string PathImpl::currentImpl()
+{
+ char buffer[MAX_PATH];
+ DWORD n = GetCurrentDirectoryA(sizeof(buffer), buffer);
+ if (n > 0 && n < sizeof(buffer))
+ {
+ std::string result(buffer, n);
+ if (result[n - 1] != '\\')
+ result.append("\\");
+ return result;
+ }
+ else throw SystemException("Cannot get current directory");
+}
+
+
+std::string PathImpl::systemImpl()
+{
+ char buffer[MAX_PATH];
+ DWORD n = GetSystemDirectoryA(buffer, sizeof(buffer));
+ if (n > 0 && n < sizeof(buffer))
+ {
+ std::string result(buffer, n);
+ if (result[n - 1] != '\\')
+ result.append("\\");
+ return result;
+ }
+ else throw SystemException("Cannot get system directory");
+}
+
+
+std::string PathImpl::homeImpl()
+{
+ std::string result;
+ if (EnvironmentImpl::hasImpl("USERPROFILE"))
+ {
+ result = EnvironmentImpl::getImpl("USERPROFILE");
+ }
+ else if (EnvironmentImpl::hasImpl("HOMEDRIVE") && EnvironmentImpl::hasImpl("HOMEPATH"))
+ {
+ result = EnvironmentImpl::getImpl("HOMEDRIVE");
+ result.append(EnvironmentImpl::getImpl("HOMEPATH"));
+ }
+ else
+ {
+ result = systemImpl();
+ }
+
+ std::string::size_type n = result.size();
+ if (n > 0 && result[n - 1] != '\\')
+ result.append("\\");
+ return result;
+}
+
+
+std::string PathImpl::configHomeImpl()
+{
+ std::string result;
+
+ // if APPDATA environment variable not exist, return home directory instead
+ try
+ {
+ result = EnvironmentImpl::getImpl("APPDATA");
+ }
+ catch (NotFoundException&)
+ {
+ result = homeImpl();
+ }
+
+ std::string::size_type n = result.size();
+ if (n > 0 && result[n - 1] != '\\')
+ result.append("\\");
+ return result;
+}
+
+
+std::string PathImpl::dataHomeImpl()
+{
+ std::string result;
+
+ // if LOCALAPPDATA environment variable not exist, return config home instead
+ try
+ {
+ result = EnvironmentImpl::getImpl("LOCALAPPDATA");
+ }
+ catch (NotFoundException&)
+ {
+ result = configHomeImpl();
+ }
+
+ std::string::size_type n = result.size();
+ if (n > 0 && result[n - 1] != '\\')
+ result.append("\\");
+ return result;
+}
+
+
+std::string PathImpl::cacheHomeImpl()
+{
+ return tempImpl();
+}
+
+
+std::string PathImpl::tempHomeImpl()
+{
+ return tempImpl();
+}
+
+
+std::string PathImpl::tempImpl()
+{
+ char buffer[MAX_PATH];
+ DWORD n = GetTempPathA(sizeof(buffer), buffer);
+ if (n > 0 && n < sizeof(buffer))
+ {
+ n = GetLongPathNameA(buffer, buffer, static_cast<DWORD>(sizeof buffer));
+ if (n <= 0) throw SystemException("Cannot get temporary directory long path name");
+ std::string result(buffer, n);
+ if (result[n - 1] != '\\')
+ result.append("\\");
+ return result;
+ }
+ else throw SystemException("Cannot get temporary directory");
+}
+
+
+std::string PathImpl::configImpl()
+{
+ std::string result;
+
+ // if PROGRAMDATA environment variable not exist, return system directory instead
+ try
+ {
+ result = EnvironmentImpl::getImpl("PROGRAMDATA");
+ }
+ catch (NotFoundException&)
+ {
+ result = systemImpl();
+ }
+
+ std::string::size_type n = result.size();
+ if (n > 0 && result[n - 1] != '\\')
+ result.append("\\");
+ return result;
+}
+
+
+std::string PathImpl::nullImpl()
+{
+ return "NUL:";
+}
+
+
+std::string PathImpl::expandImpl(const std::string& path)
+{
+ char buffer[MAX_PATH];
+ DWORD n = ExpandEnvironmentStringsA(path.c_str(), buffer, sizeof(buffer));
+ if (n > 0 && n < sizeof(buffer))
+ return std::string(buffer, n - 1);
+ else
+ return path;
+}
+
+
+void PathImpl::listRootsImpl(std::vector<std::string>& roots)
+{
+ roots.clear();
+ char buffer[128];
+ DWORD n = GetLogicalDriveStrings(sizeof(buffer) - 1, buffer);
+ char* it = buffer;
+ char* end = buffer + (n > sizeof(buffer) ? sizeof(buffer) : n);
+ while (it < end)
+ {
+ std::string dev;
+ while (it < end && *it) dev += *it++;
+ roots.push_back(dev);
+ ++it;
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Path_WIN32U.cpp b/contrib/libs/poco/Foundation/src/Path_WIN32U.cpp
index ac757d6eab..730ea59e10 100644
--- a/contrib/libs/poco/Foundation/src/Path_WIN32U.cpp
+++ b/contrib/libs/poco/Foundation/src/Path_WIN32U.cpp
@@ -1,222 +1,222 @@
-//
-// Path_WIN32U.cpp
-//
-// Library: Foundation
-// Package: Filesystem
-// Module: Path
-//
-// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Path_WIN32U.h"
-#include "Poco/Environment_WIN32.h"
-#include "Poco/UnicodeConverter.h"
-#include "Poco/Buffer.h"
-#include "Poco/Exception.h"
-#include "Poco/UnWindows.h"
-
-
-namespace Poco {
-
-
-std::string PathImpl::currentImpl()
-{
- std::string result;
- DWORD len = GetCurrentDirectoryW(0, NULL);
- if (len > 0)
- {
- Buffer<wchar_t> buffer(len);
- DWORD n = GetCurrentDirectoryW(len, buffer.begin());
- if (n > 0 && n <= len)
- {
- UnicodeConverter::toUTF8(buffer.begin(), result);
- if (result[result.size() - 1] != '\\')
- result.append("\\");
- return result;
- }
- }
- throw SystemException("Cannot get current directory");
-}
-
-
-std::string PathImpl::systemImpl()
-{
- Buffer<wchar_t> buffer(MAX_PATH_LEN);
- DWORD n = GetSystemDirectoryW(buffer.begin(), static_cast<DWORD>(buffer.size()));
- if (n > 0)
- {
- n = GetLongPathNameW(buffer.begin(), buffer.begin(), static_cast<DWORD>(buffer.size()));
- if (n <= 0) throw SystemException("Cannot get system directory long path name");
- std::string result;
- UnicodeConverter::toUTF8(buffer.begin(), result);
- if (result[result.size() - 1] != '\\') result.append("\\");
- return result;
- }
- throw SystemException("Cannot get temporary directory path");
-}
-
-
-std::string PathImpl::homeImpl()
-{
- std::string result;
- if (EnvironmentImpl::hasImpl("USERPROFILE"))
- {
- result = EnvironmentImpl::getImpl("USERPROFILE");
- }
- else if (EnvironmentImpl::hasImpl("HOMEDRIVE") && EnvironmentImpl::hasImpl("HOMEPATH"))
- {
- result = EnvironmentImpl::getImpl("HOMEDRIVE");
- result.append(EnvironmentImpl::getImpl("HOMEPATH"));
- }
- else
- {
- result = systemImpl();
- }
-
- std::string::size_type n = result.size();
- if (n > 0 && result[n - 1] != '\\')
- result.append("\\");
- return result;
-}
-
-
-std::string PathImpl::configHomeImpl()
-{
- std::string result;
-
- // if APPDATA environment variable no exist, return home directory instead
- try
- {
- result = EnvironmentImpl::getImpl("APPDATA");
- }
- catch (NotFoundException&)
- {
- result = homeImpl();
- }
-
- std::string::size_type n = result.size();
- if (n > 0 && result[n - 1] != '\\')
- result.append("\\");
- return result;
-}
-
-
-std::string PathImpl::dataHomeImpl()
-{
- std::string result;
-
- // if LOCALAPPDATA environment variable no exist, return config home instead
- try
- {
- result = EnvironmentImpl::getImpl("LOCALAPPDATA");
- }
- catch (NotFoundException&)
- {
- result = configHomeImpl();
- }
-
- std::string::size_type n = result.size();
- if (n > 0 && result[n - 1] != '\\')
- result.append("\\");
- return result;
-}
-
-
-std::string PathImpl::cacheHomeImpl()
-{
- return tempImpl();
-}
-
-
-std::string PathImpl::tempHomeImpl()
-{
- return tempImpl();
-}
-
-
-std::string PathImpl::tempImpl()
-{
- Buffer<wchar_t> buffer(MAX_PATH_LEN);
- DWORD n = GetTempPathW(static_cast<DWORD>(buffer.size()), buffer.begin());
- if (n > 0)
- {
- n = GetLongPathNameW(buffer.begin(), buffer.begin(), static_cast<DWORD>(buffer.size()));
- if (n <= 0) throw SystemException("Cannot get temporary directory long path name");
- std::string result;
- UnicodeConverter::toUTF8(buffer.begin(), result);
- if (result[result.size() - 1] != '\\')
- result.append("\\");
- return result;
- }
- throw SystemException("Cannot get temporary directory path");
-}
-
-
-std::string PathImpl::configImpl()
-{
- std::string result;
-
- // if PROGRAMDATA environment variable not exist, return system directory instead
- try
- {
- result = EnvironmentImpl::getImpl("PROGRAMDATA");
- }
- catch (NotFoundException&)
- {
- result = systemImpl();
- }
-
- std::string::size_type n = result.size();
- if (n > 0 && result[n - 1] != '\\')
- result.append("\\");
- return result;
-}
-
-
-std::string PathImpl::nullImpl()
-{
- return "NUL:";
-}
-
-
-std::string PathImpl::expandImpl(const std::string& path)
-{
- std::wstring upath;
- UnicodeConverter::toUTF16(path, upath);
- Buffer<wchar_t> buffer(MAX_PATH_LEN);
- DWORD n = ExpandEnvironmentStringsW(upath.c_str(), buffer.begin(), static_cast<DWORD>(buffer.size()));
- if (n > 0 && n < buffer.size() - 1)
- {
- buffer[n + 1] = 0;
- std::string result;
- UnicodeConverter::toUTF8(buffer.begin(), result);
- return result;
- }
- else return path;
-}
-
-
-void PathImpl::listRootsImpl(std::vector<std::string>& roots)
-{
- roots.clear();
- wchar_t buffer[128];
- DWORD n = GetLogicalDriveStringsW(sizeof(buffer)/sizeof(wchar_t) - 1, buffer);
- wchar_t* it = buffer;
- wchar_t* end = buffer + (n > sizeof(buffer) ? sizeof(buffer) : n);
- while (it < end)
- {
- std::wstring udev;
- while (it < end && *it) udev += *it++;
- std::string dev;
- UnicodeConverter::toUTF8(udev, dev);
- roots.push_back(dev);
- ++it;
- }
-}
-
-
-} // namespace Poco
+//
+// Path_WIN32U.cpp
+//
+// Library: Foundation
+// Package: Filesystem
+// Module: Path
+//
+// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Path_WIN32U.h"
+#include "Poco/Environment_WIN32.h"
+#include "Poco/UnicodeConverter.h"
+#include "Poco/Buffer.h"
+#include "Poco/Exception.h"
+#include "Poco/UnWindows.h"
+
+
+namespace Poco {
+
+
+std::string PathImpl::currentImpl()
+{
+ std::string result;
+ DWORD len = GetCurrentDirectoryW(0, NULL);
+ if (len > 0)
+ {
+ Buffer<wchar_t> buffer(len);
+ DWORD n = GetCurrentDirectoryW(len, buffer.begin());
+ if (n > 0 && n <= len)
+ {
+ UnicodeConverter::toUTF8(buffer.begin(), result);
+ if (result[result.size() - 1] != '\\')
+ result.append("\\");
+ return result;
+ }
+ }
+ throw SystemException("Cannot get current directory");
+}
+
+
+std::string PathImpl::systemImpl()
+{
+ Buffer<wchar_t> buffer(MAX_PATH_LEN);
+ DWORD n = GetSystemDirectoryW(buffer.begin(), static_cast<DWORD>(buffer.size()));
+ if (n > 0)
+ {
+ n = GetLongPathNameW(buffer.begin(), buffer.begin(), static_cast<DWORD>(buffer.size()));
+ if (n <= 0) throw SystemException("Cannot get system directory long path name");
+ std::string result;
+ UnicodeConverter::toUTF8(buffer.begin(), result);
+ if (result[result.size() - 1] != '\\') result.append("\\");
+ return result;
+ }
+ throw SystemException("Cannot get temporary directory path");
+}
+
+
+std::string PathImpl::homeImpl()
+{
+ std::string result;
+ if (EnvironmentImpl::hasImpl("USERPROFILE"))
+ {
+ result = EnvironmentImpl::getImpl("USERPROFILE");
+ }
+ else if (EnvironmentImpl::hasImpl("HOMEDRIVE") && EnvironmentImpl::hasImpl("HOMEPATH"))
+ {
+ result = EnvironmentImpl::getImpl("HOMEDRIVE");
+ result.append(EnvironmentImpl::getImpl("HOMEPATH"));
+ }
+ else
+ {
+ result = systemImpl();
+ }
+
+ std::string::size_type n = result.size();
+ if (n > 0 && result[n - 1] != '\\')
+ result.append("\\");
+ return result;
+}
+
+
+std::string PathImpl::configHomeImpl()
+{
+ std::string result;
+
+ // if APPDATA environment variable no exist, return home directory instead
+ try
+ {
+ result = EnvironmentImpl::getImpl("APPDATA");
+ }
+ catch (NotFoundException&)
+ {
+ result = homeImpl();
+ }
+
+ std::string::size_type n = result.size();
+ if (n > 0 && result[n - 1] != '\\')
+ result.append("\\");
+ return result;
+}
+
+
+std::string PathImpl::dataHomeImpl()
+{
+ std::string result;
+
+ // if LOCALAPPDATA environment variable no exist, return config home instead
+ try
+ {
+ result = EnvironmentImpl::getImpl("LOCALAPPDATA");
+ }
+ catch (NotFoundException&)
+ {
+ result = configHomeImpl();
+ }
+
+ std::string::size_type n = result.size();
+ if (n > 0 && result[n - 1] != '\\')
+ result.append("\\");
+ return result;
+}
+
+
+std::string PathImpl::cacheHomeImpl()
+{
+ return tempImpl();
+}
+
+
+std::string PathImpl::tempHomeImpl()
+{
+ return tempImpl();
+}
+
+
+std::string PathImpl::tempImpl()
+{
+ Buffer<wchar_t> buffer(MAX_PATH_LEN);
+ DWORD n = GetTempPathW(static_cast<DWORD>(buffer.size()), buffer.begin());
+ if (n > 0)
+ {
+ n = GetLongPathNameW(buffer.begin(), buffer.begin(), static_cast<DWORD>(buffer.size()));
+ if (n <= 0) throw SystemException("Cannot get temporary directory long path name");
+ std::string result;
+ UnicodeConverter::toUTF8(buffer.begin(), result);
+ if (result[result.size() - 1] != '\\')
+ result.append("\\");
+ return result;
+ }
+ throw SystemException("Cannot get temporary directory path");
+}
+
+
+std::string PathImpl::configImpl()
+{
+ std::string result;
+
+ // if PROGRAMDATA environment variable not exist, return system directory instead
+ try
+ {
+ result = EnvironmentImpl::getImpl("PROGRAMDATA");
+ }
+ catch (NotFoundException&)
+ {
+ result = systemImpl();
+ }
+
+ std::string::size_type n = result.size();
+ if (n > 0 && result[n - 1] != '\\')
+ result.append("\\");
+ return result;
+}
+
+
+std::string PathImpl::nullImpl()
+{
+ return "NUL:";
+}
+
+
+std::string PathImpl::expandImpl(const std::string& path)
+{
+ std::wstring upath;
+ UnicodeConverter::toUTF16(path, upath);
+ Buffer<wchar_t> buffer(MAX_PATH_LEN);
+ DWORD n = ExpandEnvironmentStringsW(upath.c_str(), buffer.begin(), static_cast<DWORD>(buffer.size()));
+ if (n > 0 && n < buffer.size() - 1)
+ {
+ buffer[n + 1] = 0;
+ std::string result;
+ UnicodeConverter::toUTF8(buffer.begin(), result);
+ return result;
+ }
+ else return path;
+}
+
+
+void PathImpl::listRootsImpl(std::vector<std::string>& roots)
+{
+ roots.clear();
+ wchar_t buffer[128];
+ DWORD n = GetLogicalDriveStringsW(sizeof(buffer)/sizeof(wchar_t) - 1, buffer);
+ wchar_t* it = buffer;
+ wchar_t* end = buffer + (n > sizeof(buffer) ? sizeof(buffer) : n);
+ while (it < end)
+ {
+ std::wstring udev;
+ while (it < end && *it) udev += *it++;
+ std::string dev;
+ UnicodeConverter::toUTF8(udev, dev);
+ roots.push_back(dev);
+ ++it;
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Path_WINCE.cpp b/contrib/libs/poco/Foundation/src/Path_WINCE.cpp
index 750f18dda6..367ae890d8 100644
--- a/contrib/libs/poco/Foundation/src/Path_WINCE.cpp
+++ b/contrib/libs/poco/Foundation/src/Path_WINCE.cpp
@@ -1,144 +1,144 @@
-//
-// Path_WIN32U.cpp
-//
-// Library: Foundation
-// Package: Filesystem
-// Module: Path
-//
-// Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Path_WINCE.h"
-#include "Poco/Environment_WINCE.h"
-#include "Poco/UnicodeConverter.h"
-#include "Poco/Buffer.h"
-#include "Poco/Environment.h"
-#include "Poco/Exception.h"
-#include "Poco/UnWindows.h"
-
-
-namespace Poco {
-
-
-std::string PathImpl::currentImpl()
-{
- return("\\");
-}
-
-std::string PathImpl::homeImpl()
-{
- return("\\");
-}
-
-std::string PathImpl::configHomeImpl()
-{
- return homeImpl();
-}
-
-std::string PathImpl::dataHomeImpl()
-{
- return homeImpl();
-}
-
-std::string PathImpl::cacheHomeImpl()
-{
- return homeImpl();
-}
-
-
-std::string PathImpl::tempHomeImpl()
-{
- return tempImpl();
-}
-
-
-std::string PathImpl::configImpl()
-{
- return("\\");
-}
-
-std::string PathImpl::systemImpl()
-{
- return("\\");
-}
-
-
-std::string PathImpl::nullImpl()
-{
- return "NUL:";
-}
-
-
-std::string PathImpl::tempImpl()
-{
- return "\\Temp\\";
-}
-
-
-std::string PathImpl::expandImpl(const std::string& path)
-{
- std::string result;
- std::string::const_iterator it = path.begin();
- std::string::const_iterator end = path.end();
- while (it != end)
- {
- if (*it == '%')
- {
- ++it;
- if (it != end && *it == '%')
- {
- result += '%';
- }
- else
- {
- std::string var;
- while (it != end && *it != '%') var += *it++;
- if (it != end) ++it;
- result += Environment::get(var, "");
- }
- }
- else result += *it++;
- }
- return result;
-}
-
-
-void PathImpl::listRootsImpl(std::vector<std::string>& roots)
-{
- roots.clear();
- roots.push_back("\\");
-
- WIN32_FIND_DATAW fd;
- HANDLE hFind = FindFirstFileW(L"\\*.*", &fd);
- if (hFind != INVALID_HANDLE_VALUE)
- {
- do
- {
- if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
- (fd.dwFileAttributes & FILE_ATTRIBUTE_TEMPORARY))
- {
- std::wstring name(fd.cFileName);
- name += L"\\Vol:";
- HANDLE h = CreateFileW(name.c_str(), GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- if (h != INVALID_HANDLE_VALUE)
- {
- // its a device volume
- CloseHandle(h);
- std::string name;
- UnicodeConverter::toUTF8(fd.cFileName, name);
- std::string root = "\\" + name;
- roots.push_back(root);
- }
- }
+//
+// Path_WIN32U.cpp
+//
+// Library: Foundation
+// Package: Filesystem
+// Module: Path
+//
+// Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Path_WINCE.h"
+#include "Poco/Environment_WINCE.h"
+#include "Poco/UnicodeConverter.h"
+#include "Poco/Buffer.h"
+#include "Poco/Environment.h"
+#include "Poco/Exception.h"
+#include "Poco/UnWindows.h"
+
+
+namespace Poco {
+
+
+std::string PathImpl::currentImpl()
+{
+ return("\\");
+}
+
+std::string PathImpl::homeImpl()
+{
+ return("\\");
+}
+
+std::string PathImpl::configHomeImpl()
+{
+ return homeImpl();
+}
+
+std::string PathImpl::dataHomeImpl()
+{
+ return homeImpl();
+}
+
+std::string PathImpl::cacheHomeImpl()
+{
+ return homeImpl();
+}
+
+
+std::string PathImpl::tempHomeImpl()
+{
+ return tempImpl();
+}
+
+
+std::string PathImpl::configImpl()
+{
+ return("\\");
+}
+
+std::string PathImpl::systemImpl()
+{
+ return("\\");
+}
+
+
+std::string PathImpl::nullImpl()
+{
+ return "NUL:";
+}
+
+
+std::string PathImpl::tempImpl()
+{
+ return "\\Temp\\";
+}
+
+
+std::string PathImpl::expandImpl(const std::string& path)
+{
+ std::string result;
+ std::string::const_iterator it = path.begin();
+ std::string::const_iterator end = path.end();
+ while (it != end)
+ {
+ if (*it == '%')
+ {
+ ++it;
+ if (it != end && *it == '%')
+ {
+ result += '%';
+ }
+ else
+ {
+ std::string var;
+ while (it != end && *it != '%') var += *it++;
+ if (it != end) ++it;
+ result += Environment::get(var, "");
+ }
}
- while (FindNextFileW(hFind, &fd));
- FindClose(hFind);
- }
-}
-
-
-} // namespace Poco
+ else result += *it++;
+ }
+ return result;
+}
+
+
+void PathImpl::listRootsImpl(std::vector<std::string>& roots)
+{
+ roots.clear();
+ roots.push_back("\\");
+
+ WIN32_FIND_DATAW fd;
+ HANDLE hFind = FindFirstFileW(L"\\*.*", &fd);
+ if (hFind != INVALID_HANDLE_VALUE)
+ {
+ do
+ {
+ if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
+ (fd.dwFileAttributes & FILE_ATTRIBUTE_TEMPORARY))
+ {
+ std::wstring name(fd.cFileName);
+ name += L"\\Vol:";
+ HANDLE h = CreateFileW(name.c_str(), GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (h != INVALID_HANDLE_VALUE)
+ {
+ // its a device volume
+ CloseHandle(h);
+ std::string name;
+ UnicodeConverter::toUTF8(fd.cFileName, name);
+ std::string root = "\\" + name;
+ roots.push_back(root);
+ }
+ }
+ }
+ while (FindNextFileW(hFind, &fd));
+ FindClose(hFind);
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/PatternFormatter.cpp b/contrib/libs/poco/Foundation/src/PatternFormatter.cpp
index 728c389aa0..7fd83b0109 100644
--- a/contrib/libs/poco/Foundation/src/PatternFormatter.cpp
+++ b/contrib/libs/poco/Foundation/src/PatternFormatter.cpp
@@ -1,247 +1,247 @@
-//
-// PatternFormatter.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: PatternFormatter
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/PatternFormatter.h"
-#include "Poco/Message.h"
-#include "Poco/NumberFormatter.h"
-#include "Poco/DateTimeFormat.h"
-#include "Poco/DateTimeFormatter.h"
-#include "Poco/DateTime.h"
-#include "Poco/Timestamp.h"
-#include "Poco/Timezone.h"
-#include "Poco/Environment.h"
-#include "Poco/NumberParser.h"
-
-
-namespace Poco {
-
-
-const std::string PatternFormatter::PROP_PATTERN = "pattern";
-const std::string PatternFormatter::PROP_TIMES = "times";
-
-
-PatternFormatter::PatternFormatter():
- _localTime(false)
-{
-}
-
-
-PatternFormatter::PatternFormatter(const std::string& rFormat):
- _localTime(false),
- _pattern(rFormat)
-{
- parsePattern();
-}
-
-
-PatternFormatter::~PatternFormatter()
-{
-}
-
-
-void PatternFormatter::format(const Message& msg, std::string& text)
-{
- Timestamp timestamp = msg.getTime();
- bool localTime = _localTime;
- if (localTime)
- {
- timestamp += Timezone::utcOffset()*Timestamp::resolution();
- timestamp += Timezone::dst()*Timestamp::resolution();
- }
- DateTime dateTime = timestamp;
- for (std::vector<PatternAction>::iterator ip = _patternActions.begin(); ip != _patternActions.end(); ++ip)
- {
- text.append(ip->prepend);
- switch (ip->key)
- {
- case 's': text.append(msg.getSource()); break;
- case 't': text.append(msg.getText()); break;
- case 'l': NumberFormatter::append(text, (int) msg.getPriority()); break;
- case 'p': text.append(getPriorityName((int) msg.getPriority())); break;
- case 'q': text += getPriorityName((int) msg.getPriority()).at(0); break;
- case 'P': NumberFormatter::append(text, msg.getPid()); break;
- case 'T': text.append(msg.getThread()); break;
- case 'I': NumberFormatter::append(text, msg.getTid()); break;
- case 'N': text.append(Environment::nodeName()); break;
- case 'U': text.append(msg.getSourceFile() ? msg.getSourceFile() : ""); break;
- case 'u': NumberFormatter::append(text, msg.getSourceLine()); break;
- case 'w': text.append(DateTimeFormat::WEEKDAY_NAMES[dateTime.dayOfWeek()], 0, 3); break;
- case 'W': text.append(DateTimeFormat::WEEKDAY_NAMES[dateTime.dayOfWeek()]); break;
- case 'b': text.append(DateTimeFormat::MONTH_NAMES[dateTime.month() - 1], 0, 3); break;
- case 'B': text.append(DateTimeFormat::MONTH_NAMES[dateTime.month() - 1]); break;
- case 'd': NumberFormatter::append0(text, dateTime.day(), 2); break;
- case 'e': NumberFormatter::append(text, dateTime.day()); break;
- case 'f': NumberFormatter::append(text, dateTime.day(), 2); break;
- case 'm': NumberFormatter::append0(text, dateTime.month(), 2); break;
- case 'n': NumberFormatter::append(text, dateTime.month()); break;
- case 'o': NumberFormatter::append(text, dateTime.month(), 2); break;
- case 'y': NumberFormatter::append0(text, dateTime.year() % 100, 2); break;
- case 'Y': NumberFormatter::append0(text, dateTime.year(), 4); break;
- case 'H': NumberFormatter::append0(text, dateTime.hour(), 2); break;
- case 'h': NumberFormatter::append0(text, dateTime.hourAMPM(), 2); break;
- case 'a': text.append(dateTime.isAM() ? "am" : "pm"); break;
- case 'A': text.append(dateTime.isAM() ? "AM" : "PM"); break;
- case 'M': NumberFormatter::append0(text, dateTime.minute(), 2); break;
- case 'S': NumberFormatter::append0(text, dateTime.second(), 2); break;
- case 'i': NumberFormatter::append0(text, dateTime.millisecond(), 3); break;
- case 'c': NumberFormatter::append(text, dateTime.millisecond()/100); break;
- case 'F': NumberFormatter::append0(text, dateTime.millisecond()*1000 + dateTime.microsecond(), 6); break;
- case 'z': text.append(DateTimeFormatter::tzdISO(localTime ? Timezone::tzd() : DateTimeFormatter::UTC)); break;
- case 'Z': text.append(DateTimeFormatter::tzdRFC(localTime ? Timezone::tzd() : DateTimeFormatter::UTC)); break;
- case 'E': NumberFormatter::append(text, msg.getTime().epochTime()); break;
- case 'v':
- if (ip->length > msg.getSource().length()) //append spaces
- text.append(msg.getSource()).append(ip->length - msg.getSource().length(), ' ');
- else if (ip->length && ip->length < msg.getSource().length()) // crop
- text.append(msg.getSource(), msg.getSource().length()-ip->length, ip->length);
- else
- text.append(msg.getSource());
- break;
- case 'x':
- try
- {
- text.append(msg[ip->property]);
- }
- catch (...)
- {
- }
- break;
- case 'L':
- if (!localTime)
- {
- localTime = true;
- timestamp += Timezone::utcOffset()*Timestamp::resolution();
- timestamp += Timezone::dst()*Timestamp::resolution();
- dateTime = timestamp;
- }
- break;
- }
- }
-}
-
-
-void PatternFormatter::parsePattern()
-{
- _patternActions.clear();
- std::string::const_iterator it = _pattern.begin();
- std::string::const_iterator end = _pattern.end();
- PatternAction endAct;
- while (it != end)
- {
- if (*it == '%')
- {
- if (++it != end)
- {
- PatternAction act;
- act.prepend = endAct.prepend;
- endAct.prepend.clear();
-
- if (*it == '[')
- {
- act.key = 'x';
- ++it;
- std::string prop;
- while (it != end && *it != ']') prop += *it++;
- if (it == end) --it;
- act.property = prop;
- }
- else
- {
- act.key = *it;
- if ((it + 1) != end && *(it + 1) == '[')
- {
- it += 2;
- std::string number;
- while (it != end && *it != ']') number += *it++;
- if (it == end) --it;
- try
- {
- act.length = NumberParser::parse(number);
- }
- catch (...)
- {
- }
- }
- }
- _patternActions.push_back(act);
- ++it;
- }
- }
- else
- {
- endAct.prepend += *it++;
- }
- }
- if (endAct.prepend.size())
- {
- _patternActions.push_back(endAct);
- }
-}
-
-
-void PatternFormatter::setProperty(const std::string& name, const std::string& value)
-{
- if (name == PROP_PATTERN)
- {
- _pattern = value;
- parsePattern();
- }
- else if (name == PROP_TIMES)
- {
- _localTime = (value == "local");
- }
+//
+// PatternFormatter.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: PatternFormatter
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/PatternFormatter.h"
+#include "Poco/Message.h"
+#include "Poco/NumberFormatter.h"
+#include "Poco/DateTimeFormat.h"
+#include "Poco/DateTimeFormatter.h"
+#include "Poco/DateTime.h"
+#include "Poco/Timestamp.h"
+#include "Poco/Timezone.h"
+#include "Poco/Environment.h"
+#include "Poco/NumberParser.h"
+
+
+namespace Poco {
+
+
+const std::string PatternFormatter::PROP_PATTERN = "pattern";
+const std::string PatternFormatter::PROP_TIMES = "times";
+
+
+PatternFormatter::PatternFormatter():
+ _localTime(false)
+{
+}
+
+
+PatternFormatter::PatternFormatter(const std::string& rFormat):
+ _localTime(false),
+ _pattern(rFormat)
+{
+ parsePattern();
+}
+
+
+PatternFormatter::~PatternFormatter()
+{
+}
+
+
+void PatternFormatter::format(const Message& msg, std::string& text)
+{
+ Timestamp timestamp = msg.getTime();
+ bool localTime = _localTime;
+ if (localTime)
+ {
+ timestamp += Timezone::utcOffset()*Timestamp::resolution();
+ timestamp += Timezone::dst()*Timestamp::resolution();
+ }
+ DateTime dateTime = timestamp;
+ for (std::vector<PatternAction>::iterator ip = _patternActions.begin(); ip != _patternActions.end(); ++ip)
+ {
+ text.append(ip->prepend);
+ switch (ip->key)
+ {
+ case 's': text.append(msg.getSource()); break;
+ case 't': text.append(msg.getText()); break;
+ case 'l': NumberFormatter::append(text, (int) msg.getPriority()); break;
+ case 'p': text.append(getPriorityName((int) msg.getPriority())); break;
+ case 'q': text += getPriorityName((int) msg.getPriority()).at(0); break;
+ case 'P': NumberFormatter::append(text, msg.getPid()); break;
+ case 'T': text.append(msg.getThread()); break;
+ case 'I': NumberFormatter::append(text, msg.getTid()); break;
+ case 'N': text.append(Environment::nodeName()); break;
+ case 'U': text.append(msg.getSourceFile() ? msg.getSourceFile() : ""); break;
+ case 'u': NumberFormatter::append(text, msg.getSourceLine()); break;
+ case 'w': text.append(DateTimeFormat::WEEKDAY_NAMES[dateTime.dayOfWeek()], 0, 3); break;
+ case 'W': text.append(DateTimeFormat::WEEKDAY_NAMES[dateTime.dayOfWeek()]); break;
+ case 'b': text.append(DateTimeFormat::MONTH_NAMES[dateTime.month() - 1], 0, 3); break;
+ case 'B': text.append(DateTimeFormat::MONTH_NAMES[dateTime.month() - 1]); break;
+ case 'd': NumberFormatter::append0(text, dateTime.day(), 2); break;
+ case 'e': NumberFormatter::append(text, dateTime.day()); break;
+ case 'f': NumberFormatter::append(text, dateTime.day(), 2); break;
+ case 'm': NumberFormatter::append0(text, dateTime.month(), 2); break;
+ case 'n': NumberFormatter::append(text, dateTime.month()); break;
+ case 'o': NumberFormatter::append(text, dateTime.month(), 2); break;
+ case 'y': NumberFormatter::append0(text, dateTime.year() % 100, 2); break;
+ case 'Y': NumberFormatter::append0(text, dateTime.year(), 4); break;
+ case 'H': NumberFormatter::append0(text, dateTime.hour(), 2); break;
+ case 'h': NumberFormatter::append0(text, dateTime.hourAMPM(), 2); break;
+ case 'a': text.append(dateTime.isAM() ? "am" : "pm"); break;
+ case 'A': text.append(dateTime.isAM() ? "AM" : "PM"); break;
+ case 'M': NumberFormatter::append0(text, dateTime.minute(), 2); break;
+ case 'S': NumberFormatter::append0(text, dateTime.second(), 2); break;
+ case 'i': NumberFormatter::append0(text, dateTime.millisecond(), 3); break;
+ case 'c': NumberFormatter::append(text, dateTime.millisecond()/100); break;
+ case 'F': NumberFormatter::append0(text, dateTime.millisecond()*1000 + dateTime.microsecond(), 6); break;
+ case 'z': text.append(DateTimeFormatter::tzdISO(localTime ? Timezone::tzd() : DateTimeFormatter::UTC)); break;
+ case 'Z': text.append(DateTimeFormatter::tzdRFC(localTime ? Timezone::tzd() : DateTimeFormatter::UTC)); break;
+ case 'E': NumberFormatter::append(text, msg.getTime().epochTime()); break;
+ case 'v':
+ if (ip->length > msg.getSource().length()) //append spaces
+ text.append(msg.getSource()).append(ip->length - msg.getSource().length(), ' ');
+ else if (ip->length && ip->length < msg.getSource().length()) // crop
+ text.append(msg.getSource(), msg.getSource().length()-ip->length, ip->length);
+ else
+ text.append(msg.getSource());
+ break;
+ case 'x':
+ try
+ {
+ text.append(msg[ip->property]);
+ }
+ catch (...)
+ {
+ }
+ break;
+ case 'L':
+ if (!localTime)
+ {
+ localTime = true;
+ timestamp += Timezone::utcOffset()*Timestamp::resolution();
+ timestamp += Timezone::dst()*Timestamp::resolution();
+ dateTime = timestamp;
+ }
+ break;
+ }
+ }
+}
+
+
+void PatternFormatter::parsePattern()
+{
+ _patternActions.clear();
+ std::string::const_iterator it = _pattern.begin();
+ std::string::const_iterator end = _pattern.end();
+ PatternAction endAct;
+ while (it != end)
+ {
+ if (*it == '%')
+ {
+ if (++it != end)
+ {
+ PatternAction act;
+ act.prepend = endAct.prepend;
+ endAct.prepend.clear();
+
+ if (*it == '[')
+ {
+ act.key = 'x';
+ ++it;
+ std::string prop;
+ while (it != end && *it != ']') prop += *it++;
+ if (it == end) --it;
+ act.property = prop;
+ }
+ else
+ {
+ act.key = *it;
+ if ((it + 1) != end && *(it + 1) == '[')
+ {
+ it += 2;
+ std::string number;
+ while (it != end && *it != ']') number += *it++;
+ if (it == end) --it;
+ try
+ {
+ act.length = NumberParser::parse(number);
+ }
+ catch (...)
+ {
+ }
+ }
+ }
+ _patternActions.push_back(act);
+ ++it;
+ }
+ }
+ else
+ {
+ endAct.prepend += *it++;
+ }
+ }
+ if (endAct.prepend.size())
+ {
+ _patternActions.push_back(endAct);
+ }
+}
+
+
+void PatternFormatter::setProperty(const std::string& name, const std::string& value)
+{
+ if (name == PROP_PATTERN)
+ {
+ _pattern = value;
+ parsePattern();
+ }
+ else if (name == PROP_TIMES)
+ {
+ _localTime = (value == "local");
+ }
+ else
+ {
+ Formatter::setProperty(name, value);
+ }
+}
+
+
+std::string PatternFormatter::getProperty(const std::string& name) const
+{
+ if (name == PROP_PATTERN)
+ return _pattern;
+ else if (name == PROP_TIMES)
+ return _localTime ? "local" : "UTC";
else
- {
- Formatter::setProperty(name, value);
- }
-}
-
-
-std::string PatternFormatter::getProperty(const std::string& name) const
-{
- if (name == PROP_PATTERN)
- return _pattern;
- else if (name == PROP_TIMES)
- return _localTime ? "local" : "UTC";
- else
- return Formatter::getProperty(name);
-}
-
-
-namespace
-{
- static std::string priorities[] =
- {
- "",
- "Fatal",
- "Critical",
- "Error",
- "Warning",
- "Notice",
- "Information",
- "Debug",
+ return Formatter::getProperty(name);
+}
+
+
+namespace
+{
+ static std::string priorities[] =
+ {
+ "",
+ "Fatal",
+ "Critical",
+ "Error",
+ "Warning",
+ "Notice",
+ "Information",
+ "Debug",
"Trace",
"Test"
- };
-}
-
-
-const std::string& PatternFormatter::getPriorityName(int prio)
-{
+ };
+}
+
+
+const std::string& PatternFormatter::getPriorityName(int prio)
+{
poco_assert (1 <= prio && prio <= 9);
- return priorities[prio];
-}
-
-
-} // namespace Poco
+ return priorities[prio];
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Pipe.cpp b/contrib/libs/poco/Foundation/src/Pipe.cpp
index 8cd9eb244d..75f1bb531c 100644
--- a/contrib/libs/poco/Foundation/src/Pipe.cpp
+++ b/contrib/libs/poco/Foundation/src/Pipe.cpp
@@ -1,70 +1,70 @@
-//
-// Pipe.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: Pipe
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Pipe.h"
-
-
-namespace Poco {
-
-
-Pipe::Pipe():
- _pImpl(new PipeImpl)
-{
-}
-
-
-Pipe::Pipe(const Pipe& pipe):
- _pImpl(pipe._pImpl)
-{
- _pImpl->duplicate();
-}
-
-
-Pipe::~Pipe()
-{
- _pImpl->release();
-}
-
-
-Pipe& Pipe::operator = (const Pipe& pipe)
-{
- if (this != &pipe)
- {
- _pImpl->release();
- _pImpl = pipe._pImpl;
- _pImpl->duplicate();
- }
- return *this;
-}
-
-
-void Pipe::close(CloseMode mode)
-{
- switch (mode)
- {
- case CLOSE_READ:
- _pImpl->closeRead();
- break;
- case CLOSE_WRITE:
- _pImpl->closeWrite();
- break;
- default:
- _pImpl->closeRead();
- _pImpl->closeWrite();
- break;
- }
-}
-
-
-} // namespace Poco
+//
+// Pipe.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: Pipe
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Pipe.h"
+
+
+namespace Poco {
+
+
+Pipe::Pipe():
+ _pImpl(new PipeImpl)
+{
+}
+
+
+Pipe::Pipe(const Pipe& pipe):
+ _pImpl(pipe._pImpl)
+{
+ _pImpl->duplicate();
+}
+
+
+Pipe::~Pipe()
+{
+ _pImpl->release();
+}
+
+
+Pipe& Pipe::operator = (const Pipe& pipe)
+{
+ if (this != &pipe)
+ {
+ _pImpl->release();
+ _pImpl = pipe._pImpl;
+ _pImpl->duplicate();
+ }
+ return *this;
+}
+
+
+void Pipe::close(CloseMode mode)
+{
+ switch (mode)
+ {
+ case CLOSE_READ:
+ _pImpl->closeRead();
+ break;
+ case CLOSE_WRITE:
+ _pImpl->closeWrite();
+ break;
+ default:
+ _pImpl->closeRead();
+ _pImpl->closeWrite();
+ break;
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/PipeImpl.cpp b/contrib/libs/poco/Foundation/src/PipeImpl.cpp
index 0f43b45ba1..849068a0a6 100644
--- a/contrib/libs/poco/Foundation/src/PipeImpl.cpp
+++ b/contrib/libs/poco/Foundation/src/PipeImpl.cpp
@@ -1,28 +1,28 @@
-//
-// PipeImpl.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: PipeImpl
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/PipeImpl.h"
-
-
-#if defined(POCO_OS_FAMILY_WINDOWS)
-#if defined(_WIN32_WCE)
-#include "PipeImpl_DUMMY.cpp"
-#else
-#include "PipeImpl_WIN32.cpp"
-#endif
-#elif defined(POCO_OS_FAMILY_UNIX)
-#include "PipeImpl_POSIX.cpp"
-#else
-#include "PipeImpl_DUMMY.cpp"
-#endif
+//
+// PipeImpl.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: PipeImpl
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/PipeImpl.h"
+
+
+#if defined(POCO_OS_FAMILY_WINDOWS)
+#if defined(_WIN32_WCE)
+#include "PipeImpl_DUMMY.cpp"
+#else
+#include "PipeImpl_WIN32.cpp"
+#endif
+#elif defined(POCO_OS_FAMILY_UNIX)
+#include "PipeImpl_POSIX.cpp"
+#else
+#include "PipeImpl_DUMMY.cpp"
+#endif
diff --git a/contrib/libs/poco/Foundation/src/PipeImpl_DUMMY.cpp b/contrib/libs/poco/Foundation/src/PipeImpl_DUMMY.cpp
index b0faf7b68b..22085e894b 100644
--- a/contrib/libs/poco/Foundation/src/PipeImpl_DUMMY.cpp
+++ b/contrib/libs/poco/Foundation/src/PipeImpl_DUMMY.cpp
@@ -1,65 +1,65 @@
-//
-// PipeImpl_DUMMY.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: PipeImpl
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/PipeImpl_DUMMY.h"
-
-
-namespace Poco {
-
-
-PipeImpl::PipeImpl()
-{
-}
-
-
-PipeImpl::~PipeImpl()
-{
-}
-
-
-int PipeImpl::writeBytes(const void* buffer, int length)
-{
- return 0;
-}
-
-
-int PipeImpl::readBytes(void* buffer, int length)
-{
- return 0;
-}
-
-
-PipeImpl::Handle PipeImpl::readHandle() const
-{
- return 0;
-}
-
-
-PipeImpl::Handle PipeImpl::writeHandle() const
-{
- return 0;
-}
-
-
-void PipeImpl::closeRead()
-{
-}
-
-
-void PipeImpl::closeWrite()
-{
-}
-
-
-} // namespace Poco
+//
+// PipeImpl_DUMMY.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: PipeImpl
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/PipeImpl_DUMMY.h"
+
+
+namespace Poco {
+
+
+PipeImpl::PipeImpl()
+{
+}
+
+
+PipeImpl::~PipeImpl()
+{
+}
+
+
+int PipeImpl::writeBytes(const void* buffer, int length)
+{
+ return 0;
+}
+
+
+int PipeImpl::readBytes(void* buffer, int length)
+{
+ return 0;
+}
+
+
+PipeImpl::Handle PipeImpl::readHandle() const
+{
+ return 0;
+}
+
+
+PipeImpl::Handle PipeImpl::writeHandle() const
+{
+ return 0;
+}
+
+
+void PipeImpl::closeRead()
+{
+}
+
+
+void PipeImpl::closeWrite()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/PipeImpl_POSIX.cpp b/contrib/libs/poco/Foundation/src/PipeImpl_POSIX.cpp
index 6a3edd32df..4d1f569d66 100644
--- a/contrib/libs/poco/Foundation/src/PipeImpl_POSIX.cpp
+++ b/contrib/libs/poco/Foundation/src/PipeImpl_POSIX.cpp
@@ -1,111 +1,111 @@
-//
-// PipeImpl_POSIX.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: PipeImpl
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/PipeImpl_POSIX.h"
-#include "Poco/Exception.h"
-#include <sys/types.h>
-#include <unistd.h>
-#include <errno.h>
-
-
-namespace Poco {
-
-
-PipeImpl::PipeImpl()
-{
- int fds[2];
- int rc = pipe(fds);
- if (rc == 0)
- {
- _readfd = fds[0];
- _writefd = fds[1];
- }
- else throw CreateFileException("anonymous pipe");
-}
-
-
-PipeImpl::~PipeImpl()
-{
- closeRead();
- closeWrite();
-}
-
-
-int PipeImpl::writeBytes(const void* buffer, int length)
-{
- poco_assert (_writefd != -1);
-
- int n;
- do
- {
- n = write(_writefd, buffer, length);
- }
- while (n < 0 && errno == EINTR);
- if (n >= 0)
- return n;
- else
- throw WriteFileException("anonymous pipe");
-}
-
-
-int PipeImpl::readBytes(void* buffer, int length)
-{
- poco_assert (_readfd != -1);
-
- int n;
- do
- {
- n = read(_readfd, buffer, length);
- }
- while (n < 0 && errno == EINTR);
- if (n >= 0)
- return n;
- else
- throw ReadFileException("anonymous pipe");
-}
-
-
-PipeImpl::Handle PipeImpl::readHandle() const
-{
- return _readfd;
-}
-
-
-PipeImpl::Handle PipeImpl::writeHandle() const
-{
- return _writefd;
-}
-
-
-void PipeImpl::closeRead()
-{
- if (_readfd != -1)
- {
- close(_readfd);
- _readfd = -1;
- }
-}
-
-
-void PipeImpl::closeWrite()
-{
- if (_writefd != -1)
- {
- close(_writefd);
- _writefd = -1;
- }
-}
-
-
-} // namespace Poco
+//
+// PipeImpl_POSIX.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: PipeImpl
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/PipeImpl_POSIX.h"
+#include "Poco/Exception.h"
+#include <sys/types.h>
+#include <unistd.h>
+#include <errno.h>
+
+
+namespace Poco {
+
+
+PipeImpl::PipeImpl()
+{
+ int fds[2];
+ int rc = pipe(fds);
+ if (rc == 0)
+ {
+ _readfd = fds[0];
+ _writefd = fds[1];
+ }
+ else throw CreateFileException("anonymous pipe");
+}
+
+
+PipeImpl::~PipeImpl()
+{
+ closeRead();
+ closeWrite();
+}
+
+
+int PipeImpl::writeBytes(const void* buffer, int length)
+{
+ poco_assert (_writefd != -1);
+
+ int n;
+ do
+ {
+ n = write(_writefd, buffer, length);
+ }
+ while (n < 0 && errno == EINTR);
+ if (n >= 0)
+ return n;
+ else
+ throw WriteFileException("anonymous pipe");
+}
+
+
+int PipeImpl::readBytes(void* buffer, int length)
+{
+ poco_assert (_readfd != -1);
+
+ int n;
+ do
+ {
+ n = read(_readfd, buffer, length);
+ }
+ while (n < 0 && errno == EINTR);
+ if (n >= 0)
+ return n;
+ else
+ throw ReadFileException("anonymous pipe");
+}
+
+
+PipeImpl::Handle PipeImpl::readHandle() const
+{
+ return _readfd;
+}
+
+
+PipeImpl::Handle PipeImpl::writeHandle() const
+{
+ return _writefd;
+}
+
+
+void PipeImpl::closeRead()
+{
+ if (_readfd != -1)
+ {
+ close(_readfd);
+ _readfd = -1;
+ }
+}
+
+
+void PipeImpl::closeWrite()
+{
+ if (_writefd != -1)
+ {
+ close(_writefd);
+ _writefd = -1;
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/PipeImpl_WIN32.cpp b/contrib/libs/poco/Foundation/src/PipeImpl_WIN32.cpp
index 87dbbbf3e5..49de80efac 100644
--- a/contrib/libs/poco/Foundation/src/PipeImpl_WIN32.cpp
+++ b/contrib/libs/poco/Foundation/src/PipeImpl_WIN32.cpp
@@ -1,97 +1,97 @@
-//
-// PipeImpl_WIN32.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: PipeImpl
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/PipeImpl_WIN32.h"
-#include "Poco/Exception.h"
-
-
-namespace Poco {
-
-
-PipeImpl::PipeImpl()
-{
- SECURITY_ATTRIBUTES attr;
- attr.nLength = sizeof(attr);
- attr.lpSecurityDescriptor = NULL;
- attr.bInheritHandle = FALSE;
-
- if (!CreatePipe(&_readHandle, &_writeHandle, &attr, 0))
- throw CreateFileException("anonymous pipe");
-}
-
-
-PipeImpl::~PipeImpl()
-{
- closeRead();
- closeWrite();
-}
-
-
-int PipeImpl::writeBytes(const void* buffer, int length)
-{
- poco_assert (_writeHandle != INVALID_HANDLE_VALUE);
-
- DWORD bytesWritten = 0;
- if (!WriteFile(_writeHandle, buffer, length, &bytesWritten, NULL))
- throw WriteFileException("anonymous pipe");
- return bytesWritten;
-}
-
-
-int PipeImpl::readBytes(void* buffer, int length)
-{
- poco_assert (_readHandle != INVALID_HANDLE_VALUE);
-
- DWORD bytesRead = 0;
- BOOL ok = ReadFile(_readHandle, buffer, length, &bytesRead, NULL);
- if (ok || GetLastError() == ERROR_BROKEN_PIPE)
- return bytesRead;
- else
- throw ReadFileException("anonymous pipe");
-}
-
-
-PipeImpl::Handle PipeImpl::readHandle() const
-{
- return _readHandle;
-}
-
-
-PipeImpl::Handle PipeImpl::writeHandle() const
-{
- return _writeHandle;
-}
-
-
-void PipeImpl::closeRead()
-{
- if (_readHandle != INVALID_HANDLE_VALUE)
- {
- CloseHandle(_readHandle);
- _readHandle = INVALID_HANDLE_VALUE;
- }
-}
-
-
-void PipeImpl::closeWrite()
-{
- if (_writeHandle != INVALID_HANDLE_VALUE)
- {
- CloseHandle(_writeHandle);
- _writeHandle = INVALID_HANDLE_VALUE;
- }
-}
-
-
-} // namespace Poco
+//
+// PipeImpl_WIN32.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: PipeImpl
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/PipeImpl_WIN32.h"
+#include "Poco/Exception.h"
+
+
+namespace Poco {
+
+
+PipeImpl::PipeImpl()
+{
+ SECURITY_ATTRIBUTES attr;
+ attr.nLength = sizeof(attr);
+ attr.lpSecurityDescriptor = NULL;
+ attr.bInheritHandle = FALSE;
+
+ if (!CreatePipe(&_readHandle, &_writeHandle, &attr, 0))
+ throw CreateFileException("anonymous pipe");
+}
+
+
+PipeImpl::~PipeImpl()
+{
+ closeRead();
+ closeWrite();
+}
+
+
+int PipeImpl::writeBytes(const void* buffer, int length)
+{
+ poco_assert (_writeHandle != INVALID_HANDLE_VALUE);
+
+ DWORD bytesWritten = 0;
+ if (!WriteFile(_writeHandle, buffer, length, &bytesWritten, NULL))
+ throw WriteFileException("anonymous pipe");
+ return bytesWritten;
+}
+
+
+int PipeImpl::readBytes(void* buffer, int length)
+{
+ poco_assert (_readHandle != INVALID_HANDLE_VALUE);
+
+ DWORD bytesRead = 0;
+ BOOL ok = ReadFile(_readHandle, buffer, length, &bytesRead, NULL);
+ if (ok || GetLastError() == ERROR_BROKEN_PIPE)
+ return bytesRead;
+ else
+ throw ReadFileException("anonymous pipe");
+}
+
+
+PipeImpl::Handle PipeImpl::readHandle() const
+{
+ return _readHandle;
+}
+
+
+PipeImpl::Handle PipeImpl::writeHandle() const
+{
+ return _writeHandle;
+}
+
+
+void PipeImpl::closeRead()
+{
+ if (_readHandle != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle(_readHandle);
+ _readHandle = INVALID_HANDLE_VALUE;
+ }
+}
+
+
+void PipeImpl::closeWrite()
+{
+ if (_writeHandle != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle(_writeHandle);
+ _writeHandle = INVALID_HANDLE_VALUE;
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/PipeStream.cpp b/contrib/libs/poco/Foundation/src/PipeStream.cpp
index 96fb323581..8a6194307e 100644
--- a/contrib/libs/poco/Foundation/src/PipeStream.cpp
+++ b/contrib/libs/poco/Foundation/src/PipeStream.cpp
@@ -1,127 +1,127 @@
-//
-// PipeStream.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: PipeStream
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/PipeStream.h"
-
-
-namespace Poco {
-
-
-//
-// PipeStreamBuf
-//
-
-
-PipeStreamBuf::PipeStreamBuf(const Pipe& pipe, openmode mode):
- BufferedStreamBuf(STREAM_BUFFER_SIZE, mode),
- _pipe(pipe)
-{
-}
-
-
-PipeStreamBuf::~PipeStreamBuf()
-{
-}
-
-
-int PipeStreamBuf::readFromDevice(char* buffer, std::streamsize length)
-{
- return _pipe.readBytes(buffer, (int) length);
-}
-
-
-int PipeStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
-{
- return _pipe.writeBytes(buffer, (int) length);
-}
-
-
-void PipeStreamBuf::close()
-{
- _pipe.close(Pipe::CLOSE_BOTH);
-}
-
-
-//
-// PipeIOS
-//
-
-
-PipeIOS::PipeIOS(const Pipe& pipe, openmode mode):
- _buf(pipe, mode)
-{
- poco_ios_init(&_buf);
-}
-
-
-PipeIOS::~PipeIOS()
-{
- try
- {
- _buf.sync();
- }
- catch (...)
- {
- }
-}
-
-
-PipeStreamBuf* PipeIOS::rdbuf()
-{
- return &_buf;
-}
-
-
-void PipeIOS::close()
-{
- _buf.sync();
- _buf.close();
-}
-
-
-//
-// PipeOutputStream
-//
-
-
-PipeOutputStream::PipeOutputStream(const Pipe& pipe):
- PipeIOS(pipe, std::ios::out),
- std::ostream(&_buf)
-{
-}
-
-
-PipeOutputStream::~PipeOutputStream()
-{
-}
-
-
-//
-// PipeInputStream
-//
-
-
-PipeInputStream::PipeInputStream(const Pipe& pipe):
- PipeIOS(pipe, std::ios::in),
- std::istream(&_buf)
-{
-}
-
-
-PipeInputStream::~PipeInputStream()
-{
-}
-
-
-} // namespace Poco
+//
+// PipeStream.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: PipeStream
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/PipeStream.h"
+
+
+namespace Poco {
+
+
+//
+// PipeStreamBuf
+//
+
+
+PipeStreamBuf::PipeStreamBuf(const Pipe& pipe, openmode mode):
+ BufferedStreamBuf(STREAM_BUFFER_SIZE, mode),
+ _pipe(pipe)
+{
+}
+
+
+PipeStreamBuf::~PipeStreamBuf()
+{
+}
+
+
+int PipeStreamBuf::readFromDevice(char* buffer, std::streamsize length)
+{
+ return _pipe.readBytes(buffer, (int) length);
+}
+
+
+int PipeStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
+{
+ return _pipe.writeBytes(buffer, (int) length);
+}
+
+
+void PipeStreamBuf::close()
+{
+ _pipe.close(Pipe::CLOSE_BOTH);
+}
+
+
+//
+// PipeIOS
+//
+
+
+PipeIOS::PipeIOS(const Pipe& pipe, openmode mode):
+ _buf(pipe, mode)
+{
+ poco_ios_init(&_buf);
+}
+
+
+PipeIOS::~PipeIOS()
+{
+ try
+ {
+ _buf.sync();
+ }
+ catch (...)
+ {
+ }
+}
+
+
+PipeStreamBuf* PipeIOS::rdbuf()
+{
+ return &_buf;
+}
+
+
+void PipeIOS::close()
+{
+ _buf.sync();
+ _buf.close();
+}
+
+
+//
+// PipeOutputStream
+//
+
+
+PipeOutputStream::PipeOutputStream(const Pipe& pipe):
+ PipeIOS(pipe, std::ios::out),
+ std::ostream(&_buf)
+{
+}
+
+
+PipeOutputStream::~PipeOutputStream()
+{
+}
+
+
+//
+// PipeInputStream
+//
+
+
+PipeInputStream::PipeInputStream(const Pipe& pipe):
+ PipeIOS(pipe, std::ios::in),
+ std::istream(&_buf)
+{
+}
+
+
+PipeInputStream::~PipeInputStream()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/PriorityNotificationQueue.cpp b/contrib/libs/poco/Foundation/src/PriorityNotificationQueue.cpp
index b0e5523ce2..e52f6db3fe 100644
--- a/contrib/libs/poco/Foundation/src/PriorityNotificationQueue.cpp
+++ b/contrib/libs/poco/Foundation/src/PriorityNotificationQueue.cpp
@@ -1,195 +1,195 @@
-//
-// PriorityNotificationQueue.cpp
-//
-// Library: Foundation
-// Package: Notifications
-// Module: PriorityNotificationQueue
-//
-// Copyright (c) 2009, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/PriorityNotificationQueue.h"
-#include "Poco/NotificationCenter.h"
-#include "Poco/Notification.h"
-#include "Poco/SingletonHolder.h"
-
-
-namespace Poco {
-
-
-PriorityNotificationQueue::PriorityNotificationQueue()
-{
-}
-
-
-PriorityNotificationQueue::~PriorityNotificationQueue()
-{
- try
- {
- clear();
- }
- catch (...)
- {
- poco_unexpected();
- }
-}
-
-
-void PriorityNotificationQueue::enqueueNotification(Notification::Ptr pNotification, int priority)
-{
- poco_check_ptr (pNotification);
- FastMutex::ScopedLock lock(_mutex);
- if (_waitQueue.empty())
- {
- _nfQueue.insert(NfQueue::value_type(priority, pNotification));
- }
- else
- {
- poco_assert_dbg(_nfQueue.empty());
- WaitInfo* pWI = _waitQueue.front();
- _waitQueue.pop_front();
- pWI->pNf = pNotification;
- pWI->nfAvailable.set();
- }
-}
-
-
-Notification* PriorityNotificationQueue::dequeueNotification()
-{
- FastMutex::ScopedLock lock(_mutex);
- return dequeueOne().duplicate();
-}
-
-
-Notification* PriorityNotificationQueue::waitDequeueNotification()
-{
- Notification::Ptr pNf;
- WaitInfo* pWI = 0;
- {
- FastMutex::ScopedLock lock(_mutex);
- pNf = dequeueOne();
- if (pNf) return pNf.duplicate();
- pWI = new WaitInfo;
- _waitQueue.push_back(pWI);
- }
- pWI->nfAvailable.wait();
- pNf = pWI->pNf;
- delete pWI;
- return pNf.duplicate();
-}
-
-
-Notification* PriorityNotificationQueue::waitDequeueNotification(long milliseconds)
-{
- Notification::Ptr pNf;
- WaitInfo* pWI = 0;
- {
- FastMutex::ScopedLock lock(_mutex);
- pNf = dequeueOne();
- if (pNf) return pNf.duplicate();
- pWI = new WaitInfo;
- _waitQueue.push_back(pWI);
- }
- if (pWI->nfAvailable.tryWait(milliseconds))
- {
- pNf = pWI->pNf;
- }
- else
- {
- FastMutex::ScopedLock lock(_mutex);
- pNf = pWI->pNf;
- for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it)
- {
- if (*it == pWI)
- {
- _waitQueue.erase(it);
- break;
- }
- }
- }
- delete pWI;
- return pNf.duplicate();
-}
-
-
-void PriorityNotificationQueue::dispatch(NotificationCenter& notificationCenter)
-{
- FastMutex::ScopedLock lock(_mutex);
- Notification::Ptr pNf = dequeueOne();
- while (pNf)
- {
- notificationCenter.postNotification(pNf);
- pNf = dequeueOne();
- }
-}
-
-
-void PriorityNotificationQueue::wakeUpAll()
-{
- FastMutex::ScopedLock lock(_mutex);
- for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it)
- {
- (*it)->nfAvailable.set();
- }
- _waitQueue.clear();
-}
-
-
-bool PriorityNotificationQueue::empty() const
-{
- FastMutex::ScopedLock lock(_mutex);
- return _nfQueue.empty();
-}
-
-
-int PriorityNotificationQueue::size() const
-{
- FastMutex::ScopedLock lock(_mutex);
- return static_cast<int>(_nfQueue.size());
-}
-
-
-void PriorityNotificationQueue::clear()
-{
- FastMutex::ScopedLock lock(_mutex);
- _nfQueue.clear();
-}
-
-
-bool PriorityNotificationQueue::hasIdleThreads() const
-{
- FastMutex::ScopedLock lock(_mutex);
- return !_waitQueue.empty();
-}
-
-
-Notification::Ptr PriorityNotificationQueue::dequeueOne()
-{
- Notification::Ptr pNf;
- NfQueue::iterator it = _nfQueue.begin();
- if (it != _nfQueue.end())
- {
- pNf = it->second;
- _nfQueue.erase(it);
- }
- return pNf;
-}
-
-
-namespace
-{
- static SingletonHolder<PriorityNotificationQueue> sh;
-}
-
-
-PriorityNotificationQueue& PriorityNotificationQueue::defaultQueue()
-{
- return *sh.get();
-}
-
-
-} // namespace Poco
+//
+// PriorityNotificationQueue.cpp
+//
+// Library: Foundation
+// Package: Notifications
+// Module: PriorityNotificationQueue
+//
+// Copyright (c) 2009, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/PriorityNotificationQueue.h"
+#include "Poco/NotificationCenter.h"
+#include "Poco/Notification.h"
+#include "Poco/SingletonHolder.h"
+
+
+namespace Poco {
+
+
+PriorityNotificationQueue::PriorityNotificationQueue()
+{
+}
+
+
+PriorityNotificationQueue::~PriorityNotificationQueue()
+{
+ try
+ {
+ clear();
+ }
+ catch (...)
+ {
+ poco_unexpected();
+ }
+}
+
+
+void PriorityNotificationQueue::enqueueNotification(Notification::Ptr pNotification, int priority)
+{
+ poco_check_ptr (pNotification);
+ FastMutex::ScopedLock lock(_mutex);
+ if (_waitQueue.empty())
+ {
+ _nfQueue.insert(NfQueue::value_type(priority, pNotification));
+ }
+ else
+ {
+ poco_assert_dbg(_nfQueue.empty());
+ WaitInfo* pWI = _waitQueue.front();
+ _waitQueue.pop_front();
+ pWI->pNf = pNotification;
+ pWI->nfAvailable.set();
+ }
+}
+
+
+Notification* PriorityNotificationQueue::dequeueNotification()
+{
+ FastMutex::ScopedLock lock(_mutex);
+ return dequeueOne().duplicate();
+}
+
+
+Notification* PriorityNotificationQueue::waitDequeueNotification()
+{
+ Notification::Ptr pNf;
+ WaitInfo* pWI = 0;
+ {
+ FastMutex::ScopedLock lock(_mutex);
+ pNf = dequeueOne();
+ if (pNf) return pNf.duplicate();
+ pWI = new WaitInfo;
+ _waitQueue.push_back(pWI);
+ }
+ pWI->nfAvailable.wait();
+ pNf = pWI->pNf;
+ delete pWI;
+ return pNf.duplicate();
+}
+
+
+Notification* PriorityNotificationQueue::waitDequeueNotification(long milliseconds)
+{
+ Notification::Ptr pNf;
+ WaitInfo* pWI = 0;
+ {
+ FastMutex::ScopedLock lock(_mutex);
+ pNf = dequeueOne();
+ if (pNf) return pNf.duplicate();
+ pWI = new WaitInfo;
+ _waitQueue.push_back(pWI);
+ }
+ if (pWI->nfAvailable.tryWait(milliseconds))
+ {
+ pNf = pWI->pNf;
+ }
+ else
+ {
+ FastMutex::ScopedLock lock(_mutex);
+ pNf = pWI->pNf;
+ for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it)
+ {
+ if (*it == pWI)
+ {
+ _waitQueue.erase(it);
+ break;
+ }
+ }
+ }
+ delete pWI;
+ return pNf.duplicate();
+}
+
+
+void PriorityNotificationQueue::dispatch(NotificationCenter& notificationCenter)
+{
+ FastMutex::ScopedLock lock(_mutex);
+ Notification::Ptr pNf = dequeueOne();
+ while (pNf)
+ {
+ notificationCenter.postNotification(pNf);
+ pNf = dequeueOne();
+ }
+}
+
+
+void PriorityNotificationQueue::wakeUpAll()
+{
+ FastMutex::ScopedLock lock(_mutex);
+ for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it)
+ {
+ (*it)->nfAvailable.set();
+ }
+ _waitQueue.clear();
+}
+
+
+bool PriorityNotificationQueue::empty() const
+{
+ FastMutex::ScopedLock lock(_mutex);
+ return _nfQueue.empty();
+}
+
+
+int PriorityNotificationQueue::size() const
+{
+ FastMutex::ScopedLock lock(_mutex);
+ return static_cast<int>(_nfQueue.size());
+}
+
+
+void PriorityNotificationQueue::clear()
+{
+ FastMutex::ScopedLock lock(_mutex);
+ _nfQueue.clear();
+}
+
+
+bool PriorityNotificationQueue::hasIdleThreads() const
+{
+ FastMutex::ScopedLock lock(_mutex);
+ return !_waitQueue.empty();
+}
+
+
+Notification::Ptr PriorityNotificationQueue::dequeueOne()
+{
+ Notification::Ptr pNf;
+ NfQueue::iterator it = _nfQueue.begin();
+ if (it != _nfQueue.end())
+ {
+ pNf = it->second;
+ _nfQueue.erase(it);
+ }
+ return pNf;
+}
+
+
+namespace
+{
+ static SingletonHolder<PriorityNotificationQueue> sh;
+}
+
+
+PriorityNotificationQueue& PriorityNotificationQueue::defaultQueue()
+{
+ return *sh.get();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Process.cpp b/contrib/libs/poco/Foundation/src/Process.cpp
index 6cc0b7e6b9..634a44b5b4 100644
--- a/contrib/libs/poco/Foundation/src/Process.cpp
+++ b/contrib/libs/poco/Foundation/src/Process.cpp
@@ -1,197 +1,197 @@
-//
-// Process.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: Process
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Process.h"
-#include "Poco/Environment.h"
-
-
-namespace
-{
- std::vector<char> getEnvironmentVariablesBuffer(const Poco::Process::Env& env)
- {
- std::vector<char> envbuf;
- std::size_t pos = 0;
-
- for (Poco::Process::Env::const_iterator it = env.begin(); it != env.end(); ++it)
- {
- std::size_t envlen = it->first.length() + it->second.length() + 1;
-
- envbuf.resize(pos + envlen + 1);
- std::copy(it->first.begin(), it->first.end(), &envbuf[pos]);
- pos += it->first.length();
- envbuf[pos] = '=';
- ++pos;
- std::copy(it->second.begin(), it->second.end(), &envbuf[pos]);
- pos += it->second.length();
-
- envbuf[pos] = '\0';
- ++pos;
- }
-
- envbuf.resize(pos + 1);
- envbuf[pos] = '\0';
-
- return envbuf;
- }
-}
-
-
-#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
-#if defined(_WIN32_WCE)
-#include "Process_WINCE.cpp"
-#else
-#include "Process_WIN32U.cpp"
-#endif
-#elif defined(POCO_OS_FAMILY_WINDOWS)
-#include "Process_WIN32.cpp"
-#elif defined(POCO_VXWORKS)
-#include "Process_VX.cpp"
-#elif defined(POCO_OS_FAMILY_UNIX)
-#include "Process_UNIX.cpp"
-#endif
-
-
-namespace Poco {
-
-
-//
-// ProcessHandle
-//
-ProcessHandle::ProcessHandle(const ProcessHandle& handle):
- _pImpl(handle._pImpl)
-{
- _pImpl->duplicate();
-}
-
-
-ProcessHandle::~ProcessHandle()
-{
- _pImpl->release();
-}
-
-
-ProcessHandle::ProcessHandle(ProcessHandleImpl* pImpl):
- _pImpl(pImpl)
-{
- poco_check_ptr (_pImpl);
-}
-
-
-ProcessHandle& ProcessHandle::operator = (const ProcessHandle& handle)
-{
- if (&handle != this)
- {
- _pImpl->release();
- _pImpl = handle._pImpl;
- _pImpl->duplicate();
- }
- return *this;
-}
-
-
-ProcessHandle::PID ProcessHandle::id() const
-{
- return _pImpl->id();
-}
-
-
-int ProcessHandle::wait() const
-{
- return _pImpl->wait();
-}
-
-
-//
-// Process
-//
-ProcessHandle Process::launch(const std::string& command, const Args& args)
-{
- std::string initialDirectory;
- Env env;
- return ProcessHandle(launchImpl(command, args, initialDirectory, 0, 0, 0, env));
-}
-
-
-ProcessHandle Process::launch(const std::string& command, const Args& args, const std::string& initialDirectory)
-{
- Env env;
- return ProcessHandle(launchImpl(command, args, initialDirectory, 0, 0, 0, env));
-}
-
-
-ProcessHandle Process::launch(const std::string& command, const Args& args, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe)
-{
- poco_assert (inPipe == 0 || (inPipe != outPipe && inPipe != errPipe));
- std::string initialDirectory;
- Env env;
- return ProcessHandle(launchImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env));
-}
-
-
-ProcessHandle Process::launch(const std::string& command, const Args& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe)
-{
- poco_assert (inPipe == 0 || (inPipe != outPipe && inPipe != errPipe));
- Env env;
- return ProcessHandle(launchImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env));
-}
-
-
-ProcessHandle Process::launch(const std::string& command, const Args& args, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const Env& env)
-{
- poco_assert (inPipe == 0 || (inPipe != outPipe && inPipe != errPipe));
- std::string initialDirectory;
- return ProcessHandle(launchImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env));
-}
-
-
-ProcessHandle Process::launch(const std::string& command, const Args& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const Env& env)
-{
- poco_assert (inPipe == 0 || (inPipe != outPipe && inPipe != errPipe));
- return ProcessHandle(launchImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env));
-}
-
-
-int Process::wait(const ProcessHandle& handle)
-{
- return handle.wait();
-}
-
-
-void Process::kill(ProcessHandle& handle)
-{
- killImpl(*handle._pImpl);
-}
-
-
-void Process::kill(PID pid)
-{
- killImpl(pid);
-}
-
-bool Process::isRunning(const ProcessHandle& handle)
-{
- return isRunningImpl(*handle._pImpl);
-}
-bool Process::isRunning(PID pid)
-{
- return isRunningImpl(pid);
-}
-
-void Process::requestTermination(PID pid)
-{
- requestTerminationImpl(pid);
-}
-
-
-} // namespace Poco
+//
+// Process.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: Process
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Process.h"
+#include "Poco/Environment.h"
+
+
+namespace
+{
+ std::vector<char> getEnvironmentVariablesBuffer(const Poco::Process::Env& env)
+ {
+ std::vector<char> envbuf;
+ std::size_t pos = 0;
+
+ for (Poco::Process::Env::const_iterator it = env.begin(); it != env.end(); ++it)
+ {
+ std::size_t envlen = it->first.length() + it->second.length() + 1;
+
+ envbuf.resize(pos + envlen + 1);
+ std::copy(it->first.begin(), it->first.end(), &envbuf[pos]);
+ pos += it->first.length();
+ envbuf[pos] = '=';
+ ++pos;
+ std::copy(it->second.begin(), it->second.end(), &envbuf[pos]);
+ pos += it->second.length();
+
+ envbuf[pos] = '\0';
+ ++pos;
+ }
+
+ envbuf.resize(pos + 1);
+ envbuf[pos] = '\0';
+
+ return envbuf;
+ }
+}
+
+
+#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
+#if defined(_WIN32_WCE)
+#include "Process_WINCE.cpp"
+#else
+#include "Process_WIN32U.cpp"
+#endif
+#elif defined(POCO_OS_FAMILY_WINDOWS)
+#include "Process_WIN32.cpp"
+#elif defined(POCO_VXWORKS)
+#include "Process_VX.cpp"
+#elif defined(POCO_OS_FAMILY_UNIX)
+#include "Process_UNIX.cpp"
+#endif
+
+
+namespace Poco {
+
+
+//
+// ProcessHandle
+//
+ProcessHandle::ProcessHandle(const ProcessHandle& handle):
+ _pImpl(handle._pImpl)
+{
+ _pImpl->duplicate();
+}
+
+
+ProcessHandle::~ProcessHandle()
+{
+ _pImpl->release();
+}
+
+
+ProcessHandle::ProcessHandle(ProcessHandleImpl* pImpl):
+ _pImpl(pImpl)
+{
+ poco_check_ptr (_pImpl);
+}
+
+
+ProcessHandle& ProcessHandle::operator = (const ProcessHandle& handle)
+{
+ if (&handle != this)
+ {
+ _pImpl->release();
+ _pImpl = handle._pImpl;
+ _pImpl->duplicate();
+ }
+ return *this;
+}
+
+
+ProcessHandle::PID ProcessHandle::id() const
+{
+ return _pImpl->id();
+}
+
+
+int ProcessHandle::wait() const
+{
+ return _pImpl->wait();
+}
+
+
+//
+// Process
+//
+ProcessHandle Process::launch(const std::string& command, const Args& args)
+{
+ std::string initialDirectory;
+ Env env;
+ return ProcessHandle(launchImpl(command, args, initialDirectory, 0, 0, 0, env));
+}
+
+
+ProcessHandle Process::launch(const std::string& command, const Args& args, const std::string& initialDirectory)
+{
+ Env env;
+ return ProcessHandle(launchImpl(command, args, initialDirectory, 0, 0, 0, env));
+}
+
+
+ProcessHandle Process::launch(const std::string& command, const Args& args, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe)
+{
+ poco_assert (inPipe == 0 || (inPipe != outPipe && inPipe != errPipe));
+ std::string initialDirectory;
+ Env env;
+ return ProcessHandle(launchImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env));
+}
+
+
+ProcessHandle Process::launch(const std::string& command, const Args& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe)
+{
+ poco_assert (inPipe == 0 || (inPipe != outPipe && inPipe != errPipe));
+ Env env;
+ return ProcessHandle(launchImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env));
+}
+
+
+ProcessHandle Process::launch(const std::string& command, const Args& args, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const Env& env)
+{
+ poco_assert (inPipe == 0 || (inPipe != outPipe && inPipe != errPipe));
+ std::string initialDirectory;
+ return ProcessHandle(launchImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env));
+}
+
+
+ProcessHandle Process::launch(const std::string& command, const Args& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const Env& env)
+{
+ poco_assert (inPipe == 0 || (inPipe != outPipe && inPipe != errPipe));
+ return ProcessHandle(launchImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env));
+}
+
+
+int Process::wait(const ProcessHandle& handle)
+{
+ return handle.wait();
+}
+
+
+void Process::kill(ProcessHandle& handle)
+{
+ killImpl(*handle._pImpl);
+}
+
+
+void Process::kill(PID pid)
+{
+ killImpl(pid);
+}
+
+bool Process::isRunning(const ProcessHandle& handle)
+{
+ return isRunningImpl(*handle._pImpl);
+}
+bool Process::isRunning(PID pid)
+{
+ return isRunningImpl(pid);
+}
+
+void Process::requestTermination(PID pid)
+{
+ requestTerminationImpl(pid);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Process_UNIX.cpp b/contrib/libs/poco/Foundation/src/Process_UNIX.cpp
index 490b29beb1..96129f6675 100644
--- a/contrib/libs/poco/Foundation/src/Process_UNIX.cpp
+++ b/contrib/libs/poco/Foundation/src/Process_UNIX.cpp
@@ -1,280 +1,280 @@
-//
-// Process_UNIX.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: Process
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Process_UNIX.h"
-#include "Poco/Exception.h"
-#include "Poco/NumberFormatter.h"
-#include "Poco/Pipe.h"
-#include <errno.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/resource.h>
-#include <sys/wait.h>
-
-
-#if defined(__QNX__)
-#include <process.h>
-#include <spawn.h>
-#include <cstring>
-#endif
-
-
-namespace Poco {
-
-
-//
-// ProcessHandleImpl
-//
-ProcessHandleImpl::ProcessHandleImpl(pid_t pid):
- _pid(pid)
-{
-}
-
-
-ProcessHandleImpl::~ProcessHandleImpl()
-{
-}
-
-
-pid_t ProcessHandleImpl::id() const
-{
- return _pid;
-}
-
-
-int ProcessHandleImpl::wait() const
-{
- int status;
- int rc;
- do
- {
- rc = waitpid(_pid, &status, 0);
- }
- while (rc < 0 && errno == EINTR);
- if (rc != _pid)
- throw SystemException("Cannot wait for process", NumberFormatter::format(_pid));
- return WEXITSTATUS(status);
-}
-
-
-//
-// ProcessImpl
-//
-ProcessImpl::PIDImpl ProcessImpl::idImpl()
-{
- return getpid();
-}
-
-
-void ProcessImpl::timesImpl(long& userTime, long& kernelTime)
-{
- struct rusage usage;
- getrusage(RUSAGE_SELF, &usage);
- userTime = usage.ru_utime.tv_sec;
- kernelTime = usage.ru_stime.tv_sec;
-}
-
-
-ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env)
-{
-#if defined(__QNX__)
- if (initialDirectory.empty())
- {
- /// use QNX's spawn system call which is more efficient than fork/exec.
- char** argv = new char*[args.size() + 2];
- int i = 0;
- argv[i++] = const_cast<char*>(command.c_str());
- for (ArgsImpl::const_iterator it = args.begin(); it != args.end(); ++it)
- argv[i++] = const_cast<char*>(it->c_str());
- argv[i] = NULL;
- struct inheritance inherit;
- std::memset(&inherit, 0, sizeof(inherit));
- inherit.flags = SPAWN_ALIGN_DEFAULT | SPAWN_CHECK_SCRIPT | SPAWN_SEARCH_PATH;
- int fdmap[3];
- fdmap[0] = inPipe ? inPipe->readHandle() : 0;
- fdmap[1] = outPipe ? outPipe->writeHandle() : 1;
- fdmap[2] = errPipe ? errPipe->writeHandle() : 2;
-
- char** envPtr = 0;
- std::vector<char> envChars;
- std::vector<char*> envPtrs;
- if (!env.empty())
- {
- envChars = getEnvironmentVariablesBuffer(env);
- envPtrs.reserve(env.size() + 1);
- char* p = &envChars[0];
- while (*p)
- {
- envPtrs.push_back(p);
- while (*p) ++p;
- ++p;
- }
- envPtrs.push_back(0);
- envPtr = &envPtrs[0];
- }
-
- int pid = spawn(command.c_str(), 3, fdmap, &inherit, argv, envPtr);
- delete [] argv;
- if (pid == -1)
- throw SystemException("cannot spawn", command);
-
- if (inPipe) inPipe->close(Pipe::CLOSE_READ);
- if (outPipe) outPipe->close(Pipe::CLOSE_WRITE);
- if (errPipe) errPipe->close(Pipe::CLOSE_WRITE);
- return new ProcessHandleImpl(pid);
- }
- else
- {
- return launchByForkExecImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env);
- }
-#else
- return launchByForkExecImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env);
-#endif
-}
-
-
-ProcessHandleImpl* ProcessImpl::launchByForkExecImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env)
-{
-#if !defined(POCO_NO_FORK_EXEC)
- // We must not allocated memory after fork(),
- // therefore allocate all required buffers first.
- std::vector<char> envChars = getEnvironmentVariablesBuffer(env);
- std::vector<char*> argv(args.size() + 2);
- int i = 0;
- argv[i++] = const_cast<char*>(command.c_str());
- for (ArgsImpl::const_iterator it = args.begin(); it != args.end(); ++it)
- {
- argv[i++] = const_cast<char*>(it->c_str());
- }
- argv[i] = NULL;
-
- const char* pInitialDirectory = initialDirectory.empty() ? 0 : initialDirectory.c_str();
-
- int pid = fork();
- if (pid < 0)
- {
- throw SystemException("Cannot fork process for", command);
- }
- else if (pid == 0)
- {
- if (pInitialDirectory)
- {
- if (chdir(pInitialDirectory) != 0)
- {
- _exit(72);
- }
- }
-
- // set environment variables
- char* p = &envChars[0];
- while (*p)
- {
- putenv(p);
- while (*p) ++p;
- ++p;
- }
-
- // setup redirection
- if (inPipe)
- {
- dup2(inPipe->readHandle(), STDIN_FILENO);
- inPipe->close(Pipe::CLOSE_BOTH);
- }
- // 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 (errPipe) errPipe->close(Pipe::CLOSE_BOTH);
- // close all open file descriptors other than stdin, stdout, stderr
- for (int fd = 3; i < sysconf(_SC_OPEN_MAX); ++fd)
- {
- close(fd);
- }
-
- execvp(argv[0], &argv[0]);
- _exit(72);
- }
-
- if (inPipe) inPipe->close(Pipe::CLOSE_READ);
- if (outPipe) outPipe->close(Pipe::CLOSE_WRITE);
- if (errPipe) errPipe->close(Pipe::CLOSE_WRITE);
- return new ProcessHandleImpl(pid);
-#else
- throw Poco::NotImplementedException("platform does not allow fork/exec");
-#endif
-}
-
-
-void ProcessImpl::killImpl(ProcessHandleImpl& handle)
-{
- killImpl(handle.id());
-}
-
-
-void ProcessImpl::killImpl(PIDImpl pid)
-{
- if (kill(pid, SIGKILL) != 0)
- {
- switch (errno)
- {
- case ESRCH:
- throw NotFoundException("cannot kill process");
- case EPERM:
- throw NoPermissionException("cannot kill process");
- default:
- throw SystemException("cannot kill process");
- }
- }
-}
-
-
-bool ProcessImpl::isRunningImpl(const ProcessHandleImpl& handle)
-{
- return isRunningImpl(handle.id());
-}
-
-
-bool ProcessImpl::isRunningImpl(PIDImpl pid)
-{
- if (kill(pid, 0) == 0)
- {
- return true;
+//
+// Process_UNIX.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: Process
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Process_UNIX.h"
+#include "Poco/Exception.h"
+#include "Poco/NumberFormatter.h"
+#include "Poco/Pipe.h"
+#include <errno.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/resource.h>
+#include <sys/wait.h>
+
+
+#if defined(__QNX__)
+#include <process.h>
+#include <spawn.h>
+#include <cstring>
+#endif
+
+
+namespace Poco {
+
+
+//
+// ProcessHandleImpl
+//
+ProcessHandleImpl::ProcessHandleImpl(pid_t pid):
+ _pid(pid)
+{
+}
+
+
+ProcessHandleImpl::~ProcessHandleImpl()
+{
+}
+
+
+pid_t ProcessHandleImpl::id() const
+{
+ return _pid;
+}
+
+
+int ProcessHandleImpl::wait() const
+{
+ int status;
+ int rc;
+ do
+ {
+ rc = waitpid(_pid, &status, 0);
+ }
+ while (rc < 0 && errno == EINTR);
+ if (rc != _pid)
+ throw SystemException("Cannot wait for process", NumberFormatter::format(_pid));
+ return WEXITSTATUS(status);
+}
+
+
+//
+// ProcessImpl
+//
+ProcessImpl::PIDImpl ProcessImpl::idImpl()
+{
+ return getpid();
+}
+
+
+void ProcessImpl::timesImpl(long& userTime, long& kernelTime)
+{
+ struct rusage usage;
+ getrusage(RUSAGE_SELF, &usage);
+ userTime = usage.ru_utime.tv_sec;
+ kernelTime = usage.ru_stime.tv_sec;
+}
+
+
+ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env)
+{
+#if defined(__QNX__)
+ if (initialDirectory.empty())
+ {
+ /// use QNX's spawn system call which is more efficient than fork/exec.
+ char** argv = new char*[args.size() + 2];
+ int i = 0;
+ argv[i++] = const_cast<char*>(command.c_str());
+ for (ArgsImpl::const_iterator it = args.begin(); it != args.end(); ++it)
+ argv[i++] = const_cast<char*>(it->c_str());
+ argv[i] = NULL;
+ struct inheritance inherit;
+ std::memset(&inherit, 0, sizeof(inherit));
+ inherit.flags = SPAWN_ALIGN_DEFAULT | SPAWN_CHECK_SCRIPT | SPAWN_SEARCH_PATH;
+ int fdmap[3];
+ fdmap[0] = inPipe ? inPipe->readHandle() : 0;
+ fdmap[1] = outPipe ? outPipe->writeHandle() : 1;
+ fdmap[2] = errPipe ? errPipe->writeHandle() : 2;
+
+ char** envPtr = 0;
+ std::vector<char> envChars;
+ std::vector<char*> envPtrs;
+ if (!env.empty())
+ {
+ envChars = getEnvironmentVariablesBuffer(env);
+ envPtrs.reserve(env.size() + 1);
+ char* p = &envChars[0];
+ while (*p)
+ {
+ envPtrs.push_back(p);
+ while (*p) ++p;
+ ++p;
+ }
+ envPtrs.push_back(0);
+ envPtr = &envPtrs[0];
+ }
+
+ int pid = spawn(command.c_str(), 3, fdmap, &inherit, argv, envPtr);
+ delete [] argv;
+ if (pid == -1)
+ throw SystemException("cannot spawn", command);
+
+ if (inPipe) inPipe->close(Pipe::CLOSE_READ);
+ if (outPipe) outPipe->close(Pipe::CLOSE_WRITE);
+ if (errPipe) errPipe->close(Pipe::CLOSE_WRITE);
+ return new ProcessHandleImpl(pid);
}
else
- {
- return false;
- }
-}
-
-
-void ProcessImpl::requestTerminationImpl(PIDImpl pid)
-{
- if (kill(pid, SIGINT) != 0)
- {
- switch (errno)
- {
- case ESRCH:
- throw NotFoundException("cannot terminate process");
- case EPERM:
- throw NoPermissionException("cannot terminate process");
- default:
- throw SystemException("cannot terminate process");
- }
- }
-}
-
-
-} // namespace Poco
+ {
+ return launchByForkExecImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env);
+ }
+#else
+ return launchByForkExecImpl(command, args, initialDirectory, inPipe, outPipe, errPipe, env);
+#endif
+}
+
+
+ProcessHandleImpl* ProcessImpl::launchByForkExecImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env)
+{
+#if !defined(POCO_NO_FORK_EXEC)
+ // We must not allocated memory after fork(),
+ // therefore allocate all required buffers first.
+ std::vector<char> envChars = getEnvironmentVariablesBuffer(env);
+ std::vector<char*> argv(args.size() + 2);
+ int i = 0;
+ argv[i++] = const_cast<char*>(command.c_str());
+ for (ArgsImpl::const_iterator it = args.begin(); it != args.end(); ++it)
+ {
+ argv[i++] = const_cast<char*>(it->c_str());
+ }
+ argv[i] = NULL;
+
+ const char* pInitialDirectory = initialDirectory.empty() ? 0 : initialDirectory.c_str();
+
+ int pid = fork();
+ if (pid < 0)
+ {
+ throw SystemException("Cannot fork process for", command);
+ }
+ else if (pid == 0)
+ {
+ if (pInitialDirectory)
+ {
+ if (chdir(pInitialDirectory) != 0)
+ {
+ _exit(72);
+ }
+ }
+
+ // set environment variables
+ char* p = &envChars[0];
+ while (*p)
+ {
+ putenv(p);
+ while (*p) ++p;
+ ++p;
+ }
+
+ // setup redirection
+ if (inPipe)
+ {
+ dup2(inPipe->readHandle(), STDIN_FILENO);
+ inPipe->close(Pipe::CLOSE_BOTH);
+ }
+ // 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 (errPipe) errPipe->close(Pipe::CLOSE_BOTH);
+ // close all open file descriptors other than stdin, stdout, stderr
+ for (int fd = 3; i < sysconf(_SC_OPEN_MAX); ++fd)
+ {
+ close(fd);
+ }
+
+ execvp(argv[0], &argv[0]);
+ _exit(72);
+ }
+
+ if (inPipe) inPipe->close(Pipe::CLOSE_READ);
+ if (outPipe) outPipe->close(Pipe::CLOSE_WRITE);
+ if (errPipe) errPipe->close(Pipe::CLOSE_WRITE);
+ return new ProcessHandleImpl(pid);
+#else
+ throw Poco::NotImplementedException("platform does not allow fork/exec");
+#endif
+}
+
+
+void ProcessImpl::killImpl(ProcessHandleImpl& handle)
+{
+ killImpl(handle.id());
+}
+
+
+void ProcessImpl::killImpl(PIDImpl pid)
+{
+ if (kill(pid, SIGKILL) != 0)
+ {
+ switch (errno)
+ {
+ case ESRCH:
+ throw NotFoundException("cannot kill process");
+ case EPERM:
+ throw NoPermissionException("cannot kill process");
+ default:
+ throw SystemException("cannot kill process");
+ }
+ }
+}
+
+
+bool ProcessImpl::isRunningImpl(const ProcessHandleImpl& handle)
+{
+ return isRunningImpl(handle.id());
+}
+
+
+bool ProcessImpl::isRunningImpl(PIDImpl pid)
+{
+ if (kill(pid, 0) == 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+
+void ProcessImpl::requestTerminationImpl(PIDImpl pid)
+{
+ if (kill(pid, SIGINT) != 0)
+ {
+ switch (errno)
+ {
+ case ESRCH:
+ throw NotFoundException("cannot terminate process");
+ case EPERM:
+ throw NoPermissionException("cannot terminate process");
+ default:
+ throw SystemException("cannot terminate process");
+ }
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Process_VX.cpp b/contrib/libs/poco/Foundation/src/Process_VX.cpp
index 699feb9be7..187c36f2ca 100644
--- a/contrib/libs/poco/Foundation/src/Process_VX.cpp
+++ b/contrib/libs/poco/Foundation/src/Process_VX.cpp
@@ -1,100 +1,100 @@
-//
-// Process_VX.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: Process
-//
-// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Process_VX.h"
-#include "Poco/Exception.h"
-
-
-namespace Poco {
-
-
-//
-// ProcessHandleImpl
-//
-ProcessHandleImpl::ProcessHandleImpl(int pid):
- _pid(pid)
-{
-}
-
-
-ProcessHandleImpl::~ProcessHandleImpl()
-{
-}
-
-
-int ProcessHandleImpl::id() const
-{
- return _pid;
-}
-
-
-int ProcessHandleImpl::wait() const
-{
- throw Poco::NotImplementedException("Process::wait()");
-}
-
-
-//
-// ProcessImpl
-//
-ProcessImpl::PIDImpl ProcessImpl::idImpl()
-{
- return 0;
-}
-
-
-void ProcessImpl::timesImpl(long& userTime, long& kernelTime)
-{
- userTime = 0;
- kernelTime = 0;
-}
-
-
-ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory,Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env)
-{
- throw Poco::NotImplementedException("Process::launch()");
-}
-
-
-void ProcessImpl::killImpl(ProcessHandleImpl& handle)
-{
- throw Poco::NotImplementedException("Process::kill()");
-}
-
-
-void ProcessImpl::killImpl(PIDImpl pid)
-{
- throw Poco::NotImplementedException("Process::kill()");
-}
-
-
-bool ProcessImpl::isRunningImpl(const ProcessHandleImpl& handle)
-{
- throw Poco::NotImplementedException("Process::is_running()");
-}
-
-
-bool ProcessImpl::isRunningImpl(PIDImpl pid)
-{
- throw Poco::NotImplementedException("Process::is_running()");
-}
-
-
-void ProcessImpl::requestTerminationImpl(PIDImpl pid)
-{
- throw Poco::NotImplementedException("Process::requestTermination()");
-}
-
-
-} // namespace Poco
+//
+// Process_VX.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: Process
+//
+// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Process_VX.h"
+#include "Poco/Exception.h"
+
+
+namespace Poco {
+
+
+//
+// ProcessHandleImpl
+//
+ProcessHandleImpl::ProcessHandleImpl(int pid):
+ _pid(pid)
+{
+}
+
+
+ProcessHandleImpl::~ProcessHandleImpl()
+{
+}
+
+
+int ProcessHandleImpl::id() const
+{
+ return _pid;
+}
+
+
+int ProcessHandleImpl::wait() const
+{
+ throw Poco::NotImplementedException("Process::wait()");
+}
+
+
+//
+// ProcessImpl
+//
+ProcessImpl::PIDImpl ProcessImpl::idImpl()
+{
+ return 0;
+}
+
+
+void ProcessImpl::timesImpl(long& userTime, long& kernelTime)
+{
+ userTime = 0;
+ kernelTime = 0;
+}
+
+
+ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory,Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env)
+{
+ throw Poco::NotImplementedException("Process::launch()");
+}
+
+
+void ProcessImpl::killImpl(ProcessHandleImpl& handle)
+{
+ throw Poco::NotImplementedException("Process::kill()");
+}
+
+
+void ProcessImpl::killImpl(PIDImpl pid)
+{
+ throw Poco::NotImplementedException("Process::kill()");
+}
+
+
+bool ProcessImpl::isRunningImpl(const ProcessHandleImpl& handle)
+{
+ throw Poco::NotImplementedException("Process::is_running()");
+}
+
+
+bool ProcessImpl::isRunningImpl(PIDImpl pid)
+{
+ throw Poco::NotImplementedException("Process::is_running()");
+}
+
+
+void ProcessImpl::requestTerminationImpl(PIDImpl pid)
+{
+ throw Poco::NotImplementedException("Process::requestTermination()");
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Process_WIN32.cpp b/contrib/libs/poco/Foundation/src/Process_WIN32.cpp
index d698a9726e..6174e9adea 100644
--- a/contrib/libs/poco/Foundation/src/Process_WIN32.cpp
+++ b/contrib/libs/poco/Foundation/src/Process_WIN32.cpp
@@ -1,349 +1,349 @@
-//
-// Process_WIN32.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: Process
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Process_WIN32.h"
-#include "Poco/Exception.h"
-#include "Poco/NumberFormatter.h"
-#include "Poco/NamedEvent.h"
-#include "Poco/Pipe.h"
-
-
-namespace Poco {
-
-
-//
-// ProcessHandleImpl
-//
-ProcessHandleImpl::ProcessHandleImpl(HANDLE hProcess, UInt32 pid) :
- _hProcess(hProcess),
- _pid(pid)
-{
-}
-
-
-ProcessHandleImpl::~ProcessHandleImpl()
-{
- closeHandle();
-}
-
-
-void ProcessHandleImpl::closeHandle()
-{
- if (_hProcess)
- {
- CloseHandle(_hProcess);
- _hProcess = NULL;
- }
-}
-
-
-UInt32 ProcessHandleImpl::id() const
-{
- return _pid;
-}
-
-
-HANDLE ProcessHandleImpl::process() const
-{
- return _hProcess;
-}
-
-
-int ProcessHandleImpl::wait() const
-{
- DWORD rc = WaitForSingleObject(_hProcess, INFINITE);
- if (rc != WAIT_OBJECT_0)
- throw SystemException("Wait failed for process", NumberFormatter::format(_pid));
-
- DWORD exitCode;
- if (GetExitCodeProcess(_hProcess, &exitCode) == 0)
- throw SystemException("Cannot get exit code for process", NumberFormatter::format(_pid));
-
- return exitCode;
-}
-
-
-//
-// ProcessImpl
-//
-ProcessImpl::PIDImpl ProcessImpl::idImpl()
-{
- return GetCurrentProcessId();
-}
-
-
-void ProcessImpl::timesImpl(long& userTime, long& kernelTime)
-{
- FILETIME ftCreation;
- FILETIME ftExit;
- FILETIME ftKernel;
- FILETIME ftUser;
-
- if (GetProcessTimes(GetCurrentProcess(), &ftCreation, &ftExit, &ftKernel, &ftUser) != 0)
- {
- ULARGE_INTEGER time;
- time.LowPart = ftKernel.dwLowDateTime;
- time.HighPart = ftKernel.dwHighDateTime;
- kernelTime = long(time.QuadPart / 10000000L);
- time.LowPart = ftUser.dwLowDateTime;
- time.HighPart = ftUser.dwHighDateTime;
- userTime = long(time.QuadPart / 10000000L);
+//
+// Process_WIN32.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: Process
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Process_WIN32.h"
+#include "Poco/Exception.h"
+#include "Poco/NumberFormatter.h"
+#include "Poco/NamedEvent.h"
+#include "Poco/Pipe.h"
+
+
+namespace Poco {
+
+
+//
+// ProcessHandleImpl
+//
+ProcessHandleImpl::ProcessHandleImpl(HANDLE hProcess, UInt32 pid) :
+ _hProcess(hProcess),
+ _pid(pid)
+{
+}
+
+
+ProcessHandleImpl::~ProcessHandleImpl()
+{
+ closeHandle();
+}
+
+
+void ProcessHandleImpl::closeHandle()
+{
+ if (_hProcess)
+ {
+ CloseHandle(_hProcess);
+ _hProcess = NULL;
}
- else
- {
- userTime = kernelTime = -1;
- }
-}
-
-
-static bool argNeedsEscaping(const std::string& arg)
-{
- bool containsQuotableChar = std::string::npos != arg.find_first_of(" \t\n\v\"");
- // Assume args that start and end with quotes are already quoted and do not require further quoting.
- // There is probably code out there written before launch() escaped the arguments that does its own
- // escaping of arguments. This ensures we do not interfere with those arguments.
- bool isAlreadyQuoted = arg.size() > 1 && '\"' == arg[0] && '\"' == arg[arg.size() - 1];
- return containsQuotableChar && !isAlreadyQuoted;
-}
-
-
-// Based on code from https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/
-static std::string escapeArg(const std::string& arg)
-{
- if (argNeedsEscaping(arg))
- {
- std::string quotedArg("\"");
- for (std::string::const_iterator it = arg.begin(); ; ++it)
- {
- unsigned backslashCount = 0;
- while (it != arg.end() && '\\' == *it)
- {
- ++it;
- ++backslashCount;
- }
-
- if (it == arg.end())
- {
- quotedArg.append(2 * backslashCount, '\\');
- break;
+}
+
+
+UInt32 ProcessHandleImpl::id() const
+{
+ return _pid;
+}
+
+
+HANDLE ProcessHandleImpl::process() const
+{
+ return _hProcess;
+}
+
+
+int ProcessHandleImpl::wait() const
+{
+ DWORD rc = WaitForSingleObject(_hProcess, INFINITE);
+ if (rc != WAIT_OBJECT_0)
+ throw SystemException("Wait failed for process", NumberFormatter::format(_pid));
+
+ DWORD exitCode;
+ if (GetExitCodeProcess(_hProcess, &exitCode) == 0)
+ throw SystemException("Cannot get exit code for process", NumberFormatter::format(_pid));
+
+ return exitCode;
+}
+
+
+//
+// ProcessImpl
+//
+ProcessImpl::PIDImpl ProcessImpl::idImpl()
+{
+ return GetCurrentProcessId();
+}
+
+
+void ProcessImpl::timesImpl(long& userTime, long& kernelTime)
+{
+ FILETIME ftCreation;
+ FILETIME ftExit;
+ FILETIME ftKernel;
+ FILETIME ftUser;
+
+ if (GetProcessTimes(GetCurrentProcess(), &ftCreation, &ftExit, &ftKernel, &ftUser) != 0)
+ {
+ ULARGE_INTEGER time;
+ time.LowPart = ftKernel.dwLowDateTime;
+ time.HighPart = ftKernel.dwHighDateTime;
+ kernelTime = long(time.QuadPart / 10000000L);
+ time.LowPart = ftUser.dwLowDateTime;
+ time.HighPart = ftUser.dwHighDateTime;
+ userTime = long(time.QuadPart / 10000000L);
+ }
+ else
+ {
+ userTime = kernelTime = -1;
+ }
+}
+
+
+static bool argNeedsEscaping(const std::string& arg)
+{
+ bool containsQuotableChar = std::string::npos != arg.find_first_of(" \t\n\v\"");
+ // Assume args that start and end with quotes are already quoted and do not require further quoting.
+ // There is probably code out there written before launch() escaped the arguments that does its own
+ // escaping of arguments. This ensures we do not interfere with those arguments.
+ bool isAlreadyQuoted = arg.size() > 1 && '\"' == arg[0] && '\"' == arg[arg.size() - 1];
+ return containsQuotableChar && !isAlreadyQuoted;
+}
+
+
+// Based on code from https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/
+static std::string escapeArg(const std::string& arg)
+{
+ if (argNeedsEscaping(arg))
+ {
+ std::string quotedArg("\"");
+ for (std::string::const_iterator it = arg.begin(); ; ++it)
+ {
+ unsigned backslashCount = 0;
+ while (it != arg.end() && '\\' == *it)
+ {
+ ++it;
+ ++backslashCount;
}
- else if ('"' == *it)
- {
- quotedArg.append(2 * backslashCount + 1, '\\');
- quotedArg.push_back('"');
+
+ if (it == arg.end())
+ {
+ quotedArg.append(2 * backslashCount, '\\');
+ break;
+ }
+ else if ('"' == *it)
+ {
+ quotedArg.append(2 * backslashCount + 1, '\\');
+ quotedArg.push_back('"');
+ }
+ else
+ {
+ quotedArg.append(backslashCount, '\\');
+ quotedArg.push_back(*it);
}
- else
- {
- quotedArg.append(backslashCount, '\\');
- quotedArg.push_back(*it);
- }
- }
- quotedArg.push_back('"');
- return quotedArg;
+ }
+ quotedArg.push_back('"');
+ return quotedArg;
+ }
+ else
+ {
+ return arg;
}
- else
- {
- return arg;
- }
-}
-
-
-ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env)
-{
- std::string commandLine = command;
- for (ArgsImpl::const_iterator it = args.begin(); it != args.end(); ++it)
- {
- commandLine.append(" ");
- commandLine.append(escapeArg(*it));
- }
-
- STARTUPINFOA startupInfo;
- GetStartupInfoA(&startupInfo); // take defaults from current process
- startupInfo.cb = sizeof(STARTUPINFOA);
- startupInfo.lpReserved = NULL;
- startupInfo.lpDesktop = NULL;
- startupInfo.lpTitle = NULL;
- startupInfo.dwFlags = STARTF_FORCEOFFFEEDBACK;
- startupInfo.cbReserved2 = 0;
- startupInfo.lpReserved2 = NULL;
-
- HANDLE hProc = GetCurrentProcess();
- bool mustInheritHandles = false;
- if (inPipe)
- {
- DuplicateHandle(hProc, inPipe->readHandle(), hProc, &startupInfo.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS);
- mustInheritHandles = true;
- inPipe->close(Pipe::CLOSE_READ);
+}
+
+
+ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env)
+{
+ std::string commandLine = command;
+ for (ArgsImpl::const_iterator it = args.begin(); it != args.end(); ++it)
+ {
+ commandLine.append(" ");
+ commandLine.append(escapeArg(*it));
}
- else if (GetStdHandle(STD_INPUT_HANDLE))
- {
- DuplicateHandle(hProc, GetStdHandle(STD_INPUT_HANDLE), hProc, &startupInfo.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS);
- mustInheritHandles = true;
+
+ STARTUPINFOA startupInfo;
+ GetStartupInfoA(&startupInfo); // take defaults from current process
+ startupInfo.cb = sizeof(STARTUPINFOA);
+ startupInfo.lpReserved = NULL;
+ startupInfo.lpDesktop = NULL;
+ startupInfo.lpTitle = NULL;
+ startupInfo.dwFlags = STARTF_FORCEOFFFEEDBACK;
+ startupInfo.cbReserved2 = 0;
+ startupInfo.lpReserved2 = NULL;
+
+ HANDLE hProc = GetCurrentProcess();
+ bool mustInheritHandles = false;
+ if (inPipe)
+ {
+ DuplicateHandle(hProc, inPipe->readHandle(), hProc, &startupInfo.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS);
+ mustInheritHandles = true;
+ inPipe->close(Pipe::CLOSE_READ);
+ }
+ else if (GetStdHandle(STD_INPUT_HANDLE))
+ {
+ DuplicateHandle(hProc, GetStdHandle(STD_INPUT_HANDLE), hProc, &startupInfo.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS);
+ mustInheritHandles = true;
+ }
+ else
+ {
+ startupInfo.hStdInput = 0;
}
- else
- {
- startupInfo.hStdInput = 0;
- }
- // outPipe may be the same as errPipe, so we duplicate first and close later.
- if (outPipe)
- {
- DuplicateHandle(hProc, outPipe->writeHandle(), hProc, &startupInfo.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS);
- mustInheritHandles = true;
+ // outPipe may be the same as errPipe, so we duplicate first and close later.
+ if (outPipe)
+ {
+ DuplicateHandle(hProc, outPipe->writeHandle(), hProc, &startupInfo.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS);
+ mustInheritHandles = true;
+ }
+ else if (GetStdHandle(STD_OUTPUT_HANDLE))
+ {
+ DuplicateHandle(hProc, GetStdHandle(STD_OUTPUT_HANDLE), hProc, &startupInfo.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS);
+ mustInheritHandles = true;
+ }
+ else
+ {
+ startupInfo.hStdOutput = 0;
}
- else if (GetStdHandle(STD_OUTPUT_HANDLE))
- {
- DuplicateHandle(hProc, GetStdHandle(STD_OUTPUT_HANDLE), hProc, &startupInfo.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS);
- mustInheritHandles = true;
+ if (errPipe)
+ {
+ DuplicateHandle(hProc, errPipe->writeHandle(), hProc, &startupInfo.hStdError, 0, TRUE, DUPLICATE_SAME_ACCESS);
+ mustInheritHandles = true;
+ }
+ else if (GetStdHandle(STD_ERROR_HANDLE))
+ {
+ DuplicateHandle(hProc, GetStdHandle(STD_ERROR_HANDLE), hProc, &startupInfo.hStdError, 0, TRUE, DUPLICATE_SAME_ACCESS);
+ mustInheritHandles = true;
+ }
+ else
+ {
+ startupInfo.hStdError = 0;
}
- else
- {
- startupInfo.hStdOutput = 0;
- }
- if (errPipe)
- {
- DuplicateHandle(hProc, errPipe->writeHandle(), hProc, &startupInfo.hStdError, 0, TRUE, DUPLICATE_SAME_ACCESS);
- mustInheritHandles = true;
+ if (outPipe) outPipe->close(Pipe::CLOSE_WRITE);
+ if (errPipe) errPipe->close(Pipe::CLOSE_WRITE);
+
+ if (mustInheritHandles)
+ {
+ startupInfo.dwFlags |= STARTF_USESTDHANDLES;
}
- else if (GetStdHandle(STD_ERROR_HANDLE))
- {
- DuplicateHandle(hProc, GetStdHandle(STD_ERROR_HANDLE), hProc, &startupInfo.hStdError, 0, TRUE, DUPLICATE_SAME_ACCESS);
- mustInheritHandles = true;
+
+ const char* workingDirectory = initialDirectory.empty() ? 0 : initialDirectory.c_str();
+
+ const char* pEnv = 0;
+ std::vector<char> envChars;
+ if (!env.empty())
+ {
+ envChars = getEnvironmentVariablesBuffer(env);
+ pEnv = &envChars[0];
}
- else
- {
- startupInfo.hStdError = 0;
- }
- if (outPipe) outPipe->close(Pipe::CLOSE_WRITE);
- if (errPipe) errPipe->close(Pipe::CLOSE_WRITE);
-
- if (mustInheritHandles)
- {
- startupInfo.dwFlags |= STARTF_USESTDHANDLES;
- }
-
- const char* workingDirectory = initialDirectory.empty() ? 0 : initialDirectory.c_str();
-
- const char* pEnv = 0;
- std::vector<char> envChars;
- if (!env.empty())
- {
- envChars = getEnvironmentVariablesBuffer(env);
- pEnv = &envChars[0];
- }
-
- PROCESS_INFORMATION processInfo;
- DWORD creationFlags = GetConsoleWindow() ? 0 : CREATE_NO_WINDOW;
- BOOL rc = CreateProcessA(
- NULL,
- const_cast<char*>(commandLine.c_str()),
- NULL, // processAttributes
- NULL, // threadAttributes
- mustInheritHandles,
- creationFlags,
- (LPVOID)pEnv,
- workingDirectory,
- &startupInfo,
- &processInfo
- );
- if (startupInfo.hStdInput) CloseHandle(startupInfo.hStdInput);
- if (startupInfo.hStdOutput) CloseHandle(startupInfo.hStdOutput);
- if (startupInfo.hStdError) CloseHandle(startupInfo.hStdError);
- if (rc)
- {
- CloseHandle(processInfo.hThread);
- return new ProcessHandleImpl(processInfo.hProcess, processInfo.dwProcessId);
+
+ PROCESS_INFORMATION processInfo;
+ DWORD creationFlags = GetConsoleWindow() ? 0 : CREATE_NO_WINDOW;
+ BOOL rc = CreateProcessA(
+ NULL,
+ const_cast<char*>(commandLine.c_str()),
+ NULL, // processAttributes
+ NULL, // threadAttributes
+ mustInheritHandles,
+ creationFlags,
+ (LPVOID)pEnv,
+ workingDirectory,
+ &startupInfo,
+ &processInfo
+ );
+ if (startupInfo.hStdInput) CloseHandle(startupInfo.hStdInput);
+ if (startupInfo.hStdOutput) CloseHandle(startupInfo.hStdOutput);
+ if (startupInfo.hStdError) CloseHandle(startupInfo.hStdError);
+ if (rc)
+ {
+ CloseHandle(processInfo.hThread);
+ return new ProcessHandleImpl(processInfo.hProcess, processInfo.dwProcessId);
+ }
+ else throw SystemException("Cannot launch process", command);
+}
+
+
+void ProcessImpl::killImpl(ProcessHandleImpl& handle)
+{
+ if (handle.process())
+ {
+ if (TerminateProcess(handle.process(), 0) == 0)
+ {
+ handle.closeHandle();
+ throw SystemException("cannot kill process");
+ }
+ handle.closeHandle();
}
- else throw SystemException("Cannot launch process", command);
-}
-
-
-void ProcessImpl::killImpl(ProcessHandleImpl& handle)
-{
- if (handle.process())
- {
- if (TerminateProcess(handle.process(), 0) == 0)
- {
- handle.closeHandle();
- throw SystemException("cannot kill process");
- }
- handle.closeHandle();
- }
-}
-
-void ProcessImpl::killImpl(PIDImpl pid)
-{
- HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
- if (hProc)
- {
- if (TerminateProcess(hProc, 0) == 0)
- {
- CloseHandle(hProc);
- throw SystemException("cannot kill process");
- }
- CloseHandle(hProc);
+}
+
+void ProcessImpl::killImpl(PIDImpl pid)
+{
+ HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
+ if (hProc)
+ {
+ if (TerminateProcess(hProc, 0) == 0)
+ {
+ CloseHandle(hProc);
+ throw SystemException("cannot kill process");
+ }
+ CloseHandle(hProc);
+ }
+ else
+ {
+ switch (GetLastError())
+ {
+ case ERROR_ACCESS_DENIED:
+ throw NoPermissionException("cannot kill process");
+ case ERROR_NOT_FOUND:
+ throw NotFoundException("cannot kill process");
+ case ERROR_INVALID_PARAMETER:
+ throw NotFoundException("cannot kill process");
+ default:
+ throw SystemException("cannot kill process");
+ }
}
- else
- {
- switch (GetLastError())
- {
- case ERROR_ACCESS_DENIED:
- throw NoPermissionException("cannot kill process");
- case ERROR_NOT_FOUND:
- throw NotFoundException("cannot kill process");
- case ERROR_INVALID_PARAMETER:
- throw NotFoundException("cannot kill process");
- default:
- throw SystemException("cannot kill process");
- }
- }
-}
-
-
-bool ProcessImpl::isRunningImpl(const ProcessHandleImpl& handle)
-{
- bool result = true;
- DWORD exitCode;
- BOOL rc = GetExitCodeProcess(handle.process(), &exitCode);
- if (!rc || exitCode != STILL_ACTIVE) result = false;
- return result;
-}
-
-
-bool ProcessImpl::isRunningImpl(PIDImpl pid)
-{
- HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
- bool result = true;
- DWORD exitCode;
- BOOL rc = GetExitCodeProcess(hProc, &exitCode);
- if (!rc || exitCode != STILL_ACTIVE) result = false;
- return result;
-}
-
-
-void ProcessImpl::requestTerminationImpl(PIDImpl pid)
-{
- NamedEvent ev(terminationEventName(pid));
- ev.set();
-}
-
-
-std::string ProcessImpl::terminationEventName(PIDImpl pid)
-{
- std::string evName("POCOTRM");
- NumberFormatter::appendHex(evName, pid, 8);
- return evName;
-}
-
-
-} // namespace Poco
+}
+
+
+bool ProcessImpl::isRunningImpl(const ProcessHandleImpl& handle)
+{
+ bool result = true;
+ DWORD exitCode;
+ BOOL rc = GetExitCodeProcess(handle.process(), &exitCode);
+ if (!rc || exitCode != STILL_ACTIVE) result = false;
+ return result;
+}
+
+
+bool ProcessImpl::isRunningImpl(PIDImpl pid)
+{
+ HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
+ bool result = true;
+ DWORD exitCode;
+ BOOL rc = GetExitCodeProcess(hProc, &exitCode);
+ if (!rc || exitCode != STILL_ACTIVE) result = false;
+ return result;
+}
+
+
+void ProcessImpl::requestTerminationImpl(PIDImpl pid)
+{
+ NamedEvent ev(terminationEventName(pid));
+ ev.set();
+}
+
+
+std::string ProcessImpl::terminationEventName(PIDImpl pid)
+{
+ std::string evName("POCOTRM");
+ NumberFormatter::appendHex(evName, pid, 8);
+ return evName;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Process_WIN32U.cpp b/contrib/libs/poco/Foundation/src/Process_WIN32U.cpp
index 2a81a8dd46..ff79dbb6ef 100644
--- a/contrib/libs/poco/Foundation/src/Process_WIN32U.cpp
+++ b/contrib/libs/poco/Foundation/src/Process_WIN32U.cpp
@@ -1,371 +1,371 @@
-//
-// Process_WIN32U.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: Process
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Process_WIN32U.h"
-#include "Poco/Exception.h"
-#include "Poco/NumberFormatter.h"
-#include "Poco/NamedEvent.h"
-#include "Poco/UnicodeConverter.h"
-#include "Poco/Pipe.h"
-#include "Poco/File.h"
-#include "Poco/Path.h"
-#include "Poco/String.h"
-
-
-namespace Poco {
-
-
-//
-// ProcessHandleImpl
-//
-ProcessHandleImpl::ProcessHandleImpl(HANDLE hProcess, UInt32 pid) :
- _hProcess(hProcess),
- _pid(pid)
-{
-}
-
-
-ProcessHandleImpl::~ProcessHandleImpl()
-{
- closeHandle();
-}
-
-
-void ProcessHandleImpl::closeHandle()
-{
- if (_hProcess)
- {
- CloseHandle(_hProcess);
- _hProcess = NULL;
- }
-}
-
-
-UInt32 ProcessHandleImpl::id() const
-{
- return _pid;
-}
-
-
-HANDLE ProcessHandleImpl::process() const
-{
- return _hProcess;
-}
-
-
-int ProcessHandleImpl::wait() const
-{
- DWORD rc = WaitForSingleObject(_hProcess, INFINITE);
- if (rc != WAIT_OBJECT_0)
- throw SystemException("Wait failed for process", NumberFormatter::format(_pid));
-
- DWORD exitCode;
- if (GetExitCodeProcess(_hProcess, &exitCode) == 0)
- throw SystemException("Cannot get exit code for process", NumberFormatter::format(_pid));
-
- return exitCode;
-}
-
-
-//
-// ProcessImpl
-//
-ProcessImpl::PIDImpl ProcessImpl::idImpl()
-{
- return GetCurrentProcessId();
-}
-
-
-void ProcessImpl::timesImpl(long& userTime, long& kernelTime)
-{
- FILETIME ftCreation;
- FILETIME ftExit;
- FILETIME ftKernel;
- FILETIME ftUser;
-
- if (GetProcessTimes(GetCurrentProcess(), &ftCreation, &ftExit, &ftKernel, &ftUser) != 0)
- {
- ULARGE_INTEGER time;
- time.LowPart = ftKernel.dwLowDateTime;
- time.HighPart = ftKernel.dwHighDateTime;
- kernelTime = long(time.QuadPart / 10000000L);
- time.LowPart = ftUser.dwLowDateTime;
- time.HighPart = ftUser.dwHighDateTime;
- userTime = long(time.QuadPart / 10000000L);
+//
+// Process_WIN32U.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: Process
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Process_WIN32U.h"
+#include "Poco/Exception.h"
+#include "Poco/NumberFormatter.h"
+#include "Poco/NamedEvent.h"
+#include "Poco/UnicodeConverter.h"
+#include "Poco/Pipe.h"
+#include "Poco/File.h"
+#include "Poco/Path.h"
+#include "Poco/String.h"
+
+
+namespace Poco {
+
+
+//
+// ProcessHandleImpl
+//
+ProcessHandleImpl::ProcessHandleImpl(HANDLE hProcess, UInt32 pid) :
+ _hProcess(hProcess),
+ _pid(pid)
+{
+}
+
+
+ProcessHandleImpl::~ProcessHandleImpl()
+{
+ closeHandle();
+}
+
+
+void ProcessHandleImpl::closeHandle()
+{
+ if (_hProcess)
+ {
+ CloseHandle(_hProcess);
+ _hProcess = NULL;
}
- else
- {
- userTime = kernelTime = -1;
- }
-}
-
-
-static bool argNeedsEscaping(const std::string& arg)
-{
- bool containsQuotableChar = std::string::npos != arg.find_first_of(" \t\n\v\"");
- // Assume args that start and end with quotes are already quoted and do not require further quoting.
- // There is probably code out there written before launch() escaped the arguments that does its own
- // escaping of arguments. This ensures we do not interfere with those arguments.
- bool isAlreadyQuoted = arg.size() > 1 && '\"' == arg[0] && '\"' == arg[arg.size() - 1];
- return containsQuotableChar && !isAlreadyQuoted;
-}
-
-
-// Based on code from https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/
-static std::string escapeArg(const std::string& arg)
-{
- if (argNeedsEscaping(arg))
- {
- std::string quotedArg("\"");
- for (std::string::const_iterator it = arg.begin(); ; ++it)
- {
- unsigned backslashCount = 0;
- while (it != arg.end() && '\\' == *it)
- {
- ++it;
- ++backslashCount;
- }
-
- if (it == arg.end())
- {
- quotedArg.append(2 * backslashCount, '\\');
- break;
+}
+
+
+UInt32 ProcessHandleImpl::id() const
+{
+ return _pid;
+}
+
+
+HANDLE ProcessHandleImpl::process() const
+{
+ return _hProcess;
+}
+
+
+int ProcessHandleImpl::wait() const
+{
+ DWORD rc = WaitForSingleObject(_hProcess, INFINITE);
+ if (rc != WAIT_OBJECT_0)
+ throw SystemException("Wait failed for process", NumberFormatter::format(_pid));
+
+ DWORD exitCode;
+ if (GetExitCodeProcess(_hProcess, &exitCode) == 0)
+ throw SystemException("Cannot get exit code for process", NumberFormatter::format(_pid));
+
+ return exitCode;
+}
+
+
+//
+// ProcessImpl
+//
+ProcessImpl::PIDImpl ProcessImpl::idImpl()
+{
+ return GetCurrentProcessId();
+}
+
+
+void ProcessImpl::timesImpl(long& userTime, long& kernelTime)
+{
+ FILETIME ftCreation;
+ FILETIME ftExit;
+ FILETIME ftKernel;
+ FILETIME ftUser;
+
+ if (GetProcessTimes(GetCurrentProcess(), &ftCreation, &ftExit, &ftKernel, &ftUser) != 0)
+ {
+ ULARGE_INTEGER time;
+ time.LowPart = ftKernel.dwLowDateTime;
+ time.HighPart = ftKernel.dwHighDateTime;
+ kernelTime = long(time.QuadPart / 10000000L);
+ time.LowPart = ftUser.dwLowDateTime;
+ time.HighPart = ftUser.dwHighDateTime;
+ userTime = long(time.QuadPart / 10000000L);
+ }
+ else
+ {
+ userTime = kernelTime = -1;
+ }
+}
+
+
+static bool argNeedsEscaping(const std::string& arg)
+{
+ bool containsQuotableChar = std::string::npos != arg.find_first_of(" \t\n\v\"");
+ // Assume args that start and end with quotes are already quoted and do not require further quoting.
+ // There is probably code out there written before launch() escaped the arguments that does its own
+ // escaping of arguments. This ensures we do not interfere with those arguments.
+ bool isAlreadyQuoted = arg.size() > 1 && '\"' == arg[0] && '\"' == arg[arg.size() - 1];
+ return containsQuotableChar && !isAlreadyQuoted;
+}
+
+
+// Based on code from https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/
+static std::string escapeArg(const std::string& arg)
+{
+ if (argNeedsEscaping(arg))
+ {
+ std::string quotedArg("\"");
+ for (std::string::const_iterator it = arg.begin(); ; ++it)
+ {
+ unsigned backslashCount = 0;
+ while (it != arg.end() && '\\' == *it)
+ {
+ ++it;
+ ++backslashCount;
}
- else if ('"' == *it)
- {
- quotedArg.append(2 * backslashCount + 1, '\\');
- quotedArg.push_back('"');
+
+ if (it == arg.end())
+ {
+ quotedArg.append(2 * backslashCount, '\\');
+ break;
+ }
+ else if ('"' == *it)
+ {
+ quotedArg.append(2 * backslashCount + 1, '\\');
+ quotedArg.push_back('"');
+ }
+ else
+ {
+ quotedArg.append(backslashCount, '\\');
+ quotedArg.push_back(*it);
}
- else
- {
- quotedArg.append(backslashCount, '\\');
- quotedArg.push_back(*it);
- }
- }
- quotedArg.push_back('"');
- return quotedArg;
+ }
+ quotedArg.push_back('"');
+ return quotedArg;
+ }
+ else
+ {
+ return arg;
+ }
+}
+
+
+ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env)
+{
+ std::string commandLine = escapeArg(command);
+ for (ArgsImpl::const_iterator it = args.begin(); it != args.end(); ++it)
+ {
+ commandLine.append(" ");
+ commandLine.append(escapeArg(*it));
}
- else
- {
- return arg;
- }
-}
-
-
-ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env)
-{
- std::string commandLine = escapeArg(command);
- for (ArgsImpl::const_iterator it = args.begin(); it != args.end(); ++it)
- {
- commandLine.append(" ");
- commandLine.append(escapeArg(*it));
- }
-
- std::wstring ucommandLine;
- UnicodeConverter::toUTF16(commandLine, ucommandLine);
-
- const wchar_t* applicationName = 0;
- std::wstring uapplicationName;
- if (command.size() > MAX_PATH)
- {
- Poco::Path p(command);
- if (p.isAbsolute())
- {
- UnicodeConverter::toUTF16(command, uapplicationName);
- if (p.getExtension().empty()) uapplicationName += L".EXE";
- applicationName = uapplicationName.c_str();
- }
- }
-
- STARTUPINFOW startupInfo;
- GetStartupInfoW(&startupInfo); // take defaults from current process
- startupInfo.cb = sizeof(STARTUPINFOW);
- startupInfo.lpReserved = NULL;
- startupInfo.lpDesktop = NULL;
- startupInfo.lpTitle = NULL;
- startupInfo.dwFlags = STARTF_FORCEOFFFEEDBACK;
- startupInfo.cbReserved2 = 0;
- startupInfo.lpReserved2 = NULL;
-
- HANDLE hProc = GetCurrentProcess();
- bool mustInheritHandles = false;
- if (inPipe)
- {
- DuplicateHandle(hProc, inPipe->readHandle(), hProc, &startupInfo.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS);
- mustInheritHandles = true;
- inPipe->close(Pipe::CLOSE_READ);
+
+ std::wstring ucommandLine;
+ UnicodeConverter::toUTF16(commandLine, ucommandLine);
+
+ const wchar_t* applicationName = 0;
+ std::wstring uapplicationName;
+ if (command.size() > MAX_PATH)
+ {
+ Poco::Path p(command);
+ if (p.isAbsolute())
+ {
+ UnicodeConverter::toUTF16(command, uapplicationName);
+ if (p.getExtension().empty()) uapplicationName += L".EXE";
+ applicationName = uapplicationName.c_str();
+ }
}
- else if (GetStdHandle(STD_INPUT_HANDLE))
- {
- DuplicateHandle(hProc, GetStdHandle(STD_INPUT_HANDLE), hProc, &startupInfo.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS);
- mustInheritHandles = true;
+
+ STARTUPINFOW startupInfo;
+ GetStartupInfoW(&startupInfo); // take defaults from current process
+ startupInfo.cb = sizeof(STARTUPINFOW);
+ startupInfo.lpReserved = NULL;
+ startupInfo.lpDesktop = NULL;
+ startupInfo.lpTitle = NULL;
+ startupInfo.dwFlags = STARTF_FORCEOFFFEEDBACK;
+ startupInfo.cbReserved2 = 0;
+ startupInfo.lpReserved2 = NULL;
+
+ HANDLE hProc = GetCurrentProcess();
+ bool mustInheritHandles = false;
+ if (inPipe)
+ {
+ DuplicateHandle(hProc, inPipe->readHandle(), hProc, &startupInfo.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS);
+ mustInheritHandles = true;
+ inPipe->close(Pipe::CLOSE_READ);
+ }
+ else if (GetStdHandle(STD_INPUT_HANDLE))
+ {
+ DuplicateHandle(hProc, GetStdHandle(STD_INPUT_HANDLE), hProc, &startupInfo.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS);
+ mustInheritHandles = true;
+ }
+ else
+ {
+ startupInfo.hStdInput = 0;
}
- else
- {
- startupInfo.hStdInput = 0;
- }
- // outPipe may be the same as errPipe, so we duplicate first and close later.
- if (outPipe)
- {
- DuplicateHandle(hProc, outPipe->writeHandle(), hProc, &startupInfo.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS);
- mustInheritHandles = true;
+ // outPipe may be the same as errPipe, so we duplicate first and close later.
+ if (outPipe)
+ {
+ DuplicateHandle(hProc, outPipe->writeHandle(), hProc, &startupInfo.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS);
+ mustInheritHandles = true;
+ }
+ else if (GetStdHandle(STD_OUTPUT_HANDLE))
+ {
+ DuplicateHandle(hProc, GetStdHandle(STD_OUTPUT_HANDLE), hProc, &startupInfo.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS);
+ mustInheritHandles = true;
+ }
+ else
+ {
+ startupInfo.hStdOutput = 0;
}
- else if (GetStdHandle(STD_OUTPUT_HANDLE))
- {
- DuplicateHandle(hProc, GetStdHandle(STD_OUTPUT_HANDLE), hProc, &startupInfo.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS);
- mustInheritHandles = true;
+ if (errPipe)
+ {
+ DuplicateHandle(hProc, errPipe->writeHandle(), hProc, &startupInfo.hStdError, 0, TRUE, DUPLICATE_SAME_ACCESS);
+ mustInheritHandles = true;
+ }
+ else if (GetStdHandle(STD_ERROR_HANDLE))
+ {
+ DuplicateHandle(hProc, GetStdHandle(STD_ERROR_HANDLE), hProc, &startupInfo.hStdError, 0, TRUE, DUPLICATE_SAME_ACCESS);
+ mustInheritHandles = true;
+ }
+ else
+ {
+ startupInfo.hStdError = 0;
}
- else
- {
- startupInfo.hStdOutput = 0;
- }
- if (errPipe)
- {
- DuplicateHandle(hProc, errPipe->writeHandle(), hProc, &startupInfo.hStdError, 0, TRUE, DUPLICATE_SAME_ACCESS);
- mustInheritHandles = true;
+ if (outPipe) outPipe->close(Pipe::CLOSE_WRITE);
+ if (errPipe) errPipe->close(Pipe::CLOSE_WRITE);
+
+ if (mustInheritHandles)
+ {
+ startupInfo.dwFlags |= STARTF_USESTDHANDLES;
}
- else if (GetStdHandle(STD_ERROR_HANDLE))
- {
- DuplicateHandle(hProc, GetStdHandle(STD_ERROR_HANDLE), hProc, &startupInfo.hStdError, 0, TRUE, DUPLICATE_SAME_ACCESS);
- mustInheritHandles = true;
+
+ std::wstring uinitialDirectory;
+ UnicodeConverter::toUTF16(initialDirectory, uinitialDirectory);
+ const wchar_t* workingDirectory = uinitialDirectory.empty() ? 0 : uinitialDirectory.c_str();
+
+ const char* pEnv = 0;
+ std::vector<char> envChars;
+ if (!env.empty())
+ {
+ envChars = getEnvironmentVariablesBuffer(env);
+ pEnv = &envChars[0];
}
- else
- {
- startupInfo.hStdError = 0;
- }
- if (outPipe) outPipe->close(Pipe::CLOSE_WRITE);
- if (errPipe) errPipe->close(Pipe::CLOSE_WRITE);
-
- if (mustInheritHandles)
- {
- startupInfo.dwFlags |= STARTF_USESTDHANDLES;
- }
-
- std::wstring uinitialDirectory;
- UnicodeConverter::toUTF16(initialDirectory, uinitialDirectory);
- const wchar_t* workingDirectory = uinitialDirectory.empty() ? 0 : uinitialDirectory.c_str();
-
- const char* pEnv = 0;
- std::vector<char> envChars;
- if (!env.empty())
- {
- envChars = getEnvironmentVariablesBuffer(env);
- pEnv = &envChars[0];
- }
-
- PROCESS_INFORMATION processInfo;
- DWORD creationFlags = GetConsoleWindow() ? 0 : CREATE_NO_WINDOW;
- BOOL rc = CreateProcessW(
- applicationName,
- const_cast<wchar_t*>(ucommandLine.c_str()),
- NULL, // processAttributes
- NULL, // threadAttributes
- mustInheritHandles,
- creationFlags,
- (LPVOID)pEnv,
- workingDirectory,
- &startupInfo,
- &processInfo
- );
- if (startupInfo.hStdInput) CloseHandle(startupInfo.hStdInput);
- if (startupInfo.hStdOutput) CloseHandle(startupInfo.hStdOutput);
- if (startupInfo.hStdError) CloseHandle(startupInfo.hStdError);
- if (rc)
- {
- CloseHandle(processInfo.hThread);
- return new ProcessHandleImpl(processInfo.hProcess, processInfo.dwProcessId);
+
+ PROCESS_INFORMATION processInfo;
+ DWORD creationFlags = GetConsoleWindow() ? 0 : CREATE_NO_WINDOW;
+ BOOL rc = CreateProcessW(
+ applicationName,
+ const_cast<wchar_t*>(ucommandLine.c_str()),
+ NULL, // processAttributes
+ NULL, // threadAttributes
+ mustInheritHandles,
+ creationFlags,
+ (LPVOID)pEnv,
+ workingDirectory,
+ &startupInfo,
+ &processInfo
+ );
+ if (startupInfo.hStdInput) CloseHandle(startupInfo.hStdInput);
+ if (startupInfo.hStdOutput) CloseHandle(startupInfo.hStdOutput);
+ if (startupInfo.hStdError) CloseHandle(startupInfo.hStdError);
+ if (rc)
+ {
+ CloseHandle(processInfo.hThread);
+ return new ProcessHandleImpl(processInfo.hProcess, processInfo.dwProcessId);
+ }
+ else throw SystemException("Cannot launch process", command);
+}
+
+
+void ProcessImpl::killImpl(ProcessHandleImpl& handle)
+{
+ if (handle.process())
+ {
+ if (TerminateProcess(handle.process(), 0) == 0)
+ {
+ handle.closeHandle();
+ throw SystemException("cannot kill process");
+ }
+ handle.closeHandle();
}
- else throw SystemException("Cannot launch process", command);
-}
-
-
-void ProcessImpl::killImpl(ProcessHandleImpl& handle)
-{
- if (handle.process())
- {
- if (TerminateProcess(handle.process(), 0) == 0)
- {
- handle.closeHandle();
- throw SystemException("cannot kill process");
- }
- handle.closeHandle();
- }
-}
-
-void ProcessImpl::killImpl(PIDImpl pid)
-{
- HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
- if (hProc)
- {
- if (TerminateProcess(hProc, 0) == 0)
- {
- CloseHandle(hProc);
- throw SystemException("cannot kill process");
- }
- CloseHandle(hProc);
+}
+
+void ProcessImpl::killImpl(PIDImpl pid)
+{
+ HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
+ if (hProc)
+ {
+ if (TerminateProcess(hProc, 0) == 0)
+ {
+ CloseHandle(hProc);
+ throw SystemException("cannot kill process");
+ }
+ CloseHandle(hProc);
+ }
+ else
+ {
+ switch (GetLastError())
+ {
+ case ERROR_ACCESS_DENIED:
+ throw NoPermissionException("cannot kill process");
+ case ERROR_NOT_FOUND:
+ throw NotFoundException("cannot kill process");
+ case ERROR_INVALID_PARAMETER:
+ throw NotFoundException("cannot kill process");
+ default:
+ throw SystemException("cannot kill process");
+ }
}
- else
- {
- switch (GetLastError())
- {
- case ERROR_ACCESS_DENIED:
- throw NoPermissionException("cannot kill process");
- case ERROR_NOT_FOUND:
- throw NotFoundException("cannot kill process");
- case ERROR_INVALID_PARAMETER:
- throw NotFoundException("cannot kill process");
- default:
- throw SystemException("cannot kill process");
- }
- }
-}
-
-
-bool ProcessImpl::isRunningImpl(const ProcessHandleImpl& handle)
-{
- bool result = true;
- DWORD exitCode;
- BOOL rc = GetExitCodeProcess(handle.process(), &exitCode);
- if (!rc || exitCode != STILL_ACTIVE) result = false;
- return result;
-}
-
-
-bool ProcessImpl::isRunningImpl(PIDImpl pid)
-{
- HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
- bool result = true;
- DWORD exitCode;
- BOOL rc = GetExitCodeProcess(hProc, &exitCode);
- if (!rc || exitCode != STILL_ACTIVE) result = false;
- return result;
-}
-
-
-void ProcessImpl::requestTerminationImpl(PIDImpl pid)
-{
- NamedEvent ev(terminationEventName(pid));
- ev.set();
-}
-
-
-std::string ProcessImpl::terminationEventName(PIDImpl pid)
-{
- std::string evName("POCOTRM");
- NumberFormatter::appendHex(evName, pid, 8);
- return evName;
-}
-
-
-} // namespace Poco
+}
+
+
+bool ProcessImpl::isRunningImpl(const ProcessHandleImpl& handle)
+{
+ bool result = true;
+ DWORD exitCode;
+ BOOL rc = GetExitCodeProcess(handle.process(), &exitCode);
+ if (!rc || exitCode != STILL_ACTIVE) result = false;
+ return result;
+}
+
+
+bool ProcessImpl::isRunningImpl(PIDImpl pid)
+{
+ HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
+ bool result = true;
+ DWORD exitCode;
+ BOOL rc = GetExitCodeProcess(hProc, &exitCode);
+ if (!rc || exitCode != STILL_ACTIVE) result = false;
+ return result;
+}
+
+
+void ProcessImpl::requestTerminationImpl(PIDImpl pid)
+{
+ NamedEvent ev(terminationEventName(pid));
+ ev.set();
+}
+
+
+std::string ProcessImpl::terminationEventName(PIDImpl pid)
+{
+ std::string evName("POCOTRM");
+ NumberFormatter::appendHex(evName, pid, 8);
+ return evName;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Process_WINCE.cpp b/contrib/libs/poco/Foundation/src/Process_WINCE.cpp
index e640f3be3d..dfce9e5de2 100644
--- a/contrib/libs/poco/Foundation/src/Process_WINCE.cpp
+++ b/contrib/libs/poco/Foundation/src/Process_WINCE.cpp
@@ -1,223 +1,223 @@
-//
-// Process_WINCE.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: Process
-//
-// Copyright (c) 2004-2010, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Process_WINCE.h"
-#include "Poco/Exception.h"
-#include "Poco/NumberFormatter.h"
-#include "Poco/NamedEvent.h"
-#include "Poco/UnicodeConverter.h"
-#include "Poco/Pipe.h"
-
-
-namespace Poco {
-
-
-//
-// ProcessHandleImpl
-//
-ProcessHandleImpl::ProcessHandleImpl(HANDLE hProcess, UInt32 pid):
- _hProcess(hProcess),
- _pid(pid)
-{
-}
-
-
-ProcessHandleImpl::~ProcessHandleImpl()
-{
- closeHandle();
-}
-
-void ProcessHandleImpl::closeHandle()
-{
- if (_hProcess)
- {
- CloseHandle(_hProcess);
- _hProcess = NULL;
- }
-}
-
-UInt32 ProcessHandleImpl::id() const
-{
- return _pid;
-}
-
-
-HANDLE ProcessHandleImpl::process() const
-{
- return _hProcess;
-}
-
-
-int ProcessHandleImpl::wait() const
-{
- DWORD rc = WaitForSingleObject(_hProcess, INFINITE);
- if (rc != WAIT_OBJECT_0)
- throw SystemException("Wait failed for process", NumberFormatter::format(_pid));
-
- DWORD exitCode;
- if (GetExitCodeProcess(_hProcess, &exitCode) == 0)
- throw SystemException("Cannot get exit code for process", NumberFormatter::format(_pid));
-
- return exitCode;
-}
-
-
-//
-// ProcessImpl
-//
-ProcessImpl::PIDImpl ProcessImpl::idImpl()
-{
- return GetCurrentProcessId();
-}
-
-
-void ProcessImpl::timesImpl(long& userTime, long& kernelTime)
-{
- FILETIME ftCreation;
- FILETIME ftExit;
- FILETIME ftKernel;
- FILETIME ftUser;
-
- if (GetThreadTimes(GetCurrentThread(), &ftCreation, &ftExit, &ftKernel, &ftUser) != 0)
- {
- ULARGE_INTEGER time;
- time.LowPart = ftKernel.dwLowDateTime;
- time.HighPart = ftKernel.dwHighDateTime;
- kernelTime = long(time.QuadPart/10000000L);
- time.LowPart = ftUser.dwLowDateTime;
- time.HighPart = ftUser.dwHighDateTime;
- userTime = long(time.QuadPart/10000000L);
- }
- else
- {
- userTime = kernelTime = -1;
- }
-}
-
-
-ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env)
-{
- std::wstring ucommand;
- UnicodeConverter::toUTF16(command, ucommand);
-
- std::string commandLine;
- for (ArgsImpl::const_iterator it = args.begin(); it != args.end(); ++it)
- {
- if (it != args.begin()) commandLine.append(" ");
- commandLine.append(*it);
- }
-
- std::wstring ucommandLine;
- UnicodeConverter::toUTF16(commandLine, ucommandLine);
-
- PROCESS_INFORMATION processInfo;
- BOOL rc = CreateProcessW(
- ucommand.c_str(),
- const_cast<wchar_t*>(ucommandLine.c_str()),
- NULL,
- NULL,
- FALSE,
- 0,
- NULL,
- NULL,
- NULL/*&startupInfo*/,
- &processInfo
- );
-
- if (rc)
- {
- CloseHandle(processInfo.hThread);
- return new ProcessHandleImpl(processInfo.hProcess, processInfo.dwProcessId);
- }
- else throw SystemException("Cannot launch process", command);
-}
-
-
-void ProcessImpl::killImpl(ProcessHandleImpl& handle)
-{
- if (handle.process())
- {
- if (TerminateProcess(handle.process(), 0) == 0)
- {
- handle.closeHandle();
- throw SystemException("cannot kill process");
- }
- handle.closeHandle();
- }
-}
-
-
-void ProcessImpl::killImpl(PIDImpl pid)
-{
- HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
- if (hProc)
- {
- if (TerminateProcess(hProc, 0) == 0)
- {
- CloseHandle(hProc);
- throw SystemException("cannot kill process");
- }
- CloseHandle(hProc);
- }
- else
- {
- switch (GetLastError())
- {
- case ERROR_ACCESS_DENIED:
- throw NoPermissionException("cannot kill process");
- case ERROR_NOT_FOUND:
- throw NotFoundException("cannot kill process");
- default:
- throw SystemException("cannot kill process");
- }
- }
-}
-
-
-bool ProcessImpl::isRunningImpl(const ProcessHandleImpl& handle)
-{
- bool result = true;
- DWORD exitCode;
- BOOL rc = GetExitCodeProcess(handle.process(), &exitCode);
- if (!rc || exitCode != STILL_ACTIVE) result = false;
- return result;
-}
-
-
-bool ProcessImpl::isRunningImpl(PIDImpl pid)
-{
- HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
- bool result = true;
- DWORD exitCode;
- BOOL rc = GetExitCodeProcess(hProc, &exitCode);
- if (!rc || exitCode != STILL_ACTIVE) result = false;
- return result;}
-
-
-void ProcessImpl::requestTerminationImpl(PIDImpl pid)
-{
- NamedEvent ev(terminationEventName(pid));
- ev.set();
-}
-
-
-std::string ProcessImpl::terminationEventName(PIDImpl pid)
-{
- std::string evName("POCOTRM");
- NumberFormatter::appendHex(evName, pid, 8);
- return evName;
-}
-
-
-} // namespace Poco
+//
+// Process_WINCE.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: Process
+//
+// Copyright (c) 2004-2010, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Process_WINCE.h"
+#include "Poco/Exception.h"
+#include "Poco/NumberFormatter.h"
+#include "Poco/NamedEvent.h"
+#include "Poco/UnicodeConverter.h"
+#include "Poco/Pipe.h"
+
+
+namespace Poco {
+
+
+//
+// ProcessHandleImpl
+//
+ProcessHandleImpl::ProcessHandleImpl(HANDLE hProcess, UInt32 pid):
+ _hProcess(hProcess),
+ _pid(pid)
+{
+}
+
+
+ProcessHandleImpl::~ProcessHandleImpl()
+{
+ closeHandle();
+}
+
+void ProcessHandleImpl::closeHandle()
+{
+ if (_hProcess)
+ {
+ CloseHandle(_hProcess);
+ _hProcess = NULL;
+ }
+}
+
+UInt32 ProcessHandleImpl::id() const
+{
+ return _pid;
+}
+
+
+HANDLE ProcessHandleImpl::process() const
+{
+ return _hProcess;
+}
+
+
+int ProcessHandleImpl::wait() const
+{
+ DWORD rc = WaitForSingleObject(_hProcess, INFINITE);
+ if (rc != WAIT_OBJECT_0)
+ throw SystemException("Wait failed for process", NumberFormatter::format(_pid));
+
+ DWORD exitCode;
+ if (GetExitCodeProcess(_hProcess, &exitCode) == 0)
+ throw SystemException("Cannot get exit code for process", NumberFormatter::format(_pid));
+
+ return exitCode;
+}
+
+
+//
+// ProcessImpl
+//
+ProcessImpl::PIDImpl ProcessImpl::idImpl()
+{
+ return GetCurrentProcessId();
+}
+
+
+void ProcessImpl::timesImpl(long& userTime, long& kernelTime)
+{
+ FILETIME ftCreation;
+ FILETIME ftExit;
+ FILETIME ftKernel;
+ FILETIME ftUser;
+
+ if (GetThreadTimes(GetCurrentThread(), &ftCreation, &ftExit, &ftKernel, &ftUser) != 0)
+ {
+ ULARGE_INTEGER time;
+ time.LowPart = ftKernel.dwLowDateTime;
+ time.HighPart = ftKernel.dwHighDateTime;
+ kernelTime = long(time.QuadPart/10000000L);
+ time.LowPart = ftUser.dwLowDateTime;
+ time.HighPart = ftUser.dwHighDateTime;
+ userTime = long(time.QuadPart/10000000L);
+ }
+ else
+ {
+ userTime = kernelTime = -1;
+ }
+}
+
+
+ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env)
+{
+ std::wstring ucommand;
+ UnicodeConverter::toUTF16(command, ucommand);
+
+ std::string commandLine;
+ for (ArgsImpl::const_iterator it = args.begin(); it != args.end(); ++it)
+ {
+ if (it != args.begin()) commandLine.append(" ");
+ commandLine.append(*it);
+ }
+
+ std::wstring ucommandLine;
+ UnicodeConverter::toUTF16(commandLine, ucommandLine);
+
+ PROCESS_INFORMATION processInfo;
+ BOOL rc = CreateProcessW(
+ ucommand.c_str(),
+ const_cast<wchar_t*>(ucommandLine.c_str()),
+ NULL,
+ NULL,
+ FALSE,
+ 0,
+ NULL,
+ NULL,
+ NULL/*&startupInfo*/,
+ &processInfo
+ );
+
+ if (rc)
+ {
+ CloseHandle(processInfo.hThread);
+ return new ProcessHandleImpl(processInfo.hProcess, processInfo.dwProcessId);
+ }
+ else throw SystemException("Cannot launch process", command);
+}
+
+
+void ProcessImpl::killImpl(ProcessHandleImpl& handle)
+{
+ if (handle.process())
+ {
+ if (TerminateProcess(handle.process(), 0) == 0)
+ {
+ handle.closeHandle();
+ throw SystemException("cannot kill process");
+ }
+ handle.closeHandle();
+ }
+}
+
+
+void ProcessImpl::killImpl(PIDImpl pid)
+{
+ HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
+ if (hProc)
+ {
+ if (TerminateProcess(hProc, 0) == 0)
+ {
+ CloseHandle(hProc);
+ throw SystemException("cannot kill process");
+ }
+ CloseHandle(hProc);
+ }
+ else
+ {
+ switch (GetLastError())
+ {
+ case ERROR_ACCESS_DENIED:
+ throw NoPermissionException("cannot kill process");
+ case ERROR_NOT_FOUND:
+ throw NotFoundException("cannot kill process");
+ default:
+ throw SystemException("cannot kill process");
+ }
+ }
+}
+
+
+bool ProcessImpl::isRunningImpl(const ProcessHandleImpl& handle)
+{
+ bool result = true;
+ DWORD exitCode;
+ BOOL rc = GetExitCodeProcess(handle.process(), &exitCode);
+ if (!rc || exitCode != STILL_ACTIVE) result = false;
+ return result;
+}
+
+
+bool ProcessImpl::isRunningImpl(PIDImpl pid)
+{
+ HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
+ bool result = true;
+ DWORD exitCode;
+ BOOL rc = GetExitCodeProcess(hProc, &exitCode);
+ if (!rc || exitCode != STILL_ACTIVE) result = false;
+ return result;}
+
+
+void ProcessImpl::requestTerminationImpl(PIDImpl pid)
+{
+ NamedEvent ev(terminationEventName(pid));
+ ev.set();
+}
+
+
+std::string ProcessImpl::terminationEventName(PIDImpl pid)
+{
+ std::string evName("POCOTRM");
+ NumberFormatter::appendHex(evName, pid, 8);
+ return evName;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/PurgeStrategy.cpp b/contrib/libs/poco/Foundation/src/PurgeStrategy.cpp
index 070c5c32d5..662d121a15 100644
--- a/contrib/libs/poco/Foundation/src/PurgeStrategy.cpp
+++ b/contrib/libs/poco/Foundation/src/PurgeStrategy.cpp
@@ -1,153 +1,153 @@
-//
-// PurgeStrategy.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: FileChannel
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/PurgeStrategy.h"
-#include "Poco/Path.h"
-#include "Poco/DirectoryIterator.h"
-#include "Poco/Timestamp.h"
-
-
-namespace Poco {
-
-
-//
-// PurgeStrategy
-//
-
-
-PurgeStrategy::PurgeStrategy()
-{
-}
-
-
-PurgeStrategy::~PurgeStrategy()
-{
-}
-
-
-void PurgeStrategy::list(const std::string& path, std::vector<File>& files)
-{
- Path p(path);
- p.makeAbsolute();
- Path parent = p.parent();
- std::string baseName = p.getFileName();
- baseName.append(".");
-
- DirectoryIterator it(parent);
- DirectoryIterator end;
- while (it != end)
- {
- if (it.name().compare(0, baseName.size(), baseName) == 0)
- {
- files.push_back(*it);
- }
- ++it;
- }
-}
-
-
-//
-// PurgeByAgeStrategy
-//
-
-
-PurgeByAgeStrategy::PurgeByAgeStrategy(const Timespan& age): _age(age)
-{
-}
-
-
-PurgeByAgeStrategy::~PurgeByAgeStrategy()
-{
-}
-
-
-void PurgeByAgeStrategy::purge(const std::string& path)
-{
- std::vector<File> files;
- list(path, files);
- for (std::vector<File>::iterator it = files.begin(); it != files.end(); ++it)
- {
- if (it->getLastModified().isElapsed(_age.totalMicroseconds()))
- {
- it->remove();
- }
- }
-}
-
-
-//
-// PurgeByCountStrategy
-//
-
-
-PurgeByCountStrategy::PurgeByCountStrategy(int count): _count(count)
-{
- poco_assert(count > 0);
-}
-
-
-PurgeByCountStrategy::~PurgeByCountStrategy()
-{
-}
-
-
-void PurgeByCountStrategy::purge(const std::string& path)
-{
- std::vector<File> files;
- list(path, files);
- while (files.size() > _count)
- {
- std::vector<File>::iterator it = files.begin();
- std::vector<File>::iterator purgeIt = it;
- Timestamp purgeTS = purgeIt->getLastModified();
- ++it;
- while (it != files.end())
- {
- Timestamp md(it->getLastModified());
- if (md <= purgeTS)
- {
- purgeTS = md;
- purgeIt = it;
- }
- ++it;
- }
- purgeIt->remove();
- files.erase(purgeIt);
- }
-}
-
-
-void PurgeOneFileStrategy::purge(const std::string& path)
-{
- std::vector<File> files;
- list(path, files);
-
- if (files.empty())
- {
- File(path).setSize(0);
- return;
- }
-
- auto purge_it = files.begin();
- auto it = files.begin();
- for (++it; it != files.end(); ++it)
- if (it->getLastModified() < purge_it->getLastModified())
- purge_it = it;
-
- purge_it->remove();
-}
-
-
-
-} // namespace Poco
+//
+// PurgeStrategy.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: FileChannel
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/PurgeStrategy.h"
+#include "Poco/Path.h"
+#include "Poco/DirectoryIterator.h"
+#include "Poco/Timestamp.h"
+
+
+namespace Poco {
+
+
+//
+// PurgeStrategy
+//
+
+
+PurgeStrategy::PurgeStrategy()
+{
+}
+
+
+PurgeStrategy::~PurgeStrategy()
+{
+}
+
+
+void PurgeStrategy::list(const std::string& path, std::vector<File>& files)
+{
+ Path p(path);
+ p.makeAbsolute();
+ Path parent = p.parent();
+ std::string baseName = p.getFileName();
+ baseName.append(".");
+
+ DirectoryIterator it(parent);
+ DirectoryIterator end;
+ while (it != end)
+ {
+ if (it.name().compare(0, baseName.size(), baseName) == 0)
+ {
+ files.push_back(*it);
+ }
+ ++it;
+ }
+}
+
+
+//
+// PurgeByAgeStrategy
+//
+
+
+PurgeByAgeStrategy::PurgeByAgeStrategy(const Timespan& age): _age(age)
+{
+}
+
+
+PurgeByAgeStrategy::~PurgeByAgeStrategy()
+{
+}
+
+
+void PurgeByAgeStrategy::purge(const std::string& path)
+{
+ std::vector<File> files;
+ list(path, files);
+ for (std::vector<File>::iterator it = files.begin(); it != files.end(); ++it)
+ {
+ if (it->getLastModified().isElapsed(_age.totalMicroseconds()))
+ {
+ it->remove();
+ }
+ }
+}
+
+
+//
+// PurgeByCountStrategy
+//
+
+
+PurgeByCountStrategy::PurgeByCountStrategy(int count): _count(count)
+{
+ poco_assert(count > 0);
+}
+
+
+PurgeByCountStrategy::~PurgeByCountStrategy()
+{
+}
+
+
+void PurgeByCountStrategy::purge(const std::string& path)
+{
+ std::vector<File> files;
+ list(path, files);
+ while (files.size() > _count)
+ {
+ std::vector<File>::iterator it = files.begin();
+ std::vector<File>::iterator purgeIt = it;
+ Timestamp purgeTS = purgeIt->getLastModified();
+ ++it;
+ while (it != files.end())
+ {
+ Timestamp md(it->getLastModified());
+ if (md <= purgeTS)
+ {
+ purgeTS = md;
+ purgeIt = it;
+ }
+ ++it;
+ }
+ purgeIt->remove();
+ files.erase(purgeIt);
+ }
+}
+
+
+void PurgeOneFileStrategy::purge(const std::string& path)
+{
+ std::vector<File> files;
+ list(path, files);
+
+ if (files.empty())
+ {
+ File(path).setSize(0);
+ return;
+ }
+
+ auto purge_it = files.begin();
+ auto it = files.begin();
+ for (++it; it != files.end(); ++it)
+ if (it->getLastModified() < purge_it->getLastModified())
+ purge_it = it;
+
+ purge_it->remove();
+}
+
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/RWLock.cpp b/contrib/libs/poco/Foundation/src/RWLock.cpp
index ba3f7d1425..9a5c477e74 100644
--- a/contrib/libs/poco/Foundation/src/RWLock.cpp
+++ b/contrib/libs/poco/Foundation/src/RWLock.cpp
@@ -1,46 +1,46 @@
-//
-// RWLock.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: RWLock
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/RWLock.h"
-
-
-#if defined(POCO_OS_FAMILY_WINDOWS)
-#if defined(_WIN32_WCE)
-#include "RWLock_WINCE.cpp"
-#else
-#include "RWLock_WIN32.cpp"
-#endif
-#elif POCO_OS == POCO_OS_ANDROID
-#include "RWLock_Android.cpp"
-#elif defined(POCO_VXWORKS)
-#include "RWLock_VX.cpp"
-#else
-#include "RWLock_POSIX.cpp"
-#endif
-
-
-namespace Poco {
-
-
-RWLock::RWLock()
-{
-}
-
-
-RWLock::~RWLock()
-{
-}
-
-
-} // namespace Poco
+//
+// RWLock.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: RWLock
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/RWLock.h"
+
+
+#if defined(POCO_OS_FAMILY_WINDOWS)
+#if defined(_WIN32_WCE)
+#include "RWLock_WINCE.cpp"
+#else
+#include "RWLock_WIN32.cpp"
+#endif
+#elif POCO_OS == POCO_OS_ANDROID
+#include "RWLock_Android.cpp"
+#elif defined(POCO_VXWORKS)
+#include "RWLock_VX.cpp"
+#else
+#include "RWLock_POSIX.cpp"
+#endif
+
+
+namespace Poco {
+
+
+RWLock::RWLock()
+{
+}
+
+
+RWLock::~RWLock()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/RWLock_Android.cpp b/contrib/libs/poco/Foundation/src/RWLock_Android.cpp
index 7f1ef96657..fb623422f6 100644
--- a/contrib/libs/poco/Foundation/src/RWLock_Android.cpp
+++ b/contrib/libs/poco/Foundation/src/RWLock_Android.cpp
@@ -1,39 +1,39 @@
-//
-// RWLock_Android.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: RWLock
-//
-// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/RWLock_Android.h"
-
-
-namespace Poco {
-
-
-RWLockImpl::RWLockImpl()
-{
- pthread_mutexattr_t attr;
- pthread_mutexattr_init(&attr);
- if (pthread_mutex_init(&_mutex, &attr))
- {
- pthread_mutexattr_destroy(&attr);
- throw SystemException("cannot create mutex");
- }
- pthread_mutexattr_destroy(&attr);}
-
-
-RWLockImpl::~RWLockImpl()
-{
- pthread_mutex_destroy(&_mutex);
-}
-
-
-} // namespace Poco
+//
+// RWLock_Android.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: RWLock
+//
+// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/RWLock_Android.h"
+
+
+namespace Poco {
+
+
+RWLockImpl::RWLockImpl()
+{
+ pthread_mutexattr_t attr;
+ pthread_mutexattr_init(&attr);
+ if (pthread_mutex_init(&_mutex, &attr))
+ {
+ pthread_mutexattr_destroy(&attr);
+ throw SystemException("cannot create mutex");
+ }
+ pthread_mutexattr_destroy(&attr);}
+
+
+RWLockImpl::~RWLockImpl()
+{
+ pthread_mutex_destroy(&_mutex);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/RWLock_POSIX.cpp b/contrib/libs/poco/Foundation/src/RWLock_POSIX.cpp
index 9b729e796b..99f4f3b550 100644
--- a/contrib/libs/poco/Foundation/src/RWLock_POSIX.cpp
+++ b/contrib/libs/poco/Foundation/src/RWLock_POSIX.cpp
@@ -1,34 +1,34 @@
-//
-// RWLock_POSIX.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: RWLock
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/RWLock_POSIX.h"
-
-
-namespace Poco {
-
-
-RWLockImpl::RWLockImpl()
-{
- if (pthread_rwlock_init(&_rwl, NULL))
- throw SystemException("cannot create reader/writer lock");
-}
-
-
-RWLockImpl::~RWLockImpl()
-{
- pthread_rwlock_destroy(&_rwl);
-}
-
-
-} // namespace Poco
+//
+// RWLock_POSIX.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: RWLock
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/RWLock_POSIX.h"
+
+
+namespace Poco {
+
+
+RWLockImpl::RWLockImpl()
+{
+ if (pthread_rwlock_init(&_rwl, NULL))
+ throw SystemException("cannot create reader/writer lock");
+}
+
+
+RWLockImpl::~RWLockImpl()
+{
+ pthread_rwlock_destroy(&_rwl);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/RWLock_VX.cpp b/contrib/libs/poco/Foundation/src/RWLock_VX.cpp
index 44167d97e6..67bfc46f5f 100644
--- a/contrib/libs/poco/Foundation/src/RWLock_VX.cpp
+++ b/contrib/libs/poco/Foundation/src/RWLock_VX.cpp
@@ -1,48 +1,48 @@
-//
-// RWLock_VX.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: RWLock
-//
-// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/RWLock_VX.h"
-#include <cstring>
-
-
-namespace Poco {
-
-
-RWLockImpl::RWLockImpl()
-{
-#if defined(POCO_VXWORKS)
- // This workaround is for VxWorks 5.x where
- // pthread_mutex_init() won't properly initialize the mutex
- // resulting in a subsequent freeze in pthread_mutex_destroy()
- // if the mutex has never been used.
- std::memset(&_mutex, 0, sizeof(_mutex));
-#endif
- pthread_mutexattr_t attr;
- pthread_mutexattr_init(&attr);
- if (pthread_mutex_init(&_mutex, &attr))
- {
- pthread_mutexattr_destroy(&attr);
- throw SystemException("cannot create mutex");
- }
- pthread_mutexattr_destroy(&attr);
-}
-
-
-RWLockImpl::~RWLockImpl()
-{
- pthread_mutex_destroy(&_mutex);
-}
-
-
-} // namespace Poco
+//
+// RWLock_VX.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: RWLock
+//
+// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/RWLock_VX.h"
+#include <cstring>
+
+
+namespace Poco {
+
+
+RWLockImpl::RWLockImpl()
+{
+#if defined(POCO_VXWORKS)
+ // This workaround is for VxWorks 5.x where
+ // pthread_mutex_init() won't properly initialize the mutex
+ // resulting in a subsequent freeze in pthread_mutex_destroy()
+ // if the mutex has never been used.
+ std::memset(&_mutex, 0, sizeof(_mutex));
+#endif
+ pthread_mutexattr_t attr;
+ pthread_mutexattr_init(&attr);
+ if (pthread_mutex_init(&_mutex, &attr))
+ {
+ pthread_mutexattr_destroy(&attr);
+ throw SystemException("cannot create mutex");
+ }
+ pthread_mutexattr_destroy(&attr);
+}
+
+
+RWLockImpl::~RWLockImpl()
+{
+ pthread_mutex_destroy(&_mutex);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/RWLock_WIN32.cpp b/contrib/libs/poco/Foundation/src/RWLock_WIN32.cpp
index 973b0ae3c5..95383804cd 100644
--- a/contrib/libs/poco/Foundation/src/RWLock_WIN32.cpp
+++ b/contrib/libs/poco/Foundation/src/RWLock_WIN32.cpp
@@ -1,207 +1,207 @@
-//
-// RWLock_WIN32.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: RWLock
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/RWLock_WIN32.h"
-
-
-namespace Poco {
-
-
-RWLockImpl::RWLockImpl(): _readers(0), _writersWaiting(0), _writers(0)
-{
- _mutex = CreateMutexW(NULL, FALSE, NULL);
- if (_mutex == NULL)
- throw SystemException("cannot create reader/writer lock");
-
- _readEvent = CreateEventW(NULL, TRUE, TRUE, NULL);
- if (_readEvent == NULL)
- throw SystemException("cannot create reader/writer lock");
-
- _writeEvent = CreateEventW(NULL, TRUE, TRUE, NULL);
- if (_writeEvent == NULL)
- throw SystemException("cannot create reader/writer lock");
-}
-
-
-RWLockImpl::~RWLockImpl()
-{
- CloseHandle(_mutex);
- CloseHandle(_readEvent);
- CloseHandle(_writeEvent);
-}
-
-
-inline void RWLockImpl::addWriter()
-{
- switch (WaitForSingleObject(_mutex, INFINITE))
- {
- case WAIT_OBJECT_0:
- if (++_writersWaiting == 1) ResetEvent(_readEvent);
- ReleaseMutex(_mutex);
- break;
- default:
- throw SystemException("cannot lock reader/writer lock");
- }
-}
-
-
-inline void RWLockImpl::removeWriter()
-{
- switch (WaitForSingleObject(_mutex, INFINITE))
- {
- case WAIT_OBJECT_0:
- if (--_writersWaiting == 0 && _writers == 0) SetEvent(_readEvent);
- ReleaseMutex(_mutex);
- break;
- default:
- throw SystemException("cannot lock reader/writer lock");
- }
-}
-
-
-void RWLockImpl::readLockImpl()
-{
- HANDLE h[2];
- h[0] = _mutex;
- h[1] = _readEvent;
- switch (WaitForMultipleObjects(2, h, TRUE, INFINITE))
- {
- case WAIT_OBJECT_0:
- case WAIT_OBJECT_0 + 1:
- ++_readers;
- ResetEvent(_writeEvent);
- ReleaseMutex(_mutex);
- poco_assert_dbg(_writers == 0);
- break;
- default:
- throw SystemException("cannot lock reader/writer lock");
- }
-}
-
-
-bool RWLockImpl::tryReadLockImpl()
-{
- for (;;)
- {
- if (_writers != 0 || _writersWaiting != 0)
- return false;
-
- DWORD result = tryReadLockOnce();
- switch (result)
- {
- case WAIT_OBJECT_0:
- case WAIT_OBJECT_0 + 1:
- return true;
- case WAIT_TIMEOUT:
- continue; // try again
- default:
- throw SystemException("cannot lock reader/writer lock");
- }
- }
-}
-
-
-void RWLockImpl::writeLockImpl()
-{
- addWriter();
- HANDLE h[2];
- h[0] = _mutex;
- h[1] = _writeEvent;
- switch (WaitForMultipleObjects(2, h, TRUE, INFINITE))
- {
- case WAIT_OBJECT_0:
- case WAIT_OBJECT_0 + 1:
- --_writersWaiting;
- ++_readers;
- ++_writers;
- ResetEvent(_readEvent);
- ResetEvent(_writeEvent);
- ReleaseMutex(_mutex);
- poco_assert_dbg(_writers == 1);
- break;
- default:
- removeWriter();
- throw SystemException("cannot lock reader/writer lock");
- }
-}
-
-
-bool RWLockImpl::tryWriteLockImpl()
-{
- addWriter();
- HANDLE h[2];
- h[0] = _mutex;
- h[1] = _writeEvent;
- switch (WaitForMultipleObjects(2, h, TRUE, 1))
- {
- case WAIT_OBJECT_0:
- case WAIT_OBJECT_0 + 1:
- --_writersWaiting;
- ++_readers;
- ++_writers;
- ResetEvent(_readEvent);
- ResetEvent(_writeEvent);
- ReleaseMutex(_mutex);
- poco_assert_dbg(_writers == 1);
- return true;
- case WAIT_TIMEOUT:
- removeWriter();
- return false;
- default:
- removeWriter();
- throw SystemException("cannot lock reader/writer lock");
- }
-}
-
-
-void RWLockImpl::unlockImpl()
-{
- switch (WaitForSingleObject(_mutex, INFINITE))
- {
- case WAIT_OBJECT_0:
- _writers = 0;
- if (_writersWaiting == 0) SetEvent(_readEvent);
- if (--_readers == 0) SetEvent(_writeEvent);
- ReleaseMutex(_mutex);
- break;
- default:
- throw SystemException("cannot unlock reader/writer lock");
- }
-}
-
-
-DWORD RWLockImpl::tryReadLockOnce()
-{
- HANDLE h[2];
- h[0] = _mutex;
- h[1] = _readEvent;
- DWORD result = WaitForMultipleObjects(2, h, TRUE, 1);
- switch (result)
- {
- case WAIT_OBJECT_0:
- case WAIT_OBJECT_0 + 1:
- ++_readers;
- ResetEvent(_writeEvent);
- ReleaseMutex(_mutex);
- poco_assert_dbg(_writers == 0);
- return result;
- case WAIT_TIMEOUT:
- return result;
- default:
- throw SystemException("cannot lock reader/writer lock");
- }
-}
-
-
-} // namespace Poco
+//
+// RWLock_WIN32.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: RWLock
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/RWLock_WIN32.h"
+
+
+namespace Poco {
+
+
+RWLockImpl::RWLockImpl(): _readers(0), _writersWaiting(0), _writers(0)
+{
+ _mutex = CreateMutexW(NULL, FALSE, NULL);
+ if (_mutex == NULL)
+ throw SystemException("cannot create reader/writer lock");
+
+ _readEvent = CreateEventW(NULL, TRUE, TRUE, NULL);
+ if (_readEvent == NULL)
+ throw SystemException("cannot create reader/writer lock");
+
+ _writeEvent = CreateEventW(NULL, TRUE, TRUE, NULL);
+ if (_writeEvent == NULL)
+ throw SystemException("cannot create reader/writer lock");
+}
+
+
+RWLockImpl::~RWLockImpl()
+{
+ CloseHandle(_mutex);
+ CloseHandle(_readEvent);
+ CloseHandle(_writeEvent);
+}
+
+
+inline void RWLockImpl::addWriter()
+{
+ switch (WaitForSingleObject(_mutex, INFINITE))
+ {
+ case WAIT_OBJECT_0:
+ if (++_writersWaiting == 1) ResetEvent(_readEvent);
+ ReleaseMutex(_mutex);
+ break;
+ default:
+ throw SystemException("cannot lock reader/writer lock");
+ }
+}
+
+
+inline void RWLockImpl::removeWriter()
+{
+ switch (WaitForSingleObject(_mutex, INFINITE))
+ {
+ case WAIT_OBJECT_0:
+ if (--_writersWaiting == 0 && _writers == 0) SetEvent(_readEvent);
+ ReleaseMutex(_mutex);
+ break;
+ default:
+ throw SystemException("cannot lock reader/writer lock");
+ }
+}
+
+
+void RWLockImpl::readLockImpl()
+{
+ HANDLE h[2];
+ h[0] = _mutex;
+ h[1] = _readEvent;
+ switch (WaitForMultipleObjects(2, h, TRUE, INFINITE))
+ {
+ case WAIT_OBJECT_0:
+ case WAIT_OBJECT_0 + 1:
+ ++_readers;
+ ResetEvent(_writeEvent);
+ ReleaseMutex(_mutex);
+ poco_assert_dbg(_writers == 0);
+ break;
+ default:
+ throw SystemException("cannot lock reader/writer lock");
+ }
+}
+
+
+bool RWLockImpl::tryReadLockImpl()
+{
+ for (;;)
+ {
+ if (_writers != 0 || _writersWaiting != 0)
+ return false;
+
+ DWORD result = tryReadLockOnce();
+ switch (result)
+ {
+ case WAIT_OBJECT_0:
+ case WAIT_OBJECT_0 + 1:
+ return true;
+ case WAIT_TIMEOUT:
+ continue; // try again
+ default:
+ throw SystemException("cannot lock reader/writer lock");
+ }
+ }
+}
+
+
+void RWLockImpl::writeLockImpl()
+{
+ addWriter();
+ HANDLE h[2];
+ h[0] = _mutex;
+ h[1] = _writeEvent;
+ switch (WaitForMultipleObjects(2, h, TRUE, INFINITE))
+ {
+ case WAIT_OBJECT_0:
+ case WAIT_OBJECT_0 + 1:
+ --_writersWaiting;
+ ++_readers;
+ ++_writers;
+ ResetEvent(_readEvent);
+ ResetEvent(_writeEvent);
+ ReleaseMutex(_mutex);
+ poco_assert_dbg(_writers == 1);
+ break;
+ default:
+ removeWriter();
+ throw SystemException("cannot lock reader/writer lock");
+ }
+}
+
+
+bool RWLockImpl::tryWriteLockImpl()
+{
+ addWriter();
+ HANDLE h[2];
+ h[0] = _mutex;
+ h[1] = _writeEvent;
+ switch (WaitForMultipleObjects(2, h, TRUE, 1))
+ {
+ case WAIT_OBJECT_0:
+ case WAIT_OBJECT_0 + 1:
+ --_writersWaiting;
+ ++_readers;
+ ++_writers;
+ ResetEvent(_readEvent);
+ ResetEvent(_writeEvent);
+ ReleaseMutex(_mutex);
+ poco_assert_dbg(_writers == 1);
+ return true;
+ case WAIT_TIMEOUT:
+ removeWriter();
+ return false;
+ default:
+ removeWriter();
+ throw SystemException("cannot lock reader/writer lock");
+ }
+}
+
+
+void RWLockImpl::unlockImpl()
+{
+ switch (WaitForSingleObject(_mutex, INFINITE))
+ {
+ case WAIT_OBJECT_0:
+ _writers = 0;
+ if (_writersWaiting == 0) SetEvent(_readEvent);
+ if (--_readers == 0) SetEvent(_writeEvent);
+ ReleaseMutex(_mutex);
+ break;
+ default:
+ throw SystemException("cannot unlock reader/writer lock");
+ }
+}
+
+
+DWORD RWLockImpl::tryReadLockOnce()
+{
+ HANDLE h[2];
+ h[0] = _mutex;
+ h[1] = _readEvent;
+ DWORD result = WaitForMultipleObjects(2, h, TRUE, 1);
+ switch (result)
+ {
+ case WAIT_OBJECT_0:
+ case WAIT_OBJECT_0 + 1:
+ ++_readers;
+ ResetEvent(_writeEvent);
+ ReleaseMutex(_mutex);
+ poco_assert_dbg(_writers == 0);
+ return result;
+ case WAIT_TIMEOUT:
+ return result;
+ default:
+ throw SystemException("cannot lock reader/writer lock");
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/RWLock_WINCE.cpp b/contrib/libs/poco/Foundation/src/RWLock_WINCE.cpp
index f383a9da5d..9e1e150cf6 100644
--- a/contrib/libs/poco/Foundation/src/RWLock_WINCE.cpp
+++ b/contrib/libs/poco/Foundation/src/RWLock_WINCE.cpp
@@ -1,174 +1,174 @@
-//
-// RWLock_WINCE.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: RWLock
-//
-// Copyright (c) 2009-2010, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/RWLock_WINCE.h"
-#include "Poco/Thread.h"
-
-
-namespace Poco {
-
-
-RWLockImpl::RWLockImpl():
- _readerCount(0),
- _readerWaiting(0),
- _writerCount(0),
- _writerWaiting(0),
- _writeLock(false)
-
-{
- InitializeCriticalSection(&_cs);
- _readerGreen = CreateEventW(NULL, FALSE, TRUE, NULL);
- if (!_readerGreen) throw SystemException("Cannot create RWLock");
- _writerGreen = CreateEventW(NULL, FALSE, TRUE, NULL);
- if (!_writerGreen)
- {
- CloseHandle(_readerGreen);
- throw SystemException("Cannot create RWLock");
- }
-}
-
-
-RWLockImpl::~RWLockImpl()
-{
- CloseHandle(_readerGreen);
- CloseHandle(_writerGreen);
- DeleteCriticalSection(&_cs);
-}
-
-
-void RWLockImpl::readLockImpl()
-{
- tryReadLockImpl(INFINITE);
-}
-
-
-bool RWLockImpl::tryReadLockImpl(DWORD timeout)
-{
- bool wait = false;
- do
- {
- EnterCriticalSection(&_cs);
- if (!_writerCount && !_writerWaiting)
- {
- if (wait)
- {
- _readerWaiting--;
- wait = false;
- }
- _readerCount++;
- }
- else
- {
- if (!wait)
- {
- _readerWaiting++;
- wait = true;
- }
- ResetEvent(_readerGreen);
- }
+//
+// RWLock_WINCE.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: RWLock
+//
+// Copyright (c) 2009-2010, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/RWLock_WINCE.h"
+#include "Poco/Thread.h"
+
+
+namespace Poco {
+
+
+RWLockImpl::RWLockImpl():
+ _readerCount(0),
+ _readerWaiting(0),
+ _writerCount(0),
+ _writerWaiting(0),
+ _writeLock(false)
+
+{
+ InitializeCriticalSection(&_cs);
+ _readerGreen = CreateEventW(NULL, FALSE, TRUE, NULL);
+ if (!_readerGreen) throw SystemException("Cannot create RWLock");
+ _writerGreen = CreateEventW(NULL, FALSE, TRUE, NULL);
+ if (!_writerGreen)
+ {
+ CloseHandle(_readerGreen);
+ throw SystemException("Cannot create RWLock");
+ }
+}
+
+
+RWLockImpl::~RWLockImpl()
+{
+ CloseHandle(_readerGreen);
+ CloseHandle(_writerGreen);
+ DeleteCriticalSection(&_cs);
+}
+
+
+void RWLockImpl::readLockImpl()
+{
+ tryReadLockImpl(INFINITE);
+}
+
+
+bool RWLockImpl::tryReadLockImpl(DWORD timeout)
+{
+ bool wait = false;
+ do
+ {
+ EnterCriticalSection(&_cs);
+ if (!_writerCount && !_writerWaiting)
+ {
+ if (wait)
+ {
+ _readerWaiting--;
+ wait = false;
+ }
+ _readerCount++;
+ }
+ else
+ {
+ if (!wait)
+ {
+ _readerWaiting++;
+ wait = true;
+ }
+ ResetEvent(_readerGreen);
+ }
+ LeaveCriticalSection(&_cs);
+ if (wait)
+ {
+ if (WaitForSingleObject(_readerGreen, timeout) != WAIT_OBJECT_0)
+ {
+ EnterCriticalSection(&_cs);
+ _readerWaiting--;
+ SetEvent(_readerGreen);
+ SetEvent(_writerGreen);
+ LeaveCriticalSection(&_cs);
+ return false;
+ }
+ }
+ }
+ while (wait);
+
+ return true;
+}
+
+
+void RWLockImpl::writeLockImpl()
+{
+ tryWriteLockImpl(INFINITE);
+}
+
+
+bool RWLockImpl::tryWriteLockImpl(DWORD timeout)
+{
+ bool wait = false;
+
+ do
+ {
+ EnterCriticalSection(&_cs);
+ if (!_readerCount && !_writerCount)
+ {
+ if (wait)
+ {
+ _writerWaiting--;
+ wait = false;
+ }
+ _writerCount++;
+ }
+ else
+ {
+ if (!wait)
+ {
+ _writerWaiting++;
+ wait = true;
+ }
+ ResetEvent(_writerGreen);
+ }
LeaveCriticalSection(&_cs);
- if (wait)
- {
- if (WaitForSingleObject(_readerGreen, timeout) != WAIT_OBJECT_0)
- {
- EnterCriticalSection(&_cs);
- _readerWaiting--;
+ if (wait)
+ {
+ if (WaitForSingleObject(_writerGreen, timeout) != WAIT_OBJECT_0)
+ {
+ EnterCriticalSection(&_cs);
+ _writerWaiting--;
SetEvent(_readerGreen);
- SetEvent(_writerGreen);
- LeaveCriticalSection(&_cs);
- return false;
- }
- }
+ SetEvent(_writerGreen);
+ LeaveCriticalSection(&_cs);
+ return false;
+ }
+ }
}
- while (wait);
-
- return true;
-}
-
-
-void RWLockImpl::writeLockImpl()
-{
- tryWriteLockImpl(INFINITE);
-}
-
-
-bool RWLockImpl::tryWriteLockImpl(DWORD timeout)
-{
- bool wait = false;
-
- do
- {
- EnterCriticalSection(&_cs);
- if (!_readerCount && !_writerCount)
- {
- if (wait)
- {
- _writerWaiting--;
- wait = false;
- }
- _writerCount++;
- }
- else
- {
- if (!wait)
- {
- _writerWaiting++;
- wait = true;
- }
- ResetEvent(_writerGreen);
- }
- LeaveCriticalSection(&_cs);
- if (wait)
- {
- if (WaitForSingleObject(_writerGreen, timeout) != WAIT_OBJECT_0)
- {
- EnterCriticalSection(&_cs);
- _writerWaiting--;
- SetEvent(_readerGreen);
- SetEvent(_writerGreen);
- LeaveCriticalSection(&_cs);
- return false;
- }
- }
- }
- while (wait);
-
- _writeLock = true;
- return true;
-}
-
-
-void RWLockImpl::unlockImpl()
-{
- EnterCriticalSection(&_cs);
-
- if (_writeLock)
- {
- _writeLock = false;
- _writerCount--;
- }
- else
- {
- _readerCount--;
- }
- if (_writerWaiting)
- SetEvent(_writerGreen);
- else if (_readerWaiting)
- SetEvent(_readerGreen);
-
- LeaveCriticalSection(&_cs);
-}
-
-
-} // namespace Poco
+ while (wait);
+
+ _writeLock = true;
+ return true;
+}
+
+
+void RWLockImpl::unlockImpl()
+{
+ EnterCriticalSection(&_cs);
+
+ if (_writeLock)
+ {
+ _writeLock = false;
+ _writerCount--;
+ }
+ else
+ {
+ _readerCount--;
+ }
+ if (_writerWaiting)
+ SetEvent(_writerGreen);
+ else if (_readerWaiting)
+ SetEvent(_readerGreen);
+
+ LeaveCriticalSection(&_cs);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Random.cpp b/contrib/libs/poco/Foundation/src/Random.cpp
index 048eea0144..05da8e895b 100644
--- a/contrib/libs/poco/Foundation/src/Random.cpp
+++ b/contrib/libs/poco/Foundation/src/Random.cpp
@@ -1,364 +1,364 @@
-//
-// Random.cpp
-//
-// Library: Foundation
-// Package: Crypt
-// Module: Random
-//
-// Definition of class Random.
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-//
-// Based on the FreeBSD random number generator.
-// src/lib/libc/stdlib/random.c,v 1.25
-//
-// Copyright (c) 1983, 1993
-// The Regents of the University of California. All rights reserved.
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-// 1. Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// 2. Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-// 4. Neither the name of the University nor the names of its contributors
-// may be used to endorse or promote products derived from this software
-// without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-// SUCH DAMAGE.
-//
-
-
-#include "Poco/Random.h"
-#include "Poco/RandomStream.h"
-#include <ctime>
-#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
-#error #include "wce_time.h"
-#endif
-
-
-/*
- * random.c:
- *
- * An improved random number generation package. In addition to the standard
- * rand()/srand() like interface, this package also has a special state info
- * interface. The initstate() routine is called with a seed, an array of
- * bytes, and a count of how many bytes are being passed in; this array is
- * then initialized to contain information for random number generation with
- * that much state information. Good sizes for the amount of state
- * information are 32, 64, 128, and 256 bytes. The state can be switched by
- * calling the setstate() routine with the same array as was initiallized
- * with initstate(). By default, the package runs with 128 bytes of state
- * information and generates far better random numbers than a linear
- * congruential generator. If the amount of state information is less than
- * 32 bytes, a simple linear congruential R.N.G. is used.
- *
- * Internally, the state information is treated as an array of uint32_t's; the
- * zeroeth element of the array is the type of R.N.G. being used (small
- * integer); the remainder of the array is the state information for the
- * R.N.G. Thus, 32 bytes of state information will give 7 ints worth of
- * state information, which will allow a degree seven polynomial. (Note:
- * the zeroeth word of state information also has some other information
- * stored in it -- see setstate() for details).
- *
- * The random number generation technique is a linear feedback shift register
- * approach, employing trinomials (since there are fewer terms to sum up that
- * way). In this approach, the least significant bit of all the numbers in
- * the state table will act as a linear feedback shift register, and will
- * have period 2^deg - 1 (where deg is the degree of the polynomial being
- * used, assuming that the polynomial is irreducible and primitive). The
- * higher order bits will have longer periods, since their values are also
- * influenced by pseudo-random carries out of the lower bits. The total
- * period of the generator is approximately deg*(2**deg - 1); thus doubling
- * the amount of state information has a vast influence on the period of the
- * generator. Note: the deg*(2**deg - 1) is an approximation only good for
- * large deg, when the period of the shift is the dominant factor.
- * With deg equal to seven, the period is actually much longer than the
- * 7*(2**7 - 1) predicted by this formula.
- *
- * Modified 28 December 1994 by Jacob S. Rosenberg.
- * The following changes have been made:
- * All references to the type u_int have been changed to unsigned long.
- * All references to type int have been changed to type long. Other
- * cleanups have been made as well. A warning for both initstate and
- * setstate has been inserted to the effect that on Sparc platforms
- * the 'arg_state' variable must be forced to begin on word boundaries.
- * This can be easily done by casting a long integer array to char *.
- * The overall logic has been left STRICTLY alone. This software was
- * tested on both a VAX and Sun SpacsStation with exactly the same
- * results. The new version and the original give IDENTICAL results.
- * The new version is somewhat faster than the original. As the
- * documentation says: "By default, the package runs with 128 bytes of
- * state information and generates far better random numbers than a linear
- * congruential generator. If the amount of state information is less than
- * 32 bytes, a simple linear congruential R.N.G. is used." For a buffer of
- * 128 bytes, this new version runs about 19 percent faster and for a 16
- * byte buffer it is about 5 percent faster.
- */
-
-
-/*
- * For each of the currently supported random number generators, we have a
- * break value on the amount of state information (you need at least this
- * many bytes of state info to support this random number generator), a degree
- * for the polynomial (actually a trinomial) that the R.N.G. is based on, and
- * the separation between the two lower order coefficients of the trinomial.
- */
-#define TYPE_0 0 /* linear congruential */
-#define BREAK_0 8
-#define DEG_0 0
-#define SEP_0 0
-
-#define TYPE_1 1 /* x**7 + x**3 + 1 */
-#define BREAK_1 32
-#define DEG_1 7
-#define SEP_1 3
-
-#define TYPE_2 2 /* x**15 + x + 1 */
-#define BREAK_2 64
-#define DEG_2 15
-#define SEP_2 1
-
-#define TYPE_3 3 /* x**31 + x**3 + 1 */
-#define BREAK_3 128
-#define DEG_3 31
-#define SEP_3 3
-
-#define TYPE_4 4 /* x**63 + x + 1 */
-#define BREAK_4 256
-#define DEG_4 63
-#define SEP_4 1
-
-
-namespace Poco {
-
-
-Random::Random(int stateSize)
-{
- poco_assert (BREAK_0 <= stateSize && stateSize <= BREAK_4);
-
- _pBuffer = new char[stateSize];
-#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
- initState((UInt32) wceex_time(NULL), _pBuffer, stateSize);
-#else
- initState((UInt32) std::time(NULL), _pBuffer, stateSize);
-#endif
-}
-
-
-Random::~Random()
-{
- delete [] _pBuffer;
-}
-
-
-/*
- * Compute x = (7^5 * x) mod (2^31 - 1)
- * wihout overflowing 31 bits:
- * (2^31 - 1) = 127773 * (7^5) + 2836
- * From "Random number generators: good ones are hard to find",
- * Park and Miller, Communications of the ACM, vol. 31, no. 10,
- * October 1988, p. 1195.
- */
-inline UInt32 Random::goodRand(Int32 x)
-{
- Int32 hi, lo;
-
- if (x == 0) x = 123459876;
- hi = x / 127773;
- lo = x % 127773;
- x = 16807 * lo - 2836 * hi;
- if (x < 0) x += 0x7FFFFFFF;
-
- return x;
-}
-
-
-/*
- * Initialize the random number generator based on the given seed. If the
- * type is the trivial no-state-information type, just remember the seed.
- * Otherwise, initializes state[] based on the given "seed" via a linear
- * congruential generator. Then, the pointers are set to known locations
- * that are exactly rand_sep places apart. Lastly, it cycles the state
- * information a given number of times to get rid of any initial dependencies
- * introduced by the L.C.R.N.G. Note that the initialization of randtbl[]
- * for default usage relies on values produced by this routine.
- */
-void Random::seed(UInt32 x)
-{
- int i, lim;
-
- _state[0] = x;
- if (_randType == TYPE_0)
- lim = NSHUFF;
- else
- {
- for (i = 1; i < _randDeg; i++)
- _state[i] = goodRand(_state[i - 1]);
- _fptr = &_state[_randSep];
- _rptr = &_state[0];
- lim = 10 * _randDeg;
- }
- for (i = 0; i < lim; i++)
- next();
-}
-
-
-/*
- * Many programs choose the seed value in a totally predictable manner.
- * This often causes problems. We seed the generator using the much more
- * secure random(4) interface. Note that this particular seeding
- * procedure can generate states which are impossible to reproduce by
- * calling srandom() with any value, since the succeeding terms in the
- * state buffer are no longer derived from the LC algorithm applied to
- * a fixed seed.
- */
-void Random::seed()
-{
- std::streamsize len;
-
- if (_randType == TYPE_0)
- len = sizeof _state[0];
- else
- len = _randDeg * sizeof _state[0];
-
- RandomInputStream rstr;
- rstr.read((char*) _state, len);
-}
-
-
-/*
- * Initialize the state information in the given array of n bytes for future
- * random number generation. Based on the number of bytes we are given, and
- * the break values for the different R.N.G.'s, we choose the best (largest)
- * one we can and set things up for it. srandom() is then called to
- * initialize the state information.
- *
- * Note that on return from srandom(), we set state[-1] to be the type
- * multiplexed with the current value of the rear pointer; this is so
- * successive calls to initstate() won't lose this information and will be
- * able to restart with setstate().
- *
- * Note: the first thing we do is save the current state, if any, just like
- * setstate() so that it doesn't matter when initstate is called.
- *
- * Returns a pointer to the old state.
- *
- * Note: The Sparc platform requires that arg_state begin on an int
- * word boundary; otherwise a bus error will occur. Even so, lint will
- * complain about mis-alignment, but you should disregard these messages.
- */
-void Random::initState(UInt32 s, char* argState, Int32 n)
-{
- UInt32* intArgState = (UInt32*) argState;
-
- if (n < BREAK_0)
- {
- poco_bugcheck_msg("not enough state");
- return;
- }
- if (n < BREAK_1)
- {
- _randType = TYPE_0;
- _randDeg = DEG_0;
- _randSep = SEP_0;
- }
- else if (n < BREAK_2)
- {
- _randType = TYPE_1;
- _randDeg = DEG_1;
- _randSep = SEP_1;
+//
+// Random.cpp
+//
+// Library: Foundation
+// Package: Crypt
+// Module: Random
+//
+// Definition of class Random.
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+//
+// Based on the FreeBSD random number generator.
+// src/lib/libc/stdlib/random.c,v 1.25
+//
+// Copyright (c) 1983, 1993
+// The Regents of the University of California. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// 4. Neither the name of the University nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE.
+//
+
+
+#include "Poco/Random.h"
+#include "Poco/RandomStream.h"
+#include <ctime>
+#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
+#error #include "wce_time.h"
+#endif
+
+
+/*
+ * random.c:
+ *
+ * An improved random number generation package. In addition to the standard
+ * rand()/srand() like interface, this package also has a special state info
+ * interface. The initstate() routine is called with a seed, an array of
+ * bytes, and a count of how many bytes are being passed in; this array is
+ * then initialized to contain information for random number generation with
+ * that much state information. Good sizes for the amount of state
+ * information are 32, 64, 128, and 256 bytes. The state can be switched by
+ * calling the setstate() routine with the same array as was initiallized
+ * with initstate(). By default, the package runs with 128 bytes of state
+ * information and generates far better random numbers than a linear
+ * congruential generator. If the amount of state information is less than
+ * 32 bytes, a simple linear congruential R.N.G. is used.
+ *
+ * Internally, the state information is treated as an array of uint32_t's; the
+ * zeroeth element of the array is the type of R.N.G. being used (small
+ * integer); the remainder of the array is the state information for the
+ * R.N.G. Thus, 32 bytes of state information will give 7 ints worth of
+ * state information, which will allow a degree seven polynomial. (Note:
+ * the zeroeth word of state information also has some other information
+ * stored in it -- see setstate() for details).
+ *
+ * The random number generation technique is a linear feedback shift register
+ * approach, employing trinomials (since there are fewer terms to sum up that
+ * way). In this approach, the least significant bit of all the numbers in
+ * the state table will act as a linear feedback shift register, and will
+ * have period 2^deg - 1 (where deg is the degree of the polynomial being
+ * used, assuming that the polynomial is irreducible and primitive). The
+ * higher order bits will have longer periods, since their values are also
+ * influenced by pseudo-random carries out of the lower bits. The total
+ * period of the generator is approximately deg*(2**deg - 1); thus doubling
+ * the amount of state information has a vast influence on the period of the
+ * generator. Note: the deg*(2**deg - 1) is an approximation only good for
+ * large deg, when the period of the shift is the dominant factor.
+ * With deg equal to seven, the period is actually much longer than the
+ * 7*(2**7 - 1) predicted by this formula.
+ *
+ * Modified 28 December 1994 by Jacob S. Rosenberg.
+ * The following changes have been made:
+ * All references to the type u_int have been changed to unsigned long.
+ * All references to type int have been changed to type long. Other
+ * cleanups have been made as well. A warning for both initstate and
+ * setstate has been inserted to the effect that on Sparc platforms
+ * the 'arg_state' variable must be forced to begin on word boundaries.
+ * This can be easily done by casting a long integer array to char *.
+ * The overall logic has been left STRICTLY alone. This software was
+ * tested on both a VAX and Sun SpacsStation with exactly the same
+ * results. The new version and the original give IDENTICAL results.
+ * The new version is somewhat faster than the original. As the
+ * documentation says: "By default, the package runs with 128 bytes of
+ * state information and generates far better random numbers than a linear
+ * congruential generator. If the amount of state information is less than
+ * 32 bytes, a simple linear congruential R.N.G. is used." For a buffer of
+ * 128 bytes, this new version runs about 19 percent faster and for a 16
+ * byte buffer it is about 5 percent faster.
+ */
+
+
+/*
+ * For each of the currently supported random number generators, we have a
+ * break value on the amount of state information (you need at least this
+ * many bytes of state info to support this random number generator), a degree
+ * for the polynomial (actually a trinomial) that the R.N.G. is based on, and
+ * the separation between the two lower order coefficients of the trinomial.
+ */
+#define TYPE_0 0 /* linear congruential */
+#define BREAK_0 8
+#define DEG_0 0
+#define SEP_0 0
+
+#define TYPE_1 1 /* x**7 + x**3 + 1 */
+#define BREAK_1 32
+#define DEG_1 7
+#define SEP_1 3
+
+#define TYPE_2 2 /* x**15 + x + 1 */
+#define BREAK_2 64
+#define DEG_2 15
+#define SEP_2 1
+
+#define TYPE_3 3 /* x**31 + x**3 + 1 */
+#define BREAK_3 128
+#define DEG_3 31
+#define SEP_3 3
+
+#define TYPE_4 4 /* x**63 + x + 1 */
+#define BREAK_4 256
+#define DEG_4 63
+#define SEP_4 1
+
+
+namespace Poco {
+
+
+Random::Random(int stateSize)
+{
+ poco_assert (BREAK_0 <= stateSize && stateSize <= BREAK_4);
+
+ _pBuffer = new char[stateSize];
+#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
+ initState((UInt32) wceex_time(NULL), _pBuffer, stateSize);
+#else
+ initState((UInt32) std::time(NULL), _pBuffer, stateSize);
+#endif
+}
+
+
+Random::~Random()
+{
+ delete [] _pBuffer;
+}
+
+
+/*
+ * Compute x = (7^5 * x) mod (2^31 - 1)
+ * wihout overflowing 31 bits:
+ * (2^31 - 1) = 127773 * (7^5) + 2836
+ * From "Random number generators: good ones are hard to find",
+ * Park and Miller, Communications of the ACM, vol. 31, no. 10,
+ * October 1988, p. 1195.
+ */
+inline UInt32 Random::goodRand(Int32 x)
+{
+ Int32 hi, lo;
+
+ if (x == 0) x = 123459876;
+ hi = x / 127773;
+ lo = x % 127773;
+ x = 16807 * lo - 2836 * hi;
+ if (x < 0) x += 0x7FFFFFFF;
+
+ return x;
+}
+
+
+/*
+ * Initialize the random number generator based on the given seed. If the
+ * type is the trivial no-state-information type, just remember the seed.
+ * Otherwise, initializes state[] based on the given "seed" via a linear
+ * congruential generator. Then, the pointers are set to known locations
+ * that are exactly rand_sep places apart. Lastly, it cycles the state
+ * information a given number of times to get rid of any initial dependencies
+ * introduced by the L.C.R.N.G. Note that the initialization of randtbl[]
+ * for default usage relies on values produced by this routine.
+ */
+void Random::seed(UInt32 x)
+{
+ int i, lim;
+
+ _state[0] = x;
+ if (_randType == TYPE_0)
+ lim = NSHUFF;
+ else
+ {
+ for (i = 1; i < _randDeg; i++)
+ _state[i] = goodRand(_state[i - 1]);
+ _fptr = &_state[_randSep];
+ _rptr = &_state[0];
+ lim = 10 * _randDeg;
}
- else if (n < BREAK_3)
- {
- _randType = TYPE_2;
- _randDeg = DEG_2;
- _randSep = SEP_2;
+ for (i = 0; i < lim; i++)
+ next();
+}
+
+
+/*
+ * Many programs choose the seed value in a totally predictable manner.
+ * This often causes problems. We seed the generator using the much more
+ * secure random(4) interface. Note that this particular seeding
+ * procedure can generate states which are impossible to reproduce by
+ * calling srandom() with any value, since the succeeding terms in the
+ * state buffer are no longer derived from the LC algorithm applied to
+ * a fixed seed.
+ */
+void Random::seed()
+{
+ std::streamsize len;
+
+ if (_randType == TYPE_0)
+ len = sizeof _state[0];
+ else
+ len = _randDeg * sizeof _state[0];
+
+ RandomInputStream rstr;
+ rstr.read((char*) _state, len);
+}
+
+
+/*
+ * Initialize the state information in the given array of n bytes for future
+ * random number generation. Based on the number of bytes we are given, and
+ * the break values for the different R.N.G.'s, we choose the best (largest)
+ * one we can and set things up for it. srandom() is then called to
+ * initialize the state information.
+ *
+ * Note that on return from srandom(), we set state[-1] to be the type
+ * multiplexed with the current value of the rear pointer; this is so
+ * successive calls to initstate() won't lose this information and will be
+ * able to restart with setstate().
+ *
+ * Note: the first thing we do is save the current state, if any, just like
+ * setstate() so that it doesn't matter when initstate is called.
+ *
+ * Returns a pointer to the old state.
+ *
+ * Note: The Sparc platform requires that arg_state begin on an int
+ * word boundary; otherwise a bus error will occur. Even so, lint will
+ * complain about mis-alignment, but you should disregard these messages.
+ */
+void Random::initState(UInt32 s, char* argState, Int32 n)
+{
+ UInt32* intArgState = (UInt32*) argState;
+
+ if (n < BREAK_0)
+ {
+ poco_bugcheck_msg("not enough state");
+ return;
}
- else if (n < BREAK_4)
- {
- _randType = TYPE_3;
- _randDeg = DEG_3;
- _randSep = SEP_3;
+ if (n < BREAK_1)
+ {
+ _randType = TYPE_0;
+ _randDeg = DEG_0;
+ _randSep = SEP_0;
+ }
+ else if (n < BREAK_2)
+ {
+ _randType = TYPE_1;
+ _randDeg = DEG_1;
+ _randSep = SEP_1;
+ }
+ else if (n < BREAK_3)
+ {
+ _randType = TYPE_2;
+ _randDeg = DEG_2;
+ _randSep = SEP_2;
+ }
+ else if (n < BREAK_4)
+ {
+ _randType = TYPE_3;
+ _randDeg = DEG_3;
+ _randSep = SEP_3;
+ }
+ else
+ {
+ _randType = TYPE_4;
+ _randDeg = DEG_4;
+ _randSep = SEP_4;
}
- else
- {
- _randType = TYPE_4;
- _randDeg = DEG_4;
- _randSep = SEP_4;
- }
- _state = intArgState + 1; /* first location */
- _endPtr = &_state[_randDeg]; /* must set end_ptr before seed */
- seed(s);
- if (_randType == TYPE_0)
- intArgState[0] = _randType;
- else
- intArgState[0] = MAX_TYPES * (int) (_rptr - _state) + _randType;
-}
-
-
-/*
- * Next:
- *
- * If we are using the trivial TYPE_0 R.N.G., just do the old linear
- * congruential bit. Otherwise, we do our fancy trinomial stuff, which is
- * the same in all the other cases due to all the global variables that have
- * been set up. The basic operation is to add the number at the rear pointer
- * into the one at the front pointer. Then both pointers are advanced to
- * the next location cyclically in the table. The value returned is the sum
- * generated, reduced to 31 bits by throwing away the "least random" low bit.
- *
- * Note: the code takes advantage of the fact that both the front and
- * rear pointers can't wrap on the same call by not testing the rear
- * pointer if the front one has wrapped.
- *
- * Returns a 31-bit random number.
- */
-UInt32 Random::next()
-{
- UInt32 i;
- UInt32 *f, *r;
-
+ _state = intArgState + 1; /* first location */
+ _endPtr = &_state[_randDeg]; /* must set end_ptr before seed */
+ seed(s);
if (_randType == TYPE_0)
- {
- i = _state[0];
- _state[0] = i = goodRand(i) & 0x7FFFFFFF;
- }
+ intArgState[0] = _randType;
else
- {
- /*
- * Use local variables rather than static variables for speed.
- */
- f = _fptr; r = _rptr;
- *f += *r;
- i = (*f >> 1) & 0x7FFFFFFF; /* chucking least random bit */
- if (++f >= _endPtr) {
- f = _state;
- ++r;
- }
- else if (++r >= _endPtr) {
- r = _state;
- }
-
- _fptr = f; _rptr = r;
- }
- return i;
-}
-
-
-} // namespace Poco
+ intArgState[0] = MAX_TYPES * (int) (_rptr - _state) + _randType;
+}
+
+
+/*
+ * Next:
+ *
+ * If we are using the trivial TYPE_0 R.N.G., just do the old linear
+ * congruential bit. Otherwise, we do our fancy trinomial stuff, which is
+ * the same in all the other cases due to all the global variables that have
+ * been set up. The basic operation is to add the number at the rear pointer
+ * into the one at the front pointer. Then both pointers are advanced to
+ * the next location cyclically in the table. The value returned is the sum
+ * generated, reduced to 31 bits by throwing away the "least random" low bit.
+ *
+ * Note: the code takes advantage of the fact that both the front and
+ * rear pointers can't wrap on the same call by not testing the rear
+ * pointer if the front one has wrapped.
+ *
+ * Returns a 31-bit random number.
+ */
+UInt32 Random::next()
+{
+ UInt32 i;
+ UInt32 *f, *r;
+
+ if (_randType == TYPE_0)
+ {
+ i = _state[0];
+ _state[0] = i = goodRand(i) & 0x7FFFFFFF;
+ }
+ else
+ {
+ /*
+ * Use local variables rather than static variables for speed.
+ */
+ f = _fptr; r = _rptr;
+ *f += *r;
+ i = (*f >> 1) & 0x7FFFFFFF; /* chucking least random bit */
+ if (++f >= _endPtr) {
+ f = _state;
+ ++r;
+ }
+ else if (++r >= _endPtr) {
+ r = _state;
+ }
+
+ _fptr = f; _rptr = r;
+ }
+ return i;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/RandomStream.cpp b/contrib/libs/poco/Foundation/src/RandomStream.cpp
index 7a490eb603..091b1e7955 100644
--- a/contrib/libs/poco/Foundation/src/RandomStream.cpp
+++ b/contrib/libs/poco/Foundation/src/RandomStream.cpp
@@ -1,127 +1,127 @@
-//
-// RandomStream.cpp
-//
-// Library: Foundation
-// Package: Crypt
-// Module: RandomStream
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/RandomStream.h"
-#include "Poco/Random.h"
-#include "Poco/SHA1Engine.h"
-#if defined(POCO_OS_FAMILY_WINDOWS)
-#include "Poco/UnWindows.h"
-#include <wincrypt.h>
-#elif defined(POCO_OS_FAMILY_UNIX)
-#include <fcntl.h>
-#include <unistd.h>
-#endif
-#include <ctime>
-
-
-namespace Poco {
-
-
-RandomBuf::RandomBuf(): BufferedStreamBuf(256, std::ios::in)
-{
-}
-
-
-RandomBuf::~RandomBuf()
-{
-}
-
-
-int RandomBuf::readFromDevice(char* buffer, std::streamsize length)
-{
- int n = 0;
-
-#if defined(POCO_OS_FAMILY_WINDOWS)
- HCRYPTPROV hProvider = 0;
- CryptAcquireContext(&hProvider, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
- CryptGenRandom(hProvider, (DWORD) length, (BYTE*) buffer);
- CryptReleaseContext(hProvider, 0);
- n = static_cast<int>(length);
-#else
- #if defined(POCO_OS_FAMILY_UNIX)
- int fd = open("/dev/urandom", O_RDONLY, 0);
- if (fd >= 0)
- {
- n = read(fd, buffer, length);
- close(fd);
- }
- #endif
- if (n <= 0)
- {
- // x is here as a source of randomness, so it does not make
- // much sense to protect it with a Mutex.
- static UInt32 x = 0;
- Random rnd1(256);
- Random rnd2(64);
- x += rnd1.next();
-
- n = 0;
- SHA1Engine engine;
- UInt32 t = (UInt32) std::time(NULL);
- engine.update(&t, sizeof(t));
- void* p = this;
- engine.update(&p, sizeof(p));
- engine.update(buffer, length);
- UInt32 junk[32];
- engine.update(junk, sizeof(junk));
- while (n < length)
- {
- for (int i = 0; i < 100; ++i)
- {
- UInt32 r = rnd2.next();
- engine.update(&r, sizeof(r));
- engine.update(&x, sizeof(x));
- x += rnd1.next();
- }
- DigestEngine::Digest d = engine.digest();
- for (DigestEngine::Digest::const_iterator it = d.begin(); it != d.end() && n < length; ++it, ++n)
- {
- engine.update(*it);
- *buffer++ = *it++;
- }
- }
- }
-#endif
- return n;
-}
-
-
-RandomIOS::RandomIOS()
-{
- poco_ios_init(&_buf);
-}
-
-
-RandomIOS::~RandomIOS()
-{
-}
-
-
-RandomBuf* RandomIOS::rdbuf()
-{
- return &_buf;
-}
-
-
-RandomInputStream::RandomInputStream(): std::istream(&_buf)
-{
-}
-
-
-RandomInputStream::~RandomInputStream()
-{
-}
-
-
-} // namespace Poco
+//
+// RandomStream.cpp
+//
+// Library: Foundation
+// Package: Crypt
+// Module: RandomStream
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/RandomStream.h"
+#include "Poco/Random.h"
+#include "Poco/SHA1Engine.h"
+#if defined(POCO_OS_FAMILY_WINDOWS)
+#include "Poco/UnWindows.h"
+#include <wincrypt.h>
+#elif defined(POCO_OS_FAMILY_UNIX)
+#include <fcntl.h>
+#include <unistd.h>
+#endif
+#include <ctime>
+
+
+namespace Poco {
+
+
+RandomBuf::RandomBuf(): BufferedStreamBuf(256, std::ios::in)
+{
+}
+
+
+RandomBuf::~RandomBuf()
+{
+}
+
+
+int RandomBuf::readFromDevice(char* buffer, std::streamsize length)
+{
+ int n = 0;
+
+#if defined(POCO_OS_FAMILY_WINDOWS)
+ HCRYPTPROV hProvider = 0;
+ CryptAcquireContext(&hProvider, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
+ CryptGenRandom(hProvider, (DWORD) length, (BYTE*) buffer);
+ CryptReleaseContext(hProvider, 0);
+ n = static_cast<int>(length);
+#else
+ #if defined(POCO_OS_FAMILY_UNIX)
+ int fd = open("/dev/urandom", O_RDONLY, 0);
+ if (fd >= 0)
+ {
+ n = read(fd, buffer, length);
+ close(fd);
+ }
+ #endif
+ if (n <= 0)
+ {
+ // x is here as a source of randomness, so it does not make
+ // much sense to protect it with a Mutex.
+ static UInt32 x = 0;
+ Random rnd1(256);
+ Random rnd2(64);
+ x += rnd1.next();
+
+ n = 0;
+ SHA1Engine engine;
+ UInt32 t = (UInt32) std::time(NULL);
+ engine.update(&t, sizeof(t));
+ void* p = this;
+ engine.update(&p, sizeof(p));
+ engine.update(buffer, length);
+ UInt32 junk[32];
+ engine.update(junk, sizeof(junk));
+ while (n < length)
+ {
+ for (int i = 0; i < 100; ++i)
+ {
+ UInt32 r = rnd2.next();
+ engine.update(&r, sizeof(r));
+ engine.update(&x, sizeof(x));
+ x += rnd1.next();
+ }
+ DigestEngine::Digest d = engine.digest();
+ for (DigestEngine::Digest::const_iterator it = d.begin(); it != d.end() && n < length; ++it, ++n)
+ {
+ engine.update(*it);
+ *buffer++ = *it++;
+ }
+ }
+ }
+#endif
+ return n;
+}
+
+
+RandomIOS::RandomIOS()
+{
+ poco_ios_init(&_buf);
+}
+
+
+RandomIOS::~RandomIOS()
+{
+}
+
+
+RandomBuf* RandomIOS::rdbuf()
+{
+ return &_buf;
+}
+
+
+RandomInputStream::RandomInputStream(): std::istream(&_buf)
+{
+}
+
+
+RandomInputStream::~RandomInputStream()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/RefCountedObject.cpp b/contrib/libs/poco/Foundation/src/RefCountedObject.cpp
index 4f3317ead1..138ba09ff5 100644
--- a/contrib/libs/poco/Foundation/src/RefCountedObject.cpp
+++ b/contrib/libs/poco/Foundation/src/RefCountedObject.cpp
@@ -1,31 +1,31 @@
-//
-// RefCountedObject.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: RefCountedObject
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/RefCountedObject.h"
-
-
-namespace Poco {
-
-
-RefCountedObject::RefCountedObject(): _counter(1)
-{
-}
-
-
-RefCountedObject::~RefCountedObject()
-{
-}
-
-
-} // namespace Poco
+//
+// RefCountedObject.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: RefCountedObject
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/RefCountedObject.h"
+
+
+namespace Poco {
+
+
+RefCountedObject::RefCountedObject(): _counter(1)
+{
+}
+
+
+RefCountedObject::~RefCountedObject()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/RegularExpression.cpp b/contrib/libs/poco/Foundation/src/RegularExpression.cpp
index 0ab62b654a..ebc7526705 100644
--- a/contrib/libs/poco/Foundation/src/RegularExpression.cpp
+++ b/contrib/libs/poco/Foundation/src/RegularExpression.cpp
@@ -1,284 +1,284 @@
-//
-// RegularExpression.h
-//
-// Library: Foundation
-// Package: RegExp
-// Module: RegularExpression
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/RegularExpression.h"
-#include "Poco/Exception.h"
-#include <sstream>
-#if defined(POCO_UNBUNDLED)
-#include <pcre.h>
-#else
-#include "pcre_config.h"
-#include "pcre.h"
-#endif
-
-
-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)
-{
- const char* error;
- int offs;
- _pcre = pcre_compile(pattern.c_str(), options, &error, &offs, 0);
- if (!_pcre)
- {
- std::ostringstream msg;
- msg << error << " (at offset " << offs << ")";
- throw RegularExpressionException(msg.str());
- }
- if (study)
- _extra = pcre_study(reinterpret_cast<pcre*>(_pcre), 0, &error);
-}
-
-
-RegularExpression::~RegularExpression()
-{
- if (_pcre) pcre_free(reinterpret_cast<pcre*>(_pcre));
- if (_extra) pcre_free(reinterpret_cast<struct pcre_extra*>(_extra));
-}
-
-
-int RegularExpression::match(const std::string& subject, std::string::size_type offset, Match& mtch, int options) const
-{
- 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)
- {
- mtch.offset = std::string::npos;
- mtch.length = 0;
- return 0;
- }
- else if (rc == PCRE_ERROR_BADOPTION)
- {
- throw RegularExpressionException("bad option");
- }
- else if (rc == 0)
- {
- throw RegularExpressionException("too many captured substrings");
- }
- else if (rc < 0)
- {
- std::ostringstream msg;
- msg << "PCRE error " << rc;
- throw RegularExpressionException(msg.str());
- }
- mtch.offset = ovec[0] < 0 ? std::string::npos : ovec[0];
- mtch.length = ovec[1] - mtch.offset;
- return rc;
-}
-
-
-int RegularExpression::match(const std::string& subject, std::string::size_type offset, MatchVec& matches, int options) const
-{
- poco_assert (offset <= subject.length());
-
- 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)
- {
- return 0;
- }
- else if (rc == PCRE_ERROR_BADOPTION)
- {
- throw RegularExpressionException("bad option");
- }
- else if (rc == 0)
- {
- throw RegularExpressionException("too many captured substrings");
- }
- else if (rc < 0)
- {
- std::ostringstream msg;
- msg << "PCRE error " << rc;
- throw RegularExpressionException(msg.str());
- }
- matches.reserve(rc);
- for (int i = 0; i < rc; ++i)
- {
- Match m;
- m.offset = ovec[i*2] < 0 ? std::string::npos : ovec[i*2] ;
- m.length = ovec[i*2 + 1] - m.offset;
- matches.push_back(m);
- }
- return rc;
-}
-
-
-bool RegularExpression::match(const std::string& subject, std::string::size_type offset) const
-{
- Match mtch;
- match(subject, offset, mtch, RE_ANCHORED | RE_NOTEMPTY);
- return mtch.offset == offset && mtch.length == subject.length() - offset;
-}
-
-
-bool RegularExpression::match(const std::string& subject, std::string::size_type offset, int options) const
-{
- Match mtch;
- match(subject, offset, mtch, options);
- return mtch.offset == offset && mtch.length == subject.length() - offset;
-}
-
-
-int RegularExpression::extract(const std::string& subject, std::string& str, int options) const
-{
- Match mtch;
- int rc = match(subject, 0, mtch, options);
- if (mtch.offset != std::string::npos)
- str.assign(subject, mtch.offset, mtch.length);
- else
- str.clear();
- return rc;
-}
-
-
-int RegularExpression::extract(const std::string& subject, std::string::size_type offset, std::string& str, int options) const
-{
- Match mtch;
- int rc = match(subject, offset, mtch, options);
- if (mtch.offset != std::string::npos)
- str.assign(subject, mtch.offset, mtch.length);
- else
- str.clear();
- return rc;
-}
-
-
-int RegularExpression::split(const std::string& subject, std::string::size_type offset, std::vector<std::string>& strings, int options) const
-{
- MatchVec matches;
- strings.clear();
- int rc = match(subject, offset, matches, options);
- strings.reserve(matches.size());
- for (MatchVec::const_iterator it = matches.begin(); it != matches.end(); ++it)
- {
- if (it->offset != std::string::npos)
- strings.push_back(subject.substr(it->offset, it->length));
- else
- strings.push_back(std::string());
- }
- return rc;
-}
-
-
-int RegularExpression::subst(std::string& subject, std::string::size_type offset, const std::string& replacement, int options) const
-{
- if (options & RE_GLOBAL)
- {
- int rc = 0;
- std::string::size_type pos = substOne(subject, offset, replacement, options);
- while (pos != std::string::npos)
- {
- ++rc;
- pos = substOne(subject, pos, replacement, options);
- }
- return rc;
- }
- else
- {
- return substOne(subject, offset, replacement, options) != std::string::npos ? 1 : 0;
- }
-}
-
-
-std::string::size_type RegularExpression::substOne(std::string& subject, std::string::size_type offset, const std::string& replacement, int options) const
-{
- 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)
- {
- return std::string::npos;
- }
- else if (rc == PCRE_ERROR_BADOPTION)
- {
- throw RegularExpressionException("bad option");
- }
- else if (rc == 0)
- {
- throw RegularExpressionException("too many captured substrings");
- }
- else if (rc < 0)
- {
- std::ostringstream msg;
- msg << "PCRE error " << rc;
- throw RegularExpressionException(msg.str());
- }
- std::string result;
- std::string::size_type len = subject.length();
- std::string::size_type pos = 0;
- std::string::size_type rp = std::string::npos;
- while (pos < len)
- {
- if (ovec[0] == pos)
- {
- std::string::const_iterator it = replacement.begin();
- std::string::const_iterator end = replacement.end();
- while (it != end)
- {
- if (*it == '$' && !(options & RE_NO_VARS))
- {
- ++it;
- if (it != end)
- {
- char d = *it;
- if (d >= '0' && d <= '9')
- {
- int c = d - '0';
- if (c < rc)
- {
- int o = ovec[c*2];
- int l = ovec[c*2 + 1] - o;
- result.append(subject, o, l);
- }
- }
- else
- {
- result += '$';
- result += d;
- }
- ++it;
- }
- else result += '$';
- }
- else result += *it++;
- }
- pos = ovec[1];
- rp = result.length();
- }
- else result += subject[pos++];
- }
- subject = result;
- return rp;
-}
-
-
-bool RegularExpression::match(const std::string& subject, const std::string& pattern, int options)
-{
- int ctorOptions = options & (RE_CASELESS | RE_MULTILINE | RE_DOTALL | RE_EXTENDED | RE_ANCHORED | RE_DOLLAR_ENDONLY | RE_EXTRA | RE_UNGREEDY | RE_UTF8 | RE_NO_AUTO_CAPTURE);
- int mtchOptions = options & (RE_ANCHORED | RE_NOTBOL | RE_NOTEOL | RE_NOTEMPTY | RE_NO_AUTO_CAPTURE | RE_NO_UTF8_CHECK);
- RegularExpression re(pattern, ctorOptions, false);
- return re.match(subject, 0, mtchOptions);
-}
-
-
-} // namespace Poco
+//
+// RegularExpression.h
+//
+// Library: Foundation
+// Package: RegExp
+// Module: RegularExpression
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/RegularExpression.h"
+#include "Poco/Exception.h"
+#include <sstream>
+#if defined(POCO_UNBUNDLED)
+#include <pcre.h>
+#else
+#include "pcre_config.h"
+#include "pcre.h"
+#endif
+
+
+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)
+{
+ const char* error;
+ int offs;
+ _pcre = pcre_compile(pattern.c_str(), options, &error, &offs, 0);
+ if (!_pcre)
+ {
+ std::ostringstream msg;
+ msg << error << " (at offset " << offs << ")";
+ throw RegularExpressionException(msg.str());
+ }
+ if (study)
+ _extra = pcre_study(reinterpret_cast<pcre*>(_pcre), 0, &error);
+}
+
+
+RegularExpression::~RegularExpression()
+{
+ if (_pcre) pcre_free(reinterpret_cast<pcre*>(_pcre));
+ if (_extra) pcre_free(reinterpret_cast<struct pcre_extra*>(_extra));
+}
+
+
+int RegularExpression::match(const std::string& subject, std::string::size_type offset, Match& mtch, int options) const
+{
+ 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)
+ {
+ mtch.offset = std::string::npos;
+ mtch.length = 0;
+ return 0;
+ }
+ else if (rc == PCRE_ERROR_BADOPTION)
+ {
+ throw RegularExpressionException("bad option");
+ }
+ else if (rc == 0)
+ {
+ throw RegularExpressionException("too many captured substrings");
+ }
+ else if (rc < 0)
+ {
+ std::ostringstream msg;
+ msg << "PCRE error " << rc;
+ throw RegularExpressionException(msg.str());
+ }
+ mtch.offset = ovec[0] < 0 ? std::string::npos : ovec[0];
+ mtch.length = ovec[1] - mtch.offset;
+ return rc;
+}
+
+
+int RegularExpression::match(const std::string& subject, std::string::size_type offset, MatchVec& matches, int options) const
+{
+ poco_assert (offset <= subject.length());
+
+ 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)
+ {
+ return 0;
+ }
+ else if (rc == PCRE_ERROR_BADOPTION)
+ {
+ throw RegularExpressionException("bad option");
+ }
+ else if (rc == 0)
+ {
+ throw RegularExpressionException("too many captured substrings");
+ }
+ else if (rc < 0)
+ {
+ std::ostringstream msg;
+ msg << "PCRE error " << rc;
+ throw RegularExpressionException(msg.str());
+ }
+ matches.reserve(rc);
+ for (int i = 0; i < rc; ++i)
+ {
+ Match m;
+ m.offset = ovec[i*2] < 0 ? std::string::npos : ovec[i*2] ;
+ m.length = ovec[i*2 + 1] - m.offset;
+ matches.push_back(m);
+ }
+ return rc;
+}
+
+
+bool RegularExpression::match(const std::string& subject, std::string::size_type offset) const
+{
+ Match mtch;
+ match(subject, offset, mtch, RE_ANCHORED | RE_NOTEMPTY);
+ return mtch.offset == offset && mtch.length == subject.length() - offset;
+}
+
+
+bool RegularExpression::match(const std::string& subject, std::string::size_type offset, int options) const
+{
+ Match mtch;
+ match(subject, offset, mtch, options);
+ return mtch.offset == offset && mtch.length == subject.length() - offset;
+}
+
+
+int RegularExpression::extract(const std::string& subject, std::string& str, int options) const
+{
+ Match mtch;
+ int rc = match(subject, 0, mtch, options);
+ if (mtch.offset != std::string::npos)
+ str.assign(subject, mtch.offset, mtch.length);
+ else
+ str.clear();
+ return rc;
+}
+
+
+int RegularExpression::extract(const std::string& subject, std::string::size_type offset, std::string& str, int options) const
+{
+ Match mtch;
+ int rc = match(subject, offset, mtch, options);
+ if (mtch.offset != std::string::npos)
+ str.assign(subject, mtch.offset, mtch.length);
+ else
+ str.clear();
+ return rc;
+}
+
+
+int RegularExpression::split(const std::string& subject, std::string::size_type offset, std::vector<std::string>& strings, int options) const
+{
+ MatchVec matches;
+ strings.clear();
+ int rc = match(subject, offset, matches, options);
+ strings.reserve(matches.size());
+ for (MatchVec::const_iterator it = matches.begin(); it != matches.end(); ++it)
+ {
+ if (it->offset != std::string::npos)
+ strings.push_back(subject.substr(it->offset, it->length));
+ else
+ strings.push_back(std::string());
+ }
+ return rc;
+}
+
+
+int RegularExpression::subst(std::string& subject, std::string::size_type offset, const std::string& replacement, int options) const
+{
+ if (options & RE_GLOBAL)
+ {
+ int rc = 0;
+ std::string::size_type pos = substOne(subject, offset, replacement, options);
+ while (pos != std::string::npos)
+ {
+ ++rc;
+ pos = substOne(subject, pos, replacement, options);
+ }
+ return rc;
+ }
+ else
+ {
+ return substOne(subject, offset, replacement, options) != std::string::npos ? 1 : 0;
+ }
+}
+
+
+std::string::size_type RegularExpression::substOne(std::string& subject, std::string::size_type offset, const std::string& replacement, int options) const
+{
+ 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)
+ {
+ return std::string::npos;
+ }
+ else if (rc == PCRE_ERROR_BADOPTION)
+ {
+ throw RegularExpressionException("bad option");
+ }
+ else if (rc == 0)
+ {
+ throw RegularExpressionException("too many captured substrings");
+ }
+ else if (rc < 0)
+ {
+ std::ostringstream msg;
+ msg << "PCRE error " << rc;
+ throw RegularExpressionException(msg.str());
+ }
+ std::string result;
+ std::string::size_type len = subject.length();
+ std::string::size_type pos = 0;
+ std::string::size_type rp = std::string::npos;
+ while (pos < len)
+ {
+ if (ovec[0] == pos)
+ {
+ std::string::const_iterator it = replacement.begin();
+ std::string::const_iterator end = replacement.end();
+ while (it != end)
+ {
+ if (*it == '$' && !(options & RE_NO_VARS))
+ {
+ ++it;
+ if (it != end)
+ {
+ char d = *it;
+ if (d >= '0' && d <= '9')
+ {
+ int c = d - '0';
+ if (c < rc)
+ {
+ int o = ovec[c*2];
+ int l = ovec[c*2 + 1] - o;
+ result.append(subject, o, l);
+ }
+ }
+ else
+ {
+ result += '$';
+ result += d;
+ }
+ ++it;
+ }
+ else result += '$';
+ }
+ else result += *it++;
+ }
+ pos = ovec[1];
+ rp = result.length();
+ }
+ else result += subject[pos++];
+ }
+ subject = result;
+ return rp;
+}
+
+
+bool RegularExpression::match(const std::string& subject, const std::string& pattern, int options)
+{
+ int ctorOptions = options & (RE_CASELESS | RE_MULTILINE | RE_DOTALL | RE_EXTENDED | RE_ANCHORED | RE_DOLLAR_ENDONLY | RE_EXTRA | RE_UNGREEDY | RE_UTF8 | RE_NO_AUTO_CAPTURE);
+ int mtchOptions = options & (RE_ANCHORED | RE_NOTBOL | RE_NOTEOL | RE_NOTEMPTY | RE_NO_AUTO_CAPTURE | RE_NO_UTF8_CHECK);
+ RegularExpression re(pattern, ctorOptions, false);
+ return re.match(subject, 0, mtchOptions);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/RotateStrategy.cpp b/contrib/libs/poco/Foundation/src/RotateStrategy.cpp
index 0019ff9119..1dfed687f0 100644
--- a/contrib/libs/poco/Foundation/src/RotateStrategy.cpp
+++ b/contrib/libs/poco/Foundation/src/RotateStrategy.cpp
@@ -1,113 +1,113 @@
-//
-// RotateStrategy.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: FileChannel
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/RotateStrategy.h"
-#include "Poco/FileStream.h"
-#include "Poco/DateTimeParser.h"
-#include "Poco/DateTimeFormatter.h"
-#include "Poco/DateTimeFormat.h"
-
-
-namespace Poco {
-
-
-//
-// RotateStrategy
-//
-
-
-RotateStrategy::RotateStrategy()
-{
-}
-
-
-RotateStrategy::~RotateStrategy()
-{
-}
-
-
-//
-// RotateByIntervalStrategy
-//
-
-
-const std::string RotateByIntervalStrategy::ROTATE_TEXT("# Log file created/rotated ");
-
-
-RotateByIntervalStrategy::RotateByIntervalStrategy(const Timespan& span):
- _span(span),
- _lastRotate(0)
-{
- if (span.totalMicroseconds() <= 0) throw InvalidArgumentException("time span must be greater than zero");
-}
-
-
-RotateByIntervalStrategy::~RotateByIntervalStrategy()
-{
-}
-
-
-bool RotateByIntervalStrategy::mustRotate(LogFile* pFile)
-{
- if (_lastRotate == 0 || pFile->size() == 0)
- {
- if (pFile->size() != 0)
- {
- Poco::FileInputStream istr(pFile->path());
- std::string tag;
- std::getline(istr, tag);
- if (tag.compare(0, ROTATE_TEXT.size(), ROTATE_TEXT) == 0)
- {
- std::string timestamp(tag, ROTATE_TEXT.size());
- int tzd;
- _lastRotate = DateTimeParser::parse(DateTimeFormat::RFC1036_FORMAT, timestamp, tzd).timestamp();
- }
- else _lastRotate = pFile->creationDate();
- }
- else
- {
- _lastRotate.update();
- std::string tag(ROTATE_TEXT);
- DateTimeFormatter::append(tag, _lastRotate, DateTimeFormat::RFC1036_FORMAT);
- pFile->write(tag);
- }
- }
- Timestamp now;
- return _span <= now - _lastRotate;
-}
-
-
-//
-// RotateBySizeStrategy
-//
-
-
-RotateBySizeStrategy::RotateBySizeStrategy(UInt64 size): _size(size)
-{
- if (size == 0) throw InvalidArgumentException("size must be greater than zero");
-}
-
-
-RotateBySizeStrategy::~RotateBySizeStrategy()
-{
-}
-
-
-bool RotateBySizeStrategy::mustRotate(LogFile* pFile)
-{
- return pFile->size() >= _size;
-}
-
-
-} // namespace Poco
+//
+// RotateStrategy.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: FileChannel
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/RotateStrategy.h"
+#include "Poco/FileStream.h"
+#include "Poco/DateTimeParser.h"
+#include "Poco/DateTimeFormatter.h"
+#include "Poco/DateTimeFormat.h"
+
+
+namespace Poco {
+
+
+//
+// RotateStrategy
+//
+
+
+RotateStrategy::RotateStrategy()
+{
+}
+
+
+RotateStrategy::~RotateStrategy()
+{
+}
+
+
+//
+// RotateByIntervalStrategy
+//
+
+
+const std::string RotateByIntervalStrategy::ROTATE_TEXT("# Log file created/rotated ");
+
+
+RotateByIntervalStrategy::RotateByIntervalStrategy(const Timespan& span):
+ _span(span),
+ _lastRotate(0)
+{
+ if (span.totalMicroseconds() <= 0) throw InvalidArgumentException("time span must be greater than zero");
+}
+
+
+RotateByIntervalStrategy::~RotateByIntervalStrategy()
+{
+}
+
+
+bool RotateByIntervalStrategy::mustRotate(LogFile* pFile)
+{
+ if (_lastRotate == 0 || pFile->size() == 0)
+ {
+ if (pFile->size() != 0)
+ {
+ Poco::FileInputStream istr(pFile->path());
+ std::string tag;
+ std::getline(istr, tag);
+ if (tag.compare(0, ROTATE_TEXT.size(), ROTATE_TEXT) == 0)
+ {
+ std::string timestamp(tag, ROTATE_TEXT.size());
+ int tzd;
+ _lastRotate = DateTimeParser::parse(DateTimeFormat::RFC1036_FORMAT, timestamp, tzd).timestamp();
+ }
+ else _lastRotate = pFile->creationDate();
+ }
+ else
+ {
+ _lastRotate.update();
+ std::string tag(ROTATE_TEXT);
+ DateTimeFormatter::append(tag, _lastRotate, DateTimeFormat::RFC1036_FORMAT);
+ pFile->write(tag);
+ }
+ }
+ Timestamp now;
+ return _span <= now - _lastRotate;
+}
+
+
+//
+// RotateBySizeStrategy
+//
+
+
+RotateBySizeStrategy::RotateBySizeStrategy(UInt64 size): _size(size)
+{
+ if (size == 0) throw InvalidArgumentException("size must be greater than zero");
+}
+
+
+RotateBySizeStrategy::~RotateBySizeStrategy()
+{
+}
+
+
+bool RotateBySizeStrategy::mustRotate(LogFile* pFile)
+{
+ return pFile->size() >= _size;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Runnable.cpp b/contrib/libs/poco/Foundation/src/Runnable.cpp
index 5bc17ffcf8..9fa1a6f2b8 100644
--- a/contrib/libs/poco/Foundation/src/Runnable.cpp
+++ b/contrib/libs/poco/Foundation/src/Runnable.cpp
@@ -1,32 +1,32 @@
-//
-// Runnable.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: Thread
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Runnable.h"
-#include "Poco/Thread.h"
-
-
-namespace Poco {
-
-
-Runnable::Runnable()
-{
-}
-
-
-Runnable::~Runnable()
-{
-}
-
-
-} // namespace Poco
+//
+// Runnable.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: Thread
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Runnable.h"
+#include "Poco/Thread.h"
+
+
+namespace Poco {
+
+
+Runnable::Runnable()
+{
+}
+
+
+Runnable::~Runnable()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/SHA1Engine.cpp b/contrib/libs/poco/Foundation/src/SHA1Engine.cpp
index fb945a6f57..29a8015229 100644
--- a/contrib/libs/poco/Foundation/src/SHA1Engine.cpp
+++ b/contrib/libs/poco/Foundation/src/SHA1Engine.cpp
@@ -1,283 +1,283 @@
-//
-// SHA1Engine.cpp
-//
-// Library: Foundation
-// Package: Crypt
-// Module: SHA1Engine
-//
-// Based on the public domain implementation by Peter C. Gutmann
-// on 2 Sep 1992, modified by Carl Ellison to be SHA-1.
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/SHA1Engine.h"
-#include <cstring>
-
-
-#ifdef POCO_ARCH_LITTLE_ENDIAN
- #define SHA1_BYTE_REVERSE(x, y) byteReverse(x, y)
-#else
- #define SHA1_BYTE_REVERSE(x, y)
-#endif
-
-
-namespace Poco {
-
-
-SHA1Engine::SHA1Engine()
-{
- _digest.reserve(16);
- reset();
-}
-
-
-SHA1Engine::~SHA1Engine()
-{
- reset();
-}
-
-
-inline void SHA1Engine::byteReverse(UInt32* buffer, int byteCount)
-{
-#ifdef POCO_ARCH_LITTLE_ENDIAN
- byteCount /= sizeof(UInt32);
- for(int count = 0; count < byteCount; count++)
- {
- UInt32 value = (buffer[ count ] << 16) | (buffer[ count ] >> 16);
- buffer[count] = ((value & 0xFF00FF00L) >> 8) | ((value & 0x00FF00FFL) << 8);
- }
-#endif // POCO_ARCH_LITTLE_ENDIAN
-}
-
-
-void SHA1Engine::updateImpl(const void* buffer_, std::size_t count)
-{
- const BYTE* buffer = (const BYTE*) buffer_;
- BYTE* db = (BYTE*) &_context.data[0];
-
- /* Update bitcount */
- if ((_context.countLo + ((UInt32) count << 3)) < _context.countLo)
- _context.countHi++; /* Carry from low to high bitCount */
- _context.countLo += ((UInt32) count << 3);
- _context.countHi += ((UInt32 ) count >> 29);
-
- /* Process data in BLOCK_SIZE chunks */
- while (count-- > 0)
- {
- db[_context.slop++] = *(buffer++);
- if (_context.slop == BLOCK_SIZE)
- {
- /* transform this one block */
- SHA1_BYTE_REVERSE(_context.data, BLOCK_SIZE);
- transform();
- _context.slop = 0 ; /* no slop left */
- }
- }
-}
-
-
-std::size_t SHA1Engine::digestLength() const
-{
- return DIGEST_SIZE;
-}
-
-
-void SHA1Engine::reset()
-{
- _context.digest[0] = 0x67452301L;
- _context.digest[1] = 0xEFCDAB89L;
- _context.digest[2] = 0x98BADCFEL;
- _context.digest[3] = 0x10325476L;
- _context.digest[4] = 0xC3D2E1F0L;
- _context.countLo = 0;
- _context.countHi = 0;
- _context.slop = 0;
- std::memset(_context.data, 0, sizeof(_context.data));
-}
-
-
-const DigestEngine::Digest& SHA1Engine::digest()
-{
- int count;
- UInt32 lowBitcount = _context.countLo;
- UInt32 highBitcount = _context.countHi;
-
- /* Compute number of bytes mod 64 */
- count = (int) ((_context.countLo >> 3) & 0x3F);
-
- /* Set the first char of padding to 0x80. This is safe since there is
- always at least one byte free */
- ((BYTE*) _context.data)[count++] = 0x80;
-
- /* Pad out to 56 mod 64 */
- if (count > 56)
- {
- /* Two lots of padding: Pad the first block to 64 bytes */
- std::memset((BYTE*) &_context.data + count, 0, 64 - count);
- SHA1_BYTE_REVERSE(_context.data, BLOCK_SIZE);
- transform();
-
- /* Now fill the next block with 56 bytes */
- std::memset(&_context.data, 0, 56);
- }
- else
- {
- /* Pad block to 56 bytes */
- std::memset((BYTE*) &_context.data + count, 0, 56 - count);
- }
- SHA1_BYTE_REVERSE(_context.data, BLOCK_SIZE);
-
- /* Append length in bits and transform */
- _context.data[14] = highBitcount;
- _context.data[15] = lowBitcount;
-
- transform();
- SHA1_BYTE_REVERSE(_context.data, DIGEST_SIZE);
-
- unsigned char hash[DIGEST_SIZE];
- for (count = 0; count < DIGEST_SIZE; count++)
- hash[count] = (BYTE) ((_context.digest[count>>2]) >> (8*(3-(count & 0x3)))) & 0xff;
- _digest.clear();
- _digest.insert(_digest.begin(), hash, hash + DIGEST_SIZE);
- reset();
- return _digest;
-}
-
-
-/* The SHA f()-functions */
-#define f1(x,y,z) ( ( x & y ) | ( ~x & z ) ) /* Rounds 0-19 */
-#define f2(x,y,z) ( x ^ y ^ z ) /* Rounds 20-39 */
-#define f3(x,y,z) ( ( x & y ) | ( x & z ) | ( y & z ) ) /* Rounds 40-59 */
-#define f4(x,y,z) ( x ^ y ^ z ) /* Rounds 60-79 */
-
-
-/* The SHA Mysterious Constants */
-#define K1 0x5A827999L /* Rounds 0-19 */
-#define K2 0x6ED9EBA1L /* Rounds 20-39 */
-#define K3 0x8F1BBCDCL /* Rounds 40-59 */
-#define K4 0xCA62C1D6L /* Rounds 60-79 */
-
-
-/* 32-bit rotate - kludged with shifts */
-typedef UInt32 UL; /* to save space */
-
-
-#define S(n,X) ( ( ((UL)X) << n ) | ( ((UL)X) >> ( 32 - n ) ) )
-
-
-/* The initial expanding function */
-#define expand(count) W[ count ] = S(1,(W[ count - 3 ] ^ W[ count - 8 ] ^ W[ count - 14 ] ^ W[ count - 16 ])) /* to make this SHA-1 */
-
-
-/* The four SHA sub-rounds */
-#define subRound1(count) \
-{ \
- temp = S( 5, A ) + f1( B, C, D ) + E + W[ count ] + K1; \
- E = D; \
- D = C; \
- C = S( 30, B ); \
- B = A; \
- A = temp; \
-}
-
-#define subRound2(count) \
-{ \
- temp = S( 5, A ) + f2( B, C, D ) + E + W[ count ] + K2; \
- E = D; \
- D = C; \
- C = S( 30, B ); \
- B = A; \
- A = temp; \
-}
-
-#define subRound3(count) \
-{ \
- temp = S( 5, A ) + f3( B, C, D ) + E + W[ count ] + K3; \
- E = D; \
- D = C; \
- C = S( 30, B ); \
- B = A; \
- A = temp; \
-}
-
-#define subRound4(count) \
-{ \
- temp = S( 5, A ) + f4( B, C, D ) + E + W[ count ] + K4; \
- E = D; \
- D = C; \
- C = S( 30, B ); \
- B = A; \
- A = temp; \
-}
-
-
-void SHA1Engine::transform()
-{
- UInt32 W[80];
- UInt32 temp;
- UInt32 A, B, C, D, E;
- int i;
-
- /* Step A. Copy the data buffer into the local work buffer */
- for( i = 0; i < 16; i++ )
- W[ i ] = _context.data[ i ];
-
- /* Step B. Expand the 16 words into 64 temporary data words */
- expand( 16 ); expand( 17 ); expand( 18 ); expand( 19 ); expand( 20 );
- expand( 21 ); expand( 22 ); expand( 23 ); expand( 24 ); expand( 25 );
- expand( 26 ); expand( 27 ); expand( 28 ); expand( 29 ); expand( 30 );
- expand( 31 ); expand( 32 ); expand( 33 ); expand( 34 ); expand( 35 );
- expand( 36 ); expand( 37 ); expand( 38 ); expand( 39 ); expand( 40 );
- expand( 41 ); expand( 42 ); expand( 43 ); expand( 44 ); expand( 45 );
- expand( 46 ); expand( 47 ); expand( 48 ); expand( 49 ); expand( 50 );
- expand( 51 ); expand( 52 ); expand( 53 ); expand( 54 ); expand( 55 );
- expand( 56 ); expand( 57 ); expand( 58 ); expand( 59 ); expand( 60 );
- expand( 61 ); expand( 62 ); expand( 63 ); expand( 64 ); expand( 65 );
- expand( 66 ); expand( 67 ); expand( 68 ); expand( 69 ); expand( 70 );
- expand( 71 ); expand( 72 ); expand( 73 ); expand( 74 ); expand( 75 );
- expand( 76 ); expand( 77 ); expand( 78 ); expand( 79 );
-
- /* Step C. Set up first buffer */
- A = _context.digest[ 0 ];
- B = _context.digest[ 1 ];
- C = _context.digest[ 2 ];
- D = _context.digest[ 3 ];
- E = _context.digest[ 4 ];
-
- /* Step D. Serious mangling, divided into four sub-rounds */
- subRound1( 0 ); subRound1( 1 ); subRound1( 2 ); subRound1( 3 );
- subRound1( 4 ); subRound1( 5 ); subRound1( 6 ); subRound1( 7 );
- subRound1( 8 ); subRound1( 9 ); subRound1( 10 ); subRound1( 11 );
- subRound1( 12 ); subRound1( 13 ); subRound1( 14 ); subRound1( 15 );
- subRound1( 16 ); subRound1( 17 ); subRound1( 18 ); subRound1( 19 );
- subRound2( 20 ); subRound2( 21 ); subRound2( 22 ); subRound2( 23 );
- subRound2( 24 ); subRound2( 25 ); subRound2( 26 ); subRound2( 27 );
- subRound2( 28 ); subRound2( 29 ); subRound2( 30 ); subRound2( 31 );
- subRound2( 32 ); subRound2( 33 ); subRound2( 34 ); subRound2( 35 );
- subRound2( 36 ); subRound2( 37 ); subRound2( 38 ); subRound2( 39 );
- subRound3( 40 ); subRound3( 41 ); subRound3( 42 ); subRound3( 43 );
- subRound3( 44 ); subRound3( 45 ); subRound3( 46 ); subRound3( 47 );
- subRound3( 48 ); subRound3( 49 ); subRound3( 50 ); subRound3( 51 );
- subRound3( 52 ); subRound3( 53 ); subRound3( 54 ); subRound3( 55 );
- subRound3( 56 ); subRound3( 57 ); subRound3( 58 ); subRound3( 59 );
- subRound4( 60 ); subRound4( 61 ); subRound4( 62 ); subRound4( 63 );
- subRound4( 64 ); subRound4( 65 ); subRound4( 66 ); subRound4( 67 );
- subRound4( 68 ); subRound4( 69 ); subRound4( 70 ); subRound4( 71 );
- subRound4( 72 ); subRound4( 73 ); subRound4( 74 ); subRound4( 75 );
- subRound4( 76 ); subRound4( 77 ); subRound4( 78 ); subRound4( 79 );
-
- /* Step E. Build message digest */
- _context.digest[ 0 ] += A;
- _context.digest[ 1 ] += B;
- _context.digest[ 2 ] += C;
- _context.digest[ 3 ] += D;
- _context.digest[ 4 ] += E;
-}
-
-
-} // namespace Poco
+//
+// SHA1Engine.cpp
+//
+// Library: Foundation
+// Package: Crypt
+// Module: SHA1Engine
+//
+// Based on the public domain implementation by Peter C. Gutmann
+// on 2 Sep 1992, modified by Carl Ellison to be SHA-1.
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/SHA1Engine.h"
+#include <cstring>
+
+
+#ifdef POCO_ARCH_LITTLE_ENDIAN
+ #define SHA1_BYTE_REVERSE(x, y) byteReverse(x, y)
+#else
+ #define SHA1_BYTE_REVERSE(x, y)
+#endif
+
+
+namespace Poco {
+
+
+SHA1Engine::SHA1Engine()
+{
+ _digest.reserve(16);
+ reset();
+}
+
+
+SHA1Engine::~SHA1Engine()
+{
+ reset();
+}
+
+
+inline void SHA1Engine::byteReverse(UInt32* buffer, int byteCount)
+{
+#ifdef POCO_ARCH_LITTLE_ENDIAN
+ byteCount /= sizeof(UInt32);
+ for(int count = 0; count < byteCount; count++)
+ {
+ UInt32 value = (buffer[ count ] << 16) | (buffer[ count ] >> 16);
+ buffer[count] = ((value & 0xFF00FF00L) >> 8) | ((value & 0x00FF00FFL) << 8);
+ }
+#endif // POCO_ARCH_LITTLE_ENDIAN
+}
+
+
+void SHA1Engine::updateImpl(const void* buffer_, std::size_t count)
+{
+ const BYTE* buffer = (const BYTE*) buffer_;
+ BYTE* db = (BYTE*) &_context.data[0];
+
+ /* Update bitcount */
+ if ((_context.countLo + ((UInt32) count << 3)) < _context.countLo)
+ _context.countHi++; /* Carry from low to high bitCount */
+ _context.countLo += ((UInt32) count << 3);
+ _context.countHi += ((UInt32 ) count >> 29);
+
+ /* Process data in BLOCK_SIZE chunks */
+ while (count-- > 0)
+ {
+ db[_context.slop++] = *(buffer++);
+ if (_context.slop == BLOCK_SIZE)
+ {
+ /* transform this one block */
+ SHA1_BYTE_REVERSE(_context.data, BLOCK_SIZE);
+ transform();
+ _context.slop = 0 ; /* no slop left */
+ }
+ }
+}
+
+
+std::size_t SHA1Engine::digestLength() const
+{
+ return DIGEST_SIZE;
+}
+
+
+void SHA1Engine::reset()
+{
+ _context.digest[0] = 0x67452301L;
+ _context.digest[1] = 0xEFCDAB89L;
+ _context.digest[2] = 0x98BADCFEL;
+ _context.digest[3] = 0x10325476L;
+ _context.digest[4] = 0xC3D2E1F0L;
+ _context.countLo = 0;
+ _context.countHi = 0;
+ _context.slop = 0;
+ std::memset(_context.data, 0, sizeof(_context.data));
+}
+
+
+const DigestEngine::Digest& SHA1Engine::digest()
+{
+ int count;
+ UInt32 lowBitcount = _context.countLo;
+ UInt32 highBitcount = _context.countHi;
+
+ /* Compute number of bytes mod 64 */
+ count = (int) ((_context.countLo >> 3) & 0x3F);
+
+ /* Set the first char of padding to 0x80. This is safe since there is
+ always at least one byte free */
+ ((BYTE*) _context.data)[count++] = 0x80;
+
+ /* Pad out to 56 mod 64 */
+ if (count > 56)
+ {
+ /* Two lots of padding: Pad the first block to 64 bytes */
+ std::memset((BYTE*) &_context.data + count, 0, 64 - count);
+ SHA1_BYTE_REVERSE(_context.data, BLOCK_SIZE);
+ transform();
+
+ /* Now fill the next block with 56 bytes */
+ std::memset(&_context.data, 0, 56);
+ }
+ else
+ {
+ /* Pad block to 56 bytes */
+ std::memset((BYTE*) &_context.data + count, 0, 56 - count);
+ }
+ SHA1_BYTE_REVERSE(_context.data, BLOCK_SIZE);
+
+ /* Append length in bits and transform */
+ _context.data[14] = highBitcount;
+ _context.data[15] = lowBitcount;
+
+ transform();
+ SHA1_BYTE_REVERSE(_context.data, DIGEST_SIZE);
+
+ unsigned char hash[DIGEST_SIZE];
+ for (count = 0; count < DIGEST_SIZE; count++)
+ hash[count] = (BYTE) ((_context.digest[count>>2]) >> (8*(3-(count & 0x3)))) & 0xff;
+ _digest.clear();
+ _digest.insert(_digest.begin(), hash, hash + DIGEST_SIZE);
+ reset();
+ return _digest;
+}
+
+
+/* The SHA f()-functions */
+#define f1(x,y,z) ( ( x & y ) | ( ~x & z ) ) /* Rounds 0-19 */
+#define f2(x,y,z) ( x ^ y ^ z ) /* Rounds 20-39 */
+#define f3(x,y,z) ( ( x & y ) | ( x & z ) | ( y & z ) ) /* Rounds 40-59 */
+#define f4(x,y,z) ( x ^ y ^ z ) /* Rounds 60-79 */
+
+
+/* The SHA Mysterious Constants */
+#define K1 0x5A827999L /* Rounds 0-19 */
+#define K2 0x6ED9EBA1L /* Rounds 20-39 */
+#define K3 0x8F1BBCDCL /* Rounds 40-59 */
+#define K4 0xCA62C1D6L /* Rounds 60-79 */
+
+
+/* 32-bit rotate - kludged with shifts */
+typedef UInt32 UL; /* to save space */
+
+
+#define S(n,X) ( ( ((UL)X) << n ) | ( ((UL)X) >> ( 32 - n ) ) )
+
+
+/* The initial expanding function */
+#define expand(count) W[ count ] = S(1,(W[ count - 3 ] ^ W[ count - 8 ] ^ W[ count - 14 ] ^ W[ count - 16 ])) /* to make this SHA-1 */
+
+
+/* The four SHA sub-rounds */
+#define subRound1(count) \
+{ \
+ temp = S( 5, A ) + f1( B, C, D ) + E + W[ count ] + K1; \
+ E = D; \
+ D = C; \
+ C = S( 30, B ); \
+ B = A; \
+ A = temp; \
+}
+
+#define subRound2(count) \
+{ \
+ temp = S( 5, A ) + f2( B, C, D ) + E + W[ count ] + K2; \
+ E = D; \
+ D = C; \
+ C = S( 30, B ); \
+ B = A; \
+ A = temp; \
+}
+
+#define subRound3(count) \
+{ \
+ temp = S( 5, A ) + f3( B, C, D ) + E + W[ count ] + K3; \
+ E = D; \
+ D = C; \
+ C = S( 30, B ); \
+ B = A; \
+ A = temp; \
+}
+
+#define subRound4(count) \
+{ \
+ temp = S( 5, A ) + f4( B, C, D ) + E + W[ count ] + K4; \
+ E = D; \
+ D = C; \
+ C = S( 30, B ); \
+ B = A; \
+ A = temp; \
+}
+
+
+void SHA1Engine::transform()
+{
+ UInt32 W[80];
+ UInt32 temp;
+ UInt32 A, B, C, D, E;
+ int i;
+
+ /* Step A. Copy the data buffer into the local work buffer */
+ for( i = 0; i < 16; i++ )
+ W[ i ] = _context.data[ i ];
+
+ /* Step B. Expand the 16 words into 64 temporary data words */
+ expand( 16 ); expand( 17 ); expand( 18 ); expand( 19 ); expand( 20 );
+ expand( 21 ); expand( 22 ); expand( 23 ); expand( 24 ); expand( 25 );
+ expand( 26 ); expand( 27 ); expand( 28 ); expand( 29 ); expand( 30 );
+ expand( 31 ); expand( 32 ); expand( 33 ); expand( 34 ); expand( 35 );
+ expand( 36 ); expand( 37 ); expand( 38 ); expand( 39 ); expand( 40 );
+ expand( 41 ); expand( 42 ); expand( 43 ); expand( 44 ); expand( 45 );
+ expand( 46 ); expand( 47 ); expand( 48 ); expand( 49 ); expand( 50 );
+ expand( 51 ); expand( 52 ); expand( 53 ); expand( 54 ); expand( 55 );
+ expand( 56 ); expand( 57 ); expand( 58 ); expand( 59 ); expand( 60 );
+ expand( 61 ); expand( 62 ); expand( 63 ); expand( 64 ); expand( 65 );
+ expand( 66 ); expand( 67 ); expand( 68 ); expand( 69 ); expand( 70 );
+ expand( 71 ); expand( 72 ); expand( 73 ); expand( 74 ); expand( 75 );
+ expand( 76 ); expand( 77 ); expand( 78 ); expand( 79 );
+
+ /* Step C. Set up first buffer */
+ A = _context.digest[ 0 ];
+ B = _context.digest[ 1 ];
+ C = _context.digest[ 2 ];
+ D = _context.digest[ 3 ];
+ E = _context.digest[ 4 ];
+
+ /* Step D. Serious mangling, divided into four sub-rounds */
+ subRound1( 0 ); subRound1( 1 ); subRound1( 2 ); subRound1( 3 );
+ subRound1( 4 ); subRound1( 5 ); subRound1( 6 ); subRound1( 7 );
+ subRound1( 8 ); subRound1( 9 ); subRound1( 10 ); subRound1( 11 );
+ subRound1( 12 ); subRound1( 13 ); subRound1( 14 ); subRound1( 15 );
+ subRound1( 16 ); subRound1( 17 ); subRound1( 18 ); subRound1( 19 );
+ subRound2( 20 ); subRound2( 21 ); subRound2( 22 ); subRound2( 23 );
+ subRound2( 24 ); subRound2( 25 ); subRound2( 26 ); subRound2( 27 );
+ subRound2( 28 ); subRound2( 29 ); subRound2( 30 ); subRound2( 31 );
+ subRound2( 32 ); subRound2( 33 ); subRound2( 34 ); subRound2( 35 );
+ subRound2( 36 ); subRound2( 37 ); subRound2( 38 ); subRound2( 39 );
+ subRound3( 40 ); subRound3( 41 ); subRound3( 42 ); subRound3( 43 );
+ subRound3( 44 ); subRound3( 45 ); subRound3( 46 ); subRound3( 47 );
+ subRound3( 48 ); subRound3( 49 ); subRound3( 50 ); subRound3( 51 );
+ subRound3( 52 ); subRound3( 53 ); subRound3( 54 ); subRound3( 55 );
+ subRound3( 56 ); subRound3( 57 ); subRound3( 58 ); subRound3( 59 );
+ subRound4( 60 ); subRound4( 61 ); subRound4( 62 ); subRound4( 63 );
+ subRound4( 64 ); subRound4( 65 ); subRound4( 66 ); subRound4( 67 );
+ subRound4( 68 ); subRound4( 69 ); subRound4( 70 ); subRound4( 71 );
+ subRound4( 72 ); subRound4( 73 ); subRound4( 74 ); subRound4( 75 );
+ subRound4( 76 ); subRound4( 77 ); subRound4( 78 ); subRound4( 79 );
+
+ /* Step E. Build message digest */
+ _context.digest[ 0 ] += A;
+ _context.digest[ 1 ] += B;
+ _context.digest[ 2 ] += C;
+ _context.digest[ 3 ] += D;
+ _context.digest[ 4 ] += E;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Semaphore.cpp b/contrib/libs/poco/Foundation/src/Semaphore.cpp
index 3403125bdc..5896d2aae6 100644
--- a/contrib/libs/poco/Foundation/src/Semaphore.cpp
+++ b/contrib/libs/poco/Foundation/src/Semaphore.cpp
@@ -1,45 +1,45 @@
-//
-// Semaphore.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: Semaphore
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Semaphore.h"
-
-
-#if defined(POCO_OS_FAMILY_WINDOWS)
-#include "Semaphore_WIN32.cpp"
-#elif defined(POCO_VXWORKS)
-#include "Semaphore_VX.cpp"
-#else
-#include "Semaphore_POSIX.cpp"
-#endif
-
-
-namespace Poco {
-
-
-Semaphore::Semaphore(int n): SemaphoreImpl(n, n)
-{
-}
-
-
-Semaphore::Semaphore(int n, int max): SemaphoreImpl(n, max)
-{
-}
-
-
-Semaphore::~Semaphore()
-{
-}
-
-
-} // namespace Poco
+//
+// Semaphore.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: Semaphore
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Semaphore.h"
+
+
+#if defined(POCO_OS_FAMILY_WINDOWS)
+#include "Semaphore_WIN32.cpp"
+#elif defined(POCO_VXWORKS)
+#include "Semaphore_VX.cpp"
+#else
+#include "Semaphore_POSIX.cpp"
+#endif
+
+
+namespace Poco {
+
+
+Semaphore::Semaphore(int n): SemaphoreImpl(n, n)
+{
+}
+
+
+Semaphore::Semaphore(int n, int max): SemaphoreImpl(n, max)
+{
+}
+
+
+Semaphore::~Semaphore()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Semaphore_POSIX.cpp b/contrib/libs/poco/Foundation/src/Semaphore_POSIX.cpp
index f4818af200..6a79a0c0d3 100644
--- a/contrib/libs/poco/Foundation/src/Semaphore_POSIX.cpp
+++ b/contrib/libs/poco/Foundation/src/Semaphore_POSIX.cpp
@@ -1,170 +1,170 @@
-//
-// Semaphore_POSIX.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: Semaphore
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Semaphore_POSIX.h"
-#if defined(POCO_VXWORKS)
-#include <timers.h>
-#include <cstring>
-#else
-#include <time.h>
-#include <sys/time.h>
-#endif
-
-
-//
-// Note: pthread_cond_timedwait() with CLOCK_MONOTONIC is supported
-// on Linux and QNX, as well as on Android >= 5.0 (API level 21).
-// On Android < 5.0, HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC is defined
-// to indicate availability of non-standard pthread_cond_timedwait_monotonic().
-//
-#ifndef POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT
- #if (defined(__linux__) || defined(__QNX__)) && !(defined(__ANDROID__) && (defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC) || __ANDROID_API__ <= 21))
- #define POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT 1
- #endif
-#endif
-
-
-#ifndef POCO_HAVE_CLOCK_GETTIME
- #if (defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME)) || defined(POCO_VXWORKS) || defined(__QNX__)
- #ifndef __APPLE__ // See GitHub issue #1453 - not available before Mac OS 10.12/iOS 10
- #define POCO_HAVE_CLOCK_GETTIME
- #endif
- #endif
-#endif
-
-
-namespace Poco {
-
-
-SemaphoreImpl::SemaphoreImpl(int n, int max): _n(n), _max(max)
-{
- poco_assert (n >= 0 && max > 0 && n <= max);
-
-#if defined(POCO_VXWORKS)
- // This workaround is for VxWorks 5.x where
- // pthread_mutex_init() won't properly initialize the mutex
- // resulting in a subsequent freeze in pthread_mutex_destroy()
- // if the mutex has never been used.
- std::memset(&_mutex, 0, sizeof(_mutex));
-#endif
- if (pthread_mutex_init(&_mutex, NULL))
- throw SystemException("cannot create semaphore (mutex)");
-
-#if defined(POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT)
- pthread_condattr_t attr;
- if (pthread_condattr_init(&attr))
- {
- pthread_mutex_destroy(&_mutex);
- throw SystemException("cannot create semaphore (condition attribute)");
- }
- if (pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
- {
- pthread_condattr_destroy(&attr);
- pthread_mutex_destroy(&_mutex);
- throw SystemException("cannot create semaphore (condition attribute clock)");
- }
- if (pthread_cond_init(&_cond, &attr))
- {
- pthread_condattr_destroy(&attr);
- pthread_mutex_destroy(&_mutex);
- throw SystemException("cannot create semaphore (condition)");
- }
- pthread_condattr_destroy(&attr);
-#else
- if (pthread_cond_init(&_cond, NULL))
- {
- pthread_mutex_destroy(&_mutex);
- throw SystemException("cannot create semaphore (condition)");
- }
-#endif
-}
-
-
-SemaphoreImpl::~SemaphoreImpl()
-{
- pthread_cond_destroy(&_cond);
- pthread_mutex_destroy(&_mutex);
-}
-
-
-void SemaphoreImpl::waitImpl()
-{
- if (pthread_mutex_lock(&_mutex))
- throw SystemException("wait for semaphore failed (lock)");
- while (_n < 1)
- {
- if (pthread_cond_wait(&_cond, &_mutex))
- {
- pthread_mutex_unlock(&_mutex);
- throw SystemException("wait for semaphore failed");
- }
- }
- --_n;
- pthread_mutex_unlock(&_mutex);
-}
-
-
-bool SemaphoreImpl::waitImpl(long milliseconds)
-{
- int rc = 0;
- struct timespec abstime;
-
-#if defined(POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT)
- clock_gettime(CLOCK_MONOTONIC, &abstime);
- abstime.tv_sec += milliseconds / 1000;
- abstime.tv_nsec += (milliseconds % 1000)*1000000;
- if (abstime.tv_nsec >= 1000000000)
- {
- abstime.tv_nsec -= 1000000000;
- abstime.tv_sec++;
- }
-#elif defined(POCO_HAVE_CLOCK_GETTIME)
- clock_gettime(CLOCK_REALTIME, &abstime);
- abstime.tv_sec += milliseconds / 1000;
- abstime.tv_nsec += (milliseconds % 1000)*1000000;
- if (abstime.tv_nsec >= 1000000000)
- {
- abstime.tv_nsec -= 1000000000;
- abstime.tv_sec++;
- }
-#else
- struct timeval tv;
- gettimeofday(&tv, NULL);
- abstime.tv_sec = tv.tv_sec + milliseconds / 1000;
- abstime.tv_nsec = tv.tv_usec*1000 + (milliseconds % 1000)*1000000;
- if (abstime.tv_nsec >= 1000000000)
- {
- abstime.tv_nsec -= 1000000000;
- abstime.tv_sec++;
- }
-#endif
-
- if (pthread_mutex_lock(&_mutex) != 0)
- throw SystemException("wait for semaphore failed (lock)");
- while (_n < 1)
- {
- if ((rc = pthread_cond_timedwait(&_cond, &_mutex, &abstime)))
- {
- if (rc == ETIMEDOUT) break;
- pthread_mutex_unlock(&_mutex);
- throw SystemException("cannot wait for semaphore");
- }
- }
- if (rc == 0) --_n;
- pthread_mutex_unlock(&_mutex);
- return rc == 0;
-}
-
-
-} // namespace Poco
+//
+// Semaphore_POSIX.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: Semaphore
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Semaphore_POSIX.h"
+#if defined(POCO_VXWORKS)
+#include <timers.h>
+#include <cstring>
+#else
+#include <time.h>
+#include <sys/time.h>
+#endif
+
+
+//
+// Note: pthread_cond_timedwait() with CLOCK_MONOTONIC is supported
+// on Linux and QNX, as well as on Android >= 5.0 (API level 21).
+// On Android < 5.0, HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC is defined
+// to indicate availability of non-standard pthread_cond_timedwait_monotonic().
+//
+#ifndef POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT
+ #if (defined(__linux__) || defined(__QNX__)) && !(defined(__ANDROID__) && (defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC) || __ANDROID_API__ <= 21))
+ #define POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT 1
+ #endif
+#endif
+
+
+#ifndef POCO_HAVE_CLOCK_GETTIME
+ #if (defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME)) || defined(POCO_VXWORKS) || defined(__QNX__)
+ #ifndef __APPLE__ // See GitHub issue #1453 - not available before Mac OS 10.12/iOS 10
+ #define POCO_HAVE_CLOCK_GETTIME
+ #endif
+ #endif
+#endif
+
+
+namespace Poco {
+
+
+SemaphoreImpl::SemaphoreImpl(int n, int max): _n(n), _max(max)
+{
+ poco_assert (n >= 0 && max > 0 && n <= max);
+
+#if defined(POCO_VXWORKS)
+ // This workaround is for VxWorks 5.x where
+ // pthread_mutex_init() won't properly initialize the mutex
+ // resulting in a subsequent freeze in pthread_mutex_destroy()
+ // if the mutex has never been used.
+ std::memset(&_mutex, 0, sizeof(_mutex));
+#endif
+ if (pthread_mutex_init(&_mutex, NULL))
+ throw SystemException("cannot create semaphore (mutex)");
+
+#if defined(POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT)
+ pthread_condattr_t attr;
+ if (pthread_condattr_init(&attr))
+ {
+ pthread_mutex_destroy(&_mutex);
+ throw SystemException("cannot create semaphore (condition attribute)");
+ }
+ if (pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
+ {
+ pthread_condattr_destroy(&attr);
+ pthread_mutex_destroy(&_mutex);
+ throw SystemException("cannot create semaphore (condition attribute clock)");
+ }
+ if (pthread_cond_init(&_cond, &attr))
+ {
+ pthread_condattr_destroy(&attr);
+ pthread_mutex_destroy(&_mutex);
+ throw SystemException("cannot create semaphore (condition)");
+ }
+ pthread_condattr_destroy(&attr);
+#else
+ if (pthread_cond_init(&_cond, NULL))
+ {
+ pthread_mutex_destroy(&_mutex);
+ throw SystemException("cannot create semaphore (condition)");
+ }
+#endif
+}
+
+
+SemaphoreImpl::~SemaphoreImpl()
+{
+ pthread_cond_destroy(&_cond);
+ pthread_mutex_destroy(&_mutex);
+}
+
+
+void SemaphoreImpl::waitImpl()
+{
+ if (pthread_mutex_lock(&_mutex))
+ throw SystemException("wait for semaphore failed (lock)");
+ while (_n < 1)
+ {
+ if (pthread_cond_wait(&_cond, &_mutex))
+ {
+ pthread_mutex_unlock(&_mutex);
+ throw SystemException("wait for semaphore failed");
+ }
+ }
+ --_n;
+ pthread_mutex_unlock(&_mutex);
+}
+
+
+bool SemaphoreImpl::waitImpl(long milliseconds)
+{
+ int rc = 0;
+ struct timespec abstime;
+
+#if defined(POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT)
+ clock_gettime(CLOCK_MONOTONIC, &abstime);
+ abstime.tv_sec += milliseconds / 1000;
+ abstime.tv_nsec += (milliseconds % 1000)*1000000;
+ if (abstime.tv_nsec >= 1000000000)
+ {
+ abstime.tv_nsec -= 1000000000;
+ abstime.tv_sec++;
+ }
+#elif defined(POCO_HAVE_CLOCK_GETTIME)
+ clock_gettime(CLOCK_REALTIME, &abstime);
+ abstime.tv_sec += milliseconds / 1000;
+ abstime.tv_nsec += (milliseconds % 1000)*1000000;
+ if (abstime.tv_nsec >= 1000000000)
+ {
+ abstime.tv_nsec -= 1000000000;
+ abstime.tv_sec++;
+ }
+#else
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ abstime.tv_sec = tv.tv_sec + milliseconds / 1000;
+ abstime.tv_nsec = tv.tv_usec*1000 + (milliseconds % 1000)*1000000;
+ if (abstime.tv_nsec >= 1000000000)
+ {
+ abstime.tv_nsec -= 1000000000;
+ abstime.tv_sec++;
+ }
+#endif
+
+ if (pthread_mutex_lock(&_mutex) != 0)
+ throw SystemException("wait for semaphore failed (lock)");
+ while (_n < 1)
+ {
+ if ((rc = pthread_cond_timedwait(&_cond, &_mutex, &abstime)))
+ {
+ if (rc == ETIMEDOUT) break;
+ pthread_mutex_unlock(&_mutex);
+ throw SystemException("cannot wait for semaphore");
+ }
+ }
+ if (rc == 0) --_n;
+ pthread_mutex_unlock(&_mutex);
+ return rc == 0;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Semaphore_VX.cpp b/contrib/libs/poco/Foundation/src/Semaphore_VX.cpp
index 5bc63b530c..498fa04c45 100644
--- a/contrib/libs/poco/Foundation/src/Semaphore_VX.cpp
+++ b/contrib/libs/poco/Foundation/src/Semaphore_VX.cpp
@@ -1,52 +1,52 @@
-//
-// Semaphore_VX.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: Semaphore
-//
-// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Semaphore_VX.h"
-#include <sysLib.h>
-
-
-namespace Poco {
-
-
-SemaphoreImpl::SemaphoreImpl(int n, int max)
-{
- poco_assert (n >= 0 && max > 0 && n <= max);
-
- _sem = semCCreate(SEM_Q_PRIORITY, n);
- if (_sem == 0)
- throw Poco::SystemException("cannot create semaphore");
-}
-
-
-SemaphoreImpl::~SemaphoreImpl()
-{
- semDelete(_sem);
-}
-
-
-void SemaphoreImpl::waitImpl()
-{
- if (semTake(_sem, WAIT_FOREVER) != OK)
- throw SystemException("cannot wait for semaphore");
-}
-
-
-bool SemaphoreImpl::waitImpl(long milliseconds)
-{
- int ticks = milliseconds*sysClkRateGet()/1000;
- return semTake(_sem, ticks) == OK;
-}
-
-
-} // namespace Poco
+//
+// Semaphore_VX.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: Semaphore
+//
+// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Semaphore_VX.h"
+#include <sysLib.h>
+
+
+namespace Poco {
+
+
+SemaphoreImpl::SemaphoreImpl(int n, int max)
+{
+ poco_assert (n >= 0 && max > 0 && n <= max);
+
+ _sem = semCCreate(SEM_Q_PRIORITY, n);
+ if (_sem == 0)
+ throw Poco::SystemException("cannot create semaphore");
+}
+
+
+SemaphoreImpl::~SemaphoreImpl()
+{
+ semDelete(_sem);
+}
+
+
+void SemaphoreImpl::waitImpl()
+{
+ if (semTake(_sem, WAIT_FOREVER) != OK)
+ throw SystemException("cannot wait for semaphore");
+}
+
+
+bool SemaphoreImpl::waitImpl(long milliseconds)
+{
+ int ticks = milliseconds*sysClkRateGet()/1000;
+ return semTake(_sem, ticks) == OK;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Semaphore_WIN32.cpp b/contrib/libs/poco/Foundation/src/Semaphore_WIN32.cpp
index 2ec04a8c02..c53bc3a86f 100644
--- a/contrib/libs/poco/Foundation/src/Semaphore_WIN32.cpp
+++ b/contrib/libs/poco/Foundation/src/Semaphore_WIN32.cpp
@@ -1,65 +1,65 @@
-//
-// Semaphore_WIN32.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: Semaphore
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Semaphore_WIN32.h"
-
-
-namespace Poco {
-
-
-SemaphoreImpl::SemaphoreImpl(int n, int max)
-{
- poco_assert (n >= 0 && max > 0 && n <= max);
-
- _sema = CreateSemaphoreW(NULL, n, max, NULL);
- if (!_sema)
- {
- throw SystemException("cannot create semaphore");
- }
-}
-
-
-SemaphoreImpl::~SemaphoreImpl()
-{
- CloseHandle(_sema);
-}
-
-
-void SemaphoreImpl::waitImpl()
-{
- switch (WaitForSingleObject(_sema, INFINITE))
- {
- case WAIT_OBJECT_0:
- return;
- default:
- throw SystemException("wait for semaphore failed");
- }
-}
-
-
-bool SemaphoreImpl::waitImpl(long milliseconds)
-{
- switch (WaitForSingleObject(_sema, milliseconds + 1))
- {
- case WAIT_TIMEOUT:
- return false;
- case WAIT_OBJECT_0:
- return true;
- default:
- throw SystemException("wait for semaphore failed");
- }
-}
-
-
-} // namespace Poco
+//
+// Semaphore_WIN32.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: Semaphore
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Semaphore_WIN32.h"
+
+
+namespace Poco {
+
+
+SemaphoreImpl::SemaphoreImpl(int n, int max)
+{
+ poco_assert (n >= 0 && max > 0 && n <= max);
+
+ _sema = CreateSemaphoreW(NULL, n, max, NULL);
+ if (!_sema)
+ {
+ throw SystemException("cannot create semaphore");
+ }
+}
+
+
+SemaphoreImpl::~SemaphoreImpl()
+{
+ CloseHandle(_sema);
+}
+
+
+void SemaphoreImpl::waitImpl()
+{
+ switch (WaitForSingleObject(_sema, INFINITE))
+ {
+ case WAIT_OBJECT_0:
+ return;
+ default:
+ throw SystemException("wait for semaphore failed");
+ }
+}
+
+
+bool SemaphoreImpl::waitImpl(long milliseconds)
+{
+ switch (WaitForSingleObject(_sema, milliseconds + 1))
+ {
+ case WAIT_TIMEOUT:
+ return false;
+ case WAIT_OBJECT_0:
+ return true;
+ default:
+ throw SystemException("wait for semaphore failed");
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/SharedLibrary.cpp b/contrib/libs/poco/Foundation/src/SharedLibrary.cpp
index 542f9e8102..6c0f021d96 100644
--- a/contrib/libs/poco/Foundation/src/SharedLibrary.cpp
+++ b/contrib/libs/poco/Foundation/src/SharedLibrary.cpp
@@ -1,115 +1,115 @@
-//
-// SharedLibrary.cpp
-//
-// Library: Foundation
-// Package: SharedLibrary
-// Module: SharedLibrary
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/SharedLibrary.h"
-#include "Poco/Exception.h"
-
-
-#if defined(hpux) || defined(_hpux)
-#include "SharedLibrary_HPUX.cpp"
-#elif defined(POCO_VXWORKS)
-#include "SharedLibrary_VX.cpp"
-#elif defined(POCO_OS_FAMILY_UNIX)
-#include "SharedLibrary_UNIX.cpp"
-#elif defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
-#include "SharedLibrary_WIN32U.cpp"
-#elif defined(POCO_OS_FAMILY_WINDOWS)
-#include "SharedLibrary_WIN32.cpp"
-#endif
-
-
-namespace Poco {
-
-
-SharedLibrary::SharedLibrary()
-{
-}
-
-
-SharedLibrary::SharedLibrary(const std::string& path)
-{
- loadImpl(path, 0);
-}
-
-
-SharedLibrary::SharedLibrary(const std::string& path, int flags)
-{
- loadImpl(path, flags);
-}
-
-
-SharedLibrary::~SharedLibrary()
-{
-}
-
-
-void SharedLibrary::load(const std::string& path)
-{
- loadImpl(path, 0);
-}
-
-
-void SharedLibrary::load(const std::string& path, int flags)
-{
- loadImpl(path, flags);
-}
-
-
-void SharedLibrary::unload()
-{
- unloadImpl();
-}
-
-
-bool SharedLibrary::isLoaded() const
-{
- return isLoadedImpl();
-}
-
-
-bool SharedLibrary::hasSymbol(const std::string& name)
-{
- return findSymbolImpl(name) != 0;
-}
-
-
-void* SharedLibrary::getSymbol(const std::string& name)
-{
- void* result = findSymbolImpl(name);
- if (result)
- return result;
- else
- throw NotFoundException(name);
-}
-
-
-const std::string& SharedLibrary::getPath() const
-{
- return getPathImpl();
-}
-
-
-std::string SharedLibrary::suffix()
-{
- return suffixImpl();
-}
-
-
-bool SharedLibrary::setSearchPath(const std::string& path)
-{
- return setSearchPathImpl(path);
-}
-
-
-} // namespace Poco
+//
+// SharedLibrary.cpp
+//
+// Library: Foundation
+// Package: SharedLibrary
+// Module: SharedLibrary
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/SharedLibrary.h"
+#include "Poco/Exception.h"
+
+
+#if defined(hpux) || defined(_hpux)
+#include "SharedLibrary_HPUX.cpp"
+#elif defined(POCO_VXWORKS)
+#include "SharedLibrary_VX.cpp"
+#elif defined(POCO_OS_FAMILY_UNIX)
+#include "SharedLibrary_UNIX.cpp"
+#elif defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
+#include "SharedLibrary_WIN32U.cpp"
+#elif defined(POCO_OS_FAMILY_WINDOWS)
+#include "SharedLibrary_WIN32.cpp"
+#endif
+
+
+namespace Poco {
+
+
+SharedLibrary::SharedLibrary()
+{
+}
+
+
+SharedLibrary::SharedLibrary(const std::string& path)
+{
+ loadImpl(path, 0);
+}
+
+
+SharedLibrary::SharedLibrary(const std::string& path, int flags)
+{
+ loadImpl(path, flags);
+}
+
+
+SharedLibrary::~SharedLibrary()
+{
+}
+
+
+void SharedLibrary::load(const std::string& path)
+{
+ loadImpl(path, 0);
+}
+
+
+void SharedLibrary::load(const std::string& path, int flags)
+{
+ loadImpl(path, flags);
+}
+
+
+void SharedLibrary::unload()
+{
+ unloadImpl();
+}
+
+
+bool SharedLibrary::isLoaded() const
+{
+ return isLoadedImpl();
+}
+
+
+bool SharedLibrary::hasSymbol(const std::string& name)
+{
+ return findSymbolImpl(name) != 0;
+}
+
+
+void* SharedLibrary::getSymbol(const std::string& name)
+{
+ void* result = findSymbolImpl(name);
+ if (result)
+ return result;
+ else
+ throw NotFoundException(name);
+}
+
+
+const std::string& SharedLibrary::getPath() const
+{
+ return getPathImpl();
+}
+
+
+std::string SharedLibrary::suffix()
+{
+ return suffixImpl();
+}
+
+
+bool SharedLibrary::setSearchPath(const std::string& path)
+{
+ return setSearchPathImpl(path);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/SharedLibrary_HPUX.cpp b/contrib/libs/poco/Foundation/src/SharedLibrary_HPUX.cpp
index 668bb5f64d..e5eb9347f5 100644
--- a/contrib/libs/poco/Foundation/src/SharedLibrary_HPUX.cpp
+++ b/contrib/libs/poco/Foundation/src/SharedLibrary_HPUX.cpp
@@ -1,100 +1,100 @@
-//
-// SharedLibrary_HPUX.cpp
-//
-// Library: Foundation
-// Package: SharedLibrary
-// Module: SharedLibrary
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/SharedLibrary_HPUX.h"
-#include <dl.h>
-
-
-namespace Poco {
-
-
-FastMutex SharedLibraryImpl::_mutex;
-
-
-SharedLibraryImpl::SharedLibraryImpl()
-{
- _handle = 0;
-}
-
-
-SharedLibraryImpl::~SharedLibraryImpl()
-{
-}
-
-
-void SharedLibraryImpl::loadImpl(const std::string& path, int /*flags*/)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- if (_handle) throw LibraryAlreadyLoadedException(path);
- _handle = shl_load(path.c_str(), BIND_DEFERRED, 0);
- if (!_handle) throw LibraryLoadException(path);
- _path = path;
-}
-
-
-void SharedLibraryImpl::unloadImpl()
-{
- FastMutex::ScopedLock lock(_mutex);
-
- if (_handle)
- {
- shl_unload(_handle);
- _handle = 0;
- _path.clear();
- }
-}
-
-
-bool SharedLibraryImpl::isLoadedImpl() const
-{
- return _handle != 0;
-}
-
-
-void* SharedLibraryImpl::findSymbolImpl(const std::string& name)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- void* result = 0;
- if (_handle && shl_findsym(&_handle, name.c_str(), TYPE_UNDEFINED, &result) != -1)
- return result;
- else
- return 0;
-}
-
-
-const std::string& SharedLibraryImpl::getPathImpl() const
-{
- return _path;
-}
-
-
-std::string SharedLibraryImpl::suffixImpl()
-{
-#if defined(_DEBUG) && !defined(POCO_NO_SHARED_LIBRARY_DEBUG_SUFFIX)
- return "d.sl";
-#else
- return ".sl";
-#endif
-}
-
-
-bool SharedLibraryImpl::setSearchPathImpl(const std::string&)
-{
- return false;
-}
-
-
-} // namespace Poco
+//
+// SharedLibrary_HPUX.cpp
+//
+// Library: Foundation
+// Package: SharedLibrary
+// Module: SharedLibrary
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/SharedLibrary_HPUX.h"
+#include <dl.h>
+
+
+namespace Poco {
+
+
+FastMutex SharedLibraryImpl::_mutex;
+
+
+SharedLibraryImpl::SharedLibraryImpl()
+{
+ _handle = 0;
+}
+
+
+SharedLibraryImpl::~SharedLibraryImpl()
+{
+}
+
+
+void SharedLibraryImpl::loadImpl(const std::string& path, int /*flags*/)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (_handle) throw LibraryAlreadyLoadedException(path);
+ _handle = shl_load(path.c_str(), BIND_DEFERRED, 0);
+ if (!_handle) throw LibraryLoadException(path);
+ _path = path;
+}
+
+
+void SharedLibraryImpl::unloadImpl()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (_handle)
+ {
+ shl_unload(_handle);
+ _handle = 0;
+ _path.clear();
+ }
+}
+
+
+bool SharedLibraryImpl::isLoadedImpl() const
+{
+ return _handle != 0;
+}
+
+
+void* SharedLibraryImpl::findSymbolImpl(const std::string& name)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ void* result = 0;
+ if (_handle && shl_findsym(&_handle, name.c_str(), TYPE_UNDEFINED, &result) != -1)
+ return result;
+ else
+ return 0;
+}
+
+
+const std::string& SharedLibraryImpl::getPathImpl() const
+{
+ return _path;
+}
+
+
+std::string SharedLibraryImpl::suffixImpl()
+{
+#if defined(_DEBUG) && !defined(POCO_NO_SHARED_LIBRARY_DEBUG_SUFFIX)
+ return "d.sl";
+#else
+ return ".sl";
+#endif
+}
+
+
+bool SharedLibraryImpl::setSearchPathImpl(const std::string&)
+{
+ return false;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/SharedLibrary_UNIX.cpp b/contrib/libs/poco/Foundation/src/SharedLibrary_UNIX.cpp
index 4a3dc2ffb0..60dc3cfd02 100644
--- a/contrib/libs/poco/Foundation/src/SharedLibrary_UNIX.cpp
+++ b/contrib/libs/poco/Foundation/src/SharedLibrary_UNIX.cpp
@@ -1,136 +1,136 @@
-//
-// SharedLibrary_UNIX.cpp
-//
-// Library: Foundation
-// Package: SharedLibrary
-// Module: SharedLibrary
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/SharedLibrary_UNIX.h"
-#include "Poco/Exception.h"
-#include <dlfcn.h>
-
-
-// Note: cygwin is missing RTLD_LOCAL, set it to 0
-#if defined(__CYGWIN__) && !defined(RTLD_LOCAL)
-#define RTLD_LOCAL 0
-#endif
-
-
-namespace Poco {
-
-
-FastMutex SharedLibraryImpl::_mutex;
-
-
-SharedLibraryImpl::SharedLibraryImpl()
-{
- _handle = 0;
-}
-
-
-SharedLibraryImpl::~SharedLibraryImpl()
-{
-}
-
-
-void SharedLibraryImpl::loadImpl(const std::string& path, int flags)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- if (_handle) throw LibraryAlreadyLoadedException(path);
- int realFlags = RTLD_LAZY;
- if (flags & SHLIB_LOCAL_IMPL)
- realFlags |= RTLD_LOCAL;
- else
- realFlags |= RTLD_GLOBAL;
- _handle = dlopen(path.c_str(), realFlags);
- if (!_handle)
- {
- const char* err = dlerror();
- throw LibraryLoadException(err ? std::string(err) : path);
- }
- _path = path;
-}
-
-
-void SharedLibraryImpl::unloadImpl()
-{
- FastMutex::ScopedLock lock(_mutex);
-
- if (_handle)
- {
- dlclose(_handle);
- _handle = 0;
- }
-}
-
-
-bool SharedLibraryImpl::isLoadedImpl() const
-{
- return _handle != 0;
-}
-
-
-void* SharedLibraryImpl::findSymbolImpl(const std::string& name)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- void* result = 0;
- if (_handle)
- {
- result = dlsym(_handle, name.c_str());
- }
- return result;
-}
-
-
-const std::string& SharedLibraryImpl::getPathImpl() const
-{
- return _path;
-}
-
-
-std::string SharedLibraryImpl::suffixImpl()
-{
-#if defined(__APPLE__)
- #if defined(_DEBUG) && !defined(POCO_NO_SHARED_LIBRARY_DEBUG_SUFFIX)
- return "d.dylib";
- #else
- return ".dylib";
- #endif
-#elif defined(hpux) || defined(_hpux)
- #if defined(_DEBUG) && !defined(POCO_NO_SHARED_LIBRARY_DEBUG_SUFFIX)
- return "d.sl";
- #else
- return ".sl";
- #endif
-#elif defined(__CYGWIN__)
- #if defined(_DEBUG) && !defined(POCO_NO_SHARED_LIBRARY_DEBUG_SUFFIX)
- return "d.dll";
- #else
- return ".dll";
- #endif
-#else
- #if defined(_DEBUG) && !defined(POCO_NO_SHARED_LIBRARY_DEBUG_SUFFIX)
- return "d.so";
- #else
- return ".so";
- #endif
-#endif
-}
-
-
-bool SharedLibraryImpl::setSearchPathImpl(const std::string&)
-{
- return false;
-}
-
-
-} // namespace Poco
+//
+// SharedLibrary_UNIX.cpp
+//
+// Library: Foundation
+// Package: SharedLibrary
+// Module: SharedLibrary
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/SharedLibrary_UNIX.h"
+#include "Poco/Exception.h"
+#include <dlfcn.h>
+
+
+// Note: cygwin is missing RTLD_LOCAL, set it to 0
+#if defined(__CYGWIN__) && !defined(RTLD_LOCAL)
+#define RTLD_LOCAL 0
+#endif
+
+
+namespace Poco {
+
+
+FastMutex SharedLibraryImpl::_mutex;
+
+
+SharedLibraryImpl::SharedLibraryImpl()
+{
+ _handle = 0;
+}
+
+
+SharedLibraryImpl::~SharedLibraryImpl()
+{
+}
+
+
+void SharedLibraryImpl::loadImpl(const std::string& path, int flags)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (_handle) throw LibraryAlreadyLoadedException(path);
+ int realFlags = RTLD_LAZY;
+ if (flags & SHLIB_LOCAL_IMPL)
+ realFlags |= RTLD_LOCAL;
+ else
+ realFlags |= RTLD_GLOBAL;
+ _handle = dlopen(path.c_str(), realFlags);
+ if (!_handle)
+ {
+ const char* err = dlerror();
+ throw LibraryLoadException(err ? std::string(err) : path);
+ }
+ _path = path;
+}
+
+
+void SharedLibraryImpl::unloadImpl()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (_handle)
+ {
+ dlclose(_handle);
+ _handle = 0;
+ }
+}
+
+
+bool SharedLibraryImpl::isLoadedImpl() const
+{
+ return _handle != 0;
+}
+
+
+void* SharedLibraryImpl::findSymbolImpl(const std::string& name)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ void* result = 0;
+ if (_handle)
+ {
+ result = dlsym(_handle, name.c_str());
+ }
+ return result;
+}
+
+
+const std::string& SharedLibraryImpl::getPathImpl() const
+{
+ return _path;
+}
+
+
+std::string SharedLibraryImpl::suffixImpl()
+{
+#if defined(__APPLE__)
+ #if defined(_DEBUG) && !defined(POCO_NO_SHARED_LIBRARY_DEBUG_SUFFIX)
+ return "d.dylib";
+ #else
+ return ".dylib";
+ #endif
+#elif defined(hpux) || defined(_hpux)
+ #if defined(_DEBUG) && !defined(POCO_NO_SHARED_LIBRARY_DEBUG_SUFFIX)
+ return "d.sl";
+ #else
+ return ".sl";
+ #endif
+#elif defined(__CYGWIN__)
+ #if defined(_DEBUG) && !defined(POCO_NO_SHARED_LIBRARY_DEBUG_SUFFIX)
+ return "d.dll";
+ #else
+ return ".dll";
+ #endif
+#else
+ #if defined(_DEBUG) && !defined(POCO_NO_SHARED_LIBRARY_DEBUG_SUFFIX)
+ return "d.so";
+ #else
+ return ".so";
+ #endif
+#endif
+}
+
+
+bool SharedLibraryImpl::setSearchPathImpl(const std::string&)
+{
+ return false;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/SharedLibrary_VX.cpp b/contrib/libs/poco/Foundation/src/SharedLibrary_VX.cpp
index e9de60713d..d578b6eba4 100644
--- a/contrib/libs/poco/Foundation/src/SharedLibrary_VX.cpp
+++ b/contrib/libs/poco/Foundation/src/SharedLibrary_VX.cpp
@@ -1,141 +1,141 @@
-//
-// SharedLibrary_VX.cpp
-//
-// Library: Foundation
-// Package: SharedLibrary
-// Module: SharedLibrary
-//
-// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/SharedLibrary_VX.h"
-#include "Poco/Exception.h"
-#include "Poco/Format.h"
-#error #include <loadLib.h>
-#error #include <unldLib.h>
-#include <ioLib.h>
-#error #include <symLib.h>
-#error #include <sysSymTbl.h>
-#include <cstring>
-
-
-struct SymLookup
-{
- const char* name;
- int group;
- void* addr;
-};
-
-
-extern "C" bool lookupFunc(char* name, int val, SYM_TYPE type, int arg, UINT16 group)
-{
- SymLookup* symLookup = reinterpret_cast<SymLookup*>(arg);
- if (group == symLookup->group && std::strcmp(name, symLookup->name) == 0)
- {
- symLookup->addr = reinterpret_cast<void*>(val);
- return TRUE;
- }
- else return FALSE;
-}
-
-
-namespace Poco {
-
-
-FastMutex SharedLibraryImpl::_mutex;
-
-
-SharedLibraryImpl::SharedLibraryImpl():
- _moduleId(0)
-{
-}
-
-
-SharedLibraryImpl::~SharedLibraryImpl()
-{
-}
-
-
-void SharedLibraryImpl::loadImpl(const std::string& path, int /*flags*/)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- if (_moduleId) throw LibraryAlreadyLoadedException(path);
- int fd = open(const_cast<char*>(path.c_str()), O_RDONLY, 0);
- if (fd)
- {
- _moduleId = loadModule(fd, LOAD_GLOBAL_SYMBOLS);
- if (!_moduleId)
- {
- int err = errno;
- close(fd);
- throw LibraryLoadException(Poco::format("error %d", err));
- }
- }
- else
- {
- int err = errno;
- throw LibraryLoadException(Poco::format("cannot open library (error %d)", err));
- }
- _path = path;
-}
-
-
-void SharedLibraryImpl::unloadImpl()
-{
- FastMutex::ScopedLock lock(_mutex);
-
- if (_moduleId)
- {
- unldByModuleId(_moduleId, 0);
- _moduleId = 0;
- }
-}
-
-
-bool SharedLibraryImpl::isLoadedImpl() const
-{
- return _moduleId != 0;
-}
-
-
-void* SharedLibraryImpl::findSymbolImpl(const std::string& name)
-{
- poco_assert (_moduleId != 0);
-
- FastMutex::ScopedLock lock(_mutex);
-
- MODULE_INFO mi;
- if (!moduleInfoGet(_moduleId, &mi)) return 0;
- SymLookup symLookup;
- symLookup.name = name.c_str();
- symLookup.group = mi.group;
- symLookup.addr = 0;
- symEach(sysSymTbl, reinterpret_cast<FUNCPTR>(lookupFunc), reinterpret_cast<int>(&symLookup));
- return symLookup.addr;
-}
-
-
-const std::string& SharedLibraryImpl::getPathImpl() const
-{
- return _path;
-}
-
-
-std::string SharedLibraryImpl::suffixImpl()
-{
- return ".out";
-}
-
-
-bool SharedLibraryImpl::setSearchPathImpl(const std::string&)
-{
- return false;
-}
-
-
-} // namespace Poco
+//
+// SharedLibrary_VX.cpp
+//
+// Library: Foundation
+// Package: SharedLibrary
+// Module: SharedLibrary
+//
+// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/SharedLibrary_VX.h"
+#include "Poco/Exception.h"
+#include "Poco/Format.h"
+#error #include <loadLib.h>
+#error #include <unldLib.h>
+#include <ioLib.h>
+#error #include <symLib.h>
+#error #include <sysSymTbl.h>
+#include <cstring>
+
+
+struct SymLookup
+{
+ const char* name;
+ int group;
+ void* addr;
+};
+
+
+extern "C" bool lookupFunc(char* name, int val, SYM_TYPE type, int arg, UINT16 group)
+{
+ SymLookup* symLookup = reinterpret_cast<SymLookup*>(arg);
+ if (group == symLookup->group && std::strcmp(name, symLookup->name) == 0)
+ {
+ symLookup->addr = reinterpret_cast<void*>(val);
+ return TRUE;
+ }
+ else return FALSE;
+}
+
+
+namespace Poco {
+
+
+FastMutex SharedLibraryImpl::_mutex;
+
+
+SharedLibraryImpl::SharedLibraryImpl():
+ _moduleId(0)
+{
+}
+
+
+SharedLibraryImpl::~SharedLibraryImpl()
+{
+}
+
+
+void SharedLibraryImpl::loadImpl(const std::string& path, int /*flags*/)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (_moduleId) throw LibraryAlreadyLoadedException(path);
+ int fd = open(const_cast<char*>(path.c_str()), O_RDONLY, 0);
+ if (fd)
+ {
+ _moduleId = loadModule(fd, LOAD_GLOBAL_SYMBOLS);
+ if (!_moduleId)
+ {
+ int err = errno;
+ close(fd);
+ throw LibraryLoadException(Poco::format("error %d", err));
+ }
+ }
+ else
+ {
+ int err = errno;
+ throw LibraryLoadException(Poco::format("cannot open library (error %d)", err));
+ }
+ _path = path;
+}
+
+
+void SharedLibraryImpl::unloadImpl()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (_moduleId)
+ {
+ unldByModuleId(_moduleId, 0);
+ _moduleId = 0;
+ }
+}
+
+
+bool SharedLibraryImpl::isLoadedImpl() const
+{
+ return _moduleId != 0;
+}
+
+
+void* SharedLibraryImpl::findSymbolImpl(const std::string& name)
+{
+ poco_assert (_moduleId != 0);
+
+ FastMutex::ScopedLock lock(_mutex);
+
+ MODULE_INFO mi;
+ if (!moduleInfoGet(_moduleId, &mi)) return 0;
+ SymLookup symLookup;
+ symLookup.name = name.c_str();
+ symLookup.group = mi.group;
+ symLookup.addr = 0;
+ symEach(sysSymTbl, reinterpret_cast<FUNCPTR>(lookupFunc), reinterpret_cast<int>(&symLookup));
+ return symLookup.addr;
+}
+
+
+const std::string& SharedLibraryImpl::getPathImpl() const
+{
+ return _path;
+}
+
+
+std::string SharedLibraryImpl::suffixImpl()
+{
+ return ".out";
+}
+
+
+bool SharedLibraryImpl::setSearchPathImpl(const std::string&)
+{
+ return false;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/SharedLibrary_WIN32.cpp b/contrib/libs/poco/Foundation/src/SharedLibrary_WIN32.cpp
index 340a742e8f..5a682cf72c 100644
--- a/contrib/libs/poco/Foundation/src/SharedLibrary_WIN32.cpp
+++ b/contrib/libs/poco/Foundation/src/SharedLibrary_WIN32.cpp
@@ -1,108 +1,108 @@
-//
-// SharedLibrary_WIN32.cpp
-//
-// Library: Foundation
-// Package: SharedLibrary
-// Module: SharedLibrary
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/SharedLibrary_WIN32.h"
-#include "Poco/Path.h"
-#include "Poco/UnWindows.h"
-
-
-namespace Poco {
-
-
-FastMutex SharedLibraryImpl::_mutex;
-
-
-SharedLibraryImpl::SharedLibraryImpl()
-{
- _handle = 0;
-}
-
-
-SharedLibraryImpl::~SharedLibraryImpl()
-{
-}
-
-
-void SharedLibraryImpl::loadImpl(const std::string& path, int /*flags*/)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- if (_handle) throw LibraryAlreadyLoadedException(_path);
- DWORD flags(0);
- Path p(path);
- if (p.isAbsolute()) flags |= LOAD_WITH_ALTERED_SEARCH_PATH;
- _handle = LoadLibraryExA(path.c_str(), 0, flags);
- if (!_handle) throw LibraryLoadException(path);
- _path = path;
-}
-
-
-void SharedLibraryImpl::unloadImpl()
-{
- FastMutex::ScopedLock lock(_mutex);
-
- if (_handle)
- {
- FreeLibrary((HMODULE) _handle);
- _handle = 0;
- }
- _path.clear();
-}
-
-
-bool SharedLibraryImpl::isLoadedImpl() const
-{
- return _handle != 0;
-}
-
-
-void* SharedLibraryImpl::findSymbolImpl(const std::string& name)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- if (_handle)
- {
- return (void*) GetProcAddress((HMODULE) _handle, name.c_str());
- }
- else return 0;
-}
-
-
-const std::string& SharedLibraryImpl::getPathImpl() const
-{
- return _path;
-}
-
-
-std::string SharedLibraryImpl::suffixImpl()
-{
-#if defined(_DEBUG) && !defined(POCO_NO_SHARED_LIBRARY_DEBUG_SUFFIX)
- return "d.dll";
-#else
- return ".dll";
-#endif
-}
-
-
-bool SharedLibraryImpl::setSearchPathImpl(const std::string& path)
-{
-#if _WIN32_WINNT >= 0x0502
- return SetDllDirectoryA(path.c_str()) != 0;
-#else
- return false;
-#endif
-}
-
-
-} // namespace Poco
+//
+// SharedLibrary_WIN32.cpp
+//
+// Library: Foundation
+// Package: SharedLibrary
+// Module: SharedLibrary
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/SharedLibrary_WIN32.h"
+#include "Poco/Path.h"
+#include "Poco/UnWindows.h"
+
+
+namespace Poco {
+
+
+FastMutex SharedLibraryImpl::_mutex;
+
+
+SharedLibraryImpl::SharedLibraryImpl()
+{
+ _handle = 0;
+}
+
+
+SharedLibraryImpl::~SharedLibraryImpl()
+{
+}
+
+
+void SharedLibraryImpl::loadImpl(const std::string& path, int /*flags*/)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (_handle) throw LibraryAlreadyLoadedException(_path);
+ DWORD flags(0);
+ Path p(path);
+ if (p.isAbsolute()) flags |= LOAD_WITH_ALTERED_SEARCH_PATH;
+ _handle = LoadLibraryExA(path.c_str(), 0, flags);
+ if (!_handle) throw LibraryLoadException(path);
+ _path = path;
+}
+
+
+void SharedLibraryImpl::unloadImpl()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (_handle)
+ {
+ FreeLibrary((HMODULE) _handle);
+ _handle = 0;
+ }
+ _path.clear();
+}
+
+
+bool SharedLibraryImpl::isLoadedImpl() const
+{
+ return _handle != 0;
+}
+
+
+void* SharedLibraryImpl::findSymbolImpl(const std::string& name)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (_handle)
+ {
+ return (void*) GetProcAddress((HMODULE) _handle, name.c_str());
+ }
+ else return 0;
+}
+
+
+const std::string& SharedLibraryImpl::getPathImpl() const
+{
+ return _path;
+}
+
+
+std::string SharedLibraryImpl::suffixImpl()
+{
+#if defined(_DEBUG) && !defined(POCO_NO_SHARED_LIBRARY_DEBUG_SUFFIX)
+ return "d.dll";
+#else
+ return ".dll";
+#endif
+}
+
+
+bool SharedLibraryImpl::setSearchPathImpl(const std::string& path)
+{
+#if _WIN32_WINNT >= 0x0502
+ return SetDllDirectoryA(path.c_str()) != 0;
+#else
+ return false;
+#endif
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/SharedLibrary_WIN32U.cpp b/contrib/libs/poco/Foundation/src/SharedLibrary_WIN32U.cpp
index b4f697ea0a..d4585259a1 100644
--- a/contrib/libs/poco/Foundation/src/SharedLibrary_WIN32U.cpp
+++ b/contrib/libs/poco/Foundation/src/SharedLibrary_WIN32U.cpp
@@ -1,121 +1,121 @@
-//
-// SharedLibrary_WIN32U.cpp
-//
-// Library: Foundation
-// Package: SharedLibrary
-// Module: SharedLibrary
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/SharedLibrary_WIN32U.h"
-#include "Poco/UnicodeConverter.h"
-#include "Poco/Path.h"
-#include "Poco/UnWindows.h"
-
-
-namespace Poco {
-
-
-FastMutex SharedLibraryImpl::_mutex;
-
-
-SharedLibraryImpl::SharedLibraryImpl()
-{
- _handle = 0;
-}
-
-
-SharedLibraryImpl::~SharedLibraryImpl()
-{
-}
-
-
-void SharedLibraryImpl::loadImpl(const std::string& path, int /*flags*/)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- if (_handle) throw LibraryAlreadyLoadedException(_path);
- DWORD flags(0);
-#if !defined(_WIN32_WCE)
- Path p(path);
- if (p.isAbsolute()) flags |= LOAD_WITH_ALTERED_SEARCH_PATH;
-#endif
- std::wstring upath;
- UnicodeConverter::toUTF16(path, upath);
- _handle = LoadLibraryExW(upath.c_str(), 0, flags);
- if (!_handle) throw LibraryLoadException(path);
- _path = path;
-}
-
-
-void SharedLibraryImpl::unloadImpl()
-{
- FastMutex::ScopedLock lock(_mutex);
-
- if (_handle)
- {
- FreeLibrary((HMODULE) _handle);
- _handle = 0;
- }
- _path.clear();
-}
-
-
-bool SharedLibraryImpl::isLoadedImpl() const
-{
- return _handle != 0;
-}
-
-
-void* SharedLibraryImpl::findSymbolImpl(const std::string& name)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- if (_handle)
- {
-#if defined(_WIN32_WCE)
- std::wstring uname;
- UnicodeConverter::toUTF16(name, uname);
- return (void*) GetProcAddressW((HMODULE) _handle, uname.c_str());
-#else
- return (void*) GetProcAddress((HMODULE) _handle, name.c_str());
-#endif
- }
- else return 0;
-}
-
-
-const std::string& SharedLibraryImpl::getPathImpl() const
-{
- return _path;
-}
-
-
-std::string SharedLibraryImpl::suffixImpl()
-{
-#if defined(_DEBUG) && !defined(POCO_NO_SHARED_LIBRARY_DEBUG_SUFFIX)
- return "d.dll";
-#else
- return ".dll";
-#endif
-}
-
-
-bool SharedLibraryImpl::setSearchPathImpl(const std::string& path)
-{
-#if _WIN32_WINNT >= 0x0502
- std::wstring wpath;
- Poco::UnicodeConverter::toUTF16(path, wpath);
- return SetDllDirectoryW(wpath.c_str()) != 0;
-#else
- return false;
-#endif
-}
-
-
-} // namespace Poco
+//
+// SharedLibrary_WIN32U.cpp
+//
+// Library: Foundation
+// Package: SharedLibrary
+// Module: SharedLibrary
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/SharedLibrary_WIN32U.h"
+#include "Poco/UnicodeConverter.h"
+#include "Poco/Path.h"
+#include "Poco/UnWindows.h"
+
+
+namespace Poco {
+
+
+FastMutex SharedLibraryImpl::_mutex;
+
+
+SharedLibraryImpl::SharedLibraryImpl()
+{
+ _handle = 0;
+}
+
+
+SharedLibraryImpl::~SharedLibraryImpl()
+{
+}
+
+
+void SharedLibraryImpl::loadImpl(const std::string& path, int /*flags*/)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (_handle) throw LibraryAlreadyLoadedException(_path);
+ DWORD flags(0);
+#if !defined(_WIN32_WCE)
+ Path p(path);
+ if (p.isAbsolute()) flags |= LOAD_WITH_ALTERED_SEARCH_PATH;
+#endif
+ std::wstring upath;
+ UnicodeConverter::toUTF16(path, upath);
+ _handle = LoadLibraryExW(upath.c_str(), 0, flags);
+ if (!_handle) throw LibraryLoadException(path);
+ _path = path;
+}
+
+
+void SharedLibraryImpl::unloadImpl()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (_handle)
+ {
+ FreeLibrary((HMODULE) _handle);
+ _handle = 0;
+ }
+ _path.clear();
+}
+
+
+bool SharedLibraryImpl::isLoadedImpl() const
+{
+ return _handle != 0;
+}
+
+
+void* SharedLibraryImpl::findSymbolImpl(const std::string& name)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (_handle)
+ {
+#if defined(_WIN32_WCE)
+ std::wstring uname;
+ UnicodeConverter::toUTF16(name, uname);
+ return (void*) GetProcAddressW((HMODULE) _handle, uname.c_str());
+#else
+ return (void*) GetProcAddress((HMODULE) _handle, name.c_str());
+#endif
+ }
+ else return 0;
+}
+
+
+const std::string& SharedLibraryImpl::getPathImpl() const
+{
+ return _path;
+}
+
+
+std::string SharedLibraryImpl::suffixImpl()
+{
+#if defined(_DEBUG) && !defined(POCO_NO_SHARED_LIBRARY_DEBUG_SUFFIX)
+ return "d.dll";
+#else
+ return ".dll";
+#endif
+}
+
+
+bool SharedLibraryImpl::setSearchPathImpl(const std::string& path)
+{
+#if _WIN32_WINNT >= 0x0502
+ std::wstring wpath;
+ Poco::UnicodeConverter::toUTF16(path, wpath);
+ return SetDllDirectoryW(wpath.c_str()) != 0;
+#else
+ return false;
+#endif
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/SharedMemory.cpp b/contrib/libs/poco/Foundation/src/SharedMemory.cpp
index da43a421c0..74a2a0d970 100644
--- a/contrib/libs/poco/Foundation/src/SharedMemory.cpp
+++ b/contrib/libs/poco/Foundation/src/SharedMemory.cpp
@@ -1,90 +1,90 @@
-//
-// SharedMemory.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: SharedMemory
-//
-// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/SharedMemory.h"
-#include "Poco/Exception.h"
-#if defined(POCO_NO_SHAREDMEMORY)
-#include "SharedMemory_DUMMY.cpp"
-#elif defined(POCO_OS_FAMILY_WINDOWS)
-#include "SharedMemory_WIN32.cpp"
-#elif defined(POCO_OS_FAMILY_UNIX)
-#include "SharedMemory_POSIX.cpp"
-#else
-#include "SharedMemory_DUMMY.cpp"
-#endif
-
-
-namespace Poco {
-
-
-SharedMemory::SharedMemory():
- _pImpl(0)
-{
-}
-
-
-SharedMemory::SharedMemory(const std::string& name, std::size_t size, AccessMode mode, const void* addrHint, bool server):
- _pImpl(new SharedMemoryImpl(name, size, mode, addrHint, server))
-{
-}
-
-
-SharedMemory::SharedMemory(const Poco::File& file, AccessMode mode, const void* addrHint):
- _pImpl(new SharedMemoryImpl(file, mode, addrHint))
-{
-}
-
-
-SharedMemory::SharedMemory(const SharedMemory& other):
- _pImpl(other._pImpl)
-{
- if (_pImpl)
- _pImpl->duplicate();
-}
-
-
-SharedMemory::~SharedMemory()
-{
- if (_pImpl)
- _pImpl->release();
-}
-
-
-SharedMemory& SharedMemory::operator = (const SharedMemory& other)
-{
- SharedMemory tmp(other);
- swap(tmp);
- return *this;
-}
-
-
-char* SharedMemory::begin() const
-{
- if (_pImpl)
- return _pImpl->begin();
- else
- return 0;
-}
-
-
-char* SharedMemory::end() const
-{
- if (_pImpl)
- return _pImpl->end();
- else
- return 0;
-}
-
-
-} // namespace Poco
+//
+// SharedMemory.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: SharedMemory
+//
+// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/SharedMemory.h"
+#include "Poco/Exception.h"
+#if defined(POCO_NO_SHAREDMEMORY)
+#include "SharedMemory_DUMMY.cpp"
+#elif defined(POCO_OS_FAMILY_WINDOWS)
+#include "SharedMemory_WIN32.cpp"
+#elif defined(POCO_OS_FAMILY_UNIX)
+#include "SharedMemory_POSIX.cpp"
+#else
+#include "SharedMemory_DUMMY.cpp"
+#endif
+
+
+namespace Poco {
+
+
+SharedMemory::SharedMemory():
+ _pImpl(0)
+{
+}
+
+
+SharedMemory::SharedMemory(const std::string& name, std::size_t size, AccessMode mode, const void* addrHint, bool server):
+ _pImpl(new SharedMemoryImpl(name, size, mode, addrHint, server))
+{
+}
+
+
+SharedMemory::SharedMemory(const Poco::File& file, AccessMode mode, const void* addrHint):
+ _pImpl(new SharedMemoryImpl(file, mode, addrHint))
+{
+}
+
+
+SharedMemory::SharedMemory(const SharedMemory& other):
+ _pImpl(other._pImpl)
+{
+ if (_pImpl)
+ _pImpl->duplicate();
+}
+
+
+SharedMemory::~SharedMemory()
+{
+ if (_pImpl)
+ _pImpl->release();
+}
+
+
+SharedMemory& SharedMemory::operator = (const SharedMemory& other)
+{
+ SharedMemory tmp(other);
+ swap(tmp);
+ return *this;
+}
+
+
+char* SharedMemory::begin() const
+{
+ if (_pImpl)
+ return _pImpl->begin();
+ else
+ return 0;
+}
+
+
+char* SharedMemory::end() const
+{
+ if (_pImpl)
+ return _pImpl->end();
+ else
+ return 0;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/SharedMemory_DUMMY.cpp b/contrib/libs/poco/Foundation/src/SharedMemory_DUMMY.cpp
index 3858632380..20524c2cc6 100644
--- a/contrib/libs/poco/Foundation/src/SharedMemory_DUMMY.cpp
+++ b/contrib/libs/poco/Foundation/src/SharedMemory_DUMMY.cpp
@@ -1,36 +1,36 @@
-//
-// SharedMemoryImpl.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: SharedMemoryImpl
-//
-// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/SharedMemory_DUMMY.h"
-
-
-namespace Poco {
-
-
-SharedMemoryImpl::SharedMemoryImpl(const std::string&, std::size_t, SharedMemory::AccessMode, const void*, bool)
-{
-}
-
-
-SharedMemoryImpl::SharedMemoryImpl(const Poco::File&, SharedMemory::AccessMode, const void*)
-{
-}
-
-
-SharedMemoryImpl::~SharedMemoryImpl()
-{
-}
-
-
-} // namespace Poco
+//
+// SharedMemoryImpl.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: SharedMemoryImpl
+//
+// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/SharedMemory_DUMMY.h"
+
+
+namespace Poco {
+
+
+SharedMemoryImpl::SharedMemoryImpl(const std::string&, std::size_t, SharedMemory::AccessMode, const void*, bool)
+{
+}
+
+
+SharedMemoryImpl::SharedMemoryImpl(const Poco::File&, SharedMemory::AccessMode, const void*)
+{
+}
+
+
+SharedMemoryImpl::~SharedMemoryImpl()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/SharedMemory_POSIX.cpp b/contrib/libs/poco/Foundation/src/SharedMemory_POSIX.cpp
index edeb4f5366..e7fe6a1ada 100644
--- a/contrib/libs/poco/Foundation/src/SharedMemory_POSIX.cpp
+++ b/contrib/libs/poco/Foundation/src/SharedMemory_POSIX.cpp
@@ -1,134 +1,134 @@
-//
-// SharedMemoryImpl.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: SharedMemoryImpl
-//
-// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/SharedMemory_POSIX.h"
-#include "Poco/Exception.h"
-#include "Poco/File.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-
-namespace Poco {
-
-
-SharedMemoryImpl::SharedMemoryImpl(const std::string& name, std::size_t size, SharedMemory::AccessMode mode, const void* addrHint, bool server):
- _size(size),
- _fd(-1),
- _address(0),
- _access(mode),
- _name("/"),
- _fileMapped(false),
- _server(server)
-{
-#if POCO_OS == POCO_OS_HPUX
- _name.append("tmp/");
-#endif
-
- _name.append(name);
-
- int flags = _server ? O_CREAT : 0;
- if (_access == SharedMemory::AM_WRITE)
- flags |= O_RDWR;
- else
- flags |= O_RDONLY;
-
- // open the shared memory segment
- _fd = ::shm_open(_name.c_str(), flags, S_IRUSR | S_IWUSR);
- if (_fd == -1)
- throw SystemException("Cannot create shared memory object", _name);
-
- // now set the correct size for the segment
- if (_server && -1 == ::ftruncate(_fd, size))
- {
- ::close(_fd);
- _fd = -1;
- ::shm_unlink(_name.c_str());
- throw SystemException("Cannot resize shared memory object", _name);
- }
- map(addrHint);
-}
-
-
-SharedMemoryImpl::SharedMemoryImpl(const Poco::File& file, SharedMemory::AccessMode mode, const void* addrHint):
- _size(0),
- _fd(-1),
- _address(0),
- _access(mode),
- _name(file.path()),
- _fileMapped(true),
- _server(false)
-{
- if (!file.exists() || !file.isFile())
- throw FileNotFoundException(file.path());
-
- _size = file.getSize();
- int flag = O_RDONLY;
- if (mode == SharedMemory::AM_WRITE)
- flag = O_RDWR;
- _fd = ::open(_name.c_str(), flag);
- if (-1 == _fd)
- throw OpenFileException("Cannot open memory mapped file", _name);
-
- map(addrHint);
-}
-
-
-SharedMemoryImpl::~SharedMemoryImpl()
-{
- unmap();
- close();
-}
-
-
-void SharedMemoryImpl::map(const void* addrHint)
-{
- int access = PROT_READ;
- if (_access == SharedMemory::AM_WRITE)
- access |= PROT_WRITE;
-
- void* addr = ::mmap(const_cast<void*>(addrHint), _size, access, MAP_SHARED, _fd, 0);
- if (addr == MAP_FAILED)
- throw SystemException("Cannot map file into shared memory", _name);
-
- _address = static_cast<char*>(addr);
-}
-
-
-void SharedMemoryImpl::unmap()
-{
- if (_address)
- {
- ::munmap(_address, _size);
- }
-}
-
-
-void SharedMemoryImpl::close()
-{
- if (_fd != -1)
- {
- ::close(_fd);
- _fd = -1;
- }
- if (!_fileMapped && _server)
- {
- ::shm_unlink(_name.c_str());
- }
-}
-
-
-} // namespace Poco
+//
+// SharedMemoryImpl.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: SharedMemoryImpl
+//
+// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/SharedMemory_POSIX.h"
+#include "Poco/Exception.h"
+#include "Poco/File.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+
+namespace Poco {
+
+
+SharedMemoryImpl::SharedMemoryImpl(const std::string& name, std::size_t size, SharedMemory::AccessMode mode, const void* addrHint, bool server):
+ _size(size),
+ _fd(-1),
+ _address(0),
+ _access(mode),
+ _name("/"),
+ _fileMapped(false),
+ _server(server)
+{
+#if POCO_OS == POCO_OS_HPUX
+ _name.append("tmp/");
+#endif
+
+ _name.append(name);
+
+ int flags = _server ? O_CREAT : 0;
+ if (_access == SharedMemory::AM_WRITE)
+ flags |= O_RDWR;
+ else
+ flags |= O_RDONLY;
+
+ // open the shared memory segment
+ _fd = ::shm_open(_name.c_str(), flags, S_IRUSR | S_IWUSR);
+ if (_fd == -1)
+ throw SystemException("Cannot create shared memory object", _name);
+
+ // now set the correct size for the segment
+ if (_server && -1 == ::ftruncate(_fd, size))
+ {
+ ::close(_fd);
+ _fd = -1;
+ ::shm_unlink(_name.c_str());
+ throw SystemException("Cannot resize shared memory object", _name);
+ }
+ map(addrHint);
+}
+
+
+SharedMemoryImpl::SharedMemoryImpl(const Poco::File& file, SharedMemory::AccessMode mode, const void* addrHint):
+ _size(0),
+ _fd(-1),
+ _address(0),
+ _access(mode),
+ _name(file.path()),
+ _fileMapped(true),
+ _server(false)
+{
+ if (!file.exists() || !file.isFile())
+ throw FileNotFoundException(file.path());
+
+ _size = file.getSize();
+ int flag = O_RDONLY;
+ if (mode == SharedMemory::AM_WRITE)
+ flag = O_RDWR;
+ _fd = ::open(_name.c_str(), flag);
+ if (-1 == _fd)
+ throw OpenFileException("Cannot open memory mapped file", _name);
+
+ map(addrHint);
+}
+
+
+SharedMemoryImpl::~SharedMemoryImpl()
+{
+ unmap();
+ close();
+}
+
+
+void SharedMemoryImpl::map(const void* addrHint)
+{
+ int access = PROT_READ;
+ if (_access == SharedMemory::AM_WRITE)
+ access |= PROT_WRITE;
+
+ void* addr = ::mmap(const_cast<void*>(addrHint), _size, access, MAP_SHARED, _fd, 0);
+ if (addr == MAP_FAILED)
+ throw SystemException("Cannot map file into shared memory", _name);
+
+ _address = static_cast<char*>(addr);
+}
+
+
+void SharedMemoryImpl::unmap()
+{
+ if (_address)
+ {
+ ::munmap(_address, _size);
+ }
+}
+
+
+void SharedMemoryImpl::close()
+{
+ if (_fd != -1)
+ {
+ ::close(_fd);
+ _fd = -1;
+ }
+ if (!_fileMapped && _server)
+ {
+ ::shm_unlink(_name.c_str());
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/SharedMemory_WIN32.cpp b/contrib/libs/poco/Foundation/src/SharedMemory_WIN32.cpp
index 1e86d7d10e..b995e69430 100644
--- a/contrib/libs/poco/Foundation/src/SharedMemory_WIN32.cpp
+++ b/contrib/libs/poco/Foundation/src/SharedMemory_WIN32.cpp
@@ -1,168 +1,168 @@
-//
-// SharedMemoryImpl.cpp
-//
-// Library: Foundation
-// Package: Processes
-// Module: SharedMemoryImpl
-//
-// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/SharedMemory_WIN32.h"
-#include "Poco/Error.h"
-#include "Poco/Exception.h"
-#include "Poco/File.h"
-#include "Poco/Format.h"
-#if defined (POCO_WIN32_UTF8)
-#include "Poco/UnicodeConverter.h"
-#endif
-#include "Poco/UnWindows.h"
-
-
-namespace Poco {
-
-
-SharedMemoryImpl::SharedMemoryImpl(const std::string& name, std::size_t size, SharedMemory::AccessMode mode, const void*, bool):
- _name(name),
- _memHandle(INVALID_HANDLE_VALUE),
- _fileHandle(INVALID_HANDLE_VALUE),
- _size(static_cast<DWORD>(size)),
- _mode(PAGE_READONLY),
- _address(0)
-{
- if (mode == SharedMemory::AM_WRITE)
- _mode = PAGE_READWRITE;
-
-#if defined (POCO_WIN32_UTF8)
- std::wstring utf16name;
- UnicodeConverter::toUTF16(_name, utf16name);
- _memHandle = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, _mode, 0, _size, utf16name.c_str());
-#else
- _memHandle = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, _mode, 0, _size, _name.c_str());
-#endif
-
- if (!_memHandle)
- {
- DWORD dwRetVal = GetLastError();
-#if defined (_WIN32_WCE)
- throw SystemException(format("Cannot create shared memory object %s [Error %d: %s]", _name, static_cast<int>(dwRetVal), Error::getMessage(dwRetVal)));
-#else
- if (_mode != PAGE_READONLY || dwRetVal != 5)
- throw SystemException(format("Cannot create shared memory object %s [Error %d: %s]", _name, static_cast<int>(dwRetVal), Error::getMessage(dwRetVal)));
-
-#if defined (POCO_WIN32_UTF8)
- _memHandle = OpenFileMappingW(PAGE_READONLY, FALSE, utf16name.c_str());
-#else
- _memHandle = OpenFileMappingA(PAGE_READONLY, FALSE, _name.c_str());
-#endif
- if (!_memHandle)
- {
- dwRetVal = GetLastError();
- throw SystemException(format("Cannot open shared memory object %s [Error %d: %s]", _name, static_cast<int>(dwRetVal), Error::getMessage(dwRetVal)));
- }
+//
+// SharedMemoryImpl.cpp
+//
+// Library: Foundation
+// Package: Processes
+// Module: SharedMemoryImpl
+//
+// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/SharedMemory_WIN32.h"
+#include "Poco/Error.h"
+#include "Poco/Exception.h"
+#include "Poco/File.h"
+#include "Poco/Format.h"
+#if defined (POCO_WIN32_UTF8)
+#include "Poco/UnicodeConverter.h"
#endif
- }
- map();
-}
-
-
-SharedMemoryImpl::SharedMemoryImpl(const Poco::File& file, SharedMemory::AccessMode mode, const void*):
- _name(file.path()),
- _memHandle(INVALID_HANDLE_VALUE),
- _fileHandle(INVALID_HANDLE_VALUE),
- _size(0),
- _mode(PAGE_READONLY),
- _address(0)
-{
- if (!file.exists() || !file.isFile())
- throw FileNotFoundException(_name);
-
- _size = static_cast<DWORD>(file.getSize());
-
- DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
- DWORD fileMode = GENERIC_READ;
-
- if (mode == SharedMemory::AM_WRITE)
- {
- _mode = PAGE_READWRITE;
- fileMode |= GENERIC_WRITE;
- }
-
-#if defined (POCO_WIN32_UTF8)
- std::wstring utf16name;
- UnicodeConverter::toUTF16(_name, utf16name);
- _fileHandle = CreateFileW(utf16name.c_str(), fileMode, shareMode, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
-#else
- _fileHandle = CreateFileA(_name.c_str(), fileMode, shareMode, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
-#endif
-
- if (_fileHandle == INVALID_HANDLE_VALUE)
- throw OpenFileException("Cannot open memory mapped file", _name);
-
- _memHandle = CreateFileMapping(_fileHandle, NULL, _mode, 0, 0, NULL);
- if (!_memHandle)
- {
- DWORD dwRetVal = GetLastError();
- CloseHandle(_fileHandle);
- _fileHandle = INVALID_HANDLE_VALUE;
- throw SystemException(format("Cannot map file into shared memory %s [Error %d: %s]", _name, (int)dwRetVal, Error::getMessage(dwRetVal)));
- }
- map();
-}
-
-
-SharedMemoryImpl::~SharedMemoryImpl()
-{
- unmap();
- close();
-}
-
-
-void SharedMemoryImpl::map()
-{
- DWORD access = FILE_MAP_READ;
- if (_mode == PAGE_READWRITE)
- access = FILE_MAP_WRITE;
- LPVOID addr = MapViewOfFile(_memHandle, access, 0, 0, _size);
- if (!addr)
- {
- DWORD dwRetVal = GetLastError();
- throw SystemException(format("Cannot map shared memory object %s [Error %d: %s]", _name, (int)dwRetVal, Error::getMessage(dwRetVal)));
- }
-
- _address = static_cast<char*>(addr);
-}
-
-
-void SharedMemoryImpl::unmap()
-{
- if (_address)
- {
- UnmapViewOfFile(_address);
- _address = 0;
- return;
- }
-}
-
-
-void SharedMemoryImpl::close()
-{
- if (_memHandle != INVALID_HANDLE_VALUE)
- {
- CloseHandle(_memHandle);
- _memHandle = INVALID_HANDLE_VALUE;
- }
-
- if (_fileHandle != INVALID_HANDLE_VALUE)
- {
- CloseHandle(_fileHandle);
- _fileHandle = INVALID_HANDLE_VALUE;
- }
-}
-
-
-} // namespace Poco
+#include "Poco/UnWindows.h"
+
+
+namespace Poco {
+
+
+SharedMemoryImpl::SharedMemoryImpl(const std::string& name, std::size_t size, SharedMemory::AccessMode mode, const void*, bool):
+ _name(name),
+ _memHandle(INVALID_HANDLE_VALUE),
+ _fileHandle(INVALID_HANDLE_VALUE),
+ _size(static_cast<DWORD>(size)),
+ _mode(PAGE_READONLY),
+ _address(0)
+{
+ if (mode == SharedMemory::AM_WRITE)
+ _mode = PAGE_READWRITE;
+
+#if defined (POCO_WIN32_UTF8)
+ std::wstring utf16name;
+ UnicodeConverter::toUTF16(_name, utf16name);
+ _memHandle = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, _mode, 0, _size, utf16name.c_str());
+#else
+ _memHandle = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, _mode, 0, _size, _name.c_str());
+#endif
+
+ if (!_memHandle)
+ {
+ DWORD dwRetVal = GetLastError();
+#if defined (_WIN32_WCE)
+ throw SystemException(format("Cannot create shared memory object %s [Error %d: %s]", _name, static_cast<int>(dwRetVal), Error::getMessage(dwRetVal)));
+#else
+ if (_mode != PAGE_READONLY || dwRetVal != 5)
+ throw SystemException(format("Cannot create shared memory object %s [Error %d: %s]", _name, static_cast<int>(dwRetVal), Error::getMessage(dwRetVal)));
+
+#if defined (POCO_WIN32_UTF8)
+ _memHandle = OpenFileMappingW(PAGE_READONLY, FALSE, utf16name.c_str());
+#else
+ _memHandle = OpenFileMappingA(PAGE_READONLY, FALSE, _name.c_str());
+#endif
+ if (!_memHandle)
+ {
+ dwRetVal = GetLastError();
+ throw SystemException(format("Cannot open shared memory object %s [Error %d: %s]", _name, static_cast<int>(dwRetVal), Error::getMessage(dwRetVal)));
+ }
+#endif
+ }
+ map();
+}
+
+
+SharedMemoryImpl::SharedMemoryImpl(const Poco::File& file, SharedMemory::AccessMode mode, const void*):
+ _name(file.path()),
+ _memHandle(INVALID_HANDLE_VALUE),
+ _fileHandle(INVALID_HANDLE_VALUE),
+ _size(0),
+ _mode(PAGE_READONLY),
+ _address(0)
+{
+ if (!file.exists() || !file.isFile())
+ throw FileNotFoundException(_name);
+
+ _size = static_cast<DWORD>(file.getSize());
+
+ DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
+ DWORD fileMode = GENERIC_READ;
+
+ if (mode == SharedMemory::AM_WRITE)
+ {
+ _mode = PAGE_READWRITE;
+ fileMode |= GENERIC_WRITE;
+ }
+
+#if defined (POCO_WIN32_UTF8)
+ std::wstring utf16name;
+ UnicodeConverter::toUTF16(_name, utf16name);
+ _fileHandle = CreateFileW(utf16name.c_str(), fileMode, shareMode, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+#else
+ _fileHandle = CreateFileA(_name.c_str(), fileMode, shareMode, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+#endif
+
+ if (_fileHandle == INVALID_HANDLE_VALUE)
+ throw OpenFileException("Cannot open memory mapped file", _name);
+
+ _memHandle = CreateFileMapping(_fileHandle, NULL, _mode, 0, 0, NULL);
+ if (!_memHandle)
+ {
+ DWORD dwRetVal = GetLastError();
+ CloseHandle(_fileHandle);
+ _fileHandle = INVALID_HANDLE_VALUE;
+ throw SystemException(format("Cannot map file into shared memory %s [Error %d: %s]", _name, (int)dwRetVal, Error::getMessage(dwRetVal)));
+ }
+ map();
+}
+
+
+SharedMemoryImpl::~SharedMemoryImpl()
+{
+ unmap();
+ close();
+}
+
+
+void SharedMemoryImpl::map()
+{
+ DWORD access = FILE_MAP_READ;
+ if (_mode == PAGE_READWRITE)
+ access = FILE_MAP_WRITE;
+ LPVOID addr = MapViewOfFile(_memHandle, access, 0, 0, _size);
+ if (!addr)
+ {
+ DWORD dwRetVal = GetLastError();
+ throw SystemException(format("Cannot map shared memory object %s [Error %d: %s]", _name, (int)dwRetVal, Error::getMessage(dwRetVal)));
+ }
+
+ _address = static_cast<char*>(addr);
+}
+
+
+void SharedMemoryImpl::unmap()
+{
+ if (_address)
+ {
+ UnmapViewOfFile(_address);
+ _address = 0;
+ return;
+ }
+}
+
+
+void SharedMemoryImpl::close()
+{
+ if (_memHandle != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle(_memHandle);
+ _memHandle = INVALID_HANDLE_VALUE;
+ }
+
+ if (_fileHandle != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle(_fileHandle);
+ _fileHandle = INVALID_HANDLE_VALUE;
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/SignalHandler.cpp b/contrib/libs/poco/Foundation/src/SignalHandler.cpp
index eaa1dc7ec8..4aca858367 100644
--- a/contrib/libs/poco/Foundation/src/SignalHandler.cpp
+++ b/contrib/libs/poco/Foundation/src/SignalHandler.cpp
@@ -1,111 +1,111 @@
-//
-// SignalHandler.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: SignalHandler
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/SignalHandler.h"
-
-
-#if defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_VXWORKS)
-
-
-#include "Poco/Thread.h"
-#include "Poco/NumberFormatter.h"
-#include "Poco/Exception.h"
-#include <cstdlib>
-#include <signal.h>
-
-
-namespace Poco {
-
-
-SignalHandler::JumpBufferVec SignalHandler::_jumpBufferVec;
-
-
-SignalHandler::SignalHandler()
-{
- JumpBufferVec& jbv = jumpBufferVec();
- JumpBuffer buf;
- jbv.push_back(buf);
-}
-
-
-SignalHandler::~SignalHandler()
-{
- jumpBufferVec().pop_back();
-}
-
-
-sigjmp_buf& SignalHandler::jumpBuffer()
-{
- return jumpBufferVec().back().buf;
-}
-
-
-void SignalHandler::throwSignalException(int sig)
-{
- switch (sig)
- {
- case SIGILL:
- throw SignalException("Illegal instruction");
- case SIGBUS:
- throw SignalException("Bus error");
- case SIGSEGV:
- throw SignalException("Segmentation violation");
- case SIGSYS:
- throw SignalException("Invalid system call");
- default:
- throw SignalException(NumberFormatter::formatHex(sig));
- }
-}
-
-
-void SignalHandler::install()
-{
-#ifndef POCO_NO_SIGNAL_HANDLER
- struct sigaction sa;
- sa.sa_handler = handleSignal;
- sa.sa_flags = 0;
- sigemptyset(&sa.sa_mask);
- sigaction(SIGILL, &sa, 0);
- sigaction(SIGBUS, &sa, 0);
- sigaction(SIGSEGV, &sa, 0);
- sigaction(SIGSYS, &sa, 0);
-#endif
-}
-
-
-void SignalHandler::handleSignal(int sig)
-{
- JumpBufferVec& jb = jumpBufferVec();
- if (!jb.empty())
- siglongjmp(jb.back().buf, sig);
-
- // Abort if no jump buffer registered
- std::abort();
-}
-
-
-SignalHandler::JumpBufferVec& SignalHandler::jumpBufferVec()
-{
- ThreadImpl* pThread = ThreadImpl::currentImpl();
- if (pThread)
- return pThread->_jumpBufferVec;
- else
- return _jumpBufferVec;
-}
-
-
-} // namespace Poco
-
-
-#endif // POCO_OS_FAMILY_UNIX
+//
+// SignalHandler.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: SignalHandler
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/SignalHandler.h"
+
+
+#if defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_VXWORKS)
+
+
+#include "Poco/Thread.h"
+#include "Poco/NumberFormatter.h"
+#include "Poco/Exception.h"
+#include <cstdlib>
+#include <signal.h>
+
+
+namespace Poco {
+
+
+SignalHandler::JumpBufferVec SignalHandler::_jumpBufferVec;
+
+
+SignalHandler::SignalHandler()
+{
+ JumpBufferVec& jbv = jumpBufferVec();
+ JumpBuffer buf;
+ jbv.push_back(buf);
+}
+
+
+SignalHandler::~SignalHandler()
+{
+ jumpBufferVec().pop_back();
+}
+
+
+sigjmp_buf& SignalHandler::jumpBuffer()
+{
+ return jumpBufferVec().back().buf;
+}
+
+
+void SignalHandler::throwSignalException(int sig)
+{
+ switch (sig)
+ {
+ case SIGILL:
+ throw SignalException("Illegal instruction");
+ case SIGBUS:
+ throw SignalException("Bus error");
+ case SIGSEGV:
+ throw SignalException("Segmentation violation");
+ case SIGSYS:
+ throw SignalException("Invalid system call");
+ default:
+ throw SignalException(NumberFormatter::formatHex(sig));
+ }
+}
+
+
+void SignalHandler::install()
+{
+#ifndef POCO_NO_SIGNAL_HANDLER
+ struct sigaction sa;
+ sa.sa_handler = handleSignal;
+ sa.sa_flags = 0;
+ sigemptyset(&sa.sa_mask);
+ sigaction(SIGILL, &sa, 0);
+ sigaction(SIGBUS, &sa, 0);
+ sigaction(SIGSEGV, &sa, 0);
+ sigaction(SIGSYS, &sa, 0);
+#endif
+}
+
+
+void SignalHandler::handleSignal(int sig)
+{
+ JumpBufferVec& jb = jumpBufferVec();
+ if (!jb.empty())
+ siglongjmp(jb.back().buf, sig);
+
+ // Abort if no jump buffer registered
+ std::abort();
+}
+
+
+SignalHandler::JumpBufferVec& SignalHandler::jumpBufferVec()
+{
+ ThreadImpl* pThread = ThreadImpl::currentImpl();
+ if (pThread)
+ return pThread->_jumpBufferVec;
+ else
+ return _jumpBufferVec;
+}
+
+
+} // namespace Poco
+
+
+#endif // POCO_OS_FAMILY_UNIX
diff --git a/contrib/libs/poco/Foundation/src/SimpleFileChannel.cpp b/contrib/libs/poco/Foundation/src/SimpleFileChannel.cpp
index 37dd894f88..5cfae2f40f 100644
--- a/contrib/libs/poco/Foundation/src/SimpleFileChannel.cpp
+++ b/contrib/libs/poco/Foundation/src/SimpleFileChannel.cpp
@@ -1,227 +1,227 @@
-//
-// SimpleFileChannel.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: SimpleFileChannel
-//
-// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/SimpleFileChannel.h"
-#include "Poco/LogFile.h"
-#include "Poco/File.h"
-#include "Poco/Message.h"
-#include "Poco/Exception.h"
-#include "Poco/Ascii.h"
-#include "Poco/String.h"
-
-
-namespace Poco {
-
-
-const std::string SimpleFileChannel::PROP_PATH = "path";
-const std::string SimpleFileChannel::PROP_SECONDARYPATH = "secondaryPath";
-const std::string SimpleFileChannel::PROP_ROTATION = "rotation";
-const std::string SimpleFileChannel::PROP_FLUSH = "flush";
-
-
-SimpleFileChannel::SimpleFileChannel():
- _limit(0),
- _flush(true),
- _pFile(0)
-{
-}
-
-
-SimpleFileChannel::SimpleFileChannel(const std::string& rPath):
- _path(rPath),
- _secondaryPath(rPath + ".0"),
- _limit(0),
- _flush(true),
- _pFile(0)
-{
-}
-
-
-SimpleFileChannel::~SimpleFileChannel()
-{
- try
- {
- close();
- }
- catch (...)
- {
- poco_unexpected();
- }
-}
-
-
-void SimpleFileChannel::open()
-{
- FastMutex::ScopedLock lock(_mutex);
-
- if (!_pFile)
- {
- File primary(_path);
- File secondary(_secondaryPath);
- Timestamp pt = primary.exists() ? primary.getLastModified() : 0;
- Timestamp st = secondary.exists() ? secondary.getLastModified() : 0;
- std::string pathString;
- if (pt >= st)
- pathString = _path;
- else
- pathString = _secondaryPath;
- _pFile = new LogFile(pathString);
- }
-}
-
-
-void SimpleFileChannel::close()
-{
- FastMutex::ScopedLock lock(_mutex);
-
- delete _pFile;
- _pFile = 0;
-}
-
-
-void SimpleFileChannel::log(const Message& msg)
-{
- open();
-
- FastMutex::ScopedLock lock(_mutex);
-
- if (_limit > 0 && _pFile->size() >= _limit)
- {
- rotate();
- }
- _pFile->write(msg.getText(), _flush);
-}
-
-
-void SimpleFileChannel::setProperty(const std::string& name, const std::string& value)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- if (name == PROP_PATH)
- {
- _path = value;
- if (_secondaryPath.empty())
- _secondaryPath = _path + ".0";
- }
- else if (name == PROP_SECONDARYPATH)
- _secondaryPath = value;
- else if (name == PROP_ROTATION)
- setRotation(value);
- else if (name == PROP_FLUSH)
- setFlush(value);
- else
- Channel::setProperty(name, value);
-}
-
-
-std::string SimpleFileChannel::getProperty(const std::string& name) const
-{
- if (name == PROP_PATH)
- return _path;
- else if (name == PROP_SECONDARYPATH)
- return _secondaryPath;
- else if (name == PROP_ROTATION)
- return _rotation;
- else if (name == PROP_FLUSH)
- return std::string(_flush ? "true" : "false");
- else
- return Channel::getProperty(name);
-}
-
-
-Timestamp SimpleFileChannel::creationDate() const
-{
- if (_pFile)
- return _pFile->creationDate();
- else
- return 0;
-}
-
-
-UInt64 SimpleFileChannel::size() const
-{
- if (_pFile)
- return _pFile->size();
- else
- return 0;
-}
-
-
-const std::string& SimpleFileChannel::path() const
-{
- return _path;
-}
-
-
-const std::string& SimpleFileChannel::secondaryPath() const
-{
- return _secondaryPath;
-}
-
-
-void SimpleFileChannel::setRotation(const std::string& rotation)
-{
- std::string::const_iterator it = rotation.begin();
- std::string::const_iterator end = rotation.end();
- UInt64 n = 0;
- while (it != end && Ascii::isSpace(*it)) ++it;
- while (it != end && Ascii::isDigit(*it)) { n *= 10; n += *it++ - '0'; }
- while (it != end && Ascii::isSpace(*it)) ++it;
- std::string unit;
- while (it != end && Ascii::isAlpha(*it)) unit += *it++;
-
- if (unit == "K")
- _limit = n*1024;
- else if (unit == "M")
- _limit = n*1024*1024;
- else if (unit.empty())
- _limit = n;
- else if (unit == "never")
- _limit = 0;
- else
- throw InvalidArgumentException("rotation", rotation);
- _rotation = rotation;
-}
-
-
-void SimpleFileChannel::setFlush(const std::string& flush)
-{
- _flush = icompare(flush, "true") == 0;
-}
-
-
-void SimpleFileChannel::rotate()
-{
- std::string newPath;
- if (_pFile->path() == _path)
- newPath = _secondaryPath;
- else
- newPath = _path;
- File f(newPath);
- if (f.exists())
- {
- try
- {
- f.remove();
- }
- catch (...)
- {
- }
- }
- delete _pFile;
- _pFile = new LogFile(newPath);
-}
-
-
-} // namespace Poco
+//
+// SimpleFileChannel.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: SimpleFileChannel
+//
+// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/SimpleFileChannel.h"
+#include "Poco/LogFile.h"
+#include "Poco/File.h"
+#include "Poco/Message.h"
+#include "Poco/Exception.h"
+#include "Poco/Ascii.h"
+#include "Poco/String.h"
+
+
+namespace Poco {
+
+
+const std::string SimpleFileChannel::PROP_PATH = "path";
+const std::string SimpleFileChannel::PROP_SECONDARYPATH = "secondaryPath";
+const std::string SimpleFileChannel::PROP_ROTATION = "rotation";
+const std::string SimpleFileChannel::PROP_FLUSH = "flush";
+
+
+SimpleFileChannel::SimpleFileChannel():
+ _limit(0),
+ _flush(true),
+ _pFile(0)
+{
+}
+
+
+SimpleFileChannel::SimpleFileChannel(const std::string& rPath):
+ _path(rPath),
+ _secondaryPath(rPath + ".0"),
+ _limit(0),
+ _flush(true),
+ _pFile(0)
+{
+}
+
+
+SimpleFileChannel::~SimpleFileChannel()
+{
+ try
+ {
+ close();
+ }
+ catch (...)
+ {
+ poco_unexpected();
+ }
+}
+
+
+void SimpleFileChannel::open()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (!_pFile)
+ {
+ File primary(_path);
+ File secondary(_secondaryPath);
+ Timestamp pt = primary.exists() ? primary.getLastModified() : 0;
+ Timestamp st = secondary.exists() ? secondary.getLastModified() : 0;
+ std::string pathString;
+ if (pt >= st)
+ pathString = _path;
+ else
+ pathString = _secondaryPath;
+ _pFile = new LogFile(pathString);
+ }
+}
+
+
+void SimpleFileChannel::close()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ delete _pFile;
+ _pFile = 0;
+}
+
+
+void SimpleFileChannel::log(const Message& msg)
+{
+ open();
+
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (_limit > 0 && _pFile->size() >= _limit)
+ {
+ rotate();
+ }
+ _pFile->write(msg.getText(), _flush);
+}
+
+
+void SimpleFileChannel::setProperty(const std::string& name, const std::string& value)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (name == PROP_PATH)
+ {
+ _path = value;
+ if (_secondaryPath.empty())
+ _secondaryPath = _path + ".0";
+ }
+ else if (name == PROP_SECONDARYPATH)
+ _secondaryPath = value;
+ else if (name == PROP_ROTATION)
+ setRotation(value);
+ else if (name == PROP_FLUSH)
+ setFlush(value);
+ else
+ Channel::setProperty(name, value);
+}
+
+
+std::string SimpleFileChannel::getProperty(const std::string& name) const
+{
+ if (name == PROP_PATH)
+ return _path;
+ else if (name == PROP_SECONDARYPATH)
+ return _secondaryPath;
+ else if (name == PROP_ROTATION)
+ return _rotation;
+ else if (name == PROP_FLUSH)
+ return std::string(_flush ? "true" : "false");
+ else
+ return Channel::getProperty(name);
+}
+
+
+Timestamp SimpleFileChannel::creationDate() const
+{
+ if (_pFile)
+ return _pFile->creationDate();
+ else
+ return 0;
+}
+
+
+UInt64 SimpleFileChannel::size() const
+{
+ if (_pFile)
+ return _pFile->size();
+ else
+ return 0;
+}
+
+
+const std::string& SimpleFileChannel::path() const
+{
+ return _path;
+}
+
+
+const std::string& SimpleFileChannel::secondaryPath() const
+{
+ return _secondaryPath;
+}
+
+
+void SimpleFileChannel::setRotation(const std::string& rotation)
+{
+ std::string::const_iterator it = rotation.begin();
+ std::string::const_iterator end = rotation.end();
+ UInt64 n = 0;
+ while (it != end && Ascii::isSpace(*it)) ++it;
+ while (it != end && Ascii::isDigit(*it)) { n *= 10; n += *it++ - '0'; }
+ while (it != end && Ascii::isSpace(*it)) ++it;
+ std::string unit;
+ while (it != end && Ascii::isAlpha(*it)) unit += *it++;
+
+ if (unit == "K")
+ _limit = n*1024;
+ else if (unit == "M")
+ _limit = n*1024*1024;
+ else if (unit.empty())
+ _limit = n;
+ else if (unit == "never")
+ _limit = 0;
+ else
+ throw InvalidArgumentException("rotation", rotation);
+ _rotation = rotation;
+}
+
+
+void SimpleFileChannel::setFlush(const std::string& flush)
+{
+ _flush = icompare(flush, "true") == 0;
+}
+
+
+void SimpleFileChannel::rotate()
+{
+ std::string newPath;
+ if (_pFile->path() == _path)
+ newPath = _secondaryPath;
+ else
+ newPath = _path;
+ File f(newPath);
+ if (f.exists())
+ {
+ try
+ {
+ f.remove();
+ }
+ catch (...)
+ {
+ }
+ }
+ delete _pFile;
+ _pFile = new LogFile(newPath);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/SortedDirectoryIterator.cpp b/contrib/libs/poco/Foundation/src/SortedDirectoryIterator.cpp
index 563205e5b8..813aeae010 100644
--- a/contrib/libs/poco/Foundation/src/SortedDirectoryIterator.cpp
+++ b/contrib/libs/poco/Foundation/src/SortedDirectoryIterator.cpp
@@ -1,122 +1,122 @@
-//
-// SortedDirectoryIterator.cpp
-//
-// Library: Foundation
-// Package: Filesystem
-// Module: DirectoryIterator
-//
-// Copyright (c) 2004-2012, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-#include "Poco/SortedDirectoryIterator.h"
-#include <algorithm>
-
-
-namespace Poco {
-
-
-SortedDirectoryIterator::SortedDirectoryIterator()
- : DirectoryIterator(), _is_finished(true)
-{
-}
-
-
-SortedDirectoryIterator::SortedDirectoryIterator(const std::string& rPath)
- : DirectoryIterator(rPath), _is_finished(false)
-{
- scan();
- next();
-}
-
-
-SortedDirectoryIterator::SortedDirectoryIterator(const DirectoryIterator& iterator)
- : DirectoryIterator(iterator), _is_finished(false)
-{
- scan();
- next();
-}
-
-
-SortedDirectoryIterator::SortedDirectoryIterator(const File& file)
- : DirectoryIterator(file), _is_finished(false)
-{
- scan();
- next();
-}
-
-
-SortedDirectoryIterator::SortedDirectoryIterator(const Path& rPath)
- : DirectoryIterator(rPath), _is_finished(false)
-{
- scan();
- next();
-}
-
-
-SortedDirectoryIterator::~SortedDirectoryIterator()
-{
-}
-
-
-SortedDirectoryIterator& SortedDirectoryIterator::operator ++()
-{
- if (!_is_finished)
- {
- next();
- }
- return *this;
-}
-
-
-void SortedDirectoryIterator::scan()
-{
- DirectoryIterator end_it;
- while (*this != end_it)
- {
- bool isDir = false;
- try
- {
- isDir = (*this)->isDirectory();
- }
- catch (...) {}
- if (isDir)
- _directories.push_back(_path.toString());
- else
- _files.push_back(_path.toString());
-
- DirectoryIterator::operator++();
- }
-
- std::sort(_directories.begin(), _directories.end());
- std::sort(_files.begin(), _files.end());
-}
-
-
-void SortedDirectoryIterator::next()
-{
- DirectoryIterator end_it;
- if (!_directories.empty())
- {
- _path.assign(_directories.front());
- _directories.pop_front();
- _file = _path;
- }
- else if (!_files.empty())
- {
- _path.assign(_files.front());
- _files.pop_front();
- _file = _path;
- }
- else
- {
- _is_finished = true;
- _path = end_it.path();
- _file = _path;
- }
-}
-
-
-} // namespace Poco
+//
+// SortedDirectoryIterator.cpp
+//
+// Library: Foundation
+// Package: Filesystem
+// Module: DirectoryIterator
+//
+// Copyright (c) 2004-2012, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+#include "Poco/SortedDirectoryIterator.h"
+#include <algorithm>
+
+
+namespace Poco {
+
+
+SortedDirectoryIterator::SortedDirectoryIterator()
+ : DirectoryIterator(), _is_finished(true)
+{
+}
+
+
+SortedDirectoryIterator::SortedDirectoryIterator(const std::string& rPath)
+ : DirectoryIterator(rPath), _is_finished(false)
+{
+ scan();
+ next();
+}
+
+
+SortedDirectoryIterator::SortedDirectoryIterator(const DirectoryIterator& iterator)
+ : DirectoryIterator(iterator), _is_finished(false)
+{
+ scan();
+ next();
+}
+
+
+SortedDirectoryIterator::SortedDirectoryIterator(const File& file)
+ : DirectoryIterator(file), _is_finished(false)
+{
+ scan();
+ next();
+}
+
+
+SortedDirectoryIterator::SortedDirectoryIterator(const Path& rPath)
+ : DirectoryIterator(rPath), _is_finished(false)
+{
+ scan();
+ next();
+}
+
+
+SortedDirectoryIterator::~SortedDirectoryIterator()
+{
+}
+
+
+SortedDirectoryIterator& SortedDirectoryIterator::operator ++()
+{
+ if (!_is_finished)
+ {
+ next();
+ }
+ return *this;
+}
+
+
+void SortedDirectoryIterator::scan()
+{
+ DirectoryIterator end_it;
+ while (*this != end_it)
+ {
+ bool isDir = false;
+ try
+ {
+ isDir = (*this)->isDirectory();
+ }
+ catch (...) {}
+ if (isDir)
+ _directories.push_back(_path.toString());
+ else
+ _files.push_back(_path.toString());
+
+ DirectoryIterator::operator++();
+ }
+
+ std::sort(_directories.begin(), _directories.end());
+ std::sort(_files.begin(), _files.end());
+}
+
+
+void SortedDirectoryIterator::next()
+{
+ DirectoryIterator end_it;
+ if (!_directories.empty())
+ {
+ _path.assign(_directories.front());
+ _directories.pop_front();
+ _file = _path;
+ }
+ else if (!_files.empty())
+ {
+ _path.assign(_files.front());
+ _files.pop_front();
+ _file = _path;
+ }
+ else
+ {
+ _is_finished = true;
+ _path = end_it.path();
+ _file = _path;
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/SplitterChannel.cpp b/contrib/libs/poco/Foundation/src/SplitterChannel.cpp
index 69ba36a240..a0bc69919d 100644
--- a/contrib/libs/poco/Foundation/src/SplitterChannel.cpp
+++ b/contrib/libs/poco/Foundation/src/SplitterChannel.cpp
@@ -1,113 +1,113 @@
-//
-// SplitterChannel.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: SplitterChannel
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/SplitterChannel.h"
-#include "Poco/LoggingRegistry.h"
-#include "Poco/StringTokenizer.h"
-
-
-namespace Poco {
-
-
-SplitterChannel::SplitterChannel()
-{
-}
-
-
-SplitterChannel::~SplitterChannel()
-{
- try
- {
- close();
- }
- catch (...)
- {
- poco_unexpected();
- }
-}
-
-
-void SplitterChannel::addChannel(Channel* pChannel)
-{
- poco_check_ptr (pChannel);
-
- FastMutex::ScopedLock lock(_mutex);
-
- pChannel->duplicate();
- _channels.push_back(pChannel);
-}
-
-
-void SplitterChannel::removeChannel(Channel* pChannel)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- for (ChannelVec::iterator it = _channels.begin(); it != _channels.end(); ++it)
- {
- if (*it == pChannel)
- {
- pChannel->release();
- _channels.erase(it);
- break;
- }
- }
-}
-
-
-void SplitterChannel::setProperty(const std::string& name, const std::string& value)
-{
- if (name.compare(0, 7, "channel") == 0)
- {
- StringTokenizer tokenizer(value, ",;", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
- for (StringTokenizer::Iterator it = tokenizer.begin(); it != tokenizer.end(); ++it)
- {
- addChannel(LoggingRegistry::defaultRegistry().channelForName(*it));
- }
- }
- else Channel::setProperty(name, value);
-}
-
-
-void SplitterChannel::log(const Message& msg)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- for (ChannelVec::iterator it = _channels.begin(); it != _channels.end(); ++it)
- {
- (*it)->log(msg);
- }
-}
-
-
-void SplitterChannel::close()
-{
- FastMutex::ScopedLock lock(_mutex);
-
- for (ChannelVec::iterator it = _channels.begin(); it != _channels.end(); ++it)
- {
- (*it)->release();
- }
- _channels.clear();
-}
-
-
-int SplitterChannel::count() const
-{
- FastMutex::ScopedLock lock(_mutex);
-
- return (int) _channels.size();
-}
-
-
-} // namespace Poco
+//
+// SplitterChannel.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: SplitterChannel
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/SplitterChannel.h"
+#include "Poco/LoggingRegistry.h"
+#include "Poco/StringTokenizer.h"
+
+
+namespace Poco {
+
+
+SplitterChannel::SplitterChannel()
+{
+}
+
+
+SplitterChannel::~SplitterChannel()
+{
+ try
+ {
+ close();
+ }
+ catch (...)
+ {
+ poco_unexpected();
+ }
+}
+
+
+void SplitterChannel::addChannel(Channel* pChannel)
+{
+ poco_check_ptr (pChannel);
+
+ FastMutex::ScopedLock lock(_mutex);
+
+ pChannel->duplicate();
+ _channels.push_back(pChannel);
+}
+
+
+void SplitterChannel::removeChannel(Channel* pChannel)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ for (ChannelVec::iterator it = _channels.begin(); it != _channels.end(); ++it)
+ {
+ if (*it == pChannel)
+ {
+ pChannel->release();
+ _channels.erase(it);
+ break;
+ }
+ }
+}
+
+
+void SplitterChannel::setProperty(const std::string& name, const std::string& value)
+{
+ if (name.compare(0, 7, "channel") == 0)
+ {
+ StringTokenizer tokenizer(value, ",;", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
+ for (StringTokenizer::Iterator it = tokenizer.begin(); it != tokenizer.end(); ++it)
+ {
+ addChannel(LoggingRegistry::defaultRegistry().channelForName(*it));
+ }
+ }
+ else Channel::setProperty(name, value);
+}
+
+
+void SplitterChannel::log(const Message& msg)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ for (ChannelVec::iterator it = _channels.begin(); it != _channels.end(); ++it)
+ {
+ (*it)->log(msg);
+ }
+}
+
+
+void SplitterChannel::close()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ for (ChannelVec::iterator it = _channels.begin(); it != _channels.end(); ++it)
+ {
+ (*it)->release();
+ }
+ _channels.clear();
+}
+
+
+int SplitterChannel::count() const
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ return (int) _channels.size();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Stopwatch.cpp b/contrib/libs/poco/Foundation/src/Stopwatch.cpp
index 4ce02e577b..b793954d76 100644
--- a/contrib/libs/poco/Foundation/src/Stopwatch.cpp
+++ b/contrib/libs/poco/Foundation/src/Stopwatch.cpp
@@ -1,60 +1,60 @@
-//
-// Stopwatch.cpp
-//
-// Library: Foundation
-// Package: DateTime
-// Module: Stopwatch
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Stopwatch.h"
-
-
-namespace Poco {
-
-
-Stopwatch::Stopwatch(): _elapsed(0), _running(false)
-{
-}
-
-
-Stopwatch::~Stopwatch()
-{
-}
-
-
-Clock::ClockDiff Stopwatch::elapsed() const
-{
- if (_running)
- {
- Clock current;
- return _elapsed + (current - _start);
- }
- else
- {
- return _elapsed;
- }
-}
-
-
-void Stopwatch::reset()
-{
- _elapsed = 0;
- _running = false;
-}
-
-
-void Stopwatch::restart()
-{
- _elapsed = 0;
- _start.update();
- _running = true;
-}
-
-
-} // namespace Poco
+//
+// Stopwatch.cpp
+//
+// Library: Foundation
+// Package: DateTime
+// Module: Stopwatch
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Stopwatch.h"
+
+
+namespace Poco {
+
+
+Stopwatch::Stopwatch(): _elapsed(0), _running(false)
+{
+}
+
+
+Stopwatch::~Stopwatch()
+{
+}
+
+
+Clock::ClockDiff Stopwatch::elapsed() const
+{
+ if (_running)
+ {
+ Clock current;
+ return _elapsed + (current - _start);
+ }
+ else
+ {
+ return _elapsed;
+ }
+}
+
+
+void Stopwatch::reset()
+{
+ _elapsed = 0;
+ _running = false;
+}
+
+
+void Stopwatch::restart()
+{
+ _elapsed = 0;
+ _start.update();
+ _running = true;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/StreamChannel.cpp b/contrib/libs/poco/Foundation/src/StreamChannel.cpp
index 817c047a65..dccf519d68 100644
--- a/contrib/libs/poco/Foundation/src/StreamChannel.cpp
+++ b/contrib/libs/poco/Foundation/src/StreamChannel.cpp
@@ -1,40 +1,40 @@
-//
-// StreamChannel.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: StreamChannel
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/StreamChannel.h"
-#include "Poco/Message.h"
-
-
-namespace Poco {
-
-
-StreamChannel::StreamChannel(std::ostream& str): _str(str)
-{
-}
-
-
-StreamChannel::~StreamChannel()
-{
-}
-
-
-void StreamChannel::log(const Message& msg)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- _str << msg.getText() << std::endl;
-}
-
-
-} // namespace Poco
+//
+// StreamChannel.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: StreamChannel
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/StreamChannel.h"
+#include "Poco/Message.h"
+
+
+namespace Poco {
+
+
+StreamChannel::StreamChannel(std::ostream& str): _str(str)
+{
+}
+
+
+StreamChannel::~StreamChannel()
+{
+}
+
+
+void StreamChannel::log(const Message& msg)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ _str << msg.getText() << std::endl;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/StreamConverter.cpp b/contrib/libs/poco/Foundation/src/StreamConverter.cpp
index 2677ab8c9b..aa626fbae4 100644
--- a/contrib/libs/poco/Foundation/src/StreamConverter.cpp
+++ b/contrib/libs/poco/Foundation/src/StreamConverter.cpp
@@ -1,192 +1,192 @@
-//
-// StreamConverter.cpp
-//
-// Library: Foundation
-// Package: Text
-// Module: StreamConverter
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/StreamConverter.h"
-#include "Poco/TextEncoding.h"
-
-
-namespace Poco {
-
-
-StreamConverterBuf::StreamConverterBuf(std::istream& istr, const TextEncoding& inEncoding, const TextEncoding& outEncoding, int defaultChar):
- _pIstr(&istr),
- _pOstr(0),
- _inEncoding(inEncoding),
- _outEncoding(outEncoding),
- _defaultChar(defaultChar),
- _sequenceLength(0),
- _pos(0),
- _errors(0)
-{
-}
-
-
-StreamConverterBuf::StreamConverterBuf(std::ostream& ostr, const TextEncoding& inEncoding, const TextEncoding& outEncoding, int defaultChar):
- _pIstr(0),
- _pOstr(&ostr),
- _inEncoding(inEncoding),
- _outEncoding(outEncoding),
- _defaultChar(defaultChar),
- _sequenceLength(0),
- _pos(0),
- _errors(0)
-{
-}
-
-
-StreamConverterBuf::~StreamConverterBuf()
-{
-}
-
-
-int StreamConverterBuf::readFromDevice()
-{
- poco_assert_dbg (_pIstr);
-
- if (_pos < _sequenceLength) return _buffer[_pos++];
-
- _pos = 0;
- _sequenceLength = 0;
- int c = _pIstr->get();
- if (c == -1) return -1;
-
- poco_assert (c < 256);
- int uc;
- _buffer [0] = (unsigned char) c;
- int n = _inEncoding.queryConvert(_buffer, 1);
- int read = 1;
-
- while (-1 > n)
- {
- poco_assert_dbg(-n <= sizeof(_buffer));
- _pIstr->read((char*) _buffer + read, -n - read);
- read = -n;
- n = _inEncoding.queryConvert(_buffer, -n);
- }
-
- if (-1 >= n)
- {
- uc = _defaultChar;
- ++_errors;
- }
- else
- {
- uc = n;
- }
-
- _sequenceLength = _outEncoding.convert(uc, _buffer, sizeof(_buffer));
- if (_sequenceLength == 0)
- _sequenceLength = _outEncoding.convert(_defaultChar, _buffer, sizeof(_buffer));
- if (_sequenceLength == 0)
- return -1;
- else
- return _buffer[_pos++];
-}
-
-
-int StreamConverterBuf::writeToDevice(char c)
-{
- poco_assert_dbg (_pOstr);
-
- _buffer[_pos++] = (unsigned char) c;
- if (_sequenceLength == 0 || _sequenceLength == _pos)
- {
- int n = _inEncoding.queryConvert(_buffer, _pos);
- if (-1 <= n)
- {
- int uc = n;
- if (-1 == n)
- {
- ++_errors;
- return -1;
- }
- int number = _outEncoding.convert(uc, _buffer, sizeof(_buffer));
- if (number == 0) number = _outEncoding.convert(_defaultChar, _buffer, sizeof(_buffer));
- poco_assert_dbg (number <= sizeof(_buffer));
- _pOstr->write((char*) _buffer, number);
- _sequenceLength = 0;
- _pos = 0;
- }
- else
- {
- _sequenceLength = -n;
- }
- }
-
- return charToInt(c);
-}
-
-
-int StreamConverterBuf::errors() const
-{
- return _errors;
-}
-
-
-StreamConverterIOS::StreamConverterIOS(std::istream& istr, const TextEncoding& inEncoding, const TextEncoding& outEncoding, int defaultChar):
- _buf(istr, inEncoding, outEncoding, defaultChar)
-{
- poco_ios_init(&_buf);
-}
-
-
-StreamConverterIOS::StreamConverterIOS(std::ostream& ostr, const TextEncoding& inEncoding, const TextEncoding& outEncoding, int defaultChar):
- _buf(ostr, inEncoding, outEncoding, defaultChar)
-{
- poco_ios_init(&_buf);
-}
-
-
-StreamConverterIOS::~StreamConverterIOS()
-{
-}
-
-
-StreamConverterBuf* StreamConverterIOS::rdbuf()
-{
- return &_buf;
-}
-
-
-int StreamConverterIOS::errors() const
-{
- return _buf.errors();
-}
-
-
-InputStreamConverter::InputStreamConverter(std::istream& istr, const TextEncoding& inEncoding, const TextEncoding& outEncoding, int defaultChar):
- StreamConverterIOS(istr, inEncoding, outEncoding, defaultChar),
- std::istream(&_buf)
-{
-}
-
-
-InputStreamConverter::~InputStreamConverter()
-{
-}
-
-
-OutputStreamConverter::OutputStreamConverter(std::ostream& ostr, const TextEncoding& inEncoding, const TextEncoding& outEncoding, int defaultChar):
- StreamConverterIOS(ostr, inEncoding, outEncoding, defaultChar),
- std::ostream(&_buf)
-{
-}
-
-
-OutputStreamConverter::~OutputStreamConverter()
-{
-}
-
-
-} // namespace Poco
+//
+// StreamConverter.cpp
+//
+// Library: Foundation
+// Package: Text
+// Module: StreamConverter
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/StreamConverter.h"
+#include "Poco/TextEncoding.h"
+
+
+namespace Poco {
+
+
+StreamConverterBuf::StreamConverterBuf(std::istream& istr, const TextEncoding& inEncoding, const TextEncoding& outEncoding, int defaultChar):
+ _pIstr(&istr),
+ _pOstr(0),
+ _inEncoding(inEncoding),
+ _outEncoding(outEncoding),
+ _defaultChar(defaultChar),
+ _sequenceLength(0),
+ _pos(0),
+ _errors(0)
+{
+}
+
+
+StreamConverterBuf::StreamConverterBuf(std::ostream& ostr, const TextEncoding& inEncoding, const TextEncoding& outEncoding, int defaultChar):
+ _pIstr(0),
+ _pOstr(&ostr),
+ _inEncoding(inEncoding),
+ _outEncoding(outEncoding),
+ _defaultChar(defaultChar),
+ _sequenceLength(0),
+ _pos(0),
+ _errors(0)
+{
+}
+
+
+StreamConverterBuf::~StreamConverterBuf()
+{
+}
+
+
+int StreamConverterBuf::readFromDevice()
+{
+ poco_assert_dbg (_pIstr);
+
+ if (_pos < _sequenceLength) return _buffer[_pos++];
+
+ _pos = 0;
+ _sequenceLength = 0;
+ int c = _pIstr->get();
+ if (c == -1) return -1;
+
+ poco_assert (c < 256);
+ int uc;
+ _buffer [0] = (unsigned char) c;
+ int n = _inEncoding.queryConvert(_buffer, 1);
+ int read = 1;
+
+ while (-1 > n)
+ {
+ poco_assert_dbg(-n <= sizeof(_buffer));
+ _pIstr->read((char*) _buffer + read, -n - read);
+ read = -n;
+ n = _inEncoding.queryConvert(_buffer, -n);
+ }
+
+ if (-1 >= n)
+ {
+ uc = _defaultChar;
+ ++_errors;
+ }
+ else
+ {
+ uc = n;
+ }
+
+ _sequenceLength = _outEncoding.convert(uc, _buffer, sizeof(_buffer));
+ if (_sequenceLength == 0)
+ _sequenceLength = _outEncoding.convert(_defaultChar, _buffer, sizeof(_buffer));
+ if (_sequenceLength == 0)
+ return -1;
+ else
+ return _buffer[_pos++];
+}
+
+
+int StreamConverterBuf::writeToDevice(char c)
+{
+ poco_assert_dbg (_pOstr);
+
+ _buffer[_pos++] = (unsigned char) c;
+ if (_sequenceLength == 0 || _sequenceLength == _pos)
+ {
+ int n = _inEncoding.queryConvert(_buffer, _pos);
+ if (-1 <= n)
+ {
+ int uc = n;
+ if (-1 == n)
+ {
+ ++_errors;
+ return -1;
+ }
+ int number = _outEncoding.convert(uc, _buffer, sizeof(_buffer));
+ if (number == 0) number = _outEncoding.convert(_defaultChar, _buffer, sizeof(_buffer));
+ poco_assert_dbg (number <= sizeof(_buffer));
+ _pOstr->write((char*) _buffer, number);
+ _sequenceLength = 0;
+ _pos = 0;
+ }
+ else
+ {
+ _sequenceLength = -n;
+ }
+ }
+
+ return charToInt(c);
+}
+
+
+int StreamConverterBuf::errors() const
+{
+ return _errors;
+}
+
+
+StreamConverterIOS::StreamConverterIOS(std::istream& istr, const TextEncoding& inEncoding, const TextEncoding& outEncoding, int defaultChar):
+ _buf(istr, inEncoding, outEncoding, defaultChar)
+{
+ poco_ios_init(&_buf);
+}
+
+
+StreamConverterIOS::StreamConverterIOS(std::ostream& ostr, const TextEncoding& inEncoding, const TextEncoding& outEncoding, int defaultChar):
+ _buf(ostr, inEncoding, outEncoding, defaultChar)
+{
+ poco_ios_init(&_buf);
+}
+
+
+StreamConverterIOS::~StreamConverterIOS()
+{
+}
+
+
+StreamConverterBuf* StreamConverterIOS::rdbuf()
+{
+ return &_buf;
+}
+
+
+int StreamConverterIOS::errors() const
+{
+ return _buf.errors();
+}
+
+
+InputStreamConverter::InputStreamConverter(std::istream& istr, const TextEncoding& inEncoding, const TextEncoding& outEncoding, int defaultChar):
+ StreamConverterIOS(istr, inEncoding, outEncoding, defaultChar),
+ std::istream(&_buf)
+{
+}
+
+
+InputStreamConverter::~InputStreamConverter()
+{
+}
+
+
+OutputStreamConverter::OutputStreamConverter(std::ostream& ostr, const TextEncoding& inEncoding, const TextEncoding& outEncoding, int defaultChar):
+ StreamConverterIOS(ostr, inEncoding, outEncoding, defaultChar),
+ std::ostream(&_buf)
+{
+}
+
+
+OutputStreamConverter::~OutputStreamConverter()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/StreamCopier.cpp b/contrib/libs/poco/Foundation/src/StreamCopier.cpp
index 6f34cc233a..b231a9736b 100644
--- a/contrib/libs/poco/Foundation/src/StreamCopier.cpp
+++ b/contrib/libs/poco/Foundation/src/StreamCopier.cpp
@@ -1,150 +1,150 @@
-//
-// StreamCopier.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: StreamCopier
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/StreamCopier.h"
-#include "Poco/Buffer.h"
-
-
-namespace Poco {
-
-
-std::streamsize StreamCopier::copyStream(std::istream& istr, std::ostream& ostr, std::size_t bufferSize)
-{
- poco_assert (bufferSize > 0);
-
- Buffer<char> buffer(bufferSize);
- std::streamsize len = 0;
- istr.read(buffer.begin(), bufferSize);
- std::streamsize n = istr.gcount();
- while (n > 0)
- {
- len += n;
- ostr.write(buffer.begin(), n);
- if (istr && ostr)
- {
- istr.read(buffer.begin(), bufferSize);
- n = istr.gcount();
- }
- else n = 0;
- }
- return len;
-}
-
-
-#if defined(POCO_HAVE_INT64)
-Poco::UInt64 StreamCopier::copyStream64(std::istream& istr, std::ostream& ostr, std::size_t bufferSize)
-{
- poco_assert (bufferSize > 0);
-
- Buffer<char> buffer(bufferSize);
- Poco::UInt64 len = 0;
- istr.read(buffer.begin(), bufferSize);
- std::streamsize n = istr.gcount();
- while (n > 0)
- {
- len += n;
- ostr.write(buffer.begin(), n);
- if (istr && ostr)
- {
- istr.read(buffer.begin(), bufferSize);
- n = istr.gcount();
- }
- else n = 0;
- }
- return len;
-}
-#endif
-
-
-std::streamsize StreamCopier::copyToString(std::istream& istr, std::string& str, std::size_t bufferSize)
-{
- poco_assert (bufferSize > 0);
-
- Buffer<char> buffer(bufferSize);
- std::streamsize len = 0;
- istr.read(buffer.begin(), bufferSize);
- std::streamsize n = istr.gcount();
- while (n > 0)
- {
- len += n;
- str.append(buffer.begin(), static_cast<std::string::size_type>(n));
- if (istr)
- {
- istr.read(buffer.begin(), bufferSize);
- n = istr.gcount();
- }
- else n = 0;
- }
- return len;
-}
-
-
-#if defined(POCO_HAVE_INT64)
-Poco::UInt64 StreamCopier::copyToString64(std::istream& istr, std::string& str, std::size_t bufferSize)
-{
- poco_assert (bufferSize > 0);
-
- Buffer<char> buffer(bufferSize);
- Poco::UInt64 len = 0;
- istr.read(buffer.begin(), bufferSize);
- std::streamsize n = istr.gcount();
- while (n > 0)
- {
- len += n;
- str.append(buffer.begin(), static_cast<std::string::size_type>(n));
- if (istr)
- {
- istr.read(buffer.begin(), bufferSize);
- n = istr.gcount();
- }
- else n = 0;
- }
- return len;
-}
-#endif
-
-
-std::streamsize StreamCopier::copyStreamUnbuffered(std::istream& istr, std::ostream& ostr)
-{
- char c = 0;
- std::streamsize len = 0;
- istr.get(c);
- while (istr && ostr)
- {
- ++len;
- ostr.put(c);
- istr.get(c);
- }
- return len;
-}
-
-
-#if defined(POCO_HAVE_INT64)
-Poco::UInt64 StreamCopier::copyStreamUnbuffered64(std::istream& istr, std::ostream& ostr)
-{
- char c = 0;
- Poco::UInt64 len = 0;
- istr.get(c);
- while (istr && ostr)
- {
- ++len;
- ostr.put(c);
- istr.get(c);
- }
- return len;
-}
-#endif
-
-
-} // namespace Poco
+//
+// StreamCopier.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: StreamCopier
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/StreamCopier.h"
+#include "Poco/Buffer.h"
+
+
+namespace Poco {
+
+
+std::streamsize StreamCopier::copyStream(std::istream& istr, std::ostream& ostr, std::size_t bufferSize)
+{
+ poco_assert (bufferSize > 0);
+
+ Buffer<char> buffer(bufferSize);
+ std::streamsize len = 0;
+ istr.read(buffer.begin(), bufferSize);
+ std::streamsize n = istr.gcount();
+ while (n > 0)
+ {
+ len += n;
+ ostr.write(buffer.begin(), n);
+ if (istr && ostr)
+ {
+ istr.read(buffer.begin(), bufferSize);
+ n = istr.gcount();
+ }
+ else n = 0;
+ }
+ return len;
+}
+
+
+#if defined(POCO_HAVE_INT64)
+Poco::UInt64 StreamCopier::copyStream64(std::istream& istr, std::ostream& ostr, std::size_t bufferSize)
+{
+ poco_assert (bufferSize > 0);
+
+ Buffer<char> buffer(bufferSize);
+ Poco::UInt64 len = 0;
+ istr.read(buffer.begin(), bufferSize);
+ std::streamsize n = istr.gcount();
+ while (n > 0)
+ {
+ len += n;
+ ostr.write(buffer.begin(), n);
+ if (istr && ostr)
+ {
+ istr.read(buffer.begin(), bufferSize);
+ n = istr.gcount();
+ }
+ else n = 0;
+ }
+ return len;
+}
+#endif
+
+
+std::streamsize StreamCopier::copyToString(std::istream& istr, std::string& str, std::size_t bufferSize)
+{
+ poco_assert (bufferSize > 0);
+
+ Buffer<char> buffer(bufferSize);
+ std::streamsize len = 0;
+ istr.read(buffer.begin(), bufferSize);
+ std::streamsize n = istr.gcount();
+ while (n > 0)
+ {
+ len += n;
+ str.append(buffer.begin(), static_cast<std::string::size_type>(n));
+ if (istr)
+ {
+ istr.read(buffer.begin(), bufferSize);
+ n = istr.gcount();
+ }
+ else n = 0;
+ }
+ return len;
+}
+
+
+#if defined(POCO_HAVE_INT64)
+Poco::UInt64 StreamCopier::copyToString64(std::istream& istr, std::string& str, std::size_t bufferSize)
+{
+ poco_assert (bufferSize > 0);
+
+ Buffer<char> buffer(bufferSize);
+ Poco::UInt64 len = 0;
+ istr.read(buffer.begin(), bufferSize);
+ std::streamsize n = istr.gcount();
+ while (n > 0)
+ {
+ len += n;
+ str.append(buffer.begin(), static_cast<std::string::size_type>(n));
+ if (istr)
+ {
+ istr.read(buffer.begin(), bufferSize);
+ n = istr.gcount();
+ }
+ else n = 0;
+ }
+ return len;
+}
+#endif
+
+
+std::streamsize StreamCopier::copyStreamUnbuffered(std::istream& istr, std::ostream& ostr)
+{
+ char c = 0;
+ std::streamsize len = 0;
+ istr.get(c);
+ while (istr && ostr)
+ {
+ ++len;
+ ostr.put(c);
+ istr.get(c);
+ }
+ return len;
+}
+
+
+#if defined(POCO_HAVE_INT64)
+Poco::UInt64 StreamCopier::copyStreamUnbuffered64(std::istream& istr, std::ostream& ostr)
+{
+ char c = 0;
+ Poco::UInt64 len = 0;
+ istr.get(c);
+ while (istr && ostr)
+ {
+ ++len;
+ ostr.put(c);
+ istr.get(c);
+ }
+ return len;
+}
+#endif
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/StreamTokenizer.cpp b/contrib/libs/poco/Foundation/src/StreamTokenizer.cpp
index 1b6e936274..15f554ca90 100644
--- a/contrib/libs/poco/Foundation/src/StreamTokenizer.cpp
+++ b/contrib/libs/poco/Foundation/src/StreamTokenizer.cpp
@@ -1,105 +1,105 @@
-//
-// StreamTokenizer.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: StreamTokenizer
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/StreamTokenizer.h"
-
-
-namespace Poco {
-
-
-StreamTokenizer::StreamTokenizer():
- _pIstr(0)
-{
-}
-
-
-StreamTokenizer::StreamTokenizer(std::istream& istr):
- _pIstr(&istr)
-{
-}
-
-
-StreamTokenizer::~StreamTokenizer()
-{
- for (TokenVec::iterator it = _tokens.begin(); it != _tokens.end(); ++it)
- {
- delete it->pToken;
- }
-}
-
-
-void StreamTokenizer::attachToStream(std::istream& istr)
-{
- _pIstr = &istr;
-}
-
-
-void StreamTokenizer::addToken(Token* pToken)
-{
- poco_check_ptr (pToken);
-
- TokenInfo ti;
- ti.pToken = pToken;
- ti.ignore = (pToken->tokenClass() == Token::COMMENT_TOKEN || pToken->tokenClass() == Token::WHITESPACE_TOKEN);
- _tokens.push_back(ti);
-}
-
-
-void StreamTokenizer::addToken(Token* pToken, bool ignore)
-{
- poco_check_ptr (pToken);
-
- TokenInfo ti;
- ti.pToken = pToken;
- ti.ignore = ignore;
- _tokens.push_back(ti);
-}
-
-
-const Token* StreamTokenizer::next()
-{
- poco_check_ptr (_pIstr);
-
- static const int eof = std::char_traits<char>::eof();
-
- int first = _pIstr->get();
- TokenVec::const_iterator it = _tokens.begin();
- while (first != eof && it != _tokens.end())
- {
- const TokenInfo& ti = *it;
- if (ti.pToken->start((char) first, *_pIstr))
- {
- ti.pToken->finish(*_pIstr);
- if (ti.ignore)
- {
- first = _pIstr->get();
- it = _tokens.begin();
- }
- else return ti.pToken;
- }
- else ++it;
- }
- if (first == eof)
- {
- return &_eofToken;
- }
- else
- {
- _invalidToken.start((char) first, *_pIstr);
- return &_invalidToken;
- }
-}
-
-
-} // namespace Poco
+//
+// StreamTokenizer.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: StreamTokenizer
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/StreamTokenizer.h"
+
+
+namespace Poco {
+
+
+StreamTokenizer::StreamTokenizer():
+ _pIstr(0)
+{
+}
+
+
+StreamTokenizer::StreamTokenizer(std::istream& istr):
+ _pIstr(&istr)
+{
+}
+
+
+StreamTokenizer::~StreamTokenizer()
+{
+ for (TokenVec::iterator it = _tokens.begin(); it != _tokens.end(); ++it)
+ {
+ delete it->pToken;
+ }
+}
+
+
+void StreamTokenizer::attachToStream(std::istream& istr)
+{
+ _pIstr = &istr;
+}
+
+
+void StreamTokenizer::addToken(Token* pToken)
+{
+ poco_check_ptr (pToken);
+
+ TokenInfo ti;
+ ti.pToken = pToken;
+ ti.ignore = (pToken->tokenClass() == Token::COMMENT_TOKEN || pToken->tokenClass() == Token::WHITESPACE_TOKEN);
+ _tokens.push_back(ti);
+}
+
+
+void StreamTokenizer::addToken(Token* pToken, bool ignore)
+{
+ poco_check_ptr (pToken);
+
+ TokenInfo ti;
+ ti.pToken = pToken;
+ ti.ignore = ignore;
+ _tokens.push_back(ti);
+}
+
+
+const Token* StreamTokenizer::next()
+{
+ poco_check_ptr (_pIstr);
+
+ static const int eof = std::char_traits<char>::eof();
+
+ int first = _pIstr->get();
+ TokenVec::const_iterator it = _tokens.begin();
+ while (first != eof && it != _tokens.end())
+ {
+ const TokenInfo& ti = *it;
+ if (ti.pToken->start((char) first, *_pIstr))
+ {
+ ti.pToken->finish(*_pIstr);
+ if (ti.ignore)
+ {
+ first = _pIstr->get();
+ it = _tokens.begin();
+ }
+ else return ti.pToken;
+ }
+ else ++it;
+ }
+ if (first == eof)
+ {
+ return &_eofToken;
+ }
+ else
+ {
+ _invalidToken.start((char) first, *_pIstr);
+ return &_invalidToken;
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/String.cpp b/contrib/libs/poco/Foundation/src/String.cpp
index 91b21087ea..a8fcdb271f 100644
--- a/contrib/libs/poco/Foundation/src/String.cpp
+++ b/contrib/libs/poco/Foundation/src/String.cpp
@@ -1,240 +1,240 @@
-//
-// String.h
-//
-// Library: Foundation
-// Package: Core
-// Module: String
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/String.h"
-
-
-namespace Poco {
-
-
-#if defined(POCO_NO_TEMPLATE_ICOMPARE)
-
-
-int icompare(const std::string& str, std::string::size_type pos, std::string::size_type n, std::string::const_iterator it2, std::string::const_iterator end2)
-{
- std::string::size_type sz = str.size();
- if (pos > sz) pos = sz;
- if (pos + n > sz) n = sz - pos;
- std::string::const_iterator it1 = str.begin() + pos;
- std::string::const_iterator end1 = str.begin() + pos + n;
- while (it1 != end1 && it2 != end2)
- {
- std::string::value_type c1 = Ascii::toLower(*it1);
- std::string::value_type c2 = Ascii::toLower(*it2);
- if (c1 < c2)
- return -1;
- else if (c1 > c2)
- return 1;
- ++it1; ++it2;
- }
-
- if (it1 == end1)
- return it2 == end2 ? 0 : -1;
- else
- return 1;
-}
-
-
-int icompare(const std::string& str1, const std::string& str2)
-{
- return icompare(str1, 0, str1.size(), str2.begin(), str2.end());
-}
-
-
-int icompare(const std::string& str1, std::string::size_type n1, const std::string& str2, std::string::size_type n2)
-{
- if (n2 > str2.size()) n2 = str2.size();
- return icompare(str1, 0, n1, str2.begin(), str2.begin() + n2);
-}
-
-
-int icompare(const std::string& str1, std::string::size_type n, const std::string& str2)
-{
- if (n > str2.size()) n = str2.size();
- return icompare(str1, 0, n, str2.begin(), str2.begin() + n);
-}
-
-
-int icompare(const std::string& str1, std::string::size_type pos, std::string::size_type n, const std::string& str2)
-{
- return icompare(str1, pos, n, str2.begin(), str2.end());
-}
-
-
-int icompare(const std::string& str1, std::string::size_type pos1, std::string::size_type n1, const std::string& str2, std::string::size_type pos2, std::string::size_type n2)
-{
- std::string::size_type sz2 = str2.size();
- if (pos2 > sz2) pos2 = sz2;
- if (pos2 + n2 > sz2) n2 = sz2 - pos2;
- return icompare(str1, pos1, n1, str2.begin() + pos2, str2.begin() + pos2 + n2);
-}
-
-
-int icompare(const std::string& str1, std::string::size_type pos1, std::string::size_type n, const std::string& str2, std::string::size_type pos2)
-{
- std::string::size_type sz2 = str2.size();
- if (pos2 > sz2) pos2 = sz2;
- if (pos2 + n > sz2) n = sz2 - pos2;
- return icompare(str1, pos1, n, str2.begin() + pos2, str2.begin() + pos2 + n);
-}
-
-
-int icompare(const std::string& str, std::string::size_type pos, std::string::size_type n, const std::string::value_type* ptr)
-{
- poco_check_ptr (ptr);
- std::string::size_type sz = str.size();
- if (pos > sz) pos = sz;
- if (pos + n > sz) n = sz - pos;
- std::string::const_iterator it = str.begin() + pos;
- std::string::const_iterator end = str.begin() + pos + n;
- while (it != end && *ptr)
- {
- std::string::value_type c1 = Ascii::toLower(*it);
- std::string::value_type c2 = Ascii::toLower(*ptr);
- if (c1 < c2)
- return -1;
- else if (c1 > c2)
- return 1;
- ++it; ++ptr;
- }
-
- if (it == end)
- return *ptr == 0 ? 0 : -1;
- else
- return 1;
-}
-
-
-int icompare(const std::string& str, std::string::size_type pos, const std::string::value_type* ptr)
-{
- return icompare(str, pos, str.size() - pos, ptr);
-}
-
-
-int icompare(const std::string& str, const std::string::value_type* ptr)
-{
- return icompare(str, 0, str.size(), ptr);
-}
-
-
-std::string replace(const std::string& str, const std::string& from, const std::string& to, std::string::size_type start)
-{
- std::string result(str);
- replaceInPlace(result, from, to, start);
- return result;
-}
-
-
-std::string replace(const std::string& str, const std::string::value_type* from, const std::string::value_type* to, std::string::size_type start)
-{
- std::string result(str);
- replaceInPlace(result, from, to, start);
- return result;
-}
-
-
-std::string replace(const std::string& str, const std::string::value_type from, const std::string::value_type to, std::string::size_type start)
-{
- std::string result(str);
- replaceInPlace(result, from, to, start);
- return result;
-}
-
-
-std::string remove(const std::string& str, const std::string::value_type ch, std::string::size_type start)
-{
- std::string result(str);
- replaceInPlace(result, ch, 0, start);
- return result;
-}
-
-
-std::string& replaceInPlace(std::string& str, const std::string& from, const std::string& to, std::string::size_type start)
-{
- poco_assert (from.size() > 0);
-
- std::string result;
- std::string::size_type pos = 0;
- result.append(str, 0, start);
- do
- {
- pos = str.find(from, start);
- if (pos != std::string::npos)
- {
- result.append(str, start, pos - start);
- result.append(to);
- start = pos + from.length();
- }
- else result.append(str, start, str.size() - start);
- }
- while (pos != std::string::npos);
- str.swap(result);
- return str;
-}
-
-
-std::string& replaceInPlace(std::string& str, const std::string::value_type* from, const std::string::value_type* to, std::string::size_type start)
-{
- poco_assert (*from);
-
- std::string result;
- std::string::size_type pos = 0;
- std::string::size_type fromLen = std::strlen(from);
- result.append(str, 0, start);
- do
- {
- pos = str.find(from, start);
- if (pos != std::string::npos)
- {
- result.append(str, start, pos - start);
- result.append(to);
- start = pos + fromLen;
- }
- else result.append(str, start, str.size() - start);
- }
- while (pos != std::string::npos);
- str.swap(result);
- return str;
-}
-
-
-std::string& replaceInPlace(std::string& str, const std::string::value_type from, const std::string::value_type to, std::string::size_type start)
-{
- if (from == to) return str;
-
- std::string::size_type pos = 0;
- do
- {
- pos = str.find(from, start);
- if (pos != std::string::npos)
- {
- if (to) str[pos] = to;
- else str.erase(pos, 1);
- }
- } while (pos != std::string::npos);
-
- return str;
-}
-
-
-std::string& removeInPlace(std::string& str, const std::string::value_type ch, std::string::size_type start)
-{
- return replaceInPlace(str, ch, 0, start);
-}
-
-
-#endif
-
-
-} // namespace Poco
+//
+// String.h
+//
+// Library: Foundation
+// Package: Core
+// Module: String
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/String.h"
+
+
+namespace Poco {
+
+
+#if defined(POCO_NO_TEMPLATE_ICOMPARE)
+
+
+int icompare(const std::string& str, std::string::size_type pos, std::string::size_type n, std::string::const_iterator it2, std::string::const_iterator end2)
+{
+ std::string::size_type sz = str.size();
+ if (pos > sz) pos = sz;
+ if (pos + n > sz) n = sz - pos;
+ std::string::const_iterator it1 = str.begin() + pos;
+ std::string::const_iterator end1 = str.begin() + pos + n;
+ while (it1 != end1 && it2 != end2)
+ {
+ std::string::value_type c1 = Ascii::toLower(*it1);
+ std::string::value_type c2 = Ascii::toLower(*it2);
+ if (c1 < c2)
+ return -1;
+ else if (c1 > c2)
+ return 1;
+ ++it1; ++it2;
+ }
+
+ if (it1 == end1)
+ return it2 == end2 ? 0 : -1;
+ else
+ return 1;
+}
+
+
+int icompare(const std::string& str1, const std::string& str2)
+{
+ return icompare(str1, 0, str1.size(), str2.begin(), str2.end());
+}
+
+
+int icompare(const std::string& str1, std::string::size_type n1, const std::string& str2, std::string::size_type n2)
+{
+ if (n2 > str2.size()) n2 = str2.size();
+ return icompare(str1, 0, n1, str2.begin(), str2.begin() + n2);
+}
+
+
+int icompare(const std::string& str1, std::string::size_type n, const std::string& str2)
+{
+ if (n > str2.size()) n = str2.size();
+ return icompare(str1, 0, n, str2.begin(), str2.begin() + n);
+}
+
+
+int icompare(const std::string& str1, std::string::size_type pos, std::string::size_type n, const std::string& str2)
+{
+ return icompare(str1, pos, n, str2.begin(), str2.end());
+}
+
+
+int icompare(const std::string& str1, std::string::size_type pos1, std::string::size_type n1, const std::string& str2, std::string::size_type pos2, std::string::size_type n2)
+{
+ std::string::size_type sz2 = str2.size();
+ if (pos2 > sz2) pos2 = sz2;
+ if (pos2 + n2 > sz2) n2 = sz2 - pos2;
+ return icompare(str1, pos1, n1, str2.begin() + pos2, str2.begin() + pos2 + n2);
+}
+
+
+int icompare(const std::string& str1, std::string::size_type pos1, std::string::size_type n, const std::string& str2, std::string::size_type pos2)
+{
+ std::string::size_type sz2 = str2.size();
+ if (pos2 > sz2) pos2 = sz2;
+ if (pos2 + n > sz2) n = sz2 - pos2;
+ return icompare(str1, pos1, n, str2.begin() + pos2, str2.begin() + pos2 + n);
+}
+
+
+int icompare(const std::string& str, std::string::size_type pos, std::string::size_type n, const std::string::value_type* ptr)
+{
+ poco_check_ptr (ptr);
+ std::string::size_type sz = str.size();
+ if (pos > sz) pos = sz;
+ if (pos + n > sz) n = sz - pos;
+ std::string::const_iterator it = str.begin() + pos;
+ std::string::const_iterator end = str.begin() + pos + n;
+ while (it != end && *ptr)
+ {
+ std::string::value_type c1 = Ascii::toLower(*it);
+ std::string::value_type c2 = Ascii::toLower(*ptr);
+ if (c1 < c2)
+ return -1;
+ else if (c1 > c2)
+ return 1;
+ ++it; ++ptr;
+ }
+
+ if (it == end)
+ return *ptr == 0 ? 0 : -1;
+ else
+ return 1;
+}
+
+
+int icompare(const std::string& str, std::string::size_type pos, const std::string::value_type* ptr)
+{
+ return icompare(str, pos, str.size() - pos, ptr);
+}
+
+
+int icompare(const std::string& str, const std::string::value_type* ptr)
+{
+ return icompare(str, 0, str.size(), ptr);
+}
+
+
+std::string replace(const std::string& str, const std::string& from, const std::string& to, std::string::size_type start)
+{
+ std::string result(str);
+ replaceInPlace(result, from, to, start);
+ return result;
+}
+
+
+std::string replace(const std::string& str, const std::string::value_type* from, const std::string::value_type* to, std::string::size_type start)
+{
+ std::string result(str);
+ replaceInPlace(result, from, to, start);
+ return result;
+}
+
+
+std::string replace(const std::string& str, const std::string::value_type from, const std::string::value_type to, std::string::size_type start)
+{
+ std::string result(str);
+ replaceInPlace(result, from, to, start);
+ return result;
+}
+
+
+std::string remove(const std::string& str, const std::string::value_type ch, std::string::size_type start)
+{
+ std::string result(str);
+ replaceInPlace(result, ch, 0, start);
+ return result;
+}
+
+
+std::string& replaceInPlace(std::string& str, const std::string& from, const std::string& to, std::string::size_type start)
+{
+ poco_assert (from.size() > 0);
+
+ std::string result;
+ std::string::size_type pos = 0;
+ result.append(str, 0, start);
+ do
+ {
+ pos = str.find(from, start);
+ if (pos != std::string::npos)
+ {
+ result.append(str, start, pos - start);
+ result.append(to);
+ start = pos + from.length();
+ }
+ else result.append(str, start, str.size() - start);
+ }
+ while (pos != std::string::npos);
+ str.swap(result);
+ return str;
+}
+
+
+std::string& replaceInPlace(std::string& str, const std::string::value_type* from, const std::string::value_type* to, std::string::size_type start)
+{
+ poco_assert (*from);
+
+ std::string result;
+ std::string::size_type pos = 0;
+ std::string::size_type fromLen = std::strlen(from);
+ result.append(str, 0, start);
+ do
+ {
+ pos = str.find(from, start);
+ if (pos != std::string::npos)
+ {
+ result.append(str, start, pos - start);
+ result.append(to);
+ start = pos + fromLen;
+ }
+ else result.append(str, start, str.size() - start);
+ }
+ while (pos != std::string::npos);
+ str.swap(result);
+ return str;
+}
+
+
+std::string& replaceInPlace(std::string& str, const std::string::value_type from, const std::string::value_type to, std::string::size_type start)
+{
+ if (from == to) return str;
+
+ std::string::size_type pos = 0;
+ do
+ {
+ pos = str.find(from, start);
+ if (pos != std::string::npos)
+ {
+ if (to) str[pos] = to;
+ else str.erase(pos, 1);
+ }
+ } while (pos != std::string::npos);
+
+ return str;
+}
+
+
+std::string& removeInPlace(std::string& str, const std::string::value_type ch, std::string::size_type start)
+{
+ return replaceInPlace(str, ch, 0, start);
+}
+
+
+#endif
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/StringTokenizer.cpp b/contrib/libs/poco/Foundation/src/StringTokenizer.cpp
index 4c39b5fc51..00e4eff730 100644
--- a/contrib/libs/poco/Foundation/src/StringTokenizer.cpp
+++ b/contrib/libs/poco/Foundation/src/StringTokenizer.cpp
@@ -1,135 +1,135 @@
-//
-// StringTokenizer.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: StringTokenizer
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/StringTokenizer.h"
-#include "Poco/Ascii.h"
-#include <algorithm>
-
-
-namespace Poco {
-
-
-StringTokenizer::StringTokenizer(const std::string& str, const std::string& separators, int options)
-{
- std::string::const_iterator it = str.begin();
- std::string::const_iterator itEnd = str.end();
- std::string token;
- bool doTrim = ((options & TOK_TRIM) != 0);
- bool ignoreEmpty = ((options & TOK_IGNORE_EMPTY) != 0);
- bool lastToken = false;
-
- for (;it != itEnd; ++it)
- {
- if (separators.find(*it) != std::string::npos)
- {
- if (doTrim) trim(token);
- if (!token.empty() || !ignoreEmpty) _tokens.push_back(token);
- if (!ignoreEmpty) lastToken = true;
- token.clear();
- }
- else
- {
- token += *it;
- lastToken = false;
- }
- }
-
- if (!token.empty())
- {
- if (doTrim) trim(token);
- if (!token.empty() || !ignoreEmpty) _tokens.push_back(token);
- }
- else if (lastToken)
- {
- _tokens.push_back(std::string());
- }
-}
-
-
-StringTokenizer::~StringTokenizer()
-{
-}
-
-
-void StringTokenizer::trim(std::string& token)
-{
- std::string::size_type front = 0;
- std::string::size_type back = 0;
- std::string::size_type length = token.length();
- std::string::const_iterator tIt = token.begin();
- std::string::const_iterator tEnd = token.end();
- for (; tIt != tEnd; ++tIt, ++front)
- {
- if (!Ascii::isSpace(*tIt)) break;
- }
- if (tIt != tEnd)
- {
- std::string::const_reverse_iterator tRit = token.rbegin();
- std::string::const_reverse_iterator tRend = token.rend();
- for (; tRit != tRend; ++tRit, ++back)
- {
- if (!Ascii::isSpace(*tRit)) break;
- }
- }
- token = token.substr(front, length - back - front);
-}
-
-
-std::size_t StringTokenizer::count(const std::string& token) const
-{
- std::size_t result = 0;
- TokenVec::const_iterator it = std::find(_tokens.begin(), _tokens.end(), token);
- while (it != _tokens.end())
- {
- result++;
- it = std::find(++it, _tokens.end(), token);
- }
- return result;
-}
-
-
-std::string::size_type StringTokenizer::find(const std::string& token, std::string::size_type pos) const
-{
- TokenVec::const_iterator it = std::find(_tokens.begin() + pos, _tokens.end(), token);
- if (it != _tokens.end())
- {
- return it - _tokens.begin();
- }
- throw NotFoundException(token);
-}
-
-
-bool StringTokenizer::has(const std::string& token) const
-{
- TokenVec::const_iterator it = std::find(_tokens.begin(), _tokens.end(), token);
- return it != _tokens.end();
-}
-
-
-std::size_t StringTokenizer::replace(const std::string& oldToken, const std::string& newToken, std::string::size_type pos)
-{
- std::size_t result = 0;
- TokenVec::iterator it = std::find(_tokens.begin() + pos, _tokens.end(), oldToken);
- while (it != _tokens.end())
- {
- result++;
- *it = newToken;
- it = std::find(++it, _tokens.end(), oldToken);
- }
- return result;
-}
-
-
-} // namespace Poco
-
+//
+// StringTokenizer.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: StringTokenizer
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/StringTokenizer.h"
+#include "Poco/Ascii.h"
+#include <algorithm>
+
+
+namespace Poco {
+
+
+StringTokenizer::StringTokenizer(const std::string& str, const std::string& separators, int options)
+{
+ std::string::const_iterator it = str.begin();
+ std::string::const_iterator itEnd = str.end();
+ std::string token;
+ bool doTrim = ((options & TOK_TRIM) != 0);
+ bool ignoreEmpty = ((options & TOK_IGNORE_EMPTY) != 0);
+ bool lastToken = false;
+
+ for (;it != itEnd; ++it)
+ {
+ if (separators.find(*it) != std::string::npos)
+ {
+ if (doTrim) trim(token);
+ if (!token.empty() || !ignoreEmpty) _tokens.push_back(token);
+ if (!ignoreEmpty) lastToken = true;
+ token.clear();
+ }
+ else
+ {
+ token += *it;
+ lastToken = false;
+ }
+ }
+
+ if (!token.empty())
+ {
+ if (doTrim) trim(token);
+ if (!token.empty() || !ignoreEmpty) _tokens.push_back(token);
+ }
+ else if (lastToken)
+ {
+ _tokens.push_back(std::string());
+ }
+}
+
+
+StringTokenizer::~StringTokenizer()
+{
+}
+
+
+void StringTokenizer::trim(std::string& token)
+{
+ std::string::size_type front = 0;
+ std::string::size_type back = 0;
+ std::string::size_type length = token.length();
+ std::string::const_iterator tIt = token.begin();
+ std::string::const_iterator tEnd = token.end();
+ for (; tIt != tEnd; ++tIt, ++front)
+ {
+ if (!Ascii::isSpace(*tIt)) break;
+ }
+ if (tIt != tEnd)
+ {
+ std::string::const_reverse_iterator tRit = token.rbegin();
+ std::string::const_reverse_iterator tRend = token.rend();
+ for (; tRit != tRend; ++tRit, ++back)
+ {
+ if (!Ascii::isSpace(*tRit)) break;
+ }
+ }
+ token = token.substr(front, length - back - front);
+}
+
+
+std::size_t StringTokenizer::count(const std::string& token) const
+{
+ std::size_t result = 0;
+ TokenVec::const_iterator it = std::find(_tokens.begin(), _tokens.end(), token);
+ while (it != _tokens.end())
+ {
+ result++;
+ it = std::find(++it, _tokens.end(), token);
+ }
+ return result;
+}
+
+
+std::string::size_type StringTokenizer::find(const std::string& token, std::string::size_type pos) const
+{
+ TokenVec::const_iterator it = std::find(_tokens.begin() + pos, _tokens.end(), token);
+ if (it != _tokens.end())
+ {
+ return it - _tokens.begin();
+ }
+ throw NotFoundException(token);
+}
+
+
+bool StringTokenizer::has(const std::string& token) const
+{
+ TokenVec::const_iterator it = std::find(_tokens.begin(), _tokens.end(), token);
+ return it != _tokens.end();
+}
+
+
+std::size_t StringTokenizer::replace(const std::string& oldToken, const std::string& newToken, std::string::size_type pos)
+{
+ std::size_t result = 0;
+ TokenVec::iterator it = std::find(_tokens.begin() + pos, _tokens.end(), oldToken);
+ while (it != _tokens.end())
+ {
+ result++;
+ *it = newToken;
+ it = std::find(++it, _tokens.end(), oldToken);
+ }
+ return result;
+}
+
+
+} // namespace Poco
+
diff --git a/contrib/libs/poco/Foundation/src/SynchronizedObject.cpp b/contrib/libs/poco/Foundation/src/SynchronizedObject.cpp
index 6a42e6594d..8bc9f8ce05 100644
--- a/contrib/libs/poco/Foundation/src/SynchronizedObject.cpp
+++ b/contrib/libs/poco/Foundation/src/SynchronizedObject.cpp
@@ -1,31 +1,31 @@
-//
-// SynchronizedObject.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: SynchronizedObject
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/SynchronizedObject.h"
-
-
-namespace Poco {
-
-
-SynchronizedObject::SynchronizedObject()
-{
-}
-
-
-SynchronizedObject::~SynchronizedObject()
-{
-}
-
-
-} // namespace Poco
+//
+// SynchronizedObject.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: SynchronizedObject
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/SynchronizedObject.h"
+
+
+namespace Poco {
+
+
+SynchronizedObject::SynchronizedObject()
+{
+}
+
+
+SynchronizedObject::~SynchronizedObject()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/SyslogChannel.cpp b/contrib/libs/poco/Foundation/src/SyslogChannel.cpp
index c3d3c15f92..72f750a424 100644
--- a/contrib/libs/poco/Foundation/src/SyslogChannel.cpp
+++ b/contrib/libs/poco/Foundation/src/SyslogChannel.cpp
@@ -1,257 +1,257 @@
-//
-// SyslogChannel.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: SyslogChannel
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/SyslogChannel.h"
-#include "Poco/Message.h"
-#include "Poco/StringTokenizer.h"
-#include <syslog.h>
-
-
-namespace Poco {
-
-
-const std::string SyslogChannel::PROP_NAME = "name";
-const std::string SyslogChannel::PROP_FACILITY = "facility";
-const std::string SyslogChannel::PROP_OPTIONS = "options";
-
-
-SyslogChannel::SyslogChannel():
- _options(SYSLOG_CONS),
- _facility(SYSLOG_USER),
- _open(false)
-{
-}
-
-
-SyslogChannel::SyslogChannel(const std::string& name, int options, int facility):
- _name(name),
- _options(options),
- _facility(facility),
- _open(false)
-{
-}
-
-
-SyslogChannel::~SyslogChannel()
-{
- close();
-}
-
-
-void SyslogChannel::open()
-{
- openlog(_name.c_str(), _options, _facility);
- _open = true;
-}
-
-
-void SyslogChannel::close()
-{
- if (_open)
- {
- closelog();
- _open = false;
- }
-}
-
-
-void SyslogChannel::log(const Message& msg)
-{
- if (!_open) open();
- syslog(getPrio(msg), "%s", msg.getText().c_str());
-}
-
-
-void SyslogChannel::setProperty(const std::string& name, const std::string& value)
-{
- if (name == PROP_NAME)
- {
- _name = value;
- }
- else if (name == PROP_FACILITY)
- {
- if (value == "LOG_KERN")
- _facility = SYSLOG_KERN;
- else if (value == "LOG_USER")
- _facility = SYSLOG_USER;
- else if (value == "LOG_MAIL")
- _facility = SYSLOG_MAIL;
- else if (value == "LOG_DAEMON")
- _facility = SYSLOG_DAEMON;
- else if (value == "LOG_AUTH")
- _facility = SYSLOG_AUTH;
- else if (value == "LOG_AUTHPRIV")
- _facility = SYSLOG_AUTHPRIV;
- else if (value == "LOG_SYSLOG")
- _facility = SYSLOG_SYSLOG;
- else if (value == "LOG_LPR")
- _facility = SYSLOG_LPR;
- else if (value == "LOG_NEWS")
- _facility = SYSLOG_NEWS;
- else if (value == "LOG_UUCP")
- _facility = SYSLOG_UUCP;
- else if (value == "LOG_CRON")
- _facility = SYSLOG_CRON;
- else if (value == "LOG_FTP")
- _facility = SYSLOG_FTP;
- else if (value == "LOG_LOCAL0")
- _facility = SYSLOG_LOCAL0;
- else if (value == "LOG_LOCAL1")
- _facility = SYSLOG_LOCAL1;
- else if (value == "LOG_LOCAL2")
- _facility = SYSLOG_LOCAL2;
- else if (value == "LOG_LOCAL3")
- _facility = SYSLOG_LOCAL3;
- else if (value == "LOG_LOCAL4")
- _facility = SYSLOG_LOCAL4;
- else if (value == "LOG_LOCAL5")
- _facility = SYSLOG_LOCAL5;
- else if (value == "LOG_LOCAL6")
- _facility = SYSLOG_LOCAL6;
- else if (value == "LOG_LOCAL7")
- _facility = SYSLOG_LOCAL7;
- }
- else if (name == PROP_OPTIONS)
- {
- _options = 0;
- StringTokenizer tokenizer(value, "|+:;,", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
- for (StringTokenizer::Iterator it = tokenizer.begin(); it != tokenizer.end(); ++it)
- {
- if (*it == "LOG_CONS")
- _options |= SYSLOG_CONS;
- else if (*it == "LOG_NDELAY")
- _options |= SYSLOG_NDELAY;
- else if (*it == "LOG_PERROR")
- _options |= SYSLOG_PERROR;
- else if (*it == "LOG_PID")
- _options |= SYSLOG_PID;
- }
- }
- else
- {
- Channel::setProperty(name, value);
- }
-}
-
-
-std::string SyslogChannel::getProperty(const std::string& name) const
-{
- if (name == PROP_NAME)
- {
- return _name;
- }
- else if (name == PROP_FACILITY)
- {
- if (_facility == SYSLOG_KERN)
- return "LOG_KERN";
- else if (_facility == SYSLOG_USER)
- return "LOG_USER";
- else if (_facility == SYSLOG_MAIL)
- return "LOG_MAIL";
- else if (_facility == SYSLOG_DAEMON)
- return "LOG_DAEMON";
- else if (_facility == SYSLOG_AUTH)
- return "LOG_AUTH";
- else if (_facility == SYSLOG_AUTHPRIV)
- return "LOG_AUTHPRIV";
- else if (_facility == SYSLOG_SYSLOG)
- return "LOG_SYSLOG";
- else if (_facility == SYSLOG_LPR)
- return "LOG_LPR";
- else if (_facility == SYSLOG_NEWS)
- return "LOG_NEWS";
- else if (_facility == SYSLOG_UUCP)
- return "LOG_UUCP";
- else if (_facility == SYSLOG_CRON)
- return "LOG_CRON";
- else if (_facility == SYSLOG_FTP)
- return "LOG_FTP";
- else if (_facility == SYSLOG_LOCAL0)
- return "LOG_LOCAL0";
- else if (_facility == SYSLOG_LOCAL1)
- return "LOG_LOCAL1";
- else if (_facility == SYSLOG_LOCAL2)
- return "LOG_LOCAL2";
- else if (_facility == SYSLOG_LOCAL3)
- return "LOG_LOCAL3";
- else if (_facility == SYSLOG_LOCAL4)
- return "LOG_LOCAL4";
- else if (_facility == SYSLOG_LOCAL5)
- return "LOG_LOCAL5";
- else if (_facility == SYSLOG_LOCAL6)
- return "LOG_LOCAL6";
- else if (_facility == SYSLOG_LOCAL7)
- return "LOG_LOCAL7";
- else
- return "";
- }
- else if (name == PROP_OPTIONS)
- {
- std::string result;
- if (_options & SYSLOG_CONS)
- {
- if (!result.empty()) result.append("|");
- result.append("LOG_CONS");
- }
- if (_options & SYSLOG_NDELAY)
- {
- if (!result.empty()) result.append("|");
- result.append("LOG_NDELAY");
- }
- if (_options & SYSLOG_PERROR)
- {
- if (!result.empty()) result.append("|");
- result.append("LOG_PERROR");
- }
- if (_options & SYSLOG_PID)
- {
- if (!result.empty()) result.append("|");
- result.append("LOG_PID");
- }
- return result;
- }
- else
- {
- return Channel::getProperty(name);
- }
-}
-
-
-int SyslogChannel::getPrio(const Message& msg)
-{
- switch (msg.getPriority())
- {
+//
+// SyslogChannel.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: SyslogChannel
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/SyslogChannel.h"
+#include "Poco/Message.h"
+#include "Poco/StringTokenizer.h"
+#include <syslog.h>
+
+
+namespace Poco {
+
+
+const std::string SyslogChannel::PROP_NAME = "name";
+const std::string SyslogChannel::PROP_FACILITY = "facility";
+const std::string SyslogChannel::PROP_OPTIONS = "options";
+
+
+SyslogChannel::SyslogChannel():
+ _options(SYSLOG_CONS),
+ _facility(SYSLOG_USER),
+ _open(false)
+{
+}
+
+
+SyslogChannel::SyslogChannel(const std::string& name, int options, int facility):
+ _name(name),
+ _options(options),
+ _facility(facility),
+ _open(false)
+{
+}
+
+
+SyslogChannel::~SyslogChannel()
+{
+ close();
+}
+
+
+void SyslogChannel::open()
+{
+ openlog(_name.c_str(), _options, _facility);
+ _open = true;
+}
+
+
+void SyslogChannel::close()
+{
+ if (_open)
+ {
+ closelog();
+ _open = false;
+ }
+}
+
+
+void SyslogChannel::log(const Message& msg)
+{
+ if (!_open) open();
+ syslog(getPrio(msg), "%s", msg.getText().c_str());
+}
+
+
+void SyslogChannel::setProperty(const std::string& name, const std::string& value)
+{
+ if (name == PROP_NAME)
+ {
+ _name = value;
+ }
+ else if (name == PROP_FACILITY)
+ {
+ if (value == "LOG_KERN")
+ _facility = SYSLOG_KERN;
+ else if (value == "LOG_USER")
+ _facility = SYSLOG_USER;
+ else if (value == "LOG_MAIL")
+ _facility = SYSLOG_MAIL;
+ else if (value == "LOG_DAEMON")
+ _facility = SYSLOG_DAEMON;
+ else if (value == "LOG_AUTH")
+ _facility = SYSLOG_AUTH;
+ else if (value == "LOG_AUTHPRIV")
+ _facility = SYSLOG_AUTHPRIV;
+ else if (value == "LOG_SYSLOG")
+ _facility = SYSLOG_SYSLOG;
+ else if (value == "LOG_LPR")
+ _facility = SYSLOG_LPR;
+ else if (value == "LOG_NEWS")
+ _facility = SYSLOG_NEWS;
+ else if (value == "LOG_UUCP")
+ _facility = SYSLOG_UUCP;
+ else if (value == "LOG_CRON")
+ _facility = SYSLOG_CRON;
+ else if (value == "LOG_FTP")
+ _facility = SYSLOG_FTP;
+ else if (value == "LOG_LOCAL0")
+ _facility = SYSLOG_LOCAL0;
+ else if (value == "LOG_LOCAL1")
+ _facility = SYSLOG_LOCAL1;
+ else if (value == "LOG_LOCAL2")
+ _facility = SYSLOG_LOCAL2;
+ else if (value == "LOG_LOCAL3")
+ _facility = SYSLOG_LOCAL3;
+ else if (value == "LOG_LOCAL4")
+ _facility = SYSLOG_LOCAL4;
+ else if (value == "LOG_LOCAL5")
+ _facility = SYSLOG_LOCAL5;
+ else if (value == "LOG_LOCAL6")
+ _facility = SYSLOG_LOCAL6;
+ else if (value == "LOG_LOCAL7")
+ _facility = SYSLOG_LOCAL7;
+ }
+ else if (name == PROP_OPTIONS)
+ {
+ _options = 0;
+ StringTokenizer tokenizer(value, "|+:;,", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
+ for (StringTokenizer::Iterator it = tokenizer.begin(); it != tokenizer.end(); ++it)
+ {
+ if (*it == "LOG_CONS")
+ _options |= SYSLOG_CONS;
+ else if (*it == "LOG_NDELAY")
+ _options |= SYSLOG_NDELAY;
+ else if (*it == "LOG_PERROR")
+ _options |= SYSLOG_PERROR;
+ else if (*it == "LOG_PID")
+ _options |= SYSLOG_PID;
+ }
+ }
+ else
+ {
+ Channel::setProperty(name, value);
+ }
+}
+
+
+std::string SyslogChannel::getProperty(const std::string& name) const
+{
+ if (name == PROP_NAME)
+ {
+ return _name;
+ }
+ else if (name == PROP_FACILITY)
+ {
+ if (_facility == SYSLOG_KERN)
+ return "LOG_KERN";
+ else if (_facility == SYSLOG_USER)
+ return "LOG_USER";
+ else if (_facility == SYSLOG_MAIL)
+ return "LOG_MAIL";
+ else if (_facility == SYSLOG_DAEMON)
+ return "LOG_DAEMON";
+ else if (_facility == SYSLOG_AUTH)
+ return "LOG_AUTH";
+ else if (_facility == SYSLOG_AUTHPRIV)
+ return "LOG_AUTHPRIV";
+ else if (_facility == SYSLOG_SYSLOG)
+ return "LOG_SYSLOG";
+ else if (_facility == SYSLOG_LPR)
+ return "LOG_LPR";
+ else if (_facility == SYSLOG_NEWS)
+ return "LOG_NEWS";
+ else if (_facility == SYSLOG_UUCP)
+ return "LOG_UUCP";
+ else if (_facility == SYSLOG_CRON)
+ return "LOG_CRON";
+ else if (_facility == SYSLOG_FTP)
+ return "LOG_FTP";
+ else if (_facility == SYSLOG_LOCAL0)
+ return "LOG_LOCAL0";
+ else if (_facility == SYSLOG_LOCAL1)
+ return "LOG_LOCAL1";
+ else if (_facility == SYSLOG_LOCAL2)
+ return "LOG_LOCAL2";
+ else if (_facility == SYSLOG_LOCAL3)
+ return "LOG_LOCAL3";
+ else if (_facility == SYSLOG_LOCAL4)
+ return "LOG_LOCAL4";
+ else if (_facility == SYSLOG_LOCAL5)
+ return "LOG_LOCAL5";
+ else if (_facility == SYSLOG_LOCAL6)
+ return "LOG_LOCAL6";
+ else if (_facility == SYSLOG_LOCAL7)
+ return "LOG_LOCAL7";
+ else
+ return "";
+ }
+ else if (name == PROP_OPTIONS)
+ {
+ std::string result;
+ if (_options & SYSLOG_CONS)
+ {
+ if (!result.empty()) result.append("|");
+ result.append("LOG_CONS");
+ }
+ if (_options & SYSLOG_NDELAY)
+ {
+ if (!result.empty()) result.append("|");
+ result.append("LOG_NDELAY");
+ }
+ if (_options & SYSLOG_PERROR)
+ {
+ if (!result.empty()) result.append("|");
+ result.append("LOG_PERROR");
+ }
+ if (_options & SYSLOG_PID)
+ {
+ if (!result.empty()) result.append("|");
+ result.append("LOG_PID");
+ }
+ return result;
+ }
+ else
+ {
+ return Channel::getProperty(name);
+ }
+}
+
+
+int SyslogChannel::getPrio(const Message& msg)
+{
+ switch (msg.getPriority())
+ {
case Message::PRIO_TEST:
- case Message::PRIO_TRACE:
- case Message::PRIO_DEBUG:
- return LOG_DEBUG;
- case Message::PRIO_INFORMATION:
- return LOG_INFO;
- case Message::PRIO_NOTICE:
- return LOG_NOTICE;
- case Message::PRIO_WARNING:
- return LOG_WARNING;
- case Message::PRIO_ERROR:
- return LOG_ERR;
- case Message::PRIO_CRITICAL:
- return LOG_CRIT;
- case Message::PRIO_FATAL:
- return LOG_ALERT;
- default:
- return 0;
- }
-}
-
-
-} // namespace Poco
+ case Message::PRIO_TRACE:
+ case Message::PRIO_DEBUG:
+ return LOG_DEBUG;
+ case Message::PRIO_INFORMATION:
+ return LOG_INFO;
+ case Message::PRIO_NOTICE:
+ return LOG_NOTICE;
+ case Message::PRIO_WARNING:
+ return LOG_WARNING;
+ case Message::PRIO_ERROR:
+ return LOG_ERR;
+ case Message::PRIO_CRITICAL:
+ return LOG_CRIT;
+ case Message::PRIO_FATAL:
+ return LOG_ALERT;
+ default:
+ return 0;
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Task.cpp b/contrib/libs/poco/Foundation/src/Task.cpp
index e58fdfbe96..dae7c9b2cb 100644
--- a/contrib/libs/poco/Foundation/src/Task.cpp
+++ b/contrib/libs/poco/Foundation/src/Task.cpp
@@ -1,140 +1,140 @@
-//
-// Task.cpp
-//
-// Library: Foundation
-// Package: Tasks
-// Module: Tasks
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Task.h"
-#include "Poco/TaskManager.h"
-#include "Poco/Exception.h"
-#include <array>
-
-namespace Poco {
-
-
-Task::Task(const std::string& rName):
- _name(rName),
- _pOwner(0),
- _progress(0),
- _state(TASK_IDLE),
- _cancelEvent(false)
-{
-}
-
-
-Task::~Task()
-{
-}
-
-
-void Task::cancel()
-{
- _state = TASK_CANCELLING;
- _cancelEvent.set();
- if (_pOwner)
- _pOwner->taskCancelled(this);
-}
-
-
-void Task::reset()
-{
- _progress = 0.0;
- _state = TASK_IDLE;
- _cancelEvent.reset();
-}
-
-
-void Task::run()
-{
- TaskManager* pOwner = getOwner();
- if (pOwner)
- pOwner->taskStarted(this);
- try
- {
- /** Task can be already cancelled.
- * To prevent endless executing already cancelled task _state is assigned to TASK_RUNNING only if _state != TASK_CANCELLING
- */
- std::array<TaskState, 3> allowed_states{TASK_IDLE, TASK_STARTING, TASK_FINISHED};
- for (auto & expected : allowed_states)
- if (_state.compare_exchange_strong(expected, TASK_RUNNING))
- break;
-
- if (_state == TASK_RUNNING)
- runTask();
- }
- catch (Exception& exc)
- {
- if (pOwner)
- pOwner->taskFailed(this, exc);
- }
- catch (std::exception& exc)
- {
- if (pOwner)
- pOwner->taskFailed(this, SystemException(exc.what()));
- }
- catch (...)
- {
- if (pOwner)
- pOwner->taskFailed(this, SystemException("unknown exception"));
- }
- _state = TASK_FINISHED;
- if (pOwner)
- pOwner->taskFinished(this);
-}
-
-
-bool Task::sleep(long milliseconds)
-{
- return _cancelEvent.tryWait(milliseconds);
-}
-
-
-void Task::setProgress(float taskProgress)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- if (_progress != taskProgress)
- {
- _progress = taskProgress;
- if (_pOwner)
- _pOwner->taskProgress(this, _progress);
- }
-}
-
-
-void Task::setOwner(TaskManager* pOwner)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- _pOwner = pOwner;
-}
-
-
-void Task::setState(TaskState taskState)
-{
- _state = taskState;
-}
-
-
-void Task::postNotification(Notification* pNf)
-{
- poco_check_ptr (pNf);
-
- FastMutex::ScopedLock lock(_mutex);
-
- if (_pOwner)
- {
- _pOwner->postNotification(pNf);
- }
-}
-
-
-} // namespace Poco
+//
+// Task.cpp
+//
+// Library: Foundation
+// Package: Tasks
+// Module: Tasks
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Task.h"
+#include "Poco/TaskManager.h"
+#include "Poco/Exception.h"
+#include <array>
+
+namespace Poco {
+
+
+Task::Task(const std::string& rName):
+ _name(rName),
+ _pOwner(0),
+ _progress(0),
+ _state(TASK_IDLE),
+ _cancelEvent(false)
+{
+}
+
+
+Task::~Task()
+{
+}
+
+
+void Task::cancel()
+{
+ _state = TASK_CANCELLING;
+ _cancelEvent.set();
+ if (_pOwner)
+ _pOwner->taskCancelled(this);
+}
+
+
+void Task::reset()
+{
+ _progress = 0.0;
+ _state = TASK_IDLE;
+ _cancelEvent.reset();
+}
+
+
+void Task::run()
+{
+ TaskManager* pOwner = getOwner();
+ if (pOwner)
+ pOwner->taskStarted(this);
+ try
+ {
+ /** Task can be already cancelled.
+ * To prevent endless executing already cancelled task _state is assigned to TASK_RUNNING only if _state != TASK_CANCELLING
+ */
+ std::array<TaskState, 3> allowed_states{TASK_IDLE, TASK_STARTING, TASK_FINISHED};
+ for (auto & expected : allowed_states)
+ if (_state.compare_exchange_strong(expected, TASK_RUNNING))
+ break;
+
+ if (_state == TASK_RUNNING)
+ runTask();
+ }
+ catch (Exception& exc)
+ {
+ if (pOwner)
+ pOwner->taskFailed(this, exc);
+ }
+ catch (std::exception& exc)
+ {
+ if (pOwner)
+ pOwner->taskFailed(this, SystemException(exc.what()));
+ }
+ catch (...)
+ {
+ if (pOwner)
+ pOwner->taskFailed(this, SystemException("unknown exception"));
+ }
+ _state = TASK_FINISHED;
+ if (pOwner)
+ pOwner->taskFinished(this);
+}
+
+
+bool Task::sleep(long milliseconds)
+{
+ return _cancelEvent.tryWait(milliseconds);
+}
+
+
+void Task::setProgress(float taskProgress)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (_progress != taskProgress)
+ {
+ _progress = taskProgress;
+ if (_pOwner)
+ _pOwner->taskProgress(this, _progress);
+ }
+}
+
+
+void Task::setOwner(TaskManager* pOwner)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ _pOwner = pOwner;
+}
+
+
+void Task::setState(TaskState taskState)
+{
+ _state = taskState;
+}
+
+
+void Task::postNotification(Notification* pNf)
+{
+ poco_check_ptr (pNf);
+
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (_pOwner)
+ {
+ _pOwner->postNotification(pNf);
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/TaskManager.cpp b/contrib/libs/poco/Foundation/src/TaskManager.cpp
index 8bf1cb3403..f268a4980f 100644
--- a/contrib/libs/poco/Foundation/src/TaskManager.cpp
+++ b/contrib/libs/poco/Foundation/src/TaskManager.cpp
@@ -1,156 +1,156 @@
-//
-// TaskManager.cpp
-//
-// Library: Foundation
-// Package: Tasks
-// Module: Tasks
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/TaskManager.h"
-#include "Poco/TaskNotification.h"
-#include "Poco/ThreadPool.h"
-
-
-namespace Poco {
-
-
-const int TaskManager::MIN_PROGRESS_NOTIFICATION_INTERVAL = 100000; // 100 milliseconds
-
-
-TaskManager::TaskManager():
- _threadPool(ThreadPool::defaultPool())
-{
-}
-
-
-TaskManager::TaskManager(ThreadPool& pool):
- _threadPool(pool)
-{
-}
-
-
-TaskManager::~TaskManager()
-{
-}
-
-
-void TaskManager::start(Task* pTask)
-{
- TaskPtr pAutoTask(pTask); // take ownership immediately
- FastMutex::ScopedLock lock(_mutex);
-
- pAutoTask->setOwner(this);
- pAutoTask->setState(Task::TASK_STARTING);
- _taskList.push_back(pAutoTask);
- try
- {
- _threadPool.start(*pAutoTask, pAutoTask->name());
- }
- catch (...)
- {
- // Make sure that we don't act like we own the task since
- // we never started it. If we leave the task on our task
- // list, the size of the list is incorrect.
- _taskList.pop_back();
- throw;
- }
-}
-
-
-void TaskManager::cancelAll()
-{
- FastMutex::ScopedLock lock(_mutex);
-
- for (TaskList::iterator it = _taskList.begin(); it != _taskList.end(); ++it)
- {
- (*it)->cancel();
- }
-}
-
-
-void TaskManager::joinAll()
-{
- _threadPool.joinAll();
-}
-
-
-TaskManager::TaskList TaskManager::taskList() const
-{
- FastMutex::ScopedLock lock(_mutex);
-
- return _taskList;
-}
-
-
-void TaskManager::addObserver(const AbstractObserver& observer)
-{
- _nc.addObserver(observer);
-}
-
-
-void TaskManager::removeObserver(const AbstractObserver& observer)
-{
- _nc.removeObserver(observer);
-}
-
-
-void TaskManager::postNotification(const Notification::Ptr& pNf)
-{
- _nc.postNotification(pNf);
-}
-
-
-void TaskManager::taskStarted(Task* pTask)
-{
- _nc.postNotification(new TaskStartedNotification(pTask));
-}
-
-
-void TaskManager::taskProgress(Task* pTask, float progress)
-{
- ScopedLockWithUnlock<FastMutex> lock(_mutex);
-
- if (_lastProgressNotification.isElapsed(MIN_PROGRESS_NOTIFICATION_INTERVAL))
- {
- _lastProgressNotification.update();
- lock.unlock();
- _nc.postNotification(new TaskProgressNotification(pTask, progress));
- }
-}
-
-
-void TaskManager::taskCancelled(Task* pTask)
-{
- _nc.postNotification(new TaskCancelledNotification(pTask));
-}
-
-
-void TaskManager::taskFinished(Task* pTask)
-{
- _nc.postNotification(new TaskFinishedNotification(pTask));
-
- FastMutex::ScopedLock lock(_mutex);
- for (TaskList::iterator it = _taskList.begin(); it != _taskList.end(); ++it)
- {
- if (*it == pTask)
- {
- _taskList.erase(it);
- break;
- }
- }
-}
-
-
-void TaskManager::taskFailed(Task* pTask, const Exception& exc)
-{
- _nc.postNotification(new TaskFailedNotification(pTask, exc));
-}
-
-
-} // namespace Poco
+//
+// TaskManager.cpp
+//
+// Library: Foundation
+// Package: Tasks
+// Module: Tasks
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/TaskManager.h"
+#include "Poco/TaskNotification.h"
+#include "Poco/ThreadPool.h"
+
+
+namespace Poco {
+
+
+const int TaskManager::MIN_PROGRESS_NOTIFICATION_INTERVAL = 100000; // 100 milliseconds
+
+
+TaskManager::TaskManager():
+ _threadPool(ThreadPool::defaultPool())
+{
+}
+
+
+TaskManager::TaskManager(ThreadPool& pool):
+ _threadPool(pool)
+{
+}
+
+
+TaskManager::~TaskManager()
+{
+}
+
+
+void TaskManager::start(Task* pTask)
+{
+ TaskPtr pAutoTask(pTask); // take ownership immediately
+ FastMutex::ScopedLock lock(_mutex);
+
+ pAutoTask->setOwner(this);
+ pAutoTask->setState(Task::TASK_STARTING);
+ _taskList.push_back(pAutoTask);
+ try
+ {
+ _threadPool.start(*pAutoTask, pAutoTask->name());
+ }
+ catch (...)
+ {
+ // Make sure that we don't act like we own the task since
+ // we never started it. If we leave the task on our task
+ // list, the size of the list is incorrect.
+ _taskList.pop_back();
+ throw;
+ }
+}
+
+
+void TaskManager::cancelAll()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ for (TaskList::iterator it = _taskList.begin(); it != _taskList.end(); ++it)
+ {
+ (*it)->cancel();
+ }
+}
+
+
+void TaskManager::joinAll()
+{
+ _threadPool.joinAll();
+}
+
+
+TaskManager::TaskList TaskManager::taskList() const
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ return _taskList;
+}
+
+
+void TaskManager::addObserver(const AbstractObserver& observer)
+{
+ _nc.addObserver(observer);
+}
+
+
+void TaskManager::removeObserver(const AbstractObserver& observer)
+{
+ _nc.removeObserver(observer);
+}
+
+
+void TaskManager::postNotification(const Notification::Ptr& pNf)
+{
+ _nc.postNotification(pNf);
+}
+
+
+void TaskManager::taskStarted(Task* pTask)
+{
+ _nc.postNotification(new TaskStartedNotification(pTask));
+}
+
+
+void TaskManager::taskProgress(Task* pTask, float progress)
+{
+ ScopedLockWithUnlock<FastMutex> lock(_mutex);
+
+ if (_lastProgressNotification.isElapsed(MIN_PROGRESS_NOTIFICATION_INTERVAL))
+ {
+ _lastProgressNotification.update();
+ lock.unlock();
+ _nc.postNotification(new TaskProgressNotification(pTask, progress));
+ }
+}
+
+
+void TaskManager::taskCancelled(Task* pTask)
+{
+ _nc.postNotification(new TaskCancelledNotification(pTask));
+}
+
+
+void TaskManager::taskFinished(Task* pTask)
+{
+ _nc.postNotification(new TaskFinishedNotification(pTask));
+
+ FastMutex::ScopedLock lock(_mutex);
+ for (TaskList::iterator it = _taskList.begin(); it != _taskList.end(); ++it)
+ {
+ if (*it == pTask)
+ {
+ _taskList.erase(it);
+ break;
+ }
+ }
+}
+
+
+void TaskManager::taskFailed(Task* pTask, const Exception& exc)
+{
+ _nc.postNotification(new TaskFailedNotification(pTask, exc));
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/TaskNotification.cpp b/contrib/libs/poco/Foundation/src/TaskNotification.cpp
index 32a9096b8f..daab3b4964 100644
--- a/contrib/libs/poco/Foundation/src/TaskNotification.cpp
+++ b/contrib/libs/poco/Foundation/src/TaskNotification.cpp
@@ -1,92 +1,92 @@
-//
-// TaskNotification.cpp
-//
-// Library: Foundation
-// Package: Tasks
-// Module: Tasks
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/TaskNotification.h"
-
-
-namespace Poco {
-
-
-TaskNotification::TaskNotification(Task* pTask):
- _pTask(pTask)
-{
- if (_pTask) _pTask->duplicate();
-}
-
-
-TaskNotification::~TaskNotification()
-{
- if (_pTask) _pTask->release();
-}
-
-
-TaskStartedNotification::TaskStartedNotification(Task* pTask):
- TaskNotification(pTask)
-{
-}
-
-
-TaskStartedNotification::~TaskStartedNotification()
-{
-}
-
-
-TaskCancelledNotification::TaskCancelledNotification(Task* pTask):
- TaskNotification(pTask)
-{
-}
-
-
-TaskCancelledNotification::~TaskCancelledNotification()
-{
-}
-
-
-TaskFinishedNotification::TaskFinishedNotification(Task* pTask):
- TaskNotification(pTask)
-{
-}
-
-
-TaskFinishedNotification::~TaskFinishedNotification()
-{
-}
-
-
-TaskFailedNotification::TaskFailedNotification(Task* pTask, const Exception& exc):
- TaskNotification(pTask),
- _pException(exc.clone())
-{
-}
-
-
-TaskFailedNotification::~TaskFailedNotification()
-{
- delete _pException;
-}
-
-
-TaskProgressNotification::TaskProgressNotification(Task* pTask, float taskProgress):
- TaskNotification(pTask),
- _progress(taskProgress)
-{
-}
-
-
-TaskProgressNotification::~TaskProgressNotification()
-{
-}
-
-
-} // namespace Poco
+//
+// TaskNotification.cpp
+//
+// Library: Foundation
+// Package: Tasks
+// Module: Tasks
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/TaskNotification.h"
+
+
+namespace Poco {
+
+
+TaskNotification::TaskNotification(Task* pTask):
+ _pTask(pTask)
+{
+ if (_pTask) _pTask->duplicate();
+}
+
+
+TaskNotification::~TaskNotification()
+{
+ if (_pTask) _pTask->release();
+}
+
+
+TaskStartedNotification::TaskStartedNotification(Task* pTask):
+ TaskNotification(pTask)
+{
+}
+
+
+TaskStartedNotification::~TaskStartedNotification()
+{
+}
+
+
+TaskCancelledNotification::TaskCancelledNotification(Task* pTask):
+ TaskNotification(pTask)
+{
+}
+
+
+TaskCancelledNotification::~TaskCancelledNotification()
+{
+}
+
+
+TaskFinishedNotification::TaskFinishedNotification(Task* pTask):
+ TaskNotification(pTask)
+{
+}
+
+
+TaskFinishedNotification::~TaskFinishedNotification()
+{
+}
+
+
+TaskFailedNotification::TaskFailedNotification(Task* pTask, const Exception& exc):
+ TaskNotification(pTask),
+ _pException(exc.clone())
+{
+}
+
+
+TaskFailedNotification::~TaskFailedNotification()
+{
+ delete _pException;
+}
+
+
+TaskProgressNotification::TaskProgressNotification(Task* pTask, float taskProgress):
+ TaskNotification(pTask),
+ _progress(taskProgress)
+{
+}
+
+
+TaskProgressNotification::~TaskProgressNotification()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/TeeStream.cpp b/contrib/libs/poco/Foundation/src/TeeStream.cpp
index 12ae7d0da7..fa64adf4be 100644
--- a/contrib/libs/poco/Foundation/src/TeeStream.cpp
+++ b/contrib/libs/poco/Foundation/src/TeeStream.cpp
@@ -1,133 +1,133 @@
-//
-// TeeStream.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: TeeStream
-//
-// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/TeeStream.h"
-
-
-namespace Poco {
-
-
-TeeStreamBuf::TeeStreamBuf():
- _pIstr(0)
-{
-}
-
-
-TeeStreamBuf::TeeStreamBuf(std::istream& istr):
- _pIstr(&istr)
-{
-}
-
-
-TeeStreamBuf::TeeStreamBuf(std::ostream& ostr):
- _pIstr(0)
-{
- _streams.push_back(&ostr);
-}
-
-
-TeeStreamBuf::~TeeStreamBuf()
-{
-}
-
-
-void TeeStreamBuf::addStream(std::ostream& ostr)
-{
- _streams.push_back(&ostr);
-}
-
-
-int TeeStreamBuf::readFromDevice()
-{
- if (_pIstr)
- {
- int c = _pIstr->get();
- if (c != -1) writeToDevice((char) c);
- return c;
- }
- return -1;
-}
-
-
-int TeeStreamBuf::writeToDevice(char c)
-{
- for (StreamVec::iterator it = _streams.begin(); it != _streams.end(); ++it)
- {
- (*it)->put(c);
- }
- return charToInt(c);
-}
-
-
-TeeIOS::TeeIOS()
-{
- poco_ios_init(&_buf);
-}
-
-
-TeeIOS::TeeIOS(std::istream& istr): _buf(istr)
-{
- poco_ios_init(&_buf);
-}
-
-
-TeeIOS::TeeIOS(std::ostream& ostr): _buf(ostr)
-{
- poco_ios_init(&_buf);
-}
-
-
-TeeIOS::~TeeIOS()
-{
-}
-
-
-void TeeIOS::addStream(std::ostream& ostr)
-{
- _buf.addStream(ostr);
-}
-
-
-TeeStreamBuf* TeeIOS::rdbuf()
-{
- return &_buf;
-}
-
-
-TeeInputStream::TeeInputStream(std::istream& istr): TeeIOS(istr), std::istream(&_buf)
-{
-}
-
-
-TeeInputStream::~TeeInputStream()
-{
-}
-
-
-TeeOutputStream::TeeOutputStream(): std::ostream(&_buf)
-{
-}
-
-
-TeeOutputStream::TeeOutputStream(std::ostream& ostr): TeeIOS(ostr), std::ostream(&_buf)
-{
-}
-
-
-TeeOutputStream::~TeeOutputStream()
-{
-}
-
-
-} // namespace Poco
+//
+// TeeStream.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: TeeStream
+//
+// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/TeeStream.h"
+
+
+namespace Poco {
+
+
+TeeStreamBuf::TeeStreamBuf():
+ _pIstr(0)
+{
+}
+
+
+TeeStreamBuf::TeeStreamBuf(std::istream& istr):
+ _pIstr(&istr)
+{
+}
+
+
+TeeStreamBuf::TeeStreamBuf(std::ostream& ostr):
+ _pIstr(0)
+{
+ _streams.push_back(&ostr);
+}
+
+
+TeeStreamBuf::~TeeStreamBuf()
+{
+}
+
+
+void TeeStreamBuf::addStream(std::ostream& ostr)
+{
+ _streams.push_back(&ostr);
+}
+
+
+int TeeStreamBuf::readFromDevice()
+{
+ if (_pIstr)
+ {
+ int c = _pIstr->get();
+ if (c != -1) writeToDevice((char) c);
+ return c;
+ }
+ return -1;
+}
+
+
+int TeeStreamBuf::writeToDevice(char c)
+{
+ for (StreamVec::iterator it = _streams.begin(); it != _streams.end(); ++it)
+ {
+ (*it)->put(c);
+ }
+ return charToInt(c);
+}
+
+
+TeeIOS::TeeIOS()
+{
+ poco_ios_init(&_buf);
+}
+
+
+TeeIOS::TeeIOS(std::istream& istr): _buf(istr)
+{
+ poco_ios_init(&_buf);
+}
+
+
+TeeIOS::TeeIOS(std::ostream& ostr): _buf(ostr)
+{
+ poco_ios_init(&_buf);
+}
+
+
+TeeIOS::~TeeIOS()
+{
+}
+
+
+void TeeIOS::addStream(std::ostream& ostr)
+{
+ _buf.addStream(ostr);
+}
+
+
+TeeStreamBuf* TeeIOS::rdbuf()
+{
+ return &_buf;
+}
+
+
+TeeInputStream::TeeInputStream(std::istream& istr): TeeIOS(istr), std::istream(&_buf)
+{
+}
+
+
+TeeInputStream::~TeeInputStream()
+{
+}
+
+
+TeeOutputStream::TeeOutputStream(): std::ostream(&_buf)
+{
+}
+
+
+TeeOutputStream::TeeOutputStream(std::ostream& ostr): TeeIOS(ostr), std::ostream(&_buf)
+{
+}
+
+
+TeeOutputStream::~TeeOutputStream()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/TemporaryFile.cpp b/contrib/libs/poco/Foundation/src/TemporaryFile.cpp
index e89c970f33..a14d444375 100644
--- a/contrib/libs/poco/Foundation/src/TemporaryFile.cpp
+++ b/contrib/libs/poco/Foundation/src/TemporaryFile.cpp
@@ -1,167 +1,167 @@
-//
-// TemporaryFile.cpp
-//
-// Library: Foundation
-// Package: Filesystem
-// Module: TemporaryFile
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/TemporaryFile.h"
-#include "Poco/Path.h"
-#include "Poco/Exception.h"
-#if !defined(POCO_VXWORKS)
-#include "Poco/Process.h"
-#endif
-#include "Poco/Mutex.h"
-#include <set>
-#include <sstream>
-
-
-namespace Poco {
-
-
-class TempFileCollector
-{
-public:
- TempFileCollector()
- {
- }
-
- ~TempFileCollector()
- {
- try
- {
- for (std::set<std::string>::iterator it = _files.begin(); it != _files.end(); ++it)
- {
- try
- {
- File f(*it);
- if (f.exists())
- f.remove(true);
- }
- catch (Exception&)
- {
- }
- }
- }
- catch (...)
- {
- poco_unexpected();
- }
- }
-
- void registerFile(const std::string& path)
- {
- FastMutex::ScopedLock lock(_mutex);
-
- Path p(path);
- _files.insert(p.absolute().toString());
- }
-
-private:
- std::set<std::string> _files;
- FastMutex _mutex;
-};
-
-
-TemporaryFile::TemporaryFile():
- File(tempName()),
- _keep(false)
-{
-}
-
-
-TemporaryFile::TemporaryFile(const std::string& tempDir):
- File(tempName(tempDir)),
- _keep(false)
-{
-}
-
-
-TemporaryFile::~TemporaryFile()
-{
- try
- {
- if (!_keep)
- {
- try
- {
- if (exists())
- remove(true);
- }
- catch (Exception&)
- {
- }
- }
- }
- catch (...)
- {
- poco_unexpected();
- }
-}
-
-
-void TemporaryFile::keep()
-{
- _keep = true;
-}
-
-
-void TemporaryFile::keepUntilExit()
-{
- _keep = true;
- registerForDeletion(path());
-}
-
-
+//
+// TemporaryFile.cpp
+//
+// Library: Foundation
+// Package: Filesystem
+// Module: TemporaryFile
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/TemporaryFile.h"
+#include "Poco/Path.h"
+#include "Poco/Exception.h"
+#if !defined(POCO_VXWORKS)
+#include "Poco/Process.h"
+#endif
+#include "Poco/Mutex.h"
+#include <set>
+#include <sstream>
+
+
+namespace Poco {
+
+
+class TempFileCollector
+{
+public:
+ TempFileCollector()
+ {
+ }
+
+ ~TempFileCollector()
+ {
+ try
+ {
+ for (std::set<std::string>::iterator it = _files.begin(); it != _files.end(); ++it)
+ {
+ try
+ {
+ File f(*it);
+ if (f.exists())
+ f.remove(true);
+ }
+ catch (Exception&)
+ {
+ }
+ }
+ }
+ catch (...)
+ {
+ poco_unexpected();
+ }
+ }
+
+ void registerFile(const std::string& path)
+ {
+ FastMutex::ScopedLock lock(_mutex);
+
+ Path p(path);
+ _files.insert(p.absolute().toString());
+ }
+
+private:
+ std::set<std::string> _files;
+ FastMutex _mutex;
+};
+
+
+TemporaryFile::TemporaryFile():
+ File(tempName()),
+ _keep(false)
+{
+}
+
+
+TemporaryFile::TemporaryFile(const std::string& tempDir):
+ File(tempName(tempDir)),
+ _keep(false)
+{
+}
+
+
+TemporaryFile::~TemporaryFile()
+{
+ try
+ {
+ if (!_keep)
+ {
+ try
+ {
+ if (exists())
+ remove(true);
+ }
+ catch (Exception&)
+ {
+ }
+ }
+ }
+ catch (...)
+ {
+ poco_unexpected();
+ }
+}
+
+
+void TemporaryFile::keep()
+{
+ _keep = true;
+}
+
+
+void TemporaryFile::keepUntilExit()
+{
+ _keep = true;
+ registerForDeletion(path());
+}
+
+
+namespace
+{
+ static TempFileCollector fc;
+}
+
+
+void TemporaryFile::registerForDeletion(const std::string& path)
+{
+ fc.registerFile(path);
+}
+
+
namespace
-{
- static TempFileCollector fc;
-}
-
-
-void TemporaryFile::registerForDeletion(const std::string& path)
-{
- fc.registerFile(path);
-}
-
-
-namespace
-{
- static FastMutex mutex;
-}
-
-
-std::string TemporaryFile::tempName(const std::string& tempDir)
-{
- std::ostringstream name;
- static unsigned long count = 0;
- mutex.lock();
- unsigned long n = count++;
- mutex.unlock();
- name << (tempDir.empty() ? Path::temp() : tempDir);
- if (name.str().at(name.str().size() - 1) != Path::separator())
- {
- name << Path::separator();
- }
-#if defined(POCO_VXWORKS)
- name << "tmp";
-#else
- name << "tmp" << Process::id();
-#endif
- for (int i = 0; i < 6; ++i)
- {
- name << char('a' + (n % 26));
- n /= 26;
- }
- return name.str();
-}
-
-
-} // namespace Poco
+{
+ static FastMutex mutex;
+}
+
+
+std::string TemporaryFile::tempName(const std::string& tempDir)
+{
+ std::ostringstream name;
+ static unsigned long count = 0;
+ mutex.lock();
+ unsigned long n = count++;
+ mutex.unlock();
+ name << (tempDir.empty() ? Path::temp() : tempDir);
+ if (name.str().at(name.str().size() - 1) != Path::separator())
+ {
+ name << Path::separator();
+ }
+#if defined(POCO_VXWORKS)
+ name << "tmp";
+#else
+ name << "tmp" << Process::id();
+#endif
+ for (int i = 0; i < 6; ++i)
+ {
+ name << char('a' + (n % 26));
+ n /= 26;
+ }
+ return name.str();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/TextBufferIterator.cpp b/contrib/libs/poco/Foundation/src/TextBufferIterator.cpp
index 7a503081ae..1c0fd6b6bc 100644
--- a/contrib/libs/poco/Foundation/src/TextBufferIterator.cpp
+++ b/contrib/libs/poco/Foundation/src/TextBufferIterator.cpp
@@ -1,178 +1,178 @@
-//
-// TextBufferIterator.cpp
-//
-// Library: Foundation
-// Package: Text
-// Module: TextBufferIterator
-//
-// Copyright (c) 2010, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/TextBufferIterator.h"
-#include "Poco/TextEncoding.h"
-#include <algorithm>
-#include <cstring>
-
-
-namespace Poco {
-
-
-TextBufferIterator::TextBufferIterator():
- _pEncoding(0),
- _it(0),
- _end(0)
-{
-}
-
-
-TextBufferIterator::TextBufferIterator(const char* begin, const TextEncoding& encoding):
- _pEncoding(&encoding),
- _it(begin),
- _end(begin + std::strlen(begin))
-{
-}
-
-
-TextBufferIterator::TextBufferIterator(const char* begin, std::size_t size, const TextEncoding& encoding):
- _pEncoding(&encoding),
- _it(begin),
- _end(begin + size)
-{
-}
-
-
-TextBufferIterator::TextBufferIterator(const char* begin, const char* pEnd, const TextEncoding& encoding):
- _pEncoding(&encoding),
- _it(begin),
- _end(pEnd)
-{
-}
-
-
-TextBufferIterator::TextBufferIterator(const char* pEnd):
- _pEncoding(0),
- _it(pEnd),
- _end(pEnd)
-{
-}
-
-
-TextBufferIterator::~TextBufferIterator()
-{
-}
-
-
-TextBufferIterator::TextBufferIterator(const TextBufferIterator& it):
- _pEncoding(it._pEncoding),
- _it(it._it),
- _end(it._end)
-{
-}
-
-
-TextBufferIterator& TextBufferIterator::operator = (const TextBufferIterator& it)
-{
- if (&it != this)
- {
- _pEncoding = it._pEncoding;
- _it = it._it;
- _end = it._end;
- }
- return *this;
-}
-
-
-void TextBufferIterator::swap(TextBufferIterator& it)
-{
- std::swap(_pEncoding, it._pEncoding);
- std::swap(_it, it._it);
- std::swap(_end, it._end);
-}
-
-
-int TextBufferIterator::operator * () const
-{
- poco_check_ptr (_pEncoding);
- poco_assert (_it != _end);
- const char* it = _it;
-
- unsigned char buffer[TextEncoding::MAX_SEQUENCE_LENGTH];
- unsigned char* p = buffer;
-
- if (it != _end)
- *p++ = *it++;
- else
- *p++ = 0;
-
- int read = 1;
- int n = _pEncoding->queryConvert(buffer, 1);
-
- while (-1 > n && (_end - it) >= -n - read)
- {
- while (read < -n && it != _end)
- {
- *p++ = *it++;
- read++;
- }
- n = _pEncoding->queryConvert(buffer, read);
- }
-
- if (-1 > n)
- {
- return -1;
- }
- else
- {
- return n;
- }
-}
-
-
-TextBufferIterator& TextBufferIterator::operator ++ ()
-{
- poco_check_ptr (_pEncoding);
- poco_assert (_it != _end);
-
- unsigned char buffer[TextEncoding::MAX_SEQUENCE_LENGTH];
- unsigned char* p = buffer;
-
- if (_it != _end)
- *p++ = *_it++;
- else
- *p++ = 0;
-
- int read = 1;
- int n = _pEncoding->sequenceLength(buffer, 1);
-
- while (-1 > n && (_end - _it) >= -n - read)
- {
- while (read < -n && _it != _end)
- {
- *p++ = *_it++;
- read++;
- }
- n = _pEncoding->sequenceLength(buffer, read);
- }
- while (read < n && _it != _end)
+//
+// TextBufferIterator.cpp
+//
+// Library: Foundation
+// Package: Text
+// Module: TextBufferIterator
+//
+// Copyright (c) 2010, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/TextBufferIterator.h"
+#include "Poco/TextEncoding.h"
+#include <algorithm>
+#include <cstring>
+
+
+namespace Poco {
+
+
+TextBufferIterator::TextBufferIterator():
+ _pEncoding(0),
+ _it(0),
+ _end(0)
+{
+}
+
+
+TextBufferIterator::TextBufferIterator(const char* begin, const TextEncoding& encoding):
+ _pEncoding(&encoding),
+ _it(begin),
+ _end(begin + std::strlen(begin))
+{
+}
+
+
+TextBufferIterator::TextBufferIterator(const char* begin, std::size_t size, const TextEncoding& encoding):
+ _pEncoding(&encoding),
+ _it(begin),
+ _end(begin + size)
+{
+}
+
+
+TextBufferIterator::TextBufferIterator(const char* begin, const char* pEnd, const TextEncoding& encoding):
+ _pEncoding(&encoding),
+ _it(begin),
+ _end(pEnd)
+{
+}
+
+
+TextBufferIterator::TextBufferIterator(const char* pEnd):
+ _pEncoding(0),
+ _it(pEnd),
+ _end(pEnd)
+{
+}
+
+
+TextBufferIterator::~TextBufferIterator()
+{
+}
+
+
+TextBufferIterator::TextBufferIterator(const TextBufferIterator& it):
+ _pEncoding(it._pEncoding),
+ _it(it._it),
+ _end(it._end)
+{
+}
+
+
+TextBufferIterator& TextBufferIterator::operator = (const TextBufferIterator& it)
+{
+ if (&it != this)
{
- _it++;
- read++;
- }
-
- return *this;
-}
-
-
-TextBufferIterator TextBufferIterator::operator ++ (int)
-{
- TextBufferIterator prev(*this);
- operator ++ ();
- return prev;
-}
-
-
-} // namespace Poco
+ _pEncoding = it._pEncoding;
+ _it = it._it;
+ _end = it._end;
+ }
+ return *this;
+}
+
+
+void TextBufferIterator::swap(TextBufferIterator& it)
+{
+ std::swap(_pEncoding, it._pEncoding);
+ std::swap(_it, it._it);
+ std::swap(_end, it._end);
+}
+
+
+int TextBufferIterator::operator * () const
+{
+ poco_check_ptr (_pEncoding);
+ poco_assert (_it != _end);
+ const char* it = _it;
+
+ unsigned char buffer[TextEncoding::MAX_SEQUENCE_LENGTH];
+ unsigned char* p = buffer;
+
+ if (it != _end)
+ *p++ = *it++;
+ else
+ *p++ = 0;
+
+ int read = 1;
+ int n = _pEncoding->queryConvert(buffer, 1);
+
+ while (-1 > n && (_end - it) >= -n - read)
+ {
+ while (read < -n && it != _end)
+ {
+ *p++ = *it++;
+ read++;
+ }
+ n = _pEncoding->queryConvert(buffer, read);
+ }
+
+ if (-1 > n)
+ {
+ return -1;
+ }
+ else
+ {
+ return n;
+ }
+}
+
+
+TextBufferIterator& TextBufferIterator::operator ++ ()
+{
+ poco_check_ptr (_pEncoding);
+ poco_assert (_it != _end);
+
+ unsigned char buffer[TextEncoding::MAX_SEQUENCE_LENGTH];
+ unsigned char* p = buffer;
+
+ if (_it != _end)
+ *p++ = *_it++;
+ else
+ *p++ = 0;
+
+ int read = 1;
+ int n = _pEncoding->sequenceLength(buffer, 1);
+
+ while (-1 > n && (_end - _it) >= -n - read)
+ {
+ while (read < -n && _it != _end)
+ {
+ *p++ = *_it++;
+ read++;
+ }
+ n = _pEncoding->sequenceLength(buffer, read);
+ }
+ while (read < n && _it != _end)
+ {
+ _it++;
+ read++;
+ }
+
+ return *this;
+}
+
+
+TextBufferIterator TextBufferIterator::operator ++ (int)
+{
+ TextBufferIterator prev(*this);
+ operator ++ ();
+ return prev;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/TextConverter.cpp b/contrib/libs/poco/Foundation/src/TextConverter.cpp
index 59194ed77c..bd63fd278b 100644
--- a/contrib/libs/poco/Foundation/src/TextConverter.cpp
+++ b/contrib/libs/poco/Foundation/src/TextConverter.cpp
@@ -1,128 +1,128 @@
-//
-// TextConverter.cpp
-//
-// Library: Foundation
-// Package: Text
-// Module: TextConverter
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/TextConverter.h"
-#include "Poco/TextIterator.h"
-#include "Poco/TextEncoding.h"
-
-
-namespace {
- int nullTransform(int ch)
- {
- return ch;
- }
-}
-
-
-namespace Poco {
-
-
-TextConverter::TextConverter(const TextEncoding& inEncoding, const TextEncoding& outEncoding, int defaultChar):
- _inEncoding(inEncoding),
- _outEncoding(outEncoding),
- _defaultChar(defaultChar)
-{
-}
-
-
-TextConverter::~TextConverter()
-{
-}
-
-
-int TextConverter::convert(const std::string& source, std::string& destination, Transform trans)
-{
- int errors = 0;
- TextIterator it(source, _inEncoding);
- TextIterator end(source);
- unsigned char buffer[TextEncoding::MAX_SEQUENCE_LENGTH];
-
- while (it != end)
- {
- int c = *it;
- if (c == -1) { ++errors; c = _defaultChar; }
- c = trans(c);
- int n = _outEncoding.convert(c, buffer, sizeof(buffer));
- if (n == 0) n = _outEncoding.convert(_defaultChar, buffer, sizeof(buffer));
- poco_assert (n <= sizeof(buffer));
- destination.append((const char*) buffer, n);
- ++it;
- }
- return errors;
-}
-
-
-int TextConverter::convert(const void* source, int length, std::string& destination, Transform trans)
-{
- poco_check_ptr (source);
-
- int errors = 0;
- const unsigned char* it = (const unsigned char*) source;
- const unsigned char* end = (const unsigned char*) source + length;
- unsigned char buffer[TextEncoding::MAX_SEQUENCE_LENGTH];
-
- while (it < end)
- {
- int n = _inEncoding.queryConvert(it, 1);
- int uc;
- int read = 1;
-
- while (-1 > n && (end - it) >= -n)
- {
- read = -n;
- n = _inEncoding.queryConvert(it, read);
- }
-
- if (-1 > n)
- {
- it = end;
- }
- else
- {
- it += read;
- }
-
- if (-1 >= n)
- {
- uc = _defaultChar;
- ++errors;
- }
- else
- {
- uc = n;
- }
-
- uc = trans(uc);
- n = _outEncoding.convert(uc, buffer, sizeof(buffer));
- if (n == 0) n = _outEncoding.convert(_defaultChar, buffer, sizeof(buffer));
- poco_assert (n <= sizeof(buffer));
- destination.append((const char*) buffer, n);
- }
- return errors;
-}
-
-
-int TextConverter::convert(const std::string& source, std::string& destination)
-{
- return convert(source, destination, nullTransform);
-}
-
-
-int TextConverter::convert(const void* source, int length, std::string& destination)
-{
- return convert(source, length, destination, nullTransform);
-}
-
-
-} // namespace Poco
+//
+// TextConverter.cpp
+//
+// Library: Foundation
+// Package: Text
+// Module: TextConverter
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/TextConverter.h"
+#include "Poco/TextIterator.h"
+#include "Poco/TextEncoding.h"
+
+
+namespace {
+ int nullTransform(int ch)
+ {
+ return ch;
+ }
+}
+
+
+namespace Poco {
+
+
+TextConverter::TextConverter(const TextEncoding& inEncoding, const TextEncoding& outEncoding, int defaultChar):
+ _inEncoding(inEncoding),
+ _outEncoding(outEncoding),
+ _defaultChar(defaultChar)
+{
+}
+
+
+TextConverter::~TextConverter()
+{
+}
+
+
+int TextConverter::convert(const std::string& source, std::string& destination, Transform trans)
+{
+ int errors = 0;
+ TextIterator it(source, _inEncoding);
+ TextIterator end(source);
+ unsigned char buffer[TextEncoding::MAX_SEQUENCE_LENGTH];
+
+ while (it != end)
+ {
+ int c = *it;
+ if (c == -1) { ++errors; c = _defaultChar; }
+ c = trans(c);
+ int n = _outEncoding.convert(c, buffer, sizeof(buffer));
+ if (n == 0) n = _outEncoding.convert(_defaultChar, buffer, sizeof(buffer));
+ poco_assert (n <= sizeof(buffer));
+ destination.append((const char*) buffer, n);
+ ++it;
+ }
+ return errors;
+}
+
+
+int TextConverter::convert(const void* source, int length, std::string& destination, Transform trans)
+{
+ poco_check_ptr (source);
+
+ int errors = 0;
+ const unsigned char* it = (const unsigned char*) source;
+ const unsigned char* end = (const unsigned char*) source + length;
+ unsigned char buffer[TextEncoding::MAX_SEQUENCE_LENGTH];
+
+ while (it < end)
+ {
+ int n = _inEncoding.queryConvert(it, 1);
+ int uc;
+ int read = 1;
+
+ while (-1 > n && (end - it) >= -n)
+ {
+ read = -n;
+ n = _inEncoding.queryConvert(it, read);
+ }
+
+ if (-1 > n)
+ {
+ it = end;
+ }
+ else
+ {
+ it += read;
+ }
+
+ if (-1 >= n)
+ {
+ uc = _defaultChar;
+ ++errors;
+ }
+ else
+ {
+ uc = n;
+ }
+
+ uc = trans(uc);
+ n = _outEncoding.convert(uc, buffer, sizeof(buffer));
+ if (n == 0) n = _outEncoding.convert(_defaultChar, buffer, sizeof(buffer));
+ poco_assert (n <= sizeof(buffer));
+ destination.append((const char*) buffer, n);
+ }
+ return errors;
+}
+
+
+int TextConverter::convert(const std::string& source, std::string& destination)
+{
+ return convert(source, destination, nullTransform);
+}
+
+
+int TextConverter::convert(const void* source, int length, std::string& destination)
+{
+ return convert(source, length, destination, nullTransform);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/TextEncoding.cpp b/contrib/libs/poco/Foundation/src/TextEncoding.cpp
index 45cad09d4e..122b855fea 100644
--- a/contrib/libs/poco/Foundation/src/TextEncoding.cpp
+++ b/contrib/libs/poco/Foundation/src/TextEncoding.cpp
@@ -1,208 +1,208 @@
-//
-// TextEncoding.cpp
-//
-// Library: Foundation
-// Package: Text
-// Module: TextEncoding
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/TextEncoding.h"
-#include "Poco/Exception.h"
-#include "Poco/String.h"
-#include "Poco/ASCIIEncoding.h"
-#include "Poco/Latin1Encoding.h"
-#include "Poco/Latin2Encoding.h"
-#include "Poco/Latin9Encoding.h"
-#include "Poco/UTF32Encoding.h"
-#include "Poco/UTF16Encoding.h"
-#include "Poco/UTF8Encoding.h"
-#include "Poco/Windows1250Encoding.h"
-#include "Poco/Windows1251Encoding.h"
-#include "Poco/Windows1252Encoding.h"
-#include "Poco/RWLock.h"
-#include "Poco/SingletonHolder.h"
-#include <map>
-
-
-namespace Poco {
-
-
-//
-// TextEncodingManager
-//
-
-
-class TextEncodingManager
-{
-public:
- TextEncodingManager()
- {
- TextEncoding::Ptr pUtf8Encoding(new UTF8Encoding);
- add(pUtf8Encoding, TextEncoding::GLOBAL);
-
- add(new ASCIIEncoding);
- add(new Latin1Encoding);
- add(new Latin2Encoding);
- add(new Latin9Encoding);
- add(pUtf8Encoding);
- add(new UTF16Encoding);
- add(new UTF32Encoding);
- add(new Windows1250Encoding);
- add(new Windows1251Encoding);
- add(new Windows1252Encoding);
- }
-
- ~TextEncodingManager()
- {
- }
-
- void add(TextEncoding::Ptr pEncoding)
- {
- add(pEncoding, pEncoding->canonicalName());
- }
-
- void add(TextEncoding::Ptr pEncoding, const std::string& name)
- {
- RWLock::ScopedLock lock(_lock, true);
-
- _encodings[name] = pEncoding;
- }
-
- void remove(const std::string& name)
- {
- RWLock::ScopedLock lock(_lock, true);
-
- _encodings.erase(name);
- }
-
- TextEncoding::Ptr find(const std::string& name) const
- {
- RWLock::ScopedLock lock(_lock);
-
- EncodingMap::const_iterator it = _encodings.find(name);
- if (it != _encodings.end())
- return it->second;
-
- for (it = _encodings.begin(); it != _encodings.end(); ++it)
- {
- if (it->second->isA(name))
- return it->second;
- }
- return TextEncoding::Ptr();
- }
-
-private:
- TextEncodingManager(const TextEncodingManager&);
- TextEncodingManager& operator = (const TextEncodingManager&);
-
- typedef std::map<std::string, TextEncoding::Ptr, CILess> EncodingMap;
-
- EncodingMap _encodings;
- mutable RWLock _lock;
-};
-
-
-//
-// TextEncoding
-//
-
-
-const std::string TextEncoding::GLOBAL;
-
-
-TextEncoding::~TextEncoding()
-{
-}
-
-
-int TextEncoding::convert(const unsigned char* bytes) const
-{
- return static_cast<int>(*bytes);
-}
-
-
-int TextEncoding::convert(int /*ch*/, unsigned char* /*bytes*/, int /*length*/) const
-{
- return 0;
-}
-
-
-int TextEncoding::queryConvert(const unsigned char* bytes, int /*length*/) const
-{
- return (int) *bytes;
-}
-
-
-int TextEncoding::sequenceLength(const unsigned char* /*bytes*/, int /*length*/) const
-{
- return 1;
-}
-
-
-TextEncoding& TextEncoding::byName(const std::string& encodingName)
-{
- TextEncoding* pEncoding = manager().find(encodingName);
- if (pEncoding)
- return *pEncoding;
- else
- throw NotFoundException(encodingName);
-}
-
-
-TextEncoding::Ptr TextEncoding::find(const std::string& encodingName)
-{
- return manager().find(encodingName);
-}
-
-
-void TextEncoding::add(TextEncoding::Ptr pEncoding)
-{
- manager().add(pEncoding, pEncoding->canonicalName());
-}
-
-
-void TextEncoding::add(TextEncoding::Ptr pEncoding, const std::string& name)
-{
- manager().add(pEncoding, name);
-}
-
-
-void TextEncoding::remove(const std::string& encodingName)
-{
- manager().remove(encodingName);
-}
-
-
-TextEncoding::Ptr TextEncoding::global(TextEncoding::Ptr encoding)
-{
- TextEncoding::Ptr prev = find(GLOBAL);
- add(encoding, GLOBAL);
- return prev;
-}
-
-
-TextEncoding& TextEncoding::global()
-{
- return byName(GLOBAL);
-}
-
-
-namespace
-{
- static SingletonHolder<TextEncodingManager> sh;
-}
-
-
-TextEncodingManager& TextEncoding::manager()
-{
- return *sh.get();
-}
-
-
-} // namespace Poco
+//
+// TextEncoding.cpp
+//
+// Library: Foundation
+// Package: Text
+// Module: TextEncoding
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/TextEncoding.h"
+#include "Poco/Exception.h"
+#include "Poco/String.h"
+#include "Poco/ASCIIEncoding.h"
+#include "Poco/Latin1Encoding.h"
+#include "Poco/Latin2Encoding.h"
+#include "Poco/Latin9Encoding.h"
+#include "Poco/UTF32Encoding.h"
+#include "Poco/UTF16Encoding.h"
+#include "Poco/UTF8Encoding.h"
+#include "Poco/Windows1250Encoding.h"
+#include "Poco/Windows1251Encoding.h"
+#include "Poco/Windows1252Encoding.h"
+#include "Poco/RWLock.h"
+#include "Poco/SingletonHolder.h"
+#include <map>
+
+
+namespace Poco {
+
+
+//
+// TextEncodingManager
+//
+
+
+class TextEncodingManager
+{
+public:
+ TextEncodingManager()
+ {
+ TextEncoding::Ptr pUtf8Encoding(new UTF8Encoding);
+ add(pUtf8Encoding, TextEncoding::GLOBAL);
+
+ add(new ASCIIEncoding);
+ add(new Latin1Encoding);
+ add(new Latin2Encoding);
+ add(new Latin9Encoding);
+ add(pUtf8Encoding);
+ add(new UTF16Encoding);
+ add(new UTF32Encoding);
+ add(new Windows1250Encoding);
+ add(new Windows1251Encoding);
+ add(new Windows1252Encoding);
+ }
+
+ ~TextEncodingManager()
+ {
+ }
+
+ void add(TextEncoding::Ptr pEncoding)
+ {
+ add(pEncoding, pEncoding->canonicalName());
+ }
+
+ void add(TextEncoding::Ptr pEncoding, const std::string& name)
+ {
+ RWLock::ScopedLock lock(_lock, true);
+
+ _encodings[name] = pEncoding;
+ }
+
+ void remove(const std::string& name)
+ {
+ RWLock::ScopedLock lock(_lock, true);
+
+ _encodings.erase(name);
+ }
+
+ TextEncoding::Ptr find(const std::string& name) const
+ {
+ RWLock::ScopedLock lock(_lock);
+
+ EncodingMap::const_iterator it = _encodings.find(name);
+ if (it != _encodings.end())
+ return it->second;
+
+ for (it = _encodings.begin(); it != _encodings.end(); ++it)
+ {
+ if (it->second->isA(name))
+ return it->second;
+ }
+ return TextEncoding::Ptr();
+ }
+
+private:
+ TextEncodingManager(const TextEncodingManager&);
+ TextEncodingManager& operator = (const TextEncodingManager&);
+
+ typedef std::map<std::string, TextEncoding::Ptr, CILess> EncodingMap;
+
+ EncodingMap _encodings;
+ mutable RWLock _lock;
+};
+
+
+//
+// TextEncoding
+//
+
+
+const std::string TextEncoding::GLOBAL;
+
+
+TextEncoding::~TextEncoding()
+{
+}
+
+
+int TextEncoding::convert(const unsigned char* bytes) const
+{
+ return static_cast<int>(*bytes);
+}
+
+
+int TextEncoding::convert(int /*ch*/, unsigned char* /*bytes*/, int /*length*/) const
+{
+ return 0;
+}
+
+
+int TextEncoding::queryConvert(const unsigned char* bytes, int /*length*/) const
+{
+ return (int) *bytes;
+}
+
+
+int TextEncoding::sequenceLength(const unsigned char* /*bytes*/, int /*length*/) const
+{
+ return 1;
+}
+
+
+TextEncoding& TextEncoding::byName(const std::string& encodingName)
+{
+ TextEncoding* pEncoding = manager().find(encodingName);
+ if (pEncoding)
+ return *pEncoding;
+ else
+ throw NotFoundException(encodingName);
+}
+
+
+TextEncoding::Ptr TextEncoding::find(const std::string& encodingName)
+{
+ return manager().find(encodingName);
+}
+
+
+void TextEncoding::add(TextEncoding::Ptr pEncoding)
+{
+ manager().add(pEncoding, pEncoding->canonicalName());
+}
+
+
+void TextEncoding::add(TextEncoding::Ptr pEncoding, const std::string& name)
+{
+ manager().add(pEncoding, name);
+}
+
+
+void TextEncoding::remove(const std::string& encodingName)
+{
+ manager().remove(encodingName);
+}
+
+
+TextEncoding::Ptr TextEncoding::global(TextEncoding::Ptr encoding)
+{
+ TextEncoding::Ptr prev = find(GLOBAL);
+ add(encoding, GLOBAL);
+ return prev;
+}
+
+
+TextEncoding& TextEncoding::global()
+{
+ return byName(GLOBAL);
+}
+
+
+namespace
+{
+ static SingletonHolder<TextEncodingManager> sh;
+}
+
+
+TextEncodingManager& TextEncoding::manager()
+{
+ return *sh.get();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/TextIterator.cpp b/contrib/libs/poco/Foundation/src/TextIterator.cpp
index e61bad3731..7f50f8daa9 100644
--- a/contrib/libs/poco/Foundation/src/TextIterator.cpp
+++ b/contrib/libs/poco/Foundation/src/TextIterator.cpp
@@ -1,175 +1,175 @@
-//
-// TextIterator.cpp
-//
-// Library: Foundation
-// Package: Text
-// Module: TextIterator
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/TextIterator.h"
-#include "Poco/TextEncoding.h"
-#include <algorithm>
-
-
-namespace Poco {
-
-
-TextIterator::TextIterator():
- _pEncoding(0)
-{
-}
-
-
-TextIterator::TextIterator(const std::string& str, const TextEncoding& encoding):
- _pEncoding(&encoding),
- _it(str.begin()),
- _end(str.end())
-{
-}
-
-
-TextIterator::TextIterator(const std::string::const_iterator& begin, const std::string::const_iterator& rEnd, const TextEncoding& encoding):
- _pEncoding(&encoding),
- _it(begin),
- _end(rEnd)
-{
-}
-
-
-TextIterator::TextIterator(const std::string& str):
- _pEncoding(0),
- _it(str.end()),
- _end(str.end())
-{
-}
-
-
-TextIterator::TextIterator(const std::string::const_iterator& rEnd):
- _pEncoding(0),
- _it(rEnd),
- _end(rEnd)
-{
-}
-
-
-TextIterator::~TextIterator()
-{
-}
-
-
-TextIterator::TextIterator(const TextIterator& it):
- _pEncoding(it._pEncoding),
- _it(it._it),
- _end(it._end)
-{
-}
-
-
-TextIterator& TextIterator::operator = (const TextIterator& it)
-{
- if (&it != this)
- {
- _pEncoding = it._pEncoding;
- _it = it._it;
- _end = it._end;
- }
- return *this;
-}
-
-
-void TextIterator::swap(TextIterator& it)
-{
- std::swap(_pEncoding, it._pEncoding);
- std::swap(_it, it._it);
- std::swap(_end, it._end);
-}
-
-
-int TextIterator::operator * () const
-{
- poco_check_ptr (_pEncoding);
- poco_assert (_it != _end);
- std::string::const_iterator it = _it;
-
- unsigned char buffer[TextEncoding::MAX_SEQUENCE_LENGTH];
- unsigned char* p = buffer;
-
- if (it != _end)
- *p++ = *it++;
- else
- *p++ = 0;
-
- int read = 1;
- int n = _pEncoding->queryConvert(buffer, 1);
-
- while (-1 > n && (_end - it) >= -n - read)
- {
- while (read < -n && it != _end)
- {
- *p++ = *it++;
- read++;
- }
- n = _pEncoding->queryConvert(buffer, read);
- }
-
- if (-1 > n)
- {
- return -1;
- }
- else
- {
- return n;
- }
-}
-
-
-TextIterator& TextIterator::operator ++ ()
-{
- poco_check_ptr (_pEncoding);
- poco_assert (_it != _end);
-
- unsigned char buffer[TextEncoding::MAX_SEQUENCE_LENGTH];
- unsigned char* p = buffer;
-
- if (_it != _end)
- *p++ = *_it++;
- else
- *p++ = 0;
-
- int read = 1;
- int n = _pEncoding->sequenceLength(buffer, 1);
-
- while (-1 > n && (_end - _it) >= -n - read)
- {
- while (read < -n && _it != _end)
- {
- *p++ = *_it++;
- read++;
- }
- n = _pEncoding->sequenceLength(buffer, read);
- }
- while (read < n && _it != _end)
+//
+// TextIterator.cpp
+//
+// Library: Foundation
+// Package: Text
+// Module: TextIterator
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/TextIterator.h"
+#include "Poco/TextEncoding.h"
+#include <algorithm>
+
+
+namespace Poco {
+
+
+TextIterator::TextIterator():
+ _pEncoding(0)
+{
+}
+
+
+TextIterator::TextIterator(const std::string& str, const TextEncoding& encoding):
+ _pEncoding(&encoding),
+ _it(str.begin()),
+ _end(str.end())
+{
+}
+
+
+TextIterator::TextIterator(const std::string::const_iterator& begin, const std::string::const_iterator& rEnd, const TextEncoding& encoding):
+ _pEncoding(&encoding),
+ _it(begin),
+ _end(rEnd)
+{
+}
+
+
+TextIterator::TextIterator(const std::string& str):
+ _pEncoding(0),
+ _it(str.end()),
+ _end(str.end())
+{
+}
+
+
+TextIterator::TextIterator(const std::string::const_iterator& rEnd):
+ _pEncoding(0),
+ _it(rEnd),
+ _end(rEnd)
+{
+}
+
+
+TextIterator::~TextIterator()
+{
+}
+
+
+TextIterator::TextIterator(const TextIterator& it):
+ _pEncoding(it._pEncoding),
+ _it(it._it),
+ _end(it._end)
+{
+}
+
+
+TextIterator& TextIterator::operator = (const TextIterator& it)
+{
+ if (&it != this)
{
- _it++;
- read++;
- }
-
- return *this;
-}
-
-
-TextIterator TextIterator::operator ++ (int)
-{
- TextIterator prev(*this);
- operator ++ ();
- return prev;
-}
-
-
-} // namespace Poco
+ _pEncoding = it._pEncoding;
+ _it = it._it;
+ _end = it._end;
+ }
+ return *this;
+}
+
+
+void TextIterator::swap(TextIterator& it)
+{
+ std::swap(_pEncoding, it._pEncoding);
+ std::swap(_it, it._it);
+ std::swap(_end, it._end);
+}
+
+
+int TextIterator::operator * () const
+{
+ poco_check_ptr (_pEncoding);
+ poco_assert (_it != _end);
+ std::string::const_iterator it = _it;
+
+ unsigned char buffer[TextEncoding::MAX_SEQUENCE_LENGTH];
+ unsigned char* p = buffer;
+
+ if (it != _end)
+ *p++ = *it++;
+ else
+ *p++ = 0;
+
+ int read = 1;
+ int n = _pEncoding->queryConvert(buffer, 1);
+
+ while (-1 > n && (_end - it) >= -n - read)
+ {
+ while (read < -n && it != _end)
+ {
+ *p++ = *it++;
+ read++;
+ }
+ n = _pEncoding->queryConvert(buffer, read);
+ }
+
+ if (-1 > n)
+ {
+ return -1;
+ }
+ else
+ {
+ return n;
+ }
+}
+
+
+TextIterator& TextIterator::operator ++ ()
+{
+ poco_check_ptr (_pEncoding);
+ poco_assert (_it != _end);
+
+ unsigned char buffer[TextEncoding::MAX_SEQUENCE_LENGTH];
+ unsigned char* p = buffer;
+
+ if (_it != _end)
+ *p++ = *_it++;
+ else
+ *p++ = 0;
+
+ int read = 1;
+ int n = _pEncoding->sequenceLength(buffer, 1);
+
+ while (-1 > n && (_end - _it) >= -n - read)
+ {
+ while (read < -n && _it != _end)
+ {
+ *p++ = *_it++;
+ read++;
+ }
+ n = _pEncoding->sequenceLength(buffer, read);
+ }
+ while (read < n && _it != _end)
+ {
+ _it++;
+ read++;
+ }
+
+ return *this;
+}
+
+
+TextIterator TextIterator::operator ++ (int)
+{
+ TextIterator prev(*this);
+ operator ++ ();
+ return prev;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Thread.cpp b/contrib/libs/poco/Foundation/src/Thread.cpp
index 6fc152e4b1..3e2526c468 100644
--- a/contrib/libs/poco/Foundation/src/Thread.cpp
+++ b/contrib/libs/poco/Foundation/src/Thread.cpp
@@ -1,212 +1,212 @@
-//
-// Thread.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: Thread
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Thread.h"
-#include "Poco/Mutex.h"
-#include "Poco/Exception.h"
-#include "Poco/ThreadLocal.h"
-#include "Poco/AtomicCounter.h"
-#include <sstream>
-
-
-#if defined(POCO_OS_FAMILY_WINDOWS)
-#if defined(_WIN32_WCE)
-#include "Thread_WINCE.cpp"
-#else
-#include "Thread_WIN32.cpp"
-#endif
-#elif defined(POCO_VXWORKS)
-#include "Thread_VX.cpp"
-#else
-#include "Thread_POSIX.cpp"
-#endif
-
-
-namespace Poco {
-
-
-namespace {
-
-class RunnableHolder: public Runnable
-{
-public:
- RunnableHolder(Runnable& target):
- _target(target)
- {
- }
-
- ~RunnableHolder()
- {
- }
-
- void run()
- {
- _target.run();
- }
-
-private:
- Runnable& _target;
-};
-
-
-class CallableHolder: public Runnable
-{
-public:
- CallableHolder(Thread::Callable callable, void* pData):
- _callable(callable),
- _pData(pData)
- {
- }
-
- ~CallableHolder()
- {
- }
-
- void run()
- {
- _callable(_pData);
- }
-
-private:
- Thread::Callable _callable;
- void* _pData;
-};
-
-
-} // namespace
-
-
-Thread::Thread():
- _id(uniqueId()),
- _name(makeName()),
- _pTLS(0),
- _event(true)
-{
-}
-
-
-Thread::Thread(const std::string& rName):
- _id(uniqueId()),
- _name(rName),
- _pTLS(0),
- _event(true)
-{
-}
-
-
-Thread::~Thread()
-{
- delete _pTLS;
-}
-
-
-void Thread::setPriority(Priority prio)
-{
- setPriorityImpl(prio);
-}
-
-
-Thread::Priority Thread::getPriority() const
-{
- return Priority(getPriorityImpl());
-}
-
-
-void Thread::start(Runnable& target)
-{
- startImpl(new RunnableHolder(target));
-}
-
-
-void Thread::start(Callable target, void* pData)
-{
- startImpl(new CallableHolder(target, pData));
-}
-
-
-void Thread::join()
-{
- joinImpl();
-}
-
-
-void Thread::join(long milliseconds)
-{
- if (!joinImpl(milliseconds))
- throw TimeoutException();
-}
-
-
-bool Thread::tryJoin(long milliseconds)
-{
- return joinImpl(milliseconds);
-}
-
-
-bool Thread::trySleep(long milliseconds)
-{
- Thread* pT = Thread::current();
- poco_check_ptr(pT);
- return !(pT->_event.tryWait(milliseconds));
-}
-
-
-void Thread::wakeUp()
-{
- _event.set();
-}
-
-
-ThreadLocalStorage& Thread::tls()
-{
- if (!_pTLS)
- _pTLS = new ThreadLocalStorage;
- return *_pTLS;
-}
-
-
-void Thread::clearTLS()
-{
- if (_pTLS)
- {
- delete _pTLS;
- _pTLS = 0;
- }
-}
-
-
-std::string Thread::makeName()
-{
- std::ostringstream threadName;
- threadName << '#' << _id;
- return threadName.str();
-}
-
-
-int Thread::uniqueId()
-{
- static Poco::AtomicCounter counter;
- return ++counter;
-}
-
-
-void Thread::setName(const std::string& rName)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- _name = rName;
-}
-
-
-} // namespace Poco
+//
+// Thread.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: Thread
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Thread.h"
+#include "Poco/Mutex.h"
+#include "Poco/Exception.h"
+#include "Poco/ThreadLocal.h"
+#include "Poco/AtomicCounter.h"
+#include <sstream>
+
+
+#if defined(POCO_OS_FAMILY_WINDOWS)
+#if defined(_WIN32_WCE)
+#include "Thread_WINCE.cpp"
+#else
+#include "Thread_WIN32.cpp"
+#endif
+#elif defined(POCO_VXWORKS)
+#include "Thread_VX.cpp"
+#else
+#include "Thread_POSIX.cpp"
+#endif
+
+
+namespace Poco {
+
+
+namespace {
+
+class RunnableHolder: public Runnable
+{
+public:
+ RunnableHolder(Runnable& target):
+ _target(target)
+ {
+ }
+
+ ~RunnableHolder()
+ {
+ }
+
+ void run()
+ {
+ _target.run();
+ }
+
+private:
+ Runnable& _target;
+};
+
+
+class CallableHolder: public Runnable
+{
+public:
+ CallableHolder(Thread::Callable callable, void* pData):
+ _callable(callable),
+ _pData(pData)
+ {
+ }
+
+ ~CallableHolder()
+ {
+ }
+
+ void run()
+ {
+ _callable(_pData);
+ }
+
+private:
+ Thread::Callable _callable;
+ void* _pData;
+};
+
+
+} // namespace
+
+
+Thread::Thread():
+ _id(uniqueId()),
+ _name(makeName()),
+ _pTLS(0),
+ _event(true)
+{
+}
+
+
+Thread::Thread(const std::string& rName):
+ _id(uniqueId()),
+ _name(rName),
+ _pTLS(0),
+ _event(true)
+{
+}
+
+
+Thread::~Thread()
+{
+ delete _pTLS;
+}
+
+
+void Thread::setPriority(Priority prio)
+{
+ setPriorityImpl(prio);
+}
+
+
+Thread::Priority Thread::getPriority() const
+{
+ return Priority(getPriorityImpl());
+}
+
+
+void Thread::start(Runnable& target)
+{
+ startImpl(new RunnableHolder(target));
+}
+
+
+void Thread::start(Callable target, void* pData)
+{
+ startImpl(new CallableHolder(target, pData));
+}
+
+
+void Thread::join()
+{
+ joinImpl();
+}
+
+
+void Thread::join(long milliseconds)
+{
+ if (!joinImpl(milliseconds))
+ throw TimeoutException();
+}
+
+
+bool Thread::tryJoin(long milliseconds)
+{
+ return joinImpl(milliseconds);
+}
+
+
+bool Thread::trySleep(long milliseconds)
+{
+ Thread* pT = Thread::current();
+ poco_check_ptr(pT);
+ return !(pT->_event.tryWait(milliseconds));
+}
+
+
+void Thread::wakeUp()
+{
+ _event.set();
+}
+
+
+ThreadLocalStorage& Thread::tls()
+{
+ if (!_pTLS)
+ _pTLS = new ThreadLocalStorage;
+ return *_pTLS;
+}
+
+
+void Thread::clearTLS()
+{
+ if (_pTLS)
+ {
+ delete _pTLS;
+ _pTLS = 0;
+ }
+}
+
+
+std::string Thread::makeName()
+{
+ std::ostringstream threadName;
+ threadName << '#' << _id;
+ return threadName.str();
+}
+
+
+int Thread::uniqueId()
+{
+ static Poco::AtomicCounter counter;
+ return ++counter;
+}
+
+
+void Thread::setName(const std::string& rName)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ _name = rName;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/ThreadLocal.cpp b/contrib/libs/poco/Foundation/src/ThreadLocal.cpp
index 3cc03f6966..71fd2e1aff 100644
--- a/contrib/libs/poco/Foundation/src/ThreadLocal.cpp
+++ b/contrib/libs/poco/Foundation/src/ThreadLocal.cpp
@@ -1,85 +1,85 @@
-//
-// ThreadLocal.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: Thread
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/ThreadLocal.h"
-#include "Poco/SingletonHolder.h"
-#include "Poco/Thread.h"
-
-
-namespace Poco {
-
-
-TLSAbstractSlot::TLSAbstractSlot()
-{
-}
-
-
-TLSAbstractSlot::~TLSAbstractSlot()
-{
-}
-
-
-ThreadLocalStorage::ThreadLocalStorage()
-{
-}
-
-
-ThreadLocalStorage::~ThreadLocalStorage()
-{
- for (TLSMap::iterator it = _map.begin(); it != _map.end(); ++it)
- {
- delete it->second;
- }
-}
-
-
-TLSAbstractSlot*& ThreadLocalStorage::get(const void* key)
-{
- TLSMap::iterator it = _map.find(key);
- if (it == _map.end())
- return _map.insert(TLSMap::value_type(key, reinterpret_cast<Poco::TLSAbstractSlot*>(0))).first->second;
- else
- return it->second;
-}
-
-
-namespace
-{
- static SingletonHolder<ThreadLocalStorage> sh;
-}
-
-
-ThreadLocalStorage& ThreadLocalStorage::current()
-{
- Thread* pThread = Thread::current();
- if (pThread)
- {
- return pThread->tls();
- }
- else
- {
- return *sh.get();
- }
-}
-
-
-void ThreadLocalStorage::clear()
-{
- Thread* pThread = Thread::current();
- if (pThread)
- pThread->clearTLS();
-}
-
-
-} // namespace Poco
+//
+// ThreadLocal.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: Thread
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/ThreadLocal.h"
+#include "Poco/SingletonHolder.h"
+#include "Poco/Thread.h"
+
+
+namespace Poco {
+
+
+TLSAbstractSlot::TLSAbstractSlot()
+{
+}
+
+
+TLSAbstractSlot::~TLSAbstractSlot()
+{
+}
+
+
+ThreadLocalStorage::ThreadLocalStorage()
+{
+}
+
+
+ThreadLocalStorage::~ThreadLocalStorage()
+{
+ for (TLSMap::iterator it = _map.begin(); it != _map.end(); ++it)
+ {
+ delete it->second;
+ }
+}
+
+
+TLSAbstractSlot*& ThreadLocalStorage::get(const void* key)
+{
+ TLSMap::iterator it = _map.find(key);
+ if (it == _map.end())
+ return _map.insert(TLSMap::value_type(key, reinterpret_cast<Poco::TLSAbstractSlot*>(0))).first->second;
+ else
+ return it->second;
+}
+
+
+namespace
+{
+ static SingletonHolder<ThreadLocalStorage> sh;
+}
+
+
+ThreadLocalStorage& ThreadLocalStorage::current()
+{
+ Thread* pThread = Thread::current();
+ if (pThread)
+ {
+ return pThread->tls();
+ }
+ else
+ {
+ return *sh.get();
+ }
+}
+
+
+void ThreadLocalStorage::clear()
+{
+ Thread* pThread = Thread::current();
+ if (pThread)
+ pThread->clearTLS();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/ThreadPool.cpp b/contrib/libs/poco/Foundation/src/ThreadPool.cpp
index 47716ce19f..5a03589cb2 100644
--- a/contrib/libs/poco/Foundation/src/ThreadPool.cpp
+++ b/contrib/libs/poco/Foundation/src/ThreadPool.cpp
@@ -1,527 +1,527 @@
-//
-// ThreadPool.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: ThreadPool
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/ThreadPool.h"
-#include "Poco/Runnable.h"
-#include "Poco/Thread.h"
-#include "Poco/Event.h"
-#include "Poco/ThreadLocal.h"
-#include "Poco/ErrorHandler.h"
-#include <sstream>
-#include <ctime>
-#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
-#error #include "wce_time.h"
-#endif
-
-
-namespace Poco {
-
-
-class PooledThread: public Runnable
-{
-public:
- PooledThread(const std::string& name, int stackSize = POCO_THREAD_STACK_SIZE);
- ~PooledThread();
-
- void start();
- void start(Thread::Priority priority, Runnable& target);
- void start(Thread::Priority priority, Runnable& target, const std::string& name);
- bool idle();
- int idleTime();
- void join();
- void activate();
- void release();
- void run();
-
-private:
- volatile bool _idle;
- volatile std::time_t _idleTime;
- Runnable* _pTarget;
- std::string _name;
- Thread _thread;
- Event _targetReady;
- Event _targetCompleted;
- Event _started;
- FastMutex _mutex;
-};
-
-
-PooledThread::PooledThread(const std::string& name, int stackSize):
- _idle(true),
- _idleTime(0),
- _pTarget(0),
- _name(name),
- _thread(name),
- _targetCompleted(false)
-{
- poco_assert_dbg (stackSize >= 0);
- _thread.setStackSize(stackSize);
-#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
- _idleTime = wceex_time(NULL);
-#else
- _idleTime = std::time(NULL);
-#endif
-}
-
-
-PooledThread::~PooledThread()
-{
-}
-
-
-void PooledThread::start()
-{
- _thread.start(*this);
- _started.wait();
-}
-
-
-void PooledThread::start(Thread::Priority priority, Runnable& target)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- poco_assert (_pTarget == 0);
-
- _pTarget = &target;
- _thread.setPriority(priority);
- _targetReady.set();
-}
-
-
-void PooledThread::start(Thread::Priority priority, Runnable& target, const std::string& name)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- std::string fullName(name);
- if (name.empty())
- {
- fullName = _name;
- }
- else
- {
- fullName.append(" (");
- fullName.append(_name);
- fullName.append(")");
- }
- _thread.setName(fullName);
- _thread.setPriority(priority);
-
- poco_assert (_pTarget == 0);
-
- _pTarget = &target;
- _targetReady.set();
-}
-
-
-inline bool PooledThread::idle()
-{
- FastMutex::ScopedLock lock(_mutex);
- return _idle;
-}
-
-
-int PooledThread::idleTime()
-{
- FastMutex::ScopedLock lock(_mutex);
-
-#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
- return (int) (wceex_time(NULL) - _idleTime);
-#else
- return (int) (time(NULL) - _idleTime);
-#endif
-}
-
-
-void PooledThread::join()
-{
- _mutex.lock();
- Runnable* pTarget = _pTarget;
- _mutex.unlock();
- if (pTarget)
- _targetCompleted.wait();
-}
-
-
-void PooledThread::activate()
-{
- FastMutex::ScopedLock lock(_mutex);
-
- poco_assert (_idle);
- _idle = false;
- _targetCompleted.reset();
-}
-
-
-void PooledThread::release()
-{
- const long JOIN_TIMEOUT = 10000;
-
- _mutex.lock();
- _pTarget = 0;
- _mutex.unlock();
- // In case of a statically allocated thread pool (such
- // as the default thread pool), Windows may have already
- // terminated the thread before we got here.
- if (_thread.isRunning())
- _targetReady.set();
-
- if (_thread.tryJoin(JOIN_TIMEOUT))
- {
- delete this;
- }
-}
-
-
-void PooledThread::run()
-{
- _started.set();
- for (;;)
- {
- _targetReady.wait();
- _mutex.lock();
- if (_pTarget) // a NULL target means kill yourself
- {
- Runnable* pTarget = _pTarget;
- _mutex.unlock();
- try
- {
- pTarget->run();
- }
- catch (Exception& exc)
- {
- ErrorHandler::handle(exc);
- }
- catch (std::exception& exc)
- {
- ErrorHandler::handle(exc);
- }
- catch (...)
- {
- ErrorHandler::handle();
- }
- FastMutex::ScopedLock lock(_mutex);
- _pTarget = 0;
-#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
- _idleTime = wceex_time(NULL);
-#else
- _idleTime = time(NULL);
-#endif
- _idle = true;
- _targetCompleted.set();
- ThreadLocalStorage::clear();
- _thread.setName(_name);
- _thread.setPriority(Thread::PRIO_NORMAL);
- }
- else
- {
- _mutex.unlock();
- break;
- }
- }
-}
-
-
-ThreadPool::ThreadPool(int minCapacity,
- int maxCapacity,
- int idleTime,
+//
+// ThreadPool.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: ThreadPool
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/ThreadPool.h"
+#include "Poco/Runnable.h"
+#include "Poco/Thread.h"
+#include "Poco/Event.h"
+#include "Poco/ThreadLocal.h"
+#include "Poco/ErrorHandler.h"
+#include <sstream>
+#include <ctime>
+#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
+#error #include "wce_time.h"
+#endif
+
+
+namespace Poco {
+
+
+class PooledThread: public Runnable
+{
+public:
+ PooledThread(const std::string& name, int stackSize = POCO_THREAD_STACK_SIZE);
+ ~PooledThread();
+
+ void start();
+ void start(Thread::Priority priority, Runnable& target);
+ void start(Thread::Priority priority, Runnable& target, const std::string& name);
+ bool idle();
+ int idleTime();
+ void join();
+ void activate();
+ void release();
+ void run();
+
+private:
+ volatile bool _idle;
+ volatile std::time_t _idleTime;
+ Runnable* _pTarget;
+ std::string _name;
+ Thread _thread;
+ Event _targetReady;
+ Event _targetCompleted;
+ Event _started;
+ FastMutex _mutex;
+};
+
+
+PooledThread::PooledThread(const std::string& name, int stackSize):
+ _idle(true),
+ _idleTime(0),
+ _pTarget(0),
+ _name(name),
+ _thread(name),
+ _targetCompleted(false)
+{
+ poco_assert_dbg (stackSize >= 0);
+ _thread.setStackSize(stackSize);
+#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
+ _idleTime = wceex_time(NULL);
+#else
+ _idleTime = std::time(NULL);
+#endif
+}
+
+
+PooledThread::~PooledThread()
+{
+}
+
+
+void PooledThread::start()
+{
+ _thread.start(*this);
+ _started.wait();
+}
+
+
+void PooledThread::start(Thread::Priority priority, Runnable& target)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ poco_assert (_pTarget == 0);
+
+ _pTarget = &target;
+ _thread.setPriority(priority);
+ _targetReady.set();
+}
+
+
+void PooledThread::start(Thread::Priority priority, Runnable& target, const std::string& name)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ std::string fullName(name);
+ if (name.empty())
+ {
+ fullName = _name;
+ }
+ else
+ {
+ fullName.append(" (");
+ fullName.append(_name);
+ fullName.append(")");
+ }
+ _thread.setName(fullName);
+ _thread.setPriority(priority);
+
+ poco_assert (_pTarget == 0);
+
+ _pTarget = &target;
+ _targetReady.set();
+}
+
+
+inline bool PooledThread::idle()
+{
+ FastMutex::ScopedLock lock(_mutex);
+ return _idle;
+}
+
+
+int PooledThread::idleTime()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
+ return (int) (wceex_time(NULL) - _idleTime);
+#else
+ return (int) (time(NULL) - _idleTime);
+#endif
+}
+
+
+void PooledThread::join()
+{
+ _mutex.lock();
+ Runnable* pTarget = _pTarget;
+ _mutex.unlock();
+ if (pTarget)
+ _targetCompleted.wait();
+}
+
+
+void PooledThread::activate()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ poco_assert (_idle);
+ _idle = false;
+ _targetCompleted.reset();
+}
+
+
+void PooledThread::release()
+{
+ const long JOIN_TIMEOUT = 10000;
+
+ _mutex.lock();
+ _pTarget = 0;
+ _mutex.unlock();
+ // In case of a statically allocated thread pool (such
+ // as the default thread pool), Windows may have already
+ // terminated the thread before we got here.
+ if (_thread.isRunning())
+ _targetReady.set();
+
+ if (_thread.tryJoin(JOIN_TIMEOUT))
+ {
+ delete this;
+ }
+}
+
+
+void PooledThread::run()
+{
+ _started.set();
+ for (;;)
+ {
+ _targetReady.wait();
+ _mutex.lock();
+ if (_pTarget) // a NULL target means kill yourself
+ {
+ Runnable* pTarget = _pTarget;
+ _mutex.unlock();
+ try
+ {
+ pTarget->run();
+ }
+ catch (Exception& exc)
+ {
+ ErrorHandler::handle(exc);
+ }
+ catch (std::exception& exc)
+ {
+ ErrorHandler::handle(exc);
+ }
+ catch (...)
+ {
+ ErrorHandler::handle();
+ }
+ FastMutex::ScopedLock lock(_mutex);
+ _pTarget = 0;
+#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
+ _idleTime = wceex_time(NULL);
+#else
+ _idleTime = time(NULL);
+#endif
+ _idle = true;
+ _targetCompleted.set();
+ ThreadLocalStorage::clear();
+ _thread.setName(_name);
+ _thread.setPriority(Thread::PRIO_NORMAL);
+ }
+ else
+ {
+ _mutex.unlock();
+ break;
+ }
+ }
+}
+
+
+ThreadPool::ThreadPool(int minCapacity,
+ int maxCapacity,
+ int idleTime,
+ int stackSize):
+ _minCapacity(minCapacity),
+ _maxCapacity(maxCapacity),
+ _idleTime(idleTime),
+ _serial(0),
+ _age(0),
+ _stackSize(stackSize)
+{
+ poco_assert (minCapacity >= 1 && maxCapacity >= minCapacity && idleTime > 0);
+
+ for (int i = 0; i < _minCapacity; i++)
+ {
+ PooledThread* pThread = createThread();
+ _threads.push_back(pThread);
+ pThread->start();
+ }
+}
+
+
+ThreadPool::ThreadPool(const std::string& rName,
+ int minCapacity,
+ int maxCapacity,
+ int idleTime,
int stackSize):
- _minCapacity(minCapacity),
- _maxCapacity(maxCapacity),
- _idleTime(idleTime),
- _serial(0),
- _age(0),
- _stackSize(stackSize)
-{
- poco_assert (minCapacity >= 1 && maxCapacity >= minCapacity && idleTime > 0);
-
- for (int i = 0; i < _minCapacity; i++)
- {
- PooledThread* pThread = createThread();
- _threads.push_back(pThread);
- pThread->start();
- }
-}
-
-
-ThreadPool::ThreadPool(const std::string& rName,
- int minCapacity,
- int maxCapacity,
- int idleTime,
- int stackSize):
- _name(rName),
- _minCapacity(minCapacity),
- _maxCapacity(maxCapacity),
- _idleTime(idleTime),
- _serial(0),
- _age(0),
- _stackSize(stackSize)
-{
- poco_assert (minCapacity >= 1 && maxCapacity >= minCapacity && idleTime > 0);
-
- for (int i = 0; i < _minCapacity; i++)
- {
- PooledThread* pThread = createThread();
- _threads.push_back(pThread);
- pThread->start();
- }
-}
-
-
-ThreadPool::~ThreadPool()
-{
- try
- {
- stopAll();
- }
- catch (...)
- {
- poco_unexpected();
- }
-}
-
-
-void ThreadPool::addCapacity(int n)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- poco_assert (_maxCapacity + n >= _minCapacity);
- _maxCapacity += n;
- housekeep();
-}
-
-
-int ThreadPool::capacity() const
-{
- FastMutex::ScopedLock lock(_mutex);
- return _maxCapacity;
-}
-
-
-int ThreadPool::available() const
-{
- FastMutex::ScopedLock lock(_mutex);
-
- int count = 0;
- for (ThreadVec::const_iterator it = _threads.begin(); it != _threads.end(); ++it)
- {
- if ((*it)->idle()) ++count;
- }
- return (int) (count + _maxCapacity - _threads.size());
-}
-
-
-int ThreadPool::used() const
-{
- FastMutex::ScopedLock lock(_mutex);
-
- int count = 0;
- for (ThreadVec::const_iterator it = _threads.begin(); it != _threads.end(); ++it)
- {
- if (!(*it)->idle()) ++count;
- }
- return count;
-}
-
-
-int ThreadPool::allocated() const
-{
- FastMutex::ScopedLock lock(_mutex);
-
- return int(_threads.size());
-}
-
-
-void ThreadPool::start(Runnable& target)
-{
- getThread()->start(Thread::PRIO_NORMAL, target);
-}
-
-
-void ThreadPool::start(Runnable& target, const std::string& rName)
-{
- getThread()->start(Thread::PRIO_NORMAL, target, rName);
-}
-
-
-void ThreadPool::startWithPriority(Thread::Priority priority, Runnable& target)
-{
- getThread()->start(priority, target);
-}
-
-
-void ThreadPool::startWithPriority(Thread::Priority priority, Runnable& target, const std::string& rName)
-{
- getThread()->start(priority, target, rName);
-}
-
-
-void ThreadPool::stopAll()
-{
- FastMutex::ScopedLock lock(_mutex);
-
- for (ThreadVec::iterator it = _threads.begin(); it != _threads.end(); ++it)
- {
- (*it)->release();
- }
- _threads.clear();
-}
-
-
-void ThreadPool::joinAll()
-{
- FastMutex::ScopedLock lock(_mutex);
-
- for (ThreadVec::iterator it = _threads.begin(); it != _threads.end(); ++it)
- {
- (*it)->join();
- }
- housekeep();
-}
-
-
-void ThreadPool::collect()
-{
- FastMutex::ScopedLock lock(_mutex);
- housekeep();
-}
-
-
-void ThreadPool::housekeep()
-{
- _age = 0;
- if (_threads.size() <= _minCapacity)
- return;
-
- ThreadVec idleThreads;
- ThreadVec expiredThreads;
- ThreadVec activeThreads;
- idleThreads.reserve(_threads.size());
- activeThreads.reserve(_threads.size());
-
- for (ThreadVec::iterator it = _threads.begin(); it != _threads.end(); ++it)
- {
- if ((*it)->idle())
- {
- if ((*it)->idleTime() < _idleTime)
- idleThreads.push_back(*it);
- else
- expiredThreads.push_back(*it);
- }
- else activeThreads.push_back(*it);
- }
- int n = (int) activeThreads.size();
- int limit = (int) idleThreads.size() + n;
- if (limit < _minCapacity) limit = _minCapacity;
- idleThreads.insert(idleThreads.end(), expiredThreads.begin(), expiredThreads.end());
- _threads.clear();
- for (ThreadVec::iterator it = idleThreads.begin(); it != idleThreads.end(); ++it)
- {
- if (n < limit)
- {
- _threads.push_back(*it);
- ++n;
- }
- else (*it)->release();
- }
- _threads.insert(_threads.end(), activeThreads.begin(), activeThreads.end());
-}
-
-
-PooledThread* ThreadPool::getThread()
-{
- FastMutex::ScopedLock lock(_mutex);
-
- if (++_age == 32)
- housekeep();
-
- PooledThread* pThread = 0;
- for (ThreadVec::iterator it = _threads.begin(); !pThread && it != _threads.end(); ++it)
- {
- if ((*it)->idle())
- pThread = *it;
- }
- if (!pThread)
- {
- if (_threads.size() < _maxCapacity)
- {
- pThread = createThread();
- try
- {
- pThread->start();
- _threads.push_back(pThread);
- } catch (...)
- {
- delete pThread;
- throw;
- }
- }
- else
- throw NoThreadAvailableException();
- }
- pThread->activate();
- return pThread;
-}
-
-
-PooledThread* ThreadPool::createThread()
-{
- std::ostringstream threadName;
- threadName << _name << "[#" << ++_serial << "]";
- return new PooledThread(threadName.str(), _stackSize);
-}
-
-
-class ThreadPoolSingletonHolder
-{
-public:
- ThreadPoolSingletonHolder()
- {
- _pPool = 0;
- }
- ~ThreadPoolSingletonHolder()
- {
- delete _pPool;
- }
- ThreadPool* pool()
- {
- FastMutex::ScopedLock lock(_mutex);
-
- if (!_pPool)
- {
- _pPool = new ThreadPool("default");
- if (POCO_THREAD_STACK_SIZE > 0)
- _pPool->setStackSize(POCO_THREAD_STACK_SIZE);
- }
- return _pPool;
- }
-
-private:
- ThreadPool* _pPool;
- FastMutex _mutex;
-};
-
-
-namespace
-{
- static ThreadPoolSingletonHolder sh;
-}
-
-
-ThreadPool& ThreadPool::defaultPool()
-{
- return *sh.pool();
-}
-
-
-} // namespace Poco
+ _name(rName),
+ _minCapacity(minCapacity),
+ _maxCapacity(maxCapacity),
+ _idleTime(idleTime),
+ _serial(0),
+ _age(0),
+ _stackSize(stackSize)
+{
+ poco_assert (minCapacity >= 1 && maxCapacity >= minCapacity && idleTime > 0);
+
+ for (int i = 0; i < _minCapacity; i++)
+ {
+ PooledThread* pThread = createThread();
+ _threads.push_back(pThread);
+ pThread->start();
+ }
+}
+
+
+ThreadPool::~ThreadPool()
+{
+ try
+ {
+ stopAll();
+ }
+ catch (...)
+ {
+ poco_unexpected();
+ }
+}
+
+
+void ThreadPool::addCapacity(int n)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ poco_assert (_maxCapacity + n >= _minCapacity);
+ _maxCapacity += n;
+ housekeep();
+}
+
+
+int ThreadPool::capacity() const
+{
+ FastMutex::ScopedLock lock(_mutex);
+ return _maxCapacity;
+}
+
+
+int ThreadPool::available() const
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ int count = 0;
+ for (ThreadVec::const_iterator it = _threads.begin(); it != _threads.end(); ++it)
+ {
+ if ((*it)->idle()) ++count;
+ }
+ return (int) (count + _maxCapacity - _threads.size());
+}
+
+
+int ThreadPool::used() const
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ int count = 0;
+ for (ThreadVec::const_iterator it = _threads.begin(); it != _threads.end(); ++it)
+ {
+ if (!(*it)->idle()) ++count;
+ }
+ return count;
+}
+
+
+int ThreadPool::allocated() const
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ return int(_threads.size());
+}
+
+
+void ThreadPool::start(Runnable& target)
+{
+ getThread()->start(Thread::PRIO_NORMAL, target);
+}
+
+
+void ThreadPool::start(Runnable& target, const std::string& rName)
+{
+ getThread()->start(Thread::PRIO_NORMAL, target, rName);
+}
+
+
+void ThreadPool::startWithPriority(Thread::Priority priority, Runnable& target)
+{
+ getThread()->start(priority, target);
+}
+
+
+void ThreadPool::startWithPriority(Thread::Priority priority, Runnable& target, const std::string& rName)
+{
+ getThread()->start(priority, target, rName);
+}
+
+
+void ThreadPool::stopAll()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ for (ThreadVec::iterator it = _threads.begin(); it != _threads.end(); ++it)
+ {
+ (*it)->release();
+ }
+ _threads.clear();
+}
+
+
+void ThreadPool::joinAll()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ for (ThreadVec::iterator it = _threads.begin(); it != _threads.end(); ++it)
+ {
+ (*it)->join();
+ }
+ housekeep();
+}
+
+
+void ThreadPool::collect()
+{
+ FastMutex::ScopedLock lock(_mutex);
+ housekeep();
+}
+
+
+void ThreadPool::housekeep()
+{
+ _age = 0;
+ if (_threads.size() <= _minCapacity)
+ return;
+
+ ThreadVec idleThreads;
+ ThreadVec expiredThreads;
+ ThreadVec activeThreads;
+ idleThreads.reserve(_threads.size());
+ activeThreads.reserve(_threads.size());
+
+ for (ThreadVec::iterator it = _threads.begin(); it != _threads.end(); ++it)
+ {
+ if ((*it)->idle())
+ {
+ if ((*it)->idleTime() < _idleTime)
+ idleThreads.push_back(*it);
+ else
+ expiredThreads.push_back(*it);
+ }
+ else activeThreads.push_back(*it);
+ }
+ int n = (int) activeThreads.size();
+ int limit = (int) idleThreads.size() + n;
+ if (limit < _minCapacity) limit = _minCapacity;
+ idleThreads.insert(idleThreads.end(), expiredThreads.begin(), expiredThreads.end());
+ _threads.clear();
+ for (ThreadVec::iterator it = idleThreads.begin(); it != idleThreads.end(); ++it)
+ {
+ if (n < limit)
+ {
+ _threads.push_back(*it);
+ ++n;
+ }
+ else (*it)->release();
+ }
+ _threads.insert(_threads.end(), activeThreads.begin(), activeThreads.end());
+}
+
+
+PooledThread* ThreadPool::getThread()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (++_age == 32)
+ housekeep();
+
+ PooledThread* pThread = 0;
+ for (ThreadVec::iterator it = _threads.begin(); !pThread && it != _threads.end(); ++it)
+ {
+ if ((*it)->idle())
+ pThread = *it;
+ }
+ if (!pThread)
+ {
+ if (_threads.size() < _maxCapacity)
+ {
+ pThread = createThread();
+ try
+ {
+ pThread->start();
+ _threads.push_back(pThread);
+ } catch (...)
+ {
+ delete pThread;
+ throw;
+ }
+ }
+ else
+ throw NoThreadAvailableException();
+ }
+ pThread->activate();
+ return pThread;
+}
+
+
+PooledThread* ThreadPool::createThread()
+{
+ std::ostringstream threadName;
+ threadName << _name << "[#" << ++_serial << "]";
+ return new PooledThread(threadName.str(), _stackSize);
+}
+
+
+class ThreadPoolSingletonHolder
+{
+public:
+ ThreadPoolSingletonHolder()
+ {
+ _pPool = 0;
+ }
+ ~ThreadPoolSingletonHolder()
+ {
+ delete _pPool;
+ }
+ ThreadPool* pool()
+ {
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (!_pPool)
+ {
+ _pPool = new ThreadPool("default");
+ if (POCO_THREAD_STACK_SIZE > 0)
+ _pPool->setStackSize(POCO_THREAD_STACK_SIZE);
+ }
+ return _pPool;
+ }
+
+private:
+ ThreadPool* _pPool;
+ FastMutex _mutex;
+};
+
+
+namespace
+{
+ static ThreadPoolSingletonHolder sh;
+}
+
+
+ThreadPool& ThreadPool::defaultPool()
+{
+ return *sh.pool();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/ThreadTarget.cpp b/contrib/libs/poco/Foundation/src/ThreadTarget.cpp
index 054cee8cbd..e9fbf7a44e 100644
--- a/contrib/libs/poco/Foundation/src/ThreadTarget.cpp
+++ b/contrib/libs/poco/Foundation/src/ThreadTarget.cpp
@@ -1,43 +1,43 @@
-//
-// ThreadTarget.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: ThreadTarget
-//
-// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/ThreadTarget.h"
-
-
-namespace Poco {
-
-
-ThreadTarget::ThreadTarget(Callback method): _method(method)
-{
-}
-
-
-ThreadTarget::ThreadTarget(const ThreadTarget& te): _method(te._method)
-{
-}
-
-
-ThreadTarget& ThreadTarget::operator = (const ThreadTarget& te)
-{
- _method = te._method;
- return *this;
-}
-
-
-ThreadTarget::~ThreadTarget()
-{
-}
-
-
-} // namespace Poco
+//
+// ThreadTarget.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: ThreadTarget
+//
+// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/ThreadTarget.h"
+
+
+namespace Poco {
+
+
+ThreadTarget::ThreadTarget(Callback method): _method(method)
+{
+}
+
+
+ThreadTarget::ThreadTarget(const ThreadTarget& te): _method(te._method)
+{
+}
+
+
+ThreadTarget& ThreadTarget::operator = (const ThreadTarget& te)
+{
+ _method = te._method;
+ return *this;
+}
+
+
+ThreadTarget::~ThreadTarget()
+{
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Thread_POSIX.cpp b/contrib/libs/poco/Foundation/src/Thread_POSIX.cpp
index ac3eefdeb7..291b50de0b 100644
--- a/contrib/libs/poco/Foundation/src/Thread_POSIX.cpp
+++ b/contrib/libs/poco/Foundation/src/Thread_POSIX.cpp
@@ -1,412 +1,412 @@
-//
-// Thread_POSIX.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: Thread
-//
-// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Thread_POSIX.h"
-#include "Poco/Thread.h"
-#include "Poco/Exception.h"
-#include "Poco/ErrorHandler.h"
-#include "Poco/Timespan.h"
-#include "Poco/Timestamp.h"
-#include <signal.h>
-#if defined(__sun) && defined(__SVR4)
-# if !defined(__EXTENSIONS__)
-# define __EXTENSIONS__
-# endif
-#endif
-#if POCO_OS == POCO_OS_LINUX || POCO_OS == POCO_OS_ANDROID || POCO_OS == POCO_OS_MAC_OS_X || POCO_OS == POCO_OS_QNX
-# include <time.h>
-#endif
-
-//
-// Block SIGPIPE in main thread.
-//
-#if defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_VXWORKS)
-namespace
-{
- class SignalBlocker
- {
- public:
- SignalBlocker()
- {
- sigset_t sset;
- sigemptyset(&sset);
- sigaddset(&sset, SIGPIPE);
- pthread_sigmask(SIG_BLOCK, &sset, 0);
- }
- ~SignalBlocker()
- {
- }
- };
-
- static SignalBlocker signalBlocker;
-}
-#endif
-
-
-#if defined(POCO_POSIX_DEBUGGER_THREAD_NAMES)
-
-
-namespace {
-void setThreadName(pthread_t thread, const std::string& threadName)
-{
-#if (POCO_OS == POCO_OS_MAC_OS_X)
- pthread_setname_np(threadName.c_str()); // __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
-#else
- if (pthread_setname_np(thread, threadName.c_str()) == ERANGE && threadName.size() > 15)
- {
- std::string truncName(threadName, 0, 7);
- truncName.append("~");
- truncName.append(threadName, threadName.size() - 7, 7);
- pthread_setname_np(thread, truncName.c_str());
- }
-#endif
-}
-}
-
-
-#endif
-
-
-namespace Poco {
-
-
-ThreadImpl::CurrentThreadHolder ThreadImpl::_currentThreadHolder;
-
-
-ThreadImpl::ThreadImpl():
- _pData(new ThreadData)
-{
-}
-
-
-ThreadImpl::~ThreadImpl()
-{
- if (_pData->started && !_pData->joined)
- {
- pthread_detach(_pData->thread);
- }
-}
-
-
-void ThreadImpl::setPriorityImpl(int prio)
-{
- if (prio != _pData->prio)
- {
- _pData->prio = prio;
- _pData->policy = SCHED_OTHER;
- if (isRunningImpl())
- {
- struct sched_param par; struct MyStruct
- {
-
- };
- par.sched_priority = mapPrio(_pData->prio, SCHED_OTHER);
- if (pthread_setschedparam(_pData->thread, SCHED_OTHER, &par))
- throw SystemException("cannot set thread priority");
- }
- }
-}
-
-
-void ThreadImpl::setOSPriorityImpl(int prio, int policy)
-{
- if (prio != _pData->osPrio || policy != _pData->policy)
- {
- if (_pData->pRunnableTarget)
- {
- struct sched_param par;
- par.sched_priority = prio;
- if (pthread_setschedparam(_pData->thread, policy, &par))
- throw SystemException("cannot set thread priority");
- }
- _pData->prio = reverseMapPrio(prio, policy);
- _pData->osPrio = prio;
- _pData->policy = policy;
- }
-}
-
-
-int ThreadImpl::getMinOSPriorityImpl(int policy)
-{
-#if defined(POCO_THREAD_PRIORITY_MIN)
- return POCO_THREAD_PRIORITY_MIN;
-#elif defined(__digital__)
- return PRI_OTHER_MIN;
-#else
- return sched_get_priority_min(policy);
-#endif
-}
-
-
-int ThreadImpl::getMaxOSPriorityImpl(int policy)
-{
-#if defined(POCO_THREAD_PRIORITY_MAX)
- return POCO_THREAD_PRIORITY_MAX;
-#elif defined(__digital__)
- return PRI_OTHER_MAX;
-#else
- return sched_get_priority_max(policy);
-#endif
-}
-
-
-void ThreadImpl::setStackSizeImpl(int size)
-{
-#ifndef PTHREAD_STACK_MIN
- _pData->stackSize = 0;
-#else
- if (size != 0)
- {
-#if defined(POCO_OS_FAMILY_BSD)
- // we must round up to a multiple of the memory page size
- const int STACK_PAGE_SIZE = 4096;
- size = ((size + STACK_PAGE_SIZE - 1)/STACK_PAGE_SIZE)*STACK_PAGE_SIZE;
-#endif
- if (size < PTHREAD_STACK_MIN)
- size = PTHREAD_STACK_MIN;
- }
- _pData->stackSize = size;
-#endif
-}
-
-
-void ThreadImpl::startImpl(SharedPtr<Runnable> pTarget)
-{
- if (_pData->pRunnableTarget)
- throw SystemException("thread already running");
-
- pthread_attr_t attributes;
- pthread_attr_init(&attributes);
-
- if (_pData->stackSize != 0)
- {
- if (0 != pthread_attr_setstacksize(&attributes, _pData->stackSize))
- {
- pthread_attr_destroy(&attributes);
- throw SystemException("cannot set thread stack size");
- }
- }
-
- _pData->pRunnableTarget = pTarget;
- if (pthread_create(&_pData->thread, &attributes, runnableEntry, this))
- {
- _pData->pRunnableTarget = 0;
- pthread_attr_destroy(&attributes);
- throw SystemException("cannot start thread");
- }
- _pData->started = true;
- pthread_attr_destroy(&attributes);
-
- if (_pData->policy == SCHED_OTHER)
- {
- if (_pData->prio != PRIO_NORMAL_IMPL)
- {
- struct sched_param par;
- par.sched_priority = mapPrio(_pData->prio, SCHED_OTHER);
- if (pthread_setschedparam(_pData->thread, SCHED_OTHER, &par))
- throw SystemException("cannot set thread priority");
- }
- }
- else
- {
- struct sched_param par;
- par.sched_priority = _pData->osPrio;
- if (pthread_setschedparam(_pData->thread, _pData->policy, &par))
- throw SystemException("cannot set thread priority");
- }
-}
-
-
-void ThreadImpl::joinImpl()
-{
- if (!_pData->started) return;
- _pData->done.wait();
- void* result;
- if (pthread_join(_pData->thread, &result))
- throw SystemException("cannot join thread");
- _pData->joined = true;
-}
-
-
-bool ThreadImpl::joinImpl(long milliseconds)
-{
- if (_pData->started && _pData->done.tryWait(milliseconds))
- {
- void* result;
- if (pthread_join(_pData->thread, &result))
- throw SystemException("cannot join thread");
- _pData->joined = true;
- return true;
- }
- else if (_pData->started) return false;
- else return true;
-}
-
-
-ThreadImpl* ThreadImpl::currentImpl()
-{
- return _currentThreadHolder.get();
-}
-
-
-ThreadImpl::TIDImpl ThreadImpl::currentTidImpl()
-{
- return pthread_self();
-}
-
-
-void ThreadImpl::sleepImpl(long milliseconds)
-{
-#if defined(__digital__)
- // This is specific to DECThreads
- struct timespec interval;
- interval.tv_sec = milliseconds / 1000;
- interval.tv_nsec = (milliseconds % 1000)*1000000;
- pthread_delay_np(&interval);
-#elif POCO_OS == POCO_OS_LINUX || POCO_OS == POCO_OS_ANDROID || POCO_OS == POCO_OS_MAC_OS_X || POCO_OS == POCO_OS_QNX || POCO_OS == POCO_OS_VXWORKS
- Poco::Timespan remainingTime(1000*Poco::Timespan::TimeDiff(milliseconds));
- int rc;
- do
- {
- struct timespec ts;
- ts.tv_sec = (long) remainingTime.totalSeconds();
- ts.tv_nsec = (long) remainingTime.useconds()*1000;
- Poco::Timestamp start;
- rc = ::nanosleep(&ts, 0);
- if (rc < 0 && errno == EINTR)
- {
- Poco::Timestamp end;
- Poco::Timespan waited = start.elapsed();
- if (waited < remainingTime)
- remainingTime -= waited;
- else
- remainingTime = 0;
- }
- }
- while (remainingTime > 0 && rc < 0 && errno == EINTR);
- if (rc < 0 && remainingTime > 0) throw Poco::SystemException("Thread::sleep(): nanosleep() failed");
-#else
- Poco::Timespan remainingTime(1000*Poco::Timespan::TimeDiff(milliseconds));
- int rc;
- do
- {
- struct timeval tv;
- tv.tv_sec = (long) remainingTime.totalSeconds();
- tv.tv_usec = (long) remainingTime.useconds();
- Poco::Timestamp start;
- rc = ::select(0, NULL, NULL, NULL, &tv);
- if (rc < 0 && errno == EINTR)
- {
- Poco::Timestamp end;
- Poco::Timespan waited = start.elapsed();
- if (waited < remainingTime)
- remainingTime -= waited;
- else
- remainingTime = 0;
- }
- }
- while (remainingTime > 0 && rc < 0 && errno == EINTR);
- if (rc < 0 && remainingTime > 0) throw Poco::SystemException("Thread::sleep(): select() failed");
-#endif
-}
-
-
-void* ThreadImpl::runnableEntry(void* pThread)
-{
- _currentThreadHolder.set(reinterpret_cast<ThreadImpl*>(pThread));
-
-#if defined(POCO_OS_FAMILY_UNIX)
- sigset_t sset;
- sigemptyset(&sset);
- sigaddset(&sset, SIGQUIT);
- sigaddset(&sset, SIGTERM);
- sigaddset(&sset, SIGPIPE);
- pthread_sigmask(SIG_BLOCK, &sset, 0);
-#endif
-
- ThreadImpl* pThreadImpl = reinterpret_cast<ThreadImpl*>(pThread);
-#if defined(POCO_POSIX_DEBUGGER_THREAD_NAMES)
- setThreadName(pThreadImpl->_pData->thread, reinterpret_cast<Thread*>(pThread)->getName());
-#endif
- AutoPtr<ThreadData> pData = pThreadImpl->_pData;
- try
- {
- pData->pRunnableTarget->run();
- }
- catch (Exception& exc)
- {
- ErrorHandler::handle(exc);
- }
- catch (std::exception& exc)
- {
- ErrorHandler::handle(exc);
- }
- catch (...)
- {
- ErrorHandler::handle();
- }
-
- pData->pRunnableTarget = 0;
- pData->done.set();
- return 0;
-}
-
-
-int ThreadImpl::mapPrio(int prio, int policy)
-{
- int pmin = getMinOSPriorityImpl(policy);
- int pmax = getMaxOSPriorityImpl(policy);
-
- switch (prio)
- {
- case PRIO_LOWEST_IMPL:
- return pmin;
- case PRIO_LOW_IMPL:
- return pmin + (pmax - pmin)/4;
- case PRIO_NORMAL_IMPL:
- return pmin + (pmax - pmin)/2;
- case PRIO_HIGH_IMPL:
- return pmin + 3*(pmax - pmin)/4;
- case PRIO_HIGHEST_IMPL:
- return pmax;
- default:
- poco_bugcheck_msg("invalid thread priority");
- }
- return -1; // just to satisfy compiler - we'll never get here anyway
-}
-
-
-int ThreadImpl::reverseMapPrio(int prio, int policy)
-{
- if (policy == SCHED_OTHER)
- {
- int pmin = getMinOSPriorityImpl(policy);
- int pmax = getMaxOSPriorityImpl(policy);
- int normal = pmin + (pmax - pmin)/2;
- if (prio == pmax)
- return PRIO_HIGHEST_IMPL;
- if (prio > normal)
- return PRIO_HIGH_IMPL;
- else if (prio == normal)
- return PRIO_NORMAL_IMPL;
- else if (prio > pmin)
- return PRIO_LOW_IMPL;
- else
- return PRIO_LOWEST_IMPL;
- }
- else return PRIO_HIGHEST_IMPL;
-}
-
-
-} // namespace Poco
+//
+// Thread_POSIX.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: Thread
+//
+// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Thread_POSIX.h"
+#include "Poco/Thread.h"
+#include "Poco/Exception.h"
+#include "Poco/ErrorHandler.h"
+#include "Poco/Timespan.h"
+#include "Poco/Timestamp.h"
+#include <signal.h>
+#if defined(__sun) && defined(__SVR4)
+# if !defined(__EXTENSIONS__)
+# define __EXTENSIONS__
+# endif
+#endif
+#if POCO_OS == POCO_OS_LINUX || POCO_OS == POCO_OS_ANDROID || POCO_OS == POCO_OS_MAC_OS_X || POCO_OS == POCO_OS_QNX
+# include <time.h>
+#endif
+
+//
+// Block SIGPIPE in main thread.
+//
+#if defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_VXWORKS)
+namespace
+{
+ class SignalBlocker
+ {
+ public:
+ SignalBlocker()
+ {
+ sigset_t sset;
+ sigemptyset(&sset);
+ sigaddset(&sset, SIGPIPE);
+ pthread_sigmask(SIG_BLOCK, &sset, 0);
+ }
+ ~SignalBlocker()
+ {
+ }
+ };
+
+ static SignalBlocker signalBlocker;
+}
+#endif
+
+
+#if defined(POCO_POSIX_DEBUGGER_THREAD_NAMES)
+
+
+namespace {
+void setThreadName(pthread_t thread, const std::string& threadName)
+{
+#if (POCO_OS == POCO_OS_MAC_OS_X)
+ pthread_setname_np(threadName.c_str()); // __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
+#else
+ if (pthread_setname_np(thread, threadName.c_str()) == ERANGE && threadName.size() > 15)
+ {
+ std::string truncName(threadName, 0, 7);
+ truncName.append("~");
+ truncName.append(threadName, threadName.size() - 7, 7);
+ pthread_setname_np(thread, truncName.c_str());
+ }
+#endif
+}
+}
+
+
+#endif
+
+
+namespace Poco {
+
+
+ThreadImpl::CurrentThreadHolder ThreadImpl::_currentThreadHolder;
+
+
+ThreadImpl::ThreadImpl():
+ _pData(new ThreadData)
+{
+}
+
+
+ThreadImpl::~ThreadImpl()
+{
+ if (_pData->started && !_pData->joined)
+ {
+ pthread_detach(_pData->thread);
+ }
+}
+
+
+void ThreadImpl::setPriorityImpl(int prio)
+{
+ if (prio != _pData->prio)
+ {
+ _pData->prio = prio;
+ _pData->policy = SCHED_OTHER;
+ if (isRunningImpl())
+ {
+ struct sched_param par; struct MyStruct
+ {
+
+ };
+ par.sched_priority = mapPrio(_pData->prio, SCHED_OTHER);
+ if (pthread_setschedparam(_pData->thread, SCHED_OTHER, &par))
+ throw SystemException("cannot set thread priority");
+ }
+ }
+}
+
+
+void ThreadImpl::setOSPriorityImpl(int prio, int policy)
+{
+ if (prio != _pData->osPrio || policy != _pData->policy)
+ {
+ if (_pData->pRunnableTarget)
+ {
+ struct sched_param par;
+ par.sched_priority = prio;
+ if (pthread_setschedparam(_pData->thread, policy, &par))
+ throw SystemException("cannot set thread priority");
+ }
+ _pData->prio = reverseMapPrio(prio, policy);
+ _pData->osPrio = prio;
+ _pData->policy = policy;
+ }
+}
+
+
+int ThreadImpl::getMinOSPriorityImpl(int policy)
+{
+#if defined(POCO_THREAD_PRIORITY_MIN)
+ return POCO_THREAD_PRIORITY_MIN;
+#elif defined(__digital__)
+ return PRI_OTHER_MIN;
+#else
+ return sched_get_priority_min(policy);
+#endif
+}
+
+
+int ThreadImpl::getMaxOSPriorityImpl(int policy)
+{
+#if defined(POCO_THREAD_PRIORITY_MAX)
+ return POCO_THREAD_PRIORITY_MAX;
+#elif defined(__digital__)
+ return PRI_OTHER_MAX;
+#else
+ return sched_get_priority_max(policy);
+#endif
+}
+
+
+void ThreadImpl::setStackSizeImpl(int size)
+{
+#ifndef PTHREAD_STACK_MIN
+ _pData->stackSize = 0;
+#else
+ if (size != 0)
+ {
+#if defined(POCO_OS_FAMILY_BSD)
+ // we must round up to a multiple of the memory page size
+ const int STACK_PAGE_SIZE = 4096;
+ size = ((size + STACK_PAGE_SIZE - 1)/STACK_PAGE_SIZE)*STACK_PAGE_SIZE;
+#endif
+ if (size < PTHREAD_STACK_MIN)
+ size = PTHREAD_STACK_MIN;
+ }
+ _pData->stackSize = size;
+#endif
+}
+
+
+void ThreadImpl::startImpl(SharedPtr<Runnable> pTarget)
+{
+ if (_pData->pRunnableTarget)
+ throw SystemException("thread already running");
+
+ pthread_attr_t attributes;
+ pthread_attr_init(&attributes);
+
+ if (_pData->stackSize != 0)
+ {
+ if (0 != pthread_attr_setstacksize(&attributes, _pData->stackSize))
+ {
+ pthread_attr_destroy(&attributes);
+ throw SystemException("cannot set thread stack size");
+ }
+ }
+
+ _pData->pRunnableTarget = pTarget;
+ if (pthread_create(&_pData->thread, &attributes, runnableEntry, this))
+ {
+ _pData->pRunnableTarget = 0;
+ pthread_attr_destroy(&attributes);
+ throw SystemException("cannot start thread");
+ }
+ _pData->started = true;
+ pthread_attr_destroy(&attributes);
+
+ if (_pData->policy == SCHED_OTHER)
+ {
+ if (_pData->prio != PRIO_NORMAL_IMPL)
+ {
+ struct sched_param par;
+ par.sched_priority = mapPrio(_pData->prio, SCHED_OTHER);
+ if (pthread_setschedparam(_pData->thread, SCHED_OTHER, &par))
+ throw SystemException("cannot set thread priority");
+ }
+ }
+ else
+ {
+ struct sched_param par;
+ par.sched_priority = _pData->osPrio;
+ if (pthread_setschedparam(_pData->thread, _pData->policy, &par))
+ throw SystemException("cannot set thread priority");
+ }
+}
+
+
+void ThreadImpl::joinImpl()
+{
+ if (!_pData->started) return;
+ _pData->done.wait();
+ void* result;
+ if (pthread_join(_pData->thread, &result))
+ throw SystemException("cannot join thread");
+ _pData->joined = true;
+}
+
+
+bool ThreadImpl::joinImpl(long milliseconds)
+{
+ if (_pData->started && _pData->done.tryWait(milliseconds))
+ {
+ void* result;
+ if (pthread_join(_pData->thread, &result))
+ throw SystemException("cannot join thread");
+ _pData->joined = true;
+ return true;
+ }
+ else if (_pData->started) return false;
+ else return true;
+}
+
+
+ThreadImpl* ThreadImpl::currentImpl()
+{
+ return _currentThreadHolder.get();
+}
+
+
+ThreadImpl::TIDImpl ThreadImpl::currentTidImpl()
+{
+ return pthread_self();
+}
+
+
+void ThreadImpl::sleepImpl(long milliseconds)
+{
+#if defined(__digital__)
+ // This is specific to DECThreads
+ struct timespec interval;
+ interval.tv_sec = milliseconds / 1000;
+ interval.tv_nsec = (milliseconds % 1000)*1000000;
+ pthread_delay_np(&interval);
+#elif POCO_OS == POCO_OS_LINUX || POCO_OS == POCO_OS_ANDROID || POCO_OS == POCO_OS_MAC_OS_X || POCO_OS == POCO_OS_QNX || POCO_OS == POCO_OS_VXWORKS
+ Poco::Timespan remainingTime(1000*Poco::Timespan::TimeDiff(milliseconds));
+ int rc;
+ do
+ {
+ struct timespec ts;
+ ts.tv_sec = (long) remainingTime.totalSeconds();
+ ts.tv_nsec = (long) remainingTime.useconds()*1000;
+ Poco::Timestamp start;
+ rc = ::nanosleep(&ts, 0);
+ if (rc < 0 && errno == EINTR)
+ {
+ Poco::Timestamp end;
+ Poco::Timespan waited = start.elapsed();
+ if (waited < remainingTime)
+ remainingTime -= waited;
+ else
+ remainingTime = 0;
+ }
+ }
+ while (remainingTime > 0 && rc < 0 && errno == EINTR);
+ if (rc < 0 && remainingTime > 0) throw Poco::SystemException("Thread::sleep(): nanosleep() failed");
+#else
+ Poco::Timespan remainingTime(1000*Poco::Timespan::TimeDiff(milliseconds));
+ int rc;
+ do
+ {
+ struct timeval tv;
+ tv.tv_sec = (long) remainingTime.totalSeconds();
+ tv.tv_usec = (long) remainingTime.useconds();
+ Poco::Timestamp start;
+ rc = ::select(0, NULL, NULL, NULL, &tv);
+ if (rc < 0 && errno == EINTR)
+ {
+ Poco::Timestamp end;
+ Poco::Timespan waited = start.elapsed();
+ if (waited < remainingTime)
+ remainingTime -= waited;
+ else
+ remainingTime = 0;
+ }
+ }
+ while (remainingTime > 0 && rc < 0 && errno == EINTR);
+ if (rc < 0 && remainingTime > 0) throw Poco::SystemException("Thread::sleep(): select() failed");
+#endif
+}
+
+
+void* ThreadImpl::runnableEntry(void* pThread)
+{
+ _currentThreadHolder.set(reinterpret_cast<ThreadImpl*>(pThread));
+
+#if defined(POCO_OS_FAMILY_UNIX)
+ sigset_t sset;
+ sigemptyset(&sset);
+ sigaddset(&sset, SIGQUIT);
+ sigaddset(&sset, SIGTERM);
+ sigaddset(&sset, SIGPIPE);
+ pthread_sigmask(SIG_BLOCK, &sset, 0);
+#endif
+
+ ThreadImpl* pThreadImpl = reinterpret_cast<ThreadImpl*>(pThread);
+#if defined(POCO_POSIX_DEBUGGER_THREAD_NAMES)
+ setThreadName(pThreadImpl->_pData->thread, reinterpret_cast<Thread*>(pThread)->getName());
+#endif
+ AutoPtr<ThreadData> pData = pThreadImpl->_pData;
+ try
+ {
+ pData->pRunnableTarget->run();
+ }
+ catch (Exception& exc)
+ {
+ ErrorHandler::handle(exc);
+ }
+ catch (std::exception& exc)
+ {
+ ErrorHandler::handle(exc);
+ }
+ catch (...)
+ {
+ ErrorHandler::handle();
+ }
+
+ pData->pRunnableTarget = 0;
+ pData->done.set();
+ return 0;
+}
+
+
+int ThreadImpl::mapPrio(int prio, int policy)
+{
+ int pmin = getMinOSPriorityImpl(policy);
+ int pmax = getMaxOSPriorityImpl(policy);
+
+ switch (prio)
+ {
+ case PRIO_LOWEST_IMPL:
+ return pmin;
+ case PRIO_LOW_IMPL:
+ return pmin + (pmax - pmin)/4;
+ case PRIO_NORMAL_IMPL:
+ return pmin + (pmax - pmin)/2;
+ case PRIO_HIGH_IMPL:
+ return pmin + 3*(pmax - pmin)/4;
+ case PRIO_HIGHEST_IMPL:
+ return pmax;
+ default:
+ poco_bugcheck_msg("invalid thread priority");
+ }
+ return -1; // just to satisfy compiler - we'll never get here anyway
+}
+
+
+int ThreadImpl::reverseMapPrio(int prio, int policy)
+{
+ if (policy == SCHED_OTHER)
+ {
+ int pmin = getMinOSPriorityImpl(policy);
+ int pmax = getMaxOSPriorityImpl(policy);
+ int normal = pmin + (pmax - pmin)/2;
+ if (prio == pmax)
+ return PRIO_HIGHEST_IMPL;
+ if (prio > normal)
+ return PRIO_HIGH_IMPL;
+ else if (prio == normal)
+ return PRIO_NORMAL_IMPL;
+ else if (prio > pmin)
+ return PRIO_LOW_IMPL;
+ else
+ return PRIO_LOWEST_IMPL;
+ }
+ else return PRIO_HIGHEST_IMPL;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Thread_VX.cpp b/contrib/libs/poco/Foundation/src/Thread_VX.cpp
index d1883bf915..0ece87ab71 100644
--- a/contrib/libs/poco/Foundation/src/Thread_VX.cpp
+++ b/contrib/libs/poco/Foundation/src/Thread_VX.cpp
@@ -1,273 +1,273 @@
-//
-// Thread_VX.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: Thread
-//
-// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Thread_VX.h"
-#include "Poco/ErrorHandler.h"
-#include "Poco/Exception.h"
-#include "Poco/Timestamp.h"
-#include "Poco/Timespan.h"
-#include <timers.h>
-
-
-namespace Poco {
-
-
-ThreadImpl* ThreadImpl::_pCurrent(0);
-
-
-ThreadImpl::ThreadImpl():
- _pData(new ThreadData)
-{
-}
-
-
-ThreadImpl::~ThreadImpl()
-{
-}
-
-
-void ThreadImpl::setPriorityImpl(int prio)
-{
- if (prio != _pData->prio)
- {
- _pData->prio = prio;
- _pData->osPrio = mapPrio(_pData->prio);
- if (isRunningImpl())
- {
- if (taskPrioritySet(_pData->task, _pData->osPrio) != OK)
- throw SystemException("cannot set task priority");
- }
- }
-}
-
-
-void ThreadImpl::setOSPriorityImpl(int prio, int /* policy */)
-{
- if (prio != _pData->osPrio)
- {
- _pData->prio = reverseMapPrio(prio);
- _pData->osPrio = prio;
- if (_pData->pRunnableTarget || _pData->pCallbackTarget)
- {
- if (taskPrioritySet(_pData->task, prio) != OK)
- throw SystemException("cannot set task priority");
- }
- }
-}
-
-
-int ThreadImpl::getMinOSPriorityImpl(int /* policy */)
-{
- return 255;
-}
-
-
-int ThreadImpl::getMaxOSPriorityImpl(int /* policy */)
-{
- return 0;
-}
-
-
-void ThreadImpl::setStackSizeImpl(int size)
-{
- _pData->stackSize = size;
-}
-
-
-void ThreadImpl::startImpl(Runnable& target)
-{
- if (_pData->pRunnableTarget)
- throw SystemException("thread already running");
-
- _pData->pRunnableTarget = &target;
-
- int stackSize = _pData->stackSize == 0 ? DEFAULT_THREAD_STACK_SIZE : _pData->stackSize;
- int id = taskSpawn(NULL, _pData->osPrio, VX_FP_TASK, stackSize, reinterpret_cast<FUNCPTR>(runnableEntry), reinterpret_cast<int>(this), 0, 0, 0, 0, 0, 0, 0, 0, 0);
- if (id == ERROR)
- throw SystemException("cannot spawn task");
-
- _pData->task = id;
-}
-
-
-void ThreadImpl::startImpl(Callable target, void* pData)
-{
- if (_pData->pCallbackTarget && _pData->pCallbackTarget->callback)
- throw SystemException("thread already running");
-
- if (0 == _pData->pCallbackTarget.get())
- _pData->pCallbackTarget = new CallbackData;
-
- _pData->pCallbackTarget->callback = target;
- _pData->pCallbackTarget->pData = pData;
-
- int stackSize = _pData->stackSize == 0 ? DEFAULT_THREAD_STACK_SIZE : _pData->stackSize;
- int id = taskSpawn(NULL, _pData->osPrio, VX_FP_TASK, stackSize, reinterpret_cast<FUNCPTR>(callableEntry), reinterpret_cast<int>(this), 0, 0, 0, 0, 0, 0, 0, 0, 0);
- if (id == ERROR)
- throw SystemException("cannot spawn task");
-
- _pData->task = id;
-}
-
-
-void ThreadImpl::joinImpl()
-{
- _pData->done.wait();
-}
-
-
-bool ThreadImpl::joinImpl(long milliseconds)
-{
- return _pData->done.tryWait(milliseconds);
-}
-
-
-ThreadImpl* ThreadImpl::currentImpl()
-{
- return _pCurrent;
-}
-
-
-ThreadImpl::TIDImpl ThreadImpl::currentTidImpl()
-{
- return taskIdSelf();
-}
-
-
-void ThreadImpl::sleepImpl(long milliseconds)
-{
- Poco::Timespan remainingTime(1000*Poco::Timespan::TimeDiff(milliseconds));
- int rc;
- do
- {
- struct timespec ts;
- ts.tv_sec = (long) remainingTime.totalSeconds();
- ts.tv_nsec = (long) remainingTime.useconds()*1000;
- Poco::Timestamp start;
- rc = ::nanosleep(&ts, 0);
- if (rc < 0 && errno == EINTR)
- {
- Poco::Timestamp end;
- Poco::Timespan waited = start.elapsed();
- if (waited < remainingTime)
- remainingTime -= waited;
- else
- remainingTime = 0;
- }
- }
- while (remainingTime > 0 && rc < 0 && errno == EINTR);
- if (rc < 0 && remainingTime > 0) throw Poco::SystemException("Thread::sleep(): nanosleep() failed");
-}
-
-
-void ThreadImpl::runnableEntry(void* pThread, int, int, int, int, int, int, int, int, int)
-{
- taskVarAdd(0, reinterpret_cast<int*>(&_pCurrent));
- _pCurrent = reinterpret_cast<ThreadImpl*>(pThread);
-
- AutoPtr<ThreadData> pData = _pCurrent->_pData;
- try
- {
- pData->pRunnableTarget->run();
- }
- catch (Exception& exc)
- {
- ErrorHandler::handle(exc);
- }
- catch (std::exception& exc)
- {
- ErrorHandler::handle(exc);
- }
- catch (...)
- {
- ErrorHandler::handle();
- }
-
- pData->pRunnableTarget = 0;
- pData->done.set();
-}
-
-
-void ThreadImpl::callableEntry(void* pThread, int, int, int, int, int, int, int, int, int)
-{
- taskVarAdd(0, reinterpret_cast<int*>(&_pCurrent));
- _pCurrent = reinterpret_cast<ThreadImpl*>(pThread);
-
- AutoPtr<ThreadData> pData = _pCurrent->_pData;
- try
- {
- pData->pCallbackTarget->callback(pData->pCallbackTarget->pData);
- }
- catch (Exception& exc)
- {
- ErrorHandler::handle(exc);
- }
- catch (std::exception& exc)
- {
- ErrorHandler::handle(exc);
- }
- catch (...)
- {
- ErrorHandler::handle();
- }
-
- pData->pCallbackTarget->callback = 0;
- pData->pCallbackTarget->pData = 0;
- pData->done.set();
-}
-
-
-int ThreadImpl::mapPrio(int prio)
-{
- int pmin = getMinOSPriorityImpl();
- int pmax = getMaxOSPriorityImpl();
-
- switch (prio)
- {
- case PRIO_LOWEST_IMPL:
- return pmin;
- case PRIO_LOW_IMPL:
- return pmin + (pmax - pmin)/4;
- case PRIO_NORMAL_IMPL:
- return pmin + (pmax - pmin)/2;
- case PRIO_HIGH_IMPL:
- return pmin + 3*(pmax - pmin)/4;
- case PRIO_HIGHEST_IMPL:
- return pmax;
- default:
- poco_bugcheck_msg("invalid thread priority");
- }
- return -1; // just to satisfy compiler - we'll never get here anyway
-}
-
-
-int ThreadImpl::reverseMapPrio(int prio)
-{
- int pmin = getMinOSPriorityImpl();
- int pmax = getMaxOSPriorityImpl();
- int normal = pmin + (pmax - pmin)/2;
- if (prio == pmax)
- return PRIO_HIGHEST_IMPL;
- if (prio > normal)
- return PRIO_HIGH_IMPL;
- else if (prio == normal)
- return PRIO_NORMAL_IMPL;
- else if (prio > pmin)
- return PRIO_LOW_IMPL;
- else
- return PRIO_LOWEST_IMPL;
-}
-
-
-} // namespace Poco
+//
+// Thread_VX.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: Thread
+//
+// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Thread_VX.h"
+#include "Poco/ErrorHandler.h"
+#include "Poco/Exception.h"
+#include "Poco/Timestamp.h"
+#include "Poco/Timespan.h"
+#include <timers.h>
+
+
+namespace Poco {
+
+
+ThreadImpl* ThreadImpl::_pCurrent(0);
+
+
+ThreadImpl::ThreadImpl():
+ _pData(new ThreadData)
+{
+}
+
+
+ThreadImpl::~ThreadImpl()
+{
+}
+
+
+void ThreadImpl::setPriorityImpl(int prio)
+{
+ if (prio != _pData->prio)
+ {
+ _pData->prio = prio;
+ _pData->osPrio = mapPrio(_pData->prio);
+ if (isRunningImpl())
+ {
+ if (taskPrioritySet(_pData->task, _pData->osPrio) != OK)
+ throw SystemException("cannot set task priority");
+ }
+ }
+}
+
+
+void ThreadImpl::setOSPriorityImpl(int prio, int /* policy */)
+{
+ if (prio != _pData->osPrio)
+ {
+ _pData->prio = reverseMapPrio(prio);
+ _pData->osPrio = prio;
+ if (_pData->pRunnableTarget || _pData->pCallbackTarget)
+ {
+ if (taskPrioritySet(_pData->task, prio) != OK)
+ throw SystemException("cannot set task priority");
+ }
+ }
+}
+
+
+int ThreadImpl::getMinOSPriorityImpl(int /* policy */)
+{
+ return 255;
+}
+
+
+int ThreadImpl::getMaxOSPriorityImpl(int /* policy */)
+{
+ return 0;
+}
+
+
+void ThreadImpl::setStackSizeImpl(int size)
+{
+ _pData->stackSize = size;
+}
+
+
+void ThreadImpl::startImpl(Runnable& target)
+{
+ if (_pData->pRunnableTarget)
+ throw SystemException("thread already running");
+
+ _pData->pRunnableTarget = &target;
+
+ int stackSize = _pData->stackSize == 0 ? DEFAULT_THREAD_STACK_SIZE : _pData->stackSize;
+ int id = taskSpawn(NULL, _pData->osPrio, VX_FP_TASK, stackSize, reinterpret_cast<FUNCPTR>(runnableEntry), reinterpret_cast<int>(this), 0, 0, 0, 0, 0, 0, 0, 0, 0);
+ if (id == ERROR)
+ throw SystemException("cannot spawn task");
+
+ _pData->task = id;
+}
+
+
+void ThreadImpl::startImpl(Callable target, void* pData)
+{
+ if (_pData->pCallbackTarget && _pData->pCallbackTarget->callback)
+ throw SystemException("thread already running");
+
+ if (0 == _pData->pCallbackTarget.get())
+ _pData->pCallbackTarget = new CallbackData;
+
+ _pData->pCallbackTarget->callback = target;
+ _pData->pCallbackTarget->pData = pData;
+
+ int stackSize = _pData->stackSize == 0 ? DEFAULT_THREAD_STACK_SIZE : _pData->stackSize;
+ int id = taskSpawn(NULL, _pData->osPrio, VX_FP_TASK, stackSize, reinterpret_cast<FUNCPTR>(callableEntry), reinterpret_cast<int>(this), 0, 0, 0, 0, 0, 0, 0, 0, 0);
+ if (id == ERROR)
+ throw SystemException("cannot spawn task");
+
+ _pData->task = id;
+}
+
+
+void ThreadImpl::joinImpl()
+{
+ _pData->done.wait();
+}
+
+
+bool ThreadImpl::joinImpl(long milliseconds)
+{
+ return _pData->done.tryWait(milliseconds);
+}
+
+
+ThreadImpl* ThreadImpl::currentImpl()
+{
+ return _pCurrent;
+}
+
+
+ThreadImpl::TIDImpl ThreadImpl::currentTidImpl()
+{
+ return taskIdSelf();
+}
+
+
+void ThreadImpl::sleepImpl(long milliseconds)
+{
+ Poco::Timespan remainingTime(1000*Poco::Timespan::TimeDiff(milliseconds));
+ int rc;
+ do
+ {
+ struct timespec ts;
+ ts.tv_sec = (long) remainingTime.totalSeconds();
+ ts.tv_nsec = (long) remainingTime.useconds()*1000;
+ Poco::Timestamp start;
+ rc = ::nanosleep(&ts, 0);
+ if (rc < 0 && errno == EINTR)
+ {
+ Poco::Timestamp end;
+ Poco::Timespan waited = start.elapsed();
+ if (waited < remainingTime)
+ remainingTime -= waited;
+ else
+ remainingTime = 0;
+ }
+ }
+ while (remainingTime > 0 && rc < 0 && errno == EINTR);
+ if (rc < 0 && remainingTime > 0) throw Poco::SystemException("Thread::sleep(): nanosleep() failed");
+}
+
+
+void ThreadImpl::runnableEntry(void* pThread, int, int, int, int, int, int, int, int, int)
+{
+ taskVarAdd(0, reinterpret_cast<int*>(&_pCurrent));
+ _pCurrent = reinterpret_cast<ThreadImpl*>(pThread);
+
+ AutoPtr<ThreadData> pData = _pCurrent->_pData;
+ try
+ {
+ pData->pRunnableTarget->run();
+ }
+ catch (Exception& exc)
+ {
+ ErrorHandler::handle(exc);
+ }
+ catch (std::exception& exc)
+ {
+ ErrorHandler::handle(exc);
+ }
+ catch (...)
+ {
+ ErrorHandler::handle();
+ }
+
+ pData->pRunnableTarget = 0;
+ pData->done.set();
+}
+
+
+void ThreadImpl::callableEntry(void* pThread, int, int, int, int, int, int, int, int, int)
+{
+ taskVarAdd(0, reinterpret_cast<int*>(&_pCurrent));
+ _pCurrent = reinterpret_cast<ThreadImpl*>(pThread);
+
+ AutoPtr<ThreadData> pData = _pCurrent->_pData;
+ try
+ {
+ pData->pCallbackTarget->callback(pData->pCallbackTarget->pData);
+ }
+ catch (Exception& exc)
+ {
+ ErrorHandler::handle(exc);
+ }
+ catch (std::exception& exc)
+ {
+ ErrorHandler::handle(exc);
+ }
+ catch (...)
+ {
+ ErrorHandler::handle();
+ }
+
+ pData->pCallbackTarget->callback = 0;
+ pData->pCallbackTarget->pData = 0;
+ pData->done.set();
+}
+
+
+int ThreadImpl::mapPrio(int prio)
+{
+ int pmin = getMinOSPriorityImpl();
+ int pmax = getMaxOSPriorityImpl();
+
+ switch (prio)
+ {
+ case PRIO_LOWEST_IMPL:
+ return pmin;
+ case PRIO_LOW_IMPL:
+ return pmin + (pmax - pmin)/4;
+ case PRIO_NORMAL_IMPL:
+ return pmin + (pmax - pmin)/2;
+ case PRIO_HIGH_IMPL:
+ return pmin + 3*(pmax - pmin)/4;
+ case PRIO_HIGHEST_IMPL:
+ return pmax;
+ default:
+ poco_bugcheck_msg("invalid thread priority");
+ }
+ return -1; // just to satisfy compiler - we'll never get here anyway
+}
+
+
+int ThreadImpl::reverseMapPrio(int prio)
+{
+ int pmin = getMinOSPriorityImpl();
+ int pmax = getMaxOSPriorityImpl();
+ int normal = pmin + (pmax - pmin)/2;
+ if (prio == pmax)
+ return PRIO_HIGHEST_IMPL;
+ if (prio > normal)
+ return PRIO_HIGH_IMPL;
+ else if (prio == normal)
+ return PRIO_NORMAL_IMPL;
+ else if (prio > pmin)
+ return PRIO_LOW_IMPL;
+ else
+ return PRIO_LOWEST_IMPL;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Thread_WIN32.cpp b/contrib/libs/poco/Foundation/src/Thread_WIN32.cpp
index 9bd6d25b97..40479e46cd 100644
--- a/contrib/libs/poco/Foundation/src/Thread_WIN32.cpp
+++ b/contrib/libs/poco/Foundation/src/Thread_WIN32.cpp
@@ -1,223 +1,223 @@
-//
-// Thread_WIN32.h
-//
-// Library: Foundation
-// Package: Threading
-// Module: Thread
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Thread_WIN32.h"
-#include "Poco/Exception.h"
-#include "Poco/ErrorHandler.h"
-#include <process.h>
-
-
-#if defined(POCO_WIN32_DEBUGGER_THREAD_NAMES)
-
-
-namespace
-{
- /// See <http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx>
- /// and <http://blogs.msdn.com/b/stevejs/archive/2005/12/19/505815.aspx> for
- /// more information on the code below.
-
- const DWORD MS_VC_EXCEPTION = 0x406D1388;
-
- #pragma pack(push,8)
- typedef struct tagTHREADNAME_INFO
- {
- DWORD dwType; // Must be 0x1000.
- LPCSTR szName; // Pointer to name (in user addr space).
- DWORD dwThreadID; // Thread ID (-1=caller thread).
- DWORD dwFlags; // Reserved for future use, must be zero.
- } THREADNAME_INFO;
- #pragma pack(pop)
-
- void setThreadName(DWORD dwThreadID, const char* threadName)
- {
- THREADNAME_INFO info;
- info.dwType = 0x1000;
- info.szName = threadName;
- info.dwThreadID = dwThreadID;
- info.dwFlags = 0;
-
- __try
- {
- RaiseException(MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info);
- }
- __except (EXCEPTION_CONTINUE_EXECUTION)
- {
- }
- }
-}
-
-
-#endif
-
-
-namespace Poco {
-
-
-ThreadImpl::CurrentThreadHolder ThreadImpl::_currentThreadHolder;
-
-
-ThreadImpl::ThreadImpl():
- _thread(0),
- _threadId(0),
- _prio(PRIO_NORMAL_IMPL),
- _stackSize(POCO_THREAD_STACK_SIZE)
-{
-}
-
-
-ThreadImpl::~ThreadImpl()
-{
- if (_thread) CloseHandle(_thread);
-}
-
-
-void ThreadImpl::setPriorityImpl(int prio)
-{
- if (prio != _prio)
- {
- _prio = prio;
- if (_thread)
- {
- if (SetThreadPriority(_thread, _prio) == 0)
- throw SystemException("cannot set thread priority");
- }
- }
-}
-
-
-void ThreadImpl::setOSPriorityImpl(int prio, int /* policy */)
-{
- setPriorityImpl(prio);
-}
-
-
-void ThreadImpl::startImpl(SharedPtr<Runnable> pTarget)
-{
- if (isRunningImpl())
- throw SystemException("thread already running");
-
- _pRunnableTarget = pTarget;
- createImpl(runnableEntry, this);
-}
-
-
-void ThreadImpl::createImpl(Entry ent, void* pData)
-{
-#if defined(_DLL)
- _thread = CreateThread(NULL, _stackSize, ent, pData, 0, &_threadId);
-#else
- unsigned threadId;
- _thread = (HANDLE) _beginthreadex(NULL, _stackSize, ent, this, 0, &threadId);
- _threadId = static_cast<DWORD>(threadId);
-#endif
- if (!_thread)
- throw SystemException("cannot create thread");
- if (_prio != PRIO_NORMAL_IMPL && !SetThreadPriority(_thread, _prio))
- throw SystemException("cannot set thread priority");
-}
-
-
-void ThreadImpl::joinImpl()
-{
- if (!_thread) return;
-
- switch (WaitForSingleObject(_thread, INFINITE))
- {
- case WAIT_OBJECT_0:
- threadCleanup();
- return;
- default:
- throw SystemException("cannot join thread");
- }
-}
-
-
-bool ThreadImpl::joinImpl(long milliseconds)
-{
- if (!_thread) return true;
-
- switch (WaitForSingleObject(_thread, milliseconds + 1))
- {
- case WAIT_TIMEOUT:
- return false;
- case WAIT_OBJECT_0:
- threadCleanup();
- return true;
- default:
- throw SystemException("cannot join thread");
- }
-}
-
-
-bool ThreadImpl::isRunningImpl() const
-{
- if (_thread)
- {
- DWORD ec = 0;
- return GetExitCodeThread(_thread, &ec) && ec == STILL_ACTIVE;
- }
- return false;
-}
-
-
-void ThreadImpl::threadCleanup()
-{
- if (!_thread) return;
- if (CloseHandle(_thread)) _thread = 0;
-}
-
-
-ThreadImpl* ThreadImpl::currentImpl()
-{
- return _currentThreadHolder.get();
-}
-
-
-ThreadImpl::TIDImpl ThreadImpl::currentTidImpl()
-{
- return GetCurrentThreadId();
-}
-
-
-#if defined(_DLL)
-DWORD WINAPI ThreadImpl::runnableEntry(LPVOID pThread)
-#else
-unsigned __stdcall ThreadImpl::runnableEntry(void* pThread)
-#endif
-{
- _currentThreadHolder.set(reinterpret_cast<ThreadImpl*>(pThread));
-#if defined(POCO_WIN32_DEBUGGER_THREAD_NAMES)
- setThreadName(-1, reinterpret_cast<Thread*>(pThread)->getName().c_str());
-#endif
- try
- {
- reinterpret_cast<ThreadImpl*>(pThread)->_pRunnableTarget->run();
- }
- catch (Exception& exc)
- {
- ErrorHandler::handle(exc);
- }
- catch (std::exception& exc)
- {
- ErrorHandler::handle(exc);
- }
- catch (...)
- {
- ErrorHandler::handle();
- }
- return 0;
-}
-
-
-} // namespace Poco
+//
+// Thread_WIN32.h
+//
+// Library: Foundation
+// Package: Threading
+// Module: Thread
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Thread_WIN32.h"
+#include "Poco/Exception.h"
+#include "Poco/ErrorHandler.h"
+#include <process.h>
+
+
+#if defined(POCO_WIN32_DEBUGGER_THREAD_NAMES)
+
+
+namespace
+{
+ /// See <http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx>
+ /// and <http://blogs.msdn.com/b/stevejs/archive/2005/12/19/505815.aspx> for
+ /// more information on the code below.
+
+ const DWORD MS_VC_EXCEPTION = 0x406D1388;
+
+ #pragma pack(push,8)
+ typedef struct tagTHREADNAME_INFO
+ {
+ DWORD dwType; // Must be 0x1000.
+ LPCSTR szName; // Pointer to name (in user addr space).
+ DWORD dwThreadID; // Thread ID (-1=caller thread).
+ DWORD dwFlags; // Reserved for future use, must be zero.
+ } THREADNAME_INFO;
+ #pragma pack(pop)
+
+ void setThreadName(DWORD dwThreadID, const char* threadName)
+ {
+ THREADNAME_INFO info;
+ info.dwType = 0x1000;
+ info.szName = threadName;
+ info.dwThreadID = dwThreadID;
+ info.dwFlags = 0;
+
+ __try
+ {
+ RaiseException(MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info);
+ }
+ __except (EXCEPTION_CONTINUE_EXECUTION)
+ {
+ }
+ }
+}
+
+
+#endif
+
+
+namespace Poco {
+
+
+ThreadImpl::CurrentThreadHolder ThreadImpl::_currentThreadHolder;
+
+
+ThreadImpl::ThreadImpl():
+ _thread(0),
+ _threadId(0),
+ _prio(PRIO_NORMAL_IMPL),
+ _stackSize(POCO_THREAD_STACK_SIZE)
+{
+}
+
+
+ThreadImpl::~ThreadImpl()
+{
+ if (_thread) CloseHandle(_thread);
+}
+
+
+void ThreadImpl::setPriorityImpl(int prio)
+{
+ if (prio != _prio)
+ {
+ _prio = prio;
+ if (_thread)
+ {
+ if (SetThreadPriority(_thread, _prio) == 0)
+ throw SystemException("cannot set thread priority");
+ }
+ }
+}
+
+
+void ThreadImpl::setOSPriorityImpl(int prio, int /* policy */)
+{
+ setPriorityImpl(prio);
+}
+
+
+void ThreadImpl::startImpl(SharedPtr<Runnable> pTarget)
+{
+ if (isRunningImpl())
+ throw SystemException("thread already running");
+
+ _pRunnableTarget = pTarget;
+ createImpl(runnableEntry, this);
+}
+
+
+void ThreadImpl::createImpl(Entry ent, void* pData)
+{
+#if defined(_DLL)
+ _thread = CreateThread(NULL, _stackSize, ent, pData, 0, &_threadId);
+#else
+ unsigned threadId;
+ _thread = (HANDLE) _beginthreadex(NULL, _stackSize, ent, this, 0, &threadId);
+ _threadId = static_cast<DWORD>(threadId);
+#endif
+ if (!_thread)
+ throw SystemException("cannot create thread");
+ if (_prio != PRIO_NORMAL_IMPL && !SetThreadPriority(_thread, _prio))
+ throw SystemException("cannot set thread priority");
+}
+
+
+void ThreadImpl::joinImpl()
+{
+ if (!_thread) return;
+
+ switch (WaitForSingleObject(_thread, INFINITE))
+ {
+ case WAIT_OBJECT_0:
+ threadCleanup();
+ return;
+ default:
+ throw SystemException("cannot join thread");
+ }
+}
+
+
+bool ThreadImpl::joinImpl(long milliseconds)
+{
+ if (!_thread) return true;
+
+ switch (WaitForSingleObject(_thread, milliseconds + 1))
+ {
+ case WAIT_TIMEOUT:
+ return false;
+ case WAIT_OBJECT_0:
+ threadCleanup();
+ return true;
+ default:
+ throw SystemException("cannot join thread");
+ }
+}
+
+
+bool ThreadImpl::isRunningImpl() const
+{
+ if (_thread)
+ {
+ DWORD ec = 0;
+ return GetExitCodeThread(_thread, &ec) && ec == STILL_ACTIVE;
+ }
+ return false;
+}
+
+
+void ThreadImpl::threadCleanup()
+{
+ if (!_thread) return;
+ if (CloseHandle(_thread)) _thread = 0;
+}
+
+
+ThreadImpl* ThreadImpl::currentImpl()
+{
+ return _currentThreadHolder.get();
+}
+
+
+ThreadImpl::TIDImpl ThreadImpl::currentTidImpl()
+{
+ return GetCurrentThreadId();
+}
+
+
+#if defined(_DLL)
+DWORD WINAPI ThreadImpl::runnableEntry(LPVOID pThread)
+#else
+unsigned __stdcall ThreadImpl::runnableEntry(void* pThread)
+#endif
+{
+ _currentThreadHolder.set(reinterpret_cast<ThreadImpl*>(pThread));
+#if defined(POCO_WIN32_DEBUGGER_THREAD_NAMES)
+ setThreadName(-1, reinterpret_cast<Thread*>(pThread)->getName().c_str());
+#endif
+ try
+ {
+ reinterpret_cast<ThreadImpl*>(pThread)->_pRunnableTarget->run();
+ }
+ catch (Exception& exc)
+ {
+ ErrorHandler::handle(exc);
+ }
+ catch (std::exception& exc)
+ {
+ ErrorHandler::handle(exc);
+ }
+ catch (...)
+ {
+ ErrorHandler::handle();
+ }
+ return 0;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Thread_WINCE.cpp b/contrib/libs/poco/Foundation/src/Thread_WINCE.cpp
index d769f88354..7177058668 100644
--- a/contrib/libs/poco/Foundation/src/Thread_WINCE.cpp
+++ b/contrib/libs/poco/Foundation/src/Thread_WINCE.cpp
@@ -1,169 +1,169 @@
-//
-// Thread_WINCE.h
-//
-// Library: Foundation
-// Package: Threading
-// Module: Thread
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Thread_WINCE.h"
-#include "Poco/Exception.h"
-#include "Poco/ErrorHandler.h"
-
-
-namespace Poco {
-
-
-ThreadImpl::CurrentThreadHolder ThreadImpl::_currentThreadHolder;
-
-
-ThreadImpl::ThreadImpl():
- _pRunnableTarget(0),
- _thread(0),
- _threadId(0),
- _prio(PRIO_NORMAL_IMPL),
- _stackSize(POCO_THREAD_STACK_SIZE)
-{
-}
-
-
-ThreadImpl::~ThreadImpl()
-{
- if (_thread) CloseHandle(_thread);
-}
-
-
-void ThreadImpl::setPriorityImpl(int prio)
-{
- if (prio != _prio)
- {
- _prio = prio;
- if (_thread)
- {
- if (SetThreadPriority(_thread, _prio) == 0)
- throw SystemException("cannot set thread priority");
- }
- }
-}
-
-
-void ThreadImpl::setOSPriorityImpl(int prio, int /* policy */)
-{
- setPriorityImpl(prio);
-}
-
-
-void ThreadImpl::startImpl(SharedPtr<Runnable> pTarget)
-{
- if (isRunningImpl())
- throw SystemException("thread already running");
-
- _pRunnableTarget = pTarget;
-
- createImpl(runnableEntry, this);
-}
-
-
-void ThreadImpl::createImpl(Entry ent, void* pData)
-{
- _thread = CreateThread(NULL, _stackSize, ent, pData, 0, &_threadId);
-
- if (!_thread)
- throw SystemException("cannot create thread");
- if (_prio != PRIO_NORMAL_IMPL && !SetThreadPriority(_thread, _prio))
- throw SystemException("cannot set thread priority");
-}
-
-
-void ThreadImpl::joinImpl()
-{
- if (!_thread) return;
-
- switch (WaitForSingleObject(_thread, INFINITE))
- {
- case WAIT_OBJECT_0:
- threadCleanup();
- return;
- default:
- throw SystemException("cannot join thread");
- }
-}
-
-
-bool ThreadImpl::joinImpl(long milliseconds)
-{
- if (!_thread) return true;
-
- switch (WaitForSingleObject(_thread, milliseconds + 1))
- {
- case WAIT_TIMEOUT:
- return false;
- case WAIT_OBJECT_0:
- threadCleanup();
- return true;
- default:
- throw SystemException("cannot join thread");
- }
-}
-
-
-bool ThreadImpl::isRunningImpl() const
-{
- if (_thread)
- {
- DWORD ec = 0;
- return GetExitCodeThread(_thread, &ec) && ec == STILL_ACTIVE;
- }
- return false;
-}
-
-
-void ThreadImpl::threadCleanup()
-{
- if (!_thread) return;
- if (CloseHandle(_thread)) _thread = 0;
-}
-
-
-ThreadImpl* ThreadImpl::currentImpl()
-{
- return _currentThreadHolder.get();
-}
-
-
-ThreadImpl::TIDImpl ThreadImpl::currentTidImpl()
-{
- return GetCurrentThreadId();
-}
-
-
-DWORD WINAPI ThreadImpl::runnableEntry(LPVOID pThread)
-{
- _currentThreadHolder.set(reinterpret_cast<ThreadImpl*>(pThread));
- try
- {
- reinterpret_cast<ThreadImpl*>(pThread)->_pRunnableTarget->run();
- }
- catch (Exception& exc)
- {
- ErrorHandler::handle(exc);
- }
- catch (std::exception& exc)
- {
- ErrorHandler::handle(exc);
- }
- catch (...)
- {
- ErrorHandler::handle();
- }
- return 0;
-}
-
-
-} // namespace Poco
+//
+// Thread_WINCE.h
+//
+// Library: Foundation
+// Package: Threading
+// Module: Thread
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Thread_WINCE.h"
+#include "Poco/Exception.h"
+#include "Poco/ErrorHandler.h"
+
+
+namespace Poco {
+
+
+ThreadImpl::CurrentThreadHolder ThreadImpl::_currentThreadHolder;
+
+
+ThreadImpl::ThreadImpl():
+ _pRunnableTarget(0),
+ _thread(0),
+ _threadId(0),
+ _prio(PRIO_NORMAL_IMPL),
+ _stackSize(POCO_THREAD_STACK_SIZE)
+{
+}
+
+
+ThreadImpl::~ThreadImpl()
+{
+ if (_thread) CloseHandle(_thread);
+}
+
+
+void ThreadImpl::setPriorityImpl(int prio)
+{
+ if (prio != _prio)
+ {
+ _prio = prio;
+ if (_thread)
+ {
+ if (SetThreadPriority(_thread, _prio) == 0)
+ throw SystemException("cannot set thread priority");
+ }
+ }
+}
+
+
+void ThreadImpl::setOSPriorityImpl(int prio, int /* policy */)
+{
+ setPriorityImpl(prio);
+}
+
+
+void ThreadImpl::startImpl(SharedPtr<Runnable> pTarget)
+{
+ if (isRunningImpl())
+ throw SystemException("thread already running");
+
+ _pRunnableTarget = pTarget;
+
+ createImpl(runnableEntry, this);
+}
+
+
+void ThreadImpl::createImpl(Entry ent, void* pData)
+{
+ _thread = CreateThread(NULL, _stackSize, ent, pData, 0, &_threadId);
+
+ if (!_thread)
+ throw SystemException("cannot create thread");
+ if (_prio != PRIO_NORMAL_IMPL && !SetThreadPriority(_thread, _prio))
+ throw SystemException("cannot set thread priority");
+}
+
+
+void ThreadImpl::joinImpl()
+{
+ if (!_thread) return;
+
+ switch (WaitForSingleObject(_thread, INFINITE))
+ {
+ case WAIT_OBJECT_0:
+ threadCleanup();
+ return;
+ default:
+ throw SystemException("cannot join thread");
+ }
+}
+
+
+bool ThreadImpl::joinImpl(long milliseconds)
+{
+ if (!_thread) return true;
+
+ switch (WaitForSingleObject(_thread, milliseconds + 1))
+ {
+ case WAIT_TIMEOUT:
+ return false;
+ case WAIT_OBJECT_0:
+ threadCleanup();
+ return true;
+ default:
+ throw SystemException("cannot join thread");
+ }
+}
+
+
+bool ThreadImpl::isRunningImpl() const
+{
+ if (_thread)
+ {
+ DWORD ec = 0;
+ return GetExitCodeThread(_thread, &ec) && ec == STILL_ACTIVE;
+ }
+ return false;
+}
+
+
+void ThreadImpl::threadCleanup()
+{
+ if (!_thread) return;
+ if (CloseHandle(_thread)) _thread = 0;
+}
+
+
+ThreadImpl* ThreadImpl::currentImpl()
+{
+ return _currentThreadHolder.get();
+}
+
+
+ThreadImpl::TIDImpl ThreadImpl::currentTidImpl()
+{
+ return GetCurrentThreadId();
+}
+
+
+DWORD WINAPI ThreadImpl::runnableEntry(LPVOID pThread)
+{
+ _currentThreadHolder.set(reinterpret_cast<ThreadImpl*>(pThread));
+ try
+ {
+ reinterpret_cast<ThreadImpl*>(pThread)->_pRunnableTarget->run();
+ }
+ catch (Exception& exc)
+ {
+ ErrorHandler::handle(exc);
+ }
+ catch (std::exception& exc)
+ {
+ ErrorHandler::handle(exc);
+ }
+ catch (...)
+ {
+ ErrorHandler::handle();
+ }
+ return 0;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/TimedNotificationQueue.cpp b/contrib/libs/poco/Foundation/src/TimedNotificationQueue.cpp
index 8160bb90de..6158917aed 100644
--- a/contrib/libs/poco/Foundation/src/TimedNotificationQueue.cpp
+++ b/contrib/libs/poco/Foundation/src/TimedNotificationQueue.cpp
@@ -1,203 +1,203 @@
-//
-// TimedNotificationQueue.cpp
-//
-// Library: Foundation
-// Package: Notifications
-// Module: TimedNotificationQueue
-//
-// Copyright (c) 2009, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/TimedNotificationQueue.h"
-#include "Poco/Notification.h"
-#include <limits>
-
-
-namespace Poco {
-
-
-TimedNotificationQueue::TimedNotificationQueue()
-{
-}
-
-
-TimedNotificationQueue::~TimedNotificationQueue()
-{
- try
- {
- clear();
- }
- catch (...)
- {
- poco_unexpected();
- }
-}
-
-
-void TimedNotificationQueue::enqueueNotification(Notification::Ptr pNotification, Timestamp timestamp)
-{
- poco_check_ptr (pNotification);
-
- Timestamp tsNow;
- Clock clock;
- Timestamp::TimeDiff diff = timestamp - tsNow;
- clock += diff;
-
- FastMutex::ScopedLock lock(_mutex);
- _nfQueue.insert(NfQueue::value_type(clock, pNotification));
- _nfAvailable.set();
-}
-
-
-void TimedNotificationQueue::enqueueNotification(Notification::Ptr pNotification, Clock clock)
-{
- poco_check_ptr (pNotification);
-
- FastMutex::ScopedLock lock(_mutex);
- _nfQueue.insert(NfQueue::value_type(clock, pNotification));
- _nfAvailable.set();
-}
-
-
-Notification* TimedNotificationQueue::dequeueNotification()
-{
- FastMutex::ScopedLock lock(_mutex);
-
- NfQueue::iterator it = _nfQueue.begin();
- if (it != _nfQueue.end())
- {
- Clock::ClockDiff sleep = -it->first.elapsed();
- if (sleep <= 0)
- {
- Notification::Ptr pNf = it->second;
- _nfQueue.erase(it);
- return pNf.duplicate();
- }
- }
- return 0;
-}
-
-
-Notification* TimedNotificationQueue::waitDequeueNotification()
-{
- for (;;)
- {
- _mutex.lock();
- NfQueue::iterator it = _nfQueue.begin();
- if (it != _nfQueue.end())
- {
- _mutex.unlock();
- Clock::ClockDiff sleep = -it->first.elapsed();
- if (sleep <= 0)
- {
- return dequeueOne(it).duplicate();
- }
- else if (!wait(sleep))
- {
- return dequeueOne(it).duplicate();
- }
- else continue;
- }
- else
- {
- _mutex.unlock();
- }
- _nfAvailable.wait();
- }
-}
-
-
-Notification* TimedNotificationQueue::waitDequeueNotification(long milliseconds)
-{
- while (milliseconds >= 0)
- {
- _mutex.lock();
- NfQueue::iterator it = _nfQueue.begin();
- if (it != _nfQueue.end())
- {
- _mutex.unlock();
- Clock now;
- Clock::ClockDiff sleep = it->first - now;
- if (sleep <= 0)
- {
- return dequeueOne(it).duplicate();
- }
- else if (sleep <= 1000*Clock::ClockDiff(milliseconds))
- {
- if (!wait(sleep))
- {
- return dequeueOne(it).duplicate();
- }
- else
- {
- milliseconds -= static_cast<long>((now.elapsed() + 999)/1000);
- continue;
- }
- }
- }
- else
- {
- _mutex.unlock();
- }
- if (milliseconds > 0)
- {
- Clock now;
- _nfAvailable.tryWait(milliseconds);
- milliseconds -= static_cast<long>((now.elapsed() + 999)/1000);
- }
- else return 0;
- }
- return 0;
-}
-
-
-bool TimedNotificationQueue::wait(Clock::ClockDiff interval)
-{
- const Clock::ClockDiff MAX_SLEEP = 8*60*60*Clock::ClockDiff(1000000); // sleep at most 8 hours at a time
- while (interval > 0)
- {
- Clock now;
- Clock::ClockDiff sleep = interval <= MAX_SLEEP ? interval : MAX_SLEEP;
- if (_nfAvailable.tryWait(static_cast<long>((sleep + 999)/1000)))
- return true;
- interval -= now.elapsed();
- }
- return false;
-}
-
-
-bool TimedNotificationQueue::empty() const
-{
- FastMutex::ScopedLock lock(_mutex);
- return _nfQueue.empty();
-}
-
-
-int TimedNotificationQueue::size() const
-{
- FastMutex::ScopedLock lock(_mutex);
- return static_cast<int>(_nfQueue.size());
-}
-
-
-void TimedNotificationQueue::clear()
-{
- FastMutex::ScopedLock lock(_mutex);
- _nfQueue.clear();
-}
-
-
-Notification::Ptr TimedNotificationQueue::dequeueOne(NfQueue::iterator& it)
-{
- FastMutex::ScopedLock lock(_mutex);
- Notification::Ptr pNf = it->second;
- _nfQueue.erase(it);
- return pNf;
-}
-
-
-} // namespace Poco
+//
+// TimedNotificationQueue.cpp
+//
+// Library: Foundation
+// Package: Notifications
+// Module: TimedNotificationQueue
+//
+// Copyright (c) 2009, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/TimedNotificationQueue.h"
+#include "Poco/Notification.h"
+#include <limits>
+
+
+namespace Poco {
+
+
+TimedNotificationQueue::TimedNotificationQueue()
+{
+}
+
+
+TimedNotificationQueue::~TimedNotificationQueue()
+{
+ try
+ {
+ clear();
+ }
+ catch (...)
+ {
+ poco_unexpected();
+ }
+}
+
+
+void TimedNotificationQueue::enqueueNotification(Notification::Ptr pNotification, Timestamp timestamp)
+{
+ poco_check_ptr (pNotification);
+
+ Timestamp tsNow;
+ Clock clock;
+ Timestamp::TimeDiff diff = timestamp - tsNow;
+ clock += diff;
+
+ FastMutex::ScopedLock lock(_mutex);
+ _nfQueue.insert(NfQueue::value_type(clock, pNotification));
+ _nfAvailable.set();
+}
+
+
+void TimedNotificationQueue::enqueueNotification(Notification::Ptr pNotification, Clock clock)
+{
+ poco_check_ptr (pNotification);
+
+ FastMutex::ScopedLock lock(_mutex);
+ _nfQueue.insert(NfQueue::value_type(clock, pNotification));
+ _nfAvailable.set();
+}
+
+
+Notification* TimedNotificationQueue::dequeueNotification()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ NfQueue::iterator it = _nfQueue.begin();
+ if (it != _nfQueue.end())
+ {
+ Clock::ClockDiff sleep = -it->first.elapsed();
+ if (sleep <= 0)
+ {
+ Notification::Ptr pNf = it->second;
+ _nfQueue.erase(it);
+ return pNf.duplicate();
+ }
+ }
+ return 0;
+}
+
+
+Notification* TimedNotificationQueue::waitDequeueNotification()
+{
+ for (;;)
+ {
+ _mutex.lock();
+ NfQueue::iterator it = _nfQueue.begin();
+ if (it != _nfQueue.end())
+ {
+ _mutex.unlock();
+ Clock::ClockDiff sleep = -it->first.elapsed();
+ if (sleep <= 0)
+ {
+ return dequeueOne(it).duplicate();
+ }
+ else if (!wait(sleep))
+ {
+ return dequeueOne(it).duplicate();
+ }
+ else continue;
+ }
+ else
+ {
+ _mutex.unlock();
+ }
+ _nfAvailable.wait();
+ }
+}
+
+
+Notification* TimedNotificationQueue::waitDequeueNotification(long milliseconds)
+{
+ while (milliseconds >= 0)
+ {
+ _mutex.lock();
+ NfQueue::iterator it = _nfQueue.begin();
+ if (it != _nfQueue.end())
+ {
+ _mutex.unlock();
+ Clock now;
+ Clock::ClockDiff sleep = it->first - now;
+ if (sleep <= 0)
+ {
+ return dequeueOne(it).duplicate();
+ }
+ else if (sleep <= 1000*Clock::ClockDiff(milliseconds))
+ {
+ if (!wait(sleep))
+ {
+ return dequeueOne(it).duplicate();
+ }
+ else
+ {
+ milliseconds -= static_cast<long>((now.elapsed() + 999)/1000);
+ continue;
+ }
+ }
+ }
+ else
+ {
+ _mutex.unlock();
+ }
+ if (milliseconds > 0)
+ {
+ Clock now;
+ _nfAvailable.tryWait(milliseconds);
+ milliseconds -= static_cast<long>((now.elapsed() + 999)/1000);
+ }
+ else return 0;
+ }
+ return 0;
+}
+
+
+bool TimedNotificationQueue::wait(Clock::ClockDiff interval)
+{
+ const Clock::ClockDiff MAX_SLEEP = 8*60*60*Clock::ClockDiff(1000000); // sleep at most 8 hours at a time
+ while (interval > 0)
+ {
+ Clock now;
+ Clock::ClockDiff sleep = interval <= MAX_SLEEP ? interval : MAX_SLEEP;
+ if (_nfAvailable.tryWait(static_cast<long>((sleep + 999)/1000)))
+ return true;
+ interval -= now.elapsed();
+ }
+ return false;
+}
+
+
+bool TimedNotificationQueue::empty() const
+{
+ FastMutex::ScopedLock lock(_mutex);
+ return _nfQueue.empty();
+}
+
+
+int TimedNotificationQueue::size() const
+{
+ FastMutex::ScopedLock lock(_mutex);
+ return static_cast<int>(_nfQueue.size());
+}
+
+
+void TimedNotificationQueue::clear()
+{
+ FastMutex::ScopedLock lock(_mutex);
+ _nfQueue.clear();
+}
+
+
+Notification::Ptr TimedNotificationQueue::dequeueOne(NfQueue::iterator& it)
+{
+ FastMutex::ScopedLock lock(_mutex);
+ Notification::Ptr pNf = it->second;
+ _nfQueue.erase(it);
+ return pNf;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Timer.cpp b/contrib/libs/poco/Foundation/src/Timer.cpp
index 4876e7421f..d9ba5ba3b9 100644
--- a/contrib/libs/poco/Foundation/src/Timer.cpp
+++ b/contrib/libs/poco/Foundation/src/Timer.cpp
@@ -1,247 +1,247 @@
-//
-// Timer.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: Timer
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Timer.h"
-#include "Poco/ThreadPool.h"
-#include "Poco/Exception.h"
-#include "Poco/ErrorHandler.h"
-
-
-namespace Poco {
-
-
-Timer::Timer(long startInterval, long periodicInterval):
- _startInterval(startInterval),
- _periodicInterval(periodicInterval),
- _skipped(0),
- _pCallback(0)
-{
- poco_assert (startInterval >= 0 && periodicInterval >= 0);
-}
-
-
-Timer::~Timer()
-{
- try
- {
- stop();
- }
- catch (...)
- {
- poco_unexpected();
- }
-}
-
-
-void Timer::start(const AbstractTimerCallback& method)
-{
- start(method, Thread::PRIO_NORMAL, ThreadPool::defaultPool());
-}
-
-
-void Timer::start(const AbstractTimerCallback& method, Thread::Priority priority)
-{
- start(method, priority, ThreadPool::defaultPool());
-}
-
-
-void Timer::start(const AbstractTimerCallback& method, ThreadPool& threadPool)
-{
- start(method, Thread::PRIO_NORMAL, threadPool);
-}
-
-
-void Timer::start(const AbstractTimerCallback& method, Thread::Priority priority, ThreadPool& threadPool)
-{
- Clock nextInvocation;
- nextInvocation += static_cast<Clock::ClockVal>(_startInterval)*1000;
-
- FastMutex::ScopedLock lock(_mutex);
-
- if (_pCallback)
- {
- throw Poco::IllegalStateException("Timer already running");
- }
-
- _nextInvocation = nextInvocation;
- _pCallback = method.clone();
- _wakeUp.reset();
- try
- {
- threadPool.startWithPriority(priority, *this);
- }
- catch (...)
- {
- delete _pCallback;
- _pCallback = 0;
- throw;
- }
-}
-
-
-void Timer::stop()
-{
- FastMutex::ScopedLock lock(_mutex);
- if (_pCallback)
- {
- _periodicInterval = 0;
- _mutex.unlock();
- _wakeUp.set();
- _done.wait(); // warning: deadlock if called from timer callback
- _mutex.lock();
- delete _pCallback;
- _pCallback = 0;
- }
-}
-
-
-void Timer::restart()
-{
- FastMutex::ScopedLock lock(_mutex);
- if (_pCallback)
- {
- _wakeUp.set();
- }
-}
-
-
-void Timer::restart(long milliseconds)
-{
- poco_assert (milliseconds >= 0);
- FastMutex::ScopedLock lock(_mutex);
- if (_pCallback)
- {
- _periodicInterval = milliseconds;
- _wakeUp.set();
- }
-}
-
-
-long Timer::getStartInterval() const
-{
- FastMutex::ScopedLock lock(_mutex);
- return _startInterval;
-}
-
-
-void Timer::setStartInterval(long milliseconds)
-{
- poco_assert (milliseconds >= 0);
- FastMutex::ScopedLock lock(_mutex);
- _startInterval = milliseconds;
-}
-
-
-long Timer::getPeriodicInterval() const
-{
- FastMutex::ScopedLock lock(_mutex);
- return _periodicInterval;
-}
-
-
-void Timer::setPeriodicInterval(long milliseconds)
-{
- poco_assert (milliseconds >= 0);
- FastMutex::ScopedLock lock(_mutex);
- _periodicInterval = milliseconds;
-}
-
-
-void Timer::run()
-{
- Poco::Clock now;
- long interval(0);
- do
- {
- long sleep(0);
- do
- {
- now.update();
- sleep = static_cast<long>((_nextInvocation - now)/1000);
- if (sleep < 0)
- {
- if (interval == 0)
- {
- sleep = 0;
- break;
- }
- _nextInvocation += static_cast<Clock::ClockVal>(interval)*1000;
- ++_skipped;
- }
- }
- while (sleep < 0);
-
- if (_wakeUp.tryWait(sleep))
- {
- Poco::FastMutex::ScopedLock lock(_mutex);
- _nextInvocation.update();
- interval = _periodicInterval;
- }
- else
- {
- try
- {
- _pCallback->invoke(*this);
- }
- catch (Poco::Exception& exc)
- {
- Poco::ErrorHandler::handle(exc);
- }
- catch (std::exception& exc)
- {
- Poco::ErrorHandler::handle(exc);
- }
- catch (...)
- {
- Poco::ErrorHandler::handle();
- }
- Poco::FastMutex::ScopedLock lock(_mutex);
- interval = _periodicInterval;
- }
- _nextInvocation += static_cast<Clock::ClockVal>(interval)*1000;
- _skipped = 0;
- }
- while (interval > 0);
- _done.set();
-}
-
-
-long Timer::skipped() const
-{
- return _skipped;
-}
-
-
-AbstractTimerCallback::AbstractTimerCallback()
-{
-}
-
-
-AbstractTimerCallback::AbstractTimerCallback(const AbstractTimerCallback& /*callback*/)
-{
-}
-
-
-AbstractTimerCallback::~AbstractTimerCallback()
-{
-}
-
-
-AbstractTimerCallback& AbstractTimerCallback::operator = (const AbstractTimerCallback& /*callback*/)
-{
- return *this;
-}
-
-
-} // namespace Poco
+//
+// Timer.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: Timer
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Timer.h"
+#include "Poco/ThreadPool.h"
+#include "Poco/Exception.h"
+#include "Poco/ErrorHandler.h"
+
+
+namespace Poco {
+
+
+Timer::Timer(long startInterval, long periodicInterval):
+ _startInterval(startInterval),
+ _periodicInterval(periodicInterval),
+ _skipped(0),
+ _pCallback(0)
+{
+ poco_assert (startInterval >= 0 && periodicInterval >= 0);
+}
+
+
+Timer::~Timer()
+{
+ try
+ {
+ stop();
+ }
+ catch (...)
+ {
+ poco_unexpected();
+ }
+}
+
+
+void Timer::start(const AbstractTimerCallback& method)
+{
+ start(method, Thread::PRIO_NORMAL, ThreadPool::defaultPool());
+}
+
+
+void Timer::start(const AbstractTimerCallback& method, Thread::Priority priority)
+{
+ start(method, priority, ThreadPool::defaultPool());
+}
+
+
+void Timer::start(const AbstractTimerCallback& method, ThreadPool& threadPool)
+{
+ start(method, Thread::PRIO_NORMAL, threadPool);
+}
+
+
+void Timer::start(const AbstractTimerCallback& method, Thread::Priority priority, ThreadPool& threadPool)
+{
+ Clock nextInvocation;
+ nextInvocation += static_cast<Clock::ClockVal>(_startInterval)*1000;
+
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (_pCallback)
+ {
+ throw Poco::IllegalStateException("Timer already running");
+ }
+
+ _nextInvocation = nextInvocation;
+ _pCallback = method.clone();
+ _wakeUp.reset();
+ try
+ {
+ threadPool.startWithPriority(priority, *this);
+ }
+ catch (...)
+ {
+ delete _pCallback;
+ _pCallback = 0;
+ throw;
+ }
+}
+
+
+void Timer::stop()
+{
+ FastMutex::ScopedLock lock(_mutex);
+ if (_pCallback)
+ {
+ _periodicInterval = 0;
+ _mutex.unlock();
+ _wakeUp.set();
+ _done.wait(); // warning: deadlock if called from timer callback
+ _mutex.lock();
+ delete _pCallback;
+ _pCallback = 0;
+ }
+}
+
+
+void Timer::restart()
+{
+ FastMutex::ScopedLock lock(_mutex);
+ if (_pCallback)
+ {
+ _wakeUp.set();
+ }
+}
+
+
+void Timer::restart(long milliseconds)
+{
+ poco_assert (milliseconds >= 0);
+ FastMutex::ScopedLock lock(_mutex);
+ if (_pCallback)
+ {
+ _periodicInterval = milliseconds;
+ _wakeUp.set();
+ }
+}
+
+
+long Timer::getStartInterval() const
+{
+ FastMutex::ScopedLock lock(_mutex);
+ return _startInterval;
+}
+
+
+void Timer::setStartInterval(long milliseconds)
+{
+ poco_assert (milliseconds >= 0);
+ FastMutex::ScopedLock lock(_mutex);
+ _startInterval = milliseconds;
+}
+
+
+long Timer::getPeriodicInterval() const
+{
+ FastMutex::ScopedLock lock(_mutex);
+ return _periodicInterval;
+}
+
+
+void Timer::setPeriodicInterval(long milliseconds)
+{
+ poco_assert (milliseconds >= 0);
+ FastMutex::ScopedLock lock(_mutex);
+ _periodicInterval = milliseconds;
+}
+
+
+void Timer::run()
+{
+ Poco::Clock now;
+ long interval(0);
+ do
+ {
+ long sleep(0);
+ do
+ {
+ now.update();
+ sleep = static_cast<long>((_nextInvocation - now)/1000);
+ if (sleep < 0)
+ {
+ if (interval == 0)
+ {
+ sleep = 0;
+ break;
+ }
+ _nextInvocation += static_cast<Clock::ClockVal>(interval)*1000;
+ ++_skipped;
+ }
+ }
+ while (sleep < 0);
+
+ if (_wakeUp.tryWait(sleep))
+ {
+ Poco::FastMutex::ScopedLock lock(_mutex);
+ _nextInvocation.update();
+ interval = _periodicInterval;
+ }
+ else
+ {
+ try
+ {
+ _pCallback->invoke(*this);
+ }
+ catch (Poco::Exception& exc)
+ {
+ Poco::ErrorHandler::handle(exc);
+ }
+ catch (std::exception& exc)
+ {
+ Poco::ErrorHandler::handle(exc);
+ }
+ catch (...)
+ {
+ Poco::ErrorHandler::handle();
+ }
+ Poco::FastMutex::ScopedLock lock(_mutex);
+ interval = _periodicInterval;
+ }
+ _nextInvocation += static_cast<Clock::ClockVal>(interval)*1000;
+ _skipped = 0;
+ }
+ while (interval > 0);
+ _done.set();
+}
+
+
+long Timer::skipped() const
+{
+ return _skipped;
+}
+
+
+AbstractTimerCallback::AbstractTimerCallback()
+{
+}
+
+
+AbstractTimerCallback::AbstractTimerCallback(const AbstractTimerCallback& /*callback*/)
+{
+}
+
+
+AbstractTimerCallback::~AbstractTimerCallback()
+{
+}
+
+
+AbstractTimerCallback& AbstractTimerCallback::operator = (const AbstractTimerCallback& /*callback*/)
+{
+ return *this;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Timespan.cpp b/contrib/libs/poco/Foundation/src/Timespan.cpp
index a9d42f4c3c..27188648c6 100644
--- a/contrib/libs/poco/Foundation/src/Timespan.cpp
+++ b/contrib/libs/poco/Foundation/src/Timespan.cpp
@@ -1,145 +1,145 @@
-//
-// Timespan.cpp
-//
-// Library: Foundation
-// Package: DateTime
-// Module: Timespan
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Timespan.h"
-#include <algorithm>
-
-
-namespace Poco {
-
-
-const Timespan::TimeDiff Timespan::MILLISECONDS = 1000;
-const Timespan::TimeDiff Timespan::SECONDS = 1000*Timespan::MILLISECONDS;
-const Timespan::TimeDiff Timespan::MINUTES = 60*Timespan::SECONDS;
-const Timespan::TimeDiff Timespan::HOURS = 60*Timespan::MINUTES;
-const Timespan::TimeDiff Timespan::DAYS = 24*Timespan::HOURS;
-
-
-Timespan::Timespan():
- _span(0)
-{
-}
-
-
-Timespan::Timespan(TimeDiff microSeconds):
- _span(microSeconds)
-{
-}
-
-
-Timespan::Timespan(long otherSeconds, long otherMicroSeconds):
- _span(TimeDiff(otherSeconds)*SECONDS + otherMicroSeconds)
-{
-}
-
-
-Timespan::Timespan(int otherDays, int otherHours, int otherMinutes, int otherSeconds, int otherMicroSeconds):
- _span(TimeDiff(otherMicroSeconds) + TimeDiff(otherSeconds)*SECONDS + TimeDiff(otherMinutes)*MINUTES + TimeDiff(otherHours)*HOURS + TimeDiff(otherDays)*DAYS)
-{
-}
-
-
-Timespan::Timespan(const Timespan& timespan):
- _span(timespan._span)
-{
-}
-
-
-Timespan& Timespan::operator = (const Timespan& timespan)
-{
- _span = timespan._span;
- return *this;
-}
-
-
-Timespan& Timespan::operator = (TimeDiff microSeconds)
-{
- _span = microSeconds;
- return *this;
-}
-
-
-Timespan& Timespan::assign(int otherDays, int otherHours, int otherMinutes, int otherSeconds, int otherMicroSeconds)
-{
- _span = TimeDiff(otherMicroSeconds) + TimeDiff(otherSeconds)*SECONDS + TimeDiff(otherMinutes)*MINUTES + TimeDiff(otherHours)*HOURS + TimeDiff(otherDays)*DAYS;
- return *this;
-}
-
-
-Timespan& Timespan::assign(long otherSeconds, long otherMicroSeconds)
-{
- _span = TimeDiff(otherSeconds)*SECONDS + TimeDiff(otherMicroSeconds);
- return *this;
-}
-
-
-void Timespan::swap(Timespan& timespan)
-{
- std::swap(_span, timespan._span);
-}
-
-
-Timespan Timespan::operator + (const Timespan& d) const
-{
- return Timespan(_span + d._span);
-}
-
-
-Timespan Timespan::operator - (const Timespan& d) const
-{
- return Timespan(_span - d._span);
-}
-
-
-Timespan& Timespan::operator += (const Timespan& d)
-{
- _span += d._span;
- return *this;
-}
-
-
-Timespan& Timespan::operator -= (const Timespan& d)
-{
- _span -= d._span;
- return *this;
-}
-
-
-Timespan Timespan::operator + (TimeDiff microSeconds) const
-{
- return Timespan(_span + microSeconds);
-}
-
-
-Timespan Timespan::operator - (TimeDiff microSeconds) const
-{
- return Timespan(_span - microSeconds);
-}
-
-
-Timespan& Timespan::operator += (TimeDiff microSeconds)
-{
- _span += microSeconds;
- return *this;
-}
-
-
-Timespan& Timespan::operator -= (TimeDiff microSeconds)
-{
- _span -= microSeconds;
- return *this;
-}
-
-
-} // namespace Poco
+//
+// Timespan.cpp
+//
+// Library: Foundation
+// Package: DateTime
+// Module: Timespan
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Timespan.h"
+#include <algorithm>
+
+
+namespace Poco {
+
+
+const Timespan::TimeDiff Timespan::MILLISECONDS = 1000;
+const Timespan::TimeDiff Timespan::SECONDS = 1000*Timespan::MILLISECONDS;
+const Timespan::TimeDiff Timespan::MINUTES = 60*Timespan::SECONDS;
+const Timespan::TimeDiff Timespan::HOURS = 60*Timespan::MINUTES;
+const Timespan::TimeDiff Timespan::DAYS = 24*Timespan::HOURS;
+
+
+Timespan::Timespan():
+ _span(0)
+{
+}
+
+
+Timespan::Timespan(TimeDiff microSeconds):
+ _span(microSeconds)
+{
+}
+
+
+Timespan::Timespan(long otherSeconds, long otherMicroSeconds):
+ _span(TimeDiff(otherSeconds)*SECONDS + otherMicroSeconds)
+{
+}
+
+
+Timespan::Timespan(int otherDays, int otherHours, int otherMinutes, int otherSeconds, int otherMicroSeconds):
+ _span(TimeDiff(otherMicroSeconds) + TimeDiff(otherSeconds)*SECONDS + TimeDiff(otherMinutes)*MINUTES + TimeDiff(otherHours)*HOURS + TimeDiff(otherDays)*DAYS)
+{
+}
+
+
+Timespan::Timespan(const Timespan& timespan):
+ _span(timespan._span)
+{
+}
+
+
+Timespan& Timespan::operator = (const Timespan& timespan)
+{
+ _span = timespan._span;
+ return *this;
+}
+
+
+Timespan& Timespan::operator = (TimeDiff microSeconds)
+{
+ _span = microSeconds;
+ return *this;
+}
+
+
+Timespan& Timespan::assign(int otherDays, int otherHours, int otherMinutes, int otherSeconds, int otherMicroSeconds)
+{
+ _span = TimeDiff(otherMicroSeconds) + TimeDiff(otherSeconds)*SECONDS + TimeDiff(otherMinutes)*MINUTES + TimeDiff(otherHours)*HOURS + TimeDiff(otherDays)*DAYS;
+ return *this;
+}
+
+
+Timespan& Timespan::assign(long otherSeconds, long otherMicroSeconds)
+{
+ _span = TimeDiff(otherSeconds)*SECONDS + TimeDiff(otherMicroSeconds);
+ return *this;
+}
+
+
+void Timespan::swap(Timespan& timespan)
+{
+ std::swap(_span, timespan._span);
+}
+
+
+Timespan Timespan::operator + (const Timespan& d) const
+{
+ return Timespan(_span + d._span);
+}
+
+
+Timespan Timespan::operator - (const Timespan& d) const
+{
+ return Timespan(_span - d._span);
+}
+
+
+Timespan& Timespan::operator += (const Timespan& d)
+{
+ _span += d._span;
+ return *this;
+}
+
+
+Timespan& Timespan::operator -= (const Timespan& d)
+{
+ _span -= d._span;
+ return *this;
+}
+
+
+Timespan Timespan::operator + (TimeDiff microSeconds) const
+{
+ return Timespan(_span + microSeconds);
+}
+
+
+Timespan Timespan::operator - (TimeDiff microSeconds) const
+{
+ return Timespan(_span - microSeconds);
+}
+
+
+Timespan& Timespan::operator += (TimeDiff microSeconds)
+{
+ _span += microSeconds;
+ return *this;
+}
+
+
+Timespan& Timespan::operator -= (TimeDiff microSeconds)
+{
+ _span -= microSeconds;
+ return *this;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Timestamp.cpp b/contrib/libs/poco/Foundation/src/Timestamp.cpp
index aca1e3494a..3b836ad543 100644
--- a/contrib/libs/poco/Foundation/src/Timestamp.cpp
+++ b/contrib/libs/poco/Foundation/src/Timestamp.cpp
@@ -1,313 +1,313 @@
-//
-// Timestamp.cpp
-//
-// Library: Foundation
-// Package: DateTime
-// Module: Timestamp
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Timestamp.h"
-#include "Poco/Timespan.h"
-#include "Poco/Exception.h"
-#include <algorithm>
-#undef min
-#undef max
-#include <limits>
-#if defined(POCO_OS_FAMILY_UNIX)
-#include <time.h>
-#include <unistd.h>
-#if defined(POCO_VXWORKS)
-#include <timers.h>
-#else
-#include <sys/time.h>
-#include <sys/times.h>
-#endif
-#elif defined(POCO_OS_FAMILY_WINDOWS)
-#include "Poco/UnWindows.h"
-#if defined(_WIN32_WCE)
-#include <cmath>
-#endif
-#endif
-
-
-#ifndef POCO_HAVE_CLOCK_GETTIME
- #if (defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME)) || defined(POCO_VXWORKS) || defined(__QNX__)
- #ifndef __APPLE__ // See GitHub issue #1453 - not available before Mac OS 10.12/iOS 10
- #define POCO_HAVE_CLOCK_GETTIME
- #endif
- #endif
-#endif
-
-
-#if defined(_WIN32_WCE) && defined(POCO_WINCE_TIMESTAMP_HACK)
-
-
-//
-// See <http://community.opennetcf.com/articles/cf/archive/2007/11/20/getting-a-millisecond-resolution-datetime-under-windows-ce.aspx>
-// for an explanation of the following code.
-//
-// In short: Windows CE system time in most cases only has a resolution of one second.
-// But we want millisecond resolution.
-//
-
-
-namespace {
-
-
-class TickOffset
-{
-public:
- TickOffset()
- {
- SYSTEMTIME st1, st2;
- std::memset(&st1, 0, sizeof(SYSTEMTIME));
- std::memset(&st2, 0, sizeof(SYSTEMTIME));
- GetSystemTime(&st1);
- while (true)
- {
- GetSystemTime(&st2);
-
- // wait for a rollover
- if (st1.wSecond != st2.wSecond)
- {
- _offset = GetTickCount() % 1000;
- break;
- }
- }
- }
-
- void calibrate(int seconds)
- {
- SYSTEMTIME st1, st2;
- systemTime(&st1);
-
- WORD s = st1.wSecond;
- int sum = 0;
- int remaining = seconds;
- while (remaining > 0)
- {
- systemTime(&st2);
- WORD s2 = st2.wSecond;
-
- if (s != s2)
- {
- remaining--;
- // store the offset from zero
- sum += (st2.wMilliseconds > 500) ? (st2.wMilliseconds - 1000) : st2.wMilliseconds;
- s = st2.wSecond;
- }
- }
-
- // adjust the offset by the average deviation from zero (round to the integer farthest from zero)
- if (sum < 0)
- _offset += (int) std::floor(sum / (float)seconds);
- else
- _offset += (int) std::ceil(sum / (float)seconds);
- }
-
- void systemTime(SYSTEMTIME* pST)
- {
- std::memset(pST, 0, sizeof(SYSTEMTIME));
-
- WORD tick = GetTickCount() % 1000;
- GetSystemTime(pST);
- WORD ms = (tick >= _offset) ? (tick - _offset) : (1000 - (_offset - tick));
- pST->wMilliseconds = ms;
- }
-
- void systemTimeAsFileTime(FILETIME* pFT)
- {
- SYSTEMTIME st;
- systemTime(&st);
- SystemTimeToFileTime(&st, pFT);
- }
-
-private:
- WORD _offset;
-};
-
-
-static TickOffset offset;
-
-
-void GetSystemTimeAsFileTimeWithMillisecondResolution(FILETIME* pFT)
-{
- offset.systemTimeAsFileTime(pFT);
-}
-
-
-} // namespace
-
-
-#endif // defined(_WIN32_WCE) && defined(POCO_WINCE_TIMESTAMP_HACK)
-
-
-namespace Poco {
-
-
-const Timestamp::TimeVal Timestamp::TIMEVAL_MIN = std::numeric_limits<Timestamp::TimeVal>::min();
-const Timestamp::TimeVal Timestamp::TIMEVAL_MAX = std::numeric_limits<Timestamp::TimeVal>::max();
-
-
-Timestamp::Timestamp()
-{
- update();
-}
-
-
-Timestamp::Timestamp(TimeVal tv)
-{
- _ts = tv;
-}
-
-
-Timestamp::Timestamp(const Timestamp& other)
-{
- _ts = other._ts;
-}
-
-
-Timestamp::~Timestamp()
-{
-}
-
-
-Timestamp& Timestamp::operator = (const Timestamp& other)
-{
- _ts = other._ts;
- return *this;
-}
-
-
-Timestamp& Timestamp::operator = (TimeVal tv)
-{
- _ts = tv;
- return *this;
-}
-
-
-void Timestamp::swap(Timestamp& timestamp)
-{
- std::swap(_ts, timestamp._ts);
-}
-
-
-Timestamp Timestamp::fromEpochTime(std::time_t t)
-{
- return Timestamp(TimeVal(t)*resolution());
-}
-
-
-Timestamp Timestamp::fromUtcTime(UtcTimeVal val)
-{
- val -= (TimeDiff(0x01b21dd2) << 32) + 0x13814000;
- val /= 10;
- return Timestamp(val);
-}
-
-
-void Timestamp::update()
-{
-#if defined(POCO_OS_FAMILY_WINDOWS)
-
- FILETIME ft;
-#if defined(_WIN32_WCE) && defined(POCO_WINCE_TIMESTAMP_HACK)
- GetSystemTimeAsFileTimeWithMillisecondResolution(&ft);
-#else
- GetSystemTimeAsFileTime(&ft);
-#endif
-
- ULARGE_INTEGER epoch; // UNIX epoch (1970-01-01 00:00:00) expressed in Windows NT FILETIME
- epoch.LowPart = 0xD53E8000;
- epoch.HighPart = 0x019DB1DE;
-
- ULARGE_INTEGER ts;
- ts.LowPart = ft.dwLowDateTime;
- ts.HighPart = ft.dwHighDateTime;
- ts.QuadPart -= epoch.QuadPart;
- _ts = ts.QuadPart/10;
-
-#elif defined(POCO_HAVE_CLOCK_GETTIME)
-
- struct timespec ts;
- if (clock_gettime(CLOCK_REALTIME, &ts))
- throw SystemException("cannot get time of day");
- _ts = TimeVal(ts.tv_sec)*resolution() + ts.tv_nsec/1000;
-
-#else
-
- struct timeval tv;
- if (gettimeofday(&tv, NULL))
- throw SystemException("cannot get time of day");
- _ts = TimeVal(tv.tv_sec)*resolution() + tv.tv_usec;
-
-#endif
-}
-
-
-Timestamp Timestamp::operator + (const Timespan& span) const
-{
- return *this + span.totalMicroseconds();
-}
-
-
-Timestamp Timestamp::operator - (const Timespan& span) const
-{
- return *this - span.totalMicroseconds();
-}
-
-
-Timestamp& Timestamp::operator += (const Timespan& span)
-{
- return *this += span.totalMicroseconds();
-}
-
-
-Timestamp& Timestamp::operator -= (const Timespan& span)
-{
- return *this -= span.totalMicroseconds();
-}
-
-
-#if defined(_WIN32)
-
-
-Timestamp Timestamp::fromFileTimeNP(UInt32 fileTimeLow, UInt32 fileTimeHigh)
-{
- ULARGE_INTEGER epoch; // UNIX epoch (1970-01-01 00:00:00) expressed in Windows NT FILETIME
- epoch.LowPart = 0xD53E8000;
- epoch.HighPart = 0x019DB1DE;
-
- ULARGE_INTEGER ts;
- ts.LowPart = fileTimeLow;
- ts.HighPart = fileTimeHigh;
- ts.QuadPart -= epoch.QuadPart;
-
- return Timestamp(ts.QuadPart/10);
-}
-
-
-void Timestamp::toFileTimeNP(UInt32& fileTimeLow, UInt32& fileTimeHigh) const
-{
- ULARGE_INTEGER epoch; // UNIX epoch (1970-01-01 00:00:00) expressed in Windows NT FILETIME
- epoch.LowPart = 0xD53E8000;
- epoch.HighPart = 0x019DB1DE;
-
- ULARGE_INTEGER ts;
- ts.QuadPart = _ts*10;
- ts.QuadPart += epoch.QuadPart;
- fileTimeLow = ts.LowPart;
- fileTimeHigh = ts.HighPart;
-}
-
-
-#endif
-
-
-} // namespace Poco
+//
+// Timestamp.cpp
+//
+// Library: Foundation
+// Package: DateTime
+// Module: Timestamp
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Timestamp.h"
+#include "Poco/Timespan.h"
+#include "Poco/Exception.h"
+#include <algorithm>
+#undef min
+#undef max
+#include <limits>
+#if defined(POCO_OS_FAMILY_UNIX)
+#include <time.h>
+#include <unistd.h>
+#if defined(POCO_VXWORKS)
+#include <timers.h>
+#else
+#include <sys/time.h>
+#include <sys/times.h>
+#endif
+#elif defined(POCO_OS_FAMILY_WINDOWS)
+#include "Poco/UnWindows.h"
+#if defined(_WIN32_WCE)
+#include <cmath>
+#endif
+#endif
+
+
+#ifndef POCO_HAVE_CLOCK_GETTIME
+ #if (defined(_POSIX_TIMERS) && defined(CLOCK_REALTIME)) || defined(POCO_VXWORKS) || defined(__QNX__)
+ #ifndef __APPLE__ // See GitHub issue #1453 - not available before Mac OS 10.12/iOS 10
+ #define POCO_HAVE_CLOCK_GETTIME
+ #endif
+ #endif
+#endif
+
+
+#if defined(_WIN32_WCE) && defined(POCO_WINCE_TIMESTAMP_HACK)
+
+
+//
+// See <http://community.opennetcf.com/articles/cf/archive/2007/11/20/getting-a-millisecond-resolution-datetime-under-windows-ce.aspx>
+// for an explanation of the following code.
+//
+// In short: Windows CE system time in most cases only has a resolution of one second.
+// But we want millisecond resolution.
+//
+
+
+namespace {
+
+
+class TickOffset
+{
+public:
+ TickOffset()
+ {
+ SYSTEMTIME st1, st2;
+ std::memset(&st1, 0, sizeof(SYSTEMTIME));
+ std::memset(&st2, 0, sizeof(SYSTEMTIME));
+ GetSystemTime(&st1);
+ while (true)
+ {
+ GetSystemTime(&st2);
+
+ // wait for a rollover
+ if (st1.wSecond != st2.wSecond)
+ {
+ _offset = GetTickCount() % 1000;
+ break;
+ }
+ }
+ }
+
+ void calibrate(int seconds)
+ {
+ SYSTEMTIME st1, st2;
+ systemTime(&st1);
+
+ WORD s = st1.wSecond;
+ int sum = 0;
+ int remaining = seconds;
+ while (remaining > 0)
+ {
+ systemTime(&st2);
+ WORD s2 = st2.wSecond;
+
+ if (s != s2)
+ {
+ remaining--;
+ // store the offset from zero
+ sum += (st2.wMilliseconds > 500) ? (st2.wMilliseconds - 1000) : st2.wMilliseconds;
+ s = st2.wSecond;
+ }
+ }
+
+ // adjust the offset by the average deviation from zero (round to the integer farthest from zero)
+ if (sum < 0)
+ _offset += (int) std::floor(sum / (float)seconds);
+ else
+ _offset += (int) std::ceil(sum / (float)seconds);
+ }
+
+ void systemTime(SYSTEMTIME* pST)
+ {
+ std::memset(pST, 0, sizeof(SYSTEMTIME));
+
+ WORD tick = GetTickCount() % 1000;
+ GetSystemTime(pST);
+ WORD ms = (tick >= _offset) ? (tick - _offset) : (1000 - (_offset - tick));
+ pST->wMilliseconds = ms;
+ }
+
+ void systemTimeAsFileTime(FILETIME* pFT)
+ {
+ SYSTEMTIME st;
+ systemTime(&st);
+ SystemTimeToFileTime(&st, pFT);
+ }
+
+private:
+ WORD _offset;
+};
+
+
+static TickOffset offset;
+
+
+void GetSystemTimeAsFileTimeWithMillisecondResolution(FILETIME* pFT)
+{
+ offset.systemTimeAsFileTime(pFT);
+}
+
+
+} // namespace
+
+
+#endif // defined(_WIN32_WCE) && defined(POCO_WINCE_TIMESTAMP_HACK)
+
+
+namespace Poco {
+
+
+const Timestamp::TimeVal Timestamp::TIMEVAL_MIN = std::numeric_limits<Timestamp::TimeVal>::min();
+const Timestamp::TimeVal Timestamp::TIMEVAL_MAX = std::numeric_limits<Timestamp::TimeVal>::max();
+
+
+Timestamp::Timestamp()
+{
+ update();
+}
+
+
+Timestamp::Timestamp(TimeVal tv)
+{
+ _ts = tv;
+}
+
+
+Timestamp::Timestamp(const Timestamp& other)
+{
+ _ts = other._ts;
+}
+
+
+Timestamp::~Timestamp()
+{
+}
+
+
+Timestamp& Timestamp::operator = (const Timestamp& other)
+{
+ _ts = other._ts;
+ return *this;
+}
+
+
+Timestamp& Timestamp::operator = (TimeVal tv)
+{
+ _ts = tv;
+ return *this;
+}
+
+
+void Timestamp::swap(Timestamp& timestamp)
+{
+ std::swap(_ts, timestamp._ts);
+}
+
+
+Timestamp Timestamp::fromEpochTime(std::time_t t)
+{
+ return Timestamp(TimeVal(t)*resolution());
+}
+
+
+Timestamp Timestamp::fromUtcTime(UtcTimeVal val)
+{
+ val -= (TimeDiff(0x01b21dd2) << 32) + 0x13814000;
+ val /= 10;
+ return Timestamp(val);
+}
+
+
+void Timestamp::update()
+{
+#if defined(POCO_OS_FAMILY_WINDOWS)
+
+ FILETIME ft;
+#if defined(_WIN32_WCE) && defined(POCO_WINCE_TIMESTAMP_HACK)
+ GetSystemTimeAsFileTimeWithMillisecondResolution(&ft);
+#else
+ GetSystemTimeAsFileTime(&ft);
+#endif
+
+ ULARGE_INTEGER epoch; // UNIX epoch (1970-01-01 00:00:00) expressed in Windows NT FILETIME
+ epoch.LowPart = 0xD53E8000;
+ epoch.HighPart = 0x019DB1DE;
+
+ ULARGE_INTEGER ts;
+ ts.LowPart = ft.dwLowDateTime;
+ ts.HighPart = ft.dwHighDateTime;
+ ts.QuadPart -= epoch.QuadPart;
+ _ts = ts.QuadPart/10;
+
+#elif defined(POCO_HAVE_CLOCK_GETTIME)
+
+ struct timespec ts;
+ if (clock_gettime(CLOCK_REALTIME, &ts))
+ throw SystemException("cannot get time of day");
+ _ts = TimeVal(ts.tv_sec)*resolution() + ts.tv_nsec/1000;
+
+#else
+
+ struct timeval tv;
+ if (gettimeofday(&tv, NULL))
+ throw SystemException("cannot get time of day");
+ _ts = TimeVal(tv.tv_sec)*resolution() + tv.tv_usec;
+
+#endif
+}
+
+
+Timestamp Timestamp::operator + (const Timespan& span) const
+{
+ return *this + span.totalMicroseconds();
+}
+
+
+Timestamp Timestamp::operator - (const Timespan& span) const
+{
+ return *this - span.totalMicroseconds();
+}
+
+
+Timestamp& Timestamp::operator += (const Timespan& span)
+{
+ return *this += span.totalMicroseconds();
+}
+
+
+Timestamp& Timestamp::operator -= (const Timespan& span)
+{
+ return *this -= span.totalMicroseconds();
+}
+
+
+#if defined(_WIN32)
+
+
+Timestamp Timestamp::fromFileTimeNP(UInt32 fileTimeLow, UInt32 fileTimeHigh)
+{
+ ULARGE_INTEGER epoch; // UNIX epoch (1970-01-01 00:00:00) expressed in Windows NT FILETIME
+ epoch.LowPart = 0xD53E8000;
+ epoch.HighPart = 0x019DB1DE;
+
+ ULARGE_INTEGER ts;
+ ts.LowPart = fileTimeLow;
+ ts.HighPart = fileTimeHigh;
+ ts.QuadPart -= epoch.QuadPart;
+
+ return Timestamp(ts.QuadPart/10);
+}
+
+
+void Timestamp::toFileTimeNP(UInt32& fileTimeLow, UInt32& fileTimeHigh) const
+{
+ ULARGE_INTEGER epoch; // UNIX epoch (1970-01-01 00:00:00) expressed in Windows NT FILETIME
+ epoch.LowPart = 0xD53E8000;
+ epoch.HighPart = 0x019DB1DE;
+
+ ULARGE_INTEGER ts;
+ ts.QuadPart = _ts*10;
+ ts.QuadPart += epoch.QuadPart;
+ fileTimeLow = ts.LowPart;
+ fileTimeHigh = ts.HighPart;
+}
+
+
+#endif
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Timezone.cpp b/contrib/libs/poco/Foundation/src/Timezone.cpp
index fa229cbb22..70a151ef50 100644
--- a/contrib/libs/poco/Foundation/src/Timezone.cpp
+++ b/contrib/libs/poco/Foundation/src/Timezone.cpp
@@ -1,41 +1,41 @@
-//
-// Timezone.cpp
-//
-// Library: Foundation
-// Package: DateTime
-// Module: Timezone
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Timezone.h"
-#include <ctime>
-
-
-#if defined(POCO_OS_FAMILY_WINDOWS)
-#if defined(_WIN32_WCE)
-#include "Timezone_WINCE.cpp"
-#else
-#include "Timezone_WIN32.cpp"
-#endif
-#elif defined(POCO_VXWORKS)
-#include "Timezone_VX.cpp"
-#else
-#include "Timezone_UNIX.cpp"
-#endif
-
-
-namespace Poco {
-
-
-int Timezone::tzd()
-{
- return utcOffset() + dst();
-}
-
-
-} // namespace Poco
+//
+// Timezone.cpp
+//
+// Library: Foundation
+// Package: DateTime
+// Module: Timezone
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Timezone.h"
+#include <ctime>
+
+
+#if defined(POCO_OS_FAMILY_WINDOWS)
+#if defined(_WIN32_WCE)
+#include "Timezone_WINCE.cpp"
+#else
+#include "Timezone_WIN32.cpp"
+#endif
+#elif defined(POCO_VXWORKS)
+#include "Timezone_VX.cpp"
+#else
+#include "Timezone_UNIX.cpp"
+#endif
+
+
+namespace Poco {
+
+
+int Timezone::tzd()
+{
+ return utcOffset() + dst();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Timezone_UNIX.cpp b/contrib/libs/poco/Foundation/src/Timezone_UNIX.cpp
index 118b43465e..da212e0a06 100644
--- a/contrib/libs/poco/Foundation/src/Timezone_UNIX.cpp
+++ b/contrib/libs/poco/Foundation/src/Timezone_UNIX.cpp
@@ -1,110 +1,110 @@
-//
-// Timezone_UNIX.cpp
-//
-// Library: Foundation
-// Package: DateTime
-// Module: Timezone
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Timezone.h"
-#include "Poco/Exception.h"
-#include "Poco/Mutex.h"
-#include <ctime>
-
-
-namespace Poco {
-
-
-class TZInfo
-{
-public:
- TZInfo()
- {
- tzset();
- }
-
- int timeZone()
- {
- Poco::FastMutex::ScopedLock lock(_mutex);
-
- #if defined(__APPLE__) || defined(__FreeBSD__) || defined (__OpenBSD__) || POCO_OS == POCO_OS_ANDROID // no timezone global var
- std::time_t now = std::time(NULL);
- struct std::tm t;
- gmtime_r(&now, &t);
- std::time_t utc = std::mktime(&t);
- return now - utc;
- #elif defined(__CYGWIN__)
- tzset();
- return -_timezone;
- #else
- tzset();
- return -timezone;
- #endif
- }
-
- const char* name(bool dst)
- {
- Poco::FastMutex::ScopedLock lock(_mutex);
-
- tzset();
- return tzname[dst ? 1 : 0];
- }
-
-private:
- Poco::FastMutex _mutex;
-};
-
-
-static TZInfo tzInfo;
-
-
-int Timezone::utcOffset()
-{
- return tzInfo.timeZone();
-}
-
-
-int Timezone::dst()
-{
- std::time_t now = std::time(NULL);
- struct std::tm t;
- if (!localtime_r(&now, &t))
- throw Poco::SystemException("cannot get local time DST offset");
- return t.tm_isdst == 1 ? 3600 : 0;
-}
-
-
-bool Timezone::isDst(const Timestamp& timestamp)
-{
- std::time_t time = timestamp.epochTime();
- struct std::tm* tms = std::localtime(&time);
- if (!tms) throw Poco::SystemException("cannot get local time DST flag");
- return tms->tm_isdst > 0;
-}
-
-
-std::string Timezone::name()
-{
- return std::string(tzInfo.name(dst() != 0));
-}
-
-
-std::string Timezone::standardName()
-{
- return std::string(tzInfo.name(false));
-}
-
-
-std::string Timezone::dstName()
-{
- return std::string(tzInfo.name(true));
-}
-
-
-} // namespace Poco
+//
+// Timezone_UNIX.cpp
+//
+// Library: Foundation
+// Package: DateTime
+// Module: Timezone
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Timezone.h"
+#include "Poco/Exception.h"
+#include "Poco/Mutex.h"
+#include <ctime>
+
+
+namespace Poco {
+
+
+class TZInfo
+{
+public:
+ TZInfo()
+ {
+ tzset();
+ }
+
+ int timeZone()
+ {
+ Poco::FastMutex::ScopedLock lock(_mutex);
+
+ #if defined(__APPLE__) || defined(__FreeBSD__) || defined (__OpenBSD__) || POCO_OS == POCO_OS_ANDROID // no timezone global var
+ std::time_t now = std::time(NULL);
+ struct std::tm t;
+ gmtime_r(&now, &t);
+ std::time_t utc = std::mktime(&t);
+ return now - utc;
+ #elif defined(__CYGWIN__)
+ tzset();
+ return -_timezone;
+ #else
+ tzset();
+ return -timezone;
+ #endif
+ }
+
+ const char* name(bool dst)
+ {
+ Poco::FastMutex::ScopedLock lock(_mutex);
+
+ tzset();
+ return tzname[dst ? 1 : 0];
+ }
+
+private:
+ Poco::FastMutex _mutex;
+};
+
+
+static TZInfo tzInfo;
+
+
+int Timezone::utcOffset()
+{
+ return tzInfo.timeZone();
+}
+
+
+int Timezone::dst()
+{
+ std::time_t now = std::time(NULL);
+ struct std::tm t;
+ if (!localtime_r(&now, &t))
+ throw Poco::SystemException("cannot get local time DST offset");
+ return t.tm_isdst == 1 ? 3600 : 0;
+}
+
+
+bool Timezone::isDst(const Timestamp& timestamp)
+{
+ std::time_t time = timestamp.epochTime();
+ struct std::tm* tms = std::localtime(&time);
+ if (!tms) throw Poco::SystemException("cannot get local time DST flag");
+ return tms->tm_isdst > 0;
+}
+
+
+std::string Timezone::name()
+{
+ return std::string(tzInfo.name(dst() != 0));
+}
+
+
+std::string Timezone::standardName()
+{
+ return std::string(tzInfo.name(false));
+}
+
+
+std::string Timezone::dstName()
+{
+ return std::string(tzInfo.name(true));
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Timezone_VX.cpp b/contrib/libs/poco/Foundation/src/Timezone_VX.cpp
index 18339bffab..79a8a78066 100644
--- a/contrib/libs/poco/Foundation/src/Timezone_VX.cpp
+++ b/contrib/libs/poco/Foundation/src/Timezone_VX.cpp
@@ -1,78 +1,78 @@
-//
-// Timezone_VXX.cpp
-//
-// Library: Foundation
-// Package: DateTime
-// Module: Timezone
-//
-// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Timezone.h"
-#include "Poco/Exception.h"
-#include "Poco/Environment.h"
-#include <ctime>
-
-
-namespace Poco {
-
-
-int Timezone::utcOffset()
-{
- std::time_t now = std::time(NULL);
- struct std::tm t;
- gmtime_r(&now, &t);
- std::time_t utc = std::mktime(&t);
- return now - utc;
-}
-
-
-int Timezone::dst()
-{
- std::time_t now = std::time(NULL);
- struct std::tm t;
- if (localtime_r(&now, &t) != OK)
- throw Poco::SystemException("cannot get local time DST offset");
- return t.tm_isdst == 1 ? 3600 : 0;
-}
-
-
-bool Timezone::isDst(const Timestamp& timestamp)
-{
- std::time_t time = timestamp.epochTime();
- struct std::tm* tms = std::localtime(&time);
- if (!tms) throw Poco::SystemException("cannot get local time DST flag");
- return tms->tm_isdst > 0;
-}
-
-
-std::string Timezone::name()
-{
- // format of TIMEZONE environment variable:
- // name_of_zone:<(unused)>:time_in_minutes_from_UTC:daylight_start:daylight_end
- std::string tz = Environment::get("TIMEZONE", "UTC");
- std::string::size_type pos = tz.find(':');
- if (pos != std::string::npos)
- return tz.substr(0, pos);
- else
- return tz;
-}
-
-
-std::string Timezone::standardName()
-{
- return name();
-}
-
-
-std::string Timezone::dstName()
-{
- return name();
-}
-
-
-} // namespace Poco
+//
+// Timezone_VXX.cpp
+//
+// Library: Foundation
+// Package: DateTime
+// Module: Timezone
+//
+// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Timezone.h"
+#include "Poco/Exception.h"
+#include "Poco/Environment.h"
+#include <ctime>
+
+
+namespace Poco {
+
+
+int Timezone::utcOffset()
+{
+ std::time_t now = std::time(NULL);
+ struct std::tm t;
+ gmtime_r(&now, &t);
+ std::time_t utc = std::mktime(&t);
+ return now - utc;
+}
+
+
+int Timezone::dst()
+{
+ std::time_t now = std::time(NULL);
+ struct std::tm t;
+ if (localtime_r(&now, &t) != OK)
+ throw Poco::SystemException("cannot get local time DST offset");
+ return t.tm_isdst == 1 ? 3600 : 0;
+}
+
+
+bool Timezone::isDst(const Timestamp& timestamp)
+{
+ std::time_t time = timestamp.epochTime();
+ struct std::tm* tms = std::localtime(&time);
+ if (!tms) throw Poco::SystemException("cannot get local time DST flag");
+ return tms->tm_isdst > 0;
+}
+
+
+std::string Timezone::name()
+{
+ // format of TIMEZONE environment variable:
+ // name_of_zone:<(unused)>:time_in_minutes_from_UTC:daylight_start:daylight_end
+ std::string tz = Environment::get("TIMEZONE", "UTC");
+ std::string::size_type pos = tz.find(':');
+ if (pos != std::string::npos)
+ return tz.substr(0, pos);
+ else
+ return tz;
+}
+
+
+std::string Timezone::standardName()
+{
+ return name();
+}
+
+
+std::string Timezone::dstName()
+{
+ return name();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Timezone_WIN32.cpp b/contrib/libs/poco/Foundation/src/Timezone_WIN32.cpp
index 8b1c1835ab..b8582326e9 100644
--- a/contrib/libs/poco/Foundation/src/Timezone_WIN32.cpp
+++ b/contrib/libs/poco/Foundation/src/Timezone_WIN32.cpp
@@ -1,101 +1,101 @@
-//
-// Timezone_WIN32.cpp
-//
-// Library: Foundation
-// Package: DateTime
-// Module: Timezone
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Timezone.h"
-#include "Poco/UnicodeConverter.h"
-#include "Poco/Exception.h"
-#include "Poco/UnWindows.h"
-#include <ctime>
-
-
-namespace Poco {
-
-
-int Timezone::utcOffset()
-{
- TIME_ZONE_INFORMATION tzInfo;
- /*DWORD dstFlag = */GetTimeZoneInformation(&tzInfo);
- return -tzInfo.Bias*60;
-}
-
-
-int Timezone::dst()
-{
- TIME_ZONE_INFORMATION tzInfo;
- DWORD dstFlag = GetTimeZoneInformation(&tzInfo);
- return dstFlag == TIME_ZONE_ID_DAYLIGHT ? -tzInfo.DaylightBias*60 : 0;
-}
-
-
-bool Timezone::isDst(const Timestamp& timestamp)
-{
- std::time_t time = timestamp.epochTime();
- struct std::tm* tms = std::localtime(&time);
- if (!tms) throw Poco::SystemException("cannot get local time DST flag");
- return tms->tm_isdst > 0;
-}
-
-
-std::string Timezone::name()
-{
- std::string result;
- TIME_ZONE_INFORMATION tzInfo;
- DWORD dstFlag = GetTimeZoneInformation(&tzInfo);
- WCHAR* ptr = dstFlag == TIME_ZONE_ID_DAYLIGHT ? tzInfo.DaylightName : tzInfo.StandardName;
-#if defined(POCO_WIN32_UTF8)
- UnicodeConverter::toUTF8(ptr, result);
-#else
- char buffer[256];
- DWORD rc = WideCharToMultiByte(CP_ACP, 0, ptr, -1, buffer, sizeof(buffer), NULL, NULL);
- if (rc) result = buffer;
-#endif
- return result;
-}
-
-
-std::string Timezone::standardName()
-{
- std::string result;
- TIME_ZONE_INFORMATION tzInfo;
- /*DWORD dstFlag =*/ GetTimeZoneInformation(&tzInfo);
- WCHAR* ptr = tzInfo.StandardName;
-#if defined(POCO_WIN32_UTF8)
- UnicodeConverter::toUTF8(ptr, result);
-#else
- char buffer[256];
- DWORD rc = WideCharToMultiByte(CP_ACP, 0, ptr, -1, buffer, sizeof(buffer), NULL, NULL);
- if (rc) result = buffer;
-#endif
- return result;
-}
-
-
-std::string Timezone::dstName()
-{
- std::string result;
- TIME_ZONE_INFORMATION tzInfo;
- /*DWORD dstFlag =*/ GetTimeZoneInformation(&tzInfo);
- WCHAR* ptr = tzInfo.DaylightName;
-#if defined(POCO_WIN32_UTF8)
- UnicodeConverter::toUTF8(ptr, result);
-#else
- char buffer[256];
- DWORD rc = WideCharToMultiByte(CP_ACP, 0, ptr, -1, buffer, sizeof(buffer), NULL, NULL);
- if (rc) result = buffer;
-#endif
- return result;
-}
-
-
-} // namespace Poco
+//
+// Timezone_WIN32.cpp
+//
+// Library: Foundation
+// Package: DateTime
+// Module: Timezone
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Timezone.h"
+#include "Poco/UnicodeConverter.h"
+#include "Poco/Exception.h"
+#include "Poco/UnWindows.h"
+#include <ctime>
+
+
+namespace Poco {
+
+
+int Timezone::utcOffset()
+{
+ TIME_ZONE_INFORMATION tzInfo;
+ /*DWORD dstFlag = */GetTimeZoneInformation(&tzInfo);
+ return -tzInfo.Bias*60;
+}
+
+
+int Timezone::dst()
+{
+ TIME_ZONE_INFORMATION tzInfo;
+ DWORD dstFlag = GetTimeZoneInformation(&tzInfo);
+ return dstFlag == TIME_ZONE_ID_DAYLIGHT ? -tzInfo.DaylightBias*60 : 0;
+}
+
+
+bool Timezone::isDst(const Timestamp& timestamp)
+{
+ std::time_t time = timestamp.epochTime();
+ struct std::tm* tms = std::localtime(&time);
+ if (!tms) throw Poco::SystemException("cannot get local time DST flag");
+ return tms->tm_isdst > 0;
+}
+
+
+std::string Timezone::name()
+{
+ std::string result;
+ TIME_ZONE_INFORMATION tzInfo;
+ DWORD dstFlag = GetTimeZoneInformation(&tzInfo);
+ WCHAR* ptr = dstFlag == TIME_ZONE_ID_DAYLIGHT ? tzInfo.DaylightName : tzInfo.StandardName;
+#if defined(POCO_WIN32_UTF8)
+ UnicodeConverter::toUTF8(ptr, result);
+#else
+ char buffer[256];
+ DWORD rc = WideCharToMultiByte(CP_ACP, 0, ptr, -1, buffer, sizeof(buffer), NULL, NULL);
+ if (rc) result = buffer;
+#endif
+ return result;
+}
+
+
+std::string Timezone::standardName()
+{
+ std::string result;
+ TIME_ZONE_INFORMATION tzInfo;
+ /*DWORD dstFlag =*/ GetTimeZoneInformation(&tzInfo);
+ WCHAR* ptr = tzInfo.StandardName;
+#if defined(POCO_WIN32_UTF8)
+ UnicodeConverter::toUTF8(ptr, result);
+#else
+ char buffer[256];
+ DWORD rc = WideCharToMultiByte(CP_ACP, 0, ptr, -1, buffer, sizeof(buffer), NULL, NULL);
+ if (rc) result = buffer;
+#endif
+ return result;
+}
+
+
+std::string Timezone::dstName()
+{
+ std::string result;
+ TIME_ZONE_INFORMATION tzInfo;
+ /*DWORD dstFlag =*/ GetTimeZoneInformation(&tzInfo);
+ WCHAR* ptr = tzInfo.DaylightName;
+#if defined(POCO_WIN32_UTF8)
+ UnicodeConverter::toUTF8(ptr, result);
+#else
+ char buffer[256];
+ DWORD rc = WideCharToMultiByte(CP_ACP, 0, ptr, -1, buffer, sizeof(buffer), NULL, NULL);
+ if (rc) result = buffer;
+#endif
+ return result;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Timezone_WINCE.cpp b/contrib/libs/poco/Foundation/src/Timezone_WINCE.cpp
index f69ced4f3e..7ae25b0c62 100644
--- a/contrib/libs/poco/Foundation/src/Timezone_WINCE.cpp
+++ b/contrib/libs/poco/Foundation/src/Timezone_WINCE.cpp
@@ -1,92 +1,92 @@
-//
-// Timezone_WINCE.cpp
-//
-// Library: Foundation
-// Package: DateTime
-// Module: Timezone
-//
-// Copyright (c) 2004-2010, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Timezone.h"
-#include "Poco/UnicodeConverter.h"
-#include "Poco/Exception.h"
-#include "Poco/UnWindows.h"
-#include <ctime>
-#if _WIN32_WCE >= 0x800
-#include "time.h"
-#else
-#error #include "wce_time.h"
-#endif
-
-
-namespace Poco {
-
-
-int Timezone::utcOffset()
-{
- TIME_ZONE_INFORMATION tzInfo;
- DWORD dstFlag = GetTimeZoneInformation(&tzInfo);
- return -tzInfo.Bias*60;
-}
-
-
-int Timezone::dst()
-{
- TIME_ZONE_INFORMATION tzInfo;
- DWORD dstFlag = GetTimeZoneInformation(&tzInfo);
- return dstFlag == TIME_ZONE_ID_DAYLIGHT ? -tzInfo.DaylightBias*60 : 0;
-}
-
-
-bool Timezone::isDst(const Timestamp& timestamp)
-{
- std::time_t time = timestamp.epochTime();
-#if _WIN32_WCE >= 0x800
- struct std::tm* tms = localtime(&time);
-#else
- struct std::tm* tms = wceex_localtime(&time);
-#endif
- if (!tms) throw SystemException("cannot get local time DST flag");
- return tms->tm_isdst > 0;
-}
-
-
-std::string Timezone::name()
-{
- std::string result;
- TIME_ZONE_INFORMATION tzInfo;
- DWORD dstFlag = GetTimeZoneInformation(&tzInfo);
- WCHAR* ptr = dstFlag == TIME_ZONE_ID_DAYLIGHT ? tzInfo.DaylightName : tzInfo.StandardName;
- UnicodeConverter::toUTF8(ptr, result);
- return result;
-}
-
-
-std::string Timezone::standardName()
-{
- std::string result;
- TIME_ZONE_INFORMATION tzInfo;
- DWORD dstFlag = GetTimeZoneInformation(&tzInfo);
- WCHAR* ptr = tzInfo.StandardName;
- UnicodeConverter::toUTF8(ptr, result);
- return result;
-}
-
-
-std::string Timezone::dstName()
-{
- std::string result;
- TIME_ZONE_INFORMATION tzInfo;
- DWORD dstFlag = GetTimeZoneInformation(&tzInfo);
- WCHAR* ptr = tzInfo.DaylightName;
- UnicodeConverter::toUTF8(ptr, result);
- return result;
-}
-
-
-} // namespace Poco
+//
+// Timezone_WINCE.cpp
+//
+// Library: Foundation
+// Package: DateTime
+// Module: Timezone
+//
+// Copyright (c) 2004-2010, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Timezone.h"
+#include "Poco/UnicodeConverter.h"
+#include "Poco/Exception.h"
+#include "Poco/UnWindows.h"
+#include <ctime>
+#if _WIN32_WCE >= 0x800
+#include "time.h"
+#else
+#error #include "wce_time.h"
+#endif
+
+
+namespace Poco {
+
+
+int Timezone::utcOffset()
+{
+ TIME_ZONE_INFORMATION tzInfo;
+ DWORD dstFlag = GetTimeZoneInformation(&tzInfo);
+ return -tzInfo.Bias*60;
+}
+
+
+int Timezone::dst()
+{
+ TIME_ZONE_INFORMATION tzInfo;
+ DWORD dstFlag = GetTimeZoneInformation(&tzInfo);
+ return dstFlag == TIME_ZONE_ID_DAYLIGHT ? -tzInfo.DaylightBias*60 : 0;
+}
+
+
+bool Timezone::isDst(const Timestamp& timestamp)
+{
+ std::time_t time = timestamp.epochTime();
+#if _WIN32_WCE >= 0x800
+ struct std::tm* tms = localtime(&time);
+#else
+ struct std::tm* tms = wceex_localtime(&time);
+#endif
+ if (!tms) throw SystemException("cannot get local time DST flag");
+ return tms->tm_isdst > 0;
+}
+
+
+std::string Timezone::name()
+{
+ std::string result;
+ TIME_ZONE_INFORMATION tzInfo;
+ DWORD dstFlag = GetTimeZoneInformation(&tzInfo);
+ WCHAR* ptr = dstFlag == TIME_ZONE_ID_DAYLIGHT ? tzInfo.DaylightName : tzInfo.StandardName;
+ UnicodeConverter::toUTF8(ptr, result);
+ return result;
+}
+
+
+std::string Timezone::standardName()
+{
+ std::string result;
+ TIME_ZONE_INFORMATION tzInfo;
+ DWORD dstFlag = GetTimeZoneInformation(&tzInfo);
+ WCHAR* ptr = tzInfo.StandardName;
+ UnicodeConverter::toUTF8(ptr, result);
+ return result;
+}
+
+
+std::string Timezone::dstName()
+{
+ std::string result;
+ TIME_ZONE_INFORMATION tzInfo;
+ DWORD dstFlag = GetTimeZoneInformation(&tzInfo);
+ WCHAR* ptr = tzInfo.DaylightName;
+ UnicodeConverter::toUTF8(ptr, result);
+ return result;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Token.cpp b/contrib/libs/poco/Foundation/src/Token.cpp
index 088e9a6142..06677d8940 100644
--- a/contrib/libs/poco/Foundation/src/Token.cpp
+++ b/contrib/libs/poco/Foundation/src/Token.cpp
@@ -1,166 +1,166 @@
-//
-// Token.cpp
-//
-// Library: Foundation
-// Package: Streams
-// Module: StringTokenizer
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Token.h"
-#include "Poco/NumberParser.h"
-#include "Poco/Ascii.h"
-
-
-namespace Poco {
-
-
-Token::Token()
-{
-}
-
-
-Token::~Token()
-{
-}
-
-
-bool Token::start(char c, std::istream& /*istr*/)
-{
- _value = c;
- return false;
-}
-
-
-void Token::finish(std::istream& /*istr*/)
-{
-}
-
-
-Token::Class Token::tokenClass() const
-{
- return INVALID_TOKEN;
-}
-
-
-std::string Token::asString() const
-{
- return _value;
-}
-
-
-#if defined(POCO_HAVE_INT64)
-Int64 Token::asInteger64() const
-{
- return NumberParser::parse64(_value);
-}
-
-
-UInt64 Token::asUnsignedInteger64() const
-{
- return NumberParser::parseUnsigned64(_value);
-}
-#endif
-
-
-int Token::asInteger() const
-{
- return NumberParser::parse(_value);
-}
-
-
-unsigned Token::asUnsignedInteger() const
-{
- return NumberParser::parseUnsigned(_value);
-}
-
-
-double Token::asFloat() const
-{
- return NumberParser::parseFloat(_value);
-}
-
-
-char Token::asChar() const
-{
- return _value.empty() ? 0 : _value[0];
-}
-
-
-InvalidToken::InvalidToken()
-{
-}
-
-
-InvalidToken::~InvalidToken()
-{
-}
-
-
-Token::Class InvalidToken::tokenClass() const
-{
- return INVALID_TOKEN;
-}
-
-
-EOFToken::EOFToken()
-{
-}
-
-
-EOFToken::~EOFToken()
-{
-}
-
-
-Token::Class EOFToken::tokenClass() const
-{
- return EOF_TOKEN;
-}
-
-
-WhitespaceToken::WhitespaceToken()
-{
-}
-
-
-WhitespaceToken::~WhitespaceToken()
-{
-}
-
-
-Token::Class WhitespaceToken::tokenClass() const
-{
- return WHITESPACE_TOKEN;
-}
-
-
-bool WhitespaceToken::start(char c, std::istream& /*istr*/)
-{
- if (Ascii::isSpace(c))
- {
- _value = c;
- return true;
- }
- return false;
-}
-
-
-void WhitespaceToken::finish(std::istream& istr)
-{
- int c = istr.peek();
- while (Ascii::isSpace(c))
- {
- istr.get();
- _value += (char) c;
- c = istr.peek();
- }
-}
-
-
-} // namespace Poco
+//
+// Token.cpp
+//
+// Library: Foundation
+// Package: Streams
+// Module: StringTokenizer
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Token.h"
+#include "Poco/NumberParser.h"
+#include "Poco/Ascii.h"
+
+
+namespace Poco {
+
+
+Token::Token()
+{
+}
+
+
+Token::~Token()
+{
+}
+
+
+bool Token::start(char c, std::istream& /*istr*/)
+{
+ _value = c;
+ return false;
+}
+
+
+void Token::finish(std::istream& /*istr*/)
+{
+}
+
+
+Token::Class Token::tokenClass() const
+{
+ return INVALID_TOKEN;
+}
+
+
+std::string Token::asString() const
+{
+ return _value;
+}
+
+
+#if defined(POCO_HAVE_INT64)
+Int64 Token::asInteger64() const
+{
+ return NumberParser::parse64(_value);
+}
+
+
+UInt64 Token::asUnsignedInteger64() const
+{
+ return NumberParser::parseUnsigned64(_value);
+}
+#endif
+
+
+int Token::asInteger() const
+{
+ return NumberParser::parse(_value);
+}
+
+
+unsigned Token::asUnsignedInteger() const
+{
+ return NumberParser::parseUnsigned(_value);
+}
+
+
+double Token::asFloat() const
+{
+ return NumberParser::parseFloat(_value);
+}
+
+
+char Token::asChar() const
+{
+ return _value.empty() ? 0 : _value[0];
+}
+
+
+InvalidToken::InvalidToken()
+{
+}
+
+
+InvalidToken::~InvalidToken()
+{
+}
+
+
+Token::Class InvalidToken::tokenClass() const
+{
+ return INVALID_TOKEN;
+}
+
+
+EOFToken::EOFToken()
+{
+}
+
+
+EOFToken::~EOFToken()
+{
+}
+
+
+Token::Class EOFToken::tokenClass() const
+{
+ return EOF_TOKEN;
+}
+
+
+WhitespaceToken::WhitespaceToken()
+{
+}
+
+
+WhitespaceToken::~WhitespaceToken()
+{
+}
+
+
+Token::Class WhitespaceToken::tokenClass() const
+{
+ return WHITESPACE_TOKEN;
+}
+
+
+bool WhitespaceToken::start(char c, std::istream& /*istr*/)
+{
+ if (Ascii::isSpace(c))
+ {
+ _value = c;
+ return true;
+ }
+ return false;
+}
+
+
+void WhitespaceToken::finish(std::istream& istr)
+{
+ int c = istr.peek();
+ while (Ascii::isSpace(c))
+ {
+ istr.get();
+ _value += (char) c;
+ c = istr.peek();
+ }
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/URI.cpp b/contrib/libs/poco/Foundation/src/URI.cpp
index 3cc6ff702a..b9040583f8 100644
--- a/contrib/libs/poco/Foundation/src/URI.cpp
+++ b/contrib/libs/poco/Foundation/src/URI.cpp
@@ -1,918 +1,918 @@
-//
-// URI.cpp
-//
-// Library: Foundation
-// Package: URI
-// Module: URI
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/URI.h"
-#include "Poco/NumberFormatter.h"
-#include "Poco/Exception.h"
-#include "Poco/String.h"
-#include "Poco/NumberParser.h"
-#include "Poco/Path.h"
-
-
-namespace Poco {
-
-
-const std::string URI::RESERVED_PATH = "?#";
-const std::string URI::RESERVED_QUERY = "?#/:;+@";
-const std::string URI::RESERVED_QUERY_PARAM = "?#/:;+@&=";
-const std::string URI::RESERVED_FRAGMENT = "";
-const std::string URI::ILLEGAL = "%<>{}|\\\"^`!*'()$,[]";
-
-
-URI::URI():
- _port(0)
-{
-}
-
-
-URI::URI(const std::string& uri):
- _port(0)
-{
- parse(uri);
-}
-
-
-URI::URI(const char* uri):
- _port(0)
-{
- parse(std::string(uri));
-}
-
-
-URI::URI(const std::string& scheme, const std::string& pathEtc):
- _scheme(scheme),
- _port(0)
-{
- toLowerInPlace(_scheme);
- _port = getWellKnownPort();
- std::string::const_iterator beg = pathEtc.begin();
- std::string::const_iterator end = pathEtc.end();
- parsePathEtc(beg, end);
-}
-
-
-URI::URI(const std::string& scheme, const std::string& authority, const std::string& pathEtc):
- _scheme(scheme)
-{
- toLowerInPlace(_scheme);
- std::string::const_iterator beg = authority.begin();
- std::string::const_iterator end = authority.end();
- parseAuthority(beg, end);
- beg = pathEtc.begin();
- end = pathEtc.end();
- parsePathEtc(beg, end);
-}
-
-
-URI::URI(const std::string& scheme, const std::string& authority, const std::string& path, const std::string& query):
- _scheme(scheme),
- _path(path),
- _query(query)
-{
- toLowerInPlace(_scheme);
- std::string::const_iterator beg = authority.begin();
- std::string::const_iterator end = authority.end();
- parseAuthority(beg, end);
-}
-
-
-URI::URI(const std::string& scheme, const std::string& authority, const std::string& path, const std::string& query, const std::string& fragment):
- _scheme(scheme),
- _path(path),
- _query(query),
- _fragment(fragment)
-{
- toLowerInPlace(_scheme);
- std::string::const_iterator beg = authority.begin();
- std::string::const_iterator end = authority.end();
- parseAuthority(beg, end);
-}
-
-
-URI::URI(const URI& uri):
- _scheme(uri._scheme),
- _userInfo(uri._userInfo),
- _host(uri._host),
- _port(uri._port),
- _path(uri._path),
- _query(uri._query),
- _fragment(uri._fragment)
-{
-}
-
-
-URI::URI(const URI& baseURI, const std::string& relativeURI):
- _scheme(baseURI._scheme),
- _userInfo(baseURI._userInfo),
- _host(baseURI._host),
- _port(baseURI._port),
- _path(baseURI._path),
- _query(baseURI._query),
- _fragment(baseURI._fragment)
-{
- resolve(relativeURI);
-}
-
-
-URI::URI(const Path& path):
- _scheme("file"),
- _port(0)
-{
- Path absolutePath(path);
- absolutePath.makeAbsolute();
- _path = absolutePath.toString(Path::PATH_UNIX);
-}
-
-
-URI::~URI()
-{
-}
-
-
-URI& URI::operator = (const URI& uri)
-{
- if (&uri != this)
- {
- _scheme = uri._scheme;
- _userInfo = uri._userInfo;
- _host = uri._host;
- _port = uri._port;
- _path = uri._path;
- _query = uri._query;
- _fragment = uri._fragment;
- }
- return *this;
-}
-
-
-URI& URI::operator = (const std::string& uri)
-{
- clear();
- parse(uri);
- return *this;
-}
-
-
-URI& URI::operator = (const char* uri)
-{
- clear();
- parse(std::string(uri));
- return *this;
-}
-
-
-void URI::swap(URI& uri)
-{
- std::swap(_scheme, uri._scheme);
- std::swap(_userInfo, uri._userInfo);
- std::swap(_host, uri._host);
- std::swap(_port, uri._port);
- std::swap(_path, uri._path);
- std::swap(_query, uri._query);
- std::swap(_fragment, uri._fragment);
-}
-
-
-void URI::clear()
-{
- _scheme.clear();
- _userInfo.clear();
- _host.clear();
- _port = 0;
- _path.clear();
- _query.clear();
- _fragment.clear();
-}
-
-
-std::string URI::toString() const
-{
- std::string uri;
- if (isRelative())
- {
- encode(_path, RESERVED_PATH, uri);
- }
- else
- {
- uri = _scheme;
- uri += ':';
- std::string auth = getAuthority();
- if (!auth.empty() || _scheme == "file")
- {
- uri.append("//");
- uri.append(auth);
- }
- if (!_path.empty())
- {
- if (!auth.empty() && _path[0] != '/')
- uri += '/';
- encode(_path, RESERVED_PATH, uri);
- }
- else if (!_query.empty() || !_fragment.empty())
- {
- uri += '/';
- }
- }
- if (!_query.empty())
- {
- uri += '?';
- uri.append(_query);
- }
- if (!_fragment.empty())
- {
- uri += '#';
- encode(_fragment, RESERVED_FRAGMENT, uri);
- }
- return uri;
-}
-
-
-void URI::setScheme(const std::string& scheme)
-{
- _scheme = scheme;
- toLowerInPlace(_scheme);
- if (_port == 0)
- _port = getWellKnownPort();
-}
-
-
-void URI::setUserInfo(const std::string& userInfo)
-{
- _userInfo.clear();
- decode(userInfo, _userInfo);
-}
-
-
-void URI::setHost(const std::string& host)
-{
- _host = host;
-}
-
-
-unsigned short URI::getPort() const
-{
- if (_port == 0)
- return getWellKnownPort();
- else
- return _port;
-}
-
-
-void URI::setPort(unsigned short port)
-{
- _port = port;
-}
-
-
-std::string URI::getAuthority() const
-{
- std::string auth;
- if (!_userInfo.empty())
- {
- auth.append(_userInfo);
- auth += '@';
- }
- if (_host.find(':') != std::string::npos)
- {
- auth += '[';
- auth += _host;
- auth += ']';
- }
- else auth.append(_host);
- if (_port && !isWellKnownPort())
- {
- auth += ':';
- NumberFormatter::append(auth, _port);
- }
- return auth;
-}
-
-
-void URI::setAuthority(const std::string& authority)
-{
- _userInfo.clear();
- _host.clear();
- _port = 0;
- std::string::const_iterator beg = authority.begin();
- std::string::const_iterator end = authority.end();
- parseAuthority(beg, end);
-}
-
-
-void URI::setPath(const std::string& path)
-{
- _path.clear();
- decode(path, _path);
-}
-
-
-void URI::setRawQuery(const std::string& query)
-{
- _query = query;
-}
-
-
-void URI::setQuery(const std::string& query)
-{
- _query.clear();
- encode(query, RESERVED_QUERY, _query);
-}
-
-
-void URI::addQueryParameter(const std::string& param, const std::string& val)
-{
- if (!_query.empty()) _query += '&';
- encode(param, RESERVED_QUERY_PARAM, _query);
- _query += '=';
- encode(val, RESERVED_QUERY_PARAM, _query);
-}
-
-
-std::string URI::getQuery() const
-{
- std::string query;
- decode(_query, query);
- return query;
-}
-
-
-URI::QueryParameters URI::getQueryParameters() const
-{
- QueryParameters result;
- std::string::const_iterator it(_query.begin());
- std::string::const_iterator end(_query.end());
- while (it != end)
- {
- std::string name;
- std::string value;
- while (it != end && *it != '=' && *it != '&')
- {
- if (*it == '+')
- name += ' ';
- else
- name += *it;
- ++it;
- }
- if (it != end && *it == '=')
- {
- ++it;
- while (it != end && *it != '&')
- {
- if (*it == '+')
- value += ' ';
- else
- value += *it;
- ++it;
- }
- }
- std::string decodedName;
- std::string decodedValue;
- URI::decode(name, decodedName);
- URI::decode(value, decodedValue);
- result.push_back(std::make_pair(decodedName, decodedValue));
- if (it != end && *it == '&') ++it;
- }
- return result;
-}
-
-
-void URI::setQueryParameters(const QueryParameters& params)
-{
- _query.clear();
- for (QueryParameters::const_iterator it = params.begin(); it != params.end(); ++it)
- {
- addQueryParameter(it->first, it->second);
- }
-}
-
-
-void URI::setFragment(const std::string& fragment)
-{
- _fragment.clear();
- decode(fragment, _fragment);
-}
-
-
-void URI::setPathEtc(const std::string& pathEtc)
-{
- _path.clear();
- _query.clear();
- _fragment.clear();
- std::string::const_iterator beg = pathEtc.begin();
- std::string::const_iterator end = pathEtc.end();
- parsePathEtc(beg, end);
-}
-
-
-std::string URI::getPathEtc() const
-{
- std::string pathEtc;
- encode(_path, RESERVED_PATH, pathEtc);
- if (!_query.empty())
- {
- pathEtc += '?';
- pathEtc += _query;
- }
- if (!_fragment.empty())
- {
- pathEtc += '#';
- encode(_fragment, RESERVED_FRAGMENT, pathEtc);
- }
- return pathEtc;
-}
-
-
-std::string URI::getPathAndQuery() const
-{
- std::string pathAndQuery;
- encode(_path, RESERVED_PATH, pathAndQuery);
- if (!_query.empty())
- {
- pathAndQuery += '?';
- pathAndQuery += _query;
- }
- return pathAndQuery;
-}
-
-
-void URI::resolve(const std::string& relativeURI)
-{
- URI parsedURI(relativeURI);
- resolve(parsedURI);
-}
-
-
-void URI::resolve(const URI& relativeURI)
-{
- if (!relativeURI._scheme.empty())
- {
- _scheme = relativeURI._scheme;
- _userInfo = relativeURI._userInfo;
- _host = relativeURI._host;
- _port = relativeURI._port;
- _path = relativeURI._path;
- _query = relativeURI._query;
- removeDotSegments();
- }
- else
- {
- if (!relativeURI._host.empty())
- {
- _userInfo = relativeURI._userInfo;
- _host = relativeURI._host;
- _port = relativeURI._port;
- _path = relativeURI._path;
- _query = relativeURI._query;
- removeDotSegments();
- }
- else
- {
- if (relativeURI._path.empty())
- {
- if (!relativeURI._query.empty())
- _query = relativeURI._query;
- }
- else
- {
- if (relativeURI._path[0] == '/')
- {
- _path = relativeURI._path;
- removeDotSegments();
- }
- else
- {
- mergePath(relativeURI._path);
- }
- _query = relativeURI._query;
- }
- }
- }
- _fragment = relativeURI._fragment;
-}
-
-
-bool URI::isRelative() const
-{
- return _scheme.empty();
-}
-
-
-bool URI::empty() const
-{
- return _scheme.empty() && _host.empty() && _path.empty() && _query.empty() && _fragment.empty();
-}
-
-
-bool URI::operator == (const URI& uri) const
-{
- return equals(uri);
-}
-
-
-bool URI::operator == (const std::string& uri) const
-{
- URI parsedURI(uri);
- return equals(parsedURI);
-}
-
-
-bool URI::operator != (const URI& uri) const
-{
- return !equals(uri);
-}
-
-
-bool URI::operator != (const std::string& uri) const
-{
- URI parsedURI(uri);
- return !equals(parsedURI);
-}
-
-
-bool URI::equals(const URI& uri) const
-{
- return _scheme == uri._scheme
- && _userInfo == uri._userInfo
- && _host == uri._host
- && getPort() == uri.getPort()
- && _path == uri._path
- && _query == uri._query
- && _fragment == uri._fragment;
-}
-
-
-void URI::normalize()
-{
- removeDotSegments(!isRelative());
-}
-
-
-void URI::removeDotSegments(bool removeLeading)
-{
- if (_path.empty()) return;
-
- bool leadingSlash = *(_path.begin()) == '/';
- bool trailingSlash = *(_path.rbegin()) == '/';
- std::vector<std::string> segments;
- std::vector<std::string> normalizedSegments;
- getPathSegments(segments);
- for (std::vector<std::string>::const_iterator it = segments.begin(); it != segments.end(); ++it)
- {
- if (*it == "..")
- {
- if (!normalizedSegments.empty())
- {
- if (normalizedSegments.back() == "..")
- normalizedSegments.push_back(*it);
- else
- normalizedSegments.pop_back();
- }
- else if (!removeLeading)
- {
- normalizedSegments.push_back(*it);
- }
- }
- else if (*it != ".")
- {
- normalizedSegments.push_back(*it);
- }
- }
- buildPath(normalizedSegments, leadingSlash, trailingSlash);
-}
-
-
-void URI::getPathSegments(std::vector<std::string>& segments)
-{
- getPathSegments(_path, segments);
-}
-
-
-void URI::getPathSegments(const std::string& path, std::vector<std::string>& segments)
-{
- std::string::const_iterator it = path.begin();
- std::string::const_iterator end = path.end();
- std::string seg;
- while (it != end)
- {
- if (*it == '/')
- {
- if (!seg.empty())
- {
- segments.push_back(seg);
- seg.clear();
- }
- }
- else seg += *it;
- ++it;
- }
- if (!seg.empty())
- segments.push_back(seg);
-}
-
-
-void URI::encode(const std::string& str, const std::string& reserved, std::string& encodedStr)
-{
- for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)
- {
- char c = *it;
- if ((c >= 'a' && c <= 'z') ||
- (c >= 'A' && c <= 'Z') ||
- (c >= '0' && c <= '9') ||
- c == '-' || c == '_' ||
- c == '.' || c == '~')
- {
- encodedStr += c;
- }
- else if (c <= 0x20 || c >= 0x7F || ILLEGAL.find(c) != std::string::npos || reserved.find(c) != std::string::npos)
- {
- encodedStr += '%';
- encodedStr += NumberFormatter::formatHex((unsigned) (unsigned char) c, 2);
- }
- else encodedStr += c;
- }
-}
-
-
-void URI::decode(const std::string& str, std::string& decodedStr, bool plusAsSpace)
-{
- bool inQuery = false;
- std::string::const_iterator it = str.begin();
- std::string::const_iterator end = str.end();
- while (it != end)
- {
- char c = *it++;
- if (c == '?') inQuery = true;
- // spaces may be encoded as plus signs in the query
- if (inQuery && plusAsSpace && c == '+') c = ' ';
- else if (c == '%')
- {
- if (it == end) throw URISyntaxException("URI encoding: no hex digit following percent sign", str);
- char hi = *it++;
- if (it == end) throw URISyntaxException("URI encoding: two hex digits must follow percent sign", str);
- char lo = *it++;
- if (hi >= '0' && hi <= '9')
- c = hi - '0';
- else if (hi >= 'A' && hi <= 'F')
- c = hi - 'A' + 10;
- else if (hi >= 'a' && hi <= 'f')
- c = hi - 'a' + 10;
- else throw URISyntaxException("URI encoding: not a hex digit");
- c *= 16;
- if (lo >= '0' && lo <= '9')
- c += lo - '0';
- else if (lo >= 'A' && lo <= 'F')
- c += lo - 'A' + 10;
- else if (lo >= 'a' && lo <= 'f')
- c += lo - 'a' + 10;
- else throw URISyntaxException("URI encoding: not a hex digit");
- }
- decodedStr += c;
- }
-}
-
-
-bool URI::isWellKnownPort() const
-{
- return _port == getWellKnownPort();
-}
-
-
-unsigned short URI::getWellKnownPort() const
-{
- if (_scheme == "ftp")
- return 21;
- else if (_scheme == "ssh")
- return 22;
- else if (_scheme == "telnet")
- return 23;
- else if (_scheme == "http" || _scheme == "ws")
- return 80;
- else if (_scheme == "nntp")
- return 119;
- else if (_scheme == "ldap")
- return 389;
- else if (_scheme == "https" || _scheme == "wss")
- return 443;
- else if (_scheme == "rtsp")
- return 554;
- else if (_scheme == "sip")
- return 5060;
- else if (_scheme == "sips")
- return 5061;
- else if (_scheme == "xmpp")
- return 5222;
- else
- return 0;
-}
-
-
-void URI::parse(const std::string& uri)
-{
- std::for_each(uri.begin(), uri.end(), [] (char ch) {
- if (static_cast<signed char>(ch) <= 32 || ch == '\x7F')
- throw URISyntaxException("URI contains invalid characters");
- });
-
- std::string::const_iterator it = uri.begin();
- std::string::const_iterator end = uri.end();
- if (it == end) return;
- if (*it != '/' && *it != '.' && *it != '?' && *it != '#')
- {
- std::string scheme;
- while (it != end && *it != ':' && *it != '?' && *it != '#' && *it != '/') scheme += *it++;
- if (it != end && *it == ':')
- {
- ++it;
- if (it == end) throw URISyntaxException("URI scheme must be followed by authority or path", uri);
- setScheme(scheme);
- if (*it == '/')
- {
- ++it;
- if (it != end && *it == '/')
- {
- ++it;
- parseAuthority(it, end);
- }
- else --it;
- }
- parsePathEtc(it, end);
- }
+//
+// URI.cpp
+//
+// Library: Foundation
+// Package: URI
+// Module: URI
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/URI.h"
+#include "Poco/NumberFormatter.h"
+#include "Poco/Exception.h"
+#include "Poco/String.h"
+#include "Poco/NumberParser.h"
+#include "Poco/Path.h"
+
+
+namespace Poco {
+
+
+const std::string URI::RESERVED_PATH = "?#";
+const std::string URI::RESERVED_QUERY = "?#/:;+@";
+const std::string URI::RESERVED_QUERY_PARAM = "?#/:;+@&=";
+const std::string URI::RESERVED_FRAGMENT = "";
+const std::string URI::ILLEGAL = "%<>{}|\\\"^`!*'()$,[]";
+
+
+URI::URI():
+ _port(0)
+{
+}
+
+
+URI::URI(const std::string& uri):
+ _port(0)
+{
+ parse(uri);
+}
+
+
+URI::URI(const char* uri):
+ _port(0)
+{
+ parse(std::string(uri));
+}
+
+
+URI::URI(const std::string& scheme, const std::string& pathEtc):
+ _scheme(scheme),
+ _port(0)
+{
+ toLowerInPlace(_scheme);
+ _port = getWellKnownPort();
+ std::string::const_iterator beg = pathEtc.begin();
+ std::string::const_iterator end = pathEtc.end();
+ parsePathEtc(beg, end);
+}
+
+
+URI::URI(const std::string& scheme, const std::string& authority, const std::string& pathEtc):
+ _scheme(scheme)
+{
+ toLowerInPlace(_scheme);
+ std::string::const_iterator beg = authority.begin();
+ std::string::const_iterator end = authority.end();
+ parseAuthority(beg, end);
+ beg = pathEtc.begin();
+ end = pathEtc.end();
+ parsePathEtc(beg, end);
+}
+
+
+URI::URI(const std::string& scheme, const std::string& authority, const std::string& path, const std::string& query):
+ _scheme(scheme),
+ _path(path),
+ _query(query)
+{
+ toLowerInPlace(_scheme);
+ std::string::const_iterator beg = authority.begin();
+ std::string::const_iterator end = authority.end();
+ parseAuthority(beg, end);
+}
+
+
+URI::URI(const std::string& scheme, const std::string& authority, const std::string& path, const std::string& query, const std::string& fragment):
+ _scheme(scheme),
+ _path(path),
+ _query(query),
+ _fragment(fragment)
+{
+ toLowerInPlace(_scheme);
+ std::string::const_iterator beg = authority.begin();
+ std::string::const_iterator end = authority.end();
+ parseAuthority(beg, end);
+}
+
+
+URI::URI(const URI& uri):
+ _scheme(uri._scheme),
+ _userInfo(uri._userInfo),
+ _host(uri._host),
+ _port(uri._port),
+ _path(uri._path),
+ _query(uri._query),
+ _fragment(uri._fragment)
+{
+}
+
+
+URI::URI(const URI& baseURI, const std::string& relativeURI):
+ _scheme(baseURI._scheme),
+ _userInfo(baseURI._userInfo),
+ _host(baseURI._host),
+ _port(baseURI._port),
+ _path(baseURI._path),
+ _query(baseURI._query),
+ _fragment(baseURI._fragment)
+{
+ resolve(relativeURI);
+}
+
+
+URI::URI(const Path& path):
+ _scheme("file"),
+ _port(0)
+{
+ Path absolutePath(path);
+ absolutePath.makeAbsolute();
+ _path = absolutePath.toString(Path::PATH_UNIX);
+}
+
+
+URI::~URI()
+{
+}
+
+
+URI& URI::operator = (const URI& uri)
+{
+ if (&uri != this)
+ {
+ _scheme = uri._scheme;
+ _userInfo = uri._userInfo;
+ _host = uri._host;
+ _port = uri._port;
+ _path = uri._path;
+ _query = uri._query;
+ _fragment = uri._fragment;
+ }
+ return *this;
+}
+
+
+URI& URI::operator = (const std::string& uri)
+{
+ clear();
+ parse(uri);
+ return *this;
+}
+
+
+URI& URI::operator = (const char* uri)
+{
+ clear();
+ parse(std::string(uri));
+ return *this;
+}
+
+
+void URI::swap(URI& uri)
+{
+ std::swap(_scheme, uri._scheme);
+ std::swap(_userInfo, uri._userInfo);
+ std::swap(_host, uri._host);
+ std::swap(_port, uri._port);
+ std::swap(_path, uri._path);
+ std::swap(_query, uri._query);
+ std::swap(_fragment, uri._fragment);
+}
+
+
+void URI::clear()
+{
+ _scheme.clear();
+ _userInfo.clear();
+ _host.clear();
+ _port = 0;
+ _path.clear();
+ _query.clear();
+ _fragment.clear();
+}
+
+
+std::string URI::toString() const
+{
+ std::string uri;
+ if (isRelative())
+ {
+ encode(_path, RESERVED_PATH, uri);
+ }
+ else
+ {
+ uri = _scheme;
+ uri += ':';
+ std::string auth = getAuthority();
+ if (!auth.empty() || _scheme == "file")
+ {
+ uri.append("//");
+ uri.append(auth);
+ }
+ if (!_path.empty())
+ {
+ if (!auth.empty() && _path[0] != '/')
+ uri += '/';
+ encode(_path, RESERVED_PATH, uri);
+ }
+ else if (!_query.empty() || !_fragment.empty())
+ {
+ uri += '/';
+ }
+ }
+ if (!_query.empty())
+ {
+ uri += '?';
+ uri.append(_query);
+ }
+ if (!_fragment.empty())
+ {
+ uri += '#';
+ encode(_fragment, RESERVED_FRAGMENT, uri);
+ }
+ return uri;
+}
+
+
+void URI::setScheme(const std::string& scheme)
+{
+ _scheme = scheme;
+ toLowerInPlace(_scheme);
+ if (_port == 0)
+ _port = getWellKnownPort();
+}
+
+
+void URI::setUserInfo(const std::string& userInfo)
+{
+ _userInfo.clear();
+ decode(userInfo, _userInfo);
+}
+
+
+void URI::setHost(const std::string& host)
+{
+ _host = host;
+}
+
+
+unsigned short URI::getPort() const
+{
+ if (_port == 0)
+ return getWellKnownPort();
+ else
+ return _port;
+}
+
+
+void URI::setPort(unsigned short port)
+{
+ _port = port;
+}
+
+
+std::string URI::getAuthority() const
+{
+ std::string auth;
+ if (!_userInfo.empty())
+ {
+ auth.append(_userInfo);
+ auth += '@';
+ }
+ if (_host.find(':') != std::string::npos)
+ {
+ auth += '[';
+ auth += _host;
+ auth += ']';
+ }
+ else auth.append(_host);
+ if (_port && !isWellKnownPort())
+ {
+ auth += ':';
+ NumberFormatter::append(auth, _port);
+ }
+ return auth;
+}
+
+
+void URI::setAuthority(const std::string& authority)
+{
+ _userInfo.clear();
+ _host.clear();
+ _port = 0;
+ std::string::const_iterator beg = authority.begin();
+ std::string::const_iterator end = authority.end();
+ parseAuthority(beg, end);
+}
+
+
+void URI::setPath(const std::string& path)
+{
+ _path.clear();
+ decode(path, _path);
+}
+
+
+void URI::setRawQuery(const std::string& query)
+{
+ _query = query;
+}
+
+
+void URI::setQuery(const std::string& query)
+{
+ _query.clear();
+ encode(query, RESERVED_QUERY, _query);
+}
+
+
+void URI::addQueryParameter(const std::string& param, const std::string& val)
+{
+ if (!_query.empty()) _query += '&';
+ encode(param, RESERVED_QUERY_PARAM, _query);
+ _query += '=';
+ encode(val, RESERVED_QUERY_PARAM, _query);
+}
+
+
+std::string URI::getQuery() const
+{
+ std::string query;
+ decode(_query, query);
+ return query;
+}
+
+
+URI::QueryParameters URI::getQueryParameters() const
+{
+ QueryParameters result;
+ std::string::const_iterator it(_query.begin());
+ std::string::const_iterator end(_query.end());
+ while (it != end)
+ {
+ std::string name;
+ std::string value;
+ while (it != end && *it != '=' && *it != '&')
+ {
+ if (*it == '+')
+ name += ' ';
+ else
+ name += *it;
+ ++it;
+ }
+ if (it != end && *it == '=')
+ {
+ ++it;
+ while (it != end && *it != '&')
+ {
+ if (*it == '+')
+ value += ' ';
+ else
+ value += *it;
+ ++it;
+ }
+ }
+ std::string decodedName;
+ std::string decodedValue;
+ URI::decode(name, decodedName);
+ URI::decode(value, decodedValue);
+ result.push_back(std::make_pair(decodedName, decodedValue));
+ if (it != end && *it == '&') ++it;
+ }
+ return result;
+}
+
+
+void URI::setQueryParameters(const QueryParameters& params)
+{
+ _query.clear();
+ for (QueryParameters::const_iterator it = params.begin(); it != params.end(); ++it)
+ {
+ addQueryParameter(it->first, it->second);
+ }
+}
+
+
+void URI::setFragment(const std::string& fragment)
+{
+ _fragment.clear();
+ decode(fragment, _fragment);
+}
+
+
+void URI::setPathEtc(const std::string& pathEtc)
+{
+ _path.clear();
+ _query.clear();
+ _fragment.clear();
+ std::string::const_iterator beg = pathEtc.begin();
+ std::string::const_iterator end = pathEtc.end();
+ parsePathEtc(beg, end);
+}
+
+
+std::string URI::getPathEtc() const
+{
+ std::string pathEtc;
+ encode(_path, RESERVED_PATH, pathEtc);
+ if (!_query.empty())
+ {
+ pathEtc += '?';
+ pathEtc += _query;
+ }
+ if (!_fragment.empty())
+ {
+ pathEtc += '#';
+ encode(_fragment, RESERVED_FRAGMENT, pathEtc);
+ }
+ return pathEtc;
+}
+
+
+std::string URI::getPathAndQuery() const
+{
+ std::string pathAndQuery;
+ encode(_path, RESERVED_PATH, pathAndQuery);
+ if (!_query.empty())
+ {
+ pathAndQuery += '?';
+ pathAndQuery += _query;
+ }
+ return pathAndQuery;
+}
+
+
+void URI::resolve(const std::string& relativeURI)
+{
+ URI parsedURI(relativeURI);
+ resolve(parsedURI);
+}
+
+
+void URI::resolve(const URI& relativeURI)
+{
+ if (!relativeURI._scheme.empty())
+ {
+ _scheme = relativeURI._scheme;
+ _userInfo = relativeURI._userInfo;
+ _host = relativeURI._host;
+ _port = relativeURI._port;
+ _path = relativeURI._path;
+ _query = relativeURI._query;
+ removeDotSegments();
+ }
+ else
+ {
+ if (!relativeURI._host.empty())
+ {
+ _userInfo = relativeURI._userInfo;
+ _host = relativeURI._host;
+ _port = relativeURI._port;
+ _path = relativeURI._path;
+ _query = relativeURI._query;
+ removeDotSegments();
+ }
else
- {
- it = uri.begin();
- parsePathEtc(it, end);
- }
- }
- else parsePathEtc(it, end);
-}
-
-
-void URI::parseAuthority(std::string::const_iterator& it, const std::string::const_iterator& end)
-{
- std::string userInfo;
- std::string part;
- while (it != end && *it != '/' && *it != '?' && *it != '#')
- {
- if (*it == '@')
- {
- userInfo = part;
- part.clear();
- }
- else part += *it;
- ++it;
- }
- std::string::const_iterator pbeg = part.begin();
- std::string::const_iterator pend = part.end();
- parseHostAndPort(pbeg, pend);
- _userInfo = userInfo;
-}
-
-
-void URI::parseHostAndPort(std::string::const_iterator& it, const std::string::const_iterator& end)
-{
- if (it == end) return;
- std::string host;
- if (*it == '[')
- {
- // IPv6 address
- ++it;
- while (it != end && *it != ']') host += *it++;
- if (it == end) throw URISyntaxException("unterminated IPv6 address");
- ++it;
- }
- else
- {
- while (it != end && *it != ':') host += *it++;
- }
- if (it != end && *it == ':')
- {
- ++it;
- std::string port;
- while (it != end) port += *it++;
- if (!port.empty())
- {
- int nport = 0;
- if (NumberParser::tryParse(port, nport) && nport > 0 && nport < 65536)
- _port = (unsigned short) nport;
- else
- throw URISyntaxException("bad or invalid port number", port);
- }
- else _port = getWellKnownPort();
- }
- else _port = getWellKnownPort();
- _host = host;
- toLowerInPlace(_host);
-}
-
-
-void URI::parsePath(std::string::const_iterator& it, const std::string::const_iterator& end)
-{
- std::string path;
- while (it != end && *it != '?' && *it != '#') path += *it++;
- decode(path, _path);
-}
-
-
-void URI::parsePathEtc(std::string::const_iterator& it, const std::string::const_iterator& end)
-{
- if (it == end) return;
- if (*it != '?' && *it != '#')
- parsePath(it, end);
- if (it != end && *it == '?')
- {
- ++it;
- parseQuery(it, end);
- }
- if (it != end && *it == '#')
- {
- ++it;
- parseFragment(it, end);
- }
-}
-
-
-void URI::parseQuery(std::string::const_iterator& it, const std::string::const_iterator& end)
-{
- _query.clear();
- while (it != end && *it != '#') _query += *it++;
-}
-
-
-void URI::parseFragment(std::string::const_iterator& it, const std::string::const_iterator& end)
-{
- std::string fragment;
- while (it != end) fragment += *it++;
- decode(fragment, _fragment);
-}
-
-
-void URI::mergePath(const std::string& path)
-{
- std::vector<std::string> segments;
- std::vector<std::string> normalizedSegments;
- bool addLeadingSlash = false;
- if (!_path.empty())
- {
- getPathSegments(segments);
- bool endsWithSlash = *(_path.rbegin()) == '/';
- if (!endsWithSlash && !segments.empty())
- segments.pop_back();
- addLeadingSlash = _path[0] == '/';
- }
- getPathSegments(path, segments);
- addLeadingSlash = addLeadingSlash || (!path.empty() && path[0] == '/');
- bool hasTrailingSlash = (!path.empty() && *(path.rbegin()) == '/');
- bool addTrailingSlash = false;
- for (std::vector<std::string>::const_iterator it = segments.begin(); it != segments.end(); ++it)
- {
- if (*it == "..")
- {
- addTrailingSlash = true;
- if (!normalizedSegments.empty())
- normalizedSegments.pop_back();
- }
- else if (*it != ".")
- {
- addTrailingSlash = false;
- normalizedSegments.push_back(*it);
- }
- else addTrailingSlash = true;
- }
- buildPath(normalizedSegments, addLeadingSlash, hasTrailingSlash || addTrailingSlash);
-}
-
-
-void URI::buildPath(const std::vector<std::string>& segments, bool leadingSlash, bool trailingSlash)
-{
- _path.clear();
- bool first = true;
- for (std::vector<std::string>::const_iterator it = segments.begin(); it != segments.end(); ++it)
- {
- if (first)
- {
- first = false;
- if (leadingSlash)
- _path += '/';
- else if (_scheme.empty() && (*it).find(':') != std::string::npos)
- _path.append("./");
- }
- else _path += '/';
- _path.append(*it);
- }
- if (trailingSlash)
- _path += '/';
-}
-
-
-} // namespace Poco
+ {
+ if (relativeURI._path.empty())
+ {
+ if (!relativeURI._query.empty())
+ _query = relativeURI._query;
+ }
+ else
+ {
+ if (relativeURI._path[0] == '/')
+ {
+ _path = relativeURI._path;
+ removeDotSegments();
+ }
+ else
+ {
+ mergePath(relativeURI._path);
+ }
+ _query = relativeURI._query;
+ }
+ }
+ }
+ _fragment = relativeURI._fragment;
+}
+
+
+bool URI::isRelative() const
+{
+ return _scheme.empty();
+}
+
+
+bool URI::empty() const
+{
+ return _scheme.empty() && _host.empty() && _path.empty() && _query.empty() && _fragment.empty();
+}
+
+
+bool URI::operator == (const URI& uri) const
+{
+ return equals(uri);
+}
+
+
+bool URI::operator == (const std::string& uri) const
+{
+ URI parsedURI(uri);
+ return equals(parsedURI);
+}
+
+
+bool URI::operator != (const URI& uri) const
+{
+ return !equals(uri);
+}
+
+
+bool URI::operator != (const std::string& uri) const
+{
+ URI parsedURI(uri);
+ return !equals(parsedURI);
+}
+
+
+bool URI::equals(const URI& uri) const
+{
+ return _scheme == uri._scheme
+ && _userInfo == uri._userInfo
+ && _host == uri._host
+ && getPort() == uri.getPort()
+ && _path == uri._path
+ && _query == uri._query
+ && _fragment == uri._fragment;
+}
+
+
+void URI::normalize()
+{
+ removeDotSegments(!isRelative());
+}
+
+
+void URI::removeDotSegments(bool removeLeading)
+{
+ if (_path.empty()) return;
+
+ bool leadingSlash = *(_path.begin()) == '/';
+ bool trailingSlash = *(_path.rbegin()) == '/';
+ std::vector<std::string> segments;
+ std::vector<std::string> normalizedSegments;
+ getPathSegments(segments);
+ for (std::vector<std::string>::const_iterator it = segments.begin(); it != segments.end(); ++it)
+ {
+ if (*it == "..")
+ {
+ if (!normalizedSegments.empty())
+ {
+ if (normalizedSegments.back() == "..")
+ normalizedSegments.push_back(*it);
+ else
+ normalizedSegments.pop_back();
+ }
+ else if (!removeLeading)
+ {
+ normalizedSegments.push_back(*it);
+ }
+ }
+ else if (*it != ".")
+ {
+ normalizedSegments.push_back(*it);
+ }
+ }
+ buildPath(normalizedSegments, leadingSlash, trailingSlash);
+}
+
+
+void URI::getPathSegments(std::vector<std::string>& segments)
+{
+ getPathSegments(_path, segments);
+}
+
+
+void URI::getPathSegments(const std::string& path, std::vector<std::string>& segments)
+{
+ std::string::const_iterator it = path.begin();
+ std::string::const_iterator end = path.end();
+ std::string seg;
+ while (it != end)
+ {
+ if (*it == '/')
+ {
+ if (!seg.empty())
+ {
+ segments.push_back(seg);
+ seg.clear();
+ }
+ }
+ else seg += *it;
+ ++it;
+ }
+ if (!seg.empty())
+ segments.push_back(seg);
+}
+
+
+void URI::encode(const std::string& str, const std::string& reserved, std::string& encodedStr)
+{
+ for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)
+ {
+ char c = *it;
+ if ((c >= 'a' && c <= 'z') ||
+ (c >= 'A' && c <= 'Z') ||
+ (c >= '0' && c <= '9') ||
+ c == '-' || c == '_' ||
+ c == '.' || c == '~')
+ {
+ encodedStr += c;
+ }
+ else if (c <= 0x20 || c >= 0x7F || ILLEGAL.find(c) != std::string::npos || reserved.find(c) != std::string::npos)
+ {
+ encodedStr += '%';
+ encodedStr += NumberFormatter::formatHex((unsigned) (unsigned char) c, 2);
+ }
+ else encodedStr += c;
+ }
+}
+
+
+void URI::decode(const std::string& str, std::string& decodedStr, bool plusAsSpace)
+{
+ bool inQuery = false;
+ std::string::const_iterator it = str.begin();
+ std::string::const_iterator end = str.end();
+ while (it != end)
+ {
+ char c = *it++;
+ if (c == '?') inQuery = true;
+ // spaces may be encoded as plus signs in the query
+ if (inQuery && plusAsSpace && c == '+') c = ' ';
+ else if (c == '%')
+ {
+ if (it == end) throw URISyntaxException("URI encoding: no hex digit following percent sign", str);
+ char hi = *it++;
+ if (it == end) throw URISyntaxException("URI encoding: two hex digits must follow percent sign", str);
+ char lo = *it++;
+ if (hi >= '0' && hi <= '9')
+ c = hi - '0';
+ else if (hi >= 'A' && hi <= 'F')
+ c = hi - 'A' + 10;
+ else if (hi >= 'a' && hi <= 'f')
+ c = hi - 'a' + 10;
+ else throw URISyntaxException("URI encoding: not a hex digit");
+ c *= 16;
+ if (lo >= '0' && lo <= '9')
+ c += lo - '0';
+ else if (lo >= 'A' && lo <= 'F')
+ c += lo - 'A' + 10;
+ else if (lo >= 'a' && lo <= 'f')
+ c += lo - 'a' + 10;
+ else throw URISyntaxException("URI encoding: not a hex digit");
+ }
+ decodedStr += c;
+ }
+}
+
+
+bool URI::isWellKnownPort() const
+{
+ return _port == getWellKnownPort();
+}
+
+
+unsigned short URI::getWellKnownPort() const
+{
+ if (_scheme == "ftp")
+ return 21;
+ else if (_scheme == "ssh")
+ return 22;
+ else if (_scheme == "telnet")
+ return 23;
+ else if (_scheme == "http" || _scheme == "ws")
+ return 80;
+ else if (_scheme == "nntp")
+ return 119;
+ else if (_scheme == "ldap")
+ return 389;
+ else if (_scheme == "https" || _scheme == "wss")
+ return 443;
+ else if (_scheme == "rtsp")
+ return 554;
+ else if (_scheme == "sip")
+ return 5060;
+ else if (_scheme == "sips")
+ return 5061;
+ else if (_scheme == "xmpp")
+ return 5222;
+ else
+ return 0;
+}
+
+
+void URI::parse(const std::string& uri)
+{
+ std::for_each(uri.begin(), uri.end(), [] (char ch) {
+ if (static_cast<signed char>(ch) <= 32 || ch == '\x7F')
+ throw URISyntaxException("URI contains invalid characters");
+ });
+
+ std::string::const_iterator it = uri.begin();
+ std::string::const_iterator end = uri.end();
+ if (it == end) return;
+ if (*it != '/' && *it != '.' && *it != '?' && *it != '#')
+ {
+ std::string scheme;
+ while (it != end && *it != ':' && *it != '?' && *it != '#' && *it != '/') scheme += *it++;
+ if (it != end && *it == ':')
+ {
+ ++it;
+ if (it == end) throw URISyntaxException("URI scheme must be followed by authority or path", uri);
+ setScheme(scheme);
+ if (*it == '/')
+ {
+ ++it;
+ if (it != end && *it == '/')
+ {
+ ++it;
+ parseAuthority(it, end);
+ }
+ else --it;
+ }
+ parsePathEtc(it, end);
+ }
+ else
+ {
+ it = uri.begin();
+ parsePathEtc(it, end);
+ }
+ }
+ else parsePathEtc(it, end);
+}
+
+
+void URI::parseAuthority(std::string::const_iterator& it, const std::string::const_iterator& end)
+{
+ std::string userInfo;
+ std::string part;
+ while (it != end && *it != '/' && *it != '?' && *it != '#')
+ {
+ if (*it == '@')
+ {
+ userInfo = part;
+ part.clear();
+ }
+ else part += *it;
+ ++it;
+ }
+ std::string::const_iterator pbeg = part.begin();
+ std::string::const_iterator pend = part.end();
+ parseHostAndPort(pbeg, pend);
+ _userInfo = userInfo;
+}
+
+
+void URI::parseHostAndPort(std::string::const_iterator& it, const std::string::const_iterator& end)
+{
+ if (it == end) return;
+ std::string host;
+ if (*it == '[')
+ {
+ // IPv6 address
+ ++it;
+ while (it != end && *it != ']') host += *it++;
+ if (it == end) throw URISyntaxException("unterminated IPv6 address");
+ ++it;
+ }
+ else
+ {
+ while (it != end && *it != ':') host += *it++;
+ }
+ if (it != end && *it == ':')
+ {
+ ++it;
+ std::string port;
+ while (it != end) port += *it++;
+ if (!port.empty())
+ {
+ int nport = 0;
+ if (NumberParser::tryParse(port, nport) && nport > 0 && nport < 65536)
+ _port = (unsigned short) nport;
+ else
+ throw URISyntaxException("bad or invalid port number", port);
+ }
+ else _port = getWellKnownPort();
+ }
+ else _port = getWellKnownPort();
+ _host = host;
+ toLowerInPlace(_host);
+}
+
+
+void URI::parsePath(std::string::const_iterator& it, const std::string::const_iterator& end)
+{
+ std::string path;
+ while (it != end && *it != '?' && *it != '#') path += *it++;
+ decode(path, _path);
+}
+
+
+void URI::parsePathEtc(std::string::const_iterator& it, const std::string::const_iterator& end)
+{
+ if (it == end) return;
+ if (*it != '?' && *it != '#')
+ parsePath(it, end);
+ if (it != end && *it == '?')
+ {
+ ++it;
+ parseQuery(it, end);
+ }
+ if (it != end && *it == '#')
+ {
+ ++it;
+ parseFragment(it, end);
+ }
+}
+
+
+void URI::parseQuery(std::string::const_iterator& it, const std::string::const_iterator& end)
+{
+ _query.clear();
+ while (it != end && *it != '#') _query += *it++;
+}
+
+
+void URI::parseFragment(std::string::const_iterator& it, const std::string::const_iterator& end)
+{
+ std::string fragment;
+ while (it != end) fragment += *it++;
+ decode(fragment, _fragment);
+}
+
+
+void URI::mergePath(const std::string& path)
+{
+ std::vector<std::string> segments;
+ std::vector<std::string> normalizedSegments;
+ bool addLeadingSlash = false;
+ if (!_path.empty())
+ {
+ getPathSegments(segments);
+ bool endsWithSlash = *(_path.rbegin()) == '/';
+ if (!endsWithSlash && !segments.empty())
+ segments.pop_back();
+ addLeadingSlash = _path[0] == '/';
+ }
+ getPathSegments(path, segments);
+ addLeadingSlash = addLeadingSlash || (!path.empty() && path[0] == '/');
+ bool hasTrailingSlash = (!path.empty() && *(path.rbegin()) == '/');
+ bool addTrailingSlash = false;
+ for (std::vector<std::string>::const_iterator it = segments.begin(); it != segments.end(); ++it)
+ {
+ if (*it == "..")
+ {
+ addTrailingSlash = true;
+ if (!normalizedSegments.empty())
+ normalizedSegments.pop_back();
+ }
+ else if (*it != ".")
+ {
+ addTrailingSlash = false;
+ normalizedSegments.push_back(*it);
+ }
+ else addTrailingSlash = true;
+ }
+ buildPath(normalizedSegments, addLeadingSlash, hasTrailingSlash || addTrailingSlash);
+}
+
+
+void URI::buildPath(const std::vector<std::string>& segments, bool leadingSlash, bool trailingSlash)
+{
+ _path.clear();
+ bool first = true;
+ for (std::vector<std::string>::const_iterator it = segments.begin(); it != segments.end(); ++it)
+ {
+ if (first)
+ {
+ first = false;
+ if (leadingSlash)
+ _path += '/';
+ else if (_scheme.empty() && (*it).find(':') != std::string::npos)
+ _path.append("./");
+ }
+ else _path += '/';
+ _path.append(*it);
+ }
+ if (trailingSlash)
+ _path += '/';
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/URIStreamFactory.cpp b/contrib/libs/poco/Foundation/src/URIStreamFactory.cpp
index 154693e16b..42316fe9a4 100644
--- a/contrib/libs/poco/Foundation/src/URIStreamFactory.cpp
+++ b/contrib/libs/poco/Foundation/src/URIStreamFactory.cpp
@@ -1,58 +1,58 @@
-//
-// URIStreamFactory.cpp
-//
-// Library: Foundation
-// Package: URI
-// Module: URIStreamFactory
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/URIStreamFactory.h"
-#include <algorithm>
-
-
-namespace Poco {
-
-
-URIStreamFactory::URIStreamFactory()
-{
-}
-
-
-URIStreamFactory::~URIStreamFactory()
-{
-}
-
-
-URIRedirection::URIRedirection(const std::string& rUri):
- _uri(rUri)
-{
-}
-
-
-URIRedirection::URIRedirection(const URIRedirection& redir):
- _uri(redir._uri)
-{
-}
-
-
-URIRedirection& URIRedirection::operator = (const URIRedirection& redir)
-{
- URIRedirection tmp(redir);
- swap(tmp);
- return *this;
-}
-
-
-void URIRedirection::swap(URIRedirection& redir)
-{
- std::swap(_uri, redir._uri);
-}
-
-
-} // namespace Poco
+//
+// URIStreamFactory.cpp
+//
+// Library: Foundation
+// Package: URI
+// Module: URIStreamFactory
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/URIStreamFactory.h"
+#include <algorithm>
+
+
+namespace Poco {
+
+
+URIStreamFactory::URIStreamFactory()
+{
+}
+
+
+URIStreamFactory::~URIStreamFactory()
+{
+}
+
+
+URIRedirection::URIRedirection(const std::string& rUri):
+ _uri(rUri)
+{
+}
+
+
+URIRedirection::URIRedirection(const URIRedirection& redir):
+ _uri(redir._uri)
+{
+}
+
+
+URIRedirection& URIRedirection::operator = (const URIRedirection& redir)
+{
+ URIRedirection tmp(redir);
+ swap(tmp);
+ return *this;
+}
+
+
+void URIRedirection::swap(URIRedirection& redir)
+{
+ std::swap(_uri, redir._uri);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/URIStreamOpener.cpp b/contrib/libs/poco/Foundation/src/URIStreamOpener.cpp
index 1f9631853b..609f9b343e 100644
--- a/contrib/libs/poco/Foundation/src/URIStreamOpener.cpp
+++ b/contrib/libs/poco/Foundation/src/URIStreamOpener.cpp
@@ -1,211 +1,211 @@
-//
-// URIStreamOpener.cpp
-//
-// Library: Foundation
-// Package: URI
-// Module: URIStreamOpener
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/URIStreamOpener.h"
-#include "Poco/URIStreamFactory.h"
-#include "Poco/FileStreamFactory.h"
-#include "Poco/URI.h"
-#include "Poco/Path.h"
-#include "Poco/SingletonHolder.h"
-#include "Poco/Exception.h"
-
-
-namespace Poco {
-
-
-URIStreamOpener::URIStreamOpener()
-{
- registerStreamFactory("file", new FileStreamFactory);
-}
-
-
-URIStreamOpener::~URIStreamOpener()
-{
- for (FactoryMap::iterator it = _map.begin(); it != _map.end(); ++it)
- delete it->second;
-}
-
-
-std::istream* URIStreamOpener::open(const URI& uri) const
-{
- FastMutex::ScopedLock lock(_mutex);
-
- std::string scheme;
- if (uri.isRelative())
- scheme = "file";
- else
- scheme = uri.getScheme();
- return openURI(scheme, uri);
-}
-
-
-std::istream* URIStreamOpener::open(const std::string& pathOrURI) const
-{
- FastMutex::ScopedLock lock(_mutex);
-
- try
- {
- URI uri(pathOrURI);
- std::string scheme(uri.getScheme());
- FactoryMap::const_iterator it = _map.find(scheme);
- if (it != _map.end())
- {
- return openURI(scheme, uri);
- }
- else if (scheme.length() <= 1) // could be Windows path
- {
- Path path;
- if (path.tryParse(pathOrURI, Path::PATH_GUESS))
- {
- return openFile(path);
- }
- }
- throw UnknownURISchemeException(pathOrURI);
- }
- catch (URISyntaxException&)
- {
- Path path;
- if (path.tryParse(pathOrURI, Path::PATH_GUESS))
- return openFile(path);
- else
- throw;
- }
-}
-
-
-std::istream* URIStreamOpener::open(const std::string& basePathOrURI, const std::string& pathOrURI) const
-{
- FastMutex::ScopedLock lock(_mutex);
-
- try
- {
- URI uri(basePathOrURI);
- std::string scheme(uri.getScheme());
- FactoryMap::const_iterator it = _map.find(scheme);
- if (it != _map.end())
- {
- uri.resolve(pathOrURI);
- scheme = uri.getScheme();
- return openURI(scheme, uri);
- }
- else if (scheme.length() <= 1) // could be Windows path
- {
- Path base;
- Path path;
- if (base.tryParse(basePathOrURI, Path::PATH_GUESS) && path.tryParse(pathOrURI, Path::PATH_GUESS))
- {
- base.resolve(path);
- return openFile(base);
- }
- }
- throw UnknownURISchemeException(basePathOrURI);
- }
- catch (URISyntaxException&)
- {
- Path base;
- Path path;
- if (base.tryParse(basePathOrURI, Path::PATH_GUESS) && path.tryParse(pathOrURI, Path::PATH_GUESS))
- {
- base.resolve(path);
- return openFile(base);
- }
- else throw;
- }
-}
-
-
-void URIStreamOpener::registerStreamFactory(const std::string& scheme, URIStreamFactory* pFactory)
-{
- poco_check_ptr (pFactory);
-
- FastMutex::ScopedLock lock(_mutex);
- if (_map.find(scheme) == _map.end())
- {
- _map[scheme] = pFactory;
- }
- else throw ExistsException("An URIStreamFactory for the given scheme has already been registered", scheme);
-}
-
-
-void URIStreamOpener::unregisterStreamFactory(const std::string& scheme)
-{
- FastMutex::ScopedLock lock(_mutex);
-
- FactoryMap::iterator it = _map.find(scheme);
- if (it != _map.end())
- {
- URIStreamFactory* pFactory = it->second;
- _map.erase(it);
- delete pFactory;
- }
- else throw NotFoundException("No URIStreamFactory has been registered for the given scheme", scheme);
-}
-
-
-bool URIStreamOpener::supportsScheme(const std::string& scheme)
-{
- FastMutex::ScopedLock lock(_mutex);
- return _map.find(scheme) != _map.end();
-}
-
-
-namespace
-{
- static SingletonHolder<URIStreamOpener> sh;
-}
-
-
-URIStreamOpener& URIStreamOpener::defaultOpener()
-{
- return *sh.get();
-}
-
-
-std::istream* URIStreamOpener::openFile(const Path& path) const
-{
- FileStreamFactory factory;
- return factory.open(path);
-}
-
-
-std::istream* URIStreamOpener::openURI(const std::string& scheme, const URI& uri) const
-{
- std::string actualScheme(scheme);
- URI actualURI(uri);
- int redirects = 0;
-
- while (redirects < MAX_REDIRECTS)
- {
- try
- {
- FactoryMap::const_iterator it = _map.find(actualScheme);
- if (it != _map.end())
- return it->second->open(actualURI);
- else if (redirects > 0)
- throw UnknownURISchemeException(actualURI.toString() + std::string("; redirected from ") + uri.toString());
- else
- throw UnknownURISchemeException(actualURI.toString());
- }
- catch (URIRedirection& redir)
- {
- actualURI = redir.uri();
- actualScheme = actualURI.getScheme();
- ++redirects;
- }
- }
- throw TooManyURIRedirectsException(uri.toString());
-}
-
-
-} // namespace Poco
+//
+// URIStreamOpener.cpp
+//
+// Library: Foundation
+// Package: URI
+// Module: URIStreamOpener
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/URIStreamOpener.h"
+#include "Poco/URIStreamFactory.h"
+#include "Poco/FileStreamFactory.h"
+#include "Poco/URI.h"
+#include "Poco/Path.h"
+#include "Poco/SingletonHolder.h"
+#include "Poco/Exception.h"
+
+
+namespace Poco {
+
+
+URIStreamOpener::URIStreamOpener()
+{
+ registerStreamFactory("file", new FileStreamFactory);
+}
+
+
+URIStreamOpener::~URIStreamOpener()
+{
+ for (FactoryMap::iterator it = _map.begin(); it != _map.end(); ++it)
+ delete it->second;
+}
+
+
+std::istream* URIStreamOpener::open(const URI& uri) const
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ std::string scheme;
+ if (uri.isRelative())
+ scheme = "file";
+ else
+ scheme = uri.getScheme();
+ return openURI(scheme, uri);
+}
+
+
+std::istream* URIStreamOpener::open(const std::string& pathOrURI) const
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ try
+ {
+ URI uri(pathOrURI);
+ std::string scheme(uri.getScheme());
+ FactoryMap::const_iterator it = _map.find(scheme);
+ if (it != _map.end())
+ {
+ return openURI(scheme, uri);
+ }
+ else if (scheme.length() <= 1) // could be Windows path
+ {
+ Path path;
+ if (path.tryParse(pathOrURI, Path::PATH_GUESS))
+ {
+ return openFile(path);
+ }
+ }
+ throw UnknownURISchemeException(pathOrURI);
+ }
+ catch (URISyntaxException&)
+ {
+ Path path;
+ if (path.tryParse(pathOrURI, Path::PATH_GUESS))
+ return openFile(path);
+ else
+ throw;
+ }
+}
+
+
+std::istream* URIStreamOpener::open(const std::string& basePathOrURI, const std::string& pathOrURI) const
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ try
+ {
+ URI uri(basePathOrURI);
+ std::string scheme(uri.getScheme());
+ FactoryMap::const_iterator it = _map.find(scheme);
+ if (it != _map.end())
+ {
+ uri.resolve(pathOrURI);
+ scheme = uri.getScheme();
+ return openURI(scheme, uri);
+ }
+ else if (scheme.length() <= 1) // could be Windows path
+ {
+ Path base;
+ Path path;
+ if (base.tryParse(basePathOrURI, Path::PATH_GUESS) && path.tryParse(pathOrURI, Path::PATH_GUESS))
+ {
+ base.resolve(path);
+ return openFile(base);
+ }
+ }
+ throw UnknownURISchemeException(basePathOrURI);
+ }
+ catch (URISyntaxException&)
+ {
+ Path base;
+ Path path;
+ if (base.tryParse(basePathOrURI, Path::PATH_GUESS) && path.tryParse(pathOrURI, Path::PATH_GUESS))
+ {
+ base.resolve(path);
+ return openFile(base);
+ }
+ else throw;
+ }
+}
+
+
+void URIStreamOpener::registerStreamFactory(const std::string& scheme, URIStreamFactory* pFactory)
+{
+ poco_check_ptr (pFactory);
+
+ FastMutex::ScopedLock lock(_mutex);
+ if (_map.find(scheme) == _map.end())
+ {
+ _map[scheme] = pFactory;
+ }
+ else throw ExistsException("An URIStreamFactory for the given scheme has already been registered", scheme);
+}
+
+
+void URIStreamOpener::unregisterStreamFactory(const std::string& scheme)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ FactoryMap::iterator it = _map.find(scheme);
+ if (it != _map.end())
+ {
+ URIStreamFactory* pFactory = it->second;
+ _map.erase(it);
+ delete pFactory;
+ }
+ else throw NotFoundException("No URIStreamFactory has been registered for the given scheme", scheme);
+}
+
+
+bool URIStreamOpener::supportsScheme(const std::string& scheme)
+{
+ FastMutex::ScopedLock lock(_mutex);
+ return _map.find(scheme) != _map.end();
+}
+
+
+namespace
+{
+ static SingletonHolder<URIStreamOpener> sh;
+}
+
+
+URIStreamOpener& URIStreamOpener::defaultOpener()
+{
+ return *sh.get();
+}
+
+
+std::istream* URIStreamOpener::openFile(const Path& path) const
+{
+ FileStreamFactory factory;
+ return factory.open(path);
+}
+
+
+std::istream* URIStreamOpener::openURI(const std::string& scheme, const URI& uri) const
+{
+ std::string actualScheme(scheme);
+ URI actualURI(uri);
+ int redirects = 0;
+
+ while (redirects < MAX_REDIRECTS)
+ {
+ try
+ {
+ FactoryMap::const_iterator it = _map.find(actualScheme);
+ if (it != _map.end())
+ return it->second->open(actualURI);
+ else if (redirects > 0)
+ throw UnknownURISchemeException(actualURI.toString() + std::string("; redirected from ") + uri.toString());
+ else
+ throw UnknownURISchemeException(actualURI.toString());
+ }
+ catch (URIRedirection& redir)
+ {
+ actualURI = redir.uri();
+ actualScheme = actualURI.getScheme();
+ ++redirects;
+ }
+ }
+ throw TooManyURIRedirectsException(uri.toString());
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/UTF16Encoding.cpp b/contrib/libs/poco/Foundation/src/UTF16Encoding.cpp
index ea2ee8fe4f..88eddda0c0 100644
--- a/contrib/libs/poco/Foundation/src/UTF16Encoding.cpp
+++ b/contrib/libs/poco/Foundation/src/UTF16Encoding.cpp
@@ -1,273 +1,273 @@
-//
-// UTF16Encoding.cpp
-//
-// Library: Foundation
-// Package: Text
-// Module: UTF16Encoding
-//
-// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/UTF16Encoding.h"
-#include "Poco/ByteOrder.h"
-#include "Poco/String.h"
-
-
-namespace Poco {
-
-
-const char* UTF16Encoding::_names[] =
-{
- "UTF-16",
- "UTF16",
- NULL
-};
-
-
-const TextEncoding::CharacterMap UTF16Encoding::_charMap =
-{
- /* 00 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* 10 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* 20 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* 30 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* 40 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* 50 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* 60 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* 70 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* 80 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* 90 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* a0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* b0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* c0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* d0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* e0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* f0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
-};
-
-
-UTF16Encoding::UTF16Encoding(ByteOrderType byteOrder)
-{
- setByteOrder(byteOrder);
-}
-
-
-UTF16Encoding::UTF16Encoding(int byteOrderMark)
-{
- setByteOrder(byteOrderMark);
-}
-
-
-UTF16Encoding::~UTF16Encoding()
-{
-}
-
-
-UTF16Encoding::ByteOrderType UTF16Encoding::getByteOrder() const
-{
-#if defined(POCO_ARCH_BIG_ENDIAN)
- return _flipBytes ? LITTLE_ENDIAN_BYTE_ORDER : BIG_ENDIAN_BYTE_ORDER;
-#else
- return _flipBytes ? BIG_ENDIAN_BYTE_ORDER : LITTLE_ENDIAN_BYTE_ORDER;
-#endif
-}
-
-
-void UTF16Encoding::setByteOrder(ByteOrderType byteOrder)
-{
-#if defined(POCO_ARCH_BIG_ENDIAN)
- _flipBytes = byteOrder == LITTLE_ENDIAN_BYTE_ORDER;
-#else
- _flipBytes = byteOrder == BIG_ENDIAN_BYTE_ORDER;;
-#endif
-}
-
-
-void UTF16Encoding::setByteOrder(int byteOrderMark)
-{
- _flipBytes = byteOrderMark != 0xFEFF;
-}
-
-
-const char* UTF16Encoding::canonicalName() const
-{
- return _names[0];
-}
-
-
-bool UTF16Encoding::isA(const std::string& encodingName) const
-{
- for (const char** name = _names; *name; ++name)
- {
- if (Poco::icompare(encodingName, *name) == 0)
- return true;
- }
- return false;
-}
-
-
-const TextEncoding::CharacterMap& UTF16Encoding::characterMap() const
-{
- return _charMap;
-}
-
-
-int UTF16Encoding::convert(const unsigned char* bytes) const
-{
- UInt16 uc;
- unsigned char* p = (unsigned char*) &uc;
- *p++ = *bytes++;
- *p++ = *bytes++;
-
- if (_flipBytes)
- {
- ByteOrder::flipBytes(uc);
- }
-
- if (uc >= 0xd800 && uc < 0xdc00)
- {
- UInt16 uc2;
- p = (unsigned char*) &uc2;
- *p++ = *bytes++;
- *p++ = *bytes++;
-
- if (_flipBytes)
- {
- ByteOrder::flipBytes(uc2);
- }
- if (uc2 >= 0xdc00 && uc2 < 0xe000)
- {
- return ((uc & 0x3ff) << 10) + (uc2 & 0x3ff) + 0x10000;
- }
- else
- {
- return -1;
- }
- }
- else
- {
- return uc;
- }
-}
-
-
-int UTF16Encoding::convert(int ch, unsigned char* bytes, int length) const
-{
- if (ch <= 0xFFFF)
- {
- if (bytes && length >= 2)
- {
- UInt16 ch1 = _flipBytes ? ByteOrder::flipBytes((UInt16) ch) : (UInt16) ch;
- unsigned char* p = (unsigned char*) &ch1;
- *bytes++ = *p++;
- *bytes++ = *p++;
- }
- return 2;
- }
- else
- {
- if (bytes && length >= 4)
- {
- int ch1 = ch - 0x10000;
- UInt16 w1 = 0xD800 + ((ch1 >> 10) & 0x3FF);
- UInt16 w2 = 0xDC00 + (ch1 & 0x3FF);
- if (_flipBytes)
- {
- w1 = ByteOrder::flipBytes(w1);
- w2 = ByteOrder::flipBytes(w2);
- }
- unsigned char* p = (unsigned char*) &w1;
- *bytes++ = *p++;
- *bytes++ = *p++;
- p = (unsigned char*) &w2;
- *bytes++ = *p++;
- *bytes++ = *p++;
- }
- return 4;
- }
-}
-
-
-int UTF16Encoding::queryConvert(const unsigned char* bytes, int length) const
-{
- int ret = -2;
-
- if (length >= 2)
- {
- UInt16 uc;
- unsigned char* p = (unsigned char*) &uc;
- *p++ = *bytes++;
- *p++ = *bytes++;
+//
+// UTF16Encoding.cpp
+//
+// Library: Foundation
+// Package: Text
+// Module: UTF16Encoding
+//
+// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/UTF16Encoding.h"
+#include "Poco/ByteOrder.h"
+#include "Poco/String.h"
+
+
+namespace Poco {
+
+
+const char* UTF16Encoding::_names[] =
+{
+ "UTF-16",
+ "UTF16",
+ NULL
+};
+
+
+const TextEncoding::CharacterMap UTF16Encoding::_charMap =
+{
+ /* 00 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* 10 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* 20 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* 30 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* 40 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* 50 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* 60 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* 70 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* 80 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* 90 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* a0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* b0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* c0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* d0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* e0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* f0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+};
+
+
+UTF16Encoding::UTF16Encoding(ByteOrderType byteOrder)
+{
+ setByteOrder(byteOrder);
+}
+
+
+UTF16Encoding::UTF16Encoding(int byteOrderMark)
+{
+ setByteOrder(byteOrderMark);
+}
+
+
+UTF16Encoding::~UTF16Encoding()
+{
+}
+
+
+UTF16Encoding::ByteOrderType UTF16Encoding::getByteOrder() const
+{
+#if defined(POCO_ARCH_BIG_ENDIAN)
+ return _flipBytes ? LITTLE_ENDIAN_BYTE_ORDER : BIG_ENDIAN_BYTE_ORDER;
+#else
+ return _flipBytes ? BIG_ENDIAN_BYTE_ORDER : LITTLE_ENDIAN_BYTE_ORDER;
+#endif
+}
+
+
+void UTF16Encoding::setByteOrder(ByteOrderType byteOrder)
+{
+#if defined(POCO_ARCH_BIG_ENDIAN)
+ _flipBytes = byteOrder == LITTLE_ENDIAN_BYTE_ORDER;
+#else
+ _flipBytes = byteOrder == BIG_ENDIAN_BYTE_ORDER;;
+#endif
+}
+
+
+void UTF16Encoding::setByteOrder(int byteOrderMark)
+{
+ _flipBytes = byteOrderMark != 0xFEFF;
+}
+
+
+const char* UTF16Encoding::canonicalName() const
+{
+ return _names[0];
+}
+
+
+bool UTF16Encoding::isA(const std::string& encodingName) const
+{
+ for (const char** name = _names; *name; ++name)
+ {
+ if (Poco::icompare(encodingName, *name) == 0)
+ return true;
+ }
+ return false;
+}
+
+
+const TextEncoding::CharacterMap& UTF16Encoding::characterMap() const
+{
+ return _charMap;
+}
+
+
+int UTF16Encoding::convert(const unsigned char* bytes) const
+{
+ UInt16 uc;
+ unsigned char* p = (unsigned char*) &uc;
+ *p++ = *bytes++;
+ *p++ = *bytes++;
+
+ if (_flipBytes)
+ {
+ ByteOrder::flipBytes(uc);
+ }
+
+ if (uc >= 0xd800 && uc < 0xdc00)
+ {
+ UInt16 uc2;
+ p = (unsigned char*) &uc2;
+ *p++ = *bytes++;
+ *p++ = *bytes++;
+
if (_flipBytes)
- ByteOrder::flipBytes(uc);
- if (uc >= 0xd800 && uc < 0xdc00)
- {
- if (length >= 4)
- {
- UInt16 uc2;
- p = (unsigned char*) &uc2;
- *p++ = *bytes++;
- *p++ = *bytes++;
- if (_flipBytes)
- ByteOrder::flipBytes(uc2);
- if (uc2 >= 0xdc00 && uc < 0xe000)
- {
- ret = ((uc & 0x3ff) << 10) + (uc2 & 0x3ff) + 0x10000;
- }
- else
- {
- ret = -1; // Malformed sequence
- }
- }
- else
- {
- ret = -4; // surrogate pair, four bytes needed
- }
- }
- else
- {
- ret = uc;
- }
- }
-
- return ret;
-}
-
-
-int UTF16Encoding::sequenceLength(const unsigned char* bytes, int length) const
-{
- int ret = -2;
-
- if (_flipBytes)
- {
- if (length >= 1)
- {
- unsigned char c = *bytes;
- if (c >= 0xd8 && c < 0xdc)
- ret = 4;
- else
- ret = 2;
- }
- }
- else
- {
- if (length >= 2)
- {
- UInt16 uc;
- unsigned char* p = (unsigned char*) &uc;
- *p++ = *bytes++;
- *p++ = *bytes++;
- if (uc >= 0xd800 && uc < 0xdc00)
- ret = 4;
- else
- ret = 2;
- }
- }
- return ret;
-}
-
-
-} // namespace Poco
+ {
+ ByteOrder::flipBytes(uc2);
+ }
+ if (uc2 >= 0xdc00 && uc2 < 0xe000)
+ {
+ return ((uc & 0x3ff) << 10) + (uc2 & 0x3ff) + 0x10000;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ else
+ {
+ return uc;
+ }
+}
+
+
+int UTF16Encoding::convert(int ch, unsigned char* bytes, int length) const
+{
+ if (ch <= 0xFFFF)
+ {
+ if (bytes && length >= 2)
+ {
+ UInt16 ch1 = _flipBytes ? ByteOrder::flipBytes((UInt16) ch) : (UInt16) ch;
+ unsigned char* p = (unsigned char*) &ch1;
+ *bytes++ = *p++;
+ *bytes++ = *p++;
+ }
+ return 2;
+ }
+ else
+ {
+ if (bytes && length >= 4)
+ {
+ int ch1 = ch - 0x10000;
+ UInt16 w1 = 0xD800 + ((ch1 >> 10) & 0x3FF);
+ UInt16 w2 = 0xDC00 + (ch1 & 0x3FF);
+ if (_flipBytes)
+ {
+ w1 = ByteOrder::flipBytes(w1);
+ w2 = ByteOrder::flipBytes(w2);
+ }
+ unsigned char* p = (unsigned char*) &w1;
+ *bytes++ = *p++;
+ *bytes++ = *p++;
+ p = (unsigned char*) &w2;
+ *bytes++ = *p++;
+ *bytes++ = *p++;
+ }
+ return 4;
+ }
+}
+
+
+int UTF16Encoding::queryConvert(const unsigned char* bytes, int length) const
+{
+ int ret = -2;
+
+ if (length >= 2)
+ {
+ UInt16 uc;
+ unsigned char* p = (unsigned char*) &uc;
+ *p++ = *bytes++;
+ *p++ = *bytes++;
+ if (_flipBytes)
+ ByteOrder::flipBytes(uc);
+ if (uc >= 0xd800 && uc < 0xdc00)
+ {
+ if (length >= 4)
+ {
+ UInt16 uc2;
+ p = (unsigned char*) &uc2;
+ *p++ = *bytes++;
+ *p++ = *bytes++;
+ if (_flipBytes)
+ ByteOrder::flipBytes(uc2);
+ if (uc2 >= 0xdc00 && uc < 0xe000)
+ {
+ ret = ((uc & 0x3ff) << 10) + (uc2 & 0x3ff) + 0x10000;
+ }
+ else
+ {
+ ret = -1; // Malformed sequence
+ }
+ }
+ else
+ {
+ ret = -4; // surrogate pair, four bytes needed
+ }
+ }
+ else
+ {
+ ret = uc;
+ }
+ }
+
+ return ret;
+}
+
+
+int UTF16Encoding::sequenceLength(const unsigned char* bytes, int length) const
+{
+ int ret = -2;
+
+ if (_flipBytes)
+ {
+ if (length >= 1)
+ {
+ unsigned char c = *bytes;
+ if (c >= 0xd8 && c < 0xdc)
+ ret = 4;
+ else
+ ret = 2;
+ }
+ }
+ else
+ {
+ if (length >= 2)
+ {
+ UInt16 uc;
+ unsigned char* p = (unsigned char*) &uc;
+ *p++ = *bytes++;
+ *p++ = *bytes++;
+ if (uc >= 0xd800 && uc < 0xdc00)
+ ret = 4;
+ else
+ ret = 2;
+ }
+ }
+ return ret;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/UTF32Encoding.cpp b/contrib/libs/poco/Foundation/src/UTF32Encoding.cpp
index db0cfe21d7..d5d3ef5bb0 100644
--- a/contrib/libs/poco/Foundation/src/UTF32Encoding.cpp
+++ b/contrib/libs/poco/Foundation/src/UTF32Encoding.cpp
@@ -1,178 +1,178 @@
-//
-// UTF32Encoding.cpp
-//
-// Library: Foundation
-// Package: Text
-// Module: UTF32Encoding
-//
-// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/UTF32Encoding.h"
-#include "Poco/ByteOrder.h"
-#include "Poco/String.h"
-
-
-namespace Poco {
-
-
-const char* UTF32Encoding::_names[] =
-{
- "UTF-32",
- "UTF32",
- NULL
-};
-
-
-const TextEncoding::CharacterMap UTF32Encoding::_charMap =
-{
- /* 00 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* 10 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* 20 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* 30 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* 40 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* 50 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* 60 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* 70 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* 80 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* 90 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* a0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* b0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* c0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* d0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* e0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* f0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
-};
-
-
-UTF32Encoding::UTF32Encoding(ByteOrderType byteOrder)
-{
- setByteOrder(byteOrder);
-}
-
-
-UTF32Encoding::UTF32Encoding(int byteOrderMark)
-{
- setByteOrder(byteOrderMark);
-}
-
-
-UTF32Encoding::~UTF32Encoding()
-{
-}
-
-
-UTF32Encoding::ByteOrderType UTF32Encoding::getByteOrder() const
-{
-#if defined(POCO_ARCH_BIG_ENDIAN)
- return _flipBytes ? LITTLE_ENDIAN_BYTE_ORDER : BIG_ENDIAN_BYTE_ORDER;
-#else
- return _flipBytes ? BIG_ENDIAN_BYTE_ORDER : LITTLE_ENDIAN_BYTE_ORDER;
-#endif
-}
-
-
-void UTF32Encoding::setByteOrder(ByteOrderType byteOrder)
-{
-#if defined(POCO_ARCH_BIG_ENDIAN)
- _flipBytes = byteOrder == LITTLE_ENDIAN_BYTE_ORDER;
-#else
- _flipBytes = byteOrder == BIG_ENDIAN_BYTE_ORDER;;
-#endif
-}
-
-
-void UTF32Encoding::setByteOrder(int byteOrderMark)
-{
- _flipBytes = byteOrderMark != 0xFEFF;
-}
-
-
-const char* UTF32Encoding::canonicalName() const
-{
- return _names[0];
-}
-
-
-bool UTF32Encoding::isA(const std::string& encodingName) const
-{
- for (const char** name = _names; *name; ++name)
- {
- if (Poco::icompare(encodingName, *name) == 0)
- return true;
- }
- return false;
-}
-
-
-const TextEncoding::CharacterMap& UTF32Encoding::characterMap() const
-{
- return _charMap;
-}
-
-
-int UTF32Encoding::convert(const unsigned char* bytes) const
-{
- UInt32 uc;
- unsigned char* p = (unsigned char*) &uc;
- *p++ = *bytes++;
- *p++ = *bytes++;
- *p++ = *bytes++;
- *p++ = *bytes++;
-
- if (_flipBytes)
- {
- ByteOrder::flipBytes(uc);
- }
-
- return uc;
-}
-
-
-int UTF32Encoding::convert(int ch, unsigned char* bytes, int length) const
-{
- if (bytes && length >= 4)
- {
- UInt32 ch1 = _flipBytes ? ByteOrder::flipBytes((UInt32) ch) : (UInt32) ch;
- unsigned char* p = (unsigned char*) &ch1;
- *bytes++ = *p++;
- *bytes++ = *p++;
- *bytes++ = *p++;
- *bytes++ = *p++;
- }
- return 4;
-}
-
-
-int UTF32Encoding::queryConvert(const unsigned char* bytes, int length) const
-{
- int ret = -4;
-
- if (length >= 4)
- {
- UInt32 uc;
- unsigned char* p = (unsigned char*) &uc;
- *p++ = *bytes++;
- *p++ = *bytes++;
- *p++ = *bytes++;
- *p++ = *bytes++;
- if (_flipBytes)
- ByteOrder::flipBytes(uc);
- return uc;
- }
-
- return ret;
-}
-
-
-int UTF32Encoding::sequenceLength(const unsigned char* /*bytes*/, int /*length*/) const
-{
- return 4;
-}
-
-
-} // namespace Poco
+//
+// UTF32Encoding.cpp
+//
+// Library: Foundation
+// Package: Text
+// Module: UTF32Encoding
+//
+// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/UTF32Encoding.h"
+#include "Poco/ByteOrder.h"
+#include "Poco/String.h"
+
+
+namespace Poco {
+
+
+const char* UTF32Encoding::_names[] =
+{
+ "UTF-32",
+ "UTF32",
+ NULL
+};
+
+
+const TextEncoding::CharacterMap UTF32Encoding::_charMap =
+{
+ /* 00 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* 10 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* 20 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* 30 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* 40 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* 50 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* 60 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* 70 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* 80 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* 90 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* a0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* b0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* c0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* d0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* e0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* f0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+};
+
+
+UTF32Encoding::UTF32Encoding(ByteOrderType byteOrder)
+{
+ setByteOrder(byteOrder);
+}
+
+
+UTF32Encoding::UTF32Encoding(int byteOrderMark)
+{
+ setByteOrder(byteOrderMark);
+}
+
+
+UTF32Encoding::~UTF32Encoding()
+{
+}
+
+
+UTF32Encoding::ByteOrderType UTF32Encoding::getByteOrder() const
+{
+#if defined(POCO_ARCH_BIG_ENDIAN)
+ return _flipBytes ? LITTLE_ENDIAN_BYTE_ORDER : BIG_ENDIAN_BYTE_ORDER;
+#else
+ return _flipBytes ? BIG_ENDIAN_BYTE_ORDER : LITTLE_ENDIAN_BYTE_ORDER;
+#endif
+}
+
+
+void UTF32Encoding::setByteOrder(ByteOrderType byteOrder)
+{
+#if defined(POCO_ARCH_BIG_ENDIAN)
+ _flipBytes = byteOrder == LITTLE_ENDIAN_BYTE_ORDER;
+#else
+ _flipBytes = byteOrder == BIG_ENDIAN_BYTE_ORDER;;
+#endif
+}
+
+
+void UTF32Encoding::setByteOrder(int byteOrderMark)
+{
+ _flipBytes = byteOrderMark != 0xFEFF;
+}
+
+
+const char* UTF32Encoding::canonicalName() const
+{
+ return _names[0];
+}
+
+
+bool UTF32Encoding::isA(const std::string& encodingName) const
+{
+ for (const char** name = _names; *name; ++name)
+ {
+ if (Poco::icompare(encodingName, *name) == 0)
+ return true;
+ }
+ return false;
+}
+
+
+const TextEncoding::CharacterMap& UTF32Encoding::characterMap() const
+{
+ return _charMap;
+}
+
+
+int UTF32Encoding::convert(const unsigned char* bytes) const
+{
+ UInt32 uc;
+ unsigned char* p = (unsigned char*) &uc;
+ *p++ = *bytes++;
+ *p++ = *bytes++;
+ *p++ = *bytes++;
+ *p++ = *bytes++;
+
+ if (_flipBytes)
+ {
+ ByteOrder::flipBytes(uc);
+ }
+
+ return uc;
+}
+
+
+int UTF32Encoding::convert(int ch, unsigned char* bytes, int length) const
+{
+ if (bytes && length >= 4)
+ {
+ UInt32 ch1 = _flipBytes ? ByteOrder::flipBytes((UInt32) ch) : (UInt32) ch;
+ unsigned char* p = (unsigned char*) &ch1;
+ *bytes++ = *p++;
+ *bytes++ = *p++;
+ *bytes++ = *p++;
+ *bytes++ = *p++;
+ }
+ return 4;
+}
+
+
+int UTF32Encoding::queryConvert(const unsigned char* bytes, int length) const
+{
+ int ret = -4;
+
+ if (length >= 4)
+ {
+ UInt32 uc;
+ unsigned char* p = (unsigned char*) &uc;
+ *p++ = *bytes++;
+ *p++ = *bytes++;
+ *p++ = *bytes++;
+ *p++ = *bytes++;
+ if (_flipBytes)
+ ByteOrder::flipBytes(uc);
+ return uc;
+ }
+
+ return ret;
+}
+
+
+int UTF32Encoding::sequenceLength(const unsigned char* /*bytes*/, int /*length*/) const
+{
+ return 4;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/UTF8Encoding.cpp b/contrib/libs/poco/Foundation/src/UTF8Encoding.cpp
index 78fc6d4a84..1f2491f360 100644
--- a/contrib/libs/poco/Foundation/src/UTF8Encoding.cpp
+++ b/contrib/libs/poco/Foundation/src/UTF8Encoding.cpp
@@ -1,246 +1,246 @@
-//
-// UTF8Encoding.cpp
-//
-// Library: Foundation
-// Package: Text
-// Module: UTF8Encoding
-//
-// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/UTF8Encoding.h"
-#include "Poco/String.h"
-
-
-namespace Poco {
-
-
-const char* UTF8Encoding::_names[] =
-{
- "UTF-8",
- "UTF8",
- NULL
-};
-
-
-const TextEncoding::CharacterMap UTF8Encoding::_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 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* d0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- /* e0 */ -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
- /* f0 */ -4, -4, -4, -4, -4, -4, -4, -4, -1, -1, -1, -1, -1, -1, -1, -1,
-};
-
-
-UTF8Encoding::UTF8Encoding()
-{
-}
-
-
-UTF8Encoding::~UTF8Encoding()
-{
-}
-
-
-const char* UTF8Encoding::canonicalName() const
-{
- return _names[0];
-}
-
-
-bool UTF8Encoding::isA(const std::string& encodingName) const
-{
- for (const char** name = _names; *name; ++name)
- {
- if (Poco::icompare(encodingName, *name) == 0)
- return true;
- }
- return false;
-}
-
-
-const TextEncoding::CharacterMap& UTF8Encoding::characterMap() const
-{
- return _charMap;
-}
-
-
-int UTF8Encoding::convert(const unsigned char* bytes) const
-{
- int n = _charMap[*bytes];
- int uc;
-
- switch (n)
- {
- case -1:
- return -1;
- case -4:
- case -3:
- case -2:
- if (!isLegal(bytes, -n)) return -1;
- uc = *bytes & ((0x07 << (n + 4)) | 0x03);
- break;
- default:
- return n;
- }
-
- while (n++ < -1)
- {
- uc <<= 6;
- uc |= (*++bytes & 0x3F);
- }
- return uc;
-}
-
-
-int UTF8Encoding::convert(int ch, unsigned char* bytes, int length) const
-{
- if (ch <= 0x7F)
- {
- if (bytes && length >= 1)
- *bytes = (unsigned char) ch;
- return 1;
- }
- else if (ch <= 0x7FF)
- {
- if (bytes && length >= 2)
- {
- *bytes++ = (unsigned char) (((ch >> 6) & 0x1F) | 0xC0);
- *bytes = (unsigned char) ((ch & 0x3F) | 0x80);
- }
- return 2;
- }
- else if (ch <= 0xFFFF)
- {
- if (bytes && length >= 3)
- {
- *bytes++ = (unsigned char) (((ch >> 12) & 0x0F) | 0xE0);
- *bytes++ = (unsigned char) (((ch >> 6) & 0x3F) | 0x80);
- *bytes = (unsigned char) ((ch & 0x3F) | 0x80);
- }
- return 3;
- }
- else if (ch <= 0x10FFFF)
- {
- if (bytes && length >= 4)
- {
- *bytes++ = (unsigned char) (((ch >> 18) & 0x07) | 0xF0);
- *bytes++ = (unsigned char) (((ch >> 12) & 0x3F) | 0x80);
- *bytes++ = (unsigned char) (((ch >> 6) & 0x3F) | 0x80);
- *bytes = (unsigned char) ((ch & 0x3F) | 0x80);
- }
- return 4;
- }
- else return 0;
-}
-
-
-int UTF8Encoding::queryConvert(const unsigned char* bytes, int length) const
-{
- int n = _charMap[*bytes];
- int uc;
- if (-n > length)
- {
- return n;
- }
- else
- {
- switch (n)
- {
- case -1:
- return -1;
- case -4:
- case -3:
- case -2:
- if (!isLegal(bytes, -n)) return -1;
- uc = *bytes & ((0x07 << (n + 4)) | 0x03);
- break;
- default:
- return n;
- }
- while (n++ < -1)
- {
- uc <<= 6;
- uc |= (*++bytes & 0x3F);
- }
- return uc;
- }
-}
-
-
-int UTF8Encoding::sequenceLength(const unsigned char* bytes, int length) const
-{
- if (1 <= length)
- {
- int cc = _charMap[*bytes];
- if (cc >= 0)
- return 1;
- else
- return -cc;
- }
- else return -1;
-}
-
-
-bool UTF8Encoding::isLegal(const unsigned char *bytes, int length)
-{
- // Note: The following is loosely based on the isLegalUTF8 function
- // from ftp://ftp.unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.c
- // Excuse the ugliness...
-
- if (0 == bytes || 0 == length) return false;
-
- unsigned char a;
- const unsigned char* srcptr = bytes + length;
- switch (length)
- {
- default:
- return false;
- // Everything else falls through when true.
- case 4:
- if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
- case 3:
- if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
- case 2:
- a = (*--srcptr);
- switch (*bytes)
- {
- case 0xE0:
- if (a < 0xA0 || a > 0xBF) return false;
- break;
- case 0xED:
- if (a < 0x80 || a > 0x9F) return false;
- break;
- case 0xF0:
- if (a < 0x90 || a > 0xBF) return false;
- break;
- case 0xF4:
- if (a < 0x80 || a > 0x8F) return false;
- break;
- default:
- if (a < 0x80 || a > 0xBF) return false;
- }
- case 1:
- if (*bytes >= 0x80 && *bytes < 0xC2) return false;
- }
- return *bytes <= 0xF4;
-}
-
-
-} // namespace Poco
+//
+// UTF8Encoding.cpp
+//
+// Library: Foundation
+// Package: Text
+// Module: UTF8Encoding
+//
+// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/UTF8Encoding.h"
+#include "Poco/String.h"
+
+
+namespace Poco {
+
+
+const char* UTF8Encoding::_names[] =
+{
+ "UTF-8",
+ "UTF8",
+ NULL
+};
+
+
+const TextEncoding::CharacterMap UTF8Encoding::_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 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* d0 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ /* e0 */ -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
+ /* f0 */ -4, -4, -4, -4, -4, -4, -4, -4, -1, -1, -1, -1, -1, -1, -1, -1,
+};
+
+
+UTF8Encoding::UTF8Encoding()
+{
+}
+
+
+UTF8Encoding::~UTF8Encoding()
+{
+}
+
+
+const char* UTF8Encoding::canonicalName() const
+{
+ return _names[0];
+}
+
+
+bool UTF8Encoding::isA(const std::string& encodingName) const
+{
+ for (const char** name = _names; *name; ++name)
+ {
+ if (Poco::icompare(encodingName, *name) == 0)
+ return true;
+ }
+ return false;
+}
+
+
+const TextEncoding::CharacterMap& UTF8Encoding::characterMap() const
+{
+ return _charMap;
+}
+
+
+int UTF8Encoding::convert(const unsigned char* bytes) const
+{
+ int n = _charMap[*bytes];
+ int uc;
+
+ switch (n)
+ {
+ case -1:
+ return -1;
+ case -4:
+ case -3:
+ case -2:
+ if (!isLegal(bytes, -n)) return -1;
+ uc = *bytes & ((0x07 << (n + 4)) | 0x03);
+ break;
+ default:
+ return n;
+ }
+
+ while (n++ < -1)
+ {
+ uc <<= 6;
+ uc |= (*++bytes & 0x3F);
+ }
+ return uc;
+}
+
+
+int UTF8Encoding::convert(int ch, unsigned char* bytes, int length) const
+{
+ if (ch <= 0x7F)
+ {
+ if (bytes && length >= 1)
+ *bytes = (unsigned char) ch;
+ return 1;
+ }
+ else if (ch <= 0x7FF)
+ {
+ if (bytes && length >= 2)
+ {
+ *bytes++ = (unsigned char) (((ch >> 6) & 0x1F) | 0xC0);
+ *bytes = (unsigned char) ((ch & 0x3F) | 0x80);
+ }
+ return 2;
+ }
+ else if (ch <= 0xFFFF)
+ {
+ if (bytes && length >= 3)
+ {
+ *bytes++ = (unsigned char) (((ch >> 12) & 0x0F) | 0xE0);
+ *bytes++ = (unsigned char) (((ch >> 6) & 0x3F) | 0x80);
+ *bytes = (unsigned char) ((ch & 0x3F) | 0x80);
+ }
+ return 3;
+ }
+ else if (ch <= 0x10FFFF)
+ {
+ if (bytes && length >= 4)
+ {
+ *bytes++ = (unsigned char) (((ch >> 18) & 0x07) | 0xF0);
+ *bytes++ = (unsigned char) (((ch >> 12) & 0x3F) | 0x80);
+ *bytes++ = (unsigned char) (((ch >> 6) & 0x3F) | 0x80);
+ *bytes = (unsigned char) ((ch & 0x3F) | 0x80);
+ }
+ return 4;
+ }
+ else return 0;
+}
+
+
+int UTF8Encoding::queryConvert(const unsigned char* bytes, int length) const
+{
+ int n = _charMap[*bytes];
+ int uc;
+ if (-n > length)
+ {
+ return n;
+ }
+ else
+ {
+ switch (n)
+ {
+ case -1:
+ return -1;
+ case -4:
+ case -3:
+ case -2:
+ if (!isLegal(bytes, -n)) return -1;
+ uc = *bytes & ((0x07 << (n + 4)) | 0x03);
+ break;
+ default:
+ return n;
+ }
+ while (n++ < -1)
+ {
+ uc <<= 6;
+ uc |= (*++bytes & 0x3F);
+ }
+ return uc;
+ }
+}
+
+
+int UTF8Encoding::sequenceLength(const unsigned char* bytes, int length) const
+{
+ if (1 <= length)
+ {
+ int cc = _charMap[*bytes];
+ if (cc >= 0)
+ return 1;
+ else
+ return -cc;
+ }
+ else return -1;
+}
+
+
+bool UTF8Encoding::isLegal(const unsigned char *bytes, int length)
+{
+ // Note: The following is loosely based on the isLegalUTF8 function
+ // from ftp://ftp.unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.c
+ // Excuse the ugliness...
+
+ if (0 == bytes || 0 == length) return false;
+
+ unsigned char a;
+ const unsigned char* srcptr = bytes + length;
+ switch (length)
+ {
+ default:
+ return false;
+ // Everything else falls through when true.
+ case 4:
+ if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
+ case 3:
+ if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
+ case 2:
+ a = (*--srcptr);
+ switch (*bytes)
+ {
+ case 0xE0:
+ if (a < 0xA0 || a > 0xBF) return false;
+ break;
+ case 0xED:
+ if (a < 0x80 || a > 0x9F) return false;
+ break;
+ case 0xF0:
+ if (a < 0x90 || a > 0xBF) return false;
+ break;
+ case 0xF4:
+ if (a < 0x80 || a > 0x8F) return false;
+ break;
+ default:
+ if (a < 0x80 || a > 0xBF) return false;
+ }
+ case 1:
+ if (*bytes >= 0x80 && *bytes < 0xC2) return false;
+ }
+ return *bytes <= 0xF4;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/UTF8String.cpp b/contrib/libs/poco/Foundation/src/UTF8String.cpp
index e9ef4170b9..39bb2ee25f 100644
--- a/contrib/libs/poco/Foundation/src/UTF8String.cpp
+++ b/contrib/libs/poco/Foundation/src/UTF8String.cpp
@@ -1,377 +1,377 @@
-//
-// UTF8String.cpp
-//
-// Library: Foundation
-// Package: Text
-// Module: UTF8String
-//
-// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/UTF8String.h"
-#include "Poco/Unicode.h"
-#include "Poco/TextIterator.h"
-#include "Poco/TextConverter.h"
-#include "Poco/UTF8Encoding.h"
-#include "Poco/NumberFormatter.h"
-#include "Poco/Ascii.h"
-#include <algorithm>
-
-
-namespace Poco {
-
-
-namespace
-{
- static UTF8Encoding utf8;
-}
-
-
-int UTF8::icompare(const std::string& str, std::string::size_type pos, std::string::size_type n, std::string::const_iterator it2, std::string::const_iterator end2)
-{
- std::string::size_type sz = str.size();
- if (pos > sz) pos = sz;
- if (pos + n > sz) n = sz - pos;
- TextIterator uit1(str.begin() + pos, str.begin() + pos + n, utf8);
- TextIterator uend1(str.begin() + pos + n);
- TextIterator uit2(it2, end2, utf8);
- TextIterator uend2(end2);
- while (uit1 != uend1 && uit2 != uend2)
- {
- int c1 = Unicode::toLower(*uit1);
- int c2 = Unicode::toLower(*uit2);
- if (c1 < c2)
- return -1;
- else if (c1 > c2)
- return 1;
- ++uit1; ++uit2;
- }
-
- if (uit1 == uend1)
- return uit2 == uend2 ? 0 : -1;
- else
- return 1;
-}
-
-
-int UTF8::icompare(const std::string& str1, const std::string& str2)
-{
- return icompare(str1, 0, str1.size(), str2.begin(), str2.end());
-}
-
-
-int UTF8::icompare(const std::string& str1, std::string::size_type n1, const std::string& str2, std::string::size_type n2)
-{
- if (n2 > str2.size()) n2 = str2.size();
- return icompare(str1, 0, n1, str2.begin(), str2.begin() + n2);
-}
-
-
-int UTF8::icompare(const std::string& str1, std::string::size_type n, const std::string& str2)
-{
- if (n > str2.size()) n = str2.size();
- return icompare(str1, 0, n, str2.begin(), str2.begin() + n);
-}
-
-
-int UTF8::icompare(const std::string& str1, std::string::size_type pos, std::string::size_type n, const std::string& str2)
-{
- return icompare(str1, pos, n, str2.begin(), str2.end());
-}
-
-
-int UTF8::icompare(const std::string& str1, std::string::size_type pos1, std::string::size_type n1, const std::string& str2, std::string::size_type pos2, std::string::size_type n2)
-{
- std::string::size_type sz2 = str2.size();
- if (pos2 > sz2) pos2 = sz2;
- if (pos2 + n2 > sz2) n2 = sz2 - pos2;
- return icompare(str1, pos1, n1, str2.begin() + pos2, str2.begin() + pos2 + n2);
-}
-
-
-int UTF8::icompare(const std::string& str1, std::string::size_type pos1, std::string::size_type n, const std::string& str2, std::string::size_type pos2)
-{
- std::string::size_type sz2 = str2.size();
- if (pos2 > sz2) pos2 = sz2;
- if (pos2 + n > sz2) n = sz2 - pos2;
- return icompare(str1, pos1, n, str2.begin() + pos2, str2.begin() + pos2 + n);
-}
-
-
-int UTF8::icompare(const std::string& str, std::string::size_type pos, std::string::size_type n, const std::string::value_type* ptr)
-{
- poco_check_ptr (ptr);
- std::string str2(ptr); // TODO: optimize
- return icompare(str, pos, n, str2.begin(), str2.end());
-}
-
-
-int UTF8::icompare(const std::string& str, std::string::size_type pos, const std::string::value_type* ptr)
-{
- return icompare(str, pos, str.size() - pos, ptr);
-}
-
-
-int UTF8::icompare(const std::string& str, const std::string::value_type* ptr)
-{
- return icompare(str, 0, str.size(), ptr);
-}
-
-
-std::string UTF8::toUpper(const std::string& str)
-{
- std::string result;
- TextConverter converter(utf8, utf8);
- converter.convert(str, result, Unicode::toUpper);
- return result;
-}
-
-
-std::string& UTF8::toUpperInPlace(std::string& str)
-{
- std::string result;
- TextConverter converter(utf8, utf8);
- converter.convert(str, result, Unicode::toUpper);
- std::swap(str, result);
- return str;
-}
-
-
-std::string UTF8::toLower(const std::string& str)
-{
- std::string result;
- TextConverter converter(utf8, utf8);
- converter.convert(str, result, Unicode::toLower);
- return result;
-}
-
-
-std::string& UTF8::toLowerInPlace(std::string& str)
-{
- std::string result;
- TextConverter converter(utf8, utf8);
- converter.convert(str, result, Unicode::toLower);
- std::swap(str, result);
- return str;
-}
-
-
-void UTF8::removeBOM(std::string& str)
-{
- if (str.size() >= 3
- && static_cast<unsigned char>(str[0]) == 0xEF
- && static_cast<unsigned char>(str[1]) == 0xBB
- && static_cast<unsigned char>(str[2]) == 0xBF)
- {
- str.erase(0, 3);
- }
-}
-
-
-std::string UTF8::escape(const std::string &s, bool strictJSON)
-{
- return escape(s.begin(), s.end(), strictJSON);
-}
-
-
-std::string UTF8::escape(const std::string::const_iterator& begin, const std::string::const_iterator& end, bool strictJSON)
-{
- static Poco::UInt32 offsetsFromUTF8[6] = {
- 0x00000000UL, 0x00003080UL, 0x000E2080UL,
- 0x03C82080UL, 0xFA082080UL, 0x82082080UL
- };
-
- std::string result;
-
- std::string::const_iterator it = begin;
-
- while(it != end)
- {
- Poco::UInt32 ch = 0;
- unsigned int sz = 0;
-
- do
- {
- ch <<= 6;
- ch += (unsigned char)*it++;
- sz++;
- }
- while (it != end && (*it & 0xC0) == 0x80 && sz < 6);
- ch -= offsetsFromUTF8[sz-1];
-
- if (ch == '\n') result += "\\n";
- else if (ch == '\t') result += "\\t";
- else if (ch == '\r') result += "\\r";
- else if (ch == '\b') result += "\\b";
- else if (ch == '\f') result += "\\f";
- else if (ch == '\v') result += (strictJSON ? "\\u000B" : "\\v");
- else if (ch == '\a') result += (strictJSON ? "\\u0007" : "\\a");
- else if (ch == '\\') result += "\\\\";
- else if (ch == '\"') result += "\\\"";
- else if (ch == '/') result += "\\/";
- else if (ch == '\0') result += "\\u0000";
- else if (ch < 32 || ch == 0x7f)
- {
- result += "\\u";
- NumberFormatter::appendHex(result, (unsigned short) ch, 4);
- }
- else if (ch > 0xFFFF)
- {
- ch -= 0x10000;
- result += "\\u";
- NumberFormatter::appendHex(result, (unsigned short) (( ch >> 10 ) & 0x03ff ) + 0xd800, 4);
- result += "\\u";
- NumberFormatter::appendHex(result, (unsigned short) (ch & 0x03ff ) + 0xdc00, 4);
- }
- else if (ch >= 0x80 && ch <= 0xFFFF)
- {
- result += "\\u";
- NumberFormatter::appendHex(result, (unsigned short) ch, 4);
- }
- else
- {
- result += (char) ch;
- }
- }
- return result;
-}
-
-
-std::string UTF8::unescape(const std::string &s)
-{
- return unescape(s.begin(), s.end());
-}
-
-
-std::string UTF8::unescape(const std::string::const_iterator& begin, const std::string::const_iterator& end)
-{
- std::string result;
-
- std::string::const_iterator it = begin;
-
- while (it != end)
- {
- Poco::UInt32 ch = (Poco::UInt32) *it++;
-
- if (ch == '\\')
- {
- if ( it == end )
- {
- //Invalid sequence!
- }
-
- if (*it == 'n')
- {
- ch = '\n';
- it++;
- }
- else if (*it == 't')
- {
- ch = '\t';
- it++;
- }
- else if (*it == 'r')
- {
- ch = '\r';
- it++;
- }
- else if (*it == 'b')
- {
- ch = '\b';
- it++;
- }
- else if (*it == 'f')
- {
- ch = '\f';
- it++;
- }
- else if (*it == 'v')
- {
- ch = '\v';
- it++;
- }
- else if (*it == 'a')
- {
- ch = '\a';
- it++;
- }
- else if (*it == 'u')
- {
- char digs[5];
- std::memset(digs, 0, 5);
- unsigned int dno = 0;
-
- it++;
-
- while (it != end && Ascii::isHexDigit(*it) && dno < 4) digs[dno++] = *it++;
- if (dno > 0)
- {
- ch = std::strtol(digs, NULL, 16);
- }
-
- if( ch >= 0xD800 && ch <= 0xDBFF )
- {
- if ( it == end || *it != '\\' )
- {
- //Invalid sequence!
- }
- else
- {
- it++;
- if ( it == end || *it != 'u' )
- {
- //Invalid sequence!
- }
- else
- {
- it++;
- }
- }
-
- // UTF-16 surrogate pair. Go fetch other half
- std::memset(digs, 0, 5);
- dno = 0;
- while (it != end && Ascii::isHexDigit(*it) && dno < 4) digs[dno++] = *it++;
- if (dno > 0)
- {
- Poco::UInt32 temp = std::strtol(digs, NULL, 16);
- if( temp >= 0xDC00 && temp <= 0xDFFF )
- {
- ch = ( ( ( ch - 0xD800 ) << 10 ) | ( temp - 0xDC00 ) ) + 0x10000;
- }
- }
- }
- }
- else if (*it == 'U')
- {
- char digs[9];
- std::memset(digs, 0, 9);
- unsigned int dno = 0;
-
- it++;
- while (it != end && Ascii::isHexDigit(*it) && dno < 8)
- {
- digs[dno++] = *it++;
- }
- if (dno > 0)
- {
- ch = std::strtol(digs, NULL, 16);
- }
- }
- }
-
- unsigned char utf8Code[4];
- UTF8Encoding encoding;
- int sz = encoding.convert(ch, utf8Code, 4);
- result.append((char*)utf8Code, sz);
- }
-
- return result;
-}
-
-
-} // namespace Poco
+//
+// UTF8String.cpp
+//
+// Library: Foundation
+// Package: Text
+// Module: UTF8String
+//
+// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/UTF8String.h"
+#include "Poco/Unicode.h"
+#include "Poco/TextIterator.h"
+#include "Poco/TextConverter.h"
+#include "Poco/UTF8Encoding.h"
+#include "Poco/NumberFormatter.h"
+#include "Poco/Ascii.h"
+#include <algorithm>
+
+
+namespace Poco {
+
+
+namespace
+{
+ static UTF8Encoding utf8;
+}
+
+
+int UTF8::icompare(const std::string& str, std::string::size_type pos, std::string::size_type n, std::string::const_iterator it2, std::string::const_iterator end2)
+{
+ std::string::size_type sz = str.size();
+ if (pos > sz) pos = sz;
+ if (pos + n > sz) n = sz - pos;
+ TextIterator uit1(str.begin() + pos, str.begin() + pos + n, utf8);
+ TextIterator uend1(str.begin() + pos + n);
+ TextIterator uit2(it2, end2, utf8);
+ TextIterator uend2(end2);
+ while (uit1 != uend1 && uit2 != uend2)
+ {
+ int c1 = Unicode::toLower(*uit1);
+ int c2 = Unicode::toLower(*uit2);
+ if (c1 < c2)
+ return -1;
+ else if (c1 > c2)
+ return 1;
+ ++uit1; ++uit2;
+ }
+
+ if (uit1 == uend1)
+ return uit2 == uend2 ? 0 : -1;
+ else
+ return 1;
+}
+
+
+int UTF8::icompare(const std::string& str1, const std::string& str2)
+{
+ return icompare(str1, 0, str1.size(), str2.begin(), str2.end());
+}
+
+
+int UTF8::icompare(const std::string& str1, std::string::size_type n1, const std::string& str2, std::string::size_type n2)
+{
+ if (n2 > str2.size()) n2 = str2.size();
+ return icompare(str1, 0, n1, str2.begin(), str2.begin() + n2);
+}
+
+
+int UTF8::icompare(const std::string& str1, std::string::size_type n, const std::string& str2)
+{
+ if (n > str2.size()) n = str2.size();
+ return icompare(str1, 0, n, str2.begin(), str2.begin() + n);
+}
+
+
+int UTF8::icompare(const std::string& str1, std::string::size_type pos, std::string::size_type n, const std::string& str2)
+{
+ return icompare(str1, pos, n, str2.begin(), str2.end());
+}
+
+
+int UTF8::icompare(const std::string& str1, std::string::size_type pos1, std::string::size_type n1, const std::string& str2, std::string::size_type pos2, std::string::size_type n2)
+{
+ std::string::size_type sz2 = str2.size();
+ if (pos2 > sz2) pos2 = sz2;
+ if (pos2 + n2 > sz2) n2 = sz2 - pos2;
+ return icompare(str1, pos1, n1, str2.begin() + pos2, str2.begin() + pos2 + n2);
+}
+
+
+int UTF8::icompare(const std::string& str1, std::string::size_type pos1, std::string::size_type n, const std::string& str2, std::string::size_type pos2)
+{
+ std::string::size_type sz2 = str2.size();
+ if (pos2 > sz2) pos2 = sz2;
+ if (pos2 + n > sz2) n = sz2 - pos2;
+ return icompare(str1, pos1, n, str2.begin() + pos2, str2.begin() + pos2 + n);
+}
+
+
+int UTF8::icompare(const std::string& str, std::string::size_type pos, std::string::size_type n, const std::string::value_type* ptr)
+{
+ poco_check_ptr (ptr);
+ std::string str2(ptr); // TODO: optimize
+ return icompare(str, pos, n, str2.begin(), str2.end());
+}
+
+
+int UTF8::icompare(const std::string& str, std::string::size_type pos, const std::string::value_type* ptr)
+{
+ return icompare(str, pos, str.size() - pos, ptr);
+}
+
+
+int UTF8::icompare(const std::string& str, const std::string::value_type* ptr)
+{
+ return icompare(str, 0, str.size(), ptr);
+}
+
+
+std::string UTF8::toUpper(const std::string& str)
+{
+ std::string result;
+ TextConverter converter(utf8, utf8);
+ converter.convert(str, result, Unicode::toUpper);
+ return result;
+}
+
+
+std::string& UTF8::toUpperInPlace(std::string& str)
+{
+ std::string result;
+ TextConverter converter(utf8, utf8);
+ converter.convert(str, result, Unicode::toUpper);
+ std::swap(str, result);
+ return str;
+}
+
+
+std::string UTF8::toLower(const std::string& str)
+{
+ std::string result;
+ TextConverter converter(utf8, utf8);
+ converter.convert(str, result, Unicode::toLower);
+ return result;
+}
+
+
+std::string& UTF8::toLowerInPlace(std::string& str)
+{
+ std::string result;
+ TextConverter converter(utf8, utf8);
+ converter.convert(str, result, Unicode::toLower);
+ std::swap(str, result);
+ return str;
+}
+
+
+void UTF8::removeBOM(std::string& str)
+{
+ if (str.size() >= 3
+ && static_cast<unsigned char>(str[0]) == 0xEF
+ && static_cast<unsigned char>(str[1]) == 0xBB
+ && static_cast<unsigned char>(str[2]) == 0xBF)
+ {
+ str.erase(0, 3);
+ }
+}
+
+
+std::string UTF8::escape(const std::string &s, bool strictJSON)
+{
+ return escape(s.begin(), s.end(), strictJSON);
+}
+
+
+std::string UTF8::escape(const std::string::const_iterator& begin, const std::string::const_iterator& end, bool strictJSON)
+{
+ static Poco::UInt32 offsetsFromUTF8[6] = {
+ 0x00000000UL, 0x00003080UL, 0x000E2080UL,
+ 0x03C82080UL, 0xFA082080UL, 0x82082080UL
+ };
+
+ std::string result;
+
+ std::string::const_iterator it = begin;
+
+ while(it != end)
+ {
+ Poco::UInt32 ch = 0;
+ unsigned int sz = 0;
+
+ do
+ {
+ ch <<= 6;
+ ch += (unsigned char)*it++;
+ sz++;
+ }
+ while (it != end && (*it & 0xC0) == 0x80 && sz < 6);
+ ch -= offsetsFromUTF8[sz-1];
+
+ if (ch == '\n') result += "\\n";
+ else if (ch == '\t') result += "\\t";
+ else if (ch == '\r') result += "\\r";
+ else if (ch == '\b') result += "\\b";
+ else if (ch == '\f') result += "\\f";
+ else if (ch == '\v') result += (strictJSON ? "\\u000B" : "\\v");
+ else if (ch == '\a') result += (strictJSON ? "\\u0007" : "\\a");
+ else if (ch == '\\') result += "\\\\";
+ else if (ch == '\"') result += "\\\"";
+ else if (ch == '/') result += "\\/";
+ else if (ch == '\0') result += "\\u0000";
+ else if (ch < 32 || ch == 0x7f)
+ {
+ result += "\\u";
+ NumberFormatter::appendHex(result, (unsigned short) ch, 4);
+ }
+ else if (ch > 0xFFFF)
+ {
+ ch -= 0x10000;
+ result += "\\u";
+ NumberFormatter::appendHex(result, (unsigned short) (( ch >> 10 ) & 0x03ff ) + 0xd800, 4);
+ result += "\\u";
+ NumberFormatter::appendHex(result, (unsigned short) (ch & 0x03ff ) + 0xdc00, 4);
+ }
+ else if (ch >= 0x80 && ch <= 0xFFFF)
+ {
+ result += "\\u";
+ NumberFormatter::appendHex(result, (unsigned short) ch, 4);
+ }
+ else
+ {
+ result += (char) ch;
+ }
+ }
+ return result;
+}
+
+
+std::string UTF8::unescape(const std::string &s)
+{
+ return unescape(s.begin(), s.end());
+}
+
+
+std::string UTF8::unescape(const std::string::const_iterator& begin, const std::string::const_iterator& end)
+{
+ std::string result;
+
+ std::string::const_iterator it = begin;
+
+ while (it != end)
+ {
+ Poco::UInt32 ch = (Poco::UInt32) *it++;
+
+ if (ch == '\\')
+ {
+ if ( it == end )
+ {
+ //Invalid sequence!
+ }
+
+ if (*it == 'n')
+ {
+ ch = '\n';
+ it++;
+ }
+ else if (*it == 't')
+ {
+ ch = '\t';
+ it++;
+ }
+ else if (*it == 'r')
+ {
+ ch = '\r';
+ it++;
+ }
+ else if (*it == 'b')
+ {
+ ch = '\b';
+ it++;
+ }
+ else if (*it == 'f')
+ {
+ ch = '\f';
+ it++;
+ }
+ else if (*it == 'v')
+ {
+ ch = '\v';
+ it++;
+ }
+ else if (*it == 'a')
+ {
+ ch = '\a';
+ it++;
+ }
+ else if (*it == 'u')
+ {
+ char digs[5];
+ std::memset(digs, 0, 5);
+ unsigned int dno = 0;
+
+ it++;
+
+ while (it != end && Ascii::isHexDigit(*it) && dno < 4) digs[dno++] = *it++;
+ if (dno > 0)
+ {
+ ch = std::strtol(digs, NULL, 16);
+ }
+
+ if( ch >= 0xD800 && ch <= 0xDBFF )
+ {
+ if ( it == end || *it != '\\' )
+ {
+ //Invalid sequence!
+ }
+ else
+ {
+ it++;
+ if ( it == end || *it != 'u' )
+ {
+ //Invalid sequence!
+ }
+ else
+ {
+ it++;
+ }
+ }
+
+ // UTF-16 surrogate pair. Go fetch other half
+ std::memset(digs, 0, 5);
+ dno = 0;
+ while (it != end && Ascii::isHexDigit(*it) && dno < 4) digs[dno++] = *it++;
+ if (dno > 0)
+ {
+ Poco::UInt32 temp = std::strtol(digs, NULL, 16);
+ if( temp >= 0xDC00 && temp <= 0xDFFF )
+ {
+ ch = ( ( ( ch - 0xD800 ) << 10 ) | ( temp - 0xDC00 ) ) + 0x10000;
+ }
+ }
+ }
+ }
+ else if (*it == 'U')
+ {
+ char digs[9];
+ std::memset(digs, 0, 9);
+ unsigned int dno = 0;
+
+ it++;
+ while (it != end && Ascii::isHexDigit(*it) && dno < 8)
+ {
+ digs[dno++] = *it++;
+ }
+ if (dno > 0)
+ {
+ ch = std::strtol(digs, NULL, 16);
+ }
+ }
+ }
+
+ unsigned char utf8Code[4];
+ UTF8Encoding encoding;
+ int sz = encoding.convert(ch, utf8Code, 4);
+ result.append((char*)utf8Code, sz);
+ }
+
+ return result;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/UUID.cpp b/contrib/libs/poco/Foundation/src/UUID.cpp
index a47cfb443c..42eb758fbf 100644
--- a/contrib/libs/poco/Foundation/src/UUID.cpp
+++ b/contrib/libs/poco/Foundation/src/UUID.cpp
@@ -1,370 +1,370 @@
-//
-// UUID.cpp
-//
-// Library: Foundation
-// Package: UUID
-// Module: UUID
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/UUID.h"
-#include "Poco/ByteOrder.h"
-#include "Poco/Exception.h"
-#include <algorithm>
-#include <cstring>
-
-
-namespace Poco {
-
-
-UUID::UUID():
- _timeLow(0),
- _timeMid(0),
- _timeHiAndVersion(0),
- _clockSeq(0)
-{
- std::memset(_node, 0, sizeof(_node));
-}
-
-
-UUID::UUID(const UUID& uuid):
- _timeLow(uuid._timeLow),
- _timeMid(uuid._timeMid),
- _timeHiAndVersion(uuid._timeHiAndVersion),
- _clockSeq(uuid._clockSeq)
-{
- std::memcpy(_node, uuid._node, sizeof(_node));
-}
-
-
-UUID::UUID(const std::string& uuid)
-{
- parse(uuid);
-}
-
-
-UUID::UUID(const char* uuid)
-{
- poco_check_ptr (uuid);
- parse(std::string(uuid));
-}
-
-
-UUID::UUID(UInt32 timeLow, UInt32 timeMid, UInt32 timeHiAndVersion, UInt16 clockSeq, UInt8 node[]):
- _timeLow(static_cast<UInt16>(timeLow)),
- _timeMid(static_cast<UInt16>(timeMid)),
- _timeHiAndVersion(static_cast<UInt16>(timeHiAndVersion)),
- _clockSeq(clockSeq)
-{
- std::memcpy(_node, node, sizeof(_node));
-}
-
-
-UUID::UUID(const char* bytes, Version uuidVersion)
-{
- UInt32 i32;
- UInt16 i16;
- std::memcpy(&i32, bytes, sizeof(i32));
- _timeLow = ByteOrder::fromNetwork(i32);
- bytes += sizeof(i32);
- std::memcpy(&i16, bytes, sizeof(i16));
- _timeMid = ByteOrder::fromNetwork(i16);
- bytes += sizeof(i16);
- std::memcpy(&i16, bytes, sizeof(i16));
- _timeHiAndVersion = ByteOrder::fromNetwork(i16);
- bytes += sizeof(i16);
- std::memcpy(&i16, bytes, sizeof(i16));
- _clockSeq = ByteOrder::fromNetwork(i16);
- bytes += sizeof(i16);
- std::memcpy(_node, bytes, sizeof(_node));
-
- _timeHiAndVersion &= 0x0FFF;
- _timeHiAndVersion |= (uuidVersion << 12);
- _clockSeq &= 0x3FFF;
- _clockSeq |= 0x8000;
-}
-
-
-UUID::~UUID()
-{
-}
-
-
-UUID& UUID::operator = (const UUID& uuid)
-{
- if (&uuid != this)
- {
- _timeLow = uuid._timeLow;
- _timeMid = uuid._timeMid;
- _timeHiAndVersion = uuid._timeHiAndVersion;
- _clockSeq = uuid._clockSeq;
- std::memcpy(_node, uuid._node, sizeof(_node));
- }
- return *this;
-}
-
-
-void UUID::swap(UUID& uuid)
-{
- std::swap(_timeLow, uuid._timeLow);
- std::swap(_timeMid, uuid._timeMid);
- std::swap(_timeHiAndVersion, uuid._timeHiAndVersion);
- std::swap(_clockSeq, uuid._clockSeq);
- std::swap_ranges(_node, _node + 6, &uuid._node[0]);
-}
-
-
-void UUID::parse(const std::string& uuid)
-{
- if (!tryParse(uuid))
- throw SyntaxException(uuid);
-}
-
-
-bool UUID::tryParse(const std::string& uuid)
-{
- if (uuid.size() < 32)
- return false;
-
- bool haveHyphens = false;
- if (uuid[8] == '-' && uuid[13] == '-' && uuid[18] == '-' && uuid[23] == '-')
- {
- if (uuid.size() >= 36)
- haveHyphens = true;
- else
- return false;
- }
-
- UUID newUUID;
- std::string::const_iterator it = uuid.begin();
- newUUID._timeLow = 0;
- for (int i = 0; i < 8; ++i)
- {
- Int16 n = nibble(*it++);
- if (n < 0) return false;
- newUUID._timeLow = (newUUID._timeLow << 4) | n;
- }
- if (haveHyphens) ++it;
- newUUID._timeMid = 0;
- for (int i = 0; i < 4; ++i)
- {
- Int16 n = nibble(*it++);
- if (n < 0) return false;
- newUUID._timeMid = (newUUID._timeMid << 4) | n;
- }
- if (haveHyphens) ++it;
- newUUID._timeHiAndVersion = 0;
- for (int i = 0; i < 4; ++i)
- {
- Int16 n = nibble(*it++);
- if (n < 0) return false;
- newUUID._timeHiAndVersion = (newUUID._timeHiAndVersion << 4) | n;
- }
- if (haveHyphens) ++it;
- newUUID._clockSeq = 0;
- for (int i = 0; i < 4; ++i)
- {
- Int16 n = nibble(*it++);
- if (n < 0) return false;
- newUUID._clockSeq = (newUUID._clockSeq << 4) | n;
- }
- if (haveHyphens) ++it;
- for (int i = 0; i < 6; ++i)
- {
- Int16 n1 = nibble(*it++);
- if (n1 < 0) return false;
- Int16 n2 = nibble(*it++);
- if (n2 < 0) return false;
-
- newUUID._node[i] = static_cast<UInt8>((n1 << 4) | n2);
- }
- swap(newUUID);
-
- return true;
-}
-
-
-std::string UUID::toString() const
-{
- std::string result;
- result.reserve(36);
- appendHex(result, _timeLow);
- result += '-';
- appendHex(result, _timeMid);
- result += '-';
- appendHex(result, _timeHiAndVersion);
- result += '-';
- appendHex(result, _clockSeq);
- result += '-';
- for (int i = 0; i < sizeof(_node); ++i)
- appendHex(result, _node[i]);
- return result;
-}
-
-
-void UUID::copyFrom(const char* buffer)
-{
- UInt32 i32;
- UInt16 i16;
- std::memcpy(&i32, buffer, sizeof(i32));
- _timeLow = ByteOrder::fromNetwork(i32);
- buffer += sizeof(i32);
- std::memcpy(&i16, buffer, sizeof(i16));
- _timeMid = ByteOrder::fromNetwork(i16);
- buffer += sizeof(i16);
- std::memcpy(&i16, buffer, sizeof(i16));
- _timeHiAndVersion = ByteOrder::fromNetwork(i16);
- buffer += sizeof(i16);
- std::memcpy(&i16, buffer, sizeof(i16));
- _clockSeq = ByteOrder::fromNetwork(i16);
- buffer += sizeof(i16);
- std::memcpy(_node, buffer, sizeof(_node));
-}
-
-
-void UUID::copyTo(char* buffer) const
-{
- UInt32 i32 = ByteOrder::toNetwork(_timeLow);
- std::memcpy(buffer, &i32, sizeof(i32));
- buffer += sizeof(i32);
- UInt16 i16 = ByteOrder::toNetwork(_timeMid);
- std::memcpy(buffer, &i16, sizeof(i16));
- buffer += sizeof(i16);
- i16 = ByteOrder::toNetwork(_timeHiAndVersion);
- std::memcpy(buffer, &i16, sizeof(i16));
- buffer += sizeof(i16);
- i16 = ByteOrder::toNetwork(_clockSeq);
- std::memcpy(buffer, &i16, sizeof(i16));
- buffer += sizeof(i16);
- std::memcpy(buffer, _node, sizeof(_node));
-}
-
-
-int UUID::variant() const
-{
- int v = _clockSeq >> 13;
- if ((v & 6) == 6)
- return v;
- else if (v & 4)
- return 2;
- else
- return 0;
-}
-
-
-int UUID::compare(const UUID& uuid) const
-{
- if (_timeLow != uuid._timeLow) return _timeLow < uuid._timeLow ? -1 : 1;
- if (_timeMid != uuid._timeMid) return _timeMid < uuid._timeMid ? -1 : 1;
- if (_timeHiAndVersion != uuid._timeHiAndVersion) return _timeHiAndVersion < uuid._timeHiAndVersion ? -1 : 1;
- if (_clockSeq != uuid._clockSeq) return _clockSeq < uuid._clockSeq ? -1 : 1;
- for (int i = 0; i < sizeof(_node); ++i)
- {
- if (_node[i] < uuid._node[i])
- return -1;
- else if (_node[i] > uuid._node[i])
- return 1;
- }
- return 0;
-}
-
-
-void UUID::appendHex(std::string& str, UInt8 n)
-{
- static const char* digits = "0123456789abcdef";
- str += digits[(n >> 4) & 0xF];
- str += digits[n & 0xF];
-}
-
-
-void UUID::appendHex(std::string& str, UInt16 n)
-{
- appendHex(str, UInt8(n >> 8));
- appendHex(str, UInt8(n & 0xFF));
-}
-
-
-void UUID::appendHex(std::string& str, UInt32 n)
-{
- appendHex(str, UInt16(n >> 16));
- appendHex(str, UInt16(n & 0xFFFF));
-}
-
-
-Int16 UUID::nibble(char hex)
-{
- if (hex >= 'a' && hex <= 'f')
- return hex - 'a' + 10;
- else if (hex >= 'A' && hex <= 'F')
- return hex - 'A' + 10;
- else if (hex >= '0' && hex <= '9')
- return hex - '0';
- else
- return -1;
-}
-
-
-void UUID::fromNetwork()
-{
- _timeLow = ByteOrder::fromNetwork(_timeLow);
- _timeMid = ByteOrder::fromNetwork(_timeMid);
- _timeHiAndVersion = ByteOrder::fromNetwork(_timeHiAndVersion);
- _clockSeq = ByteOrder::fromNetwork(_clockSeq);
-}
-
-
-void UUID::toNetwork()
-{
- _timeLow = ByteOrder::toNetwork(_timeLow);
- _timeMid = ByteOrder::toNetwork(_timeMid);
- _timeHiAndVersion = ByteOrder::toNetwork(_timeHiAndVersion);
- _clockSeq = ByteOrder::toNetwork(_clockSeq);
-}
-
-
-namespace
-{
- static UUID uuidNull;
- static UUID uuidDNS("6ba7b810-9dad-11d1-80b4-00c04fd430c8");
- static UUID uuidURI("6ba7b811-9dad-11d1-80b4-00c04fd430c8");
- static UUID uuidOID("6ba7b812-9dad-11d1-80b4-00c04fd430c8");
- static UUID uuidX500("6ba7b814-9dad-11d1-80b4-00c04fd430c8");
-}
-
-
-const UUID& UUID::null()
-{
- return uuidNull;
-}
-
-
-const UUID& UUID::dns()
-{
- return uuidDNS;
-}
-
-
-const UUID& UUID::uri()
-{
- return uuidURI;
-}
-
-
-const UUID& UUID::oid()
-{
- return uuidOID;
-}
-
-
-const UUID& UUID::x500()
-{
- return uuidX500;
-}
-
-
-} // namespace Poco
+//
+// UUID.cpp
+//
+// Library: Foundation
+// Package: UUID
+// Module: UUID
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/UUID.h"
+#include "Poco/ByteOrder.h"
+#include "Poco/Exception.h"
+#include <algorithm>
+#include <cstring>
+
+
+namespace Poco {
+
+
+UUID::UUID():
+ _timeLow(0),
+ _timeMid(0),
+ _timeHiAndVersion(0),
+ _clockSeq(0)
+{
+ std::memset(_node, 0, sizeof(_node));
+}
+
+
+UUID::UUID(const UUID& uuid):
+ _timeLow(uuid._timeLow),
+ _timeMid(uuid._timeMid),
+ _timeHiAndVersion(uuid._timeHiAndVersion),
+ _clockSeq(uuid._clockSeq)
+{
+ std::memcpy(_node, uuid._node, sizeof(_node));
+}
+
+
+UUID::UUID(const std::string& uuid)
+{
+ parse(uuid);
+}
+
+
+UUID::UUID(const char* uuid)
+{
+ poco_check_ptr (uuid);
+ parse(std::string(uuid));
+}
+
+
+UUID::UUID(UInt32 timeLow, UInt32 timeMid, UInt32 timeHiAndVersion, UInt16 clockSeq, UInt8 node[]):
+ _timeLow(static_cast<UInt16>(timeLow)),
+ _timeMid(static_cast<UInt16>(timeMid)),
+ _timeHiAndVersion(static_cast<UInt16>(timeHiAndVersion)),
+ _clockSeq(clockSeq)
+{
+ std::memcpy(_node, node, sizeof(_node));
+}
+
+
+UUID::UUID(const char* bytes, Version uuidVersion)
+{
+ UInt32 i32;
+ UInt16 i16;
+ std::memcpy(&i32, bytes, sizeof(i32));
+ _timeLow = ByteOrder::fromNetwork(i32);
+ bytes += sizeof(i32);
+ std::memcpy(&i16, bytes, sizeof(i16));
+ _timeMid = ByteOrder::fromNetwork(i16);
+ bytes += sizeof(i16);
+ std::memcpy(&i16, bytes, sizeof(i16));
+ _timeHiAndVersion = ByteOrder::fromNetwork(i16);
+ bytes += sizeof(i16);
+ std::memcpy(&i16, bytes, sizeof(i16));
+ _clockSeq = ByteOrder::fromNetwork(i16);
+ bytes += sizeof(i16);
+ std::memcpy(_node, bytes, sizeof(_node));
+
+ _timeHiAndVersion &= 0x0FFF;
+ _timeHiAndVersion |= (uuidVersion << 12);
+ _clockSeq &= 0x3FFF;
+ _clockSeq |= 0x8000;
+}
+
+
+UUID::~UUID()
+{
+}
+
+
+UUID& UUID::operator = (const UUID& uuid)
+{
+ if (&uuid != this)
+ {
+ _timeLow = uuid._timeLow;
+ _timeMid = uuid._timeMid;
+ _timeHiAndVersion = uuid._timeHiAndVersion;
+ _clockSeq = uuid._clockSeq;
+ std::memcpy(_node, uuid._node, sizeof(_node));
+ }
+ return *this;
+}
+
+
+void UUID::swap(UUID& uuid)
+{
+ std::swap(_timeLow, uuid._timeLow);
+ std::swap(_timeMid, uuid._timeMid);
+ std::swap(_timeHiAndVersion, uuid._timeHiAndVersion);
+ std::swap(_clockSeq, uuid._clockSeq);
+ std::swap_ranges(_node, _node + 6, &uuid._node[0]);
+}
+
+
+void UUID::parse(const std::string& uuid)
+{
+ if (!tryParse(uuid))
+ throw SyntaxException(uuid);
+}
+
+
+bool UUID::tryParse(const std::string& uuid)
+{
+ if (uuid.size() < 32)
+ return false;
+
+ bool haveHyphens = false;
+ if (uuid[8] == '-' && uuid[13] == '-' && uuid[18] == '-' && uuid[23] == '-')
+ {
+ if (uuid.size() >= 36)
+ haveHyphens = true;
+ else
+ return false;
+ }
+
+ UUID newUUID;
+ std::string::const_iterator it = uuid.begin();
+ newUUID._timeLow = 0;
+ for (int i = 0; i < 8; ++i)
+ {
+ Int16 n = nibble(*it++);
+ if (n < 0) return false;
+ newUUID._timeLow = (newUUID._timeLow << 4) | n;
+ }
+ if (haveHyphens) ++it;
+ newUUID._timeMid = 0;
+ for (int i = 0; i < 4; ++i)
+ {
+ Int16 n = nibble(*it++);
+ if (n < 0) return false;
+ newUUID._timeMid = (newUUID._timeMid << 4) | n;
+ }
+ if (haveHyphens) ++it;
+ newUUID._timeHiAndVersion = 0;
+ for (int i = 0; i < 4; ++i)
+ {
+ Int16 n = nibble(*it++);
+ if (n < 0) return false;
+ newUUID._timeHiAndVersion = (newUUID._timeHiAndVersion << 4) | n;
+ }
+ if (haveHyphens) ++it;
+ newUUID._clockSeq = 0;
+ for (int i = 0; i < 4; ++i)
+ {
+ Int16 n = nibble(*it++);
+ if (n < 0) return false;
+ newUUID._clockSeq = (newUUID._clockSeq << 4) | n;
+ }
+ if (haveHyphens) ++it;
+ for (int i = 0; i < 6; ++i)
+ {
+ Int16 n1 = nibble(*it++);
+ if (n1 < 0) return false;
+ Int16 n2 = nibble(*it++);
+ if (n2 < 0) return false;
+
+ newUUID._node[i] = static_cast<UInt8>((n1 << 4) | n2);
+ }
+ swap(newUUID);
+
+ return true;
+}
+
+
+std::string UUID::toString() const
+{
+ std::string result;
+ result.reserve(36);
+ appendHex(result, _timeLow);
+ result += '-';
+ appendHex(result, _timeMid);
+ result += '-';
+ appendHex(result, _timeHiAndVersion);
+ result += '-';
+ appendHex(result, _clockSeq);
+ result += '-';
+ for (int i = 0; i < sizeof(_node); ++i)
+ appendHex(result, _node[i]);
+ return result;
+}
+
+
+void UUID::copyFrom(const char* buffer)
+{
+ UInt32 i32;
+ UInt16 i16;
+ std::memcpy(&i32, buffer, sizeof(i32));
+ _timeLow = ByteOrder::fromNetwork(i32);
+ buffer += sizeof(i32);
+ std::memcpy(&i16, buffer, sizeof(i16));
+ _timeMid = ByteOrder::fromNetwork(i16);
+ buffer += sizeof(i16);
+ std::memcpy(&i16, buffer, sizeof(i16));
+ _timeHiAndVersion = ByteOrder::fromNetwork(i16);
+ buffer += sizeof(i16);
+ std::memcpy(&i16, buffer, sizeof(i16));
+ _clockSeq = ByteOrder::fromNetwork(i16);
+ buffer += sizeof(i16);
+ std::memcpy(_node, buffer, sizeof(_node));
+}
+
+
+void UUID::copyTo(char* buffer) const
+{
+ UInt32 i32 = ByteOrder::toNetwork(_timeLow);
+ std::memcpy(buffer, &i32, sizeof(i32));
+ buffer += sizeof(i32);
+ UInt16 i16 = ByteOrder::toNetwork(_timeMid);
+ std::memcpy(buffer, &i16, sizeof(i16));
+ buffer += sizeof(i16);
+ i16 = ByteOrder::toNetwork(_timeHiAndVersion);
+ std::memcpy(buffer, &i16, sizeof(i16));
+ buffer += sizeof(i16);
+ i16 = ByteOrder::toNetwork(_clockSeq);
+ std::memcpy(buffer, &i16, sizeof(i16));
+ buffer += sizeof(i16);
+ std::memcpy(buffer, _node, sizeof(_node));
+}
+
+
+int UUID::variant() const
+{
+ int v = _clockSeq >> 13;
+ if ((v & 6) == 6)
+ return v;
+ else if (v & 4)
+ return 2;
+ else
+ return 0;
+}
+
+
+int UUID::compare(const UUID& uuid) const
+{
+ if (_timeLow != uuid._timeLow) return _timeLow < uuid._timeLow ? -1 : 1;
+ if (_timeMid != uuid._timeMid) return _timeMid < uuid._timeMid ? -1 : 1;
+ if (_timeHiAndVersion != uuid._timeHiAndVersion) return _timeHiAndVersion < uuid._timeHiAndVersion ? -1 : 1;
+ if (_clockSeq != uuid._clockSeq) return _clockSeq < uuid._clockSeq ? -1 : 1;
+ for (int i = 0; i < sizeof(_node); ++i)
+ {
+ if (_node[i] < uuid._node[i])
+ return -1;
+ else if (_node[i] > uuid._node[i])
+ return 1;
+ }
+ return 0;
+}
+
+
+void UUID::appendHex(std::string& str, UInt8 n)
+{
+ static const char* digits = "0123456789abcdef";
+ str += digits[(n >> 4) & 0xF];
+ str += digits[n & 0xF];
+}
+
+
+void UUID::appendHex(std::string& str, UInt16 n)
+{
+ appendHex(str, UInt8(n >> 8));
+ appendHex(str, UInt8(n & 0xFF));
+}
+
+
+void UUID::appendHex(std::string& str, UInt32 n)
+{
+ appendHex(str, UInt16(n >> 16));
+ appendHex(str, UInt16(n & 0xFFFF));
+}
+
+
+Int16 UUID::nibble(char hex)
+{
+ if (hex >= 'a' && hex <= 'f')
+ return hex - 'a' + 10;
+ else if (hex >= 'A' && hex <= 'F')
+ return hex - 'A' + 10;
+ else if (hex >= '0' && hex <= '9')
+ return hex - '0';
+ else
+ return -1;
+}
+
+
+void UUID::fromNetwork()
+{
+ _timeLow = ByteOrder::fromNetwork(_timeLow);
+ _timeMid = ByteOrder::fromNetwork(_timeMid);
+ _timeHiAndVersion = ByteOrder::fromNetwork(_timeHiAndVersion);
+ _clockSeq = ByteOrder::fromNetwork(_clockSeq);
+}
+
+
+void UUID::toNetwork()
+{
+ _timeLow = ByteOrder::toNetwork(_timeLow);
+ _timeMid = ByteOrder::toNetwork(_timeMid);
+ _timeHiAndVersion = ByteOrder::toNetwork(_timeHiAndVersion);
+ _clockSeq = ByteOrder::toNetwork(_clockSeq);
+}
+
+
+namespace
+{
+ static UUID uuidNull;
+ static UUID uuidDNS("6ba7b810-9dad-11d1-80b4-00c04fd430c8");
+ static UUID uuidURI("6ba7b811-9dad-11d1-80b4-00c04fd430c8");
+ static UUID uuidOID("6ba7b812-9dad-11d1-80b4-00c04fd430c8");
+ static UUID uuidX500("6ba7b814-9dad-11d1-80b4-00c04fd430c8");
+}
+
+
+const UUID& UUID::null()
+{
+ return uuidNull;
+}
+
+
+const UUID& UUID::dns()
+{
+ return uuidDNS;
+}
+
+
+const UUID& UUID::uri()
+{
+ return uuidURI;
+}
+
+
+const UUID& UUID::oid()
+{
+ return uuidOID;
+}
+
+
+const UUID& UUID::x500()
+{
+ return uuidX500;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/UUIDGenerator.cpp b/contrib/libs/poco/Foundation/src/UUIDGenerator.cpp
index 1ae72005ac..3ab36426b5 100644
--- a/contrib/libs/poco/Foundation/src/UUIDGenerator.cpp
+++ b/contrib/libs/poco/Foundation/src/UUIDGenerator.cpp
@@ -1,151 +1,151 @@
-//
-// UUIDGenerator.cpp
-//
-// Library: Foundation
-// Package: UUID
-// Module: UUID
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/UUIDGenerator.h"
-#include "Poco/Thread.h"
-#include "Poco/RandomStream.h"
-#include "Poco/DigestEngine.h"
-#include "Poco/MD5Engine.h"
-#include "Poco/SHA1Engine.h"
-#include "Poco/SingletonHolder.h"
-#include <cstring>
-
-
-namespace Poco {
-
-
-UUIDGenerator::UUIDGenerator(): _ticks(0), _haveNode(false)
-{
-}
-
-
-UUIDGenerator::~UUIDGenerator()
-{
-}
-
-
-UUID UUIDGenerator::create()
-{
- FastMutex::ScopedLock lock(_mutex);
-
- if (!_haveNode)
- {
- Environment::nodeId(_node);
- _haveNode = true;
- }
- Timestamp::UtcTimeVal tv = timeStamp();
- UInt32 timeLow = UInt32(tv & 0xFFFFFFFF);
- UInt16 timeMid = UInt16((tv >> 32) & 0xFFFF);
- UInt16 timeHiAndVersion = UInt16((tv >> 48) & 0x0FFF) + (UUID::UUID_TIME_BASED << 12);
- UInt16 clockSeq = (UInt16(_random.next() >> 4) & 0x3FFF) | 0x8000;
- return UUID(timeLow, timeMid, timeHiAndVersion, clockSeq, _node);
-}
-
-
-UUID UUIDGenerator::createFromName(const UUID& nsid, const std::string& name)
-{
- MD5Engine md5;
- return createFromName(nsid, name, md5);
-}
-
-
-UUID UUIDGenerator::createFromName(const UUID& nsid, const std::string& name, DigestEngine& de)
-{
- UUID::Version version = UUID::UUID_NAME_BASED;
- if (dynamic_cast<SHA1Engine*>(&de)) version = UUID::UUID_NAME_BASED_SHA1;
- return createFromName(nsid, name, de, version);
-}
-
-
-UUID UUIDGenerator::createFromName(const UUID& nsid, const std::string& name, DigestEngine& de, UUID::Version version)
-{
- poco_assert_dbg (de.digestLength() >= 16);
-
- UUID netNsid = nsid;
- netNsid.toNetwork();
- de.reset();
- de.update(&netNsid._timeLow, sizeof(netNsid._timeLow));
- de.update(&netNsid._timeMid, sizeof(netNsid._timeMid));
- de.update(&netNsid._timeHiAndVersion, sizeof(netNsid._timeHiAndVersion));
- de.update(&netNsid._clockSeq, sizeof(netNsid._clockSeq));
- de.update(&netNsid._node[0], sizeof(netNsid._node));
- de.update(name);
- char buffer[16];
- const DigestEngine::Digest& d = de.digest();
- for (int i = 0; i < 16; ++i)
- {
- buffer[i] = d[i];
- }
- return UUID(buffer, version);
-}
-
-
-UUID UUIDGenerator::createRandom()
-{
- char buffer[16];
- RandomInputStream ris;
- ris.read(buffer, sizeof(buffer));
- return UUID(buffer, UUID::UUID_RANDOM);
-}
-
-
-Timestamp::UtcTimeVal UUIDGenerator::timeStamp()
-{
- Timestamp now;
- for (;;)
- {
- if (now != _lastTime)
- {
- _lastTime = now;
- _ticks = 0;
- break;
- }
- if (_ticks < 100)
- {
- ++_ticks;
- break;
- }
- now.update();
- }
- Timestamp::UtcTimeVal tv = now.utcTime();
- return tv + _ticks;
-}
-
-
-UUID UUIDGenerator::createOne()
-{
- try
- {
- return create();
- }
- catch (Exception&)
- {
- return createRandom();
- }
-}
-
-
-namespace
-{
- static SingletonHolder<UUIDGenerator> sh;
-}
-
-
-UUIDGenerator& UUIDGenerator::defaultGenerator()
-{
- return *sh.get();
-}
-
-
-} // namespace Poco
+//
+// UUIDGenerator.cpp
+//
+// Library: Foundation
+// Package: UUID
+// Module: UUID
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/UUIDGenerator.h"
+#include "Poco/Thread.h"
+#include "Poco/RandomStream.h"
+#include "Poco/DigestEngine.h"
+#include "Poco/MD5Engine.h"
+#include "Poco/SHA1Engine.h"
+#include "Poco/SingletonHolder.h"
+#include <cstring>
+
+
+namespace Poco {
+
+
+UUIDGenerator::UUIDGenerator(): _ticks(0), _haveNode(false)
+{
+}
+
+
+UUIDGenerator::~UUIDGenerator()
+{
+}
+
+
+UUID UUIDGenerator::create()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (!_haveNode)
+ {
+ Environment::nodeId(_node);
+ _haveNode = true;
+ }
+ Timestamp::UtcTimeVal tv = timeStamp();
+ UInt32 timeLow = UInt32(tv & 0xFFFFFFFF);
+ UInt16 timeMid = UInt16((tv >> 32) & 0xFFFF);
+ UInt16 timeHiAndVersion = UInt16((tv >> 48) & 0x0FFF) + (UUID::UUID_TIME_BASED << 12);
+ UInt16 clockSeq = (UInt16(_random.next() >> 4) & 0x3FFF) | 0x8000;
+ return UUID(timeLow, timeMid, timeHiAndVersion, clockSeq, _node);
+}
+
+
+UUID UUIDGenerator::createFromName(const UUID& nsid, const std::string& name)
+{
+ MD5Engine md5;
+ return createFromName(nsid, name, md5);
+}
+
+
+UUID UUIDGenerator::createFromName(const UUID& nsid, const std::string& name, DigestEngine& de)
+{
+ UUID::Version version = UUID::UUID_NAME_BASED;
+ if (dynamic_cast<SHA1Engine*>(&de)) version = UUID::UUID_NAME_BASED_SHA1;
+ return createFromName(nsid, name, de, version);
+}
+
+
+UUID UUIDGenerator::createFromName(const UUID& nsid, const std::string& name, DigestEngine& de, UUID::Version version)
+{
+ poco_assert_dbg (de.digestLength() >= 16);
+
+ UUID netNsid = nsid;
+ netNsid.toNetwork();
+ de.reset();
+ de.update(&netNsid._timeLow, sizeof(netNsid._timeLow));
+ de.update(&netNsid._timeMid, sizeof(netNsid._timeMid));
+ de.update(&netNsid._timeHiAndVersion, sizeof(netNsid._timeHiAndVersion));
+ de.update(&netNsid._clockSeq, sizeof(netNsid._clockSeq));
+ de.update(&netNsid._node[0], sizeof(netNsid._node));
+ de.update(name);
+ char buffer[16];
+ const DigestEngine::Digest& d = de.digest();
+ for (int i = 0; i < 16; ++i)
+ {
+ buffer[i] = d[i];
+ }
+ return UUID(buffer, version);
+}
+
+
+UUID UUIDGenerator::createRandom()
+{
+ char buffer[16];
+ RandomInputStream ris;
+ ris.read(buffer, sizeof(buffer));
+ return UUID(buffer, UUID::UUID_RANDOM);
+}
+
+
+Timestamp::UtcTimeVal UUIDGenerator::timeStamp()
+{
+ Timestamp now;
+ for (;;)
+ {
+ if (now != _lastTime)
+ {
+ _lastTime = now;
+ _ticks = 0;
+ break;
+ }
+ if (_ticks < 100)
+ {
+ ++_ticks;
+ break;
+ }
+ now.update();
+ }
+ Timestamp::UtcTimeVal tv = now.utcTime();
+ return tv + _ticks;
+}
+
+
+UUID UUIDGenerator::createOne()
+{
+ try
+ {
+ return create();
+ }
+ catch (Exception&)
+ {
+ return createRandom();
+ }
+}
+
+
+namespace
+{
+ static SingletonHolder<UUIDGenerator> sh;
+}
+
+
+UUIDGenerator& UUIDGenerator::defaultGenerator()
+{
+ return *sh.get();
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Unicode.cpp b/contrib/libs/poco/Foundation/src/Unicode.cpp
index 172158d379..ec602694ab 100644
--- a/contrib/libs/poco/Foundation/src/Unicode.cpp
+++ b/contrib/libs/poco/Foundation/src/Unicode.cpp
@@ -1,56 +1,56 @@
-//
-// Unicode.cpp
-//
-// Library: Foundation
-// Package: Text
-// Module: Unicode
-//
-// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Unicode.h"
-
-
-extern "C"
-{
-#include "pcre_config.h"
-#include "pcre_internal.h"
-}
-
-
-namespace Poco {
-
-
-void Unicode::properties(int ch, CharacterProperties& props)
-{
- if (ch > UCP_MAX_CODEPOINT) ch = 0;
- const ucd_record* ucd = GET_UCD(ch);
- props.category = static_cast<CharacterCategory>(_pcre_ucp_gentype[ucd->chartype]);
- props.type = static_cast<CharacterType>(ucd->chartype);
- props.script = static_cast<Script>(ucd->script);
-}
-
-
-int Unicode::toLower(int ch)
-{
- if (isUpper(ch))
- return static_cast<int>(UCD_OTHERCASE(static_cast<unsigned>(ch)));
- else
- return ch;
-}
-
-
-int Unicode::toUpper(int ch)
-{
- if (isLower(ch))
- return static_cast<int>(UCD_OTHERCASE(static_cast<unsigned>(ch)));
- else
- return ch;
-}
-
-
-} // namespace Poco
+//
+// Unicode.cpp
+//
+// Library: Foundation
+// Package: Text
+// Module: Unicode
+//
+// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Unicode.h"
+
+
+extern "C"
+{
+#include "pcre_config.h"
+#include "pcre_internal.h"
+}
+
+
+namespace Poco {
+
+
+void Unicode::properties(int ch, CharacterProperties& props)
+{
+ if (ch > UCP_MAX_CODEPOINT) ch = 0;
+ const ucd_record* ucd = GET_UCD(ch);
+ props.category = static_cast<CharacterCategory>(_pcre_ucp_gentype[ucd->chartype]);
+ props.type = static_cast<CharacterType>(ucd->chartype);
+ props.script = static_cast<Script>(ucd->script);
+}
+
+
+int Unicode::toLower(int ch)
+{
+ if (isUpper(ch))
+ return static_cast<int>(UCD_OTHERCASE(static_cast<unsigned>(ch)));
+ else
+ return ch;
+}
+
+
+int Unicode::toUpper(int ch)
+{
+ if (isLower(ch))
+ return static_cast<int>(UCD_OTHERCASE(static_cast<unsigned>(ch)));
+ else
+ return ch;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/UnicodeConverter.cpp b/contrib/libs/poco/Foundation/src/UnicodeConverter.cpp
index 992c644c61..184330ba1a 100644
--- a/contrib/libs/poco/Foundation/src/UnicodeConverter.cpp
+++ b/contrib/libs/poco/Foundation/src/UnicodeConverter.cpp
@@ -1,161 +1,161 @@
-//
-// UnicodeConverter.cpp
-//
-// Library: Foundation
-// Package: Text
-// Module: UnicodeConverter
-//
-// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/UnicodeConverter.h"
-#include "Poco/TextConverter.h"
-#include "Poco/TextIterator.h"
-#include "Poco/UTF8Encoding.h"
-#include "Poco/UTF16Encoding.h"
-#include "Poco/UTF32Encoding.h"
-#include <cstring>
-
-
-namespace Poco {
-
-
-void UnicodeConverter::convert(const std::string& utf8String, UTF32String& utf32String)
-{
- utf32String.clear();
- UTF8Encoding utf8Encoding;
- TextIterator it(utf8String, utf8Encoding);
- TextIterator end(utf8String);
-
- while (it != end)
- {
- int cc = *it++;
- utf32String += (UTF32Char) cc;
- }
-}
-
-
-void UnicodeConverter::convert(const char* utf8String, std::size_t length, UTF32String& utf32String)
-{
- if (!utf8String || !length)
- {
- utf32String.clear();
- return;
- }
-
- convert(std::string(utf8String, utf8String + length), utf32String);
-}
-
-
-void UnicodeConverter::convert(const char* utf8String, UTF32String& utf32String)
-{
- if (!utf8String || !std::strlen(utf8String))
- {
- utf32String.clear();
- return;
- }
-
- convert(utf8String, std::strlen(utf8String), utf32String);
-}
-
-
-void UnicodeConverter::convert(const std::string& utf8String, UTF16String& utf16String)
-{
- utf16String.clear();
- UTF8Encoding utf8Encoding;
- TextIterator it(utf8String, utf8Encoding);
- TextIterator end(utf8String);
+//
+// UnicodeConverter.cpp
+//
+// Library: Foundation
+// Package: Text
+// Module: UnicodeConverter
+//
+// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/UnicodeConverter.h"
+#include "Poco/TextConverter.h"
+#include "Poco/TextIterator.h"
+#include "Poco/UTF8Encoding.h"
+#include "Poco/UTF16Encoding.h"
+#include "Poco/UTF32Encoding.h"
+#include <cstring>
+
+
+namespace Poco {
+
+
+void UnicodeConverter::convert(const std::string& utf8String, UTF32String& utf32String)
+{
+ utf32String.clear();
+ UTF8Encoding utf8Encoding;
+ TextIterator it(utf8String, utf8Encoding);
+ TextIterator end(utf8String);
+
while (it != end)
- {
- int cc = *it++;
- if (cc <= 0xffff)
- {
- utf16String += (UTF16Char) cc;
- }
- else
- {
- cc -= 0x10000;
- utf16String += (UTF16Char) ((cc >> 10) & 0x3ff) | 0xd800;
- utf16String += (UTF16Char) (cc & 0x3ff) | 0xdc00;
- }
- }
-}
-
-
-void UnicodeConverter::convert(const char* utf8String, std::size_t length, UTF16String& utf16String)
-{
- if (!utf8String || !length)
- {
- utf16String.clear();
- return;
- }
-
- convert(std::string(utf8String, utf8String + length), utf16String);
-}
-
-
-void UnicodeConverter::convert(const char* utf8String, UTF16String& utf16String)
-{
- if (!utf8String || !std::strlen(utf8String))
- {
- utf16String.clear();
- return;
- }
-
- convert(std::string(utf8String), utf16String);
-}
-
-
-void UnicodeConverter::convert(const UTF16String& utf16String, std::string& utf8String)
-{
- utf8String.clear();
- UTF8Encoding utf8Encoding;
- UTF16Encoding utf16Encoding;
- TextConverter converter(utf16Encoding, utf8Encoding);
- converter.convert(utf16String.data(), (int) utf16String.length() * sizeof(UTF16Char), utf8String);
-}
-
-
-void UnicodeConverter::convert(const UTF32String& utf32String, std::string& utf8String)
-{
- utf8String.clear();
- UTF8Encoding utf8Encoding;
- UTF32Encoding utf32Encoding;
- TextConverter converter(utf32Encoding, utf8Encoding);
- converter.convert(utf32String.data(), (int) utf32String.length() * sizeof(UTF32Char), utf8String);
-}
-
-
-void UnicodeConverter::convert(const UTF16Char* utf16String, std::size_t length, std::string& utf8String)
-{
- utf8String.clear();
- UTF8Encoding utf8Encoding;
- UTF16Encoding utf16Encoding;
- TextConverter converter(utf16Encoding, utf8Encoding);
- converter.convert(utf16String, (int) length * sizeof(UTF16Char), utf8String);
-}
-
-
-void UnicodeConverter::convert(const UTF32Char* utf32String, std::size_t length, std::string& utf8String)
-{
- toUTF8(UTF32String(utf32String, length), utf8String);
-}
-
-
-void UnicodeConverter::convert(const UTF16Char* utf16String, std::string& utf8String)
-{
- toUTF8(utf16String, UTFStrlen(utf16String), utf8String);
-}
-
-
-void UnicodeConverter::convert(const UTF32Char* utf32String, std::string& utf8String)
-{
- toUTF8(utf32String, UTFStrlen(utf32String), utf8String);
-}
-
-
-} // namespace Poco
+ {
+ int cc = *it++;
+ utf32String += (UTF32Char) cc;
+ }
+}
+
+
+void UnicodeConverter::convert(const char* utf8String, std::size_t length, UTF32String& utf32String)
+{
+ if (!utf8String || !length)
+ {
+ utf32String.clear();
+ return;
+ }
+
+ convert(std::string(utf8String, utf8String + length), utf32String);
+}
+
+
+void UnicodeConverter::convert(const char* utf8String, UTF32String& utf32String)
+{
+ if (!utf8String || !std::strlen(utf8String))
+ {
+ utf32String.clear();
+ return;
+ }
+
+ convert(utf8String, std::strlen(utf8String), utf32String);
+}
+
+
+void UnicodeConverter::convert(const std::string& utf8String, UTF16String& utf16String)
+{
+ utf16String.clear();
+ UTF8Encoding utf8Encoding;
+ TextIterator it(utf8String, utf8Encoding);
+ TextIterator end(utf8String);
+ while (it != end)
+ {
+ int cc = *it++;
+ if (cc <= 0xffff)
+ {
+ utf16String += (UTF16Char) cc;
+ }
+ else
+ {
+ cc -= 0x10000;
+ utf16String += (UTF16Char) ((cc >> 10) & 0x3ff) | 0xd800;
+ utf16String += (UTF16Char) (cc & 0x3ff) | 0xdc00;
+ }
+ }
+}
+
+
+void UnicodeConverter::convert(const char* utf8String, std::size_t length, UTF16String& utf16String)
+{
+ if (!utf8String || !length)
+ {
+ utf16String.clear();
+ return;
+ }
+
+ convert(std::string(utf8String, utf8String + length), utf16String);
+}
+
+
+void UnicodeConverter::convert(const char* utf8String, UTF16String& utf16String)
+{
+ if (!utf8String || !std::strlen(utf8String))
+ {
+ utf16String.clear();
+ return;
+ }
+
+ convert(std::string(utf8String), utf16String);
+}
+
+
+void UnicodeConverter::convert(const UTF16String& utf16String, std::string& utf8String)
+{
+ utf8String.clear();
+ UTF8Encoding utf8Encoding;
+ UTF16Encoding utf16Encoding;
+ TextConverter converter(utf16Encoding, utf8Encoding);
+ converter.convert(utf16String.data(), (int) utf16String.length() * sizeof(UTF16Char), utf8String);
+}
+
+
+void UnicodeConverter::convert(const UTF32String& utf32String, std::string& utf8String)
+{
+ utf8String.clear();
+ UTF8Encoding utf8Encoding;
+ UTF32Encoding utf32Encoding;
+ TextConverter converter(utf32Encoding, utf8Encoding);
+ converter.convert(utf32String.data(), (int) utf32String.length() * sizeof(UTF32Char), utf8String);
+}
+
+
+void UnicodeConverter::convert(const UTF16Char* utf16String, std::size_t length, std::string& utf8String)
+{
+ utf8String.clear();
+ UTF8Encoding utf8Encoding;
+ UTF16Encoding utf16Encoding;
+ TextConverter converter(utf16Encoding, utf8Encoding);
+ converter.convert(utf16String, (int) length * sizeof(UTF16Char), utf8String);
+}
+
+
+void UnicodeConverter::convert(const UTF32Char* utf32String, std::size_t length, std::string& utf8String)
+{
+ toUTF8(UTF32String(utf32String, length), utf8String);
+}
+
+
+void UnicodeConverter::convert(const UTF16Char* utf16String, std::string& utf8String)
+{
+ toUTF8(utf16String, UTFStrlen(utf16String), utf8String);
+}
+
+
+void UnicodeConverter::convert(const UTF32Char* utf32String, std::string& utf8String)
+{
+ toUTF8(utf32String, UTFStrlen(utf32String), utf8String);
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Var.cpp b/contrib/libs/poco/Foundation/src/Var.cpp
index 03deaef854..79b668b126 100644
--- a/contrib/libs/poco/Foundation/src/Var.cpp
+++ b/contrib/libs/poco/Foundation/src/Var.cpp
@@ -1,636 +1,636 @@
-//
-// Var.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: Var
-//
-// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Dynamic/Var.h"
-#include "Poco/Dynamic/Struct.h"
-#include <algorithm>
-#include <cctype>
-#include <vector>
-#include <list>
-#include <deque>
-
-
-namespace Poco {
-namespace Dynamic {
-
-
-Var::Var()
-#ifdef POCO_NO_SOO
- : _pHolder(0)
-#endif
-{
-}
-
-
-Var::Var(const char* pVal)
+//
+// Var.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: Var
+//
+// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Dynamic/Var.h"
+#include "Poco/Dynamic/Struct.h"
+#include <algorithm>
+#include <cctype>
+#include <vector>
+#include <list>
+#include <deque>
+
+
+namespace Poco {
+namespace Dynamic {
+
+
+Var::Var()
#ifdef POCO_NO_SOO
- : _pHolder(new VarHolderImpl<std::string>(pVal))
-{
-}
-#else
-{
- construct(std::string(pVal));
-}
-#endif
-
-
-Var::Var(const Var& other)
-#ifdef POCO_NO_SOO
- : _pHolder(other._pHolder ? other._pHolder->clone() : 0)
-{
-}
-#else
-{
- if ((this != &other) && !other.isEmpty())
- construct(other);
-}
-#endif
-
-
-Var::~Var()
-{
- destruct();
-}
-
-
-Var& Var::operator = (const Var& rhs)
-{
-#ifdef POCO_NO_SOO
- Var tmp(rhs);
- swap(tmp);
-#else
- if ((this != &rhs) && !rhs.isEmpty())
- construct(rhs);
- else if ((this != &rhs) && rhs.isEmpty())
- _placeholder.erase();
-#endif
- return *this;
-}
-
-
-const Var Var::operator + (const Var& other) const
-{
- if (isInteger())
- {
- if (isSigned())
- return add<Poco::Int64>(other);
- else
- return add<Poco::UInt64>(other);
- }
- else if (isNumeric())
- return add<double>(other);
- else if (isString())
- return add<std::string>(other);
- else
- throw InvalidArgumentException("Invalid operation for this data type.");
-}
-
-
-Var& Var::operator += (const Var& other)
-{
- if (isInteger())
- {
- if (isSigned())
- return *this = add<Poco::Int64>(other);
- else
- return *this = add<Poco::UInt64>(other);
- }
- else if (isNumeric())
- return *this = add<double>(other);
- else if (isString())
- return *this = add<std::string>(other);
- else
- throw InvalidArgumentException("Invalid operation for this data type.");
-}
-
-
-const Var Var::operator - (const Var& other) const
-{
- if (isInteger())
- {
- if (isSigned())
- return subtract<Poco::Int64>(other);
- else
- return subtract<Poco::UInt64>(other);
- }
- else if (isNumeric())
- return subtract<double>(other);
- else
- throw InvalidArgumentException("Invalid operation for this data type.");
-}
-
-
-Var& Var::operator -= (const Var& other)
-{
- if (isInteger())
- {
- if (isSigned())
- return *this = subtract<Poco::Int64>(other);
- else
- return *this = subtract<Poco::UInt64>(other);
- }
- else if (isNumeric())
- return *this = subtract<double>(other);
- else
- throw InvalidArgumentException("Invalid operation for this data type.");
-}
-
-
-const Var Var::operator * (const Var& other) const
-{
- if (isInteger())
- {
- if (isSigned())
- return multiply<Poco::Int64>(other);
- else
- return multiply<Poco::UInt64>(other);
- }
- else if (isNumeric())
- return multiply<double>(other);
- else
- throw InvalidArgumentException("Invalid operation for this data type.");
-}
-
-
-Var& Var::operator *= (const Var& other)
-{
- if (isInteger())
- {
- if (isSigned())
- return *this = multiply<Poco::Int64>(other);
- else
- return *this = multiply<Poco::UInt64>(other);
- }
- else if (isNumeric())
- return *this = multiply<double>(other);
- else
- throw InvalidArgumentException("Invalid operation for this data type.");
-}
-
-
-const Var Var::operator / (const Var& other) const
-{
- if (isInteger())
- {
- if (isSigned())
- return divide<Poco::Int64>(other);
- else
- return divide<Poco::UInt64>(other);
- }
- else if (isNumeric())
- return divide<double>(other);
- else
- throw InvalidArgumentException("Invalid operation for this data type.");
-}
-
-
-Var& Var::operator /= (const Var& other)
-{
- if (isInteger())
- {
- if (isSigned())
- return *this = divide<Poco::Int64>(other);
- else
- return *this = divide<Poco::UInt64>(other);
- }
- else if (isNumeric())
- return *this = divide<double>(other);
- else
- throw InvalidArgumentException("Invalid operation for this data type.");
-}
-
-
-Var& Var::operator ++ ()
-{
- if (!isInteger())
- throw InvalidArgumentException("Invalid operation for this data type.");
-
- return *this = *this + 1;
-}
-
-
-const Var Var::operator ++ (int)
-{
- if (!isInteger())
- throw InvalidArgumentException("Invalid operation for this data type.");
-
- Var tmp(*this);
- *this += 1;
- return tmp;
-}
-
-
-Var& Var::operator -- ()
-{
- if (!isInteger())
- throw InvalidArgumentException("Invalid operation for this data type.");
-
- return *this = *this - 1;
-}
-
-
-const Var Var::operator -- (int)
-{
- if (!isInteger())
- throw InvalidArgumentException("Invalid operation for this data type.");
-
- Var tmp(*this);
- *this -= 1;
- return tmp;
-}
-
-
-bool Var::operator == (const Var& other) const
-{
- if (isEmpty() != other.isEmpty()) return false;
- if (isEmpty() && other.isEmpty()) return true;
- return convert<std::string>() == other.convert<std::string>();
-}
-
-
-bool Var::operator == (const char* other) const
-{
- if (isEmpty()) return false;
- return convert<std::string>() == other;
-}
-
-
-bool Var::operator != (const Var& other) const
-{
- if (isEmpty() && other.isEmpty()) return false;
- else if (isEmpty() || other.isEmpty()) return true;
-
- return convert<std::string>() != other.convert<std::string>();
-}
-
-
-bool Var::operator != (const char* other) const
-{
- if (isEmpty()) return true;
- return convert<std::string>() != other;
-}
-
-
-bool Var::operator < (const Var& other) const
-{
- if (isEmpty() || other.isEmpty()) return false;
- return convert<std::string>() < other.convert<std::string>();
-}
-
-
-bool Var::operator <= (const Var& other) const
-{
- if (isEmpty() || other.isEmpty()) return false;
- return convert<std::string>() <= other.convert<std::string>();
-}
-
-
-bool Var::operator > (const Var& other) const
-{
- if (isEmpty() || other.isEmpty()) return false;
- return convert<std::string>() > other.convert<std::string>();
-}
-
-
-bool Var::operator >= (const Var& other) const
-{
- if (isEmpty() || other.isEmpty()) return false;
- return convert<std::string>() >= other.convert<std::string>();
-}
-
-
-bool Var::operator || (const Var& other) const
-{
- if (isEmpty() || other.isEmpty()) return false;
- return convert<bool>() || other.convert<bool>();
-}
-
-
-bool Var::operator && (const Var& other) const
-{
- if (isEmpty() || other.isEmpty()) return false;
- return convert<bool>() && other.convert<bool>();
-}
-
-
-void Var::empty()
-{
-#ifdef POCO_NO_SOO
- delete _pHolder;
- _pHolder = 0;
-#else
- if (_placeholder.isLocal()) this->~Var();
- else delete content();
- _placeholder.erase();
-#endif
-}
-
-
-void Var::clear()
-{
-#ifdef POCO_NO_SOO
- delete _pHolder;
- _pHolder = 0;
-#else
- if (_placeholder.isLocal()) this->~Var();
- else delete content();
- _placeholder.erase();
-#endif
-}
-
-
-Var& Var::getAt(std::size_t n)
-{
- if (isVector())
- return holderImpl<std::vector<Var>,
- InvalidAccessException>("Not a vector.")->operator[](n);
- else if (isList())
- return holderImpl<std::list<Var>,
- InvalidAccessException>("Not a list.")->operator[](n);
- else if (isDeque())
- return holderImpl<std::deque<Var>,
- InvalidAccessException>("Not a deque.")->operator[](n);
- else if (isStruct())
- return structIndexOperator(holderImpl<Struct<int>,
- InvalidAccessException>("Not a struct."), static_cast<int>(n));
- else if (!isString() && !isEmpty() && (n == 0))
- return *this;
-
- throw RangeException("Index out of bounds.");
-}
-
-
-char& Var::at(std::size_t n)
-{
- if (isString())
- {
- return holderImpl<std::string,
- InvalidAccessException>("Not a string.")->operator[](n);
- }
-
- throw InvalidAccessException("Not a string.");
-}
-
-
-Var& Var::getAt(const std::string& name)
-{
- return holderImpl<DynamicStruct,
- InvalidAccessException>("Not a struct.")->operator[](name);
-}
-
-
-Var Var::parse(const std::string& val)
-{
- std::string::size_type t = 0;
- return parse(val, t);
-}
-
-
-Var Var::parse(const std::string& val, std::string::size_type& pos)
-{
- // { -> an Object==DynamicStruct
- // [ -> an array
- // '/" -> a string (strip '/")
- // other: also treat as string
- skipWhiteSpace(val, pos);
- if (pos < val.size())
- {
- switch (val[pos])
- {
- case '{':
- return parseObject(val, pos);
- case '[':
- return parseArray(val, pos);
- case '"':
- return parseJSONString(val, pos);
- default:
- {
- std::string str = parseString(val, pos);
- if (str == "false")
- return false;
-
- if (str == "true")
- return true;
-
- bool isNumber = false;
- bool isSigned = false;
- int separators = 0;
- int frac = 0;
- int index = 0;
- size_t size = str.size();
- for (size_t i = 0; i < size ; ++i)
- {
- int ch = str[i];
- if ((ch == '-' || ch == '+') && index == 0)
- {
- if (ch == '-')
- isSigned = true;
- }
- else if (Ascii::isDigit(ch))
- {
- isNumber |= true;
- }
- else if (ch == '.' || ch == ',')
- {
- frac = ch;
- ++separators;
- if (separators > 1)
- return str;
- }
- else
- return str;
-
- ++index;
- }
-
- if (frac && isNumber)
- {
- const double number = NumberParser::parseFloat(str, frac);
- return Var(number);
- }
- else if (frac == 0 && isNumber && isSigned)
- {
- const Poco::Int64 number = NumberParser::parse64(str);
- return number;
- }
- else if (frac == 0 && isNumber && !isSigned)
- {
- const Poco::UInt64 number = NumberParser::parseUnsigned64(str);
- return number;
- }
-
- return str;
- }
- }
- }
- std::string empty;
- return empty;
-}
-
-
-Var Var::parseObject(const std::string& val, std::string::size_type& pos)
-{
- poco_assert_dbg (pos < val.size() && val[pos] == '{');
- ++pos;
- skipWhiteSpace(val, pos);
- DynamicStruct aStruct;
- while (val[pos] != '}' && pos < val.size())
- {
- std::string key = parseString(val, pos);
- skipWhiteSpace(val, pos);
- if (val[pos] != ':')
- throw DataFormatException("Incorrect object, must contain: key : value pairs");
- ++pos; // skip past :
- Var value = parse(val, pos);
- aStruct.insert(key, value);
- skipWhiteSpace(val, pos);
- if (val[pos] == ',')
- {
- ++pos;
- skipWhiteSpace(val, pos);
- }
- }
- if (val[pos] != '}')
- throw DataFormatException("Unterminated object");
- ++pos;
- return aStruct;
-}
-
-
-Var Var::parseArray(const std::string& val, std::string::size_type& pos)
-{
- poco_assert_dbg (pos < val.size() && val[pos] == '[');
- ++pos;
- skipWhiteSpace(val, pos);
- std::vector<Var> result;
- while (val[pos] != ']' && pos < val.size())
- {
- result.push_back(parse(val, pos));
- skipWhiteSpace(val, pos);
- if (val[pos] == ',')
- {
- ++pos;
- skipWhiteSpace(val, pos);
- }
- }
- if (val[pos] != ']')
- throw DataFormatException("Unterminated array");
- ++pos;
- return result;
-}
-
-
-std::string Var::parseString(const std::string& val, std::string::size_type& pos)
-{
- poco_assert_dbg (pos < val.size());
- if (val[pos] == '"')
- {
- return parseJSONString(val, pos);
- }
- else
- {
- std::string result;
- while (pos < val.size()
- && !Poco::Ascii::isSpace(val[pos])
- && val[pos] != ','
- && val[pos] != ']'
- && val[pos] != '}')
- {
- result += val[pos++];
- }
- return result;
- }
-}
-
-
-std::string Var::parseJSONString(const std::string& val, std::string::size_type& pos)
-{
- poco_assert_dbg (pos < val.size() && val[pos] == '"');
- ++pos;
- std::string result;
- bool done = false;
- while (pos < val.size() && !done)
- {
- switch (val[pos])
- {
- case '"':
- done = true;
- ++pos;
- break;
- case '\\':
- if (pos < val.size())
- {
- ++pos;
- switch (val[pos])
- {
- case 'b':
- result += '\b';
- break;
- case 'f':
- result += '\f';
- break;
- case 'n':
- result += '\n';
- break;
- case 'r':
- result += '\r';
- break;
- case 't':
- result += '\t';
+ : _pHolder(0)
+#endif
+{
+}
+
+
+Var::Var(const char* pVal)
+#ifdef POCO_NO_SOO
+ : _pHolder(new VarHolderImpl<std::string>(pVal))
+{
+}
+#else
+{
+ construct(std::string(pVal));
+}
+#endif
+
+
+Var::Var(const Var& other)
+#ifdef POCO_NO_SOO
+ : _pHolder(other._pHolder ? other._pHolder->clone() : 0)
+{
+}
+#else
+{
+ if ((this != &other) && !other.isEmpty())
+ construct(other);
+}
+#endif
+
+
+Var::~Var()
+{
+ destruct();
+}
+
+
+Var& Var::operator = (const Var& rhs)
+{
+#ifdef POCO_NO_SOO
+ Var tmp(rhs);
+ swap(tmp);
+#else
+ if ((this != &rhs) && !rhs.isEmpty())
+ construct(rhs);
+ else if ((this != &rhs) && rhs.isEmpty())
+ _placeholder.erase();
+#endif
+ return *this;
+}
+
+
+const Var Var::operator + (const Var& other) const
+{
+ if (isInteger())
+ {
+ if (isSigned())
+ return add<Poco::Int64>(other);
+ else
+ return add<Poco::UInt64>(other);
+ }
+ else if (isNumeric())
+ return add<double>(other);
+ else if (isString())
+ return add<std::string>(other);
+ else
+ throw InvalidArgumentException("Invalid operation for this data type.");
+}
+
+
+Var& Var::operator += (const Var& other)
+{
+ if (isInteger())
+ {
+ if (isSigned())
+ return *this = add<Poco::Int64>(other);
+ else
+ return *this = add<Poco::UInt64>(other);
+ }
+ else if (isNumeric())
+ return *this = add<double>(other);
+ else if (isString())
+ return *this = add<std::string>(other);
+ else
+ throw InvalidArgumentException("Invalid operation for this data type.");
+}
+
+
+const Var Var::operator - (const Var& other) const
+{
+ if (isInteger())
+ {
+ if (isSigned())
+ return subtract<Poco::Int64>(other);
+ else
+ return subtract<Poco::UInt64>(other);
+ }
+ else if (isNumeric())
+ return subtract<double>(other);
+ else
+ throw InvalidArgumentException("Invalid operation for this data type.");
+}
+
+
+Var& Var::operator -= (const Var& other)
+{
+ if (isInteger())
+ {
+ if (isSigned())
+ return *this = subtract<Poco::Int64>(other);
+ else
+ return *this = subtract<Poco::UInt64>(other);
+ }
+ else if (isNumeric())
+ return *this = subtract<double>(other);
+ else
+ throw InvalidArgumentException("Invalid operation for this data type.");
+}
+
+
+const Var Var::operator * (const Var& other) const
+{
+ if (isInteger())
+ {
+ if (isSigned())
+ return multiply<Poco::Int64>(other);
+ else
+ return multiply<Poco::UInt64>(other);
+ }
+ else if (isNumeric())
+ return multiply<double>(other);
+ else
+ throw InvalidArgumentException("Invalid operation for this data type.");
+}
+
+
+Var& Var::operator *= (const Var& other)
+{
+ if (isInteger())
+ {
+ if (isSigned())
+ return *this = multiply<Poco::Int64>(other);
+ else
+ return *this = multiply<Poco::UInt64>(other);
+ }
+ else if (isNumeric())
+ return *this = multiply<double>(other);
+ else
+ throw InvalidArgumentException("Invalid operation for this data type.");
+}
+
+
+const Var Var::operator / (const Var& other) const
+{
+ if (isInteger())
+ {
+ if (isSigned())
+ return divide<Poco::Int64>(other);
+ else
+ return divide<Poco::UInt64>(other);
+ }
+ else if (isNumeric())
+ return divide<double>(other);
+ else
+ throw InvalidArgumentException("Invalid operation for this data type.");
+}
+
+
+Var& Var::operator /= (const Var& other)
+{
+ if (isInteger())
+ {
+ if (isSigned())
+ return *this = divide<Poco::Int64>(other);
+ else
+ return *this = divide<Poco::UInt64>(other);
+ }
+ else if (isNumeric())
+ return *this = divide<double>(other);
+ else
+ throw InvalidArgumentException("Invalid operation for this data type.");
+}
+
+
+Var& Var::operator ++ ()
+{
+ if (!isInteger())
+ throw InvalidArgumentException("Invalid operation for this data type.");
+
+ return *this = *this + 1;
+}
+
+
+const Var Var::operator ++ (int)
+{
+ if (!isInteger())
+ throw InvalidArgumentException("Invalid operation for this data type.");
+
+ Var tmp(*this);
+ *this += 1;
+ return tmp;
+}
+
+
+Var& Var::operator -- ()
+{
+ if (!isInteger())
+ throw InvalidArgumentException("Invalid operation for this data type.");
+
+ return *this = *this - 1;
+}
+
+
+const Var Var::operator -- (int)
+{
+ if (!isInteger())
+ throw InvalidArgumentException("Invalid operation for this data type.");
+
+ Var tmp(*this);
+ *this -= 1;
+ return tmp;
+}
+
+
+bool Var::operator == (const Var& other) const
+{
+ if (isEmpty() != other.isEmpty()) return false;
+ if (isEmpty() && other.isEmpty()) return true;
+ return convert<std::string>() == other.convert<std::string>();
+}
+
+
+bool Var::operator == (const char* other) const
+{
+ if (isEmpty()) return false;
+ return convert<std::string>() == other;
+}
+
+
+bool Var::operator != (const Var& other) const
+{
+ if (isEmpty() && other.isEmpty()) return false;
+ else if (isEmpty() || other.isEmpty()) return true;
+
+ return convert<std::string>() != other.convert<std::string>();
+}
+
+
+bool Var::operator != (const char* other) const
+{
+ if (isEmpty()) return true;
+ return convert<std::string>() != other;
+}
+
+
+bool Var::operator < (const Var& other) const
+{
+ if (isEmpty() || other.isEmpty()) return false;
+ return convert<std::string>() < other.convert<std::string>();
+}
+
+
+bool Var::operator <= (const Var& other) const
+{
+ if (isEmpty() || other.isEmpty()) return false;
+ return convert<std::string>() <= other.convert<std::string>();
+}
+
+
+bool Var::operator > (const Var& other) const
+{
+ if (isEmpty() || other.isEmpty()) return false;
+ return convert<std::string>() > other.convert<std::string>();
+}
+
+
+bool Var::operator >= (const Var& other) const
+{
+ if (isEmpty() || other.isEmpty()) return false;
+ return convert<std::string>() >= other.convert<std::string>();
+}
+
+
+bool Var::operator || (const Var& other) const
+{
+ if (isEmpty() || other.isEmpty()) return false;
+ return convert<bool>() || other.convert<bool>();
+}
+
+
+bool Var::operator && (const Var& other) const
+{
+ if (isEmpty() || other.isEmpty()) return false;
+ return convert<bool>() && other.convert<bool>();
+}
+
+
+void Var::empty()
+{
+#ifdef POCO_NO_SOO
+ delete _pHolder;
+ _pHolder = 0;
+#else
+ if (_placeholder.isLocal()) this->~Var();
+ else delete content();
+ _placeholder.erase();
+#endif
+}
+
+
+void Var::clear()
+{
+#ifdef POCO_NO_SOO
+ delete _pHolder;
+ _pHolder = 0;
+#else
+ if (_placeholder.isLocal()) this->~Var();
+ else delete content();
+ _placeholder.erase();
+#endif
+}
+
+
+Var& Var::getAt(std::size_t n)
+{
+ if (isVector())
+ return holderImpl<std::vector<Var>,
+ InvalidAccessException>("Not a vector.")->operator[](n);
+ else if (isList())
+ return holderImpl<std::list<Var>,
+ InvalidAccessException>("Not a list.")->operator[](n);
+ else if (isDeque())
+ return holderImpl<std::deque<Var>,
+ InvalidAccessException>("Not a deque.")->operator[](n);
+ else if (isStruct())
+ return structIndexOperator(holderImpl<Struct<int>,
+ InvalidAccessException>("Not a struct."), static_cast<int>(n));
+ else if (!isString() && !isEmpty() && (n == 0))
+ return *this;
+
+ throw RangeException("Index out of bounds.");
+}
+
+
+char& Var::at(std::size_t n)
+{
+ if (isString())
+ {
+ return holderImpl<std::string,
+ InvalidAccessException>("Not a string.")->operator[](n);
+ }
+
+ throw InvalidAccessException("Not a string.");
+}
+
+
+Var& Var::getAt(const std::string& name)
+{
+ return holderImpl<DynamicStruct,
+ InvalidAccessException>("Not a struct.")->operator[](name);
+}
+
+
+Var Var::parse(const std::string& val)
+{
+ std::string::size_type t = 0;
+ return parse(val, t);
+}
+
+
+Var Var::parse(const std::string& val, std::string::size_type& pos)
+{
+ // { -> an Object==DynamicStruct
+ // [ -> an array
+ // '/" -> a string (strip '/")
+ // other: also treat as string
+ skipWhiteSpace(val, pos);
+ if (pos < val.size())
+ {
+ switch (val[pos])
+ {
+ case '{':
+ return parseObject(val, pos);
+ case '[':
+ return parseArray(val, pos);
+ case '"':
+ return parseJSONString(val, pos);
+ default:
+ {
+ std::string str = parseString(val, pos);
+ if (str == "false")
+ return false;
+
+ if (str == "true")
+ return true;
+
+ bool isNumber = false;
+ bool isSigned = false;
+ int separators = 0;
+ int frac = 0;
+ int index = 0;
+ size_t size = str.size();
+ for (size_t i = 0; i < size ; ++i)
+ {
+ int ch = str[i];
+ if ((ch == '-' || ch == '+') && index == 0)
+ {
+ if (ch == '-')
+ isSigned = true;
+ }
+ else if (Ascii::isDigit(ch))
+ {
+ isNumber |= true;
+ }
+ else if (ch == '.' || ch == ',')
+ {
+ frac = ch;
+ ++separators;
+ if (separators > 1)
+ return str;
+ }
+ else
+ return str;
+
+ ++index;
+ }
+
+ if (frac && isNumber)
+ {
+ const double number = NumberParser::parseFloat(str, frac);
+ return Var(number);
+ }
+ else if (frac == 0 && isNumber && isSigned)
+ {
+ const Poco::Int64 number = NumberParser::parse64(str);
+ return number;
+ }
+ else if (frac == 0 && isNumber && !isSigned)
+ {
+ const Poco::UInt64 number = NumberParser::parseUnsigned64(str);
+ return number;
+ }
+
+ return str;
+ }
+ }
+ }
+ std::string empty;
+ return empty;
+}
+
+
+Var Var::parseObject(const std::string& val, std::string::size_type& pos)
+{
+ poco_assert_dbg (pos < val.size() && val[pos] == '{');
+ ++pos;
+ skipWhiteSpace(val, pos);
+ DynamicStruct aStruct;
+ while (val[pos] != '}' && pos < val.size())
+ {
+ std::string key = parseString(val, pos);
+ skipWhiteSpace(val, pos);
+ if (val[pos] != ':')
+ throw DataFormatException("Incorrect object, must contain: key : value pairs");
+ ++pos; // skip past :
+ Var value = parse(val, pos);
+ aStruct.insert(key, value);
+ skipWhiteSpace(val, pos);
+ if (val[pos] == ',')
+ {
+ ++pos;
+ skipWhiteSpace(val, pos);
+ }
+ }
+ if (val[pos] != '}')
+ throw DataFormatException("Unterminated object");
+ ++pos;
+ return aStruct;
+}
+
+
+Var Var::parseArray(const std::string& val, std::string::size_type& pos)
+{
+ poco_assert_dbg (pos < val.size() && val[pos] == '[');
+ ++pos;
+ skipWhiteSpace(val, pos);
+ std::vector<Var> result;
+ while (val[pos] != ']' && pos < val.size())
+ {
+ result.push_back(parse(val, pos));
+ skipWhiteSpace(val, pos);
+ if (val[pos] == ',')
+ {
+ ++pos;
+ skipWhiteSpace(val, pos);
+ }
+ }
+ if (val[pos] != ']')
+ throw DataFormatException("Unterminated array");
+ ++pos;
+ return result;
+}
+
+
+std::string Var::parseString(const std::string& val, std::string::size_type& pos)
+{
+ poco_assert_dbg (pos < val.size());
+ if (val[pos] == '"')
+ {
+ return parseJSONString(val, pos);
+ }
+ else
+ {
+ std::string result;
+ while (pos < val.size()
+ && !Poco::Ascii::isSpace(val[pos])
+ && val[pos] != ','
+ && val[pos] != ']'
+ && val[pos] != '}')
+ {
+ result += val[pos++];
+ }
+ return result;
+ }
+}
+
+
+std::string Var::parseJSONString(const std::string& val, std::string::size_type& pos)
+{
+ poco_assert_dbg (pos < val.size() && val[pos] == '"');
+ ++pos;
+ std::string result;
+ bool done = false;
+ while (pos < val.size() && !done)
+ {
+ switch (val[pos])
+ {
+ case '"':
+ done = true;
+ ++pos;
+ break;
+ case '\\':
+ if (pos < val.size())
+ {
+ ++pos;
+ switch (val[pos])
+ {
+ case 'b':
+ result += '\b';
+ break;
+ case 'f':
+ result += '\f';
+ break;
+ case 'n':
+ result += '\n';
+ break;
+ case 'r':
+ result += '\r';
+ break;
+ case 't':
+ result += '\t';
+ break;
+ default:
+ result += val[pos];
break;
- default:
- result += val[pos];
- break;
- }
- break;
- }
- else
- {
- result += val[pos];
- }
- ++pos;
- break;
- default:
- result += val[pos++];
- break;
- }
- }
- if (!done) throw Poco::DataFormatException("unterminated JSON string");
- return result;
-}
-
-
-void Var::skipWhiteSpace(const std::string& val, std::string::size_type& pos)
-{
- poco_assert_dbg (pos < val.size());
- while (std::isspace(val[pos]) && pos < val.size())
- ++pos;
-}
-
-
-std::string Var::toString(const Var& any)
-{
- std::string res;
- Impl::appendJSONValue(res, any);
- return res;
-}
-
-
-Var& Var::structIndexOperator(VarHolderImpl<Struct<int> >* pStr, int n) const
-{
- return pStr->operator[](n);
-}
-
-
-} } // namespace Poco::Dynamic
+ }
+ break;
+ }
+ else
+ {
+ result += val[pos];
+ }
+ ++pos;
+ break;
+ default:
+ result += val[pos++];
+ break;
+ }
+ }
+ if (!done) throw Poco::DataFormatException("unterminated JSON string");
+ return result;
+}
+
+
+void Var::skipWhiteSpace(const std::string& val, std::string::size_type& pos)
+{
+ poco_assert_dbg (pos < val.size());
+ while (std::isspace(val[pos]) && pos < val.size())
+ ++pos;
+}
+
+
+std::string Var::toString(const Var& any)
+{
+ std::string res;
+ Impl::appendJSONValue(res, any);
+ return res;
+}
+
+
+Var& Var::structIndexOperator(VarHolderImpl<Struct<int> >* pStr, int n) const
+{
+ return pStr->operator[](n);
+}
+
+
+} } // namespace Poco::Dynamic
diff --git a/contrib/libs/poco/Foundation/src/VarHolder.cpp b/contrib/libs/poco/Foundation/src/VarHolder.cpp
index a08d6e08c7..d457805732 100644
--- a/contrib/libs/poco/Foundation/src/VarHolder.cpp
+++ b/contrib/libs/poco/Foundation/src/VarHolder.cpp
@@ -1,92 +1,92 @@
-//
-// VarHolder.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: VarHolder
-//
-// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Dynamic/VarHolder.h"
-#include "Poco/Dynamic/Var.h"
-#include "Poco/JSONString.h"
-
-
-namespace Poco {
-namespace Dynamic {
-
-
-VarHolder::VarHolder()
-{
-}
-
-
-VarHolder::~VarHolder()
-{
-}
-
-
-namespace Impl {
-
-
-void escape(std::string& target, const std::string& source)
-{
- target = toJSON(source);
-}
-
-
-bool isJSONString(const Var& any)
-{
- return any.type() == typeid(std::string) ||
- any.type() == typeid(char) ||
- any.type() == typeid(char*) ||
- any.type() == typeid(Poco::DateTime) ||
- any.type() == typeid(Poco::LocalDateTime) ||
- any.type() == typeid(Poco::Timestamp);
-}
-
-
-void appendJSONString(std::string& val, const Var& any)
-{
- std::string json;
- escape(json, any.convert<std::string>());
- val.append(json);
-}
-
-
-void appendJSONKey(std::string& val, const Var& any)
-{
- return appendJSONString(val, any);
-}
-
-
-void appendJSONValue(std::string& val, const Var& any)
-{
- if (any.isEmpty())
- {
- val.append("null");
- }
- else
- {
- bool isStr = isJSONString(any);
- if (isStr)
- {
- appendJSONString(val, any.convert<std::string>());
- }
- else
- {
- val.append(any.convert<std::string>());
- }
- }
-}
-
-
-} // namespace Impl
-
-
-} } // namespace Poco::Dynamic
+//
+// VarHolder.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: VarHolder
+//
+// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Dynamic/VarHolder.h"
+#include "Poco/Dynamic/Var.h"
+#include "Poco/JSONString.h"
+
+
+namespace Poco {
+namespace Dynamic {
+
+
+VarHolder::VarHolder()
+{
+}
+
+
+VarHolder::~VarHolder()
+{
+}
+
+
+namespace Impl {
+
+
+void escape(std::string& target, const std::string& source)
+{
+ target = toJSON(source);
+}
+
+
+bool isJSONString(const Var& any)
+{
+ return any.type() == typeid(std::string) ||
+ any.type() == typeid(char) ||
+ any.type() == typeid(char*) ||
+ any.type() == typeid(Poco::DateTime) ||
+ any.type() == typeid(Poco::LocalDateTime) ||
+ any.type() == typeid(Poco::Timestamp);
+}
+
+
+void appendJSONString(std::string& val, const Var& any)
+{
+ std::string json;
+ escape(json, any.convert<std::string>());
+ val.append(json);
+}
+
+
+void appendJSONKey(std::string& val, const Var& any)
+{
+ return appendJSONString(val, any);
+}
+
+
+void appendJSONValue(std::string& val, const Var& any)
+{
+ if (any.isEmpty())
+ {
+ val.append("null");
+ }
+ else
+ {
+ bool isStr = isJSONString(any);
+ if (isStr)
+ {
+ appendJSONString(val, any.convert<std::string>());
+ }
+ else
+ {
+ val.append(any.convert<std::string>());
+ }
+ }
+}
+
+
+} // namespace Impl
+
+
+} } // namespace Poco::Dynamic
diff --git a/contrib/libs/poco/Foundation/src/VarIterator.cpp b/contrib/libs/poco/Foundation/src/VarIterator.cpp
index d816c23c4a..e133b9a9a7 100644
--- a/contrib/libs/poco/Foundation/src/VarIterator.cpp
+++ b/contrib/libs/poco/Foundation/src/VarIterator.cpp
@@ -1,167 +1,167 @@
-//
-// VarIterator.cpp
-//
-// Library: Foundation
-// Package: Dynamic
-// Module: VarIterator
-//
-// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Dynamic/VarIterator.h"
-#include "Poco/Dynamic/Var.h"
-#include "Poco/Dynamic/Struct.h"
-#undef min
-#undef max
-#include <limits>
-
-
-namespace Poco {
-namespace Dynamic {
-
-
-const std::size_t VarIterator::POSITION_END = std::numeric_limits<std::size_t>::max();
-
-
-VarIterator::VarIterator(Var* pVar, bool positionEnd):
- _pVar(pVar),
- _position(positionEnd ? POSITION_END : 0)
-{
-}
-
-
-VarIterator::VarIterator(const VarIterator& other):
- _pVar(other._pVar),
- _position(other._position)
-{
-}
-
-
-VarIterator::~VarIterator()
-{
-}
-
-
-VarIterator& VarIterator::operator = (const VarIterator& other)
-{
- VarIterator tmp(other);
- swap(tmp);
- return *this;
-}
-
-
-void VarIterator::swap(VarIterator& other)
-{
- using std::swap;
-
- swap(_pVar, other._pVar);
- swap(_position, other._position);
-}
-
-
-void VarIterator::increment() const
-{
- if (POSITION_END == _position)
- throw RangeException("End of iterator reached.");
-
- if (_position < _pVar->size() - 1)
- ++_position;
- else
- _position = POSITION_END;
-}
-
-
-void VarIterator::decrement() const
-{
- if (0 == _position)
- throw RangeException("Beginning of iterator reached.");
- else if (POSITION_END == _position)
- _position = _pVar->size() - 1;
- else
- --_position;
-}
-
-
-void VarIterator::setPosition(std::size_t pos) const
-{
- if (_position == pos) return;
-
- if (pos < _pVar->size())
- _position = pos;
- else if (pos == _pVar->size())
- _position = POSITION_END;
- else
- throw RangeException("Invalid position argument.");
-}
-
-
-Var& VarIterator::operator * () const
-{
- if (POSITION_END == _position)
- throw InvalidAccessException("End of iterator reached.");
-
- return _pVar->operator[](_position);
-}
-
-
-Var* VarIterator::operator -> () const
-{
- if (POSITION_END == _position)
- throw InvalidAccessException("End of iterator reached.");
-
- return &_pVar->operator[](_position);
-}
-
-
-const VarIterator& VarIterator::operator ++ () const
-{
- increment();
- return *this;
-}
-
-
-VarIterator VarIterator::operator ++ (int) const
-{
- VarIterator old(*this);
- increment();
- return old;
-}
-
-
-const VarIterator& VarIterator::operator -- () const
-{
- decrement();
- return *this;
-}
-
-
-VarIterator VarIterator::operator -- (int) const
-{
- VarIterator old(*this);
- decrement();
- return old;
-}
-
-
-VarIterator VarIterator::operator + (std::size_t diff) const
-{
- VarIterator ri(*this);
- ri.setPosition(_position + diff);
- return ri;
-}
-
-
-VarIterator VarIterator::operator - (std::size_t diff) const
-{
- if (diff > _position) throw RangeException("Invalid position argument.");
- VarIterator ri(*this);
- ri.setPosition(_position - diff);
- return ri;
-}
-
-
-} } // namespace Poco::Dynamic
+//
+// VarIterator.cpp
+//
+// Library: Foundation
+// Package: Dynamic
+// Module: VarIterator
+//
+// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Dynamic/VarIterator.h"
+#include "Poco/Dynamic/Var.h"
+#include "Poco/Dynamic/Struct.h"
+#undef min
+#undef max
+#include <limits>
+
+
+namespace Poco {
+namespace Dynamic {
+
+
+const std::size_t VarIterator::POSITION_END = std::numeric_limits<std::size_t>::max();
+
+
+VarIterator::VarIterator(Var* pVar, bool positionEnd):
+ _pVar(pVar),
+ _position(positionEnd ? POSITION_END : 0)
+{
+}
+
+
+VarIterator::VarIterator(const VarIterator& other):
+ _pVar(other._pVar),
+ _position(other._position)
+{
+}
+
+
+VarIterator::~VarIterator()
+{
+}
+
+
+VarIterator& VarIterator::operator = (const VarIterator& other)
+{
+ VarIterator tmp(other);
+ swap(tmp);
+ return *this;
+}
+
+
+void VarIterator::swap(VarIterator& other)
+{
+ using std::swap;
+
+ swap(_pVar, other._pVar);
+ swap(_position, other._position);
+}
+
+
+void VarIterator::increment() const
+{
+ if (POSITION_END == _position)
+ throw RangeException("End of iterator reached.");
+
+ if (_position < _pVar->size() - 1)
+ ++_position;
+ else
+ _position = POSITION_END;
+}
+
+
+void VarIterator::decrement() const
+{
+ if (0 == _position)
+ throw RangeException("Beginning of iterator reached.");
+ else if (POSITION_END == _position)
+ _position = _pVar->size() - 1;
+ else
+ --_position;
+}
+
+
+void VarIterator::setPosition(std::size_t pos) const
+{
+ if (_position == pos) return;
+
+ if (pos < _pVar->size())
+ _position = pos;
+ else if (pos == _pVar->size())
+ _position = POSITION_END;
+ else
+ throw RangeException("Invalid position argument.");
+}
+
+
+Var& VarIterator::operator * () const
+{
+ if (POSITION_END == _position)
+ throw InvalidAccessException("End of iterator reached.");
+
+ return _pVar->operator[](_position);
+}
+
+
+Var* VarIterator::operator -> () const
+{
+ if (POSITION_END == _position)
+ throw InvalidAccessException("End of iterator reached.");
+
+ return &_pVar->operator[](_position);
+}
+
+
+const VarIterator& VarIterator::operator ++ () const
+{
+ increment();
+ return *this;
+}
+
+
+VarIterator VarIterator::operator ++ (int) const
+{
+ VarIterator old(*this);
+ increment();
+ return old;
+}
+
+
+const VarIterator& VarIterator::operator -- () const
+{
+ decrement();
+ return *this;
+}
+
+
+VarIterator VarIterator::operator -- (int) const
+{
+ VarIterator old(*this);
+ decrement();
+ return old;
+}
+
+
+VarIterator VarIterator::operator + (std::size_t diff) const
+{
+ VarIterator ri(*this);
+ ri.setPosition(_position + diff);
+ return ri;
+}
+
+
+VarIterator VarIterator::operator - (std::size_t diff) const
+{
+ if (diff > _position) throw RangeException("Invalid position argument.");
+ VarIterator ri(*this);
+ ri.setPosition(_position - diff);
+ return ri;
+}
+
+
+} } // namespace Poco::Dynamic
diff --git a/contrib/libs/poco/Foundation/src/Void.cpp b/contrib/libs/poco/Foundation/src/Void.cpp
index 7566bc00d0..eb3887f58e 100644
--- a/contrib/libs/poco/Foundation/src/Void.cpp
+++ b/contrib/libs/poco/Foundation/src/Void.cpp
@@ -1,42 +1,42 @@
-//
-// Void.cpp
-//
-// Library: Foundation
-// Package: Core
-// Module: Void
-//
-// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Void.h"
-
-
-namespace Poco {
-
-
-Void::Void()
-{
-}
-
-
-Void::Void(const Void&)
-{
-}
-
-
-Void::~Void()
-{
-}
-
-
-Void& Void::operator = (const Void&)
-{
- return *this;
-}
-
-
-} // namespace Poco
+//
+// Void.cpp
+//
+// Library: Foundation
+// Package: Core
+// Module: Void
+//
+// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Void.h"
+
+
+namespace Poco {
+
+
+Void::Void()
+{
+}
+
+
+Void::Void(const Void&)
+{
+}
+
+
+Void::~Void()
+{
+}
+
+
+Void& Void::operator = (const Void&)
+{
+ return *this;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Windows1250Encoding.cpp b/contrib/libs/poco/Foundation/src/Windows1250Encoding.cpp
index 96e18af6cd..55a5966954 100644
--- a/contrib/libs/poco/Foundation/src/Windows1250Encoding.cpp
+++ b/contrib/libs/poco/Foundation/src/Windows1250Encoding.cpp
@@ -1,196 +1,196 @@
-//
-// Windows1250Encoding.cpp
-//
-// Library: Foundation
-// Package: Text
-// Module: Windows1250Encoding
-//
-// Copyright (c) 2005-2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Windows1250Encoding.h"
-#include "Poco/String.h"
-
-
-namespace Poco {
-
-
-const char* Windows1250Encoding::_names[] =
-{
- "windows-1250",
- "Windows-1250",
- "cp1250",
- "CP1250",
- NULL
-};
-
-
-const TextEncoding::CharacterMap Windows1250Encoding::_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 */ 0x20ac, 0xfffe, 0x201a, 0xfffe, 0x201e, 0x2026, 0x2020, 0x2021, 0xfffe, 0x2030, 0x0160, 0x2039, 0x015a, 0x0164, 0x017d, 0x0179,
- /* 90 */ 0xfffe, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0xfffe, 0x2122, 0x0161, 0x203a, 0x015b, 0x0165, 0x017e, 0x017a,
- /* a0 */ 0x00a0, 0x02c7, 0x02d8, 0x0141, 0x00a4, 0x0104, 0x00a6, 0x00a7, 0x00a8, 0x00a9, 0x015e, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x017b,
- /* b0 */ 0x00b0, 0x00b1, 0x02db, 0x0142, 0x00b4, 0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x0105, 0x015f, 0x00bb, 0x013d, 0x02dd, 0x013e, 0x017c,
- /* c0 */ 0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7, 0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e,
- /* d0 */ 0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7, 0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df,
- /* e0 */ 0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7, 0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f,
- /* f0 */ 0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7, 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9,
-};
-
-
-Windows1250Encoding::Windows1250Encoding()
-{
-}
-
-
-Windows1250Encoding::~Windows1250Encoding()
-{
-}
-
-
-const char* Windows1250Encoding::canonicalName() const
-{
- return _names[0];
-}
-
-
-bool Windows1250Encoding::isA(const std::string& encodingName) const
-{
- for (const char** name = _names; *name; ++name)
- {
- if (Poco::icompare(encodingName, *name) == 0)
- return true;
- }
- return false;
-}
-
-
-const TextEncoding::CharacterMap& Windows1250Encoding::characterMap() const
-{
- return _charMap;
-}
-
-
-int Windows1250Encoding::convert(const unsigned char* bytes) const
-{
- return _charMap[*bytes];
-}
-
-
-int Windows1250Encoding::convert(int ch, unsigned char* bytes, int length) const
-{
- if (ch >= 0 && ch <= 255 && _charMap[ch] == ch)
- {
- if (bytes && length >= 1)
- *bytes = (unsigned char) ch;
- return 1;
- }
- else switch(ch)
- {
- case 0x20ac: if (bytes && length >= 1) *bytes = 0x80; return 1;
- case 0x201a: if (bytes && length >= 1) *bytes = 0x82; return 1;
- case 0x201e: if (bytes && length >= 1) *bytes = 0x84; return 1;
- case 0x2026: if (bytes && length >= 1) *bytes = 0x85; return 1;
- case 0x2020: if (bytes && length >= 1) *bytes = 0x86; return 1;
- case 0x2021: if (bytes && length >= 1) *bytes = 0x87; return 1;
- case 0x2030: if (bytes && length >= 1) *bytes = 0x89; return 1;
- case 0x0160: if (bytes && length >= 1) *bytes = 0x8a; return 1;
- case 0x2039: if (bytes && length >= 1) *bytes = 0x8b; return 1;
- case 0x015a: if (bytes && length >= 1) *bytes = 0x8c; return 1;
- case 0x0164: if (bytes && length >= 1) *bytes = 0x8d; return 1;
- case 0x017d: if (bytes && length >= 1) *bytes = 0x8e; return 1;
- case 0x0179: if (bytes && length >= 1) *bytes = 0x8f; return 1;
- case 0x2018: if (bytes && length >= 1) *bytes = 0x91; return 1;
- case 0x2019: if (bytes && length >= 1) *bytes = 0x92; return 1;
- case 0x201c: if (bytes && length >= 1) *bytes = 0x93; return 1;
- case 0x201d: if (bytes && length >= 1) *bytes = 0x94; return 1;
- case 0x2022: if (bytes && length >= 1) *bytes = 0x95; return 1;
- case 0x2013: if (bytes && length >= 1) *bytes = 0x96; return 1;
- case 0x2014: if (bytes && length >= 1) *bytes = 0x97; return 1;
- case 0x2122: if (bytes && length >= 1) *bytes = 0x99; return 1;
- case 0x0161: if (bytes && length >= 1) *bytes = 0x9a; return 1;
- case 0x203a: if (bytes && length >= 1) *bytes = 0x9b; return 1;
- case 0x015b: if (bytes && length >= 1) *bytes = 0x9c; return 1;
- case 0x0165: if (bytes && length >= 1) *bytes = 0x9d; return 1;
- case 0x017e: if (bytes && length >= 1) *bytes = 0x9e; return 1;
- case 0x017a: if (bytes && length >= 1) *bytes = 0x9f; return 1;
- case 0x02c7: if (bytes && length >= 1) *bytes = 0xa1; return 1;
- case 0x02d8: if (bytes && length >= 1) *bytes = 0xa2; return 1;
- case 0x0141: if (bytes && length >= 1) *bytes = 0xa3; return 1;
- case 0x0104: if (bytes && length >= 1) *bytes = 0xa5; return 1;
- case 0x015e: if (bytes && length >= 1) *bytes = 0xaa; return 1;
- case 0x017b: if (bytes && length >= 1) *bytes = 0xaf; return 1;
- case 0x02db: if (bytes && length >= 1) *bytes = 0xb2; return 1;
- case 0x0142: if (bytes && length >= 1) *bytes = 0xb3; return 1;
- case 0x0105: if (bytes && length >= 1) *bytes = 0xb9; return 1;
- case 0x015f: if (bytes && length >= 1) *bytes = 0xba; return 1;
- case 0x013d: if (bytes && length >= 1) *bytes = 0xbc; return 1;
- case 0x02dd: if (bytes && length >= 1) *bytes = 0xbd; return 1;
- case 0x013e: if (bytes && length >= 1) *bytes = 0xbe; return 1;
- case 0x017c: if (bytes && length >= 1) *bytes = 0xbf; return 1;
- case 0x0154: if (bytes && length >= 1) *bytes = 0xc0; return 1;
- case 0x0102: if (bytes && length >= 1) *bytes = 0xc3; return 1;
- case 0x0139: if (bytes && length >= 1) *bytes = 0xc5; return 1;
- case 0x0106: if (bytes && length >= 1) *bytes = 0xc6; return 1;
- case 0x010c: if (bytes && length >= 1) *bytes = 0xc8; return 1;
- case 0x0118: if (bytes && length >= 1) *bytes = 0xca; return 1;
- case 0x011a: if (bytes && length >= 1) *bytes = 0xcc; return 1;
- case 0x010e: if (bytes && length >= 1) *bytes = 0xcf; return 1;
- case 0x0110: if (bytes && length >= 1) *bytes = 0xd0; return 1;
- case 0x0143: if (bytes && length >= 1) *bytes = 0xd1; return 1;
- case 0x0147: if (bytes && length >= 1) *bytes = 0xd2; return 1;
- case 0x0150: if (bytes && length >= 1) *bytes = 0xd5; return 1;
- case 0x0158: if (bytes && length >= 1) *bytes = 0xd8; return 1;
- case 0x016e: if (bytes && length >= 1) *bytes = 0xd9; return 1;
- case 0x0170: if (bytes && length >= 1) *bytes = 0xdb; return 1;
- case 0x0162: if (bytes && length >= 1) *bytes = 0xde; return 1;
- case 0x0155: if (bytes && length >= 1) *bytes = 0xe0; return 1;
- case 0x0103: if (bytes && length >= 1) *bytes = 0xe3; return 1;
- case 0x013a: if (bytes && length >= 1) *bytes = 0xe5; return 1;
- case 0x0107: if (bytes && length >= 1) *bytes = 0xe6; return 1;
- case 0x010d: if (bytes && length >= 1) *bytes = 0xe8; return 1;
- case 0x0119: if (bytes && length >= 1) *bytes = 0xea; return 1;
- case 0x011b: if (bytes && length >= 1) *bytes = 0xec; return 1;
- case 0x010f: if (bytes && length >= 1) *bytes = 0xef; return 1;
- case 0x0111: if (bytes && length >= 1) *bytes = 0xf0; return 1;
- case 0x0144: if (bytes && length >= 1) *bytes = 0xf1; return 1;
- case 0x0148: if (bytes && length >= 1) *bytes = 0xf2; return 1;
- case 0x0151: if (bytes && length >= 1) *bytes = 0xf5; return 1;
- case 0x0159: if (bytes && length >= 1) *bytes = 0xf8; return 1;
- case 0x016f: if (bytes && length >= 1) *bytes = 0xf9; return 1;
- case 0x0171: if (bytes && length >= 1) *bytes = 0xfb; return 1;
- case 0x0163: if (bytes && length >= 1) *bytes = 0xfe; return 1;
- default: return 0;
- }
-}
-
-
-int Windows1250Encoding::queryConvert(const unsigned char* bytes, int length) const
-{
- if (1 <= length)
- return _charMap[*bytes];
- else
- return -1;
-}
-
-
-int Windows1250Encoding::sequenceLength(const unsigned char* /*bytes*/, int /*length*/) const
-{
- return 1;
-}
-
-
-} // namespace Poco
+//
+// Windows1250Encoding.cpp
+//
+// Library: Foundation
+// Package: Text
+// Module: Windows1250Encoding
+//
+// Copyright (c) 2005-2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Windows1250Encoding.h"
+#include "Poco/String.h"
+
+
+namespace Poco {
+
+
+const char* Windows1250Encoding::_names[] =
+{
+ "windows-1250",
+ "Windows-1250",
+ "cp1250",
+ "CP1250",
+ NULL
+};
+
+
+const TextEncoding::CharacterMap Windows1250Encoding::_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 */ 0x20ac, 0xfffe, 0x201a, 0xfffe, 0x201e, 0x2026, 0x2020, 0x2021, 0xfffe, 0x2030, 0x0160, 0x2039, 0x015a, 0x0164, 0x017d, 0x0179,
+ /* 90 */ 0xfffe, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0xfffe, 0x2122, 0x0161, 0x203a, 0x015b, 0x0165, 0x017e, 0x017a,
+ /* a0 */ 0x00a0, 0x02c7, 0x02d8, 0x0141, 0x00a4, 0x0104, 0x00a6, 0x00a7, 0x00a8, 0x00a9, 0x015e, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x017b,
+ /* b0 */ 0x00b0, 0x00b1, 0x02db, 0x0142, 0x00b4, 0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x0105, 0x015f, 0x00bb, 0x013d, 0x02dd, 0x013e, 0x017c,
+ /* c0 */ 0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7, 0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e,
+ /* d0 */ 0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7, 0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df,
+ /* e0 */ 0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7, 0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f,
+ /* f0 */ 0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7, 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9,
+};
+
+
+Windows1250Encoding::Windows1250Encoding()
+{
+}
+
+
+Windows1250Encoding::~Windows1250Encoding()
+{
+}
+
+
+const char* Windows1250Encoding::canonicalName() const
+{
+ return _names[0];
+}
+
+
+bool Windows1250Encoding::isA(const std::string& encodingName) const
+{
+ for (const char** name = _names; *name; ++name)
+ {
+ if (Poco::icompare(encodingName, *name) == 0)
+ return true;
+ }
+ return false;
+}
+
+
+const TextEncoding::CharacterMap& Windows1250Encoding::characterMap() const
+{
+ return _charMap;
+}
+
+
+int Windows1250Encoding::convert(const unsigned char* bytes) const
+{
+ return _charMap[*bytes];
+}
+
+
+int Windows1250Encoding::convert(int ch, unsigned char* bytes, int length) const
+{
+ if (ch >= 0 && ch <= 255 && _charMap[ch] == ch)
+ {
+ if (bytes && length >= 1)
+ *bytes = (unsigned char) ch;
+ return 1;
+ }
+ else switch(ch)
+ {
+ case 0x20ac: if (bytes && length >= 1) *bytes = 0x80; return 1;
+ case 0x201a: if (bytes && length >= 1) *bytes = 0x82; return 1;
+ case 0x201e: if (bytes && length >= 1) *bytes = 0x84; return 1;
+ case 0x2026: if (bytes && length >= 1) *bytes = 0x85; return 1;
+ case 0x2020: if (bytes && length >= 1) *bytes = 0x86; return 1;
+ case 0x2021: if (bytes && length >= 1) *bytes = 0x87; return 1;
+ case 0x2030: if (bytes && length >= 1) *bytes = 0x89; return 1;
+ case 0x0160: if (bytes && length >= 1) *bytes = 0x8a; return 1;
+ case 0x2039: if (bytes && length >= 1) *bytes = 0x8b; return 1;
+ case 0x015a: if (bytes && length >= 1) *bytes = 0x8c; return 1;
+ case 0x0164: if (bytes && length >= 1) *bytes = 0x8d; return 1;
+ case 0x017d: if (bytes && length >= 1) *bytes = 0x8e; return 1;
+ case 0x0179: if (bytes && length >= 1) *bytes = 0x8f; return 1;
+ case 0x2018: if (bytes && length >= 1) *bytes = 0x91; return 1;
+ case 0x2019: if (bytes && length >= 1) *bytes = 0x92; return 1;
+ case 0x201c: if (bytes && length >= 1) *bytes = 0x93; return 1;
+ case 0x201d: if (bytes && length >= 1) *bytes = 0x94; return 1;
+ case 0x2022: if (bytes && length >= 1) *bytes = 0x95; return 1;
+ case 0x2013: if (bytes && length >= 1) *bytes = 0x96; return 1;
+ case 0x2014: if (bytes && length >= 1) *bytes = 0x97; return 1;
+ case 0x2122: if (bytes && length >= 1) *bytes = 0x99; return 1;
+ case 0x0161: if (bytes && length >= 1) *bytes = 0x9a; return 1;
+ case 0x203a: if (bytes && length >= 1) *bytes = 0x9b; return 1;
+ case 0x015b: if (bytes && length >= 1) *bytes = 0x9c; return 1;
+ case 0x0165: if (bytes && length >= 1) *bytes = 0x9d; return 1;
+ case 0x017e: if (bytes && length >= 1) *bytes = 0x9e; return 1;
+ case 0x017a: if (bytes && length >= 1) *bytes = 0x9f; return 1;
+ case 0x02c7: if (bytes && length >= 1) *bytes = 0xa1; return 1;
+ case 0x02d8: if (bytes && length >= 1) *bytes = 0xa2; return 1;
+ case 0x0141: if (bytes && length >= 1) *bytes = 0xa3; return 1;
+ case 0x0104: if (bytes && length >= 1) *bytes = 0xa5; return 1;
+ case 0x015e: if (bytes && length >= 1) *bytes = 0xaa; return 1;
+ case 0x017b: if (bytes && length >= 1) *bytes = 0xaf; return 1;
+ case 0x02db: if (bytes && length >= 1) *bytes = 0xb2; return 1;
+ case 0x0142: if (bytes && length >= 1) *bytes = 0xb3; return 1;
+ case 0x0105: if (bytes && length >= 1) *bytes = 0xb9; return 1;
+ case 0x015f: if (bytes && length >= 1) *bytes = 0xba; return 1;
+ case 0x013d: if (bytes && length >= 1) *bytes = 0xbc; return 1;
+ case 0x02dd: if (bytes && length >= 1) *bytes = 0xbd; return 1;
+ case 0x013e: if (bytes && length >= 1) *bytes = 0xbe; return 1;
+ case 0x017c: if (bytes && length >= 1) *bytes = 0xbf; return 1;
+ case 0x0154: if (bytes && length >= 1) *bytes = 0xc0; return 1;
+ case 0x0102: if (bytes && length >= 1) *bytes = 0xc3; return 1;
+ case 0x0139: if (bytes && length >= 1) *bytes = 0xc5; return 1;
+ case 0x0106: if (bytes && length >= 1) *bytes = 0xc6; return 1;
+ case 0x010c: if (bytes && length >= 1) *bytes = 0xc8; return 1;
+ case 0x0118: if (bytes && length >= 1) *bytes = 0xca; return 1;
+ case 0x011a: if (bytes && length >= 1) *bytes = 0xcc; return 1;
+ case 0x010e: if (bytes && length >= 1) *bytes = 0xcf; return 1;
+ case 0x0110: if (bytes && length >= 1) *bytes = 0xd0; return 1;
+ case 0x0143: if (bytes && length >= 1) *bytes = 0xd1; return 1;
+ case 0x0147: if (bytes && length >= 1) *bytes = 0xd2; return 1;
+ case 0x0150: if (bytes && length >= 1) *bytes = 0xd5; return 1;
+ case 0x0158: if (bytes && length >= 1) *bytes = 0xd8; return 1;
+ case 0x016e: if (bytes && length >= 1) *bytes = 0xd9; return 1;
+ case 0x0170: if (bytes && length >= 1) *bytes = 0xdb; return 1;
+ case 0x0162: if (bytes && length >= 1) *bytes = 0xde; return 1;
+ case 0x0155: if (bytes && length >= 1) *bytes = 0xe0; return 1;
+ case 0x0103: if (bytes && length >= 1) *bytes = 0xe3; return 1;
+ case 0x013a: if (bytes && length >= 1) *bytes = 0xe5; return 1;
+ case 0x0107: if (bytes && length >= 1) *bytes = 0xe6; return 1;
+ case 0x010d: if (bytes && length >= 1) *bytes = 0xe8; return 1;
+ case 0x0119: if (bytes && length >= 1) *bytes = 0xea; return 1;
+ case 0x011b: if (bytes && length >= 1) *bytes = 0xec; return 1;
+ case 0x010f: if (bytes && length >= 1) *bytes = 0xef; return 1;
+ case 0x0111: if (bytes && length >= 1) *bytes = 0xf0; return 1;
+ case 0x0144: if (bytes && length >= 1) *bytes = 0xf1; return 1;
+ case 0x0148: if (bytes && length >= 1) *bytes = 0xf2; return 1;
+ case 0x0151: if (bytes && length >= 1) *bytes = 0xf5; return 1;
+ case 0x0159: if (bytes && length >= 1) *bytes = 0xf8; return 1;
+ case 0x016f: if (bytes && length >= 1) *bytes = 0xf9; return 1;
+ case 0x0171: if (bytes && length >= 1) *bytes = 0xfb; return 1;
+ case 0x0163: if (bytes && length >= 1) *bytes = 0xfe; return 1;
+ default: return 0;
+ }
+}
+
+
+int Windows1250Encoding::queryConvert(const unsigned char* bytes, int length) const
+{
+ if (1 <= length)
+ return _charMap[*bytes];
+ else
+ return -1;
+}
+
+
+int Windows1250Encoding::sequenceLength(const unsigned char* /*bytes*/, int /*length*/) const
+{
+ return 1;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/Windows1251Encoding.cpp b/contrib/libs/poco/Foundation/src/Windows1251Encoding.cpp
index 8563d34eee..4f1169531b 100644
--- a/contrib/libs/poco/Foundation/src/Windows1251Encoding.cpp
+++ b/contrib/libs/poco/Foundation/src/Windows1251Encoding.cpp
@@ -1,237 +1,237 @@
-//
-// Windows1251Encoding.cpp
-//
-// Library: Foundation
-// Package: Text
-// Module: Windows1251Encoding
-//
-// Copyright (c) 2005-2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Windows1251Encoding.h"
-#include "Poco/String.h"
-
-
-namespace Poco {
-
-
-const char* Windows1251Encoding::_names[] =
-{
- "windows-1251",
- "Windows-1251",
- "cp1251",
- "CP1251",
- NULL
-};
-
-
-const TextEncoding::CharacterMap Windows1251Encoding::_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 */ 0x0402, 0x0403, 0x201a, 0x0453, 0x201e, 0x2026, 0x2020, 0x2021, 0x20ac, 0x2030, 0x0409, 0x2039, 0x040a, 0x040c, 0x040b, 0x040f,
- /* 90 */ 0x0452, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0xfffe, 0x2122, 0x0459, 0x203a, 0x045a, 0x045c, 0x045b, 0x045f,
- /* a0 */ 0x00a0, 0x040e, 0x045e, 0x0408, 0x00a4, 0x0490, 0x00a6, 0x00a7, 0x0401, 0x00a9, 0x0404, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x0407,
- /* b0 */ 0x00b0, 0x00b1, 0x0406, 0x0456, 0x0491, 0x00b5, 0x00b6, 0x00b7, 0x0451, 0x2116, 0x0454, 0x00bb, 0x0458, 0x0405, 0x0455, 0x0457,
- /* c0 */ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f,
- /* d0 */ 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f,
- /* e0 */ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f,
- /* f0 */ 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f,
-};
-
-
-Windows1251Encoding::Windows1251Encoding()
-{
-}
-
-
-Windows1251Encoding::~Windows1251Encoding()
-{
-}
-
-
-const char* Windows1251Encoding::canonicalName() const
-{
- return _names[0];
-}
-
-
-bool Windows1251Encoding::isA(const std::string& encodingName) const
-{
- for (const char** name = _names; *name; ++name)
- {
- if (Poco::icompare(encodingName, *name) == 0)
- return true;
- }
- return false;
-}
-
-
-const TextEncoding::CharacterMap& Windows1251Encoding::characterMap() const
-{
- return _charMap;
-}
-
-
-int Windows1251Encoding::convert(const unsigned char* bytes) const
-{
- return _charMap[*bytes];
-}
-
-
-int Windows1251Encoding::convert(int ch, unsigned char* bytes, int length) const
-{
- if (ch >= 0 && ch <= 255 && _charMap[ch] == ch)
- {
- if (bytes && length >= 1)
- *bytes = (unsigned char) ch;
- return 1;
- }
- else switch(ch)
- {
- case 0x0402: if (bytes && length >= 1) *bytes = 0x80; return 1;
- case 0x0403: if (bytes && length >= 1) *bytes = 0x81; return 1;
- case 0x201a: if (bytes && length >= 1) *bytes = 0x82; return 1;
- case 0x0453: if (bytes && length >= 1) *bytes = 0x83; return 1;
- case 0x201e: if (bytes && length >= 1) *bytes = 0x84; return 1;
- case 0x2026: if (bytes && length >= 1) *bytes = 0x85; return 1;
- case 0x2020: if (bytes && length >= 1) *bytes = 0x86; return 1;
- case 0x2021: if (bytes && length >= 1) *bytes = 0x87; return 1;
- case 0x20ac: if (bytes && length >= 1) *bytes = 0x88; return 1;
- case 0x2030: if (bytes && length >= 1) *bytes = 0x89; return 1;
- case 0x0409: if (bytes && length >= 1) *bytes = 0x8a; return 1;
- case 0x2039: if (bytes && length >= 1) *bytes = 0x8b; return 1;
- case 0x040a: if (bytes && length >= 1) *bytes = 0x8c; return 1;
- case 0x040c: if (bytes && length >= 1) *bytes = 0x8d; return 1;
- case 0x040b: if (bytes && length >= 1) *bytes = 0x8e; return 1;
- case 0x040f: if (bytes && length >= 1) *bytes = 0x8f; return 1;
- case 0x0452: if (bytes && length >= 1) *bytes = 0x90; return 1;
- case 0x2018: if (bytes && length >= 1) *bytes = 0x91; return 1;
- case 0x2019: if (bytes && length >= 1) *bytes = 0x92; return 1;
- case 0x201c: if (bytes && length >= 1) *bytes = 0x93; return 1;
- case 0x201d: if (bytes && length >= 1) *bytes = 0x94; return 1;
- case 0x2022: if (bytes && length >= 1) *bytes = 0x95; return 1;
- case 0x2013: if (bytes && length >= 1) *bytes = 0x96; return 1;
- case 0x2014: if (bytes && length >= 1) *bytes = 0x97; return 1;
- case 0xfffe: if (bytes && length >= 1) *bytes = 0x98; return 1;
- case 0x2122: if (bytes && length >= 1) *bytes = 0x99; return 1;
- case 0x0459: if (bytes && length >= 1) *bytes = 0x9a; return 1;
- case 0x203a: if (bytes && length >= 1) *bytes = 0x9b; return 1;
- case 0x045a: if (bytes && length >= 1) *bytes = 0x9c; return 1;
- case 0x045c: if (bytes && length >= 1) *bytes = 0x9d; return 1;
- case 0x045b: if (bytes && length >= 1) *bytes = 0x9e; return 1;
- case 0x045f: if (bytes && length >= 1) *bytes = 0x9f; return 1;
- case 0x040e: if (bytes && length >= 1) *bytes = 0xa1; return 1;
- case 0x045e: if (bytes && length >= 1) *bytes = 0xa2; return 1;
- case 0x0408: if (bytes && length >= 1) *bytes = 0xa3; return 1;
- case 0x0490: if (bytes && length >= 1) *bytes = 0xa5; return 1;
- case 0x0401: if (bytes && length >= 1) *bytes = 0xa8; return 1;
- case 0x0404: if (bytes && length >= 1) *bytes = 0xaa; return 1;
- case 0x0407: if (bytes && length >= 1) *bytes = 0xaf; return 1;
- case 0x0406: if (bytes && length >= 1) *bytes = 0xb2; return 1;
- case 0x0456: if (bytes && length >= 1) *bytes = 0xb3; return 1;
- case 0x0491: if (bytes && length >= 1) *bytes = 0xb4; return 1;
- case 0x0451: if (bytes && length >= 1) *bytes = 0xb8; return 1;
- case 0x2116: if (bytes && length >= 1) *bytes = 0xb9; return 1;
- case 0x0454: if (bytes && length >= 1) *bytes = 0xba; return 1;
- case 0x0458: if (bytes && length >= 1) *bytes = 0xbc; return 1;
- case 0x0405: if (bytes && length >= 1) *bytes = 0xbd; return 1;
- case 0x0455: if (bytes && length >= 1) *bytes = 0xbe; return 1;
- case 0x0457: if (bytes && length >= 1) *bytes = 0xbf; return 1;
- case 0x0410: if (bytes && length >= 1) *bytes = 0xc0; return 1;
- case 0x0411: if (bytes && length >= 1) *bytes = 0xc1; return 1;
- case 0x0412: if (bytes && length >= 1) *bytes = 0xc2; return 1;
- case 0x0413: if (bytes && length >= 1) *bytes = 0xc3; return 1;
- case 0x0414: if (bytes && length >= 1) *bytes = 0xc4; return 1;
- case 0x0415: if (bytes && length >= 1) *bytes = 0xc5; return 1;
- case 0x0416: if (bytes && length >= 1) *bytes = 0xc6; return 1;
- case 0x0417: if (bytes && length >= 1) *bytes = 0xc7; return 1;
- case 0x0418: if (bytes && length >= 1) *bytes = 0xc8; return 1;
- case 0x0419: if (bytes && length >= 1) *bytes = 0xc9; return 1;
- case 0x041a: if (bytes && length >= 1) *bytes = 0xca; return 1;
- case 0x041b: if (bytes && length >= 1) *bytes = 0xcb; return 1;
- case 0x041c: if (bytes && length >= 1) *bytes = 0xcc; return 1;
- case 0x041d: if (bytes && length >= 1) *bytes = 0xcd; return 1;
- case 0x041e: if (bytes && length >= 1) *bytes = 0xce; return 1;
- case 0x041f: if (bytes && length >= 1) *bytes = 0xcf; return 1;
- case 0x0420: if (bytes && length >= 1) *bytes = 0xd0; return 1;
- case 0x0421: if (bytes && length >= 1) *bytes = 0xd1; return 1;
- case 0x0422: if (bytes && length >= 1) *bytes = 0xd2; return 1;
- case 0x0423: if (bytes && length >= 1) *bytes = 0xd3; return 1;
- case 0x0424: if (bytes && length >= 1) *bytes = 0xd4; return 1;
- case 0x0425: if (bytes && length >= 1) *bytes = 0xd5; return 1;
- case 0x0426: if (bytes && length >= 1) *bytes = 0xd6; return 1;
- case 0x0427: if (bytes && length >= 1) *bytes = 0xd7; return 1;
- case 0x0428: if (bytes && length >= 1) *bytes = 0xd8; return 1;
- case 0x0429: if (bytes && length >= 1) *bytes = 0xd9; return 1;
- case 0x042a: if (bytes && length >= 1) *bytes = 0xda; return 1;
- case 0x042b: if (bytes && length >= 1) *bytes = 0xdb; return 1;
- case 0x042c: if (bytes && length >= 1) *bytes = 0xdc; return 1;
- case 0x042d: if (bytes && length >= 1) *bytes = 0xdd; return 1;
- case 0x042e: if (bytes && length >= 1) *bytes = 0xde; return 1;
- case 0x042f: if (bytes && length >= 1) *bytes = 0xdf; return 1;
- case 0x0430: if (bytes && length >= 1) *bytes = 0xe0; return 1;
- case 0x0431: if (bytes && length >= 1) *bytes = 0xe1; return 1;
- case 0x0432: if (bytes && length >= 1) *bytes = 0xe2; return 1;
- case 0x0433: if (bytes && length >= 1) *bytes = 0xe3; return 1;
- case 0x0434: if (bytes && length >= 1) *bytes = 0xe4; return 1;
- case 0x0435: if (bytes && length >= 1) *bytes = 0xe5; return 1;
- case 0x0436: if (bytes && length >= 1) *bytes = 0xe6; return 1;
- case 0x0437: if (bytes && length >= 1) *bytes = 0xe7; return 1;
- case 0x0438: if (bytes && length >= 1) *bytes = 0xe8; return 1;
- case 0x0439: if (bytes && length >= 1) *bytes = 0xe9; return 1;
- case 0x043a: if (bytes && length >= 1) *bytes = 0xea; return 1;
- case 0x043b: if (bytes && length >= 1) *bytes = 0xeb; return 1;
- case 0x043c: if (bytes && length >= 1) *bytes = 0xec; return 1;
- case 0x043d: if (bytes && length >= 1) *bytes = 0xed; return 1;
- case 0x043e: if (bytes && length >= 1) *bytes = 0xee; return 1;
- case 0x043f: if (bytes && length >= 1) *bytes = 0xef; return 1;
- case 0x0440: if (bytes && length >= 1) *bytes = 0xf0; return 1;
- case 0x0441: if (bytes && length >= 1) *bytes = 0xf1; return 1;
- case 0x0442: if (bytes && length >= 1) *bytes = 0xf2; return 1;
- case 0x0443: if (bytes && length >= 1) *bytes = 0xf3; return 1;
- case 0x0444: if (bytes && length >= 1) *bytes = 0xf4; return 1;
- case 0x0445: if (bytes && length >= 1) *bytes = 0xf5; return 1;
- case 0x0446: if (bytes && length >= 1) *bytes = 0xf6; return 1;
- case 0x0447: if (bytes && length >= 1) *bytes = 0xf7; return 1;
- case 0x0448: if (bytes && length >= 1) *bytes = 0xf8; return 1;
- case 0x0449: if (bytes && length >= 1) *bytes = 0xf9; return 1;
- case 0x044a: if (bytes && length >= 1) *bytes = 0xfa; return 1;
- case 0x044b: if (bytes && length >= 1) *bytes = 0xfb; return 1;
- case 0x044c: if (bytes && length >= 1) *bytes = 0xfc; return 1;
- case 0x044d: if (bytes && length >= 1) *bytes = 0xfd; return 1;
- case 0x044e: if (bytes && length >= 1) *bytes = 0xfe; return 1;
- case 0x044f: if (bytes && length >= 1) *bytes = 0xff; return 1;
- default: return 0;
- }
-}
-
-
-int Windows1251Encoding::queryConvert(const unsigned char* bytes, int length) const
-{
- if (1 <= length)
- return _charMap[*bytes];
- else
- return -1;
-}
-
-
-int Windows1251Encoding::sequenceLength(const unsigned char* /*bytes*/, int /*length*/) const
-{
- return 1;
-}
-
-
-} // namespace Poco
-
+//
+// Windows1251Encoding.cpp
+//
+// Library: Foundation
+// Package: Text
+// Module: Windows1251Encoding
+//
+// Copyright (c) 2005-2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Windows1251Encoding.h"
+#include "Poco/String.h"
+
+
+namespace Poco {
+
+
+const char* Windows1251Encoding::_names[] =
+{
+ "windows-1251",
+ "Windows-1251",
+ "cp1251",
+ "CP1251",
+ NULL
+};
+
+
+const TextEncoding::CharacterMap Windows1251Encoding::_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 */ 0x0402, 0x0403, 0x201a, 0x0453, 0x201e, 0x2026, 0x2020, 0x2021, 0x20ac, 0x2030, 0x0409, 0x2039, 0x040a, 0x040c, 0x040b, 0x040f,
+ /* 90 */ 0x0452, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0xfffe, 0x2122, 0x0459, 0x203a, 0x045a, 0x045c, 0x045b, 0x045f,
+ /* a0 */ 0x00a0, 0x040e, 0x045e, 0x0408, 0x00a4, 0x0490, 0x00a6, 0x00a7, 0x0401, 0x00a9, 0x0404, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x0407,
+ /* b0 */ 0x00b0, 0x00b1, 0x0406, 0x0456, 0x0491, 0x00b5, 0x00b6, 0x00b7, 0x0451, 0x2116, 0x0454, 0x00bb, 0x0458, 0x0405, 0x0455, 0x0457,
+ /* c0 */ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f,
+ /* d0 */ 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f,
+ /* e0 */ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f,
+ /* f0 */ 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f,
+};
+
+
+Windows1251Encoding::Windows1251Encoding()
+{
+}
+
+
+Windows1251Encoding::~Windows1251Encoding()
+{
+}
+
+
+const char* Windows1251Encoding::canonicalName() const
+{
+ return _names[0];
+}
+
+
+bool Windows1251Encoding::isA(const std::string& encodingName) const
+{
+ for (const char** name = _names; *name; ++name)
+ {
+ if (Poco::icompare(encodingName, *name) == 0)
+ return true;
+ }
+ return false;
+}
+
+
+const TextEncoding::CharacterMap& Windows1251Encoding::characterMap() const
+{
+ return _charMap;
+}
+
+
+int Windows1251Encoding::convert(const unsigned char* bytes) const
+{
+ return _charMap[*bytes];
+}
+
+
+int Windows1251Encoding::convert(int ch, unsigned char* bytes, int length) const
+{
+ if (ch >= 0 && ch <= 255 && _charMap[ch] == ch)
+ {
+ if (bytes && length >= 1)
+ *bytes = (unsigned char) ch;
+ return 1;
+ }
+ else switch(ch)
+ {
+ case 0x0402: if (bytes && length >= 1) *bytes = 0x80; return 1;
+ case 0x0403: if (bytes && length >= 1) *bytes = 0x81; return 1;
+ case 0x201a: if (bytes && length >= 1) *bytes = 0x82; return 1;
+ case 0x0453: if (bytes && length >= 1) *bytes = 0x83; return 1;
+ case 0x201e: if (bytes && length >= 1) *bytes = 0x84; return 1;
+ case 0x2026: if (bytes && length >= 1) *bytes = 0x85; return 1;
+ case 0x2020: if (bytes && length >= 1) *bytes = 0x86; return 1;
+ case 0x2021: if (bytes && length >= 1) *bytes = 0x87; return 1;
+ case 0x20ac: if (bytes && length >= 1) *bytes = 0x88; return 1;
+ case 0x2030: if (bytes && length >= 1) *bytes = 0x89; return 1;
+ case 0x0409: if (bytes && length >= 1) *bytes = 0x8a; return 1;
+ case 0x2039: if (bytes && length >= 1) *bytes = 0x8b; return 1;
+ case 0x040a: if (bytes && length >= 1) *bytes = 0x8c; return 1;
+ case 0x040c: if (bytes && length >= 1) *bytes = 0x8d; return 1;
+ case 0x040b: if (bytes && length >= 1) *bytes = 0x8e; return 1;
+ case 0x040f: if (bytes && length >= 1) *bytes = 0x8f; return 1;
+ case 0x0452: if (bytes && length >= 1) *bytes = 0x90; return 1;
+ case 0x2018: if (bytes && length >= 1) *bytes = 0x91; return 1;
+ case 0x2019: if (bytes && length >= 1) *bytes = 0x92; return 1;
+ case 0x201c: if (bytes && length >= 1) *bytes = 0x93; return 1;
+ case 0x201d: if (bytes && length >= 1) *bytes = 0x94; return 1;
+ case 0x2022: if (bytes && length >= 1) *bytes = 0x95; return 1;
+ case 0x2013: if (bytes && length >= 1) *bytes = 0x96; return 1;
+ case 0x2014: if (bytes && length >= 1) *bytes = 0x97; return 1;
+ case 0xfffe: if (bytes && length >= 1) *bytes = 0x98; return 1;
+ case 0x2122: if (bytes && length >= 1) *bytes = 0x99; return 1;
+ case 0x0459: if (bytes && length >= 1) *bytes = 0x9a; return 1;
+ case 0x203a: if (bytes && length >= 1) *bytes = 0x9b; return 1;
+ case 0x045a: if (bytes && length >= 1) *bytes = 0x9c; return 1;
+ case 0x045c: if (bytes && length >= 1) *bytes = 0x9d; return 1;
+ case 0x045b: if (bytes && length >= 1) *bytes = 0x9e; return 1;
+ case 0x045f: if (bytes && length >= 1) *bytes = 0x9f; return 1;
+ case 0x040e: if (bytes && length >= 1) *bytes = 0xa1; return 1;
+ case 0x045e: if (bytes && length >= 1) *bytes = 0xa2; return 1;
+ case 0x0408: if (bytes && length >= 1) *bytes = 0xa3; return 1;
+ case 0x0490: if (bytes && length >= 1) *bytes = 0xa5; return 1;
+ case 0x0401: if (bytes && length >= 1) *bytes = 0xa8; return 1;
+ case 0x0404: if (bytes && length >= 1) *bytes = 0xaa; return 1;
+ case 0x0407: if (bytes && length >= 1) *bytes = 0xaf; return 1;
+ case 0x0406: if (bytes && length >= 1) *bytes = 0xb2; return 1;
+ case 0x0456: if (bytes && length >= 1) *bytes = 0xb3; return 1;
+ case 0x0491: if (bytes && length >= 1) *bytes = 0xb4; return 1;
+ case 0x0451: if (bytes && length >= 1) *bytes = 0xb8; return 1;
+ case 0x2116: if (bytes && length >= 1) *bytes = 0xb9; return 1;
+ case 0x0454: if (bytes && length >= 1) *bytes = 0xba; return 1;
+ case 0x0458: if (bytes && length >= 1) *bytes = 0xbc; return 1;
+ case 0x0405: if (bytes && length >= 1) *bytes = 0xbd; return 1;
+ case 0x0455: if (bytes && length >= 1) *bytes = 0xbe; return 1;
+ case 0x0457: if (bytes && length >= 1) *bytes = 0xbf; return 1;
+ case 0x0410: if (bytes && length >= 1) *bytes = 0xc0; return 1;
+ case 0x0411: if (bytes && length >= 1) *bytes = 0xc1; return 1;
+ case 0x0412: if (bytes && length >= 1) *bytes = 0xc2; return 1;
+ case 0x0413: if (bytes && length >= 1) *bytes = 0xc3; return 1;
+ case 0x0414: if (bytes && length >= 1) *bytes = 0xc4; return 1;
+ case 0x0415: if (bytes && length >= 1) *bytes = 0xc5; return 1;
+ case 0x0416: if (bytes && length >= 1) *bytes = 0xc6; return 1;
+ case 0x0417: if (bytes && length >= 1) *bytes = 0xc7; return 1;
+ case 0x0418: if (bytes && length >= 1) *bytes = 0xc8; return 1;
+ case 0x0419: if (bytes && length >= 1) *bytes = 0xc9; return 1;
+ case 0x041a: if (bytes && length >= 1) *bytes = 0xca; return 1;
+ case 0x041b: if (bytes && length >= 1) *bytes = 0xcb; return 1;
+ case 0x041c: if (bytes && length >= 1) *bytes = 0xcc; return 1;
+ case 0x041d: if (bytes && length >= 1) *bytes = 0xcd; return 1;
+ case 0x041e: if (bytes && length >= 1) *bytes = 0xce; return 1;
+ case 0x041f: if (bytes && length >= 1) *bytes = 0xcf; return 1;
+ case 0x0420: if (bytes && length >= 1) *bytes = 0xd0; return 1;
+ case 0x0421: if (bytes && length >= 1) *bytes = 0xd1; return 1;
+ case 0x0422: if (bytes && length >= 1) *bytes = 0xd2; return 1;
+ case 0x0423: if (bytes && length >= 1) *bytes = 0xd3; return 1;
+ case 0x0424: if (bytes && length >= 1) *bytes = 0xd4; return 1;
+ case 0x0425: if (bytes && length >= 1) *bytes = 0xd5; return 1;
+ case 0x0426: if (bytes && length >= 1) *bytes = 0xd6; return 1;
+ case 0x0427: if (bytes && length >= 1) *bytes = 0xd7; return 1;
+ case 0x0428: if (bytes && length >= 1) *bytes = 0xd8; return 1;
+ case 0x0429: if (bytes && length >= 1) *bytes = 0xd9; return 1;
+ case 0x042a: if (bytes && length >= 1) *bytes = 0xda; return 1;
+ case 0x042b: if (bytes && length >= 1) *bytes = 0xdb; return 1;
+ case 0x042c: if (bytes && length >= 1) *bytes = 0xdc; return 1;
+ case 0x042d: if (bytes && length >= 1) *bytes = 0xdd; return 1;
+ case 0x042e: if (bytes && length >= 1) *bytes = 0xde; return 1;
+ case 0x042f: if (bytes && length >= 1) *bytes = 0xdf; return 1;
+ case 0x0430: if (bytes && length >= 1) *bytes = 0xe0; return 1;
+ case 0x0431: if (bytes && length >= 1) *bytes = 0xe1; return 1;
+ case 0x0432: if (bytes && length >= 1) *bytes = 0xe2; return 1;
+ case 0x0433: if (bytes && length >= 1) *bytes = 0xe3; return 1;
+ case 0x0434: if (bytes && length >= 1) *bytes = 0xe4; return 1;
+ case 0x0435: if (bytes && length >= 1) *bytes = 0xe5; return 1;
+ case 0x0436: if (bytes && length >= 1) *bytes = 0xe6; return 1;
+ case 0x0437: if (bytes && length >= 1) *bytes = 0xe7; return 1;
+ case 0x0438: if (bytes && length >= 1) *bytes = 0xe8; return 1;
+ case 0x0439: if (bytes && length >= 1) *bytes = 0xe9; return 1;
+ case 0x043a: if (bytes && length >= 1) *bytes = 0xea; return 1;
+ case 0x043b: if (bytes && length >= 1) *bytes = 0xeb; return 1;
+ case 0x043c: if (bytes && length >= 1) *bytes = 0xec; return 1;
+ case 0x043d: if (bytes && length >= 1) *bytes = 0xed; return 1;
+ case 0x043e: if (bytes && length >= 1) *bytes = 0xee; return 1;
+ case 0x043f: if (bytes && length >= 1) *bytes = 0xef; return 1;
+ case 0x0440: if (bytes && length >= 1) *bytes = 0xf0; return 1;
+ case 0x0441: if (bytes && length >= 1) *bytes = 0xf1; return 1;
+ case 0x0442: if (bytes && length >= 1) *bytes = 0xf2; return 1;
+ case 0x0443: if (bytes && length >= 1) *bytes = 0xf3; return 1;
+ case 0x0444: if (bytes && length >= 1) *bytes = 0xf4; return 1;
+ case 0x0445: if (bytes && length >= 1) *bytes = 0xf5; return 1;
+ case 0x0446: if (bytes && length >= 1) *bytes = 0xf6; return 1;
+ case 0x0447: if (bytes && length >= 1) *bytes = 0xf7; return 1;
+ case 0x0448: if (bytes && length >= 1) *bytes = 0xf8; return 1;
+ case 0x0449: if (bytes && length >= 1) *bytes = 0xf9; return 1;
+ case 0x044a: if (bytes && length >= 1) *bytes = 0xfa; return 1;
+ case 0x044b: if (bytes && length >= 1) *bytes = 0xfb; return 1;
+ case 0x044c: if (bytes && length >= 1) *bytes = 0xfc; return 1;
+ case 0x044d: if (bytes && length >= 1) *bytes = 0xfd; return 1;
+ case 0x044e: if (bytes && length >= 1) *bytes = 0xfe; return 1;
+ case 0x044f: if (bytes && length >= 1) *bytes = 0xff; return 1;
+ default: return 0;
+ }
+}
+
+
+int Windows1251Encoding::queryConvert(const unsigned char* bytes, int length) const
+{
+ if (1 <= length)
+ return _charMap[*bytes];
+ else
+ return -1;
+}
+
+
+int Windows1251Encoding::sequenceLength(const unsigned char* /*bytes*/, int /*length*/) const
+{
+ return 1;
+}
+
+
+} // namespace Poco
+
diff --git a/contrib/libs/poco/Foundation/src/Windows1252Encoding.cpp b/contrib/libs/poco/Foundation/src/Windows1252Encoding.cpp
index 3b03b548ed..f90817d440 100644
--- a/contrib/libs/poco/Foundation/src/Windows1252Encoding.cpp
+++ b/contrib/libs/poco/Foundation/src/Windows1252Encoding.cpp
@@ -1,151 +1,151 @@
-//
-// Windows1252Encoding.cpp
-//
-// Library: Foundation
-// Package: Text
-// Module: Windows1252Encoding
-//
-// Copyright (c) 2005-2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/Windows1252Encoding.h"
-#include "Poco/String.h"
-#include <map>
-
-
-namespace Poco {
-
-
-const char* Windows1252Encoding::_names[] =
-{
- "windows-1252",
- "Windows-1252",
- "cp1252",
- "CP1252",
- NULL
-};
-
-
-const TextEncoding::CharacterMap Windows1252Encoding::_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 */ 0x20ac, 0x0081, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021, 0x02c6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008d, 0x017d, 0x008f,
- /* 90 */ 0x0090, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0x02dc, 0x2122, 0x0161, 0x203a, 0x0153, 0x009d, 0x017e, 0x0178,
- /* a0 */ 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
- /* b0 */ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 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,
-};
-
-
-Windows1252Encoding::Windows1252Encoding()
-{
-}
-
-
-Windows1252Encoding::~Windows1252Encoding()
-{
-}
-
-
-const char* Windows1252Encoding::canonicalName() const
-{
- return _names[0];
-}
-
-
-bool Windows1252Encoding::isA(const std::string& encodingName) const
-{
- for (const char** name = _names; *name; ++name)
- {
- if (Poco::icompare(encodingName, *name) == 0)
- return true;
- }
- return false;
-}
-
-
-const TextEncoding::CharacterMap& Windows1252Encoding::characterMap() const
-{
- return _charMap;
-}
-
-
-int Windows1252Encoding::convert(const unsigned char* bytes) const
-{
- return _charMap[*bytes];
-}
-
-
-int Windows1252Encoding::convert(int ch, unsigned char* bytes, int length) const
-{
- if (ch >= 0 && ch <= 255 && _charMap[ch] == ch)
- {
- if (bytes && length >= 1)
- *bytes = static_cast<UInt8>(ch);
- return 1;
- }
- else switch (ch)
- {
- case 0x20ac: if (bytes && length >= 1) *bytes = 0x80; return 1;
- case 0x201a: if (bytes && length >= 1) *bytes = 0x82; return 1;
- case 0x0192: if (bytes && length >= 1) *bytes = 0x83; return 1;
- case 0x201e: if (bytes && length >= 1) *bytes = 0x84; return 1;
- case 0x2026: if (bytes && length >= 1) *bytes = 0x85; return 1;
- case 0x2020: if (bytes && length >= 1) *bytes = 0x86; return 1;
- case 0x2021: if (bytes && length >= 1) *bytes = 0x87; return 1;
- case 0x02c6: if (bytes && length >= 1) *bytes = 0x88; return 1;
- case 0x2030: if (bytes && length >= 1) *bytes = 0x89; return 1;
- case 0x0160: if (bytes && length >= 1) *bytes = 0x8a; return 1;
- case 0x2039: if (bytes && length >= 1) *bytes = 0x8b; return 1;
- case 0x0152: if (bytes && length >= 1) *bytes = 0x8c; return 1;
- case 0x017d: if (bytes && length >= 1) *bytes = 0x8e; return 1;
- case 0x2018: if (bytes && length >= 1) *bytes = 0x91; return 1;
- case 0x2019: if (bytes && length >= 1) *bytes = 0x92; return 1;
- case 0x201c: if (bytes && length >= 1) *bytes = 0x93; return 1;
- case 0x201d: if (bytes && length >= 1) *bytes = 0x94; return 1;
- case 0x2022: if (bytes && length >= 1) *bytes = 0x95; return 1;
- case 0x2013: if (bytes && length >= 1) *bytes = 0x96; return 1;
- case 0x2014: if (bytes && length >= 1) *bytes = 0x97; return 1;
- case 0x02dc: if (bytes && length >= 1) *bytes = 0x98; return 1;
- case 0x2122: if (bytes && length >= 1) *bytes = 0x99; return 1;
- case 0x0161: if (bytes && length >= 1) *bytes = 0x9a; return 1;
- case 0x203a: if (bytes && length >= 1) *bytes = 0x9b; return 1;
- case 0x0153: if (bytes && length >= 1) *bytes = 0x9c; return 1;
- case 0x017e: if (bytes && length >= 1) *bytes = 0x9e; return 1;
- case 0x0178: if (bytes && length >= 1) *bytes = 0x9f; return 1;
- default: return 0;
- }
-}
-
-
-int Windows1252Encoding::queryConvert(const unsigned char* bytes, int length) const
-{
- if (1 <= length)
- return _charMap[*bytes];
- else
- return -1;
-}
-
-
-int Windows1252Encoding::sequenceLength(const unsigned char* /*bytes*/, int /*length*/) const
-{
- return 1;
-}
-
-
-} // namespace Poco
+//
+// Windows1252Encoding.cpp
+//
+// Library: Foundation
+// Package: Text
+// Module: Windows1252Encoding
+//
+// Copyright (c) 2005-2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Windows1252Encoding.h"
+#include "Poco/String.h"
+#include <map>
+
+
+namespace Poco {
+
+
+const char* Windows1252Encoding::_names[] =
+{
+ "windows-1252",
+ "Windows-1252",
+ "cp1252",
+ "CP1252",
+ NULL
+};
+
+
+const TextEncoding::CharacterMap Windows1252Encoding::_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 */ 0x20ac, 0x0081, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021, 0x02c6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008d, 0x017d, 0x008f,
+ /* 90 */ 0x0090, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0x02dc, 0x2122, 0x0161, 0x203a, 0x0153, 0x009d, 0x017e, 0x0178,
+ /* a0 */ 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
+ /* b0 */ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 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,
+};
+
+
+Windows1252Encoding::Windows1252Encoding()
+{
+}
+
+
+Windows1252Encoding::~Windows1252Encoding()
+{
+}
+
+
+const char* Windows1252Encoding::canonicalName() const
+{
+ return _names[0];
+}
+
+
+bool Windows1252Encoding::isA(const std::string& encodingName) const
+{
+ for (const char** name = _names; *name; ++name)
+ {
+ if (Poco::icompare(encodingName, *name) == 0)
+ return true;
+ }
+ return false;
+}
+
+
+const TextEncoding::CharacterMap& Windows1252Encoding::characterMap() const
+{
+ return _charMap;
+}
+
+
+int Windows1252Encoding::convert(const unsigned char* bytes) const
+{
+ return _charMap[*bytes];
+}
+
+
+int Windows1252Encoding::convert(int ch, unsigned char* bytes, int length) const
+{
+ if (ch >= 0 && ch <= 255 && _charMap[ch] == ch)
+ {
+ if (bytes && length >= 1)
+ *bytes = static_cast<UInt8>(ch);
+ return 1;
+ }
+ else switch (ch)
+ {
+ case 0x20ac: if (bytes && length >= 1) *bytes = 0x80; return 1;
+ case 0x201a: if (bytes && length >= 1) *bytes = 0x82; return 1;
+ case 0x0192: if (bytes && length >= 1) *bytes = 0x83; return 1;
+ case 0x201e: if (bytes && length >= 1) *bytes = 0x84; return 1;
+ case 0x2026: if (bytes && length >= 1) *bytes = 0x85; return 1;
+ case 0x2020: if (bytes && length >= 1) *bytes = 0x86; return 1;
+ case 0x2021: if (bytes && length >= 1) *bytes = 0x87; return 1;
+ case 0x02c6: if (bytes && length >= 1) *bytes = 0x88; return 1;
+ case 0x2030: if (bytes && length >= 1) *bytes = 0x89; return 1;
+ case 0x0160: if (bytes && length >= 1) *bytes = 0x8a; return 1;
+ case 0x2039: if (bytes && length >= 1) *bytes = 0x8b; return 1;
+ case 0x0152: if (bytes && length >= 1) *bytes = 0x8c; return 1;
+ case 0x017d: if (bytes && length >= 1) *bytes = 0x8e; return 1;
+ case 0x2018: if (bytes && length >= 1) *bytes = 0x91; return 1;
+ case 0x2019: if (bytes && length >= 1) *bytes = 0x92; return 1;
+ case 0x201c: if (bytes && length >= 1) *bytes = 0x93; return 1;
+ case 0x201d: if (bytes && length >= 1) *bytes = 0x94; return 1;
+ case 0x2022: if (bytes && length >= 1) *bytes = 0x95; return 1;
+ case 0x2013: if (bytes && length >= 1) *bytes = 0x96; return 1;
+ case 0x2014: if (bytes && length >= 1) *bytes = 0x97; return 1;
+ case 0x02dc: if (bytes && length >= 1) *bytes = 0x98; return 1;
+ case 0x2122: if (bytes && length >= 1) *bytes = 0x99; return 1;
+ case 0x0161: if (bytes && length >= 1) *bytes = 0x9a; return 1;
+ case 0x203a: if (bytes && length >= 1) *bytes = 0x9b; return 1;
+ case 0x0153: if (bytes && length >= 1) *bytes = 0x9c; return 1;
+ case 0x017e: if (bytes && length >= 1) *bytes = 0x9e; return 1;
+ case 0x0178: if (bytes && length >= 1) *bytes = 0x9f; return 1;
+ default: return 0;
+ }
+}
+
+
+int Windows1252Encoding::queryConvert(const unsigned char* bytes, int length) const
+{
+ if (1 <= length)
+ return _charMap[*bytes];
+ else
+ return -1;
+}
+
+
+int Windows1252Encoding::sequenceLength(const unsigned char* /*bytes*/, int /*length*/) const
+{
+ return 1;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/WindowsConsoleChannel.cpp b/contrib/libs/poco/Foundation/src/WindowsConsoleChannel.cpp
index 07e352935f..1401a0bc60 100644
--- a/contrib/libs/poco/Foundation/src/WindowsConsoleChannel.cpp
+++ b/contrib/libs/poco/Foundation/src/WindowsConsoleChannel.cpp
@@ -1,302 +1,302 @@
-//
-// WindowsConsoleChannel.cpp
-//
-// Library: Foundation
-// Package: Logging
-// Module: WindowsConsoleChannel
-//
-// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/WindowsConsoleChannel.h"
-#include "Poco/Message.h"
-#if defined(POCO_WIN32_UTF8)
-#include "Poco/UnicodeConverter.h"
-#endif
-#include "Poco/String.h"
-#include "Poco/Exception.h"
-
-
-namespace Poco {
-
-
-WindowsConsoleChannel::WindowsConsoleChannel():
- _isFile(false),
- _hConsole(INVALID_HANDLE_VALUE)
-{
- _hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
- // check whether the console has been redirected
- DWORD mode;
- _isFile = (GetConsoleMode(_hConsole, &mode) == 0);
-}
-
-
-WindowsConsoleChannel::~WindowsConsoleChannel()
-{
-}
-
-
-void WindowsConsoleChannel::log(const Message& msg)
-{
- std::string text = msg.getText();
- text += "\r\n";
-
-#if defined(POCO_WIN32_UTF8)
- if (_isFile)
- {
- DWORD written;
- WriteFile(_hConsole, text.data(), static_cast<DWORD>(text.size()), &written, NULL);
- }
- else
- {
- std::wstring utext;
- UnicodeConverter::toUTF16(text, utext);
- DWORD written;
- WriteConsoleW(_hConsole, utext.data(), static_cast<DWORD>(utext.size()), &written, NULL);
- }
-#else
- DWORD written;
- WriteFile(_hConsole, text.data(), text.size(), &written, NULL);
-#endif
-}
-
-
-WindowsColorConsoleChannel::WindowsColorConsoleChannel():
- _enableColors(true),
- _isFile(false),
- _hConsole(INVALID_HANDLE_VALUE)
-{
- _hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
- // check whether the console has been redirected
- DWORD mode;
- _isFile = (GetConsoleMode(_hConsole, &mode) == 0);
- initColors();
-}
-
-
-WindowsColorConsoleChannel::~WindowsColorConsoleChannel()
-{
-}
-
-
-void WindowsColorConsoleChannel::log(const Message& msg)
-{
- std::string text = msg.getText();
- text += "\r\n";
-
- if (_enableColors && !_isFile)
- {
- WORD attr = _colors[0];
- attr &= 0xFFF0;
- attr |= _colors[msg.getPriority()];
- SetConsoleTextAttribute(_hConsole, attr);
- }
-
-#if defined(POCO_WIN32_UTF8)
- if (_isFile)
- {
- DWORD written;
- WriteFile(_hConsole, text.data(), static_cast<DWORD>(text.size()), &written, NULL);
- }
- else
- {
- std::wstring utext;
- UnicodeConverter::toUTF16(text, utext);
- DWORD written;
- WriteConsoleW(_hConsole, utext.data(), static_cast<DWORD>(utext.size()), &written, NULL);
- }
-#else
- DWORD written;
- WriteFile(_hConsole, text.data(), text.size(), &written, NULL);
-#endif
-
- if (_enableColors && !_isFile)
- {
- SetConsoleTextAttribute(_hConsole, _colors[0]);
- }
-}
-
-
-void WindowsColorConsoleChannel::setProperty(const std::string& name, const std::string& value)
-{
- if (name == "enableColors")
- {
- _enableColors = icompare(value, "true") == 0;
- }
- else if (name == "traceColor")
- {
- _colors[Message::PRIO_TRACE] = parseColor(value);
- }
- else if (name == "debugColor")
- {
- _colors[Message::PRIO_DEBUG] = parseColor(value);
- }
- else if (name == "informationColor")
- {
- _colors[Message::PRIO_INFORMATION] = parseColor(value);
- }
- else if (name == "noticeColor")
- {
- _colors[Message::PRIO_NOTICE] = parseColor(value);
- }
- else if (name == "warningColor")
- {
- _colors[Message::PRIO_WARNING] = parseColor(value);
- }
- else if (name == "errorColor")
- {
- _colors[Message::PRIO_ERROR] = parseColor(value);
- }
- else if (name == "criticalColor")
- {
- _colors[Message::PRIO_CRITICAL] = parseColor(value);
- }
- else if (name == "fatalColor")
- {
- _colors[Message::PRIO_FATAL] = parseColor(value);
- }
- else
- {
- Channel::setProperty(name, value);
- }
-}
-
-
-std::string WindowsColorConsoleChannel::getProperty(const std::string& name) const
-{
- if (name == "enableColors")
- {
- return _enableColors ? "true" : "false";
- }
- else if (name == "traceColor")
- {
- return formatColor(_colors[Message::PRIO_TRACE]);
- }
- else if (name == "debugColor")
- {
- return formatColor(_colors[Message::PRIO_DEBUG]);
- }
- else if (name == "informationColor")
- {
- return formatColor(_colors[Message::PRIO_INFORMATION]);
- }
- else if (name == "noticeColor")
- {
- return formatColor(_colors[Message::PRIO_NOTICE]);
- }
- else if (name == "warningColor")
- {
- return formatColor(_colors[Message::PRIO_WARNING]);
- }
- else if (name == "errorColor")
- {
- return formatColor(_colors[Message::PRIO_ERROR]);
- }
- else if (name == "criticalColor")
- {
- return formatColor(_colors[Message::PRIO_CRITICAL]);
- }
- else if (name == "fatalColor")
- {
- return formatColor(_colors[Message::PRIO_FATAL]);
- }
- else
- {
- return Channel::getProperty(name);
- }
-}
-
-
-WORD WindowsColorConsoleChannel::parseColor(const std::string& color) const
-{
- if (icompare(color, "default") == 0)
- return _colors[0];
- else if (icompare(color, "black") == 0)
- return CC_BLACK;
- else if (icompare(color, "red") == 0)
- return CC_RED;
- else if (icompare(color, "green") == 0)
- return CC_GREEN;
- else if (icompare(color, "brown") == 0)
- return CC_BROWN;
- else if (icompare(color, "blue") == 0)
- return CC_BLUE;
- else if (icompare(color, "magenta") == 0)
- return CC_MAGENTA;
- else if (icompare(color, "cyan") == 0)
- return CC_CYAN;
- else if (icompare(color, "gray") == 0)
- return CC_GRAY;
- else if (icompare(color, "darkGray") == 0)
- return CC_DARKGRAY;
- else if (icompare(color, "lightRed") == 0)
- return CC_LIGHTRED;
- else if (icompare(color, "lightGreen") == 0)
- return CC_LIGHTGREEN;
- else if (icompare(color, "yellow") == 0)
- return CC_YELLOW;
- else if (icompare(color, "lightBlue") == 0)
- return CC_LIGHTBLUE;
- else if (icompare(color, "lightMagenta") == 0)
- return CC_LIGHTMAGENTA;
- else if (icompare(color, "lightCyan") == 0)
- return CC_LIGHTCYAN;
- else if (icompare(color, "white") == 0)
- return CC_WHITE;
- else throw InvalidArgumentException("Invalid color value", color);
-}
-
-
-std::string WindowsColorConsoleChannel::formatColor(WORD color) const
-{
- switch (color)
- {
- case CC_BLACK: return "black";
- case CC_RED: return "red";
- case CC_GREEN: return "green";
- case CC_BROWN: return "brown";
- case CC_BLUE: return "blue";
- case CC_MAGENTA: return "magenta";
- case CC_CYAN: return "cyan";
- case CC_GRAY: return "gray";
- case CC_DARKGRAY: return "darkGray";
- case CC_LIGHTRED: return "lightRed";
- case CC_LIGHTGREEN: return "lightGreen";
- case CC_YELLOW: return "yellow";
- case CC_LIGHTBLUE: return "lightBlue";
- case CC_LIGHTMAGENTA: return "lightMagenta";
- case CC_LIGHTCYAN: return "lightCyan";
- case CC_WHITE: return "white";
- default: return "invalid";
- }
-}
-
-
-void WindowsColorConsoleChannel::initColors()
-{
- if (!_isFile)
- {
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- GetConsoleScreenBufferInfo(_hConsole, &csbi);
- _colors[0] = csbi.wAttributes;
- }
- else
- {
- _colors[0] = CC_WHITE;
- }
- _colors[Message::PRIO_FATAL] = CC_LIGHTRED;
- _colors[Message::PRIO_CRITICAL] = CC_LIGHTRED;
- _colors[Message::PRIO_ERROR] = CC_LIGHTRED;
- _colors[Message::PRIO_WARNING] = CC_YELLOW;
- _colors[Message::PRIO_NOTICE] = _colors[0];
- _colors[Message::PRIO_INFORMATION] = _colors[0];
- _colors[Message::PRIO_DEBUG] = CC_GRAY;
- _colors[Message::PRIO_TRACE] = CC_GRAY;
-}
-
-
-} // namespace Poco
+//
+// WindowsConsoleChannel.cpp
+//
+// Library: Foundation
+// Package: Logging
+// Module: WindowsConsoleChannel
+//
+// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/WindowsConsoleChannel.h"
+#include "Poco/Message.h"
+#if defined(POCO_WIN32_UTF8)
+#include "Poco/UnicodeConverter.h"
+#endif
+#include "Poco/String.h"
+#include "Poco/Exception.h"
+
+
+namespace Poco {
+
+
+WindowsConsoleChannel::WindowsConsoleChannel():
+ _isFile(false),
+ _hConsole(INVALID_HANDLE_VALUE)
+{
+ _hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
+ // check whether the console has been redirected
+ DWORD mode;
+ _isFile = (GetConsoleMode(_hConsole, &mode) == 0);
+}
+
+
+WindowsConsoleChannel::~WindowsConsoleChannel()
+{
+}
+
+
+void WindowsConsoleChannel::log(const Message& msg)
+{
+ std::string text = msg.getText();
+ text += "\r\n";
+
+#if defined(POCO_WIN32_UTF8)
+ if (_isFile)
+ {
+ DWORD written;
+ WriteFile(_hConsole, text.data(), static_cast<DWORD>(text.size()), &written, NULL);
+ }
+ else
+ {
+ std::wstring utext;
+ UnicodeConverter::toUTF16(text, utext);
+ DWORD written;
+ WriteConsoleW(_hConsole, utext.data(), static_cast<DWORD>(utext.size()), &written, NULL);
+ }
+#else
+ DWORD written;
+ WriteFile(_hConsole, text.data(), text.size(), &written, NULL);
+#endif
+}
+
+
+WindowsColorConsoleChannel::WindowsColorConsoleChannel():
+ _enableColors(true),
+ _isFile(false),
+ _hConsole(INVALID_HANDLE_VALUE)
+{
+ _hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
+ // check whether the console has been redirected
+ DWORD mode;
+ _isFile = (GetConsoleMode(_hConsole, &mode) == 0);
+ initColors();
+}
+
+
+WindowsColorConsoleChannel::~WindowsColorConsoleChannel()
+{
+}
+
+
+void WindowsColorConsoleChannel::log(const Message& msg)
+{
+ std::string text = msg.getText();
+ text += "\r\n";
+
+ if (_enableColors && !_isFile)
+ {
+ WORD attr = _colors[0];
+ attr &= 0xFFF0;
+ attr |= _colors[msg.getPriority()];
+ SetConsoleTextAttribute(_hConsole, attr);
+ }
+
+#if defined(POCO_WIN32_UTF8)
+ if (_isFile)
+ {
+ DWORD written;
+ WriteFile(_hConsole, text.data(), static_cast<DWORD>(text.size()), &written, NULL);
+ }
+ else
+ {
+ std::wstring utext;
+ UnicodeConverter::toUTF16(text, utext);
+ DWORD written;
+ WriteConsoleW(_hConsole, utext.data(), static_cast<DWORD>(utext.size()), &written, NULL);
+ }
+#else
+ DWORD written;
+ WriteFile(_hConsole, text.data(), text.size(), &written, NULL);
+#endif
+
+ if (_enableColors && !_isFile)
+ {
+ SetConsoleTextAttribute(_hConsole, _colors[0]);
+ }
+}
+
+
+void WindowsColorConsoleChannel::setProperty(const std::string& name, const std::string& value)
+{
+ if (name == "enableColors")
+ {
+ _enableColors = icompare(value, "true") == 0;
+ }
+ else if (name == "traceColor")
+ {
+ _colors[Message::PRIO_TRACE] = parseColor(value);
+ }
+ else if (name == "debugColor")
+ {
+ _colors[Message::PRIO_DEBUG] = parseColor(value);
+ }
+ else if (name == "informationColor")
+ {
+ _colors[Message::PRIO_INFORMATION] = parseColor(value);
+ }
+ else if (name == "noticeColor")
+ {
+ _colors[Message::PRIO_NOTICE] = parseColor(value);
+ }
+ else if (name == "warningColor")
+ {
+ _colors[Message::PRIO_WARNING] = parseColor(value);
+ }
+ else if (name == "errorColor")
+ {
+ _colors[Message::PRIO_ERROR] = parseColor(value);
+ }
+ else if (name == "criticalColor")
+ {
+ _colors[Message::PRIO_CRITICAL] = parseColor(value);
+ }
+ else if (name == "fatalColor")
+ {
+ _colors[Message::PRIO_FATAL] = parseColor(value);
+ }
+ else
+ {
+ Channel::setProperty(name, value);
+ }
+}
+
+
+std::string WindowsColorConsoleChannel::getProperty(const std::string& name) const
+{
+ if (name == "enableColors")
+ {
+ return _enableColors ? "true" : "false";
+ }
+ else if (name == "traceColor")
+ {
+ return formatColor(_colors[Message::PRIO_TRACE]);
+ }
+ else if (name == "debugColor")
+ {
+ return formatColor(_colors[Message::PRIO_DEBUG]);
+ }
+ else if (name == "informationColor")
+ {
+ return formatColor(_colors[Message::PRIO_INFORMATION]);
+ }
+ else if (name == "noticeColor")
+ {
+ return formatColor(_colors[Message::PRIO_NOTICE]);
+ }
+ else if (name == "warningColor")
+ {
+ return formatColor(_colors[Message::PRIO_WARNING]);
+ }
+ else if (name == "errorColor")
+ {
+ return formatColor(_colors[Message::PRIO_ERROR]);
+ }
+ else if (name == "criticalColor")
+ {
+ return formatColor(_colors[Message::PRIO_CRITICAL]);
+ }
+ else if (name == "fatalColor")
+ {
+ return formatColor(_colors[Message::PRIO_FATAL]);
+ }
+ else
+ {
+ return Channel::getProperty(name);
+ }
+}
+
+
+WORD WindowsColorConsoleChannel::parseColor(const std::string& color) const
+{
+ if (icompare(color, "default") == 0)
+ return _colors[0];
+ else if (icompare(color, "black") == 0)
+ return CC_BLACK;
+ else if (icompare(color, "red") == 0)
+ return CC_RED;
+ else if (icompare(color, "green") == 0)
+ return CC_GREEN;
+ else if (icompare(color, "brown") == 0)
+ return CC_BROWN;
+ else if (icompare(color, "blue") == 0)
+ return CC_BLUE;
+ else if (icompare(color, "magenta") == 0)
+ return CC_MAGENTA;
+ else if (icompare(color, "cyan") == 0)
+ return CC_CYAN;
+ else if (icompare(color, "gray") == 0)
+ return CC_GRAY;
+ else if (icompare(color, "darkGray") == 0)
+ return CC_DARKGRAY;
+ else if (icompare(color, "lightRed") == 0)
+ return CC_LIGHTRED;
+ else if (icompare(color, "lightGreen") == 0)
+ return CC_LIGHTGREEN;
+ else if (icompare(color, "yellow") == 0)
+ return CC_YELLOW;
+ else if (icompare(color, "lightBlue") == 0)
+ return CC_LIGHTBLUE;
+ else if (icompare(color, "lightMagenta") == 0)
+ return CC_LIGHTMAGENTA;
+ else if (icompare(color, "lightCyan") == 0)
+ return CC_LIGHTCYAN;
+ else if (icompare(color, "white") == 0)
+ return CC_WHITE;
+ else throw InvalidArgumentException("Invalid color value", color);
+}
+
+
+std::string WindowsColorConsoleChannel::formatColor(WORD color) const
+{
+ switch (color)
+ {
+ case CC_BLACK: return "black";
+ case CC_RED: return "red";
+ case CC_GREEN: return "green";
+ case CC_BROWN: return "brown";
+ case CC_BLUE: return "blue";
+ case CC_MAGENTA: return "magenta";
+ case CC_CYAN: return "cyan";
+ case CC_GRAY: return "gray";
+ case CC_DARKGRAY: return "darkGray";
+ case CC_LIGHTRED: return "lightRed";
+ case CC_LIGHTGREEN: return "lightGreen";
+ case CC_YELLOW: return "yellow";
+ case CC_LIGHTBLUE: return "lightBlue";
+ case CC_LIGHTMAGENTA: return "lightMagenta";
+ case CC_LIGHTCYAN: return "lightCyan";
+ case CC_WHITE: return "white";
+ default: return "invalid";
+ }
+}
+
+
+void WindowsColorConsoleChannel::initColors()
+{
+ if (!_isFile)
+ {
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ GetConsoleScreenBufferInfo(_hConsole, &csbi);
+ _colors[0] = csbi.wAttributes;
+ }
+ else
+ {
+ _colors[0] = CC_WHITE;
+ }
+ _colors[Message::PRIO_FATAL] = CC_LIGHTRED;
+ _colors[Message::PRIO_CRITICAL] = CC_LIGHTRED;
+ _colors[Message::PRIO_ERROR] = CC_LIGHTRED;
+ _colors[Message::PRIO_WARNING] = CC_YELLOW;
+ _colors[Message::PRIO_NOTICE] = _colors[0];
+ _colors[Message::PRIO_INFORMATION] = _colors[0];
+ _colors[Message::PRIO_DEBUG] = CC_GRAY;
+ _colors[Message::PRIO_TRACE] = CC_GRAY;
+}
+
+
+} // namespace Poco
diff --git a/contrib/libs/poco/Foundation/src/pocomsg.h b/contrib/libs/poco/Foundation/src/pocomsg.h
index fe68ae436f..43d4b7f40b 100644
--- a/contrib/libs/poco/Foundation/src/pocomsg.h
+++ b/contrib/libs/poco/Foundation/src/pocomsg.h
@@ -1,158 +1,158 @@
-//
-// pocomsg.mc[.h]
-//
-// $Id: //poco/1.4/Foundation/src/pocomsg.mc#1 $
-//
-// The Poco message source/header file.
-//
-// NOTE: pocomsg.h is automatically generated from pocomsg.mc.
-// Never edit pocomsg.h directly!
-//
-// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// Permission is hereby granted, free of charge, to any person or organization
-// obtaining a copy of the software and accompanying documentation covered by
-// this license (the "Software") to use, reproduce, display, distribute,
-// execute, and transmit the Software, and to prepare derivative works of the
-// Software, and to permit third-parties to whom the Software is furnished to
-// do so, all subject to the following:
-//
-// The copyright notices in the Software and this entire statement, including
-// the above license grant, this restriction and the following disclaimer,
-// must be included in all copies of the Software, in whole or in part, and
-// all derivative works of the Software, unless such copies or derivative
-// works are solely in the form of machine-executable object code generated by
-// a source language processor.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-// DEALINGS IN THE SOFTWARE.
-//
-//
-// Categories
-//
-//
-// Values are 32 bit values laid out as follows:
-//
-// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
-// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-// +---+-+-+-----------------------+-------------------------------+
-// |Sev|C|R| Facility | Code |
-// +---+-+-+-----------------------+-------------------------------+
-//
-// where
-//
-// Sev - is the severity code
-//
-// 00 - Success
-// 01 - Informational
-// 10 - Warning
-// 11 - Error
-//
-// C - is the Customer code flag
-//
-// R - is a reserved bit
-//
-// Facility - is the facility code
-//
-// Code - is the facility's status code
-//
-//
-// Define the facility codes
-//
-
-
-//
-// Define the severity codes
-//
-
-
-//
-// MessageId: POCO_CTG_FATAL
-//
-// MessageText:
-//
-// Fatal
-//
-#define POCO_CTG_FATAL 0x00000001L
-
-//
-// MessageId: POCO_CTG_CRITICAL
-//
-// MessageText:
-//
-// Critical
-//
-#define POCO_CTG_CRITICAL 0x00000002L
-
-//
-// MessageId: POCO_CTG_ERROR
-//
-// MessageText:
-//
-// Error
-//
-#define POCO_CTG_ERROR 0x00000003L
-
-//
-// MessageId: POCO_CTG_WARNING
-//
-// MessageText:
-//
-// Warning
-//
-#define POCO_CTG_WARNING 0x00000004L
-
-//
-// MessageId: POCO_CTG_NOTICE
-//
-// MessageText:
-//
-// Notice
-//
-#define POCO_CTG_NOTICE 0x00000005L
-
-//
-// MessageId: POCO_CTG_INFORMATION
-//
-// MessageText:
-//
-// Information
-//
-#define POCO_CTG_INFORMATION 0x00000006L
-
-//
-// MessageId: POCO_CTG_DEBUG
-//
-// MessageText:
-//
-// Debug
-//
-#define POCO_CTG_DEBUG 0x00000007L
-
-//
-// MessageId: POCO_CTG_TRACE
-//
-// MessageText:
-//
-// Trace
-//
-#define POCO_CTG_TRACE 0x00000008L
-
-//
-// Event Identifiers
-//
-//
-// MessageId: POCO_MSG_LOG
-//
-// MessageText:
-//
-// %1
-//
-#define POCO_MSG_LOG 0x00001000L
-
+//
+// pocomsg.mc[.h]
+//
+// $Id: //poco/1.4/Foundation/src/pocomsg.mc#1 $
+//
+// The Poco message source/header file.
+//
+// NOTE: pocomsg.h is automatically generated from pocomsg.mc.
+// Never edit pocomsg.h directly!
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// Permission is hereby granted, free of charge, to any person or organization
+// obtaining a copy of the software and accompanying documentation covered by
+// this license (the "Software") to use, reproduce, display, distribute,
+// execute, and transmit the Software, and to prepare derivative works of the
+// Software, and to permit third-parties to whom the Software is furnished to
+// do so, all subject to the following:
+//
+// The copyright notices in the Software and this entire statement, including
+// the above license grant, this restriction and the following disclaimer,
+// must be included in all copies of the Software, in whole or in part, and
+// all derivative works of the Software, unless such copies or derivative
+// works are solely in the form of machine-executable object code generated by
+// a source language processor.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+//
+//
+// Categories
+//
+//
+// Values are 32 bit values laid out as follows:
+//
+// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+// +---+-+-+-----------------------+-------------------------------+
+// |Sev|C|R| Facility | Code |
+// +---+-+-+-----------------------+-------------------------------+
+//
+// where
+//
+// Sev - is the severity code
+//
+// 00 - Success
+// 01 - Informational
+// 10 - Warning
+// 11 - Error
+//
+// C - is the Customer code flag
+//
+// R - is a reserved bit
+//
+// Facility - is the facility code
+//
+// Code - is the facility's status code
+//
+//
+// Define the facility codes
+//
+
+
+//
+// Define the severity codes
+//
+
+
+//
+// MessageId: POCO_CTG_FATAL
+//
+// MessageText:
+//
+// Fatal
+//
+#define POCO_CTG_FATAL 0x00000001L
+
+//
+// MessageId: POCO_CTG_CRITICAL
+//
+// MessageText:
+//
+// Critical
+//
+#define POCO_CTG_CRITICAL 0x00000002L
+
+//
+// MessageId: POCO_CTG_ERROR
+//
+// MessageText:
+//
+// Error
+//
+#define POCO_CTG_ERROR 0x00000003L
+
+//
+// MessageId: POCO_CTG_WARNING
+//
+// MessageText:
+//
+// Warning
+//
+#define POCO_CTG_WARNING 0x00000004L
+
+//
+// MessageId: POCO_CTG_NOTICE
+//
+// MessageText:
+//
+// Notice
+//
+#define POCO_CTG_NOTICE 0x00000005L
+
+//
+// MessageId: POCO_CTG_INFORMATION
+//
+// MessageText:
+//
+// Information
+//
+#define POCO_CTG_INFORMATION 0x00000006L
+
+//
+// MessageId: POCO_CTG_DEBUG
+//
+// MessageText:
+//
+// Debug
+//
+#define POCO_CTG_DEBUG 0x00000007L
+
+//
+// MessageId: POCO_CTG_TRACE
+//
+// MessageText:
+//
+// Trace
+//
+#define POCO_CTG_TRACE 0x00000008L
+
+//
+// Event Identifiers
+//
+//
+// MessageId: POCO_MSG_LOG
+//
+// MessageText:
+//
+// %1
+//
+#define POCO_MSG_LOG 0x00001000L
+