mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-20 07:51:33 +02:00
commit
cc55658b44
5
.gitattributes
vendored
5
.gitattributes
vendored
@ -31,3 +31,8 @@
|
|||||||
*.png binary
|
*.png binary
|
||||||
*.jpg binary
|
*.jpg binary
|
||||||
*.gif binary
|
*.gif binary
|
||||||
|
|
||||||
|
# Linguist overrides
|
||||||
|
.cpp linguist-language=C++
|
||||||
|
.h linguist-language=C++
|
||||||
|
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
# Contributing
|
# Contributing
|
||||||
|
|
||||||
---
|
---
|
||||||
## Bug Reports and Feature requests
|
## Bug Reports and Feature Requests
|
||||||
---
|
---
|
||||||
If you think you've found a bug or would like to see a feature in one of the [upcoming releases](https://github.com/pocoproject/poco/milestones), file an [issue](https://github.com/pocoproject/poco/issues). Please make sure that your explanations are clear and coherent; do the homework of understanding the problem and searching for existing solutions before posting.
|
If you think you've found a bug or would like to see a feature in one of the [upcoming releases](https://github.com/pocoproject/poco/milestones), file an [issue](https://github.com/pocoproject/poco/issues). Please make sure that your explanations are clear and coherent; do the homework of understanding the problem and searching for existing solutions before posting.
|
||||||
|
|
||||||
|
Possible security issues or vulnerabilities can also be reported via email directly to the core team security AT pocoproject.org. The core team will respond to security issues within 24 hours.
|
||||||
|
|
||||||
If you're in a hurry, the fastest way to have bugs fixed or features added are code contributions. Good code contributions, to be precise; if you want to contribute, read on ...
|
If you're in a hurry, the fastest way to have bugs fixed or features added are code contributions. Good code contributions, to be precise; if you want to contribute, read on ...
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -150,8 +150,17 @@ void SessionHandle::close()
|
|||||||
|
|
||||||
void SessionHandle::startTransaction()
|
void SessionHandle::startTransaction()
|
||||||
{
|
{
|
||||||
if (mysql_autocommit(_pHandle, false) != 0)
|
int rc = mysql_autocommit(_pHandle, false);
|
||||||
throw TransactionException("Start transaction failed.", _pHandle);
|
if (rc != 0)
|
||||||
|
{
|
||||||
|
// retry if connection lost
|
||||||
|
int err = mysql_errno(_pHandle);
|
||||||
|
if (err == 2006 /* CR_SERVER_GONE_ERROR */ || err == 2013 /* CR_SERVER_LOST */)
|
||||||
|
{
|
||||||
|
rc = mysql_autocommit(_pHandle, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rc != 0) throw TransactionException("Start transaction failed.", _pHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,9 @@ namespace SQLite {
|
|||||||
|
|
||||||
|
|
||||||
Notifier::Notifier(const Session& session, EnabledEventType enabled):
|
Notifier::Notifier(const Session& session, EnabledEventType enabled):
|
||||||
_session(session)
|
_session(session),
|
||||||
|
_row(),
|
||||||
|
_enabledEvents()
|
||||||
{
|
{
|
||||||
if (enabled & SQLITE_NOTIFY_UPDATE) enableUpdate();
|
if (enabled & SQLITE_NOTIFY_UPDATE) enableUpdate();
|
||||||
if (enabled & SQLITE_NOTIFY_COMMIT) enableCommit();
|
if (enabled & SQLITE_NOTIFY_COMMIT) enableCommit();
|
||||||
@ -35,7 +37,9 @@ Notifier::Notifier(const Session& session, EnabledEventType enabled):
|
|||||||
|
|
||||||
Notifier::Notifier(const Session& session, const Any& value, EnabledEventType enabled):
|
Notifier::Notifier(const Session& session, const Any& value, EnabledEventType enabled):
|
||||||
_session(session),
|
_session(session),
|
||||||
_value(value)
|
_value(value),
|
||||||
|
_row(),
|
||||||
|
_enabledEvents()
|
||||||
{
|
{
|
||||||
if (enabled & SQLITE_NOTIFY_UPDATE) enableUpdate();
|
if (enabled & SQLITE_NOTIFY_UPDATE) enableUpdate();
|
||||||
if (enabled & SQLITE_NOTIFY_COMMIT) enableCommit();
|
if (enabled & SQLITE_NOTIFY_COMMIT) enableCommit();
|
||||||
|
@ -90,7 +90,8 @@ public:
|
|||||||
AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()),
|
AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()),
|
||||||
_rResult(rResult),
|
_rResult(rResult),
|
||||||
_default(),
|
_default(),
|
||||||
_extracted(false)
|
_extracted(false),
|
||||||
|
_null(false)
|
||||||
/// Creates an Extraction object at specified position.
|
/// Creates an Extraction object at specified position.
|
||||||
/// Uses an empty object T as default value.
|
/// Uses an empty object T as default value.
|
||||||
{
|
{
|
||||||
@ -100,7 +101,8 @@ public:
|
|||||||
AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()),
|
AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()),
|
||||||
_rResult(rResult),
|
_rResult(rResult),
|
||||||
_default(def),
|
_default(def),
|
||||||
_extracted(false)
|
_extracted(false),
|
||||||
|
_null(false)
|
||||||
/// Creates an Extraction object at specified position.
|
/// Creates an Extraction object at specified position.
|
||||||
/// Uses the provided def object as default value.
|
/// Uses the provided def object as default value.
|
||||||
{
|
{
|
||||||
@ -180,7 +182,6 @@ public:
|
|||||||
AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()),
|
AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()),
|
||||||
_rResult(rResult),
|
_rResult(rResult),
|
||||||
_default()
|
_default()
|
||||||
|
|
||||||
{
|
{
|
||||||
_rResult.clear();
|
_rResult.clear();
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,12 @@ namespace Poco {
|
|||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
|
|
||||||
MetaColumn::MetaColumn()
|
MetaColumn::MetaColumn():
|
||||||
|
_length(),
|
||||||
|
_precision(),
|
||||||
|
_position(),
|
||||||
|
_type(),
|
||||||
|
_nullable()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,8 +256,7 @@ bool RecordSet::moveFirst()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t currentRow = _currentRow;
|
std::size_t currentRow = 0;
|
||||||
currentRow = 0;
|
|
||||||
while (!isAllowed(currentRow))
|
while (!isAllowed(currentRow))
|
||||||
{
|
{
|
||||||
if (currentRow >= rc - 1) return false;
|
if (currentRow >= rc - 1) return false;
|
||||||
@ -303,8 +302,7 @@ bool RecordSet::moveLast()
|
|||||||
{
|
{
|
||||||
if (storageRowCount() > 0)
|
if (storageRowCount() > 0)
|
||||||
{
|
{
|
||||||
std::size_t currentRow = _currentRow;
|
std::size_t currentRow = subTotalRowCount() - 1;
|
||||||
currentRow = storageRowCount() - 1;
|
|
||||||
if (!isFiltered())
|
if (!isFiltered())
|
||||||
{
|
{
|
||||||
_currentRow = currentRow;
|
_currentRow = currentRow;
|
||||||
|
@ -47,7 +47,10 @@ SQLChannel::SQLChannel():
|
|||||||
_table("T_POCO_LOG"),
|
_table("T_POCO_LOG"),
|
||||||
_timeout(1000),
|
_timeout(1000),
|
||||||
_throw(true),
|
_throw(true),
|
||||||
_async(true)
|
_async(true),
|
||||||
|
_pid(),
|
||||||
|
_tid(),
|
||||||
|
_priority()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +64,10 @@ SQLChannel::SQLChannel(const std::string& connector,
|
|||||||
_table("T_POCO_LOG"),
|
_table("T_POCO_LOG"),
|
||||||
_timeout(1000),
|
_timeout(1000),
|
||||||
_throw(true),
|
_throw(true),
|
||||||
_async(true)
|
_async(true),
|
||||||
|
_pid(),
|
||||||
|
_tid(),
|
||||||
|
_priority()
|
||||||
{
|
{
|
||||||
open();
|
open();
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ Session SessionPool::get()
|
|||||||
_idleSessions.push_front(pHolder);
|
_idleSessions.push_front(pHolder);
|
||||||
++_nSessions;
|
++_nSessions;
|
||||||
}
|
}
|
||||||
else throw SessionPoolExhaustedException(_connector, _connectionString);
|
else throw SessionPoolExhaustedException(_connector);
|
||||||
}
|
}
|
||||||
|
|
||||||
PooledSessionHolderPtr pHolder(_idleSessions.front());
|
PooledSessionHolderPtr pHolder(_idleSessions.front());
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <cstdlib>
|
||||||
#if defined(_DEBUG)
|
#if defined(_DEBUG)
|
||||||
# include <iostream>
|
# include <iostream>
|
||||||
#endif
|
#endif
|
||||||
@ -81,6 +82,28 @@ protected:
|
|||||||
//
|
//
|
||||||
// useful macros (these automatically supply line number and file name)
|
// useful macros (these automatically supply line number and file name)
|
||||||
//
|
//
|
||||||
|
#if defined(__KLOCWORK__) || defined(__clang_analyzer__)
|
||||||
|
|
||||||
|
|
||||||
|
// Short-circuit these macros when under static analysis.
|
||||||
|
// Ideally, static analysis tools should understand and reason correctly about
|
||||||
|
// noreturn methods such as Bugcheck::bugcheck(). In practice, they don't.
|
||||||
|
// Help them by turning these macros into std::abort() as described here:
|
||||||
|
// https://developer.klocwork.com/documentation/en/insight/10-1/tuning-cc-analysis#Usingthe__KLOCWORK__macro
|
||||||
|
|
||||||
|
#include <cstdlib> // for abort
|
||||||
|
#define poco_assert_dbg(cond) do { if (!(cond)) std::abort(); } while (0)
|
||||||
|
#define poco_assert_msg_dbg(cond, text) do { if (!(cond)) std::abort(); } while (0)
|
||||||
|
#define poco_assert(cond) do { if (!(cond)) std::abort(); } while (0)
|
||||||
|
#define poco_assert_msg(cond, text) do { if (!(cond)) std::abort(); } while (0)
|
||||||
|
#define poco_check_ptr(ptr) do { if (!(ptr)) std::abort(); } while (0)
|
||||||
|
#define poco_bugcheck() do { std::abort(); } while (0)
|
||||||
|
#define poco_bugcheck_msg(msg) do { std::abort(); } while (0)
|
||||||
|
|
||||||
|
|
||||||
|
#else // defined(__KLOCWORK__) || defined(__clang_analyzer__)
|
||||||
|
|
||||||
|
|
||||||
#if defined(_DEBUG)
|
#if defined(_DEBUG)
|
||||||
#define poco_assert_dbg(cond) \
|
#define poco_assert_dbg(cond) \
|
||||||
if (!(cond)) Poco::Bugcheck::assertion(#cond, __FILE__, __LINE__); else (void) 0
|
if (!(cond)) Poco::Bugcheck::assertion(#cond, __FILE__, __LINE__); else (void) 0
|
||||||
@ -113,6 +136,9 @@ protected:
|
|||||||
Poco::Bugcheck::bugcheck(msg, __FILE__, __LINE__)
|
Poco::Bugcheck::bugcheck(msg, __FILE__, __LINE__)
|
||||||
|
|
||||||
|
|
||||||
|
#endif // defined(__KLOCWORK__) || defined(__clang_analyzer__)
|
||||||
|
|
||||||
|
|
||||||
#define poco_unexpected() \
|
#define poco_unexpected() \
|
||||||
Poco::Bugcheck::unexpected(__FILE__, __LINE__);
|
Poco::Bugcheck::unexpected(__FILE__, __LINE__);
|
||||||
|
|
||||||
|
@ -158,11 +158,13 @@ public:
|
|||||||
if (it == _map.end())
|
if (it == _map.end())
|
||||||
{
|
{
|
||||||
LibraryInfo li;
|
LibraryInfo li;
|
||||||
li.pLibrary = new SharedLibrary(path);
|
li.pLibrary = 0;
|
||||||
li.pManifest = new Manif();
|
li.pManifest = 0;
|
||||||
li.refCount = 1;
|
li.refCount = 1;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
li.pLibrary = new SharedLibrary(path);
|
||||||
|
li.pManifest = new Manif();
|
||||||
std::string pocoBuildManifestSymbol("pocoBuildManifest");
|
std::string pocoBuildManifestSymbol("pocoBuildManifest");
|
||||||
pocoBuildManifestSymbol.append(manifest);
|
pocoBuildManifestSymbol.append(manifest);
|
||||||
if (li.pLibrary->hasSymbol("pocoInitializeLibrary"))
|
if (li.pLibrary->hasSymbol("pocoInitializeLibrary"))
|
||||||
|
@ -128,7 +128,6 @@ public:
|
|||||||
{
|
{
|
||||||
if (&delegate != this)
|
if (&delegate != this)
|
||||||
{
|
{
|
||||||
this->_pTarget = delegate._pTarget;
|
|
||||||
this->_receiverObject = delegate._receiverObject;
|
this->_receiverObject = delegate._receiverObject;
|
||||||
this->_receiverMethod = delegate._receiverMethod;
|
this->_receiverMethod = delegate._receiverMethod;
|
||||||
}
|
}
|
||||||
@ -341,7 +340,6 @@ public:
|
|||||||
{
|
{
|
||||||
if (&delegate != this)
|
if (&delegate != this)
|
||||||
{
|
{
|
||||||
this->_pTarget = delegate._pTarget;
|
|
||||||
this->_receiverObject = delegate._receiverObject;
|
this->_receiverObject = delegate._receiverObject;
|
||||||
this->_receiverMethod = delegate._receiverMethod;
|
this->_receiverMethod = delegate._receiverMethod;
|
||||||
}
|
}
|
||||||
|
@ -255,6 +255,8 @@ POCO_DECLARE_EXCEPTION(Foundation_API, OpenFileException, FileException)
|
|||||||
POCO_DECLARE_EXCEPTION(Foundation_API, WriteFileException, FileException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, WriteFileException, FileException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, ReadFileException, FileException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, ReadFileException, FileException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, UnknownURISchemeException, RuntimeException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, UnknownURISchemeException, RuntimeException)
|
||||||
|
POCO_DECLARE_EXCEPTION(Foundation_API, TooManyURIRedirectsException, RuntimeException)
|
||||||
|
POCO_DECLARE_EXCEPTION(Foundation_API, URISyntaxException, SyntaxException)
|
||||||
|
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, ApplicationException, Exception)
|
POCO_DECLARE_EXCEPTION(Foundation_API, ApplicationException, Exception)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, BadCastException, RuntimeException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, BadCastException, RuntimeException)
|
||||||
|
@ -73,6 +73,8 @@ private:
|
|||||||
MemoryPool(const MemoryPool&);
|
MemoryPool(const MemoryPool&);
|
||||||
MemoryPool& operator = (const MemoryPool&);
|
MemoryPool& operator = (const MemoryPool&);
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
BLOCK_RESERVE = 128
|
BLOCK_RESERVE = 128
|
||||||
|
@ -63,28 +63,32 @@ public:
|
|||||||
Nullable():
|
Nullable():
|
||||||
/// Creates an empty Nullable.
|
/// Creates an empty Nullable.
|
||||||
_value(),
|
_value(),
|
||||||
_isNull(true)
|
_isNull(true),
|
||||||
|
_null()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Nullable(const NullType&):
|
Nullable(const NullType&):
|
||||||
/// Creates an empty Nullable.
|
/// Creates an empty Nullable.
|
||||||
_value(),
|
_value(),
|
||||||
_isNull(true)
|
_isNull(true),
|
||||||
|
_null()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Nullable(const C& value):
|
Nullable(const C& value):
|
||||||
/// Creates a Nullable with the given value.
|
/// Creates a Nullable with the given value.
|
||||||
_value(value),
|
_value(value),
|
||||||
_isNull(false)
|
_isNull(false),
|
||||||
|
_null()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Nullable(const Nullable& other):
|
Nullable(const Nullable& other):
|
||||||
/// Creates a Nullable by copying another one.
|
/// Creates a Nullable by copying another one.
|
||||||
_value(other._value),
|
_value(other._value),
|
||||||
_isNull(other._isNull)
|
_isNull(other._isNull),
|
||||||
|
_null()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,6 +132,7 @@ private:
|
|||||||
ThreadData():
|
ThreadData():
|
||||||
thread(0),
|
thread(0),
|
||||||
prio(PRIO_NORMAL_IMPL),
|
prio(PRIO_NORMAL_IMPL),
|
||||||
|
osPrio(),
|
||||||
policy(SCHED_OTHER),
|
policy(SCHED_OTHER),
|
||||||
done(Event::EVENT_MANUALRESET),
|
done(Event::EVENT_MANUALRESET),
|
||||||
stackSize(POCO_THREAD_STACK_SIZE),
|
stackSize(POCO_THREAD_STACK_SIZE),
|
||||||
|
@ -27,13 +27,20 @@ DeflatingStreamBuf::DeflatingStreamBuf(std::istream& istr, StreamType type, int
|
|||||||
_pOstr(0),
|
_pOstr(0),
|
||||||
_eof(false)
|
_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.zalloc = Z_NULL;
|
||||||
_zstr.zfree = Z_NULL;
|
_zstr.zfree = Z_NULL;
|
||||||
_zstr.opaque = Z_NULL;
|
_zstr.opaque = Z_NULL;
|
||||||
_zstr.next_in = 0;
|
_zstr.data_type = 0;
|
||||||
_zstr.avail_in = 0;
|
_zstr.adler = 0;
|
||||||
_zstr.next_out = 0;
|
_zstr.reserved = 0;
|
||||||
_zstr.avail_out = 0;
|
|
||||||
|
|
||||||
_buffer = new char[DEFLATE_BUFFER_SIZE];
|
_buffer = new char[DEFLATE_BUFFER_SIZE];
|
||||||
|
|
||||||
|
@ -179,9 +179,11 @@ POCO_IMPLEMENT_EXCEPTION(OpenFileException, FileException, "Cannot open file")
|
|||||||
POCO_IMPLEMENT_EXCEPTION(WriteFileException, FileException, "Cannot write file")
|
POCO_IMPLEMENT_EXCEPTION(WriteFileException, FileException, "Cannot write file")
|
||||||
POCO_IMPLEMENT_EXCEPTION(ReadFileException, FileException, "Cannot read file")
|
POCO_IMPLEMENT_EXCEPTION(ReadFileException, FileException, "Cannot read file")
|
||||||
POCO_IMPLEMENT_EXCEPTION(UnknownURISchemeException, RuntimeException, "Unknown URI scheme")
|
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(ApplicationException, Exception, "Application exception")
|
||||||
POCO_IMPLEMENT_EXCEPTION(BadCastException, RuntimeException, "Bad cast exception")
|
POCO_IMPLEMENT_EXCEPTION(BadCastException, RuntimeException, "Bad cast exception")
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "Poco/InflatingStream.h"
|
#include "Poco/InflatingStream.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
@ -28,13 +29,20 @@ InflatingStreamBuf::InflatingStreamBuf(std::istream& istr, StreamType type):
|
|||||||
_eof(false),
|
_eof(false),
|
||||||
_check(type != STREAM_ZIP)
|
_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.zalloc = Z_NULL;
|
||||||
_zstr.zfree = Z_NULL;
|
_zstr.zfree = Z_NULL;
|
||||||
_zstr.opaque = Z_NULL;
|
_zstr.opaque = Z_NULL;
|
||||||
_zstr.next_in = 0;
|
_zstr.data_type = 0;
|
||||||
_zstr.avail_in = 0;
|
_zstr.adler = 0;
|
||||||
_zstr.next_out = 0;
|
_zstr.reserved = 0;
|
||||||
_zstr.avail_out = 0;
|
|
||||||
|
|
||||||
_buffer = new char[INFLATE_BUFFER_SIZE];
|
_buffer = new char[INFLATE_BUFFER_SIZE];
|
||||||
|
|
||||||
|
@ -35,19 +35,35 @@ MemoryPool::MemoryPool(std::size_t blockLength, int preAlloc, int maxAlloc):
|
|||||||
if (maxAlloc > 0 && maxAlloc < r)
|
if (maxAlloc > 0 && maxAlloc < r)
|
||||||
r = maxAlloc;
|
r = maxAlloc;
|
||||||
_blocks.reserve(r);
|
_blocks.reserve(r);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
for (int i = 0; i < preAlloc; ++i)
|
for (int i = 0; i < preAlloc; ++i)
|
||||||
{
|
{
|
||||||
_blocks.push_back(new char[_blockSize]);
|
_blocks.push_back(new char[_blockSize]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MemoryPool::~MemoryPool()
|
MemoryPool::~MemoryPool()
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MemoryPool::clear()
|
||||||
{
|
{
|
||||||
for (BlockVec::iterator it = _blocks.begin(); it != _blocks.end(); ++it)
|
for (BlockVec::iterator it = _blocks.begin(); it != _blocks.end(); ++it)
|
||||||
{
|
{
|
||||||
delete [] *it;
|
delete [] *it;
|
||||||
}
|
}
|
||||||
|
_blocks.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -77,8 +93,15 @@ void MemoryPool::release(void* ptr)
|
|||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
_blocks.push_back(reinterpret_cast<char*>(ptr));
|
_blocks.push_back(reinterpret_cast<char*>(ptr));
|
||||||
}
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
delete [] reinterpret_cast<char*>(ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
@ -119,7 +119,7 @@ Poco::UInt64 StreamCopier::copyToString64(std::istream& istr, std::string& str,
|
|||||||
|
|
||||||
std::streamsize StreamCopier::copyStreamUnbuffered(std::istream& istr, std::ostream& ostr)
|
std::streamsize StreamCopier::copyStreamUnbuffered(std::istream& istr, std::ostream& ostr)
|
||||||
{
|
{
|
||||||
char c;
|
char c = 0;
|
||||||
std::streamsize len = 0;
|
std::streamsize len = 0;
|
||||||
istr.get(c);
|
istr.get(c);
|
||||||
while (istr && ostr)
|
while (istr && ostr)
|
||||||
@ -135,7 +135,7 @@ std::streamsize StreamCopier::copyStreamUnbuffered(std::istream& istr, std::ostr
|
|||||||
#if defined(POCO_HAVE_INT64)
|
#if defined(POCO_HAVE_INT64)
|
||||||
Poco::UInt64 StreamCopier::copyStreamUnbuffered64(std::istream& istr, std::ostream& ostr)
|
Poco::UInt64 StreamCopier::copyStreamUnbuffered64(std::istream& istr, std::ostream& ostr)
|
||||||
{
|
{
|
||||||
char c;
|
char c = 0;
|
||||||
Poco::UInt64 len = 0;
|
Poco::UInt64 len = 0;
|
||||||
istr.get(c);
|
istr.get(c);
|
||||||
while (istr && ostr)
|
while (istr && ostr)
|
||||||
|
@ -660,9 +660,9 @@ void URI::decode(const std::string& str, std::string& decodedStr, bool plusAsSpa
|
|||||||
if (inQuery && plusAsSpace && c == '+') c = ' ';
|
if (inQuery && plusAsSpace && c == '+') c = ' ';
|
||||||
else if (c == '%')
|
else if (c == '%')
|
||||||
{
|
{
|
||||||
if (it == end) throw SyntaxException("URI encoding: no hex digit following percent sign", str);
|
if (it == end) throw URISyntaxException("URI encoding: no hex digit following percent sign", str);
|
||||||
char hi = *it++;
|
char hi = *it++;
|
||||||
if (it == end) throw SyntaxException("URI encoding: two hex digits must follow percent sign", str);
|
if (it == end) throw URISyntaxException("URI encoding: two hex digits must follow percent sign", str);
|
||||||
char lo = *it++;
|
char lo = *it++;
|
||||||
if (hi >= '0' && hi <= '9')
|
if (hi >= '0' && hi <= '9')
|
||||||
c = hi - '0';
|
c = hi - '0';
|
||||||
@ -670,7 +670,7 @@ void URI::decode(const std::string& str, std::string& decodedStr, bool plusAsSpa
|
|||||||
c = hi - 'A' + 10;
|
c = hi - 'A' + 10;
|
||||||
else if (hi >= 'a' && hi <= 'f')
|
else if (hi >= 'a' && hi <= 'f')
|
||||||
c = hi - 'a' + 10;
|
c = hi - 'a' + 10;
|
||||||
else throw SyntaxException("URI encoding: not a hex digit");
|
else throw URISyntaxException("URI encoding: not a hex digit");
|
||||||
c *= 16;
|
c *= 16;
|
||||||
if (lo >= '0' && lo <= '9')
|
if (lo >= '0' && lo <= '9')
|
||||||
c += lo - '0';
|
c += lo - '0';
|
||||||
@ -678,7 +678,7 @@ void URI::decode(const std::string& str, std::string& decodedStr, bool plusAsSpa
|
|||||||
c += lo - 'A' + 10;
|
c += lo - 'A' + 10;
|
||||||
else if (lo >= 'a' && lo <= 'f')
|
else if (lo >= 'a' && lo <= 'f')
|
||||||
c += lo - 'a' + 10;
|
c += lo - 'a' + 10;
|
||||||
else throw SyntaxException("URI encoding: not a hex digit");
|
else throw URISyntaxException("URI encoding: not a hex digit");
|
||||||
}
|
}
|
||||||
decodedStr += c;
|
decodedStr += c;
|
||||||
}
|
}
|
||||||
@ -732,7 +732,7 @@ void URI::parse(const std::string& uri)
|
|||||||
if (it != end && *it == ':')
|
if (it != end && *it == ':')
|
||||||
{
|
{
|
||||||
++it;
|
++it;
|
||||||
if (it == end) throw SyntaxException("URI scheme must be followed by authority or path", uri);
|
if (it == end) throw URISyntaxException("URI scheme must be followed by authority or path", uri);
|
||||||
setScheme(scheme);
|
setScheme(scheme);
|
||||||
if (*it == '/')
|
if (*it == '/')
|
||||||
{
|
{
|
||||||
@ -786,7 +786,7 @@ void URI::parseHostAndPort(std::string::const_iterator& it, const std::string::c
|
|||||||
// IPv6 address
|
// IPv6 address
|
||||||
++it;
|
++it;
|
||||||
while (it != end && *it != ']') host += *it++;
|
while (it != end && *it != ']') host += *it++;
|
||||||
if (it == end) throw SyntaxException("unterminated IPv6 address");
|
if (it == end) throw URISyntaxException("unterminated IPv6 address");
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -804,7 +804,7 @@ void URI::parseHostAndPort(std::string::const_iterator& it, const std::string::c
|
|||||||
if (NumberParser::tryParse(port, nport) && nport > 0 && nport < 65536)
|
if (NumberParser::tryParse(port, nport) && nport > 0 && nport < 65536)
|
||||||
_port = (unsigned short) nport;
|
_port = (unsigned short) nport;
|
||||||
else
|
else
|
||||||
throw SyntaxException("bad or invalid port number", port);
|
throw URISyntaxException("bad or invalid port number", port);
|
||||||
}
|
}
|
||||||
else _port = getWellKnownPort();
|
else _port = getWellKnownPort();
|
||||||
}
|
}
|
||||||
|
@ -62,14 +62,28 @@ std::istream* URIStreamOpener::open(const std::string& pathOrURI) const
|
|||||||
std::string scheme(uri.getScheme());
|
std::string scheme(uri.getScheme());
|
||||||
FactoryMap::const_iterator it = _map.find(scheme);
|
FactoryMap::const_iterator it = _map.find(scheme);
|
||||||
if (it != _map.end())
|
if (it != _map.end())
|
||||||
|
{
|
||||||
return openURI(scheme, uri);
|
return openURI(scheme, uri);
|
||||||
}
|
}
|
||||||
catch (Exception&)
|
else if (scheme.length() <= 1) // could be Windows path
|
||||||
|
{
|
||||||
|
Path path;
|
||||||
|
if (path.tryParse(pathOrURI, Path::PATH_GUESS))
|
||||||
{
|
{
|
||||||
}
|
|
||||||
Path path(pathOrURI, Path::PATH_GUESS);
|
|
||||||
return openFile(path);
|
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
|
std::istream* URIStreamOpener::open(const std::string& basePathOrURI, const std::string& pathOrURI) const
|
||||||
@ -84,17 +98,33 @@ std::istream* URIStreamOpener::open(const std::string& basePathOrURI, const std:
|
|||||||
if (it != _map.end())
|
if (it != _map.end())
|
||||||
{
|
{
|
||||||
uri.resolve(pathOrURI);
|
uri.resolve(pathOrURI);
|
||||||
|
scheme = uri.getScheme();
|
||||||
return openURI(scheme, uri);
|
return openURI(scheme, uri);
|
||||||
}
|
}
|
||||||
}
|
else if (scheme.length() <= 1) // could be Windows path
|
||||||
catch (Exception&)
|
{
|
||||||
|
Path base;
|
||||||
|
Path path;
|
||||||
|
if (base.tryParse(basePathOrURI, Path::PATH_GUESS) && path.tryParse(pathOrURI, Path::PATH_GUESS))
|
||||||
{
|
{
|
||||||
}
|
|
||||||
Path base(basePathOrURI, Path::PATH_GUESS);
|
|
||||||
Path path(pathOrURI, Path::PATH_GUESS);
|
|
||||||
base.resolve(path);
|
base.resolve(path);
|
||||||
return openFile(base);
|
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)
|
void URIStreamOpener::registerStreamFactory(const std::string& scheme, URIStreamFactory* pFactory)
|
||||||
@ -176,7 +206,7 @@ std::istream* URIStreamOpener::openURI(const std::string& scheme, const URI& uri
|
|||||||
++redirects;
|
++redirects;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw IOException("Too many redirects while opening URI", uri.toString());
|
throw TooManyURIRedirectsException(uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -350,14 +350,16 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
Template::Template(const Path& templatePath)
|
Template::Template(const Path& templatePath)
|
||||||
: _parts(NULL)
|
: _parts(0)
|
||||||
|
, _currentPart(0)
|
||||||
, _templatePath(templatePath)
|
, _templatePath(templatePath)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Template::Template()
|
Template::Template()
|
||||||
: _parts(NULL)
|
: _parts(0)
|
||||||
|
, _currentPart(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,6 +247,54 @@ inline void BSONWriter::write<NullValue>(NullValue& from)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct BSONTimestamp
|
||||||
|
{
|
||||||
|
Poco::Timestamp ts;
|
||||||
|
Poco::Int32 inc;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// BSON Timestamp
|
||||||
|
// spec: int64
|
||||||
|
template<>
|
||||||
|
struct ElementTraits<BSONTimestamp>
|
||||||
|
{
|
||||||
|
enum { TypeId = 0x11 };
|
||||||
|
|
||||||
|
static std::string toString(const BSONTimestamp& value, int indent = 0)
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
result.append(1, '"');
|
||||||
|
result.append(DateTimeFormatter::format(value.ts, "%Y-%m-%dT%H:%M:%s%z"));
|
||||||
|
result.append(1, ' ');
|
||||||
|
result.append(NumberFormatter::format(value.inc));
|
||||||
|
result.append(1, '"');
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline void BSONReader::read<BSONTimestamp>(BSONTimestamp& to)
|
||||||
|
{
|
||||||
|
Poco::Int64 value;
|
||||||
|
_reader >> value;
|
||||||
|
to.inc = value & 0xffffffff;
|
||||||
|
value >>= 32;
|
||||||
|
to.ts = Timestamp::fromEpochTime(static_cast<std::time_t>(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline void BSONWriter::write<BSONTimestamp>(BSONTimestamp& from)
|
||||||
|
{
|
||||||
|
Poco::Int64 value = from.ts.epochMicroseconds() / 1000;
|
||||||
|
value <<= 32;
|
||||||
|
value += from.inc;
|
||||||
|
_writer << value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// BSON 64-bit integer
|
// BSON 64-bit integer
|
||||||
// spec: int64
|
// spec: int64
|
||||||
template<>
|
template<>
|
||||||
|
@ -118,6 +118,9 @@ void Document::read(BinaryReader& reader)
|
|||||||
case ElementTraits<Poco::Timestamp>::TypeId:
|
case ElementTraits<Poco::Timestamp>::TypeId:
|
||||||
element = new ConcreteElement<Poco::Timestamp>(name, Poco::Timestamp());
|
element = new ConcreteElement<Poco::Timestamp>(name, Poco::Timestamp());
|
||||||
break;
|
break;
|
||||||
|
case ElementTraits<BSONTimestamp>::TypeId:
|
||||||
|
element = new ConcreteElement<BSONTimestamp>(name, BSONTimestamp());
|
||||||
|
break;
|
||||||
case ElementTraits<NullValue>::TypeId:
|
case ElementTraits<NullValue>::TypeId:
|
||||||
element = new ConcreteElement<NullValue>(name, NullValue(0));
|
element = new ConcreteElement<NullValue>(name, NullValue(0));
|
||||||
break;
|
break;
|
||||||
@ -133,7 +136,7 @@ void Document::read(BinaryReader& reader)
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "Element " << name << " contains an unsupported type " << std::hex << (int) type;
|
ss << "Element " << name << " contains an unsupported type 0x" << std::hex << (int) type;
|
||||||
throw Poco::NotImplementedException(ss.str());
|
throw Poco::NotImplementedException(ss.str());
|
||||||
}
|
}
|
||||||
//TODO: x0F -> JavaScript code with scope
|
//TODO: x0F -> JavaScript code with scope
|
||||||
|
@ -42,7 +42,7 @@ public:
|
|||||||
ICMPSocket(const Socket& socket);
|
ICMPSocket(const Socket& socket);
|
||||||
/// Creates the ICMPSocket with the SocketImpl
|
/// Creates the ICMPSocket with the SocketImpl
|
||||||
/// from another socket. The SocketImpl must be
|
/// from another socket. The SocketImpl must be
|
||||||
/// a DatagramSocketImpl, otherwise an InvalidArgumentException
|
/// a ICMPSocketImpl, otherwise an InvalidArgumentException
|
||||||
/// will be thrown.
|
/// will be thrown.
|
||||||
|
|
||||||
~ICMPSocket();
|
~ICMPSocket();
|
||||||
@ -84,35 +84,9 @@ protected:
|
|||||||
///
|
///
|
||||||
/// The SocketImpl must be a ICMPSocketImpl, otherwise
|
/// The SocketImpl must be a ICMPSocketImpl, otherwise
|
||||||
/// an InvalidArgumentException will be thrown.
|
/// an InvalidArgumentException will be thrown.
|
||||||
|
|
||||||
private:
|
|
||||||
int _dataSize;
|
|
||||||
int _ttl;
|
|
||||||
int _timeout;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// inlines
|
|
||||||
//
|
|
||||||
inline int ICMPSocket::dataSize() const
|
|
||||||
{
|
|
||||||
return _dataSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline int ICMPSocket::ttl() const
|
|
||||||
{
|
|
||||||
return _ttl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline int ICMPSocket::timeout() const
|
|
||||||
{
|
|
||||||
return _timeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::Net
|
} } // namespace Poco::Net
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,15 +50,46 @@ public:
|
|||||||
///
|
///
|
||||||
/// Returns the time elapsed since the originating request was sent.
|
/// Returns the time elapsed since the originating request was sent.
|
||||||
|
|
||||||
|
int dataSize() const;
|
||||||
|
/// Returns the data size in bytes.
|
||||||
|
|
||||||
|
int ttl() const;
|
||||||
|
/// Returns the Time-To-Live value.
|
||||||
|
|
||||||
|
int timeout() const;
|
||||||
|
/// Returns the socket timeout value.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~ICMPSocketImpl();
|
~ICMPSocketImpl();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ICMPPacket _icmpPacket;
|
ICMPPacket _icmpPacket;
|
||||||
|
int _ttl;
|
||||||
int _timeout;
|
int _timeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// inlines
|
||||||
|
//
|
||||||
|
inline int ICMPSocketImpl::dataSize() const
|
||||||
|
{
|
||||||
|
return _icmpPacket.getDataSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline int ICMPSocketImpl::ttl() const
|
||||||
|
{
|
||||||
|
return _ttl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline int ICMPSocketImpl::timeout() const
|
||||||
|
{
|
||||||
|
return _timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::Net
|
} } // namespace Poco::Net
|
||||||
|
|
||||||
|
|
||||||
|
@ -242,6 +242,7 @@ void HTTPResponse::read(std::istream& istr)
|
|||||||
while (ch != '\r' && ch != '\n' && ch != eof && reason.length() < MAX_REASON_LENGTH) { reason += (char) ch; ch = istr.get(); }
|
while (ch != '\r' && ch != '\n' && ch != eof && reason.length() < MAX_REASON_LENGTH) { reason += (char) ch; ch = istr.get(); }
|
||||||
if (!Poco::Ascii::isSpace(ch)) throw MessageException("HTTP reason string too long");
|
if (!Poco::Ascii::isSpace(ch)) throw MessageException("HTTP reason string too long");
|
||||||
if (ch == '\r') ch = istr.get();
|
if (ch == '\r') ch = istr.get();
|
||||||
|
if (ch != '\n') throw MessageException("Unterminated HTTP response line");
|
||||||
|
|
||||||
HTTPMessage::read(istr);
|
HTTPMessage::read(istr);
|
||||||
ch = istr.get();
|
ch = istr.get();
|
||||||
|
@ -27,10 +27,7 @@ namespace Net {
|
|||||||
|
|
||||||
|
|
||||||
ICMPSocket::ICMPSocket(IPAddress::Family family, int dataSize, int ttl, int timeout):
|
ICMPSocket::ICMPSocket(IPAddress::Family family, int dataSize, int ttl, int timeout):
|
||||||
Socket(new ICMPSocketImpl(family, dataSize, ttl, timeout)),
|
Socket(new ICMPSocketImpl(family, dataSize, ttl, timeout))
|
||||||
_dataSize(dataSize),
|
|
||||||
_ttl(ttl),
|
|
||||||
_timeout(timeout)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,4 +75,22 @@ int ICMPSocket::receiveFrom(SocketAddress& address, int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ICMPSocket::dataSize() const
|
||||||
|
{
|
||||||
|
return static_cast<ICMPSocketImpl*>(impl())->dataSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ICMPSocket::ttl() const
|
||||||
|
{
|
||||||
|
return static_cast<ICMPSocketImpl*>(impl())->ttl();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ICMPSocket::timeout() const
|
||||||
|
{
|
||||||
|
return static_cast<ICMPSocketImpl*>(impl())->timeout();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::Net
|
} } // namespace Poco::Net
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "Poco/Timespan.h"
|
#include "Poco/Timespan.h"
|
||||||
#include "Poco/Timestamp.h"
|
#include "Poco/Timestamp.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
|
#include "Poco/Buffer.h"
|
||||||
|
|
||||||
|
|
||||||
using Poco::TimeoutException;
|
using Poco::TimeoutException;
|
||||||
@ -33,6 +34,7 @@ namespace Net {
|
|||||||
ICMPSocketImpl::ICMPSocketImpl(IPAddress::Family family, int dataSize, int ttl, int timeout):
|
ICMPSocketImpl::ICMPSocketImpl(IPAddress::Family family, int dataSize, int ttl, int timeout):
|
||||||
RawSocketImpl(family, IPPROTO_ICMP),
|
RawSocketImpl(family, IPPROTO_ICMP),
|
||||||
_icmpPacket(family, dataSize),
|
_icmpPacket(family, dataSize),
|
||||||
|
_ttl(ttl),
|
||||||
_timeout(timeout)
|
_timeout(timeout)
|
||||||
{
|
{
|
||||||
setOption(IPPROTO_IP, IP_TTL, ttl);
|
setOption(IPPROTO_IP, IP_TTL, ttl);
|
||||||
@ -55,7 +57,7 @@ int ICMPSocketImpl::sendTo(const void*, int, const SocketAddress& address, int f
|
|||||||
int ICMPSocketImpl::receiveFrom(void*, int, SocketAddress& address, int flags)
|
int ICMPSocketImpl::receiveFrom(void*, int, SocketAddress& address, int flags)
|
||||||
{
|
{
|
||||||
int maxPacketSize = _icmpPacket.maxPacketSize();
|
int maxPacketSize = _icmpPacket.maxPacketSize();
|
||||||
unsigned char* buffer = new unsigned char[maxPacketSize];
|
Poco::Buffer<unsigned char> buffer(maxPacketSize);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -68,31 +70,24 @@ int ICMPSocketImpl::receiveFrom(void*, int, SocketAddress& address, int flags)
|
|||||||
// fake ping responses will cause an endless loop.
|
// fake ping responses will cause an endless loop.
|
||||||
throw TimeoutException();
|
throw TimeoutException();
|
||||||
}
|
}
|
||||||
SocketImpl::receiveFrom(buffer, maxPacketSize, address, flags);
|
SocketImpl::receiveFrom(buffer.begin(), maxPacketSize, address, flags);
|
||||||
}
|
}
|
||||||
while (!_icmpPacket.validReplyID(buffer, maxPacketSize));
|
while (!_icmpPacket.validReplyID(buffer.begin(), maxPacketSize));
|
||||||
}
|
|
||||||
catch (TimeoutException&)
|
|
||||||
{
|
|
||||||
delete [] buffer;
|
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
catch (Exception&)
|
catch (Exception&)
|
||||||
{
|
{
|
||||||
std::string err = _icmpPacket.errorDescription(buffer, maxPacketSize);
|
std::string err = _icmpPacket.errorDescription(buffer.begin(), maxPacketSize);
|
||||||
delete [] buffer;
|
|
||||||
if (!err.empty())
|
if (!err.empty())
|
||||||
throw ICMPException(err);
|
throw ICMPException(err);
|
||||||
else
|
else
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct timeval then = _icmpPacket.time(buffer, maxPacketSize);
|
struct timeval then = _icmpPacket.time(buffer.begin(), maxPacketSize);
|
||||||
struct timeval now = _icmpPacket.time();
|
struct timeval now = _icmpPacket.time();
|
||||||
|
|
||||||
int elapsed = (((now.tv_sec * 1000000) + now.tv_usec) - ((then.tv_sec * 1000000) + then.tv_usec))/1000;
|
int elapsed = (((now.tv_sec * 1000000) + now.tv_usec) - ((then.tv_sec * 1000000) + then.tv_usec))/1000;
|
||||||
|
|
||||||
delete[] buffer;
|
|
||||||
return elapsed;
|
return elapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,18 +105,21 @@ namespace
|
|||||||
poco_check_ptr (pPS);
|
poco_check_ptr (pPS);
|
||||||
NameValueCollection::ConstIterator it = header.begin();
|
NameValueCollection::ConstIterator it = header.begin();
|
||||||
NameValueCollection::ConstIterator end = header.end();
|
NameValueCollection::ConstIterator end = header.end();
|
||||||
|
bool added = false;
|
||||||
for (; it != end; ++it)
|
for (; it != end; ++it)
|
||||||
{
|
{
|
||||||
if (MailMessage::HEADER_CONTENT_DISPOSITION == it->first)
|
if (!added && MailMessage::HEADER_CONTENT_DISPOSITION == it->first)
|
||||||
{
|
{
|
||||||
if (it->second == "inline")
|
if (it->second == "inline")
|
||||||
_pMsg->addContent(pPS, cte);
|
_pMsg->addContent(pPS, cte);
|
||||||
else
|
else
|
||||||
_pMsg->addAttachment("", pPS, cte);
|
_pMsg->addAttachment("", pPS, cte);
|
||||||
|
added = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pPS->headers().set(it->first, it->second);
|
pPS->headers().set(it->first, it->second);
|
||||||
}
|
}
|
||||||
|
if (!added) delete pPS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,6 +194,7 @@ const std::string MailMessage::CTE_BASE64("base64");
|
|||||||
|
|
||||||
|
|
||||||
MailMessage::MailMessage(PartStoreFactory* pStoreFactory):
|
MailMessage::MailMessage(PartStoreFactory* pStoreFactory):
|
||||||
|
_encoding(),
|
||||||
_pStoreFactory(pStoreFactory)
|
_pStoreFactory(pStoreFactory)
|
||||||
{
|
{
|
||||||
Poco::Timestamp now;
|
Poco::Timestamp now;
|
||||||
|
@ -88,13 +88,13 @@ int MultipartStreamBuf::readFromDevice(char* buffer, std::streamsize length)
|
|||||||
{
|
{
|
||||||
if (ch == '\r')
|
if (ch == '\r')
|
||||||
{
|
{
|
||||||
ch = buf.sbumpc(); // '\n'
|
buf.sbumpc(); // '\n'
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (ch == '-' && buf.sgetc() == '-')
|
else if (ch == '-' && buf.sgetc() == '-')
|
||||||
{
|
{
|
||||||
ch = buf.sbumpc(); // '-'
|
buf.sbumpc(); // '-'
|
||||||
_lastPart = true;
|
_lastPart = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -268,7 +268,7 @@ void MultipartReader::guessBoundary()
|
|||||||
ch = _istr.peek();
|
ch = _istr.peek();
|
||||||
}
|
}
|
||||||
if (ch == '\r' || ch == '\n')
|
if (ch == '\r' || ch == '\n')
|
||||||
ch = _istr.get();
|
_istr.get();
|
||||||
if (_istr.peek() == '\n')
|
if (_istr.peek() == '\n')
|
||||||
_istr.get();
|
_istr.get();
|
||||||
}
|
}
|
||||||
@ -281,7 +281,7 @@ void MultipartReader::parseHeader(MessageHeader& messageHeader)
|
|||||||
messageHeader.clear();
|
messageHeader.clear();
|
||||||
messageHeader.read(_istr);
|
messageHeader.read(_istr);
|
||||||
int ch = _istr.get();
|
int ch = _istr.get();
|
||||||
if (ch == '\r' && _istr.peek() == '\n') ch = _istr.get();
|
if (ch == '\r' && _istr.peek() == '\n') _istr.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -228,7 +228,8 @@ NetworkInterfaceImpl::NetworkInterfaceImpl(const std::string& name,
|
|||||||
_pointToPoint(false),
|
_pointToPoint(false),
|
||||||
_up(false),
|
_up(false),
|
||||||
_running(false),
|
_running(false),
|
||||||
_mtu(0)
|
_mtu(0),
|
||||||
|
_type(NetworkInterface::NI_TYPE_OTHER)
|
||||||
{
|
{
|
||||||
_addressList.push_back(AddressTuple(address, subnetMask, broadcastAddress));
|
_addressList.push_back(AddressTuple(address, subnetMask, broadcastAddress));
|
||||||
setPhyParams();
|
setPhyParams();
|
||||||
|
@ -48,7 +48,7 @@ int QuotedPrintableDecoderBuf::readFromDevice()
|
|||||||
ch = _buf.sbumpc();
|
ch = _buf.sbumpc();
|
||||||
if (ch == '\r')
|
if (ch == '\r')
|
||||||
{
|
{
|
||||||
ch = _buf.sbumpc(); // read \n
|
_buf.sbumpc(); // read \n
|
||||||
}
|
}
|
||||||
else if (Poco::Ascii::isHexDigit(ch))
|
else if (Poco::Ascii::isHexDigit(ch))
|
||||||
{
|
{
|
||||||
|
@ -252,7 +252,7 @@ void SocketAddress::init(const std::string& hostAddress, Poco::UInt16 portNumber
|
|||||||
{
|
{
|
||||||
#if defined(POCO_HAVE_IPv6)
|
#if defined(POCO_HAVE_IPv6)
|
||||||
// if we get both IPv4 and IPv6 addresses, prefer IPv4
|
// if we get both IPv4 and IPv6 addresses, prefer IPv4
|
||||||
std::sort(addresses.begin(), addresses.end(), AFLT());
|
std::stable_sort(addresses.begin(), addresses.end(), AFLT());
|
||||||
#endif
|
#endif
|
||||||
init(addresses[0], portNumber);
|
init(addresses[0], portNumber);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ void ConsoleCertificateHandler::onInvalidCertificate(const void*, VerificationEr
|
|||||||
std::cout << "The certificate yielded the error: " << errorCert.errorMessage() << "\n\n";
|
std::cout << "The certificate yielded the error: " << errorCert.errorMessage() << "\n\n";
|
||||||
std::cout << "The error occurred in the certificate chain at position " << errorCert.errorDepth() << "\n";
|
std::cout << "The error occurred in the certificate chain at position " << errorCert.errorDepth() << "\n";
|
||||||
std::cout << "Accept the certificate (y,n)? ";
|
std::cout << "Accept the certificate (y,n)? ";
|
||||||
char c;
|
char c = 0;
|
||||||
std::cin >> c;
|
std::cin >> c;
|
||||||
if (c == 'y' || c == 'Y')
|
if (c == 'y' || c == 'Y')
|
||||||
errorCert.setIgnoreError(true);
|
errorCert.setIgnoreError(true);
|
||||||
|
@ -132,7 +132,8 @@ std::istream* HTTPSStreamFactory::open(const URI& uri)
|
|||||||
resolvedURI.setUserInfo(username + ":" + password);
|
resolvedURI.setUserInfo(username + ":" + password);
|
||||||
authorize = false;
|
authorize = false;
|
||||||
}
|
}
|
||||||
delete pSession; pSession = 0;
|
delete pSession;
|
||||||
|
pSession = 0;
|
||||||
++redirects;
|
++redirects;
|
||||||
retry = true;
|
retry = true;
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ void PageReader::nextToken(std::istream& istr, std::string& token)
|
|||||||
if (ch == '<' && istr.peek() == '%')
|
if (ch == '<' && istr.peek() == '%')
|
||||||
{
|
{
|
||||||
token += "<%";
|
token += "<%";
|
||||||
ch = istr.get();
|
istr.get();
|
||||||
ch = istr.peek();
|
ch = istr.peek();
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
@ -300,7 +300,7 @@ void PageReader::nextToken(std::istream& istr, std::string& token)
|
|||||||
else if (ch == '%' && istr.peek() == '>')
|
else if (ch == '%' && istr.peek() == '>')
|
||||||
{
|
{
|
||||||
token += "%>";
|
token += "%>";
|
||||||
ch = istr.get();
|
istr.get();
|
||||||
}
|
}
|
||||||
else token += (char) ch;
|
else token += (char) ch;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ Build Status
|
|||||||
|
|
||||||
- Travis: [](https://travis-ci.org/pocoproject/poco)
|
- Travis: [](https://travis-ci.org/pocoproject/poco)
|
||||||
- AppVeyor: [](https://ci.appveyor.com/project/obiltschnig/poco)
|
- AppVeyor: [](https://ci.appveyor.com/project/obiltschnig/poco)
|
||||||
|
- [](https://bestpractices.coreinfrastructure.org/projects/370)
|
||||||
|
|
||||||
|
|
||||||
![alt text][logo]
|
![alt text][logo]
|
||||||
@ -21,11 +22,13 @@ POrtable COmponents C++ Libraries are:
|
|||||||
- Open Source, licensed under the [Boost Software License](https://spdx.org/licenses/BSL-1.0).
|
- Open Source, licensed under the [Boost Software License](https://spdx.org/licenses/BSL-1.0).
|
||||||
|
|
||||||
----
|
----
|
||||||
To start using POCO, see the [Guided Tour](http://pocoproject.org/docs/00100-GuidedTour.html) and [Getting Started](http://pocoproject.org/docs/00200-GettingStarted.html) documents.
|
To start using POCO, see the [Guided Tour](https://pocoproject.org/docs/00100-GuidedTour.html) and [Getting Started](https://pocoproject.org/docs/00200-GettingStarted.html) documents.
|
||||||
|
|
||||||
----
|
----
|
||||||
POCO has an active user and contributing community, please visit our [web site](http://pocoproject.org), [forum](http://pocoproject.org/forum) and [blog](http://pocoproject.org/blog).
|
POCO has an active user and contributing community, please visit our [web site](https://pocoproject.org), [forum](https://pocoproject.org/forum) and [blog](https://pocoproject.org/blog).
|
||||||
Answers to POCO-related questions can also be found on [Stack Overflow](http://stackoverflow.com/questions/tagged/poco-libraries).
|
Answers to POCO-related questions can also be found on [Stack Overflow](https://stackoverflow.com/questions/tagged/poco-libraries).
|
||||||
|
|
||||||
|
Please see [CONTRIBUTING](CONTRIBUTING.md) for submitting contributions, bugs reports, feature requests or security issues.
|
||||||
|
|
||||||
----
|
----
|
||||||
In regards to Boost, in spite of some functional overlapping,
|
In regards to Boost, in spite of some functional overlapping,
|
||||||
|
@ -450,19 +450,27 @@ void ParserEngine::init()
|
|||||||
if (dynamic_cast<NoNamespacePrefixesStrategy*>(_pNamespaceStrategy))
|
if (dynamic_cast<NoNamespacePrefixesStrategy*>(_pNamespaceStrategy))
|
||||||
{
|
{
|
||||||
_parser = XML_ParserCreateNS(_encodingSpecified ? _encoding.c_str() : 0, '\t');
|
_parser = XML_ParserCreateNS(_encodingSpecified ? _encoding.c_str() : 0, '\t');
|
||||||
|
if (_parser)
|
||||||
|
{
|
||||||
XML_SetNamespaceDeclHandler(_parser, handleStartNamespaceDecl, handleEndNamespaceDecl);
|
XML_SetNamespaceDeclHandler(_parser, handleStartNamespaceDecl, handleEndNamespaceDecl);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (dynamic_cast<NamespacePrefixesStrategy*>(_pNamespaceStrategy))
|
else if (dynamic_cast<NamespacePrefixesStrategy*>(_pNamespaceStrategy))
|
||||||
{
|
{
|
||||||
_parser = XML_ParserCreateNS(_encodingSpecified ? _encoding.c_str() : 0, '\t');
|
_parser = XML_ParserCreateNS(_encodingSpecified ? _encoding.c_str() : 0, '\t');
|
||||||
|
if (_parser)
|
||||||
|
{
|
||||||
XML_SetReturnNSTriplet(_parser, 1);
|
XML_SetReturnNSTriplet(_parser, 1);
|
||||||
XML_SetNamespaceDeclHandler(_parser, handleStartNamespaceDecl, handleEndNamespaceDecl);
|
XML_SetNamespaceDeclHandler(_parser, handleStartNamespaceDecl, handleEndNamespaceDecl);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_parser = XML_ParserCreate(_encodingSpecified ? _encoding.c_str() : 0);
|
_parser = XML_ParserCreate(_encodingSpecified ? _encoding.c_str() : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_parser) throw XMLException("Cannot create Expat parser");
|
||||||
|
|
||||||
XML_SetUserData(_parser, this);
|
XML_SetUserData(_parser, this);
|
||||||
XML_SetElementHandler(_parser, handleStartElement, handleEndElement);
|
XML_SetElementHandler(_parser, handleStartElement, handleEndElement);
|
||||||
XML_SetCharacterDataHandler(_parser, handleCharacterData);
|
XML_SetCharacterDataHandler(_parser, handleCharacterData);
|
||||||
@ -720,6 +728,8 @@ int ParserEngine::handleExternalEntityRef(XML_Parser parser, const XML_Char* con
|
|||||||
if (pInputSource)
|
if (pInputSource)
|
||||||
{
|
{
|
||||||
XML_Parser extParser = XML_ExternalEntityParserCreate(pThis->_parser, context, 0);
|
XML_Parser extParser = XML_ExternalEntityParserCreate(pThis->_parser, context, 0);
|
||||||
|
if (!extParser) throw XMLException("Cannot create external entity parser");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pThis->parseExternal(extParser, pInputSource);
|
pThis->parseExternal(extParser, pInputSource);
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "Poco/Zip/ZipLocalFileHeader.h"
|
#include "Poco/Zip/ZipLocalFileHeader.h"
|
||||||
#include "Poco/Zip/ZipFileInfo.h"
|
#include "Poco/Zip/ZipFileInfo.h"
|
||||||
#include "Poco/Zip/ZipArchiveInfo.h"
|
#include "Poco/Zip/ZipArchiveInfo.h"
|
||||||
|
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
@ -69,6 +69,7 @@ int AutoDetectStreamBuf::readFromDevice(char* buffer, std::streamsize length)
|
|||||||
{
|
{
|
||||||
_pIstr->seekg(_start, std::ios_base::beg);
|
_pIstr->seekg(_start, std::ios_base::beg);
|
||||||
_reposition = false;
|
_reposition = false;
|
||||||
|
if (!_pIstr->good()) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_prefix.empty())
|
if (!_prefix.empty())
|
||||||
@ -145,11 +146,9 @@ int AutoDetectStreamBuf::readFromDevice(char* buffer, std::streamsize length)
|
|||||||
{
|
{
|
||||||
if (c-1 == byte3)
|
if (c-1 == byte3)
|
||||||
{
|
{
|
||||||
// a match, pushback
|
// a match, seek back
|
||||||
_pIstr->putback(c);
|
_pIstr->seekg(-4, std::ios::cur);
|
||||||
_pIstr->putback(byte3);
|
if (!_pIstr->good()) throw Poco::IOException("Failed to seek on input stream");
|
||||||
_pIstr->putback(ZipLocalFileHeader::HEADER[1]);
|
|
||||||
_pIstr->putback(ZipLocalFileHeader::HEADER[0]);
|
|
||||||
_eofDetected = true;
|
_eofDetected = true;
|
||||||
return tempPos;
|
return tempPos;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ void Compress::addEntry(std::istream& in, const Poco::DateTime& lastModifiedAt,
|
|||||||
_offset = hdr.getEndPos();
|
_offset = hdr.getEndPos();
|
||||||
_offset += extraDataSize;
|
_offset += extraDataSize;
|
||||||
_files.insert(std::make_pair(fileName.toString(Poco::Path::PATH_UNIX), hdr));
|
_files.insert(std::make_pair(fileName.toString(Poco::Path::PATH_UNIX), hdr));
|
||||||
poco_assert (_out);
|
if (!_out) throw Poco::IOException("Bad output stream");
|
||||||
ZipFileInfo nfo(hdr);
|
ZipFileInfo nfo(hdr);
|
||||||
nfo.setOffset(localHeaderOffset);
|
nfo.setOffset(localHeaderOffset);
|
||||||
nfo.setZip64Data();
|
nfo.setZip64Data();
|
||||||
@ -89,12 +89,13 @@ void Compress::addEntry(std::istream& in, const Poco::DateTime& lastModifiedAt,
|
|||||||
|
|
||||||
void Compress::addFileRaw(std::istream& in, const ZipLocalFileHeader& h, const Poco::Path& fileName)
|
void Compress::addFileRaw(std::istream& in, const ZipLocalFileHeader& h, const Poco::Path& fileName)
|
||||||
{
|
{
|
||||||
|
if (!in.good())
|
||||||
|
throw ZipException("Invalid input stream");
|
||||||
|
|
||||||
std::string fn = ZipUtil::validZipEntryFileName(fileName);
|
std::string fn = ZipUtil::validZipEntryFileName(fileName);
|
||||||
//bypass the header of the input stream and point to the first byte of the data payload
|
//bypass the header of the input stream and point to the first byte of the data payload
|
||||||
in.seekg(h.getDataStartPos(), std::ios_base::beg);
|
in.seekg(h.getDataStartPos(), std::ios_base::beg);
|
||||||
|
if (!in.good()) throw Poco::IOException("Failed to seek on input stream");
|
||||||
if (!in.good())
|
|
||||||
throw ZipException("Invalid input stream");
|
|
||||||
|
|
||||||
std::streamoff localHeaderOffset = _offset;
|
std::streamoff localHeaderOffset = _offset;
|
||||||
ZipLocalFileHeader hdr(h);
|
ZipLocalFileHeader hdr(h);
|
||||||
@ -161,7 +162,7 @@ void Compress::addFileRaw(std::istream& in, const ZipLocalFileHeader& h, const P
|
|||||||
}
|
}
|
||||||
|
|
||||||
_files.insert(std::make_pair(fileName.toString(Poco::Path::PATH_UNIX), hdr));
|
_files.insert(std::make_pair(fileName.toString(Poco::Path::PATH_UNIX), hdr));
|
||||||
poco_assert (_out);
|
if (!_out) throw Poco::IOException("Bad output stream");
|
||||||
ZipFileInfo nfo(hdr);
|
ZipFileInfo nfo(hdr);
|
||||||
nfo.setOffset(localHeaderOffset);
|
nfo.setOffset(localHeaderOffset);
|
||||||
nfo.setZip64Data();
|
nfo.setZip64Data();
|
||||||
@ -229,7 +230,7 @@ void Compress::addDirectory(const Poco::Path& entryName, const Poco::DateTime& l
|
|||||||
if (hdr.searchCRCAndSizesAfterData())
|
if (hdr.searchCRCAndSizesAfterData())
|
||||||
_offset += extraDataSize;
|
_offset += extraDataSize;
|
||||||
_files.insert(std::make_pair(entryName.toString(Poco::Path::PATH_UNIX), hdr));
|
_files.insert(std::make_pair(entryName.toString(Poco::Path::PATH_UNIX), hdr));
|
||||||
poco_assert (_out);
|
if (!_out) throw Poco::IOException("Bad output stream");
|
||||||
ZipFileInfo nfo(hdr);
|
ZipFileInfo nfo(hdr);
|
||||||
nfo.setOffset(localHeaderOffset);
|
nfo.setOffset(localHeaderOffset);
|
||||||
nfo.setZip64Data();
|
nfo.setZip64Data();
|
||||||
@ -314,7 +315,7 @@ ZipArchive Compress::close()
|
|||||||
centralDirSize64 += entrySize;
|
centralDirSize64 += entrySize;
|
||||||
_offset += entrySize;
|
_offset += entrySize;
|
||||||
}
|
}
|
||||||
poco_assert (_out);
|
if (!_out) throw Poco::IOException("Bad output stream");
|
||||||
|
|
||||||
Poco::UInt64 numEntries64 = _infos.size();
|
Poco::UInt64 numEntries64 = _infos.size();
|
||||||
needZip64 = needZip64 || _offset >= ZipCommon::ZIP64_MAGIC;
|
needZip64 = needZip64 || _offset >= ZipCommon::ZIP64_MAGIC;
|
||||||
|
@ -39,7 +39,7 @@ Decompress::Decompress(std::istream& in, const Poco::Path& outputDir, bool flatt
|
|||||||
{
|
{
|
||||||
_outDir.makeAbsolute();
|
_outDir.makeAbsolute();
|
||||||
_outDir.makeDirectory();
|
_outDir.makeDirectory();
|
||||||
poco_assert (_in.good());
|
if (!_in.good()) throw Poco::IOException("Bad input stream");
|
||||||
Poco::File tmp(_outDir);
|
Poco::File tmp(_outDir);
|
||||||
if (!tmp.exists())
|
if (!tmp.exists())
|
||||||
{
|
{
|
||||||
|
@ -69,7 +69,7 @@ int PartialStreamBuf::readFromDevice(char* buffer, std::streamsize length)
|
|||||||
_pIstr->clear();
|
_pIstr->clear();
|
||||||
_pIstr->seekg(_start, std::ios_base::beg);
|
_pIstr->seekg(_start, std::ios_base::beg);
|
||||||
if (_pIstr->fail())
|
if (_pIstr->fail())
|
||||||
throw Poco::IOException("Failed to reposition in stream");
|
throw Poco::IOException("Failed to seek on input stream");
|
||||||
}
|
}
|
||||||
if (!_prefix.empty())
|
if (!_prefix.empty())
|
||||||
{
|
{
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "Poco/Zip/SkipCallback.h"
|
#include "Poco/Zip/SkipCallback.h"
|
||||||
#include "Poco/Zip/ZipLocalFileHeader.h"
|
#include "Poco/Zip/ZipLocalFileHeader.h"
|
||||||
#include "Poco/Zip/ZipUtil.h"
|
#include "Poco/Zip/ZipUtil.h"
|
||||||
|
#include "Poco/Exception.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
@ -39,6 +40,7 @@ bool SkipCallback::handleZipEntry(std::istream& zipStream, const ZipLocalFileHea
|
|||||||
zipStream.seekg(hdr.getCompressedSize(), std::ios_base::cur);
|
zipStream.seekg(hdr.getCompressedSize(), std::ios_base::cur);
|
||||||
else
|
else
|
||||||
ZipUtil::sync(zipStream);
|
ZipUtil::sync(zipStream);
|
||||||
|
if (!zipStream.good()) throw Poco::IOException("Failed to seek on input stream");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,12 +59,16 @@ void ZipArchiveInfo::parse(std::istream& inp, bool assumeHeaderRead)
|
|||||||
if (!assumeHeaderRead)
|
if (!assumeHeaderRead)
|
||||||
{
|
{
|
||||||
inp.read(_rawInfo, ZipCommon::HEADER_SIZE);
|
inp.read(_rawInfo, ZipCommon::HEADER_SIZE);
|
||||||
|
if (inp.gcount() != ZipCommon::HEADER_SIZE)
|
||||||
|
throw Poco::IOException("Failed to read archive info header");
|
||||||
|
if (std::memcmp(_rawInfo, HEADER, ZipCommon::HEADER_SIZE) != 0)
|
||||||
|
throw Poco::DataFormatException("Bad archive info header");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::memcpy(_rawInfo, HEADER, ZipCommon::HEADER_SIZE);
|
std::memcpy(_rawInfo, HEADER, ZipCommon::HEADER_SIZE);
|
||||||
}
|
}
|
||||||
poco_assert (std::memcmp(_rawInfo, HEADER, ZipCommon::HEADER_SIZE) == 0);
|
|
||||||
// read the rest of the header
|
// read the rest of the header
|
||||||
inp.read(_rawInfo + ZipCommon::HEADER_SIZE, FULLHEADER_SIZE - ZipCommon::HEADER_SIZE);
|
inp.read(_rawInfo + ZipCommon::HEADER_SIZE, FULLHEADER_SIZE - ZipCommon::HEADER_SIZE);
|
||||||
Poco::UInt16 len = getZipCommentSize();
|
Poco::UInt16 len = getZipCommentSize();
|
||||||
@ -136,12 +140,16 @@ void ZipArchiveInfo64::parse(std::istream& inp, bool assumeHeaderRead)
|
|||||||
if (!assumeHeaderRead)
|
if (!assumeHeaderRead)
|
||||||
{
|
{
|
||||||
inp.read(_rawInfo, ZipCommon::HEADER_SIZE);
|
inp.read(_rawInfo, ZipCommon::HEADER_SIZE);
|
||||||
|
if (inp.gcount() != ZipCommon::HEADER_SIZE)
|
||||||
|
throw Poco::IOException("Failed to read archive info header");
|
||||||
|
if (std::memcmp(_rawInfo, HEADER, ZipCommon::HEADER_SIZE) != 0)
|
||||||
|
throw Poco::DataFormatException("Bad archive info header");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::memcpy(_rawInfo, HEADER, ZipCommon::HEADER_SIZE);
|
std::memcpy(_rawInfo, HEADER, ZipCommon::HEADER_SIZE);
|
||||||
}
|
}
|
||||||
poco_assert (std::memcmp(_rawInfo, HEADER, ZipCommon::HEADER_SIZE) == 0);
|
|
||||||
std::memset(_rawInfo + ZipCommon::HEADER_SIZE, 0, FULL_HEADER_SIZE - ZipCommon::HEADER_SIZE);
|
std::memset(_rawInfo + ZipCommon::HEADER_SIZE, 0, FULL_HEADER_SIZE - ZipCommon::HEADER_SIZE);
|
||||||
|
|
||||||
// read the rest of the header
|
// read the rest of the header
|
||||||
@ -164,7 +172,11 @@ void ZipArchiveInfo64::parse(std::istream& inp, bool assumeHeaderRead)
|
|||||||
ZipUtil::set64BitValue(FULL_HEADER_SIZE + len - offset, _rawInfo, RECORDSIZE_POS);
|
ZipUtil::set64BitValue(FULL_HEADER_SIZE + len - offset, _rawInfo, RECORDSIZE_POS);
|
||||||
}
|
}
|
||||||
inp.read(_locInfo, FULL_LOCATOR_SIZE);
|
inp.read(_locInfo, FULL_LOCATOR_SIZE);
|
||||||
poco_assert (std::memcmp(_locInfo, LOCATOR_HEADER, ZipCommon::HEADER_SIZE) == 0);
|
if (inp.gcount() != FULL_LOCATOR_SIZE)
|
||||||
|
throw Poco::IOException("Failed to read locator");
|
||||||
|
if (std::memcmp(_locInfo, LOCATOR_HEADER, ZipCommon::HEADER_SIZE) != 0)
|
||||||
|
throw Poco::DataFormatException("Bad locator header");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Poco/Zip/ZipDataInfo.h"
|
#include "Poco/Zip/ZipDataInfo.h"
|
||||||
|
#include "Poco/Exception.h"
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
@ -47,10 +48,11 @@ ZipDataInfo::ZipDataInfo(std::istream& in, bool assumeHeaderRead):
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
in.read(_rawInfo, ZipCommon::HEADER_SIZE);
|
in.read(_rawInfo, ZipCommon::HEADER_SIZE);
|
||||||
if ((!in) || (in.gcount() != ZipCommon::HEADER_SIZE))
|
if (in.gcount() != ZipCommon::HEADER_SIZE)
|
||||||
return;
|
throw Poco::IOException("Failed to read data info header");
|
||||||
|
if (std::memcmp(_rawInfo, HEADER, ZipCommon::HEADER_SIZE) != 0)
|
||||||
|
throw Poco::DataFormatException("Bad data info header");
|
||||||
}
|
}
|
||||||
poco_assert (std::memcmp(_rawInfo, HEADER, ZipCommon::HEADER_SIZE) == 0);
|
|
||||||
// now copy the rest of the header
|
// now copy the rest of the header
|
||||||
in.read(_rawInfo+ZipCommon::HEADER_SIZE, FULLHEADER_SIZE - ZipCommon::HEADER_SIZE);
|
in.read(_rawInfo+ZipCommon::HEADER_SIZE, FULLHEADER_SIZE - ZipCommon::HEADER_SIZE);
|
||||||
_valid = (!in.eof() && in.good());
|
_valid = (!in.eof() && in.good());
|
||||||
@ -87,10 +89,12 @@ ZipDataInfo64::ZipDataInfo64(std::istream& in, bool assumeHeaderRead):
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
in.read(_rawInfo, ZipCommon::HEADER_SIZE);
|
in.read(_rawInfo, ZipCommon::HEADER_SIZE);
|
||||||
if ((!in) || (in.gcount() != ZipCommon::HEADER_SIZE))
|
if (in.gcount() != ZipCommon::HEADER_SIZE)
|
||||||
return;
|
throw Poco::IOException("Failed to read data info header");
|
||||||
|
if (std::memcmp(_rawInfo, HEADER, ZipCommon::HEADER_SIZE) != 0)
|
||||||
|
throw Poco::DataFormatException("Bad data info header");
|
||||||
}
|
}
|
||||||
poco_assert (std::memcmp(_rawInfo, HEADER, ZipCommon::HEADER_SIZE) == 0);
|
|
||||||
// now copy the rest of the header
|
// now copy the rest of the header
|
||||||
in.read(_rawInfo+ZipCommon::HEADER_SIZE, FULLHEADER_SIZE - ZipCommon::HEADER_SIZE);
|
in.read(_rawInfo+ZipCommon::HEADER_SIZE, FULLHEADER_SIZE - ZipCommon::HEADER_SIZE);
|
||||||
_valid = (!in.eof() && in.good());
|
_valid = (!in.eof() && in.good());
|
||||||
|
@ -87,12 +87,16 @@ void ZipFileInfo::parse(std::istream& inp, bool assumeHeaderRead)
|
|||||||
if (!assumeHeaderRead)
|
if (!assumeHeaderRead)
|
||||||
{
|
{
|
||||||
inp.read(_rawInfo, ZipCommon::HEADER_SIZE);
|
inp.read(_rawInfo, ZipCommon::HEADER_SIZE);
|
||||||
|
if (inp.gcount() != ZipCommon::HEADER_SIZE)
|
||||||
|
throw Poco::IOException("Failed to read file info header");
|
||||||
|
if (std::memcmp(_rawInfo, HEADER, ZipCommon::HEADER_SIZE) != 0)
|
||||||
|
throw Poco::DataFormatException("Bad file info header");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::memcpy(_rawInfo, HEADER, ZipCommon::HEADER_SIZE);
|
std::memcpy(_rawInfo, HEADER, ZipCommon::HEADER_SIZE);
|
||||||
}
|
}
|
||||||
poco_assert (std::memcmp(_rawInfo, HEADER, ZipCommon::HEADER_SIZE) == 0);
|
|
||||||
// read the rest of the header
|
// read the rest of the header
|
||||||
inp.read(_rawInfo + ZipCommon::HEADER_SIZE, FULLHEADER_SIZE - ZipCommon::HEADER_SIZE);
|
inp.read(_rawInfo + ZipCommon::HEADER_SIZE, FULLHEADER_SIZE - ZipCommon::HEADER_SIZE);
|
||||||
_crc32 = getCRCFromHeader();
|
_crc32 = getCRCFromHeader();
|
||||||
@ -101,29 +105,47 @@ void ZipFileInfo::parse(std::istream& inp, bool assumeHeaderRead)
|
|||||||
_localHeaderOffset = getOffsetFromHeader();
|
_localHeaderOffset = getOffsetFromHeader();
|
||||||
parseDateTime();
|
parseDateTime();
|
||||||
Poco::UInt16 len = getFileNameLength();
|
Poco::UInt16 len = getFileNameLength();
|
||||||
|
if (len > 0)
|
||||||
|
{
|
||||||
Poco::Buffer<char> buf(len);
|
Poco::Buffer<char> buf(len);
|
||||||
inp.read(buf.begin(), len);
|
inp.read(buf.begin(), len);
|
||||||
_fileName = std::string(buf.begin(), len);
|
_fileName = std::string(buf.begin(), len);
|
||||||
|
}
|
||||||
if (hasExtraField())
|
if (hasExtraField())
|
||||||
{
|
{
|
||||||
len = getExtraFieldLength();
|
len = getExtraFieldLength();
|
||||||
|
if (len > 0)
|
||||||
|
{
|
||||||
Poco::Buffer<char> xtra(len);
|
Poco::Buffer<char> xtra(len);
|
||||||
inp.read(xtra.begin(), len);
|
inp.read(xtra.begin(), len);
|
||||||
_extraField = std::string(xtra.begin(), len);
|
_extraField = std::string(xtra.begin(), len);
|
||||||
char* ptr = xtra.begin();
|
char* ptr = xtra.begin();
|
||||||
while(ptr <= xtra.begin() + len - 4) {
|
while (ptr <= xtra.begin() + len - 4)
|
||||||
Poco::UInt16 id = ZipUtil::get16BitValue(ptr, 0); ptr +=2;
|
{
|
||||||
Poco::UInt16 size = ZipUtil::get16BitValue(ptr, 0); ptr += 2;
|
Poco::UInt16 id = ZipUtil::get16BitValue(ptr, 0);
|
||||||
if(id == ZipCommon::ZIP64_EXTRA_ID) {
|
ptr += 2;
|
||||||
|
Poco::UInt16 size = ZipUtil::get16BitValue(ptr, 0);
|
||||||
|
ptr += 2;
|
||||||
|
if (id == ZipCommon::ZIP64_EXTRA_ID)
|
||||||
|
{
|
||||||
poco_assert(size >= 8);
|
poco_assert(size >= 8);
|
||||||
if(getUncompressedSizeFromHeader() == ZipCommon::ZIP64_MAGIC) {
|
if (getUncompressedSizeFromHeader() == ZipCommon::ZIP64_MAGIC)
|
||||||
setUncompressedSize(ZipUtil::get64BitValue(ptr, 0)); size -= 8; ptr += 8;
|
{
|
||||||
|
setUncompressedSize(ZipUtil::get64BitValue(ptr, 0));
|
||||||
|
size -= 8;
|
||||||
|
ptr += 8;
|
||||||
}
|
}
|
||||||
if(size >= 8 && getCompressedSizeFromHeader() == ZipCommon::ZIP64_MAGIC) {
|
if (size >= 8 && getCompressedSizeFromHeader() == ZipCommon::ZIP64_MAGIC)
|
||||||
setCompressedSize(ZipUtil::get64BitValue(ptr, 0)); size -= 8; ptr += 8;
|
{
|
||||||
|
setCompressedSize(ZipUtil::get64BitValue(ptr, 0));
|
||||||
|
size -= 8;
|
||||||
|
ptr += 8;
|
||||||
}
|
}
|
||||||
if(size >= 8 && getOffsetFromHeader() == ZipCommon::ZIP64_MAGIC) {
|
if (size >= 8 && getOffsetFromHeader() == ZipCommon::ZIP64_MAGIC)
|
||||||
setOffset(ZipUtil::get64BitValue(ptr, 0)); size -= 8; ptr += 8;
|
{
|
||||||
|
setOffset(ZipUtil::get64BitValue(ptr, 0));
|
||||||
|
size -= 8;
|
||||||
|
ptr += 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -132,6 +154,7 @@ void ZipFileInfo::parse(std::istream& inp, bool assumeHeaderRead)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
len = getFileCommentLength();
|
len = getFileCommentLength();
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
{
|
{
|
||||||
|
@ -118,12 +118,16 @@ void ZipLocalFileHeader::parse(std::istream& inp, bool assumeHeaderRead)
|
|||||||
if (!assumeHeaderRead)
|
if (!assumeHeaderRead)
|
||||||
{
|
{
|
||||||
inp.read(_rawHeader, ZipCommon::HEADER_SIZE);
|
inp.read(_rawHeader, ZipCommon::HEADER_SIZE);
|
||||||
|
if (inp.gcount() != ZipCommon::HEADER_SIZE)
|
||||||
|
throw Poco::IOException("Failed to read local file header");
|
||||||
|
if (std::memcmp(_rawHeader, HEADER, ZipCommon::HEADER_SIZE) != 0)
|
||||||
|
throw Poco::DataFormatException("Bad local file header");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::memcpy(_rawHeader, HEADER, ZipCommon::HEADER_SIZE);
|
std::memcpy(_rawHeader, HEADER, ZipCommon::HEADER_SIZE);
|
||||||
}
|
}
|
||||||
poco_assert (std::memcmp(_rawHeader, HEADER, ZipCommon::HEADER_SIZE) == 0);
|
|
||||||
// read the rest of the header
|
// read the rest of the header
|
||||||
inp.read(_rawHeader + ZipCommon::HEADER_SIZE, FULLHEADER_SIZE - ZipCommon::HEADER_SIZE);
|
inp.read(_rawHeader + ZipCommon::HEADER_SIZE, FULLHEADER_SIZE - ZipCommon::HEADER_SIZE);
|
||||||
poco_assert (_rawHeader[VERSION_POS + 1]>= ZipCommon::HS_FAT && _rawHeader[VERSION_POS + 1] < ZipCommon::HS_UNUSED);
|
poco_assert (_rawHeader[VERSION_POS + 1]>= ZipCommon::HS_FAT && _rawHeader[VERSION_POS + 1] < ZipCommon::HS_UNUSED);
|
||||||
@ -131,9 +135,12 @@ void ZipLocalFileHeader::parse(std::istream& inp, bool assumeHeaderRead)
|
|||||||
poco_assert (ZipUtil::get16BitValue(_rawHeader, COMPR_METHOD_POS) < ZipCommon::CM_UNUSED);
|
poco_assert (ZipUtil::get16BitValue(_rawHeader, COMPR_METHOD_POS) < ZipCommon::CM_UNUSED);
|
||||||
parseDateTime();
|
parseDateTime();
|
||||||
Poco::UInt16 len = getFileNameLength();
|
Poco::UInt16 len = getFileNameLength();
|
||||||
|
if (len > 0)
|
||||||
|
{
|
||||||
Poco::Buffer<char> buf(len);
|
Poco::Buffer<char> buf(len);
|
||||||
inp.read(buf.begin(), len);
|
inp.read(buf.begin(), len);
|
||||||
_fileName = std::string(buf.begin(), len);
|
_fileName = std::string(buf.begin(), len);
|
||||||
|
}
|
||||||
|
|
||||||
if (!searchCRCAndSizesAfterData())
|
if (!searchCRCAndSizesAfterData())
|
||||||
{
|
{
|
||||||
@ -145,24 +152,32 @@ void ZipLocalFileHeader::parse(std::istream& inp, bool assumeHeaderRead)
|
|||||||
if (hasExtraField())
|
if (hasExtraField())
|
||||||
{
|
{
|
||||||
len = getExtraFieldLength();
|
len = getExtraFieldLength();
|
||||||
|
if (len > 0)
|
||||||
|
{
|
||||||
Poco::Buffer<char> xtra(len);
|
Poco::Buffer<char> xtra(len);
|
||||||
inp.read(xtra.begin(), len);
|
inp.read(xtra.begin(), len);
|
||||||
_extraField = std::string(xtra.begin(), len);
|
_extraField = std::string(xtra.begin(), len);
|
||||||
char* ptr = xtra.begin();
|
char* ptr = xtra.begin();
|
||||||
while (ptr <= xtra.begin() + len - 4)
|
while (ptr <= xtra.begin() + len - 4)
|
||||||
{
|
{
|
||||||
Poco::UInt16 id = ZipUtil::get16BitValue(ptr, 0); ptr +=2;
|
Poco::UInt16 id = ZipUtil::get16BitValue(ptr, 0);
|
||||||
Poco::UInt16 size = ZipUtil::get16BitValue(ptr, 0); ptr += 2;
|
ptr += 2;
|
||||||
|
Poco::UInt16 size = ZipUtil::get16BitValue(ptr, 0);
|
||||||
|
ptr += 2;
|
||||||
if (id == ZipCommon::ZIP64_EXTRA_ID)
|
if (id == ZipCommon::ZIP64_EXTRA_ID)
|
||||||
{
|
{
|
||||||
poco_assert(size >= 8);
|
poco_assert(size >= 8);
|
||||||
if (getUncompressedSizeFromHeader() == ZipCommon::ZIP64_MAGIC)
|
if (getUncompressedSizeFromHeader() == ZipCommon::ZIP64_MAGIC)
|
||||||
{
|
{
|
||||||
setUncompressedSize(ZipUtil::get64BitValue(ptr, 0)); size -= 8; ptr += 8;
|
setUncompressedSize(ZipUtil::get64BitValue(ptr, 0));
|
||||||
|
size -= 8;
|
||||||
|
ptr += 8;
|
||||||
}
|
}
|
||||||
if (size >= 8 && getCompressedSizeFromHeader() == ZipCommon::ZIP64_MAGIC)
|
if (size >= 8 && getCompressedSizeFromHeader() == ZipCommon::ZIP64_MAGIC)
|
||||||
{
|
{
|
||||||
setCompressedSize(ZipUtil::get64BitValue(ptr, 0)); size -= 8; ptr += 8;
|
setCompressedSize(ZipUtil::get64BitValue(ptr, 0));
|
||||||
|
size -= 8;
|
||||||
|
ptr += 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -171,7 +186,7 @@ void ZipLocalFileHeader::parse(std::istream& inp, bool assumeHeaderRead)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ const ZipLocalFileHeader& ZipManipulator::getForChange(const std::string& zipPat
|
|||||||
{
|
{
|
||||||
ZipArchive::FileHeaders::const_iterator it = _in->findHeader(zipPath);
|
ZipArchive::FileHeaders::const_iterator it = _in->findHeader(zipPath);
|
||||||
if (it == _in->headerEnd())
|
if (it == _in->headerEnd())
|
||||||
throw ZipManipulationException("entry not found: " + zipPath);
|
throw ZipManipulationException("Entry not found: " + zipPath);
|
||||||
|
|
||||||
if (_changes.find(zipPath) != _changes.end())
|
if (_changes.find(zipPath) != _changes.end())
|
||||||
throw ZipManipulationException("A change request exists already for entry " + zipPath);
|
throw ZipManipulationException("A change request exists already for entry " + zipPath);
|
||||||
|
@ -177,8 +177,8 @@ int ZipStreamBuf::readFromDevice(char* buffer, std::streamsize length)
|
|||||||
Poco::Int32 size = static_cast<Poco::Int32>(nfo.getFullHeaderSize());
|
Poco::Int32 size = static_cast<Poco::Int32>(nfo.getFullHeaderSize());
|
||||||
_expectedCrc32 = nfo.getCRC32();
|
_expectedCrc32 = nfo.getCRC32();
|
||||||
const char* rawHeader = nfo.getRawHeader();
|
const char* rawHeader = nfo.getRawHeader();
|
||||||
for (Poco::Int32 i = size-1; i >= 0; --i)
|
_pIstr->seekg(-size, std::ios::cur);
|
||||||
_pIstr->putback(rawHeader[i]);
|
if (!_pIstr->good()) throw Poco::IOException("Failed to seek on input stream");
|
||||||
if (!crcValid())
|
if (!crcValid())
|
||||||
throw ZipException("CRC failure");
|
throw ZipException("CRC failure");
|
||||||
}
|
}
|
||||||
@ -215,7 +215,8 @@ void ZipStreamBuf::close(Poco::UInt64& extraDataSize)
|
|||||||
_ptrOHelper->close();
|
_ptrOHelper->close();
|
||||||
}
|
}
|
||||||
_ptrOBuf = 0;
|
_ptrOBuf = 0;
|
||||||
poco_assert (*_pOstr);
|
if (!*_pOstr) throw Poco::IOException("Bad output stream");
|
||||||
|
|
||||||
// write an extra datablock if required
|
// write an extra datablock if required
|
||||||
// or fix the crc entries
|
// or fix the crc entries
|
||||||
poco_check_ptr(_pHeader);
|
poco_check_ptr(_pHeader);
|
||||||
@ -248,13 +249,14 @@ void ZipStreamBuf::close(Poco::UInt64& extraDataSize)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
_pOstr->seekp(_pHeader->getStartPos(), std::ios_base::beg);
|
_pOstr->seekp(_pHeader->getStartPos(), std::ios_base::beg);
|
||||||
poco_assert (*_pOstr);
|
if (!*_pOstr) throw Poco::IOException("Bad output stream");
|
||||||
|
|
||||||
if (_pHeader->hasExtraField()) // Update sizes in header extension.
|
if (_pHeader->hasExtraField()) // Update sizes in header extension.
|
||||||
_pHeader->setZip64Data();
|
_pHeader->setZip64Data();
|
||||||
std::string header = _pHeader->createHeader();
|
std::string header = _pHeader->createHeader();
|
||||||
_pOstr->write(header.c_str(), static_cast<std::streamsize>(header.size()));
|
_pOstr->write(header.c_str(), static_cast<std::streamsize>(header.size()));
|
||||||
_pOstr->seekp(0, std::ios_base::end);
|
_pOstr->seekp(0, std::ios_base::end);
|
||||||
poco_assert (*_pOstr);
|
if (!*_pOstr) throw Poco::IOException("Bad output stream");
|
||||||
}
|
}
|
||||||
_pHeader = 0;
|
_pHeader = 0;
|
||||||
}
|
}
|
||||||
|
@ -117,31 +117,23 @@ void ZipUtil::sync(std::istream& in)
|
|||||||
{
|
{
|
||||||
if (std::memcmp(ZipLocalFileHeader::HEADER+PREFIX, &temp[tempPos - PREFIX], PREFIX) == 0)
|
if (std::memcmp(ZipLocalFileHeader::HEADER+PREFIX, &temp[tempPos - PREFIX], PREFIX) == 0)
|
||||||
{
|
{
|
||||||
in.putback(ZipLocalFileHeader::HEADER[3]);
|
in.seekg(-4, std::ios::cur);
|
||||||
in.putback(ZipLocalFileHeader::HEADER[2]);
|
if (!in.good()) throw Poco::IOException("Failed to seek on input stream");
|
||||||
in.putback(ZipLocalFileHeader::HEADER[1]);
|
|
||||||
in.putback(ZipLocalFileHeader::HEADER[0]);
|
|
||||||
}
|
}
|
||||||
else if (std::memcmp(ZipArchiveInfo::HEADER+PREFIX, &temp[tempPos - PREFIX], PREFIX) == 0)
|
else if (std::memcmp(ZipArchiveInfo::HEADER+PREFIX, &temp[tempPos - PREFIX], PREFIX) == 0)
|
||||||
{
|
{
|
||||||
in.putback(ZipArchiveInfo::HEADER[3]);
|
in.seekg(-4, std::ios::cur);
|
||||||
in.putback(ZipArchiveInfo::HEADER[2]);
|
if (!in.good()) throw Poco::IOException("Failed to seek on input stream");
|
||||||
in.putback(ZipArchiveInfo::HEADER[1]);
|
|
||||||
in.putback(ZipArchiveInfo::HEADER[0]);
|
|
||||||
}
|
}
|
||||||
else if (std::memcmp(ZipFileInfo::HEADER+PREFIX, &temp[tempPos - PREFIX], PREFIX) == 0)
|
else if (std::memcmp(ZipFileInfo::HEADER+PREFIX, &temp[tempPos - PREFIX], PREFIX) == 0)
|
||||||
{
|
{
|
||||||
in.putback(ZipFileInfo::HEADER[3]);
|
in.seekg(-4, std::ios::cur);
|
||||||
in.putback(ZipFileInfo::HEADER[2]);
|
if (!in.good()) throw Poco::IOException("Failed to seek on input stream");
|
||||||
in.putback(ZipFileInfo::HEADER[1]);
|
|
||||||
in.putback(ZipFileInfo::HEADER[0]);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
in.putback(ZipDataInfo::HEADER[3]);
|
in.seekg(-4, std::ios::cur);
|
||||||
in.putback(ZipDataInfo::HEADER[2]);
|
if (!in.good()) throw Poco::IOException("Failed to seek on input stream");
|
||||||
in.putback(ZipDataInfo::HEADER[1]);
|
|
||||||
in.putback(ZipDataInfo::HEADER[0]);
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -149,6 +141,7 @@ void ZipUtil::sync(std::istream& in)
|
|||||||
{
|
{
|
||||||
// we have read 2 bytes, should only be one: putback the last char
|
// we have read 2 bytes, should only be one: putback the last char
|
||||||
in.putback(temp[tempPos - 1]);
|
in.putback(temp[tempPos - 1]);
|
||||||
|
if (!in.good()) throw Poco::IOException("Failed to putback on input stream");
|
||||||
--tempPos;
|
--tempPos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -384,7 +384,7 @@ build_script:
|
|||||||
}
|
}
|
||||||
if ($env:builder -eq "msbuild")
|
if ($env:builder -eq "msbuild")
|
||||||
{
|
{
|
||||||
$logger='"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"';
|
$logger='"C:\Progra~1\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"';
|
||||||
$verbosity='minimal';
|
$verbosity='minimal';
|
||||||
|
|
||||||
$process = Start-Process -PassThru -nnw -Wait -FilePath "$env:poco_base\buildwin.cmd" -RSO cout -RSE cerr `
|
$process = Start-Process -PassThru -nnw -Wait -FilePath "$env:poco_base\buildwin.cmd" -RSO cout -RSE cerr `
|
||||||
|
@ -69,7 +69,7 @@ RELEASEOPT_LINK = -O2
|
|||||||
#
|
#
|
||||||
# System Specific Flags
|
# System Specific Flags
|
||||||
#
|
#
|
||||||
SYSFLAGS = -D_XOPEN_SOURCE=500 -D_REENTRANT -D_THREAD_SAFE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DPOCO_HAVE_FD_EPOLL -DPOCO_HAVE_ADDRINFO -DPOCO_HAVE_LIBRESOLV
|
SYSFLAGS = -D_XOPEN_SOURCE=600 -D_REENTRANT -D_THREAD_SAFE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DPOCO_HAVE_FD_EPOLL -DPOCO_HAVE_ADDRINFO -DPOCO_HAVE_LIBRESOLV
|
||||||
|
|
||||||
#
|
#
|
||||||
# System Specific Libraries
|
# System Specific Libraries
|
||||||
|
Loading…
x
Reference in New Issue
Block a user