aboutsummaryrefslogtreecommitdiffstats
path: root/websocketpp/common
diff options
context:
space:
mode:
Diffstat (limited to 'websocketpp/common')
-rw-r--r--websocketpp/common/asio.hpp131
-rw-r--r--websocketpp/common/asio_ssl.hpp39
-rw-r--r--websocketpp/common/chrono.hpp68
-rw-r--r--websocketpp/common/connection_hdl.hpp52
-rw-r--r--websocketpp/common/cpp11.hpp162
-rw-r--r--websocketpp/common/functional.hpp105
-rw-r--r--websocketpp/common/md5.hpp448
-rw-r--r--websocketpp/common/memory.hpp89
-rw-r--r--websocketpp/common/network.hpp106
-rw-r--r--websocketpp/common/platforms.hpp46
-rw-r--r--websocketpp/common/random.hpp82
-rw-r--r--websocketpp/common/regex.hpp59
-rw-r--r--websocketpp/common/stdint.hpp73
-rw-r--r--websocketpp/common/system_error.hpp84
-rw-r--r--websocketpp/common/thread.hpp84
-rw-r--r--websocketpp/common/time.hpp56
-rw-r--r--websocketpp/common/type_traits.hpp65
17 files changed, 1749 insertions, 0 deletions
diff --git a/websocketpp/common/asio.hpp b/websocketpp/common/asio.hpp
new file mode 100644
index 00000000..ca483593
--- /dev/null
+++ b/websocketpp/common/asio.hpp
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2015, Peter Thorson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the WebSocket++ Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef WEBSOCKETPP_COMMON_ASIO_HPP
+#define WEBSOCKETPP_COMMON_ASIO_HPP
+
+// This file goes to some length to preserve compatibility with versions of
+// boost older than 1.49 (where the first modern steady_timer timer based on
+// boost/std chrono was introduced.
+//
+// For the versions older than 1.49, the deadline_timer is used instead. this
+// brings in dependencies on boost date_time and it has a different interface
+// that is normalized by the `lib::asio::is_neg` and `lib::asio::milliseconds`
+// wrappers provided by this file.
+//
+// The primary reason for this continued support is that boost 1.48 is the
+// default and not easily changeable version of boost supplied by the package
+// manager of popular Linux distributions like Ubuntu 12.04 LTS. Once the need
+// for this has passed this should be cleaned up and simplified.
+
+#ifdef ASIO_STANDALONE
+ #include <asio/version.hpp>
+
+ #if (ASIO_VERSION/100000) == 1 && ((ASIO_VERSION/100)%1000) < 8
+ static_assert(false, "The minimum version of standalone Asio is 1.8.0");
+ #endif
+
+ #include <asio.hpp>
+ #include <asio/steady_timer.hpp>
+ #include <websocketpp/common/chrono.hpp>
+#else
+ #include <boost/version.hpp>
+
+ // See note above about boost <1.49 compatibility. If we are running on
+ // boost > 1.48 pull in the steady timer and chrono library
+ #if (BOOST_VERSION/100000) == 1 && ((BOOST_VERSION/100)%1000) > 48
+ #include <boost/asio/steady_timer.hpp>
+ #include <websocketpp/common/chrono.hpp>
+ #endif
+
+ #include <boost/asio.hpp>
+ #include <boost/system/error_code.hpp>
+#endif
+
+namespace websocketpp {
+namespace lib {
+
+#ifdef ASIO_STANDALONE
+ namespace asio {
+ using namespace ::asio;
+ // Here we assume that we will be using std::error_code with standalone
+ // Asio. This is probably a good assumption, but it is possible in rare
+ // cases that local Asio versions would be used.
+ using std::errc;
+
+ // See note above about boost <1.49 compatibility. Because we require
+ // a standalone Asio version of 1.8+ we are guaranteed to have
+ // steady_timer available. By convention we require the chrono library
+ // (either boost or std) for use with standalone Asio.
+ template <typename T>
+ bool is_neg(T duration) {
+ return duration.count() < 0;
+ }
+ inline lib::chrono::milliseconds milliseconds(long duration) {
+ return lib::chrono::milliseconds(duration);
+ }
+ } // namespace asio
+
+#else
+ namespace asio {
+ using namespace boost::asio;
+
+ // See note above about boost <1.49 compatibility
+ #if (BOOST_VERSION/100000) == 1 && ((BOOST_VERSION/100)%1000) > 48
+ // Using boost::asio >=1.49 so we use chrono and steady_timer
+ template <typename T>
+ bool is_neg(T duration) {
+ return duration.count() < 0;
+ }
+ inline lib::chrono::milliseconds milliseconds(long duration) {
+ return lib::chrono::milliseconds(duration);
+ }
+ #else
+ // Using boost::asio <1.49 we pretend a deadline timer is a steady
+ // timer and wrap the negative detection and duration conversion
+ // appropriately.
+ typedef boost::asio::deadline_timer steady_timer;
+
+ template <typename T>
+ bool is_neg(T duration) {
+ return duration.is_negative();
+ }
+ inline boost::posix_time::time_duration milliseconds(long duration) {
+ return boost::posix_time::milliseconds(duration);
+ }
+ #endif
+
+ using boost::system::error_code;
+ namespace errc = boost::system::errc;
+ } // namespace asio
+#endif
+
+
+} // namespace lib
+} // namespace websocketpp
+
+#endif // WEBSOCKETPP_COMMON_ASIO_HPP
diff --git a/websocketpp/common/asio_ssl.hpp b/websocketpp/common/asio_ssl.hpp
new file mode 100644
index 00000000..69892832
--- /dev/null
+++ b/websocketpp/common/asio_ssl.hpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2015, Peter Thorson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the WebSocket++ Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef WEBSOCKETPP_COMMON_ASIO_SSL_HPP
+#define WEBSOCKETPP_COMMON_ASIO_SSL_HPP
+
+// NOTE: This file must be included before common/asio.hpp
+
+#ifdef ASIO_STANDALONE
+ #include <asio/ssl.hpp>
+#else
+ #include <boost/asio/ssl.hpp>
+#endif
+
+#endif // WEBSOCKETPP_COMMON_ASIO_SSL_HPP
diff --git a/websocketpp/common/chrono.hpp b/websocketpp/common/chrono.hpp
new file mode 100644
index 00000000..975ee043
--- /dev/null
+++ b/websocketpp/common/chrono.hpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2015, Peter Thorson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the WebSocket++ Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef WEBSOCKETPP_COMMON_CHRONO_HPP
+#define WEBSOCKETPP_COMMON_CHRONO_HPP
+
+#include <websocketpp/common/cpp11.hpp>
+
+// If we've determined that we're in full C++11 mode and the user hasn't
+// explicitly disabled the use of C++11 functional header, then prefer it to
+// boost.
+#if defined _WEBSOCKETPP_CPP11_INTERNAL_ && !defined _WEBSOCKETPP_NO_CPP11_CHRONO_
+ #ifndef _WEBSOCKETPP_CPP11_CHRONO_
+ #define _WEBSOCKETPP_CPP11_CHRONO_
+ #endif
+#endif
+
+// If we're on Visual Studio 2012 or higher and haven't explicitly disabled
+// the use of C++11 chrono header then prefer it to boost.
+#if defined(_MSC_VER) && _MSC_VER >= 1700 && !defined _WEBSOCKETPP_NO_CPP11_CHRONO_
+ #ifndef _WEBSOCKETPP_CPP11_CHRONO_
+ #define _WEBSOCKETPP_CPP11_CHRONO_
+ #endif
+#endif
+
+#ifdef _WEBSOCKETPP_CPP11_CHRONO_
+ #include <chrono>
+#else
+ #include <boost/chrono.hpp>
+#endif
+
+namespace websocketpp {
+namespace lib {
+
+#ifdef _WEBSOCKETPP_CPP11_CHRONO_
+ namespace chrono = std::chrono;
+#else
+ namespace chrono = boost::chrono;
+#endif
+
+} // namespace lib
+} // namespace websocketpp
+
+#endif // WEBSOCKETPP_COMMON_CHRONO_HPP
diff --git a/websocketpp/common/connection_hdl.hpp b/websocketpp/common/connection_hdl.hpp
new file mode 100644
index 00000000..1044c88e
--- /dev/null
+++ b/websocketpp/common/connection_hdl.hpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2014, Peter Thorson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the WebSocket++ Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef WEBSOCKETPP_COMMON_CONNECTION_HDL_HPP
+#define WEBSOCKETPP_COMMON_CONNECTION_HDL_HPP
+
+#include <websocketpp/common/memory.hpp>
+
+namespace websocketpp {
+
+/// A handle to uniquely identify a connection.
+/**
+ * This type uniquely identifies a connection. It is implemented as a weak
+ * pointer to the connection in question. This provides uniqueness across
+ * multiple endpoints and ensures that IDs never conflict or run out.
+ *
+ * It is safe to make copies of this handle, store those copies in containers,
+ * and use them from other threads.
+ *
+ * This handle can be upgraded to a full shared_ptr using
+ * `endpoint::get_con_from_hdl()` from within a handler fired by the connection
+ * that owns the handler.
+ */
+typedef lib::weak_ptr<void> connection_hdl;
+
+} // namespace websocketpp
+
+#endif // WEBSOCKETPP_COMMON_CONNECTION_HDL_HPP
diff --git a/websocketpp/common/cpp11.hpp b/websocketpp/common/cpp11.hpp
new file mode 100644
index 00000000..492a3b8f
--- /dev/null
+++ b/websocketpp/common/cpp11.hpp
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2014, Peter Thorson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the WebSocket++ Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef WEBSOCKETPP_COMMON_CPP11_HPP
+#define WEBSOCKETPP_COMMON_CPP11_HPP
+
+/**
+ * This header sets up some constants based on the state of C++11 support
+ */
+
+// Hide clang feature detection from other compilers
+#ifndef __has_feature // Optional of course.
+ #define __has_feature(x) 0 // Compatibility with non-clang compilers.
+#endif
+#ifndef __has_extension
+ #define __has_extension __has_feature // Compatibility with pre-3.0 compilers.
+#endif
+
+// The code below attempts to use information provided by the build system or
+// user supplied defines to selectively enable C++11 language and library
+// features. In most cases features that are targeted individually may also be
+// selectively disabled via an associated _WEBSOCKETPP_NOXXX_ define.
+
+#if defined(_WEBSOCKETPP_CPP11_STL_) || __cplusplus >= 201103L || defined(_WEBSOCKETPP_CPP11_STRICT_)
+ // This check tests for blanket c++11 coverage. It can be activated in one
+ // of three ways. Either the compiler itself reports that it is a full
+ // C++11 compiler via the __cplusplus macro or the user/build system
+ // supplies one of the two preprocessor defines below:
+
+ // This is defined to allow other WebSocket++ common headers to enable
+ // C++11 features when they are detected by this file rather than
+ // duplicating the above logic in every common header.
+ #define _WEBSOCKETPP_CPP11_INTERNAL_
+
+ // _WEBSOCKETPP_CPP11_STRICT_
+ //
+ // This define reports to WebSocket++ that 100% of the language and library
+ // features of C++11 are available. Using this define on a non-C++11
+ // compiler will result in problems.
+
+ // _WEBSOCKETPP_CPP11_STL_
+ //
+ // This define enables *most* C++11 options that were implemented early on
+ // by compilers. It is typically used for compilers that have many, but not
+ // all C++11 features. It should be safe to use on GCC 4.7-4.8 and perhaps
+ // earlier.
+ #ifndef _WEBSOCKETPP_NOEXCEPT_TOKEN_
+ #define _WEBSOCKETPP_NOEXCEPT_TOKEN_ noexcept
+ #endif
+ #ifndef _WEBSOCKETPP_CONSTEXPR_TOKEN_
+ #define _WEBSOCKETPP_CONSTEXPR_TOKEN_ constexpr
+ #endif
+ #ifndef _WEBSOCKETPP_INITIALIZER_LISTS_
+ #define _WEBSOCKETPP_INITIALIZER_LISTS_
+ #endif
+ #ifndef _WEBSOCKETPP_NULLPTR_TOKEN_
+ #define _WEBSOCKETPP_NULLPTR_TOKEN_ nullptr
+ #endif
+ #ifndef _WEBSOCKETPP_MOVE_SEMANTICS_
+ #define _WEBSOCKETPP_MOVE_SEMANTICS_
+ #endif
+ #ifndef _WEBSOCKETPP_DEFAULT_DELETE_FUNCTIONS_
+ #define _WEBSOCKETPP_DEFAULT_DELETE_FUNCTIONS_
+ #endif
+
+ #ifndef __GNUC__
+ // GCC as of version 4.9 (latest) does not support std::put_time yet.
+ // so ignore it
+ #define _WEBSOCKETPP_PUTTIME_
+ #endif
+#else
+ // In the absence of a blanket define, try to use compiler versions or
+ // feature testing macros to selectively enable what we can.
+
+ // Test for noexcept
+ #ifndef _WEBSOCKETPP_NOEXCEPT_TOKEN_
+ #ifdef _WEBSOCKETPP_NOEXCEPT_
+ // build system says we have noexcept
+ #define _WEBSOCKETPP_NOEXCEPT_TOKEN_ noexcept
+ #else
+ #if __has_feature(cxx_noexcept)
+ // clang feature detect says we have noexcept
+ #define _WEBSOCKETPP_NOEXCEPT_TOKEN_ noexcept
+ #elif defined(_MSC_VER) && _MSC_VER >= 1900
+ // Visual Studio 2015+ has noexcept
+ #define _WEBSOCKETPP_NOEXCEPT_TOKEN_ noexcept
+ #else
+ // assume we don't have noexcept
+ #define _WEBSOCKETPP_NOEXCEPT_TOKEN_
+ #endif
+ #endif
+ #endif
+
+ // Test for constexpr
+ #ifndef _WEBSOCKETPP_CONSTEXPR_TOKEN_
+ #ifdef _WEBSOCKETPP_CONSTEXPR_
+ // build system says we have constexpr
+ #define _WEBSOCKETPP_CONSTEXPR_TOKEN_ constexpr
+ #else
+ #if __has_feature(cxx_constexpr)
+ // clang feature detect says we have constexpr
+ #define _WEBSOCKETPP_CONSTEXPR_TOKEN_ constexpr
+ #elif defined(_MSC_VER) && _MSC_VER >= 1900
+ // Visual Studio 2015+ has constexpr
+ #define _WEBSOCKETPP_CONSTEXPR_TOKEN_ constexpr
+ #else
+ // assume we don't have constexpr
+ #define _WEBSOCKETPP_CONSTEXPR_TOKEN_
+ #endif
+ #endif
+ #endif
+
+ // Enable initializer lists on clang when available.
+ #if __has_feature(cxx_generalized_initializers) && !defined(_WEBSOCKETPP_INITIALIZER_LISTS_)
+ #define _WEBSOCKETPP_INITIALIZER_LISTS_
+ #endif
+
+ // Test for nullptr
+ #ifndef _WEBSOCKETPP_NULLPTR_TOKEN_
+ #ifdef _WEBSOCKETPP_NULLPTR_
+ // build system says we have nullptr
+ #define _WEBSOCKETPP_NULLPTR_TOKEN_ nullptr
+ #else
+ #if __has_feature(cxx_nullptr)
+ // clang feature detect says we have nullptr
+ #define _WEBSOCKETPP_NULLPTR_TOKEN_ nullptr
+ #elif defined(_MSC_VER) &&_MSC_VER >= 1600
+ // Visual Studio version that has nullptr
+ #define _WEBSOCKETPP_NULLPTR_TOKEN_ nullptr
+ #else
+ // assume we don't have nullptr
+ #define _WEBSOCKETPP_NULLPTR_TOKEN_ 0
+ #endif
+ #endif
+ #endif
+#endif
+
+#endif // WEBSOCKETPP_COMMON_CPP11_HPP
diff --git a/websocketpp/common/functional.hpp b/websocketpp/common/functional.hpp
new file mode 100644
index 00000000..d332dd15
--- /dev/null
+++ b/websocketpp/common/functional.hpp
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2014, Peter Thorson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the WebSocket++ Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef WEBSOCKETPP_COMMON_FUNCTIONAL_HPP
+#define WEBSOCKETPP_COMMON_FUNCTIONAL_HPP
+
+#include <websocketpp/common/cpp11.hpp>
+
+// If we've determined that we're in full C++11 mode and the user hasn't
+// explicitly disabled the use of C++11 functional header, then prefer it to
+// boost.
+#if defined _WEBSOCKETPP_CPP11_INTERNAL_ && !defined _WEBSOCKETPP_NO_CPP11_FUNCTIONAL_
+ #ifndef _WEBSOCKETPP_CPP11_FUNCTIONAL_
+ #define _WEBSOCKETPP_CPP11_FUNCTIONAL_
+ #endif
+#endif
+
+// If we're on Visual Studio 2010 or higher and haven't explicitly disabled
+// the use of C++11 functional header then prefer it to boost.
+#if defined(_MSC_VER) && _MSC_VER >= 1600 && !defined _WEBSOCKETPP_NO_CPP11_FUNCTIONAL_
+ #ifndef _WEBSOCKETPP_CPP11_FUNCTIONAL_
+ #define _WEBSOCKETPP_CPP11_FUNCTIONAL_
+ #endif
+#endif
+
+
+
+#ifdef _WEBSOCKETPP_CPP11_FUNCTIONAL_
+ #include <functional>
+#else
+ #include <boost/bind.hpp>
+ #include <boost/function.hpp>
+ #include <boost/ref.hpp>
+#endif
+
+
+
+namespace websocketpp {
+namespace lib {
+
+#ifdef _WEBSOCKETPP_CPP11_FUNCTIONAL_
+ using std::function;
+ using std::bind;
+ using std::ref;
+ namespace placeholders = std::placeholders;
+
+ // There are some cases where a C++11 compiler balks at using std::ref
+ // but a C++03 compiler using boost function requires boost::ref. As such
+ // lib::ref is not useful in these cases. Instead this macro allows the use
+ // of boost::ref in the case of a boost compile or no reference wrapper at
+ // all in the case of a C++11 compile
+ #define _WEBSOCKETPP_REF(x) x
+
+ template <typename T>
+ void clear_function(T & x) {
+ x = nullptr;
+ }
+#else
+ using boost::function;
+ using boost::bind;
+ using boost::ref;
+ namespace placeholders {
+ /// \todo this feels hacky, is there a better way?
+ using ::_1;
+ using ::_2;
+ using ::_3;
+ }
+
+ // See above definition for more details on what this is and why it exists
+ #define _WEBSOCKETPP_REF(x) boost::ref(x)
+
+ template <typename T>
+ void clear_function(T & x) {
+ x.clear();
+ }
+#endif
+
+} // namespace lib
+} // namespace websocketpp
+
+#endif // WEBSOCKETPP_COMMON_FUNCTIONAL_HPP
diff --git a/websocketpp/common/md5.hpp b/websocketpp/common/md5.hpp
new file mode 100644
index 00000000..279725f4
--- /dev/null
+++ b/websocketpp/common/md5.hpp
@@ -0,0 +1,448 @@
+/*
+ md5.hpp is a reformulation of the md5.h and md5.c code from
+ http://www.opensource.apple.com/source/cups/cups-59/cups/md5.c to allow it to
+ function as a component of a header only library. This conversion was done by
+ Peter Thorson (webmaster@zaphoyd.com) in 2012 for the WebSocket++ project. The
+ changes are released under the same license as the original (listed below)
+*/
+/*
+ Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved.
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ L. Peter Deutsch
+ ghost@aladdin.com
+
+ */
+/* $Id: md5.h,v 1.4 2002/04/13 19:20:28 lpd Exp $ */
+/*
+ Independent implementation of MD5 (RFC 1321).
+
+ This code implements the MD5 Algorithm defined in RFC 1321, whose
+ text is available at
+ http://www.ietf.org/rfc/rfc1321.txt
+ The code is derived from the text of the RFC, including the test suite
+ (section A.5) but excluding the rest of Appendix A. It does not include
+ any code or documentation that is identified in the RFC as being
+ copyrighted.
+
+ The original and principal author of md5.h is L. Peter Deutsch
+ <ghost@aladdin.com>. Other authors are noted in the change history
+ that follows (in reverse chronological order):
+
+ 2002-04-13 lpd Removed support for non-ANSI compilers; removed
+ references to Ghostscript; clarified derivation from RFC 1321;
+ now handles byte order either statically or dynamically.
+ 1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
+ 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
+ added conditionalization for C++ compilation from Martin
+ Purschke <purschke@bnl.gov>.
+ 1999-05-03 lpd Original version.
+ */
+
+#ifndef WEBSOCKETPP_COMMON_MD5_HPP
+#define WEBSOCKETPP_COMMON_MD5_HPP
+
+/*
+ * This package supports both compile-time and run-time determination of CPU
+ * byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be
+ * compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is
+ * defined as non-zero, the code will be compiled to run only on big-endian
+ * CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to
+ * run on either big- or little-endian CPUs, but will run slightly less
+ * efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined.
+ */
+
+#include <stddef.h>
+#include <string>
+#include <cstring>
+
+namespace websocketpp {
+/// Provides MD5 hashing functionality
+namespace md5 {
+
+typedef unsigned char md5_byte_t; /* 8-bit byte */
+typedef unsigned int md5_word_t; /* 32-bit word */
+
+/* Define the state of the MD5 Algorithm. */
+typedef struct md5_state_s {
+ md5_word_t count[2]; /* message length in bits, lsw first */
+ md5_word_t abcd[4]; /* digest buffer */
+ md5_byte_t buf[64]; /* accumulate block */
+} md5_state_t;
+
+/* Initialize the algorithm. */
+inline void md5_init(md5_state_t *pms);
+
+/* Append a string to the message. */
+inline void md5_append(md5_state_t *pms, md5_byte_t const * data, size_t nbytes);
+
+/* Finish the message and return the digest. */
+inline void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
+
+#undef ZSW_MD5_BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */
+#ifdef ARCH_IS_BIG_ENDIAN
+# define ZSW_MD5_BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1)
+#else
+# define ZSW_MD5_BYTE_ORDER 0
+#endif
+
+#define ZSW_MD5_T_MASK ((md5_word_t)~0)
+#define ZSW_MD5_T1 /* 0xd76aa478 */ (ZSW_MD5_T_MASK ^ 0x28955b87)
+#define ZSW_MD5_T2 /* 0xe8c7b756 */ (ZSW_MD5_T_MASK ^ 0x173848a9)
+#define ZSW_MD5_T3 0x242070db
+#define ZSW_MD5_T4 /* 0xc1bdceee */ (ZSW_MD5_T_MASK ^ 0x3e423111)
+#define ZSW_MD5_T5 /* 0xf57c0faf */ (ZSW_MD5_T_MASK ^ 0x0a83f050)
+#define ZSW_MD5_T6 0x4787c62a
+#define ZSW_MD5_T7 /* 0xa8304613 */ (ZSW_MD5_T_MASK ^ 0x57cfb9ec)
+#define ZSW_MD5_T8 /* 0xfd469501 */ (ZSW_MD5_T_MASK ^ 0x02b96afe)
+#define ZSW_MD5_T9 0x698098d8
+#define ZSW_MD5_T10 /* 0x8b44f7af */ (ZSW_MD5_T_MASK ^ 0x74bb0850)
+#define ZSW_MD5_T11 /* 0xffff5bb1 */ (ZSW_MD5_T_MASK ^ 0x0000a44e)
+#define ZSW_MD5_T12 /* 0x895cd7be */ (ZSW_MD5_T_MASK ^ 0x76a32841)
+#define ZSW_MD5_T13 0x6b901122
+#define ZSW_MD5_T14 /* 0xfd987193 */ (ZSW_MD5_T_MASK ^ 0x02678e6c)
+#define ZSW_MD5_T15 /* 0xa679438e */ (ZSW_MD5_T_MASK ^ 0x5986bc71)
+#define ZSW_MD5_T16 0x49b40821
+#define ZSW_MD5_T17 /* 0xf61e2562 */ (ZSW_MD5_T_MASK ^ 0x09e1da9d)
+#define ZSW_MD5_T18 /* 0xc040b340 */ (ZSW_MD5_T_MASK ^ 0x3fbf4cbf)
+#define ZSW_MD5_T19 0x265e5a51
+#define ZSW_MD5_T20 /* 0xe9b6c7aa */ (ZSW_MD5_T_MASK ^ 0x16493855)
+#define ZSW_MD5_T21 /* 0xd62f105d */ (ZSW_MD5_T_MASK ^ 0x29d0efa2)
+#define ZSW_MD5_T22 0x02441453
+#define ZSW_MD5_T23 /* 0xd8a1e681 */ (ZSW_MD5_T_MASK ^ 0x275e197e)
+#define ZSW_MD5_T24 /* 0xe7d3fbc8 */ (ZSW_MD5_T_MASK ^ 0x182c0437)
+#define ZSW_MD5_T25 0x21e1cde6
+#define ZSW_MD5_T26 /* 0xc33707d6 */ (ZSW_MD5_T_MASK ^ 0x3cc8f829)
+#define ZSW_MD5_T27 /* 0xf4d50d87 */ (ZSW_MD5_T_MASK ^ 0x0b2af278)
+#define ZSW_MD5_T28 0x455a14ed
+#define ZSW_MD5_T29 /* 0xa9e3e905 */ (ZSW_MD5_T_MASK ^ 0x561c16fa)
+#define ZSW_MD5_T30 /* 0xfcefa3f8 */ (ZSW_MD5_T_MASK ^ 0x03105c07)
+#define ZSW_MD5_T31 0x676f02d9
+#define ZSW_MD5_T32 /* 0x8d2a4c8a */ (ZSW_MD5_T_MASK ^ 0x72d5b375)
+#define ZSW_MD5_T33 /* 0xfffa3942 */ (ZSW_MD5_T_MASK ^ 0x0005c6bd)
+#define ZSW_MD5_T34 /* 0x8771f681 */ (ZSW_MD5_T_MASK ^ 0x788e097e)
+#define ZSW_MD5_T35 0x6d9d6122
+#define ZSW_MD5_T36 /* 0xfde5380c */ (ZSW_MD5_T_MASK ^ 0x021ac7f3)
+#define ZSW_MD5_T37 /* 0xa4beea44 */ (ZSW_MD5_T_MASK ^ 0x5b4115bb)
+#define ZSW_MD5_T38 0x4bdecfa9
+#define ZSW_MD5_T39 /* 0xf6bb4b60 */ (ZSW_MD5_T_MASK ^ 0x0944b49f)
+#define ZSW_MD5_T40 /* 0xbebfbc70 */ (ZSW_MD5_T_MASK ^ 0x4140438f)
+#define ZSW_MD5_T41 0x289b7ec6
+#define ZSW_MD5_T42 /* 0xeaa127fa */ (ZSW_MD5_T_MASK ^ 0x155ed805)
+#define ZSW_MD5_T43 /* 0xd4ef3085 */ (ZSW_MD5_T_MASK ^ 0x2b10cf7a)
+#define ZSW_MD5_T44 0x04881d05
+#define ZSW_MD5_T45 /* 0xd9d4d039 */ (ZSW_MD5_T_MASK ^ 0x262b2fc6)
+#define ZSW_MD5_T46 /* 0xe6db99e5 */ (ZSW_MD5_T_MASK ^ 0x1924661a)
+#define ZSW_MD5_T47 0x1fa27cf8
+#define ZSW_MD5_T48 /* 0xc4ac5665 */ (ZSW_MD5_T_MASK ^ 0x3b53a99a)
+#define ZSW_MD5_T49 /* 0xf4292244 */ (ZSW_MD5_T_MASK ^ 0x0bd6ddbb)
+#define ZSW_MD5_T50 0x432aff97
+#define ZSW_MD5_T51 /* 0xab9423a7 */ (ZSW_MD5_T_MASK ^ 0x546bdc58)
+#define ZSW_MD5_T52 /* 0xfc93a039 */ (ZSW_MD5_T_MASK ^ 0x036c5fc6)
+#define ZSW_MD5_T53 0x655b59c3
+#define ZSW_MD5_T54 /* 0x8f0ccc92 */ (ZSW_MD5_T_MASK ^ 0x70f3336d)
+#define ZSW_MD5_T55 /* 0xffeff47d */ (ZSW_MD5_T_MASK ^ 0x00100b82)
+#define ZSW_MD5_T56 /* 0x85845dd1 */ (ZSW_MD5_T_MASK ^ 0x7a7ba22e)
+#define ZSW_MD5_T57 0x6fa87e4f
+#define ZSW_MD5_T58 /* 0xfe2ce6e0 */ (ZSW_MD5_T_MASK ^ 0x01d3191f)
+#define ZSW_MD5_T59 /* 0xa3014314 */ (ZSW_MD5_T_MASK ^ 0x5cfebceb)
+#define ZSW_MD5_T60 0x4e0811a1
+#define ZSW_MD5_T61 /* 0xf7537e82 */ (ZSW_MD5_T_MASK ^ 0x08ac817d)
+#define ZSW_MD5_T62 /* 0xbd3af235 */ (ZSW_MD5_T_MASK ^ 0x42c50dca)
+#define ZSW_MD5_T63 0x2ad7d2bb
+#define ZSW_MD5_T64 /* 0xeb86d391 */ (ZSW_MD5_T_MASK ^ 0x14792c6e)
+
+static void md5_process(md5_state_t *pms, md5_byte_t const * data /*[64]*/) {
+ md5_word_t
+ a = pms->abcd[0], b = pms->abcd[1],
+ c = pms->abcd[2], d = pms->abcd[3];
+ md5_word_t t;
+#if ZSW_MD5_BYTE_ORDER > 0
+ /* Define storage only for big-endian CPUs. */
+ md5_word_t X[16];
+#else
+ /* Define storage for little-endian or both types of CPUs. */
+ md5_word_t xbuf[16];
+ md5_word_t const * X;
+#endif
+
+ {
+#if ZSW_MD5_BYTE_ORDER == 0
+ /*
+ * Determine dynamically whether this is a big-endian or
+ * little-endian machine, since we can use a more efficient
+ * algorithm on the latter.
+ */
+ static int const w = 1;
+
+ if (*((md5_byte_t const *)&w)) /* dynamic little-endian */
+#endif
+#if ZSW_MD5_BYTE_ORDER <= 0 /* little-endian */
+ {
+ /*
+ * On little-endian machines, we can process properly aligned
+ * data without copying it.
+ */
+ if (!((data - (md5_byte_t const *)0) & 3)) {
+ /* data are properly aligned */
+ X = (md5_word_t const *)data;
+ } else {
+ /* not aligned */
+ std::memcpy(xbuf, data, 64);
+ X = xbuf;
+ }
+ }
+#endif
+#if ZSW_MD5_BYTE_ORDER == 0
+ else /* dynamic big-endian */
+#endif
+#if ZSW_MD5_BYTE_ORDER >= 0 /* big-endian */
+ {
+ /*
+ * On big-endian machines, we must arrange the bytes in the
+ * right order.
+ */
+ const md5_byte_t *xp = data;
+ int i;
+
+# if ZSW_MD5_BYTE_ORDER == 0
+ X = xbuf; /* (dynamic only) */
+# else
+# define xbuf X /* (static only) */
+# endif
+ for (i = 0; i < 16; ++i, xp += 4)
+ xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
+ }
+#endif
+ }
+
+#define ZSW_MD5_ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
+
+ /* Round 1. */
+ /* Let [abcd k s i] denote the operation
+ a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */
+#define ZSW_MD5_F(x, y, z) (((x) & (y)) | (~(x) & (z)))
+#define SET(a, b, c, d, k, s, Ti)\
+ t = a + ZSW_MD5_F(b,c,d) + X[k] + Ti;\
+ a = ZSW_MD5_ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 0, 7, ZSW_MD5_T1);
+ SET(d, a, b, c, 1, 12, ZSW_MD5_T2);
+ SET(c, d, a, b, 2, 17, ZSW_MD5_T3);
+ SET(b, c, d, a, 3, 22, ZSW_MD5_T4);
+ SET(a, b, c, d, 4, 7, ZSW_MD5_T5);
+ SET(d, a, b, c, 5, 12, ZSW_MD5_T6);
+ SET(c, d, a, b, 6, 17, ZSW_MD5_T7);
+ SET(b, c, d, a, 7, 22, ZSW_MD5_T8);
+ SET(a, b, c, d, 8, 7, ZSW_MD5_T9);
+ SET(d, a, b, c, 9, 12, ZSW_MD5_T10);
+ SET(c, d, a, b, 10, 17, ZSW_MD5_T11);
+ SET(b, c, d, a, 11, 22, ZSW_MD5_T12);
+ SET(a, b, c, d, 12, 7, ZSW_MD5_T13);
+ SET(d, a, b, c, 13, 12, ZSW_MD5_T14);
+ SET(c, d, a, b, 14, 17, ZSW_MD5_T15);
+ SET(b, c, d, a, 15, 22, ZSW_MD5_T16);
+#undef SET
+
+ /* Round 2. */
+ /* Let [abcd k s i] denote the operation
+ a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */
+#define ZSW_MD5_G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
+#define SET(a, b, c, d, k, s, Ti)\
+ t = a + ZSW_MD5_G(b,c,d) + X[k] + Ti;\
+ a = ZSW_MD5_ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 1, 5, ZSW_MD5_T17);
+ SET(d, a, b, c, 6, 9, ZSW_MD5_T18);
+ SET(c, d, a, b, 11, 14, ZSW_MD5_T19);
+ SET(b, c, d, a, 0, 20, ZSW_MD5_T20);
+ SET(a, b, c, d, 5, 5, ZSW_MD5_T21);
+ SET(d, a, b, c, 10, 9, ZSW_MD5_T22);
+ SET(c, d, a, b, 15, 14, ZSW_MD5_T23);
+ SET(b, c, d, a, 4, 20, ZSW_MD5_T24);
+ SET(a, b, c, d, 9, 5, ZSW_MD5_T25);
+ SET(d, a, b, c, 14, 9, ZSW_MD5_T26);
+ SET(c, d, a, b, 3, 14, ZSW_MD5_T27);
+ SET(b, c, d, a, 8, 20, ZSW_MD5_T28);
+ SET(a, b, c, d, 13, 5, ZSW_MD5_T29);
+ SET(d, a, b, c, 2, 9, ZSW_MD5_T30);
+ SET(c, d, a, b, 7, 14, ZSW_MD5_T31);
+ SET(b, c, d, a, 12, 20, ZSW_MD5_T32);
+#undef SET
+
+ /* Round 3. */
+ /* Let [abcd k s t] denote the operation
+ a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */
+#define ZSW_MD5_H(x, y, z) ((x) ^ (y) ^ (z))
+#define SET(a, b, c, d, k, s, Ti)\
+ t = a + ZSW_MD5_H(b,c,d) + X[k] + Ti;\
+ a = ZSW_MD5_ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 5, 4, ZSW_MD5_T33);
+ SET(d, a, b, c, 8, 11, ZSW_MD5_T34);
+ SET(c, d, a, b, 11, 16, ZSW_MD5_T35);
+ SET(b, c, d, a, 14, 23, ZSW_MD5_T36);
+ SET(a, b, c, d, 1, 4, ZSW_MD5_T37);
+ SET(d, a, b, c, 4, 11, ZSW_MD5_T38);
+ SET(c, d, a, b, 7, 16, ZSW_MD5_T39);
+ SET(b, c, d, a, 10, 23, ZSW_MD5_T40);
+ SET(a, b, c, d, 13, 4, ZSW_MD5_T41);
+ SET(d, a, b, c, 0, 11, ZSW_MD5_T42);
+ SET(c, d, a, b, 3, 16, ZSW_MD5_T43);
+ SET(b, c, d, a, 6, 23, ZSW_MD5_T44);
+ SET(a, b, c, d, 9, 4, ZSW_MD5_T45);
+ SET(d, a, b, c, 12, 11, ZSW_MD5_T46);
+ SET(c, d, a, b, 15, 16, ZSW_MD5_T47);
+ SET(b, c, d, a, 2, 23, ZSW_MD5_T48);
+#undef SET
+
+ /* Round 4. */
+ /* Let [abcd k s t] denote the operation
+ a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */
+#define ZSW_MD5_I(x, y, z) ((y) ^ ((x) | ~(z)))
+#define SET(a, b, c, d, k, s, Ti)\
+ t = a + ZSW_MD5_I(b,c,d) + X[k] + Ti;\
+ a = ZSW_MD5_ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 0, 6, ZSW_MD5_T49);
+ SET(d, a, b, c, 7, 10, ZSW_MD5_T50);
+ SET(c, d, a, b, 14, 15, ZSW_MD5_T51);
+ SET(b, c, d, a, 5, 21, ZSW_MD5_T52);
+ SET(a, b, c, d, 12, 6, ZSW_MD5_T53);
+ SET(d, a, b, c, 3, 10, ZSW_MD5_T54);
+ SET(c, d, a, b, 10, 15, ZSW_MD5_T55);
+ SET(b, c, d, a, 1, 21, ZSW_MD5_T56);
+ SET(a, b, c, d, 8, 6, ZSW_MD5_T57);
+ SET(d, a, b, c, 15, 10, ZSW_MD5_T58);
+ SET(c, d, a, b, 6, 15, ZSW_MD5_T59);
+ SET(b, c, d, a, 13, 21, ZSW_MD5_T60);
+ SET(a, b, c, d, 4, 6, ZSW_MD5_T61);
+ SET(d, a, b, c, 11, 10, ZSW_MD5_T62);
+ SET(c, d, a, b, 2, 15, ZSW_MD5_T63);
+ SET(b, c, d, a, 9, 21, ZSW_MD5_T64);
+#undef SET
+
+ /* Then perform the following additions. (That is increment each
+ of the four registers by the value it had before this block
+ was started.) */
+ pms->abcd[0] += a;
+ pms->abcd[1] += b;
+ pms->abcd[2] += c;
+ pms->abcd[3] += d;
+}
+
+void md5_init(md5_state_t *pms) {
+ pms->count[0] = pms->count[1] = 0;
+ pms->abcd[0] = 0x67452301;
+ pms->abcd[1] = /*0xefcdab89*/ ZSW_MD5_T_MASK ^ 0x10325476;
+ pms->abcd[2] = /*0x98badcfe*/ ZSW_MD5_T_MASK ^ 0x67452301;
+ pms->abcd[3] = 0x10325476;
+}
+
+void md5_append(md5_state_t *pms, md5_byte_t const * data, size_t nbytes) {
+ md5_byte_t const * p = data;
+ size_t left = nbytes;
+ int offset = (pms->count[0] >> 3) & 63;
+ md5_word_t nbits = (md5_word_t)(nbytes << 3);
+
+ if (nbytes <= 0)
+ return;
+
+ /* Update the message length. */
+ pms->count[1] += nbytes >> 29;
+ pms->count[0] += nbits;
+ if (pms->count[0] < nbits)
+ pms->count[1]++;
+
+ /* Process an initial partial block. */
+ if (offset) {
+ int copy = (offset + nbytes > 64 ? 64 - offset : static_cast<int>(nbytes));
+
+ std::memcpy(pms->buf + offset, p, copy);
+ if (offset + copy < 64)
+ return;
+ p += copy;
+ left -= copy;
+ md5_process(pms, pms->buf);
+ }
+
+ /* Process full blocks. */
+ for (; left >= 64; p += 64, left -= 64)
+ md5_process(pms, p);
+
+ /* Process a final partial block. */
+ if (left)
+ std::memcpy(pms->buf, p, left);
+}
+
+void md5_finish(md5_state_t *pms, md5_byte_t digest[16]) {
+ static md5_byte_t const pad[64] = {
+ 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
+ md5_byte_t data[8];
+ int i;
+
+ /* Save the length before padding. */
+ for (i = 0; i < 8; ++i)
+ data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
+ /* Pad to 56 bytes mod 64. */
+ md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
+ /* Append the length. */
+ md5_append(pms, data, 8);
+ for (i = 0; i < 16; ++i)
+ digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
+}
+
+// some convenience c++ functions
+inline std::string md5_hash_string(std::string const & s) {
+ char digest[16];
+
+ md5_state_t state;
+
+ md5_init(&state);
+ md5_append(&state, (md5_byte_t const *)s.c_str(), s.size());
+ md5_finish(&state, (md5_byte_t *)digest);
+
+ std::string ret;
+ ret.resize(16);
+ std::copy(digest,digest+16,ret.begin());
+
+ return ret;
+}
+
+const char hexval[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+
+inline std::string md5_hash_hex(std::string const & input) {
+ std::string hash = md5_hash_string(input);
+ std::string hex;
+
+ for (size_t i = 0; i < hash.size(); i++) {
+ hex.push_back(hexval[((hash[i] >> 4) & 0xF)]);
+ hex.push_back(hexval[(hash[i]) & 0x0F]);
+ }
+
+ return hex;
+}
+
+} // md5
+} // websocketpp
+
+#endif // WEBSOCKETPP_COMMON_MD5_HPP
diff --git a/websocketpp/common/memory.hpp b/websocketpp/common/memory.hpp
new file mode 100644
index 00000000..581aa559
--- /dev/null
+++ b/websocketpp/common/memory.hpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2014, Peter Thorson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the WebSocket++ Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef WEBSOCKETPP_COMMON_MEMORY_HPP
+#define WEBSOCKETPP_COMMON_MEMORY_HPP
+
+#include <websocketpp/common/cpp11.hpp>
+
+// If we've determined that we're in full C++11 mode and the user hasn't
+// explicitly disabled the use of C++11 memory header, then prefer it to
+// boost.
+#if defined _WEBSOCKETPP_CPP11_INTERNAL_ && !defined _WEBSOCKETPP_NO_CPP11_MEMORY_
+ #ifndef _WEBSOCKETPP_CPP11_MEMORY_
+ #define _WEBSOCKETPP_CPP11_MEMORY_
+ #endif
+#endif
+
+// If we're on Visual Studio 2010 or higher and haven't explicitly disabled
+// the use of C++11 functional header then prefer it to boost.
+#if defined(_MSC_VER) && _MSC_VER >= 1600 && !defined _WEBSOCKETPP_NO_CPP11_MEMORY_
+ #ifndef _WEBSOCKETPP_CPP11_MEMORY_
+ #define _WEBSOCKETPP_CPP11_MEMORY_
+ #endif
+#endif
+
+
+
+#ifdef _WEBSOCKETPP_CPP11_MEMORY_
+ #include <memory>
+#else
+ #include <boost/shared_ptr.hpp>
+ #include <boost/make_shared.hpp>
+ #include <boost/scoped_array.hpp>
+ #include <boost/enable_shared_from_this.hpp>
+ #include <boost/pointer_cast.hpp>
+#endif
+
+namespace websocketpp {
+namespace lib {
+
+#ifdef _WEBSOCKETPP_CPP11_MEMORY_
+ using std::shared_ptr;
+ using std::weak_ptr;
+ using std::auto_ptr;
+ using std::enable_shared_from_this;
+ using std::static_pointer_cast;
+ using std::make_shared;
+ using std::unique_ptr;
+
+ typedef std::unique_ptr<unsigned char[]> unique_ptr_uchar_array;
+#else
+ using boost::shared_ptr;
+ using boost::weak_ptr;
+ using std::auto_ptr;
+ using boost::enable_shared_from_this;
+ using boost::static_pointer_cast;
+ using boost::make_shared;
+
+ typedef boost::scoped_array<unsigned char> unique_ptr_uchar_array;
+#endif
+
+} // namespace lib
+} // namespace websocketpp
+
+#endif // WEBSOCKETPP_COMMON_MEMORY_HPP
diff --git a/websocketpp/common/network.hpp b/websocketpp/common/network.hpp
new file mode 100644
index 00000000..26a4cb9e
--- /dev/null
+++ b/websocketpp/common/network.hpp
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2014, Peter Thorson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the WebSocket++ Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef WEBSOCKETPP_COMMON_NETWORK_HPP
+#define WEBSOCKETPP_COMMON_NETWORK_HPP
+
+// For ntohs and htons
+#if defined(_WIN32)
+ #include <winsock2.h>
+#else
+ //#include <arpa/inet.h>
+ #include <netinet/in.h>
+#endif
+
+#include <websocketpp/common/stdint.hpp>
+
+namespace websocketpp {
+namespace lib {
+namespace net {
+
+inline bool is_little_endian() {
+ short int val = 0x1;
+ char *ptr = reinterpret_cast<char *>(&val);
+ return (ptr[0] == 1);
+}
+
+#define TYP_INIT 0
+#define TYP_SMLE 1
+#define TYP_BIGE 2
+
+/// Convert 64 bit value to network byte order
+/**
+ * This method is prefixed to avoid conflicts with operating system level
+ * macros for this functionality.
+ *
+ * TODO: figure out if it would be beneficial to use operating system level
+ * macros for this.
+ *
+ * @param src The integer in host byte order
+ * @return src converted to network byte order
+ */
+inline uint64_t _htonll(uint64_t src) {
+ static int typ = TYP_INIT;
+ unsigned char c;
+ union {
+ uint64_t ull;
+ unsigned char c[8];
+ } x;
+ if (typ == TYP_INIT) {
+ x.ull = 0x01;
+ typ = (x.c[7] == 0x01ULL) ? TYP_BIGE : TYP_SMLE;
+ }
+ if (typ == TYP_BIGE)
+ return src;
+ x.ull = src;
+ c = x.c[0]; x.c[0] = x.c[7]; x.c[7] = c;
+ c = x.c[1]; x.c[1] = x.c[6]; x.c[6] = c;
+ c = x.c[2]; x.c[2] = x.c[5]; x.c[5] = c;
+ c = x.c[3]; x.c[3] = x.c[4]; x.c[4] = c;
+ return x.ull;
+}
+
+/// Convert 64 bit value to host byte order
+/**
+ * This method is prefixed to avoid conflicts with operating system level
+ * macros for this functionality.
+ *
+ * TODO: figure out if it would be beneficial to use operating system level
+ * macros for this.
+ *
+ * @param src The integer in network byte order
+ * @return src converted to host byte order
+ */
+inline uint64_t _ntohll(uint64_t src) {
+ return _htonll(src);
+}
+
+} // net
+} // lib
+} // websocketpp
+
+#endif // WEBSOCKETPP_COMMON_NETWORK_HPP
diff --git a/websocketpp/common/platforms.hpp b/websocketpp/common/platforms.hpp
new file mode 100644
index 00000000..87798577
--- /dev/null
+++ b/websocketpp/common/platforms.hpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2014, Peter Thorson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the WebSocket++ Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef WEBSOCKETPP_COMMON_PLATFORMS_HPP
+#define WEBSOCKETPP_COMMON_PLATFORMS_HPP
+
+/**
+ * This header contains any platform specific preprocessor adjustments that
+ * don't fit somewhere else better.
+ */
+
+#if defined(_WIN32) && !defined(NOMINMAX)
+ // don't define min and max macros that conflict with std::min and std::max
+ #define NOMINMAX
+#endif
+
+// Bump up the variadic parameter max for Visual Studio 2012
+#if defined(_MSC_VER) && _MSC_VER == 1700
+ #define _VARIADIC_MAX 8
+#endif
+
+#endif // WEBSOCKETPP_COMMON_PLATFORMS_HPP
diff --git a/websocketpp/common/random.hpp b/websocketpp/common/random.hpp
new file mode 100644
index 00000000..ddf99694
--- /dev/null
+++ b/websocketpp/common/random.hpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2014, Peter Thorson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the WebSocket++ Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef WEBSOCKETPP_COMMON_RANDOM_DEVICE_HPP
+#define WEBSOCKETPP_COMMON_RANDOM_DEVICE_HPP
+
+#include <websocketpp/common/cpp11.hpp>
+
+// If we've determined that we're in full C++11 mode and the user hasn't
+// explicitly disabled the use of C++11 random header, then prefer it to
+// boost.
+#if defined _WEBSOCKETPP_CPP11_INTERNAL_ && !defined _WEBSOCKETPP_NO_CPP11_RANDOM_DEVICE_
+ #ifndef _WEBSOCKETPP_CPP11_RANDOM_DEVICE_
+ #define _WEBSOCKETPP_CPP11_RANDOM_DEVICE_
+ #endif
+#endif
+
+
+// If we're on Visual Studio 2010 or higher and haven't explicitly disabled
+// the use of C++11 random header then prefer it to boost.
+#if defined(_MSC_VER) && _MSC_VER >= 1600 && !defined _WEBSOCKETPP_NO_CPP11_MEMORY_
+ #ifndef _WEBSOCKETPP_CPP11_MEMORY_
+ #define _WEBSOCKETPP_CPP11_MEMORY_
+ #endif
+#endif
+
+
+
+#ifdef _WEBSOCKETPP_CPP11_RANDOM_DEVICE_
+ #include <random>
+#else
+ #include <boost/version.hpp>
+
+ #if (BOOST_VERSION/100000) == 1 && ((BOOST_VERSION/100)%1000) > 46
+ #include <boost/random/uniform_int_distribution.hpp>
+ #include <boost/random/random_device.hpp>
+ #elif (BOOST_VERSION/100000) == 1 && ((BOOST_VERSION/100)%1000) >= 43
+ #include <boost/nondet_random.hpp>
+ #else
+ // TODO: static_assert(false, "Could not find a suitable random_device")
+ #endif
+#endif
+
+namespace websocketpp {
+namespace lib {
+
+#ifdef _WEBSOCKETPP_CPP11_RANDOM_DEVICE_
+ using std::random_device;
+ using std::uniform_int_distribution;
+#else
+ using boost::random::random_device;
+ using boost::random::uniform_int_distribution;
+#endif
+
+} // namespace lib
+} // namespace websocketpp
+
+#endif // WEBSOCKETPP_COMMON_RANDOM_DEVICE_HPP
diff --git a/websocketpp/common/regex.hpp b/websocketpp/common/regex.hpp
new file mode 100644
index 00000000..326635de
--- /dev/null
+++ b/websocketpp/common/regex.hpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2014, Peter Thorson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the WebSocket++ Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef WEBSOCKETPP_COMMON_REGEX_HPP
+#define WEBSOCKETPP_COMMON_REGEX_HPP
+
+#if defined _WEBSOCKETPP_CPP11_STL_ && !defined _WEBSOCKETPP_NO_CPP11_REGEX_
+ #ifndef _WEBSOCKETPP_CPP11_REGEX_
+ #define _WEBSOCKETPP_CPP11_REGEX_
+ #endif
+#endif
+
+#ifdef _WEBSOCKETPP_CPP11_REGEX_
+ #include <regex>
+#else
+ #include <boost/regex.hpp>
+#endif
+
+namespace websocketpp {
+namespace lib {
+
+#ifdef _WEBSOCKETPP_CPP11_REGEX_
+ using std::cmatch;
+ using std::regex;
+ using std::regex_match;
+#else
+ using boost::cmatch;
+ using boost::regex;
+ using boost::regex_match;
+#endif
+
+} // namespace lib
+} // namespace websocketpp
+
+#endif // WEBSOCKETPP_COMMON_REGEX_HPP
diff --git a/websocketpp/common/stdint.hpp b/websocketpp/common/stdint.hpp
new file mode 100644
index 00000000..ec48ea75
--- /dev/null
+++ b/websocketpp/common/stdint.hpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2014, Peter Thorson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the WebSocket++ Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef WEBSOCKETPP_COMMON_STDINT_HPP
+#define WEBSOCKETPP_COMMON_STDINT_HPP
+
+#ifndef __STDC_LIMIT_MACROS
+ #define __STDC_LIMIT_MACROS 1
+#endif
+
+#if defined (_WIN32) && defined (_MSC_VER) && (_MSC_VER < 1600)
+ #include <boost/cstdint.hpp>
+
+ using boost::int8_t;
+ using boost::int_least8_t;
+ using boost::int_fast8_t;
+ using boost::uint8_t;
+ using boost::uint_least8_t;
+ using boost::uint_fast8_t;
+
+ using boost::int16_t;
+ using boost::int_least16_t;
+ using boost::int_fast16_t;
+ using boost::uint16_t;
+ using boost::uint_least16_t;
+ using boost::uint_fast16_t;
+
+ using boost::int32_t;
+ using boost::int_least32_t;
+ using boost::int_fast32_t;
+ using boost::uint32_t;
+ using boost::uint_least32_t;
+ using boost::uint_fast32_t;
+
+ #ifndef BOOST_NO_INT64_T
+ using boost::int64_t;
+ using boost::int_least64_t;
+ using boost::int_fast64_t;
+ using boost::uint64_t;
+ using boost::uint_least64_t;
+ using boost::uint_fast64_t;
+ #endif
+ using boost::intmax_t;
+ using boost::uintmax_t;
+#else
+ #include <stdint.h>
+#endif
+
+#endif // WEBSOCKETPP_COMMON_STDINT_HPP
diff --git a/websocketpp/common/system_error.hpp b/websocketpp/common/system_error.hpp
new file mode 100644
index 00000000..e5aea254
--- /dev/null
+++ b/websocketpp/common/system_error.hpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2014, Peter Thorson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the WebSocket++ Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef WEBSOCKETPP_COMMON_SYSTEM_ERROR_HPP
+#define WEBSOCKETPP_COMMON_SYSTEM_ERROR_HPP
+
+
+#include <websocketpp/common/cpp11.hpp>
+
+// If we've determined that we're in full C++11 mode and the user hasn't
+// explicitly disabled the use of C++11 system_error header, then prefer it to
+// boost.
+#if defined _WEBSOCKETPP_CPP11_INTERNAL_ && !defined _WEBSOCKETPP_NO_CPP11_SYSTEM_ERROR_
+ #ifndef _WEBSOCKETPP_CPP11_SYSTEM_ERROR_
+ #define _WEBSOCKETPP_CPP11_SYSTEM_ERROR_
+ #endif
+#endif
+
+// If we're on Visual Studio 2010 or higher and haven't explicitly disabled
+// the use of C++11 system_error header then prefer it to boost.
+#if defined(_MSC_VER) && _MSC_VER >= 1600 && !defined _WEBSOCKETPP_NO_CPP11_SYSTEM_ERROR_
+ #ifndef _WEBSOCKETPP_CPP11_SYSTEM_ERROR_
+ #define _WEBSOCKETPP_CPP11_SYSTEM_ERROR_
+ #endif
+#endif
+
+
+
+#ifdef _WEBSOCKETPP_CPP11_SYSTEM_ERROR_
+ #include <system_error>
+#else
+ #include <boost/system/error_code.hpp>
+ #include <boost/system/system_error.hpp>
+#endif
+
+namespace websocketpp {
+namespace lib {
+
+#ifdef _WEBSOCKETPP_CPP11_SYSTEM_ERROR_
+ using std::errc;
+ using std::error_code;
+ using std::error_category;
+ using std::error_condition;
+ using std::system_error;
+ #define _WEBSOCKETPP_ERROR_CODE_ENUM_NS_START_ namespace std {
+ #define _WEBSOCKETPP_ERROR_CODE_ENUM_NS_END_ }
+#else
+ namespace errc = boost::system::errc;
+ using boost::system::error_code;
+ using boost::system::error_category;
+ using boost::system::error_condition;
+ using boost::system::system_error;
+ #define _WEBSOCKETPP_ERROR_CODE_ENUM_NS_START_ namespace boost { namespace system {
+ #define _WEBSOCKETPP_ERROR_CODE_ENUM_NS_END_ }}
+#endif
+
+} // namespace lib
+} // namespace websocketpp
+
+#endif // WEBSOCKETPP_COMMON_SYSTEM_ERROR_HPP
diff --git a/websocketpp/common/thread.hpp b/websocketpp/common/thread.hpp
new file mode 100644
index 00000000..09f6b3c5
--- /dev/null
+++ b/websocketpp/common/thread.hpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2015, Peter Thorson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the WebSocket++ Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef WEBSOCKETPP_COMMON_THREAD_HPP
+#define WEBSOCKETPP_COMMON_THREAD_HPP
+
+#include <websocketpp/common/cpp11.hpp>
+
+// If we autodetect C++11 and haven't been explicitly instructed to not use
+// C++11 threads, then set the defines that instructs the rest of this header
+// to use C++11 <thread> and <mutex>
+#if defined _WEBSOCKETPP_CPP11_INTERNAL_ && !defined _WEBSOCKETPP_NO_CPP11_THREAD_
+ // MinGW by default does not support C++11 thread/mutex so even if the
+ // internal check for C++11 passes, ignore it if we are on MinGW
+ #if (!defined(__MINGW32__) && !defined(__MINGW64__))
+ #ifndef _WEBSOCKETPP_CPP11_THREAD_
+ #define _WEBSOCKETPP_CPP11_THREAD_
+ #endif
+ #endif
+#endif
+
+// If we're on Visual Studio 2013 or higher and haven't explicitly disabled
+// the use of C++11 thread header then prefer it to boost.
+#if defined(_MSC_VER) && _MSC_VER >= 1800 && !defined _WEBSOCKETPP_NO_CPP11_THREAD_
+ #ifndef _WEBSOCKETPP_CPP11_THREAD_
+ #define _WEBSOCKETPP_CPP11_THREAD_
+ #endif
+#endif
+
+#ifdef _WEBSOCKETPP_CPP11_THREAD_
+ #include <thread>
+ #include <mutex>
+ #include <condition_variable>
+#else
+ #include <boost/thread.hpp>
+ #include <boost/thread/mutex.hpp>
+ #include <boost/thread/condition_variable.hpp>
+#endif
+
+namespace websocketpp {
+namespace lib {
+
+#ifdef _WEBSOCKETPP_CPP11_THREAD_
+ using std::mutex;
+ using std::lock_guard;
+ using std::thread;
+ using std::unique_lock;
+ using std::condition_variable;
+#else
+ using boost::mutex;
+ using boost::lock_guard;
+ using boost::thread;
+ using boost::unique_lock;
+ using boost::condition_variable;
+#endif
+
+} // namespace lib
+} // namespace websocketpp
+
+#endif // WEBSOCKETPP_COMMON_THREAD_HPP
diff --git a/websocketpp/common/time.hpp b/websocketpp/common/time.hpp
new file mode 100644
index 00000000..571688e1
--- /dev/null
+++ b/websocketpp/common/time.hpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2014, Peter Thorson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the WebSocket++ Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef WEBSOCKETPP_COMMON_TIME_HPP
+#define WEBSOCKETPP_COMMON_TIME_HPP
+
+#include <ctime>
+
+namespace websocketpp {
+namespace lib {
+
+// Code in this header was inspired by the following article and includes some
+// code from the related project g2log. The g2log code is public domain licensed
+// http://kjellkod.wordpress.com/2013/01/22/exploring-c11-part-2-localtime-and-time-again/
+
+/// Thread safe cross platform localtime
+inline std::tm localtime(std::time_t const & time) {
+ std::tm tm_snapshot;
+#if (defined(__MINGW32__) || defined(__MINGW64__))
+ memcpy(&tm_snapshot, ::localtime(&time), sizeof(std::tm));
+#elif (defined(WIN32) || defined(_WIN32) || defined(__WIN32__))
+ localtime_s(&tm_snapshot, &time);
+#else
+ localtime_r(&time, &tm_snapshot); // POSIX
+#endif
+ return tm_snapshot;
+}
+
+} // lib
+} // websocketpp
+
+#endif // WEBSOCKETPP_COMMON_TIME_HPP
diff --git a/websocketpp/common/type_traits.hpp b/websocketpp/common/type_traits.hpp
new file mode 100644
index 00000000..c89b82b3
--- /dev/null
+++ b/websocketpp/common/type_traits.hpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2015, Peter Thorson. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the WebSocket++ Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef WEBSOCKETPP_COMMON_TYPE_TRAITS_HPP
+#define WEBSOCKETPP_COMMON_TYPE_TRAITS_HPP
+
+#include <websocketpp/common/cpp11.hpp>
+
+// If we've determined that we're in full C++11 mode and the user hasn't
+// explicitly disabled the use of C++11 functional header, then prefer it to
+// boost.
+#if defined _WEBSOCKETPP_CPP11_INTERNAL_ && !defined _WEBSOCKETPP_NO_CPP11_TYPE_TRAITS_
+ #ifndef _WEBSOCKETPP_CPP11_TYPE_TRAITS_
+ #define _WEBSOCKETPP_CPP11_TYPE_TRAITS_
+ #endif
+#endif
+
+
+#ifdef _WEBSOCKETPP_CPP11_TYPE_TRAITS_
+ #include <type_traits>
+#else
+ #include <boost/aligned_storage.hpp>
+#endif
+
+
+
+namespace websocketpp {
+namespace lib {
+
+#ifdef _WEBSOCKETPP_CPP11_TYPE_TRAITS_
+ using std::aligned_storage;
+ using std::is_same;
+#else
+ using boost::aligned_storage;
+ using boost::is_same;
+#endif
+
+} // namespace lib
+} // namespace websocketpp
+
+#endif // WEBSOCKETPP_COMMON_TYPE_TRAITS_HPP