aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2016-03-13 16:22:21 +0000
committerVincent Richard <[email protected]>2016-03-13 16:22:21 +0000
commit68ad348b4466819600f3139be404b6296f3cecf3 (patch)
tree34a8f1bf259ef62c9498fa2e6dc013153e9993a0
parentUpdated doc on building with CMake. (diff)
downloadvmime-68ad348b4466819600f3139be404b6296f3cecf3.tar.gz
vmime-68ad348b4466819600f3139be404b6296f3cecf3.zip
Issue #126: don't use deprecated 'auto_ptr' on C++11.
-rw-r--r--src/vmime/net/imap/IMAPConnection.cpp12
-rw-r--r--src/vmime/net/imap/IMAPFolder.cpp36
-rw-r--r--src/vmime/net/imap/IMAPMessage.cpp2
-rw-r--r--src/vmime/net/imap/IMAPParser.hpp68
-rw-r--r--src/vmime/net/imap/IMAPStore.cpp2
-rw-r--r--src/vmime/net/tls/openssl/TLSSocket_OpenSSL.cpp2
-rw-r--r--src/vmime/net/tls/openssl/TLSSocket_OpenSSL.hpp2
-rw-r--r--src/vmime/platforms/posix/posixChildProcess.cpp2
8 files changed, 71 insertions, 55 deletions
diff --git a/src/vmime/net/imap/IMAPConnection.cpp b/src/vmime/net/imap/IMAPConnection.cpp
index 2de93314..4daa2774 100644
--- a/src/vmime/net/imap/IMAPConnection.cpp
+++ b/src/vmime/net/imap/IMAPConnection.cpp
@@ -157,7 +157,7 @@ void IMAPConnection::connect()
// eg: C: <connection to server>
// --- S: * OK mydomain.org IMAP4rev1 v12.256 server ready
- std::auto_ptr <IMAPParser::greeting> greet(m_parser->readGreeting());
+ scoped_ptr <IMAPParser::greeting> greet(m_parser->readGreeting());
bool needAuth = false;
if (greet->resp_cond_bye())
@@ -274,7 +274,7 @@ void IMAPConnection::authenticate()
shared_ptr <IMAPConnection> conn = dynamicCast <IMAPConnection>(shared_from_this());
IMAPCommand::LOGIN(username, password)->send(conn);
- std::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_parser->readResponse());
if (resp->isBad())
{
@@ -393,7 +393,7 @@ void IMAPConnection::authenticateSASL()
for (bool cont = true ; cont ; )
{
- std::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_parser->readResponse());
if (resp->response_done() &&
resp->response_done()->response_tagged() &&
@@ -507,7 +507,7 @@ void IMAPConnection::startTLS()
{
IMAPCommand::STARTTLS()->send(dynamicCast <IMAPConnection>(shared_from_this()));
- std::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_parser->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -606,7 +606,7 @@ void IMAPConnection::fetchCapabilities()
{
IMAPCommand::CAPABILITY()->send(dynamicCast <IMAPConnection>(shared_from_this()));
- std::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_parser->readResponse());
if (resp->response_done()->response_tagged()->
resp_cond_state()->status() == IMAPParser::resp_cond_state::OK)
@@ -716,7 +716,7 @@ void IMAPConnection::initHierarchySeparator()
{
IMAPCommand::LIST("", "")->send(dynamicCast <IMAPConnection>(shared_from_this()));
- std::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_parser->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
diff --git a/src/vmime/net/imap/IMAPFolder.cpp b/src/vmime/net/imap/IMAPFolder.cpp
index 3c55dbad..5f8c8b71 100644
--- a/src/vmime/net/imap/IMAPFolder.cpp
+++ b/src/vmime/net/imap/IMAPFolder.cpp
@@ -177,7 +177,7 @@ void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable)
)->send(connection);
// Read the response
- std::auto_ptr <IMAPParser::response> resp(connection->readResponse());
+ scoped_ptr <IMAPParser::response> resp(connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -381,7 +381,7 @@ void IMAPFolder::create(const folderAttributes& attribs)
IMAPCommand::CREATE(mailbox, createParams)->send(m_connection);
- std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -416,7 +416,7 @@ void IMAPFolder::destroy()
IMAPCommand::DELETE(mailbox)->send(m_connection);
- std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -471,7 +471,7 @@ int IMAPFolder::testExistAndGetType()
(m_connection->hierarchySeparator(), getFullPath()))->send(m_connection);
- std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -565,7 +565,7 @@ std::vector <shared_ptr <message> > IMAPFolder::getMessages(const messageSet& ms
IMAPCommand::FETCH(msgs, params)->send(m_connection);
// Get the response
- std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -692,7 +692,7 @@ std::vector <shared_ptr <folder> > IMAPFolder::getFolders(const bool recursive)
cmd->send(m_connection);
- std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -776,7 +776,7 @@ void IMAPFolder::fetchMessages(std::vector <shared_ptr <message> >& msg, const f
(m_connection, messageSet::byNumber(list), options)->send(m_connection);
// Get the response
- std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -872,7 +872,7 @@ std::vector <shared_ptr <message> > IMAPFolder::getAndFetchMessages
(m_connection, msgs, attribsWithUID)->send(m_connection);
// Get the response
- std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1008,7 +1008,7 @@ void IMAPFolder::deleteMessages(const messageSet& msgs)
)->send(m_connection);
// Get the response
- std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1031,7 +1031,7 @@ void IMAPFolder::setMessageFlags(const messageSet& msgs, const int flags, const
IMAPCommand::STORE(msgs, mode, flagList)->send(m_connection);
// Get the response
- std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1081,7 +1081,7 @@ messageSet IMAPFolder::addMessage
)->send(m_connection);
// Get the response
- std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
bool ok = false;
const std::vector <IMAPParser::continue_req_or_response_data*>& respList
@@ -1138,7 +1138,7 @@ messageSet IMAPFolder::addMessage
progress->stop(total);
// Get the response
- std::auto_ptr <IMAPParser::response> finalResp(m_connection->readResponse());
+ scoped_ptr <IMAPParser::response> finalResp(m_connection->readResponse());
if (finalResp->isBad() || finalResp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1174,7 +1174,7 @@ void IMAPFolder::expunge()
IMAPCommand::EXPUNGE()->send(m_connection);
// Get the response
- std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1207,7 +1207,7 @@ void IMAPFolder::rename(const folder::path& newPath)
)->send(m_connection);
// Get the response
- std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1268,7 +1268,7 @@ messageSet IMAPFolder::copyMessages(const folder::path& dest, const messageSet&
)->send(m_connection);
// Get the response
- std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1326,7 +1326,7 @@ shared_ptr <folderStatus> IMAPFolder::getStatus()
)->send(m_connection);
// Get the response
- std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1372,7 +1372,7 @@ void IMAPFolder::noop()
IMAPCommand::NOOP()->send(m_connection);
- std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1397,7 +1397,7 @@ std::vector <int> IMAPFolder::getMessageNumbersStartingOnUID(const message::uid&
IMAPCommand::SEARCH(searchKeys, /* charset */ NULL)->send(m_connection);
// Get the response
- std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() ||
resp->response_done()->response_tagged()->resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
diff --git a/src/vmime/net/imap/IMAPMessage.cpp b/src/vmime/net/imap/IMAPMessage.cpp
index c79c4ffa..c0141337 100644
--- a/src/vmime/net/imap/IMAPMessage.cpp
+++ b/src/vmime/net/imap/IMAPMessage.cpp
@@ -364,7 +364,7 @@ void IMAPMessage::extractImpl
)->send(constCast <IMAPFolder>(folder)->m_connection);
// Get the response
- std::auto_ptr <IMAPParser::response> resp
+ scoped_ptr <IMAPParser::response> resp
(constCast <IMAPFolder>(folder)->m_connection->readResponse(&literalHandler));
if (resp->isBad() || resp->response_done()->response_tagged()->
diff --git a/src/vmime/net/imap/IMAPParser.hpp b/src/vmime/net/imap/IMAPParser.hpp
index 44f9d23b..b1241224 100644
--- a/src/vmime/net/imap/IMAPParser.hpp
+++ b/src/vmime/net/imap/IMAPParser.hpp
@@ -113,7 +113,7 @@
VIMAP_PARSER_FAIL_UNLESS(variable = parser.get <type>(line, &pos)); \
}
-#define VIMAP_PARSER_GET_PTR(type, variable) /* auto_ptr/shared_ptr version */ \
+#define VIMAP_PARSER_GET_PTR(type, variable) /* scoped_ptr/shared_ptr version */ \
{ \
variable.reset(parser.get <type>(line, &pos)); \
VIMAP_PARSER_FAIL_UNLESS(variable.get()); \
@@ -125,9 +125,36 @@
#define VIMAP_PARSER_TRY_GET(type, variable) /* raw pointer version */ \
(variable = parser.get <type>(line, &pos))
-#define VIMAP_PARSER_TRY_GET_PTR(type, variable) /* auto_ptr/shared_ptr version */ \
+#define VIMAP_PARSER_TRY_GET_PTR(type, variable) /* scoped_ptr/shared_ptr version */ \
(variable.reset(parser.get <type>(line, &pos)), variable.get())
+/** Get an optional token and advance. If found, token will be pushed back
+ * to a vector. If the token is not matched, stopInstr will be executed.
+ *
+ * @param type token class
+ * @param variable variable of type std::vector<> to which the retrieved
+ * token will be pushed
+ * @param stopInstr instruction to execute if token is not found
+ */
+#define VIMAP_PARSER_TRY_GET_PUSHBACK_OR_ELSE(type, variable, stopInstr) \
+ { \
+ type* v = NULL; \
+ try \
+ { \
+ v = parser.get <type>(line, &pos); \
+ if (!v) \
+ { \
+ stopInstr; \
+ } \
+ variable.push_back(v); \
+ } \
+ catch (...) \
+ { \
+ delete v; \
+ throw; \
+ } \
+ }
+
/** Get a token and advance. Token will be pushed back to a vector.
* If the token is not matched, parsing will fail.
*
@@ -136,11 +163,8 @@
* token will be pushed
*/
#define VIMAP_PARSER_GET_PUSHBACK(type, variable) \
- { \
- std::auto_ptr <type> v(parser.get <type>(line, &pos)); \
- VIMAP_PARSER_FAIL_UNLESS(v.get()); \
- variable.push_back(v.release()); \
- }
+ VIMAP_PARSER_TRY_GET_PUSHBACK_OR_ELSE(type, variable, VIMAP_PARSER_FAIL())
+
/** Check for a token which takes an argument and advance.
* If the token is not matched, parsing will fail.
@@ -1452,7 +1476,7 @@ public:
m_charset = theCharset->value();
// Decode text
- std::auto_ptr <utility::encoder::encoder> theEncoder;
+ scoped_ptr <utility::encoder::encoder> theEncoder;
if (theEncoding->value()[0] == 'q' || theEncoding->value()[0] == 'Q')
{
@@ -2364,10 +2388,9 @@ public:
{
size_t pos = *currentPos;
- std::auto_ptr <IMAPParser::atom> at;
- VIMAP_PARSER_GET_PTR(IMAPParser::atom, at);
+ VIMAP_PARSER_GET(IMAPParser::atom, m_atom);
- string value = at->value();
+ string value = m_atom->value();
const char* str = value.c_str();
if ((str[0] == 'a' || str[0] == 'A') &&
@@ -2378,10 +2401,9 @@ public:
{
size_t pos = 5;
m_auth_type = parser.get <IMAPParser::auth_type>(value, &pos);
- }
- else
- {
- m_atom = at.release();
+
+ delete m_atom;
+ m_atom = NULL;
}
*currentPos = pos;
@@ -4064,13 +4086,7 @@ public:
while (true)
{
- std::auto_ptr <xbody> b;
- VIMAP_PARSER_TRY_GET_PTR(xbody, b);
-
- if (!b.get())
- break;
-
- m_list.push_back(b.release());
+ VIMAP_PARSER_TRY_GET_PUSHBACK_OR_ELSE(xbody, m_list, break);
}
VIMAP_PARSER_CHECK(SPACE);
@@ -4432,7 +4448,7 @@ public:
{
size_t pos = *currentPos;
- std::auto_ptr <nz_number> num;
+ scoped_ptr <nz_number> num;
VIMAP_PARSER_GET_PTR(nz_number, num);
m_number = static_cast <unsigned int>(num->value());
@@ -4731,7 +4747,7 @@ public:
VIMAP_PARSER_TRY_CHECK(SPACE);
}
- std::auto_ptr <text_mime2> text1;
+ scoped_ptr <text_mime2> text1;
VIMAP_PARSER_TRY_GET_PTR(text_mime2, text1);
if (text1.get())
@@ -4740,7 +4756,7 @@ public:
}
else
{
- std::auto_ptr <IMAPParser::text> text2;
+ scoped_ptr <IMAPParser::text> text2;
VIMAP_PARSER_TRY_GET_PTR(IMAPParser::text, text2);
if (text2.get())
@@ -5729,7 +5745,7 @@ public:
const size_t oldPos = *currentPos;
TYPE term(arg);
-
+
if (!term.parse(*this, line, currentPos))
{
*currentPos = oldPos;
diff --git a/src/vmime/net/imap/IMAPStore.cpp b/src/vmime/net/imap/IMAPStore.cpp
index 28ba34e8..cc7c7a3f 100644
--- a/src/vmime/net/imap/IMAPStore.cpp
+++ b/src/vmime/net/imap/IMAPStore.cpp
@@ -187,7 +187,7 @@ void IMAPStore::noop()
IMAPCommand::NOOP()->send(m_connection);
- std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
diff --git a/src/vmime/net/tls/openssl/TLSSocket_OpenSSL.cpp b/src/vmime/net/tls/openssl/TLSSocket_OpenSSL.cpp
index 4f61e355..5faafdbe 100644
--- a/src/vmime/net/tls/openssl/TLSSocket_OpenSSL.cpp
+++ b/src/vmime/net/tls/openssl/TLSSocket_OpenSSL.cpp
@@ -77,7 +77,7 @@ shared_ptr <TLSSocket> TLSSocket::wrap(shared_ptr <TLSSession> session, shared_p
TLSSocket_OpenSSL::TLSSocket_OpenSSL(shared_ptr <TLSSession_OpenSSL> session, shared_ptr <socket> sok)
- : m_session(session), m_wrapped(sok), m_connected(false), m_ssl(0), m_status(0), m_ex(NULL)
+ : m_session(session), m_wrapped(sok), m_connected(false), m_ssl(0), m_status(0), m_ex()
{
}
diff --git a/src/vmime/net/tls/openssl/TLSSocket_OpenSSL.hpp b/src/vmime/net/tls/openssl/TLSSocket_OpenSSL.hpp
index 913a02fe..b4b90098 100644
--- a/src/vmime/net/tls/openssl/TLSSocket_OpenSSL.hpp
+++ b/src/vmime/net/tls/openssl/TLSSocket_OpenSSL.hpp
@@ -121,7 +121,7 @@ private:
unsigned long m_status;
// Last exception thrown from C BIO functions
- std::auto_ptr <exception> m_ex;
+ scoped_ptr <exception> m_ex;
};
diff --git a/src/vmime/platforms/posix/posixChildProcess.cpp b/src/vmime/platforms/posix/posixChildProcess.cpp
index 54d4cd75..275cacfd 100644
--- a/src/vmime/platforms/posix/posixChildProcess.cpp
+++ b/src/vmime/platforms/posix/posixChildProcess.cpp
@@ -377,7 +377,7 @@ void posixChildProcess::waitForFinish()
{
if (WEXITSTATUS(wstat) == 255)
{
- std::auto_ptr <posixFileSystemFactory> pfsf(new posixFileSystemFactory());
+ scoped_ptr <posixFileSystemFactory> pfsf(new posixFileSystemFactory());
throw exceptions::system_error("Could not execute '"
+ pfsf->pathToString(m_processPath) + "'");