Refactor #includes (Part 5).

This commit is contained in:
Gunnar Beutner 2013-03-18 17:04:22 +01:00
parent 0744397427
commit 2a8bc3ca0f
12 changed files with 166 additions and 155 deletions

View File

@ -138,18 +138,18 @@ void CompatComponent::CommandPipeThread(const String& commandPath)
} else {
if (unlink(commandPath.CStr()) < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("unlink")
<< errinfo_errno(errno)
<< errinfo_file_name(commandPath));
<< boost::errinfo_api_function("unlink")
<< boost::errinfo_errno(errno)
<< boost::errinfo_file_name(commandPath));
}
}
}
if (!fifo_ok && mkfifo(commandPath.CStr(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("mkfifo")
<< errinfo_errno(errno)
<< errinfo_file_name(commandPath));
<< boost::errinfo_api_function("mkfifo")
<< boost::errinfo_errno(errno)
<< boost::errinfo_file_name(commandPath));
}
for (;;) {
@ -161,9 +161,9 @@ void CompatComponent::CommandPipeThread(const String& commandPath)
if (fd < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("open")
<< errinfo_errno(errno)
<< errinfo_file_name(commandPath));
<< boost::errinfo_api_function("open")
<< boost::errinfo_errno(errno)
<< boost::errinfo_file_name(commandPath));
}
FILE *fp = fdopen(fd, "r");
@ -171,8 +171,8 @@ void CompatComponent::CommandPipeThread(const String& commandPath)
if (fp == NULL) {
(void) close(fd);
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("fdopen")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("fdopen")
<< boost::errinfo_errno(errno));
}
char line[2048];
@ -665,16 +665,16 @@ void CompatComponent::StatusTimerHandler(void)
statusfp.close();
if (rename(statuspathtmp.CStr(), statuspath.CStr()) < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("rename")
<< errinfo_errno(errno)
<< errinfo_file_name(statuspathtmp));
<< boost::errinfo_api_function("rename")
<< boost::errinfo_errno(errno)
<< boost::errinfo_file_name(statuspathtmp));
}
objectfp.close();
if (rename(objectspathtmp.CStr(), objectspath.CStr()) < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("rename")
<< errinfo_errno(errno)
<< errinfo_file_name(objectspathtmp));
<< boost::errinfo_api_function("rename")
<< boost::errinfo_errno(errno)
<< boost::errinfo_file_name(objectspathtmp));
}
}

View File

@ -32,6 +32,9 @@
#include <boost/foreach.hpp>
#include <boost/exception/diagnostic_information.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/exception/errinfo_api_function.hpp>
#include <boost/exception/errinfo_errno.hpp>
#include <boost/exception/errinfo_file_name.hpp>
#include <iostream>
using namespace icinga;
@ -62,8 +65,8 @@ Application::Application(const Dictionary::Ptr& serializedUpdate)
WSADATA wsaData;
if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
BOOST_THROW_EXCEPTION(win32_error()
<< errinfo_api_function("WSAStartup")
<< errinfo_win32_error(WSAGetLastError()));
<< boost::errinfo_api_function("WSAStartup")
<< boost::errinfo_win32_error(WSAGetLastError()));
}
#endif /* _WIN32 */
@ -208,8 +211,8 @@ String Application::GetExePath(const String& argv0)
char buffer[MAXPATHLEN];
if (getcwd(buffer, sizeof(buffer)) == NULL) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("getcwd")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("getcwd")
<< boost::errinfo_errno(errno));
}
String workingDirectory = buffer;
@ -253,9 +256,9 @@ String Application::GetExePath(const String& argv0)
if (realpath(executablePath.CStr(), buffer) == NULL) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("realpath")
<< errinfo_errno(errno)
<< errinfo_file_name(executablePath));
<< boost::errinfo_api_function("realpath")
<< boost::errinfo_errno(errno)
<< boost::errinfo_file_name(executablePath));
}
return buffer;
@ -264,8 +267,8 @@ String Application::GetExePath(const String& argv0)
if (!GetModuleFileName(NULL, FullExePath, sizeof(FullExePath)))
BOOST_THROW_EXCEPTION(win32_error()
<< errinfo_api_function("GetModuleFileName")
<< errinfo_win32_error(GetLastError()));
<< boost::errinfo_api_function("GetModuleFileName")
<< boost::errinfo_win32_error(GetLastError()));
return FullExePath;
#endif /* _WIN32 */

View File

@ -31,6 +31,9 @@
#include <fstream>
#include <boost/make_shared.hpp>
#include <boost/foreach.hpp>
#include <boost/exception/errinfo_api_function.hpp>
#include <boost/exception/errinfo_errno.hpp>
#include <boost/exception/errinfo_file_name.hpp>
using namespace icinga;
@ -519,9 +522,9 @@ void DynamicObject::DumpObjects(const String& filename)
if (rename(tempFilename.CStr(), filename.CStr()) < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("rename")
<< errinfo_errno(errno)
<< errinfo_file_name(tempFilename));
<< boost::errinfo_api_function("rename")
<< boost::errinfo_errno(errno)
<< boost::errinfo_file_name(tempFilename));
}
}

View File

@ -24,6 +24,9 @@
#include "base/stacktrace.h"
#include <sstream>
#include <boost/thread/tss.hpp>
#include <boost/exception/errinfo_api_function.hpp>
#include <boost/exception/errinfo_errno.hpp>
#include <boost/exception/errinfo_file_name.hpp>
#ifdef _WIN32
# include <boost/algorithm/string/trim.hpp>
@ -54,6 +57,7 @@ class I2_BASE_API posix_error : virtual public std::exception, virtual public bo
#ifdef _WIN32
class I2_BASE_API win32_error : virtual public std::exception, virtual public boost::exception { };
struct errinfo_win32_error_;
typedef boost::error_info<struct errinfo_win32_error_, int> errinfo_win32_error;
inline std::string to_string(const errinfo_win32_error& e)
@ -83,6 +87,7 @@ inline std::string to_string(const errinfo_win32_error& e)
class I2_BASE_API openssl_error : virtual public std::exception, virtual public boost::exception { };
struct errinfo_openssl_error_;
typedef boost::error_info<struct errinfo_openssl_error_, int> errinfo_openssl_error;
inline std::string to_string(const errinfo_openssl_error& e)

View File

@ -82,18 +82,11 @@
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/weak_ptr.hpp>
#include <boost/exception/error_info.hpp>
#include <boost/exception/errinfo_api_function.hpp>
#include <boost/exception/errinfo_errno.hpp>
#include <boost/exception/errinfo_file_name.hpp>
using boost::shared_ptr;
using boost::weak_ptr;
using boost::dynamic_pointer_cast;
using boost::static_pointer_cast;
using boost::errinfo_api_function;
using boost::errinfo_errno;
using boost::errinfo_file_name;
#if defined(__APPLE__) && defined(__MACH__)
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"

View File

@ -52,14 +52,14 @@ void Process::Initialize(void)
#if HAVE_PIPE2
if (pipe2(fds, O_CLOEXEC) < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("pipe2")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("pipe2")
<< boost::errinfo_errno(errno));
}
#else /* HAVE_PIPE2 */
if (pipe(fds) < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("pipe")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("pipe")
<< boost::errinfo_errno(errno));
}
/* Don't bother setting fds[0] to clo-exec as we'll only
@ -80,8 +80,8 @@ void Process::Initialize(void)
if (childTaskFd < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("dup")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("dup")
<< boost::errinfo_errno(errno));
}
Utility::SetNonBlocking(childTaskFd);
@ -111,8 +111,8 @@ void Process::WorkerThreadProc(int taskFd)
if (pfds == NULL) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("realloc")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("realloc")
<< boost::errinfo_errno(errno));
}
int idx = 0;
@ -134,8 +134,8 @@ void Process::WorkerThreadProc(int taskFd)
if (rc < 0 && errno != EINTR) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("poll")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("poll")
<< boost::errinfo_errno(errno));
}
if (rc == 0)
@ -165,8 +165,8 @@ void Process::WorkerThreadProc(int taskFd)
break; /* Someone else was faster and took our task. */
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("read")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("read")
<< boost::errinfo_errno(errno));
}
while (have > 0) {
@ -232,8 +232,8 @@ void Process::QueueTask(void)
*/
if (write(m_TaskFd, "T", 1) < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("write")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("write")
<< boost::errinfo_errno(errno));
}
}
}
@ -249,14 +249,14 @@ void Process::InitTask(void)
#if HAVE_PIPE2
if (pipe2(fds, O_NONBLOCK | O_CLOEXEC) < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("pipe2")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("pipe2")
<< boost::errinfo_errno(errno));
}
#else /* HAVE_PIPE2 */
if (pipe(fds) < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("pipe")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("pipe")
<< boost::errinfo_errno(errno));
}
Utility::SetNonBlocking(fds[0]);
@ -313,8 +313,8 @@ void Process::InitTask(void)
if (m_Pid < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("fork")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("fork")
<< boost::errinfo_errno(errno));
}
if (m_Pid == 0) {
@ -378,8 +378,8 @@ bool Process::RunTask(void)
if (waitpid(m_Pid, &status, 0) != m_Pid) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("waitpid")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("waitpid")
<< boost::errinfo_errno(errno));
}
if (WIFEXITED(status)) {

View File

@ -21,6 +21,7 @@
#define STRING_H
#include "base/i2-base.h"
#include <boost/range/iterator.hpp>
#include <ostream>
#include <istream>

View File

@ -23,6 +23,9 @@
#include <sstream>
#include <boost/bind.hpp>
#include <boost/make_shared.hpp>
#include <boost/exception/errinfo_api_function.hpp>
#include <boost/exception/errinfo_errno.hpp>
#include <boost/exception/errinfo_file_name.hpp>
using namespace icinga;
@ -151,12 +154,12 @@ void Socket::HandleException(void)
#ifndef _WIN32
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("select")
<< errinfo_errno(GetError()));
<< boost::errinfo_api_function("select")
<< boost::errinfo_errno(GetError()));
#else /* _WIN32 */
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("select")
<< errinfo_win32_error(GetError()));
<< boost::errinfo_api_function("select")
<< boost::errinfo_win32_error(GetError()));
#endif /* _WIN32 */
}
@ -174,12 +177,12 @@ String Socket::GetAddressFromSockaddr(sockaddr *address, socklen_t len)
sizeof(service), NI_NUMERICHOST | NI_NUMERICSERV) < 0) {
#ifndef _WIN32
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("getnameinfo")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("getnameinfo")
<< boost::errinfo_errno(errno));
#else /* _WIN32 */
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("getnameinfo")
<< errinfo_win32_error(WSAGetLastError()));
<< boost::errinfo_api_function("getnameinfo")
<< boost::errinfo_win32_error(WSAGetLastError()));
#endif /* _WIN32 */
}
@ -203,12 +206,12 @@ String Socket::GetClientAddress(void)
if (getsockname(GetFD(), (sockaddr *)&sin, &len) < 0) {
#ifndef _WIN32
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("getsockname")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("getsockname")
<< boost::errinfo_errno(errno));
#else /* _WIN32 */
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("getsockname")
<< errinfo_win32_error(WSAGetLastError()));
<< boost::errinfo_api_function("getsockname")
<< boost::errinfo_win32_error(WSAGetLastError()));
#endif /* _WIN32 */
}
@ -230,12 +233,12 @@ String Socket::GetPeerAddress(void)
if (getpeername(GetFD(), (sockaddr *)&sin, &len) < 0) {
#ifndef _WIN32
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("getpeername")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("getpeername")
<< boost::errinfo_errno(errno));
#else /* _WIN32 */
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("getpeername")
<< errinfo_win32_error(WSAGetLastError()));
<< boost::errinfo_api_function("getpeername")
<< boost::errinfo_win32_error(WSAGetLastError()));
#endif /* _WIN32 */
}
@ -282,12 +285,12 @@ void Socket::ReadThreadProc(void)
if (rc < 0) {
#ifndef _WIN32
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("select")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("select")
<< boost::errinfo_errno(errno));
#else /* _WIN32 */
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("select")
<< errinfo_win32_error(WSAGetLastError()));
<< boost::errinfo_api_function("select")
<< boost::errinfo_win32_error(WSAGetLastError()));
#endif /* _WIN32 */
}
@ -349,12 +352,12 @@ void Socket::WriteThreadProc(void)
if (rc < 0) {
#ifndef _WIN32
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("select")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("select")
<< boost::errinfo_errno(errno));
#else /* _WIN32 */
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("select")
<< errinfo_win32_error(WSAGetLastError()));
<< boost::errinfo_api_function("select")
<< boost::errinfo_win32_error(WSAGetLastError()));
#endif /* _WIN32 */
}
@ -479,12 +482,12 @@ void Socket::Listen(void)
if (listen(GetFD(), SOMAXCONN) < 0) {
#ifndef _WIN32
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("listen")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("listen")
<< boost::errinfo_errno(errno));
#else /* _WIN32 */
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("listen")
<< errinfo_win32_error(WSAGetLastError()));
<< boost::errinfo_api_function("listen")
<< boost::errinfo_win32_error(WSAGetLastError()));
#endif /* _WIN32 */
}
@ -537,12 +540,12 @@ void Socket::HandleWritableClient(void)
if (rc <= 0) {
#ifndef _WIN32
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("send")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("send")
<< boost::errinfo_errno(errno));
#else /* _WIN32 */
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("send")
<< errinfo_win32_error(WSAGetLastError()));
<< boost::errinfo_api_function("send")
<< boost::errinfo_win32_error(WSAGetLastError()));
#endif /* _WIN32 */
}
@ -574,12 +577,12 @@ void Socket::HandleReadableClient(void)
if (rc < 0) {
#ifndef _WIN32
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("recv")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("recv")
<< boost::errinfo_errno(errno));
#else /* _WIN32 */
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("recv")
<< errinfo_win32_error(WSAGetLastError()));
<< boost::errinfo_api_function("recv")
<< boost::errinfo_win32_error(WSAGetLastError()));
#endif /* _WIN32 */
}
@ -618,12 +621,12 @@ void Socket::HandleReadableServer(void)
if (fd < 0) {
#ifndef _WIN32
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("accept")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("accept")
<< boost::errinfo_errno(errno));
#else /* _WIN32 */
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("accept")
<< errinfo_win32_error(WSAGetLastError()));
<< boost::errinfo_api_function("accept")
<< boost::errinfo_win32_error(WSAGetLastError()));
#endif /* _WIN32 */
}

View File

@ -18,6 +18,9 @@
******************************************************************************/
#include "base/tcpsocket.h"
#include <boost/exception/errinfo_api_function.hpp>
#include <boost/exception/errinfo_errno.hpp>
#include <boost/exception/errinfo_file_name.hpp>
using namespace icinga;
@ -55,12 +58,12 @@ void TcpSocket::Bind(String node, String service, int family)
service.CStr(), &hints, &result) < 0) {
#ifndef _WIN32
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("getaddrinfo")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("getaddrinfo")
<< boost::errinfo_errno(errno));
#else /* _WIN32 */
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("getaddrinfo")
<< errinfo_win32_error(WSAGetLastError()));
<< boost::errinfo_api_function("getaddrinfo")
<< boost::errinfo_win32_error(WSAGetLastError()));
#endif /* _WIN32 */
}
@ -126,12 +129,12 @@ void TcpSocket::Connect(const String& node, const String& service)
if (rc < 0) {
#ifndef _WIN32
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("getaddrinfo")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("getaddrinfo")
<< boost::errinfo_errno(errno));
#else /* _WIN32 */
BOOST_THROW_EXCEPTION(socket_error()
<< errinfo_api_function("getaddrinfo")
<< errinfo_win32_error(WSAGetLastError()));
<< boost::errinfo_api_function("getaddrinfo")
<< boost::errinfo_win32_error(WSAGetLastError()));
#endif /* _WIN32 */
}

View File

@ -54,7 +54,7 @@ void TlsStream::Start(void)
if (!m_SSL) {
BOOST_THROW_EXCEPTION(openssl_error()
<< errinfo_api_function("SSL_new")
<< boost::errinfo_api_function("SSL_new")
<< errinfo_openssl_error(ERR_get_error()));
}
@ -161,7 +161,7 @@ void TlsStream::HandleIO(void)
default:
I2Stream_check_exception(m_BIO);
BOOST_THROW_EXCEPTION(openssl_error()
<< errinfo_api_function("SSL_do_handshake")
<< boost::errinfo_api_function("SSL_do_handshake")
<< errinfo_openssl_error(ERR_get_error()));
}
}
@ -188,7 +188,7 @@ void TlsStream::HandleIO(void)
default:
I2Stream_check_exception(m_BIO);
BOOST_THROW_EXCEPTION(openssl_error()
<< errinfo_api_function("SSL_read")
<< boost::errinfo_api_function("SSL_read")
<< errinfo_openssl_error(ERR_get_error()));
}
}
@ -227,7 +227,7 @@ void TlsStream::HandleIO(void)
default:
I2Stream_check_exception(m_BIO);
BOOST_THROW_EXCEPTION(openssl_error()
<< errinfo_api_function("SSL_write")
<< boost::errinfo_api_function("SSL_write")
<< errinfo_openssl_error(ERR_get_error()));
}
}

View File

@ -29,8 +29,8 @@ UnixSocket::UnixSocket(void)
if (fd < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("socket")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("socket")
<< boost::errinfo_errno(errno));
}
SetFD(fd);
@ -48,8 +48,8 @@ void UnixSocket::Bind(const String& path)
if (bind(GetFD(), (sockaddr *)&sun, SUN_LEN(&sun)) < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("bind")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("bind")
<< boost::errinfo_errno(errno));
}
}
@ -63,8 +63,8 @@ void UnixSocket::Connect(const String& path)
if (connect(GetFD(), (sockaddr *)&sun, SUN_LEN(&sun)) < 0 && errno != EINPROGRESS) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("connect")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("connect")
<< boost::errinfo_errno(errno));
}
}
#endif /* _WIN32 */

View File

@ -103,23 +103,23 @@ shared_ptr<SSL_CTX> Utility::MakeSSLContext(const String& pubkey, const String&
if (!SSL_CTX_use_certificate_chain_file(sslContext.get(), pubkey.CStr())) {
BOOST_THROW_EXCEPTION(openssl_error()
<< errinfo_api_function("SSL_CTX_use_certificate_chain_file")
<< boost::errinfo_api_function("SSL_CTX_use_certificate_chain_file")
<< errinfo_openssl_error(ERR_get_error())
<< errinfo_file_name(pubkey));
<< boost::errinfo_file_name(pubkey));
}
if (!SSL_CTX_use_PrivateKey_file(sslContext.get(), privkey.CStr(), SSL_FILETYPE_PEM)) {
BOOST_THROW_EXCEPTION(openssl_error()
<< errinfo_api_function("SSL_CTX_use_PrivateKey_file")
<< boost::errinfo_api_function("SSL_CTX_use_PrivateKey_file")
<< errinfo_openssl_error(ERR_get_error())
<< errinfo_file_name(privkey));
<< boost::errinfo_file_name(privkey));
}
if (!SSL_CTX_load_verify_locations(sslContext.get(), cakey.CStr(), NULL)) {
BOOST_THROW_EXCEPTION(openssl_error()
<< errinfo_api_function("SSL_CTX_load_verify_locations")
<< boost::errinfo_api_function("SSL_CTX_load_verify_locations")
<< errinfo_openssl_error(ERR_get_error())
<< errinfo_file_name(cakey));
<< boost::errinfo_file_name(cakey));
}
STACK_OF(X509_NAME) *cert_names;
@ -127,9 +127,9 @@ shared_ptr<SSL_CTX> Utility::MakeSSLContext(const String& pubkey, const String&
cert_names = SSL_load_client_CA_file(cakey.CStr());
if (cert_names == NULL) {
BOOST_THROW_EXCEPTION(openssl_error()
<< errinfo_api_function("SSL_load_client_CA_file")
<< boost::errinfo_api_function("SSL_load_client_CA_file")
<< errinfo_openssl_error(ERR_get_error())
<< errinfo_file_name(cakey));
<< boost::errinfo_file_name(cakey));
}
SSL_CTX_set_client_CA_list(sslContext.get(), cert_names);
@ -152,7 +152,7 @@ String Utility::GetCertificateCN(const shared_ptr<X509>& certificate)
if (rc == -1) {
BOOST_THROW_EXCEPTION(openssl_error()
<< errinfo_api_function("X509_NAME_get_text_by_NID")
<< boost::errinfo_api_function("X509_NAME_get_text_by_NID")
<< errinfo_openssl_error(ERR_get_error()));
}
@ -172,21 +172,21 @@ shared_ptr<X509> Utility::GetX509Certificate(const String& pemfile)
if (fpcert == NULL) {
BOOST_THROW_EXCEPTION(openssl_error()
<< errinfo_api_function("BIO_new")
<< boost::errinfo_api_function("BIO_new")
<< errinfo_openssl_error(ERR_get_error()));
}
if (BIO_read_filename(fpcert, pemfile.CStr()) < 0) {
BOOST_THROW_EXCEPTION(openssl_error()
<< errinfo_api_function("BIO_read_filename")
<< boost::errinfo_api_function("BIO_read_filename")
<< errinfo_openssl_error(ERR_get_error())
<< errinfo_file_name(pemfile));
<< boost::errinfo_file_name(pemfile));
}
cert = PEM_read_bio_X509_AUX(fpcert, NULL, NULL, NULL);
if (cert == NULL) {
BOOST_THROW_EXCEPTION(openssl_error()
<< errinfo_api_function("PEM_read_bio_X509_AUX")
<< boost::errinfo_api_function("PEM_read_bio_X509_AUX")
<< errinfo_openssl_error(ERR_get_error()));
}
@ -243,8 +243,8 @@ String Utility::DirName(const String& path)
free(dir);
BOOST_THROW_EXCEPTION(win32_error()
<< errinfo_api_function("PathRemoveFileSpec")
<< errinfo_win32_error(GetLastError()));
<< boost::errinfo_api_function("PathRemoveFileSpec")
<< errinfo_win32_error(GetLastError()));
}
result = dir;
@ -322,8 +322,8 @@ double Utility::GetTime(void)
if (gettimeofday(&tv, NULL) < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("gettimeofday")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("gettimeofday")
<< boost::errinfo_errno(errno));
}
return tv.tv_sec + tv.tv_usec / 1000000.0;
@ -384,9 +384,9 @@ Utility::LoadExtensionLibrary(const String& library)
if (hModule == NULL) {
BOOST_THROW_EXCEPTION(win32_error()
<< errinfo_api_function("LoadLibrary")
<< errinfo_win32_error(GetLastError())
<< errinfo_file_name(path));
<< boost::errinfo_api_function("LoadLibrary")
<< errinfo_win32_error(GetLastError())
<< boost::errinfo_file_name(path));
}
#else /* _WIN32 */
lt_dlhandle hModule = lt_dlopen(path.CStr());
@ -430,9 +430,9 @@ bool Utility::Glob(const String& pathSpec, const boost::function<void (const Str
return false;
BOOST_THROW_EXCEPTION(win32_error()
<< errinfo_api_function("FindFirstFile")
<< errinfo_win32_error(errorCode)
<< errinfo_file_name(pathSpec));
<< boost::errinfo_api_function("FindFirstFile")
<< boost::errinfo_win32_error(errorCode)
<< boost::errinfo_file_name(pathSpec));
}
do {
@ -441,7 +441,7 @@ bool Utility::Glob(const String& pathSpec, const boost::function<void (const Str
if (!FindClose(handle)) {
BOOST_THROW_EXCEPTION(win32_error()
<< errinfo_api_function("FindClose")
<< boost::errinfo_api_function("FindClose")
<< errinfo_win32_error(GetLastError()));
}
@ -456,9 +456,9 @@ bool Utility::Glob(const String& pathSpec, const boost::function<void (const Str
return false;
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("glob")
<< errinfo_errno(errno)
<< errinfo_file_name(pathSpec));
<< boost::errinfo_api_function("glob")
<< boost::errinfo_errno(errno)
<< boost::errinfo_file_name(pathSpec));
}
if (gr.gl_pathc == 0) {
@ -485,14 +485,14 @@ void Utility::SetNonBlocking(int fd)
if (flags < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("fcntl")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("fcntl")
<< boost::errinfo_errno(errno));
}
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("fcntl")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("fcntl")
<< boost::errinfo_errno(errno));
}
}
@ -502,14 +502,14 @@ void Utility::SetCloExec(int fd)
if (flags < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("fcntl")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("fcntl")
<< boost::errinfo_errno(errno));
}
if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("fcntl")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("fcntl")
<< boost::errinfo_errno(errno));
}
}
#endif /* _WIN32 */
@ -540,16 +540,16 @@ String Utility::FormatDateTime(const char *format, double ts)
if (temp == NULL) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("localtime")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("localtime")
<< boost::errinfo_errno(errno));
}
tmthen = *temp;
#else /* _MSC_VER */
if (localtime_r(&tempts, &tmthen) == NULL) {
BOOST_THROW_EXCEPTION(posix_error()
<< errinfo_api_function("localtime_r")
<< errinfo_errno(errno));
<< boost::errinfo_api_function("localtime_r")
<< boost::errinfo_errno(errno));
}
#endif /* _MSC_VER */