diff --git a/.gitignore b/.gitignore
index 20a3894a65..0b1472706b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,8 @@
.DS_Store
/build
/tags
+.idea
+.ycm_extra_conf.py
+.ycm_extra_conf.pyc
+Release
+Debug
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 243001d1d2..ee849afabe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,38 +4,58 @@ set(VERSION "0.1")
# $Format:Packaged from commit %H%nset(COMMIT %h)%nset(REFS "%d")$
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
-set(CMAKE_CONFIGURATION_TYPES "Debug;Release")
+set(CMAKE_CONFIGURATION_TYPES Debug RelWithDebInfo Release CACHE TYPE INTERNAL)
+set(CMAKE_SKIP_INSTALL_RULES ON)
+set(CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY ON)
+set(CMAKE_SUPPRESS_REGENERATION ON)
enable_testing()
+# copy CTestCustom.cmake to build dir to disable long running tests in 'make test'
+configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_BINARY_DIR})
-include_directories(include src contrib/epee/include external "${CMAKE_BINARY_DIR}/version")
+project(DigitalNote)
+
+include_directories(include src external "${CMAKE_BINARY_DIR}/version")
if(APPLE)
include_directories(SYSTEM /usr/include/malloc)
+ enable_language(ASM)
+endif()
+
+if(MSVC)
+include_directories(src/Platform/Windows)
+elseif(APPLE)
+include_directories(src/Platform/OSX)
+else()
+include_directories(src/Platform/Linux)
endif()
set(STATIC ${MSVC} CACHE BOOL "Link libraries statically")
if(MSVC)
- add_definitions("/bigobj /MP /W3 /GS- /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4345 /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0 /D_VARIADIC_MAX=8 /FIinline_c.h /D__SSE4_1__")
- # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Dinline=__inline")
+ add_definitions("/bigobj /MP /W3 /GS- /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4345 /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0 /D_VARIADIC_MAX=8 /D__SSE4_1__")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10485760")
if(STATIC)
- foreach(VAR CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+ foreach(VAR CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE)
string(REPLACE "/MD" "/MT" ${VAR} "${${VAR}}")
endforeach()
endif()
include_directories(SYSTEM src/platform/msc)
else()
+ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
+ # This option has no effect in glibc version less than 2.20.
+ # Since glibc 2.20 _BSD_SOURCE is deprecated, this macro is recomended instead
+ add_definitions("-D_DEFAULT_SOURCE -D_GNU_SOURCE")
+ endif()
set(ARCH native CACHE STRING "CPU to build for: -march value or default")
if("${ARCH}" STREQUAL "default")
set(ARCH_FLAG "")
else()
set(ARCH_FLAG "-march=${ARCH}")
endif()
- set(WARNINGS "-Wall -Wextra -Wpointer-arith -Wundef -Wvla -Wwrite-strings -Werror -Wno-error=extra -Wno-error=deprecated-declarations -Wno-error=sign-compare -Wno-error=strict-aliasing -Wno-error=type-limits -Wno-unused-parameter -Wno-error=unused-variable -Wno-error=undef -Wno-error=uninitialized")
+ set(WARNINGS "-Wall -Wextra -Wpointer-arith -Wundef -Wvla -Wwrite-strings -Werror -Wno-error=extra -Wno-error=unused-function -Wno-error=deprecated-declarations -Wno-error=sign-compare -Wno-error=strict-aliasing -Wno-error=type-limits -Wno-unused-parameter -Wno-error=unused-variable -Wno-error=undef -Wno-error=uninitialized -Wno-error=unused-result")
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
- set(WARNINGS "${WARNINGS} -Wno-error=mismatched-tags -Wno-error=null-conversion -Wno-overloaded-shift-op-parentheses -Wno-error=shift-count-overflow -Wno-error=tautological-constant-out-of-range-compare -Wno-error=unused-private-field -Wno-error=unneeded-internal-declaration")
+ set(WARNINGS "${WARNINGS} -Wno-error=mismatched-tags -Wno-error=null-conversion -Wno-overloaded-shift-op-parentheses -Wno-error=shift-count-overflow -Wno-error=tautological-constant-out-of-range-compare -Wno-error=unused-private-field -Wno-error=unneeded-internal-declaration -Wno-error=unused-function")
else()
- set(WARNINGS "${WARNINGS} -Wlogical-op -Wno-error=maybe-uninitialized")
+ set(WARNINGS "${WARNINGS} -Wlogical-op -Wno-error=maybe-uninitialized -Wno-error=clobbered -Wno-error=unused-but-set-variable")
endif()
if(MINGW)
set(WARNINGS "${WARNINGS} -Wno-error=unused-value")
@@ -44,16 +64,16 @@ else()
else()
set(MINGW_FLAG "")
endif()
+ if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_C_COMPILER_VERSION VERSION_LESS 5.1))
+ set(WARNINGS "${WARNINGS} -Wno-error=odr")
+ endif()
set(C_WARNINGS "-Waggregate-return -Wnested-externs -Wold-style-definition -Wstrict-prototypes")
set(CXX_WARNINGS "-Wno-reorder -Wno-missing-field-initializers")
- try_compile(STATIC_ASSERT_RES "${CMAKE_CURRENT_BINARY_DIR}/static-assert" "${CMAKE_CURRENT_SOURCE_DIR}/utils/test-static-assert.c" COMPILE_DEFINITIONS "-std=c11")
- if(STATIC_ASSERT_RES)
- set(STATIC_ASSERT_FLAG "")
- else()
- set(STATIC_ASSERT_FLAG "-Dstatic_assert=_Static_assert")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 ${MINGW_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG} -maes")
+ if(NOT APPLE)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
endif()
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG} -maes")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_GNU_SOURCE ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG} -maes")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG} -maes")
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGTEST_HAS_TR1_TUPLE=0")
endif()
@@ -65,6 +85,12 @@ else()
set(RELEASE_FLAGS "-Ofast -DNDEBUG -Wno-unused-variable")
if(NOT APPLE)
# There is a clang bug that does not allow to compile code that uses AES-NI intrinsics if -flto is enabled
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux"
+ AND CMAKE_BUILD_TYPE STREQUAL "Release" AND ((CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.9) OR (CMAKE_C_COMPILER_VERSION VERSION_EQUAL 4.9)))
+ # On linux, to build in lto mode, check that ld.gold linker is used: 'update-alternatives --install /usr/bin/ld ld /usr/bin/ld.gold HIGHEST_PRIORITY'
+ set(CMAKE_AR gcc-ar)
+ set(CMAKE_RANLIB gcc-ranlib)
+ endif()
set(RELEASE_FLAGS "${RELEASE_FLAGS} -flto")
endif()
#if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT MINGW)
@@ -83,10 +109,7 @@ if(STATIC)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME ON)
endif()
-find_package(Boost 1.53 REQUIRED COMPONENTS system filesystem thread date_time chrono regex serialization program_options)
-if((${Boost_MAJOR_VERSION} EQUAL 1) AND (${Boost_MINOR_VERSION} EQUAL 54))
- message(SEND_ERROR "Boost version 1.54 is unsupported, more details are available here http://goo.gl/RrCFmA")
-endif()
+find_package(Boost 1.55 REQUIRED COMPONENTS system filesystem thread date_time chrono regex serialization program_options)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
if(MINGW)
set(Boost_LIBRARIES "${Boost_LIBRARIES};ws2_32;mswsock")
@@ -122,7 +145,6 @@ else()
endif()
endif()
-add_subdirectory(contrib)
add_subdirectory(external)
add_subdirectory(src)
add_subdirectory(tests)
diff --git a/CTestCustom.cmake b/CTestCustom.cmake
new file mode 100644
index 0000000000..088261fad1
--- /dev/null
+++ b/CTestCustom.cmake
@@ -0,0 +1,11 @@
+set(CTEST_CUSTOM_TESTS_IGNORE
+ CoreTests
+ IntegrationTestLibrary
+ TestGenerator
+ CryptoTests
+ IntegrationTests
+ NodeRpcProxyTests
+ PerformanceTests
+ TransfersTests
+ )
+
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 65c5ca88a6..0000000000
--- a/LICENSE
+++ /dev/null
@@ -1,165 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/README b/README
deleted file mode 100644
index 87a89c5871..0000000000
--- a/README
+++ /dev/null
@@ -1,32 +0,0 @@
--= Building CryptoNote =-
-
-On *nix:
-
-Dependencies: GCC 4.7.3 or later, CMake 2.8.6 or later, and Boost 1.53 or later (except 1.54, more details here: http://goo.gl/RrCFmA).
-You may download them from:
-http://gcc.gnu.org/
-http://www.cmake.org/
-http://www.boost.org/
-Alternatively, it may be possible to install them using a package manager.
-
-To build, change to a directory where this file is located, and run `make'. The resulting executables can be found in build/release/src.
-
-Advanced options:
-Parallel build: run `make -j' instead of `make'.
-Debug build: run `make build-debug'.
-Test suite: run `make test-release' to run tests in addition to building. Running `make test-debug' will do the same to the debug version.
-Building with Clang: it may be possible to use Clang instead of GCC, but this may not work everywhere. To build, run `export CC=clang CXX=clang++' before running `make'.
-
-On Windows:
-Dependencies: MSVC 2012 or later, CMake 2.8.6 or later, and Boost 1.53 or later. You may download them from:
-http://www.microsoft.com/
-http://www.cmake.org/
-http://www.boost.org/
-
-To build, change to a directory where this file is located, and run this commands:
-mkdir build
-cd build
-cmake -G "Visual Studio 11 Win64" ..
-
-And then do Build.
-Good luck!
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000000..9eb7170327
--- /dev/null
+++ b/README.md
@@ -0,0 +1,43 @@
+## Building DigitalNote
+
+### On *nix:
+
+Dependencies: GCC 4.7.3 or later, CMake 2.8.6 or later, and Boost 1.55 or later.
+
+You may download them from:
+
+- http://gcc.gnu.org/
+- http://www.cmake.org/
+- http://www.boost.org/
+
+Alternatively, it may be possible to install them using a package manager.
+
+To build, change to a directory where this file is located, and run `make`. The resulting executables can be found in `build/release/src`.
+
+#### Advanced options:
+
+Parallel build: run `make -j` instead of `make`.
+
+Debug build: run `make build-debug`.
+
+Test suite: run `make test-release` to run tests in addition to building. Running `make test-debug` will do the same to the debug version.
+
+Building with Clang: it may be possible to use Clang instead of GCC, but this may not work everywhere. To build, run `export CC=clang CXX=clang++` before running `make`.
+
+### On Windows:
+Dependencies: MSVC 2013 or later, CMake 2.8.6 or later, and Boost 1.55 or later. You may download them from:
+
+- http://www.microsoft.com/
+- http://www.cmake.org/
+- http://www.boost.org/
+
+To build, change to a directory where this file is located, and run this commands:
+```
+mkdir build
+cd build
+cmake -G "Visual Studio 12 Win64" ..
+```
+
+And then do Build.
+
+Good luck!
diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt
index fb8883979b..95246c1590 100644
--- a/ReleaseNotes.txt
+++ b/ReleaseNotes.txt
@@ -1,3 +1,51 @@
+Release notes 4.0.3-beta
+
+- Blockchain synchronization improvements
+
+Release notes 4.0.2-beta
+
+- Latest checkpoints and fixes
+
+Release notes 4.0.1-beta
+
+- Default block size updated to 200Kb to avoid any unconfirmed transactions
+- Mining update
+
+Release notes 4.0.0-beta
+
+- Empowering XDN network security with merged mining with any CryptoNote cryptocurrency
+- Second step to the PoA with the new type of PoW merged mining blocks
+
+Release notes 3.1.0-beta
+
+- Messages 2.0 core support
+- Messages API for simplewallet
+- Basic access authentication
+
+Release notes 3.0.0-beta
+
+- New industrial type wallet for services: walletd
+- New RPC-API for walletd
+- XDN addresses for services and processing centers: multi-addresses. Can use instead of Payment ID, like Bitcoin
+- Transactions pool synchronization
+- Network layer refactoring
+- Extra high wallet synchronization speed
+- New multithreading library
+- Improved console logging
+
+Release notes 2.0.0-beta
+
+- DigitalNote
+- Multisignatures with API
+- Deposits based on multisignatures
+
+- Low level API
+- High level API improvements
+- Instant transaction pool notifications
+- Refactored simplewallet
+- Optimization in daemon RAM consumption
+- Minor network health updates
+
Release notes 1.0.2
- JSON RPC for encrypted messages
diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt
deleted file mode 100644
index 7222cce5ee..0000000000
--- a/contrib/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-file(GLOB_RECURSE EPEE epee/include/*)
-
-source_group(epee FILES ${EPEE})
-
-add_library(epee ${EPEE})
-
-set_property(TARGET epee PROPERTY FOLDER "external")
diff --git a/contrib/epee/LICENSE.txt b/contrib/epee/LICENSE.txt
deleted file mode 100644
index 4a6b529e5d..0000000000
--- a/contrib/epee/LICENSE.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
-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 Andrey N. Sabelnikov 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 Andrey N. Sabelnikov 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.
\ No newline at end of file
diff --git a/contrib/epee/README.md b/contrib/epee/README.md
deleted file mode 100644
index a69884f570..0000000000
--- a/contrib/epee/README.md
+++ /dev/null
@@ -1 +0,0 @@
-epee - is a small library of helpers, wrappers, tools and and so on, used to make my life easier.
\ No newline at end of file
diff --git a/contrib/epee/demo/.gitignore b/contrib/epee/demo/.gitignore
deleted file mode 100644
index d9b4f015d3..0000000000
--- a/contrib/epee/demo/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build/*
diff --git a/contrib/epee/demo/CMakeLists.txt b/contrib/epee/demo/CMakeLists.txt
deleted file mode 100644
index b4ac2cc8ba..0000000000
--- a/contrib/epee/demo/CMakeLists.txt
+++ /dev/null
@@ -1,49 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-set(Boost_USE_MULTITHREADED ON)
-#set(Boost_DEBUG 1)
-find_package(Boost COMPONENTS system filesystem thread date_time chrono regex )
-
-include_directories( ${Boost_INCLUDE_DIRS} )
-
-
-IF (MSVC)
- add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4345 /nologo /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /bigobj" )
-ELSE()
- # set stuff for other systems
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wno-reorder -D_GNU_SOURCE")
-ENDIF()
-
-
-include_directories(.)
-include_directories(../include)
-include_directories(iface)
-
-
-# Add folders to filters
-file(GLOB_RECURSE LEVIN_GENERAL_SECTION RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}/demo_levin_server/*.h
- ${CMAKE_CURRENT_SOURCE_DIR}/demo_levin_server/*.inl
- ${CMAKE_CURRENT_SOURCE_DIR}/demo_levin_server/*.cpp)
-
-file(GLOB_RECURSE HTTP_GENERAL_SECTION RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}/demo_http_server/*.h
- ${CMAKE_CURRENT_SOURCE_DIR}/demo_http_server/*.inl
- ${CMAKE_CURRENT_SOURCE_DIR}/demo_http_server/*.cpp)
-
-
-
-source_group(general FILES ${LEVIN_GENERAL_SECTION} FILES ${HTTP_GENERAL_SECTION})
-#source_group(general FILES ${HTTP_GENERAL_SECTION})
-
-add_executable(demo_http_server ${HTTP_GENERAL_SECTION} )
-add_executable(demo_levin_server ${LEVIN_GENERAL_SECTION} )
-
-target_link_libraries( demo_http_server ${Boost_LIBRARIES} )
-target_link_libraries( demo_levin_server ${Boost_LIBRARIES} )
-
-IF (NOT WIN32)
- target_link_libraries (demo_http_server rt)
- target_link_libraries (demo_levin_server rt)
-ENDIF()
-
-
diff --git a/contrib/epee/demo/README.txt b/contrib/epee/demo/README.txt
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/contrib/epee/demo/demo_http_server/demo_http_server.cpp b/contrib/epee/demo/demo_http_server/demo_http_server.cpp
deleted file mode 100644
index 85547e4c9e..0000000000
--- a/contrib/epee/demo/demo_http_server/demo_http_server.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
-// 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 Andrey N. Sabelnikov 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 THE COPYRIGHT OWNER BE LIABLE FOR ANY
-// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-
-#include "stdafx.h"
-#include "console_handler.h"
-#include "demo_http_server.h"
-#include "net/http_client.h"
-#include "storages/http_abstract_invoke.h"
-
-
-template
-bool communicate(const std::string url, t_request& req, t_response& rsp, const std::string& ip, const std::string& port, bool use_json, bool use_jrpc = false)
-{
- epee::net_utils::http::http_simple_client http_client;
- bool r = http_client.connect(ip, port, 1000);
- CHECK_AND_ASSERT_MES(r, false, "failed to connect");
- if(use_json)
- {
- if(use_jrpc)
- {
- epee::json_rpc::request req_t = AUTO_VAL_INIT(req_t);
- req_t.jsonrpc = "2.0";
- req_t.id = epee::serialization::storage_entry(10);
- req_t.method = "command_example_1";
- req_t.params = req;
- epee::json_rpc::response resp_t = AUTO_VAL_INIT(resp_t);
- if(!epee::net_utils::invoke_http_json_remote_command2("/request_json_rpc", req_t, resp_t, http_client))
- {
- return false;
- }
- rsp = resp_t.result;
- return true;
- }else
- return epee::net_utils::invoke_http_json_remote_command2(url, req, rsp, http_client);
- }
- else
- return epee::net_utils::invoke_http_bin_remote_command2(url, req, rsp, http_client);
-}
-
-
-int main(int argc, char* argv[])
-{
- TRY_ENTRY();
- string_tools::set_module_name_and_folder(argv[0]);
-
- //set up logging options
- log_space::get_set_log_detalisation_level(true, LOG_LEVEL_2);
- log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL);
- log_space::log_singletone::add_logger(LOGGER_FILE,
- log_space::log_singletone::get_default_log_file().c_str(),
- log_space::log_singletone::get_default_log_folder().c_str());
-
-
-
- LOG_PRINT("Demo server starting ...", LOG_LEVEL_0);
-
-
- demo::demo_http_server srv;
-
- start_default_console(&srv, "#");
-
- std::string bind_param = "0.0.0.0";
- std::string port = "83";
-
- if(!srv.init(port, bind_param))
- {
- LOG_ERROR("Failed to initialize srv!");
- return 1;
- }
-
- //log loop
- srv.run();
- size_t count = 0;
- while (!srv.is_stop())
- {
-
- demo::COMMAND_EXAMPLE_1::request req;
- req.sub = demo::get_test_data();
- demo::COMMAND_EXAMPLE_1::response rsp;
- bool r = false;
- if(count%2)
- {//invoke json
- r = communicate("/request_api_json_1", req, rsp, "127.0.0.1", port, true, true);
- }else{
- r = communicate("/request_api_bin_1", req, rsp, "127.0.0.1", port, false);
- }
- CHECK_AND_ASSERT_MES(r, false, "failed to invoke http request");
- CHECK_AND_ASSERT_MES(rsp.m_success, false, "wrong response");
- CHECK_AND_ASSERT_MES(rsp.subs.size()==1, false, "wrong response");
- CHECK_AND_ASSERT_MES(rsp.subs.front() == demo::get_test_data(), false, "wrong response");
- //misc_utils::sleep_no_w(1000);
- ++count;
- }
- bool r = srv.wait_stop();
- CHECK_AND_ASSERT_MES(r, 1, "failed to wait server stop");
- srv.deinit();
-
- LOG_PRINT("Demo server stoped.", LOG_LEVEL_0);
- return 1;
-
- CATCH_ENTRY_L0("main", 1);
-}
-
-/************************************************************************/
-/* */
-/************************************************************************/
-namespace demo
-{
- bool demo_http_server::init(const std::string& bind_port, const std::string& bind_ip)
- {
-
-
- //set self as callback handler
- m_net_server.get_config_object().m_phandler = this;
-
- //here set folder for hosting reqests
- m_net_server.get_config_object().m_folder = "";
-
- LOG_PRINT_L0("Binding on " << bind_ip << ":" << bind_port);
- return m_net_server.init_server(bind_port, bind_ip);
- }
-
- bool demo_http_server::run()
- {
- m_stop = false;
- //here you can set worker threads count
- int thrds_count = 4;
-
- //go to loop
- LOG_PRINT("Run net_service loop( " << thrds_count << " threads)...", LOG_LEVEL_0);
- if(!m_net_server.run_server(thrds_count, false))
- {
- LOG_ERROR("Failed to run net tcp server!");
- }
-
- return true;
- }
-
- bool demo_http_server::deinit()
- {
- return m_net_server.deinit_server();
- }
-
- bool demo_http_server::send_stop_signal()
- {
- m_stop = true;
- m_net_server.send_stop_signal();
- return true;
- }
-
- bool demo_http_server::on_requestr_uri_1(const net_utils::http::http_request_info& query_info,
- net_utils::http::http_response_info& response,
- const net_utils::connection_context_base& m_conn_context)
- {
- return true;
- }
-
-
- bool demo_http_server::on_requestr_uri_2(const net_utils::http::http_request_info& query_info,
- net_utils::http::http_response_info& response,
- const net_utils::connection_context_base& m_conn_context)
- {
- return true;
- }
-
-
- bool demo_http_server::on_hosting_request( const net_utils::http::http_request_info& query_info,
- net_utils::http::http_response_info& response,
- const net_utils::connection_context_base& m_conn_context)
- {
- //read file from filesystem here
- return true;
- }
-
- bool demo_http_server::on_request_api_1(const COMMAND_EXAMPLE_1::request& req, COMMAND_EXAMPLE_1::response& res, connection_context& ctxt)
- {
- CHECK_AND_ASSERT_MES(req.sub == demo::get_test_data(), false, "wrong request");
- res.m_success = true;
- res.subs.push_back(req.sub);
- return true;
- }
-
- bool demo_http_server::on_request_api_1_with_error(const COMMAND_EXAMPLE_1::request& req, COMMAND_EXAMPLE_1::response& res, epee::json_rpc::error& error_resp, connection_context& ctxt)
- {
- error_resp.code = 232432;
- error_resp.message = "bla bla bla";
- return false;
- }
-
- bool demo_http_server::on_request_api_2(const COMMAND_EXAMPLE_2::request& req, COMMAND_EXAMPLE_2::response& res, connection_context& ctxt)
- {
- return true;
- }
-}
diff --git a/contrib/epee/demo/demo_http_server/demo_http_server.h b/contrib/epee/demo/demo_http_server/demo_http_server.h
deleted file mode 100644
index 088ead548e..0000000000
--- a/contrib/epee/demo/demo_http_server/demo_http_server.h
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
-// 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 Andrey N. Sabelnikov 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 THE COPYRIGHT OWNER 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.
-//
-
-
-
-#pragma once
-#include
-#include
-
-#include "net/http_server_cp2.h"
-#include "transport_defs.h"
-#include "net/http_server_handlers_map2.h"
-
-using namespace epee;
-
-namespace demo
-{
-
- class demo_http_server: public net_utils::http::i_http_server_handler
- {
- public:
- typedef epee::net_utils::connection_context_base connection_context;
-
- demo_http_server():m_stop(false){}
- bool run();
- bool init(const std::string& bind_port = "11112", const std::string& bind_ip = "0.0.0.0");
- bool deinit();
- bool send_stop_signal();
- bool is_stop(){return m_stop;}
- bool wait_stop(){return m_net_server.timed_wait_server_stop(100000);}
- private:
-
-
- CHAIN_HTTP_TO_MAP2(connection_context); //forward http requests to uri map
-
- BEGIN_URI_MAP2()
- MAP_URI2("/requestr_uri_1", on_requestr_uri_1)
- MAP_URI2("/requestr_uri_2", on_requestr_uri_1)
- //MAP_URI_AUTO_XML2("/request_api_xml_1", on_request_api_1, COMMAND_EXAMPLE_1)
- //MAP_URI_AUTO_XML2("/request_api_xml_2", on_request_api_2, COMMAND_EXAMPLE_2)
- MAP_URI_AUTO_JON2("/request_api_json_1", on_request_api_1, COMMAND_EXAMPLE_1)
- MAP_URI_AUTO_JON2("/request_api_json_2", on_request_api_2, COMMAND_EXAMPLE_2)
- MAP_URI_AUTO_BIN2("/request_api_bin_1", on_request_api_1, COMMAND_EXAMPLE_1)
- MAP_URI_AUTO_BIN2("/request_api_bin_2", on_request_api_2, COMMAND_EXAMPLE_2)
- BEGIN_JSON_RPC_MAP("/request_json_rpc")
- MAP_JON_RPC("command_example_1", on_request_api_1, COMMAND_EXAMPLE_1)
- MAP_JON_RPC("command_example_2", on_request_api_2, COMMAND_EXAMPLE_2)
- MAP_JON_RPC_WE("command_example_1_we", on_request_api_1_with_error, COMMAND_EXAMPLE_1)
- END_JSON_RPC_MAP()
- CHAIN_URI_MAP2(on_hosting_request)
- END_URI_MAP2()
-
-
-
- bool on_requestr_uri_1(const net_utils::http::http_request_info& query_info,
- net_utils::http::http_response_info& response,
- const net_utils::connection_context_base& m_conn_context);
-
-
- bool on_requestr_uri_2(const net_utils::http::http_request_info& query_info,
- net_utils::http::http_response_info& response,
- const net_utils::connection_context_base& m_conn_context);
-
-
-
-
- bool on_hosting_request( const net_utils::http::http_request_info& query_info,
- net_utils::http::http_response_info& response,
- const net_utils::connection_context_base& m_conn_context);
-
- bool on_request_api_1(const COMMAND_EXAMPLE_1::request& req, COMMAND_EXAMPLE_1::response& res, connection_context& ctxt);
- bool on_request_api_2(const COMMAND_EXAMPLE_2::request& req, COMMAND_EXAMPLE_2::response& res, connection_context& ctxt);
-
- bool on_request_api_1_with_error(const COMMAND_EXAMPLE_1::request& req, COMMAND_EXAMPLE_1::response& res, epee::json_rpc::error& error_resp, connection_context& ctxt);
-
- net_utils::boosted_http_server_custum_handling m_net_server;
- std::atomic m_stop;
- };
-}
-
diff --git a/contrib/epee/demo/demo_http_server/stdafx.cpp b/contrib/epee/demo/demo_http_server/stdafx.cpp
deleted file mode 100644
index ecec246572..0000000000
--- a/contrib/epee/demo/demo_http_server/stdafx.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-// stdafx.cpp : source file that includes just the standard includes
-// demo_http_server.pch will be the pre-compiled header
-// stdafx.obj will contain the pre-compiled type information
-
-#include "stdafx.h"
-
-// TODO: reference any additional headers you need in STDAFX.H
-// and not in this file
diff --git a/contrib/epee/demo/demo_http_server/stdafx.h b/contrib/epee/demo/demo_http_server/stdafx.h
deleted file mode 100644
index e288832024..0000000000
--- a/contrib/epee/demo/demo_http_server/stdafx.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
-// 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 Andrey N. Sabelnikov 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 THE COPYRIGHT OWNER 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.
-//
-
-
-#pragma once
-
-#include "targetver.h"
-
-
-#include
-
-
-#define BOOST_FILESYSTEM_VERSION 3
-#define ENABLE_RELEASE_LOGGING
-#include "misc_log_ex.h"
-
-
diff --git a/contrib/epee/demo/demo_http_server/targetver.h b/contrib/epee/demo/demo_http_server/targetver.h
deleted file mode 100644
index 6fe8eb79e1..0000000000
--- a/contrib/epee/demo/demo_http_server/targetver.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#pragma once
-
-// The following macros define the minimum required platform. The minimum required platform
-// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
-// your application. The macros work by enabling all features available on platform versions up to and
-// including the version specified.
-
-// Modify the following defines if you have to target a platform prior to the ones specified below.
-// Refer to MSDN for the latest info on corresponding values for different platforms.
-#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
-#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
-#endif
-
diff --git a/contrib/epee/demo/demo_levin_server/demo_levin_server.cpp b/contrib/epee/demo/demo_levin_server/demo_levin_server.cpp
deleted file mode 100644
index a99a1f564c..0000000000
--- a/contrib/epee/demo/demo_levin_server/demo_levin_server.cpp
+++ /dev/null
@@ -1,200 +0,0 @@
-// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
-// 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 Andrey N. Sabelnikov 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 THE COPYRIGHT OWNER BE LIABLE FOR ANY
-// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-
-
-
-#include "stdafx.h"
-#include "demo_levin_server.h"
-#include "console_handler.h"
-
-
-template
-bool communicate(net_utils::boosted_levin_async_server& transport, int id, t_request& req, const std::string& ip, const std::string& port, bool use_async)
-{
- if(use_async)
- {
- //IMPORTANT: do not pass local parameters from stack by reference! connect_async returns immediately, and callback will call in any thread later
- transport.connect_async(ip, port, 10000, [&transport, id, req, ip, port](net_utils::connection_context_base& ctx, const boost::system::error_code& ec_)
- {
- if(!!ec_)
- {
- LOG_ERROR("Failed to connect to " << ip << ":" << port);
- }else
- {//connected ok!
-
- epee::net_utils::async_invoke_remote_command2(ctx.m_connection_id, id, req, transport.get_config_object(), [&transport, ip, port](int res_code, demo::COMMAND_EXAMPLE_1::response& rsp, net_utils::connection_context_base& ctx)
- {
- if(res_code < 0)
- {
- LOG_ERROR("Failed to invoke to " << ip << ":" << port);
- }else
- {//invoked ok
- CHECK_AND_ASSERT_MES(rsp.m_success, false, "wrong response");
- CHECK_AND_ASSERT_MES(rsp.subs.size()==1, false, "wrong response");
- CHECK_AND_ASSERT_MES(rsp.subs.front() == demo::get_test_data(), false, "wrong response");
- LOG_PRINT_GREEN("Client COMMAND_EXAMPLE_1 async invoked ok", LOG_LEVEL_0);
- }
- transport.get_config_object().close(ctx.m_connection_id);
- return true;
- });
- LOG_PRINT_GREEN("Client COMMAND_EXAMPLE_1 async invoke requested", LOG_LEVEL_0);
- }
- });
- }else
- {
- net_utils::connection_context_base ctx = AUTO_VAL_INIT(ctx);
- bool r = transport.connect(ip, port, 10000, ctx);
- CHECK_AND_ASSERT_MES(r, false, "failed to connect to " << ip << ":" << port);
- demo::COMMAND_EXAMPLE_1::response rsp = AUTO_VAL_INIT(rsp);
- LOG_PRINT_GREEN("Client COMMAND_EXAMPLE_1 sync invoke requested", LOG_LEVEL_0);
- r = epee::net_utils::invoke_remote_command2(ctx.m_connection_id, id, req, rsp, transport.get_config_object());
- CHECK_AND_ASSERT_MES(r, false, "failed to invoke levin request");
- CHECK_AND_ASSERT_MES(rsp.m_success, false, "wrong response");
- CHECK_AND_ASSERT_MES(rsp.subs.size()==1, false, "wrong response");
- CHECK_AND_ASSERT_MES(rsp.subs.front() == demo::get_test_data(), false, "wrong response");
- transport.get_config_object().close(ctx.m_connection_id);
- LOG_PRINT_GREEN("Client COMMAND_EXAMPLE_1 sync invoked ok", LOG_LEVEL_0);
- }
- return true;
-}
-
-
-int main(int argc, char* argv[])
-{
- TRY_ENTRY();
- string_tools::set_module_name_and_folder(argv[0]);
-
- //set up logging options
- log_space::get_set_log_detalisation_level(true, LOG_LEVEL_2);
- log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL);
- log_space::log_singletone::add_logger(LOGGER_FILE,
- log_space::log_singletone::get_default_log_file().c_str(),
- log_space::log_singletone::get_default_log_folder().c_str());
-
-
-
- LOG_PRINT("Demo server starting ...", LOG_LEVEL_0);
-
-
- demo::demo_levin_server srv;
-
- start_default_console(&srv, "#");
-
- std::string bind_param = "0.0.0.0";
- std::string port = "12345";
-
- if(!srv.init(port, bind_param))
- {
- LOG_ERROR("Failed to initialize srv!");
- return 1;
- }
-
- srv.run();
-
- size_t c = 1;
- while (!srv.is_stop())
- {
-
- demo::COMMAND_EXAMPLE_1::request req;
- req.sub = demo::get_test_data();
- bool r = communicate(srv.get_server(), demo::COMMAND_EXAMPLE_1::ID, req, "127.0.0.1", port, (c%2 == 0));
- misc_utils::sleep_no_w(1000);
- ++c;
- }
- bool r = srv.wait_stop();
- CHECK_AND_ASSERT_MES(r, 1, "failed to wait server stop");
-
-
- srv.deinit();
-
- LOG_PRINT("Demo server stoped.", LOG_LEVEL_0);
- return 1;
-
- CATCH_ENTRY_L0("main", 1);
-}
-
-/************************************************************************/
-/* */
-/************************************************************************/
-namespace demo
-{
- bool demo_levin_server::init(const std::string& bind_port, const std::string& bind_ip)
- {
- m_net_server.get_config_object().m_pcommands_handler = this;
- LOG_PRINT_L0("Binding on " << bind_ip << ":" << bind_port);
- return m_net_server.init_server(bind_port, bind_ip);
- }
-
- bool demo_levin_server::run()
- {
- m_stop = false;
- //here you can set worker threads count
- int thrds_count = 4;
- m_net_server.get_config_object().m_invoke_timeout = 10000;
- m_net_server.get_config_object().m_pcommands_handler = this;
-
- //go to loop
- LOG_PRINT("Run net_service loop( " << thrds_count << " threads)...", LOG_LEVEL_0);
- if(!m_net_server.run_server(thrds_count, false))
- {
- LOG_ERROR("Failed to run net tcp server!");
- }
-
- LOG_PRINT("net_service loop stopped.", LOG_LEVEL_0);
- return true;
- }
-
- bool demo_levin_server::deinit()
- {
- return m_net_server.deinit_server();
- }
-
- bool demo_levin_server::send_stop_signal()
- {
- m_net_server.send_stop_signal();
- return true;
- }
- int demo_levin_server::handle_command_1(int command, COMMAND_EXAMPLE_1::request& arg, COMMAND_EXAMPLE_1::response& rsp, const net_utils::connection_context_base& context)
- {
- CHECK_AND_ASSERT_MES(arg.sub == demo::get_test_data(), false, "wrong request");
- rsp.m_success = true;
- rsp.subs.push_back(arg.sub);
- LOG_PRINT_GREEN("Server COMMAND_EXAMPLE_1 ok", LOG_LEVEL_0);
- return 1;
- }
- int demo_levin_server::handle_command_2(int command, COMMAND_EXAMPLE_2::request& arg, COMMAND_EXAMPLE_2::response& rsp, const net_utils::connection_context_base& context)
- {
- return 1;
- }
- int demo_levin_server::handle_notify_1(int command, COMMAND_EXAMPLE_1::request& arg, const net_utils::connection_context_base& context)
- {
- return 1;
- }
- int demo_levin_server::handle_notify_2(int command, COMMAND_EXAMPLE_2::request& arg, const net_utils::connection_context_base& context)
- {
- return 1;
- }
-}
diff --git a/contrib/epee/demo/demo_levin_server/demo_levin_server.h b/contrib/epee/demo/demo_levin_server/demo_levin_server.h
deleted file mode 100644
index 5a6f68f2d4..0000000000
--- a/contrib/epee/demo/demo_levin_server/demo_levin_server.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
-// 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 Andrey N. Sabelnikov 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 THE COPYRIGHT OWNER 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.
-//
-
-
-
-#pragma once
-#include
-#include
-
-#include "net/levin_server_cp2.h"
-#include "transport_defs.h"
-#include "storages/levin_abstract_invoke2.h"
-
-using namespace epee;
-
-namespace demo
-{
-
- class demo_levin_server: public levin::levin_commands_handler<>
- {
- public:
- bool run();
- bool init(const std::string& bind_port = "11112", const std::string& bind_ip = "0.0.0.0");
- bool deinit();
- bool send_stop_signal();
- bool is_stop(){return m_stop;}
- bool wait_stop(){return m_net_server.timed_wait_server_stop(100000);}
- net_utils::boosted_levin_async_server& get_server(){return m_net_server;}
- private:
-
-
- CHAIN_LEVIN_INVOKE_MAP(); //move levin_commands_handler interface invoke(...) callbacks into invoke map
- CHAIN_LEVIN_NOTIFY_STUB(); //move levin_commands_handler interface notify(...) callbacks into nothing
-
- BEGIN_INVOKE_MAP2(demo_levin_server)
- HANDLE_INVOKE_T2(COMMAND_EXAMPLE_1, &demo_levin_server::handle_command_1)
- HANDLE_INVOKE_T2(COMMAND_EXAMPLE_2, &demo_levin_server::handle_command_2)
- HANDLE_NOTIFY_T2(COMMAND_EXAMPLE_1, &demo_levin_server::handle_notify_1)
- HANDLE_NOTIFY_T2(COMMAND_EXAMPLE_2, &demo_levin_server::handle_notify_2)
- END_INVOKE_MAP2()
-
- //----------------- commands handlers ----------------------------------------------
- int handle_command_1(int command, COMMAND_EXAMPLE_1::request& arg, COMMAND_EXAMPLE_1::response& rsp, const net_utils::connection_context_base& context);
- int handle_command_2(int command, COMMAND_EXAMPLE_2::request& arg, COMMAND_EXAMPLE_2::response& rsp, const net_utils::connection_context_base& context);
- int handle_notify_1(int command, COMMAND_EXAMPLE_1::request& arg, const net_utils::connection_context_base& context);
- int handle_notify_2(int command, COMMAND_EXAMPLE_2::request& arg, const net_utils::connection_context_base& context);
- //----------------------------------------------------------------------------------
- net_utils::boosted_levin_async_server m_net_server;
- std::atomic m_stop;
-
- };
-}
-
diff --git a/contrib/epee/demo/demo_levin_server/stdafx.cpp b/contrib/epee/demo/demo_levin_server/stdafx.cpp
deleted file mode 100644
index d6ea1c6f2d..0000000000
--- a/contrib/epee/demo/demo_levin_server/stdafx.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
-// 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 Andrey N. Sabelnikov 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 THE COPYRIGHT OWNER BE LIABLE FOR ANY
-// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-
-
-
-#include "stdafx.h"
-
diff --git a/contrib/epee/demo/demo_levin_server/stdafx.h b/contrib/epee/demo/demo_levin_server/stdafx.h
deleted file mode 100644
index cc4558434d..0000000000
--- a/contrib/epee/demo/demo_levin_server/stdafx.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
-// 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 Andrey N. Sabelnikov 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 THE COPYRIGHT OWNER 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.
-//
-
-
-#pragma once
-
-#include "targetver.h"
-
-
-#include
-
-
-#define BOOST_FILESYSTEM_VERSION 3
-#define ENABLE_RELEASE_LOGGING
-#include "misc_log_ex.h"
diff --git a/contrib/epee/demo/demo_levin_server/targetver.h b/contrib/epee/demo/demo_levin_server/targetver.h
deleted file mode 100644
index 6fe8eb79e1..0000000000
--- a/contrib/epee/demo/demo_levin_server/targetver.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#pragma once
-
-// The following macros define the minimum required platform. The minimum required platform
-// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
-// your application. The macros work by enabling all features available on platform versions up to and
-// including the version specified.
-
-// Modify the following defines if you have to target a platform prior to the ones specified below.
-// Refer to MSDN for the latest info on corresponding values for different platforms.
-#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
-#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
-#endif
-
diff --git a/contrib/epee/demo/generate_gcc.sh b/contrib/epee/demo/generate_gcc.sh
deleted file mode 100644
index fcd0a8a7e7..0000000000
--- a/contrib/epee/demo/generate_gcc.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-mkdir build
-cd build
-cmake ..
-#cmake -DBOOST_ROOT=/usr/local/proj/boost_1_49_0 -DBOOST_LIBRARYDIR=/usr/local/proj/boost_1_49_0/stage/lib ..
diff --git a/contrib/epee/demo/generate_vc_proj.bat b/contrib/epee/demo/generate_vc_proj.bat
deleted file mode 100755
index 111405981f..0000000000
--- a/contrib/epee/demo/generate_vc_proj.bat
+++ /dev/null
@@ -1,7 +0,0 @@
-mkdir build
-
-cd build
-
-cmake "-DBoost_USE_STATIC_LIBS=TRUE" -G "Visual Studio 11 Win64" ..
-cd ..
-pause
\ No newline at end of file
diff --git a/contrib/epee/demo/iface/transport_defs.h b/contrib/epee/demo/iface/transport_defs.h
deleted file mode 100644
index 8463eb903a..0000000000
--- a/contrib/epee/demo/iface/transport_defs.h
+++ /dev/null
@@ -1,221 +0,0 @@
-#pragma once
-
-#include "serialization/keyvalue_serialization.h"
-#include "storages/portable_storage_base.h"
-
-namespace demo
-{
-
- struct some_test_subdata
- {
- std::string m_str;
-
- BEGIN_KV_SERIALIZE_MAP()
- KV_SERIALIZE(m_str)
- END_KV_SERIALIZE_MAP()
- };
-
- struct some_test_data
- {
- std::string m_str;
- uint64_t m_uint64;
- uint32_t m_uint32;
- uint16_t m_uint16;
- uint8_t m_uint8;
- int64_t m_int64;
- int32_t m_int32;
- int16_t m_int16;
- int8_t m_int8;
- double m_double;
- bool m_bool;
- std::list m_list_of_str;
- std::list m_list_of_uint64_t;
- std::list m_list_of_uint32_t;
- std::list m_list_of_uint16_t;
- std::list m_list_of_uint8_t;
- std::list m_list_of_int64_t;
- std::list m_list_of_int32_t;
- std::list m_list_of_int16_t;
- std::list m_list_of_int8_t;
- std::list m_list_of_double;
- std::list m_list_of_bool;
- some_test_subdata m_subobj;
- std::list m_list_of_self;
- epee::serialization::storage_entry m_storage_entry_int;
- epee::serialization::storage_entry m_storage_entry_string;
-
- BEGIN_KV_SERIALIZE_MAP()
- KV_SERIALIZE(m_str)
- KV_SERIALIZE(m_uint64)
- KV_SERIALIZE(m_uint32)
- KV_SERIALIZE(m_uint16)
- KV_SERIALIZE(m_uint8)
- KV_SERIALIZE(m_int64)
- KV_SERIALIZE(m_int32)
- KV_SERIALIZE(m_int16)
- KV_SERIALIZE(m_int8)
- KV_SERIALIZE(m_double)
- KV_SERIALIZE(m_bool)
- KV_SERIALIZE(m_subobj)
- KV_SERIALIZE(m_list_of_str)
- KV_SERIALIZE(m_list_of_uint64_t)
- KV_SERIALIZE(m_list_of_uint32_t)
- KV_SERIALIZE(m_list_of_uint16_t)
- KV_SERIALIZE(m_list_of_uint8_t)
- KV_SERIALIZE(m_list_of_int64_t)
- KV_SERIALIZE(m_list_of_int32_t)
- KV_SERIALIZE(m_list_of_int16_t)
- KV_SERIALIZE(m_list_of_int8_t)
- KV_SERIALIZE(m_list_of_double)
- KV_SERIALIZE(m_list_of_bool)
- KV_SERIALIZE(m_list_of_self)
- KV_SERIALIZE(m_storage_entry_int)
- KV_SERIALIZE(m_storage_entry_string)
- END_KV_SERIALIZE_MAP()
- };
-
- /************************************************************************/
- /* */
- /************************************************************************/
- struct COMMAND_EXAMPLE_1
- {
- const static int ID = 1000;
-
- struct request
- {
- std::string example_string_data;
- some_test_data sub;
-
- BEGIN_KV_SERIALIZE_MAP()
- KV_SERIALIZE(example_string_data)
- KV_SERIALIZE(sub)
- END_KV_SERIALIZE_MAP()
- };
-
-
- struct response
- {
- bool m_success;
- std::list subs;
-
- BEGIN_KV_SERIALIZE_MAP()
- KV_SERIALIZE(m_success)
- KV_SERIALIZE(subs)
- END_KV_SERIALIZE_MAP()
- };
- };
-
-
-
- struct COMMAND_EXAMPLE_2
- {
- const static int ID = 1001;
-
- struct request
- {
- std::string example_string_data2;
-
- BEGIN_KV_SERIALIZE_MAP()
- KV_SERIALIZE(example_string_data2)
- END_KV_SERIALIZE_MAP()
- };
-
- struct response
- {
- bool m_success;
-
-
- BEGIN_KV_SERIALIZE_MAP()
- KV_SERIALIZE(m_success)
- END_KV_SERIALIZE_MAP()
- };
- };
-
-
- //-------------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------
- //in debug purpose
- bool operator != (const some_test_subdata& a, const some_test_subdata& b)
- {
- return b.m_str != a.m_str;
- }
-
- bool operator == (const some_test_data& a, const some_test_data& b)
- {
- if( b.m_str != a.m_str
- || b.m_uint64 != a.m_uint64
- || b.m_uint32 != a.m_uint32
- || b.m_uint16 != a.m_uint16
- || b.m_uint8 != a.m_uint8
- || b.m_int64 != a.m_int64
- || b.m_int32 != a.m_int32
- || b.m_int16 != a.m_int16
- || b.m_int8 != a.m_int8
- || b.m_double != a.m_double
- || b.m_bool != a.m_bool
- || b.m_list_of_str != a.m_list_of_str
- || b.m_list_of_uint64_t != a.m_list_of_uint64_t
- || b.m_list_of_uint32_t != a.m_list_of_uint32_t
- || b.m_list_of_uint16_t != a.m_list_of_uint16_t
- || b.m_list_of_uint8_t != a.m_list_of_uint8_t
- || b.m_list_of_int64_t != a.m_list_of_int64_t
- || b.m_list_of_int32_t != a.m_list_of_int32_t
- || b.m_list_of_int16_t != a.m_list_of_int16_t
- || b.m_list_of_int8_t != a.m_list_of_int8_t
- || b.m_list_of_double != a.m_list_of_double
- || b.m_list_of_bool != a.m_list_of_bool
- || b.m_subobj != a.m_subobj
- || b.m_list_of_self != a.m_list_of_self
- || b.m_storage_entry_int.which() != a.m_storage_entry_int.which()
- || b.m_storage_entry_string.which() != a.m_storage_entry_string.which()
- )
- return false;
- return true;
- }
-
- inline some_test_data get_test_data()
- {
- some_test_data s;
- s.m_str = "zuzuzuzuzuz";
- s.m_uint64 = 111111111111111;
- s.m_uint32 = 2222222;
- s.m_uint16 = 2222;
- s.m_uint8 = 22;
- s.m_int64 = -111111111111111;
- s.m_int32 = -2222222;
- s.m_int16 = -2222;
- s.m_int8 = -24;
- s.m_double = 0.11111;
- s.m_bool = true;
- s.m_list_of_str.push_back("1112121");
- s.m_list_of_uint64_t.push_back(1111111111);
- s.m_list_of_uint64_t.push_back(2222222222);
- s.m_list_of_uint32_t.push_back(1111111);
- s.m_list_of_uint32_t.push_back(2222222);
- s.m_list_of_uint16_t.push_back(1111);
- s.m_list_of_uint16_t.push_back(2222);
- s.m_list_of_uint8_t.push_back(11);
- s.m_list_of_uint8_t.push_back(22);
-
-
- s.m_list_of_int64_t.push_back(-1111111111);
- s.m_list_of_int64_t.push_back(-222222222);
- s.m_list_of_int32_t.push_back(-1111111);
- s.m_list_of_int32_t.push_back(-2222222);
- s.m_list_of_int16_t.push_back(-1111);
- s.m_list_of_int16_t.push_back(-2222);
- s.m_list_of_int8_t.push_back(-11);
- s.m_list_of_int8_t.push_back(-22);
-
- s.m_list_of_double.push_back(0.11111);
- s.m_list_of_double.push_back(0.22222);
- s.m_list_of_bool.push_back(true);
- s.m_list_of_bool.push_back(false);
-
- s.m_subobj.m_str = "subszzzzzzzz";
- s.m_list_of_self.push_back(s);
- s.m_storage_entry_int = epee::serialization::storage_entry(uint64_t(22222));;
- s.m_storage_entry_string = epee::serialization::storage_entry(std::string("sdsvsdvs"));
- return s;
- }
-}
\ No newline at end of file
diff --git a/contrib/epee/include/ado_db_helper.h b/contrib/epee/include/ado_db_helper.h
deleted file mode 100644
index ed4e5b30f8..0000000000
--- a/contrib/epee/include/ado_db_helper.h
+++ /dev/null
@@ -1,1095 +0,0 @@
-// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
-// 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 Andrey N. Sabelnikov 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 THE COPYRIGHT OWNER 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 _DB_ADO_HELPER_H_
-#define _DB_ADO_HELPER_H_
-
-#include
-#include
-#include "string_coding.h"
-#include "math_helper.h"
-#include "file_io_utils.h"
-#include "global_stream_operators.h"
-
-
-
-#define BEGIN_TRY_SECTION() try {
-
-#define CATCH_TRY_SECTION(ret_val) CATCH_TRY_SECTION_MESS(ret_val, "")
-
-#define CATCH_TRY_SECTION_MESS(ret_val, mess_where) }\
- catch(const std::exception&ex)\
- {\
- LOG_PRINT_J("DB_ERROR: " << ex.what(), LOG_LEVEL_0);\
- return ret_val;\
- }\
- catch(const _com_error& comm_err)\
- {\
- const TCHAR* pstr = comm_err.Description();\
- std::string descr = string_encoding::convert_to_ansii(pstr?pstr:TEXT(""));\
- const TCHAR* pmessage = comm_err.ErrorMessage();\
- pstr = comm_err.Source();\
- std::string source = string_encoding::convert_to_ansii(pstr?pstr:TEXT(""));\
- LOG_PRINT_J("COM_ERROR " << mess_where << ":\n\tDescriprion:" << descr << ", \n\t Message: " << string_encoding::convert_to_ansii(pmessage) << "\n\t Source: " << source, LOG_LEVEL_0);\
- return ret_val;\
- }\
- catch(...)\
- {\
- LOG_PRINT_J("..._ERROR: Unknown error.", LOG_LEVEL_0);\
- return ret_val;\
- }\
-
-namespace epee
-{
-namespace ado_db_helper
-{
-
- struct profile_entry
- {
- profile_entry():m_call_count(0), m_max_time(0), m_min_time(0)
- {}
- //std::string m_sql;
- math_helper::average m_avrg;
- size_t m_call_count;
- DWORD m_max_time;
- DWORD m_min_time;
- };
-
- class profiler_manager
- {
- public:
- typedef std::map sqls_map;
- profiler_manager(){}
-
- static bool sort_by_timing(const sqls_map::iterator& a, const sqls_map::iterator& b)
- {
- return a->second.m_avrg.get_avg() > b->second.m_avrg.get_avg();
- }
-
- bool flush_log(const std::string& path)
- {
- CRITICAL_REGION_BEGIN(m_sqls_lock);
- std::stringstream strm;
- strm << "SQL PROFILE:\r\nStatements: " << m_sqls.size() << "\r\n";
- std::list m_sorted_by_time_sqls;
- for(std::map::iterator it = m_sqls.begin();it!=m_sqls.end();it++)
- m_sorted_by_time_sqls.push_back(it);
-
- m_sorted_by_time_sqls.sort(sort_by_timing);
-
- for(std::list::iterator it = m_sorted_by_time_sqls.begin();it!=m_sorted_by_time_sqls.end();it++)
- {
- strm << "---------------------------------------------------------------------------------------------------------\r\nSQL: " << (*it)->first << "\r\n";
- strm << "\tavrg: " << (*it)->second.m_avrg.get_avg() << "\r\n\tmax: " << (*it)->second.m_max_time << "\r\n\tmin: " << (*it)->second.m_min_time << "\r\n\tcount: " << (*it)->second.m_call_count << "\r\n";
- }
-
- return file_io_utils::save_string_to_file(path.c_str(), strm.str());
- CRITICAL_REGION_END();
- }
-
- bool push_entry(const std::string sql, DWORD time)
- {
- CRITICAL_REGION_BEGIN(m_sqls_lock);
- profile_entry& entry_ref = m_sqls[sql];
- entry_ref.m_avrg.push(time);
- entry_ref.m_call_count++;
- if(time > entry_ref.m_max_time) entry_ref.m_max_time = time;
- if(time < entry_ref.m_min_time || entry_ref.m_min_time == 0) entry_ref.m_min_time = time;
- CRITICAL_REGION_END();
- return true;
- }
-
- bool get_entry_avarege(const std::string sql, DWORD& time)
- {
- CRITICAL_REGION_BEGIN(m_sqls_lock);
- sqls_map::iterator it = m_sqls.find(sql);
- if(it==m_sqls.end())
- return false;
-
- time = static_cast(it->second.m_avrg.get_avg());
- CRITICAL_REGION_END();
- return true;
- }
-
- private:
-
- sqls_map m_sqls;
- critical_section m_sqls_lock;
- };
-inline
- profiler_manager* get_set_profiler(bool need_to_set = false, profiler_manager** pprofiler = NULL)
- {
- static profiler_manager* pmanager = NULL;
- if(need_to_set)
- pmanager = *pprofiler;
- //else
- // *pprofiler = pmanager;
-
- return pmanager;
- }
-inline
- bool init() // INIT and DEINIT are NOT THREAD SAFE operations, CALL it BEFOR u start using this wrapper.
- {
- profiler_manager* pmanager = new profiler_manager();
- get_set_profiler(true, &pmanager);
- return true;
- }
-inline
- bool deinit()
- {
- profiler_manager* pmanager = get_set_profiler();
- //get_set_profiler(false, &pmanager);
- if(pmanager)
- delete pmanager;
- return true;
- }
- inline bool push_timing(const std::string sql, DWORD time)
- {
- profiler_manager* pmanager = get_set_profiler();
- //get_set_profiler(false, &pmanager);
- if(pmanager)
- return pmanager->push_entry(sql, time);
- return true;
- }
-
- inline bool flush_profiler(const std::string path)
- {
- profiler_manager* pmanager = get_set_profiler();
- //get_set_profiler(false, &pmanager);
- if(pmanager)
- return pmanager->flush_log(path);
- return true;
- }
-
- class timing_guard
- {
- DWORD m_start_time;
- std::string m_sql;
-
- public:
- timing_guard(const std::string& sql)
- {
- m_start_time = ::GetTickCount();
- m_sql = sql;
- }
-
- ~timing_guard()
- {
- DWORD timing = ::GetTickCount() - m_start_time;
- push_timing(m_sql, timing);
- }
- };
-#define PROFILE_SQL(sql) timing_guard local_timing(sql)
-
-
- typedef std::vector > table;
-
- inline bool add_parametr(ADODB::_CommandPtr cmd, const std::string& parametr)
- {
- _variant_t param(parametr.c_str());
- ADODB::ADO_LONGPTR size = sizeof(parametr);
- ADODB::_ParameterPtr param_obj = cmd->CreateParameter("", ADODB::adVarChar, ADODB::adParamInput, static_cast(parametr.size()+1), param);
- cmd->Parameters->Append(param_obj);
- return true;
- }
-
- inline bool add_parametr(ADODB::_CommandPtr cmd, const std::wstring& parametr)
- {
- _variant_t param(parametr.c_str());
- ADODB::ADO_LONGPTR size = sizeof(parametr);
- ADODB::_ParameterPtr param_obj = cmd->CreateParameter("", ADODB::adVarWChar, ADODB::adParamInput, static_cast(parametr.size()+2), param);
- cmd->Parameters->Append(param_obj);
- return true;
- }
-
- inline bool add_parametr(ADODB::_CommandPtr cmd, const __int64 parametr)
- {
- _variant_t param(parametr);
- ADODB::ADO_LONGPTR size = static_cast(sizeof(parametr));
- ADODB::_ParameterPtr param_obj = cmd->CreateParameter("parametr", ADODB::adBigInt, ADODB::adParamInput, static_cast(size), param);
- cmd->Parameters->Append(param_obj);
- return true;
- }
-
- inline bool add_parametr(ADODB::_CommandPtr cmd, const unsigned __int64 parametr)
- {
- _variant_t param(parametr);
- ADODB::ADO_LONGPTR size = static_cast(sizeof(parametr));
- ADODB::_ParameterPtr param_obj = cmd->CreateParameter("parametr", ADODB::adUnsignedBigInt, ADODB::adParamInput, static_cast(size), param);
- cmd->Parameters->Append(param_obj);
- return true;
- }
-
-
- inline bool add_parametr(ADODB::_CommandPtr cmd, const int parametr)
- {
- _variant_t param(parametr);
- ADODB::ADO_LONGPTR size = static_cast(sizeof(parametr));
- ADODB::_ParameterPtr param_obj = cmd->CreateParameter("parametr", ADODB::adInteger, ADODB::adParamInput, static_cast(size), param);
- cmd->Parameters->Append(param_obj);
- return true;
- }
-
- inline bool add_parametr(ADODB::_CommandPtr cmd, const unsigned int parametr)
- {
- _variant_t param(parametr);
- ADODB::ADO_LONGPTR size = static_cast(sizeof(parametr));
- ADODB::_ParameterPtr param_obj = cmd->CreateParameter("parametr", ADODB::adUnsignedInt, ADODB::adParamInput, static_cast(size), param);
- cmd->Parameters->Append(param_obj);
- return true;
- }
-
- inline bool add_parametr(ADODB::_CommandPtr cmd, float parametr)
- {
- _variant_t param;
- param.ChangeType(VT_R4);
- param.fltVal = parametr;
- ADODB::_ParameterPtr param_obj = cmd->CreateParameter("parametr", ADODB::adSingle, ADODB::adParamInput, static_cast(sizeof(float)), param);
- cmd->Parameters->Append(param_obj);
- return true;
- }
-
- inline bool add_parametr(ADODB::_CommandPtr cmd, bool parametr)
- {
- _variant_t param;
- param = parametr;
- ADODB::_ParameterPtr param_obj = cmd->CreateParameter("parametr", ADODB::adBoolean, ADODB::adParamInput, sizeof(parametr), param);
- cmd->Parameters->Append(param_obj);
- return true;
- }
-
-
- inline bool add_parametr(ADODB::_CommandPtr cmd, _variant_t parametr)
- {
- ADODB::_ParameterPtr param_obj = cmd->CreateParameter("parametr", ADODB::adDBTimeStamp, ADODB::adParamInput, sizeof(parametr), parametr);
- cmd->Parameters->Append(param_obj);
- return true;
- }
-
-
- inline bool add_parametr_as_double(ADODB::_CommandPtr cmd, const DATE parametr)
- {
- _variant_t param;
- param.ChangeType(VT_R8);
- param.dblVal = parametr;
- ADODB::_ParameterPtr param_obj = cmd->CreateParameter("parametr", ADODB::adDouble, ADODB::adParamInput, sizeof(float), param);
- cmd->Parameters->Append(param_obj);
- return true;
- }
-
- template
- inline bool add_parametr(ADODB::_CommandPtr cmd, const std::list params)
- {
- for(std::list::const_iterator it = params.begin(); it!=params.end(); it++)
- if(!add_parametr(cmd, *it))
- return false;
- return true;
- }
-
- /*
- inline bool add_parametr(ADODB::_CommandPtr cmd, const size_t parametr)
- {
- _variant_t param;
- param.ChangeType(VT_I4);
- param.intVal = parametr;
- ADODB::_ParameterPtr param_obj = cmd->CreateParameter("parametr", ADODB::adInteger, ADODB::adParamInput, sizeof(parametr), param);
- cmd->Parameters->Append(param_obj);
- return true;
- }*/
-
-
- inline bool add_parametr(ADODB::_CommandPtr cmd, const DATE parametr)
- {
- /*_variant_t param;
- param.ChangeType(VT_R8);
- param.dblVal = parametr;
- ADODB::_ParameterPtr param_obj = cmd->CreateParameter("parametr", ADODB::adDouble, ADODB::adParamInput, sizeof(float), param);
- cmd->Parameters->Append(param_obj);*/
-
- _variant_t param;
- param.ChangeType(VT_DATE);
- param.date = parametr;
- ADODB::_ParameterPtr param_obj = cmd->CreateParameter("parametr", ADODB::adDBDate, ADODB::adParamInput, sizeof(parametr), param);
- cmd->Parameters->Append(param_obj);
-
- return true;
- }
-
-
- inline bool execute_helper(ADODB::_CommandPtr cmd, _variant_t* pcount_processed = NULL)
- {
- //BEGIN_TRY_SECTION();
-
- cmd->Execute(pcount_processed, NULL, ADODB::adExecuteNoRecords);
-
-
- //CATCH_TRY_SECTION(false);
-
- return true;
- }
-
-
- inline bool select_helper(ADODB::_CommandPtr cmd, table& result_vector)
- {
- result_vector.clear();
- //BEGIN_TRY_SECTION();
-
- ADODB::_RecordsetPtr precordset = cmd->Execute(NULL, NULL, NULL);
- if(!precordset)
- {
- LOG_ERROR("DB_ERROR: cmd->Execute returned NULL!!!");
- return false;
- }
-
- //if(precordset->EndOfFile == EOF)
- //{
- // return true;
- //}
- /*try
- {
- if(precordset->MoveFirst()!= S_OK)
- {
- LOG_ERROR("DB_ERROR: Filed to move first!!!");
- return false;
- }
- }
- catch (...)
- {
- return true;
- }*/
-
- size_t current_record_index = 0;
- while(precordset->EndOfFile != EOF)
- {
- result_vector.push_back(table::value_type());
- size_t fields_count = precordset->Fields->Count;
- result_vector[current_record_index].resize(fields_count);
- for(size_t current_field_index = 0; current_field_index < fields_count; current_field_index++)
- {
- _variant_t var;
- var.ChangeType(VT_I2);
- var.intVal = static_cast(current_field_index);
- result_vector[current_record_index][current_field_index] = precordset->Fields->GetItem(var)->Value;
- }
- precordset->MoveNext();
- current_record_index++;
- }
- //CATCH_TRY_SECTION(false);
- return true;
- }
-
-
- template
- struct adapter_zero
- {
-
- };
-
- template
- struct adapter_single
- {
- TParam1 tparam1;
- };
- template
- struct adapter_double
- {
- TParam1 tparam1;
- TParam2 tparam2;
- };
-
-
- template
- struct adapter_triple
- {
- TParam1 tparam1;
- TParam2 tparam2;
- TParam3 tparam3;
- };
-
- template
- struct adapter_quad
- {
- TParam1 tparam1;
- TParam2 tparam2;
- TParam3 tparam3;
- TParam4 tparam4;
- };
-
- template
- struct adapter_quanto
- {
- TParam1 tparam1;
- TParam2 tparam2;
- TParam3 tparam3;
- TParam4 tparam4;
- TParam5 tparam5;
- };
-
- template
- struct adapter_sixto
- {
- TParam1 tparam1;
- TParam2 tparam2;
- TParam3 tparam3;
- TParam4 tparam4;
- TParam5 tparam5;
- TParam6 tparam6;
- };
-
- template
- struct adapter_sevento
- {
- TParam1 tparam1;
- TParam2 tparam2;
- TParam3 tparam3;
- TParam4 tparam4;
- TParam5 tparam5;
- TParam6 tparam6;
- TParam7 tparam7;
- };
-
- template
- struct adapter_nine
- {
- TParam1 tparam1;
- TParam2 tparam2;
- TParam3 tparam3;
- TParam4 tparam4;
- TParam5 tparam5;
- TParam6 tparam6;
- TParam7 tparam7;
- TParam8 tparam8;
- TParam9 tparam9;
- };
-
- template
- bool add_parametrs_multi(ADODB::_CommandPtr cmd, const adapter_zero& params)
- {
- return true;
- }
-
- template
- bool add_parametrs_multi(ADODB::_CommandPtr cmd, const adapter_single& params)
- {
- return add_parametr(cmd, params.tparam1);
- }
-
- template
- bool add_parametrs_multi(ADODB::_CommandPtr cmd, const adapter_double& params)
- {
- if(!add_parametr(cmd, params.tparam1)) return false;
- return add_parametr(cmd, params.tparam2);
- }
-
- template
- bool add_parametrs_multi(ADODB::_CommandPtr cmd, const adapter_triple& params)
- {
- if(!add_parametr(cmd, params.tparam1)) return false;
- if(!add_parametr(cmd, params.tparam2)) return false;
- return add_parametr(cmd, params.tparam3);
- }
-
- template
- bool add_parametrs_multi(ADODB::_CommandPtr cmd, const adapter_quad& params)
- {
- if(!add_parametr(cmd, params.tparam1)) return false;
- if(!add_parametr(cmd, params.tparam2)) return false;
- if(!add_parametr(cmd, params.tparam3)) return false;
- return add_parametr(cmd, params.tparam4);
- }
-
- template
- bool add_parametrs_multi(ADODB::_CommandPtr cmd, const adapter_quanto& params)
- {
- if(!add_parametr(cmd, params.tparam1)) return false;
- if(!add_parametr(cmd, params.tparam2)) return false;
- if(!add_parametr(cmd, params.tparam3)) return false;
- if(!add_parametr(cmd, params.tparam4)) return false;
- return add_parametr(cmd, params.tparam5);
- }
-
- template
- bool add_parametrs_multi(ADODB::_CommandPtr cmd, const adapter_sixto& params)
- {
- if(!add_parametr(cmd, params.tparam1)) return false;
- if(!add_parametr(cmd, params.tparam2)) return false;
- if(!add_parametr(cmd, params.tparam3)) return false;
- if(!add_parametr(cmd, params.tparam4)) return false;
- if(!add_parametr(cmd, params.tparam5)) return false;
- return add_parametr(cmd, params.tparam6);
- }
-
- template
- bool add_parametrs_multi(ADODB::_CommandPtr cmd, const adapter_sevento& params)
- {
- if(!add_parametr(cmd, params.tparam1)) return false;
- if(!add_parametr(cmd, params.tparam2)) return false;
- if(!add_parametr(cmd, params.tparam3)) return false;
- if(!add_parametr(cmd, params.tparam4)) return false;
- if(!add_parametr(cmd, params.tparam5)) return false;
- if(!add_parametr(cmd, params.tparam6)) return false;
- return add_parametr(cmd, params.tparam7);
- }
-
- template
- bool add_parametrs_multi(ADODB::_CommandPtr cmd, const adapter_nine& params)
- {
- if(!add_parametr(cmd, params.tparam1)) return false;
- if(!add_parametr(cmd, params.tparam2)) return false;
- if(!add_parametr(cmd, params.tparam3)) return false;
- if(!add_parametr(cmd, params.tparam4)) return false;
- if(!add_parametr(cmd, params.tparam5)) return false;
- if(!add_parametr(cmd, params.tparam6)) return false;
- if(!add_parametr(cmd, params.tparam7)) return false;
- if(!add_parametr(cmd, params.tparam8)) return false;
- return add_parametr(cmd, params.tparam9);
- }
-
- template
- std::string print_parameters_multi(const adapter_sevento& params)
- {
- std::stringstream strm;
- strm << params.tparam1 << ", " << params.tparam2 << ", " << params.tparam3 << ", " << params.tparam4 << ", " << params.tparam5 << ", " << params.tparam6 << ", " << params.tparam7;
- return strm.str();
- }
-
- template
- std::string print_parameters_multi(const adapter_nine& params)
- {
- std::stringstream strm;
- strm << params.tparam1 << ", " << params.tparam2 << ", " << params.tparam3 << ", " << params.tparam4 << ", " << params.tparam5 << ", " << params.tparam6 << ", " << params.tparam7 << ", " << params.tparam8 << ", " << params.tparam9;
- return strm.str();
- }
-
- template
- std::string print_parameters_multi(const adapter_sixto& params)
- {
- std::stringstream strm;
- strm << params.tparam1 << ", " << params.tparam2 << ", " << params.tparam3 << ", " << params.tparam4 << ", " << params.tparam5 << ", " << params.tparam6;
- return strm.str();
- }
-
- template
- std::string print_parameters_multi(const adapter_quanto& params)
- {
- std::stringstream strm;
- strm << params.tparam1 << ", " << params.tparam2 << ", " << params.tparam3 << ", " << params.tparam4 << ", " << params.tparam5;
- return strm.str();
- }
-
-
- template
- std::string print_parameters_multi(const adapter_quad& params)
- {
- std::stringstream strm;
- strm << params.tparam1 << ", " << params.tparam2 << ", " << params.tparam3 << ", " << params.tparam4;
- return strm.str();
- }
-
- template
- std::string print_parameters_multi(const adapter_triple& params)
- {
- std::stringstream strm;
- strm << params.tparam1 << ", " << params.tparam2 << ", " << params.tparam3;
- return strm.str();
- }
-
- template
- std::string get_str_param(const TParam& prm)
- {
- std::stringstream strm;
- strm << prm;
- return strm.str();
- }
-
- template
- std::string get_str_param(const std::list& prm_lst)
- {
- std::stringstream strm;
- for(std::list::const_iterator it = prm_lst.begin();it!=prm_lst.end();it++)
- strm << get_str_param(*it) << ", ";
- return strm.str();
- }
-
-
- template
- std::string print_parameters_multi(const adapter_double& params)
- {
- std::stringstream strm;
- strm << get_str_param(params.tparam1) << ", " << get_str_param(params.tparam2);
- return strm.str();
- }
-
- template
- std::string print_parameters_multi(const adapter_single& params)
- {
- std::stringstream strm;
- strm << get_str_param(params.tparam1);
- return strm.str();
- }
-
- template
- std::string print_parameters_multi(const adapter_zero& params)
- {
- std::stringstream strm;
- strm << "(no parametrs)";
- return strm.str();
- }
-
-
- template
- bool execute_helper_multiparam(ADODB::_ConnectionPtr pconnection, const std::string& sql_statment, const TParams& parametrs, _variant_t* pcount_processed = NULL)
- {
- PROFILE_SQL(sql_statment);
- bool res = false;
- BEGIN_TRY_SECTION();
-
- ADODB::_CommandPtr cmd;
- cmd.CreateInstance(__uuidof(ADODB::Command));
- cmd->CommandText = _bstr_t(sql_statment.c_str());
-
- if(!add_parametrs_multi(cmd, parametrs))
- return false;
-
- cmd->ActiveConnection = pconnection;
- res = execute_helper(cmd, pcount_processed);
-
- CATCH_TRY_SECTION_MESS(false, "while statment: " << sql_statment << " [params]: " << print_parameters_multi(parametrs));
- return res;
- }
-
-
- template
- inline
- bool select_helper_multiparam(ADODB::_ConnectionPtr pconnection, const std::string& sql_statment, const TParams& parametrs, table& result_vector)
- {
- PROFILE_SQL(sql_statment);
- bool res = false;
- BEGIN_TRY_SECTION();
- ADODB::_CommandPtr cmd;
- cmd.CreateInstance(__uuidof(ADODB::Command));
- cmd->CommandText = _bstr_t(sql_statment.c_str());
-
-
- if(!add_parametrs_multi(cmd, parametrs))
- return false;
-
- cmd->ActiveConnection = pconnection;
- res = select_helper(cmd, result_vector);
- CATCH_TRY_SECTION_MESS(false, "while statment: " << sql_statment << " [params]: " << print_parameters_multi(parametrs));
- return res;
- }
-
-
- template
- inline
- bool select_helper_param_container(ADODB::_ConnectionPtr pconnection, const std::string& sql_statment, const TParams& parametrs, table& result_vector)
- {
- PROFILE_SQL(sql_statment);
- bool res = false;
- BEGIN_TRY_SECTION();
- ADODB::_CommandPtr cmd;
- cmd.CreateInstance(__uuidof(ADODB::Command));
- cmd->CommandText = _bstr_t(sql_statment.c_str());
-
-
- for(TParams::const_iterator it = parametrs.begin(); it!=parametrs.end(); it++)
- {
- add_parametr(cmd, *it);
- }
-
- cmd->ActiveConnection = pconnection;
- res = select_helper(cmd, result_vector);
-
- CATCH_TRY_SECTION(false);
- return res;
- }
-
-
- inline
- bool execute_helper(ADODB::_ConnectionPtr pconnection, const std::string& sql_statment, _variant_t* pvt = NULL)
- {
- adapter_zero params;
- return execute_helper_multiparam(pconnection, sql_statment, params, pvt);
- }
-
- template
- bool execute_helper(ADODB::_ConnectionPtr pconnection, const std::string& sql_statment, const TParam& parametr)
- {
- adapter_single params;
- params.tparam1 = parametr;
- return execute_helper_multiparam(pconnection, sql_statment, params);
- }
-
-
- template
- bool execute_helper(ADODB::_ConnectionPtr pconnection, const std::string& sql_statment, const TParam1& parametr1, const TParam2& parametr2)
- {
- adapter_double params;
- params.tparam1 = parametr1;
- params.tparam2 = parametr2;
- return execute_helper_multiparam(pconnection, sql_statment, params);
-
- }
-
- template
- bool execute_helper(ADODB::_ConnectionPtr pconnection, const std::string& sql_statment, const TParam1& parametr1, const TParam2& parametr2, const TParam3& parametr3)
- {
- adapter_triple params;
- params.tparam1 = parametr1;
- params.tparam2 = parametr2;
- params.tparam3 = parametr3;
- return execute_helper_multiparam(pconnection, sql_statment, params);
- }
-
- template
- bool execute_helper(ADODB::_ConnectionPtr pconnection, const std::string& sql_statment, const TParam1& parametr1, const TParam2& parametr2, const TParam3& parametr3, const TParam4& parametr4)
- {
- adapter_quad params;
- params.tparam1 = parametr1;
- params.tparam2 = parametr2;
- params.tparam3 = parametr3;
- params.tparam4 = parametr4;
- return execute_helper_multiparam(pconnection, sql_statment, params);
- }
-
- template
- bool execute_helper(ADODB::_ConnectionPtr pconnection, const std::string& sql_statment, const TParam1& parametr1, const TParam2& parametr2, const TParam3& parametr3, const TParam4& parametr4, const TParam5& parametr5)
- {
- adapter_quanto params;
- params.tparam1 = parametr1;
- params.tparam2 = parametr2;
- params.tparam3 = parametr3;
- params.tparam4 = parametr4;
- params.tparam5 = parametr5;
- return execute_helper_multiparam(pconnection, sql_statment, params);
- }
-
- template
- bool execute_helper(ADODB::_ConnectionPtr pconnection, const std::string& sql_statment, const TParam1& parametr1, const TParam2& parametr2, const TParam3& parametr3, const TParam4& parametr4, const TParam5& parametr5, const TParam6& parametr6)
- {
- adapter_sixto params;
- params.tparam1 = parametr1;
- params.tparam2 = parametr2;
- params.tparam3 = parametr3;
- params.tparam4 = parametr4;
- params.tparam5 = parametr5;
- params.tparam6 = parametr6;
- return execute_helper_multiparam(pconnection, sql_statment, params);
- }
-
-
- template
- bool execute_helper(ADODB::_ConnectionPtr pconnection, const std::string& sql_statment, const TParam1& parametr1, const TParam2& parametr2, const TParam3& parametr3, const TParam4& parametr4, const TParam5& parametr5, const TParam6& parametr6, const TParam7& parametr7)
- {
- adapter_sevento params;
- params.tparam1 = parametr1;
- params.tparam2 = parametr2;
- params.tparam3 = parametr3;
- params.tparam4 = parametr4;
- params.tparam5 = parametr5;
- params.tparam6 = parametr6;
- params.tparam7 = parametr7;
- return execute_helper_multiparam(pconnection, sql_statment, params);
- }
-
- inline
- bool select_helper(ADODB::_ConnectionPtr pconnection, const std::string& sql_statment, table& result_vector)
- {
- adapter_zero params;
- return select_helper_multiparam(pconnection, sql_statment, params, result_vector);
- }
-
-
- template
- bool select_helper(ADODB::_ConnectionPtr pconnection, const std::string& sql_statment, const TParam& parametr, table& result_vector)
- {
- adapter_single params;
- params.tparam1 = parametr;
- return select_helper_multiparam(pconnection, sql_statment, params, result_vector);
- }
-
- template
- bool select_helper(ADODB::_ConnectionPtr pconnection, const std::string& sql_statment, const TParam1 parametr1, const TParam2 parametr2, table& result_vector)
- {
- adapter_double params;
- params.tparam1 = parametr1;
- params.tparam2 = parametr2;
- return select_helper_multiparam(pconnection, sql_statment, params, result_vector);
-
- }
-
- template
- bool select_helper(ADODB::_ConnectionPtr pconnection, const std::string& sql_statment, const TParam1 parametr1, const TParam2 parametr2, const TParam3 parametr3, table& result_vector)
- {
- adapter_triple params;
- params.tparam1 = parametr1;
- params.tparam2 = parametr2;
- params.tparam3 = parametr3;
- return select_helper_multiparam(pconnection, sql_statment, params, result_vector);
-
- }
-
- template
- bool select_helper(ADODB::_ConnectionPtr pconnection, const std::string& sql_statment, const TParam1 parametr1, const TParam2 parametr2, const TParam3 parametr3, const TParam4 parametr4, table& result_vector)
- {
- adapter_quad params;
- params.tparam1 = parametr1;
- params.tparam2 = parametr2;
- params.tparam3 = parametr3;
- params.tparam4 = parametr4;
- return select_helper_multiparam(pconnection, sql_statment, params, result_vector);
- }
-
- template
- bool select_helper(ADODB::_ConnectionPtr pconnection, const std::string& sql_statment, const TParam1 parametr1, const TParam2 parametr2, const TParam3 parametr3, const TParam4 parametr4, const TParam5 parametr5, table& result_vector)
- {
- adapter_quanto params;
- params.tparam1 = parametr1;
- params.tparam2 = parametr2;
- params.tparam3 = parametr3;
- params.tparam4 = parametr4;
- params.tparam5 = parametr5;
- return select_helper_multiparam(pconnection, sql_statment, params, result_vector);
- }
-
-
- template
- bool select_helper(ADODB::_ConnectionPtr pconnection, const std::string& sql_statment, const TParam1 parametr1, const TParam2 parametr2, const TParam3 parametr3, const TParam4 parametr4, const TParam5 parametr5, const TParam6 parametr6, table& result_vector)
- {
- adapter_sixto params;
- params.tparam1 = parametr1;
- params.tparam2 = parametr2;
- params.tparam3 = parametr3;
- params.tparam4 = parametr4;
- params.tparam5 = parametr5;
- params.tparam6 = parametr6;
- return select_helper_multiparam(pconnection, sql_statment, params, result_vector);
- }
-
- template
- bool select_helper(ADODB::_ConnectionPtr pconnection, const std::string& sql_statment, const TParam1 parametr1, const TParam2 parametr2, const TParam3 parametr3, const TParam4 parametr4, const TParam5 parametr5, const TParam6 parametr6, const TParam7 parametr7, table& result_vector)
- {
- adapter_sevento params;
- params.tparam1 = parametr1;
- params.tparam2 = parametr2;
- params.tparam3 = parametr3;
- params.tparam4 = parametr4;
- params.tparam5 = parametr5;
- params.tparam6 = parametr6;
- params.tparam7 = parametr7;
- return select_helper_multiparam(pconnection, sql_statment, params, result_vector);
- }
-
- template
- bool select_helper(ADODB::_ConnectionPtr pconnection, const std::string& sql_statment, const TParam1 parametr1, const TParam2 parametr2, const TParam3 parametr3, const TParam4 parametr4, const TParam5 parametr5, const TParam6 parametr6, const TParam7 parametr7,const TParam8 parametr8,const TParam9 parametr9, table& result_vector)
- {
- adapter_nine params;
- params.tparam1 = parametr1;
- params.tparam2 = parametr2;
- params.tparam3 = parametr3;
- params.tparam4 = parametr4;
- params.tparam5 = parametr5;
- params.tparam6 = parametr6;
- params.tparam7 = parametr7;
- params.tparam8 = parametr8;
- params.tparam9 = parametr9;
- return select_helper_multiparam(pconnection, sql_statment, params, result_vector);
- }
-
-
-
-
- /************************************************************************/
- /* */
- /************************************************************************/
-
- class per_thread_connection_pool
- {
- public:
- bool init(const std::string& connection_string, const std::string& login, const std::string& pass)
- {
- m_connection_string = connection_string;
- m_login = login;
- m_password = pass;
- if(!get_db_connection().GetInterfacePtr())
- return false;
-
- return true;
- }
-
- ADODB::_ConnectionPtr& get_db_connection()
- {
-
- //soci::session
-
- m_db_connections_lock.lock();
- boost::shared_ptr& conn_ptr = m_db_connections[::GetCurrentThreadId()];
- m_db_connections_lock.unlock();
- if(!conn_ptr.get())
- {
- conn_ptr.reset(new ADODB::_ConnectionPtr());
- ADODB::_ConnectionPtr& conn = *conn_ptr.get();
- //init new connection
-
- BEGIN_TRY_SECTION();
- //_bstr_t str = _bstr_t("Provider=SQLOLEDB;Data Source=SRV1;Integrated Security=SSPI;Initial Catalog=dispatcher;");
-
- if(S_OK != conn.CreateInstance(__uuidof(ADODB::Connection)))
- {
- LOG_ERROR("Failed to Create, instance, was CoInitialize called ???!");
- return conn;
- }
-
- HRESULT res = conn->Open(_bstr_t(m_connection_string.c_str()), _bstr_t(m_login.c_str()), _bstr_t(m_password.c_str()), NULL);
- if(res != S_OK)
- {
- LOG_ERROR("Failed to connect do DB, connection str:" << m_connection_string);
- return conn;
- }
- CATCH_TRY_SECTION_MESS(conn, "while creating another connection");
- LOG_PRINT("New DB Connection added for threadid=" << ::GetCurrentThreadId(), LOG_LEVEL_0);
- ado_db_helper::execute_helper(conn, "set enable_seqscan=false;");
- return conn;
- }
-
- return *conn_ptr.get();
- }
-
- //----------------------------------------------------------------------------------------------
- bool check_status()
- {
- ADODB::_ConnectionPtr& rconn = get_db_connection();
- if(!ado_db_helper::execute_helper(rconn, "SET CLIENT_ENCODING TO 'SQL_ASCII'"))
- {
-
- try{
- HRESULT res = rconn->Close();
- }
- catch(...)
- {
-
- };
- BEGIN_TRY_SECTION();
-
- HRESULT res = rconn->Open(_bstr_t(m_connection_string.c_str()), _bstr_t(m_login.c_str()), _bstr_t(m_password.c_str()), NULL);
- if(res != S_OK)
- {
- LOG_PRINT("Failed to restore connection to local AI DB", LOG_LEVEL_1);
- return false;
- }
- CATCH_TRY_SECTION(false);
- }
-
- return true;
- }
-
- protected:
- private:
- std::map > m_db_connections;
- critical_section m_db_connections_lock;
- std::string m_connection_string;
- std::string m_login;
- std::string m_password;
- };
-
-
- template
- bool find_or_add_t(const std::string& sql_select_statment, const std::string& sql_insert_statment, OUT default_id_type& id, OUT bool& new_object_added, TParam1 parametr_1, t_conn& c)
- {
- ado_db_helper::adapter_single params;
- params.tparam1 = parametr_1;
- return find_or_add_t_multiparametred(sql_select_statment, sql_insert_statment, id, new_object_added, params, c);
- }
-
-
- template
- bool find_or_add_t(const std::string& sql_select_statment, const std::string& sql_insert_statment, OUT default_id_type& id, OUT bool& new_object_added, TParam1 parametr_1, TParam2 parametr_2, t_conn& c)
- {
- ado_db_helper::adapter_double params;
- params.tparam1 = parametr_1;
- params.tparam2 = parametr_2;
- return find_or_add_t_multiparametred(sql_select_statment, sql_insert_statment, id, new_object_added, params, c);
- }
-
-
- template
- bool find_or_add_t(const std::string& sql_select_statment, const std::string& sql_insert_statment, OUT default_id_type& id, OUT bool& new_object_added, TParam1 parametr_1, TParam2 parametr_2, TParam3 parametr_3, t_conn& c)
- {
- ado_db_helper::adapter_triple params;
- params.tparam1 = parametr_1;
- params.tparam2 = parametr_2;
- params.tparam3 = parametr_3;
- return find_or_add_t_multiparametred(sql_select_statment, sql_insert_statment, id, new_object_added, params, c);
- }
-
- template
- bool find_or_add_t(const std::string& sql_select_statment, const std::string& sql_insert_statment, OUT default_id_type& id, OUT bool& new_object_added, TParam1 parametr_1, TParam2 parametr_2, TParam3 parametr_3, TParam4 parametr_4, t_conn& c)
- {
- ado_db_helper::adapter_quad params;
- params.tparam1 = parametr_1;
- params.tparam2 = parametr_2;
- params.tparam3 = parametr_3;
- params.tparam4 = parametr_4;
- return find_or_add_t_multiparametred(sql_select_statment, sql_insert_statment, id, new_object_added, params, c);
- }
-
- template
- bool find_or_add_t_multiparametred(const std::string& sql_select_statment, const std::string& sql_insert_statment, OUT default_id_type& id, OUT bool& new_object_added, TParams params, t_conn& c)
- {
-
- //CHECK_CONNECTION(false);
-
- new_object_added = false;
- ado_db_helper::table result_table;
-
- bool res = select_helper_multiparam(c.get_db_connection(), sql_select_statment, params, result_table);
- if(!result_table.size())
- {
- res = select_helper_multiparam(c.get_db_connection(), sql_insert_statment, params, result_table);
- if(!res || !result_table.size())
- {
- //last time try to select
- res = select_helper_multiparam(c.get_db_connection(), sql_select_statment, params, result_table);
- CHECK_AND_ASSERT_MES(res, false, "Failed to execute statment: " << sql_select_statment);
- CHECK_AND_ASSERT_MES(result_table.size(), false, "No records returned from statment: " << sql_select_statment);
- }else
- {
- new_object_added = true;
- }
- }
-
- BEGIN_TRY_SECTION()
- id = result_table[0][0];
- CATCH_TRY_SECTION_MESS(false, "while converting returned value [find_or_add_t_multiparametred()]");
-
- return true;
- }
-
-}
-}
-#endif //!_DB_HELPER_H_
diff --git a/contrib/epee/include/console_handler.h b/contrib/epee/include/console_handler.h
deleted file mode 100644
index a1df78395f..0000000000
--- a/contrib/epee/include/console_handler.h
+++ /dev/null
@@ -1,429 +0,0 @@
-// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
-// 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 Andrey N. Sabelnikov 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 THE COPYRIGHT OWNER 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.
-//
-
-#pragma once
-
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-#include "string_tools.h"
-
-namespace epee
-{
- class async_stdin_reader
- {
- public:
- async_stdin_reader()
- : m_run(true)
- , m_has_read_request(false)
- , m_read_status(state_init)
- {
- m_reader_thread = std::thread(std::bind(&async_stdin_reader::reader_thread_func, this));
- }
-
- ~async_stdin_reader()
- {
- stop();
- }
-
- // Not thread safe. Only one thread can call this method at once.
- bool get_line(std::string& line)
- {
- if (!start_read())
- return false;
-
- std::unique_lock lock(m_response_mutex);
- while (state_init == m_read_status)
- {
- m_response_cv.wait(lock);
- }
-
- bool res = false;
- if (state_success == m_read_status)
- {
- line = m_line;
- res = true;
- }
-
- m_read_status = state_init;
-
- return res;
- }
-
- void stop()
- {
- if (m_run)
- {
- m_run.store(false, std::memory_order_relaxed);
-
-#if defined(WIN32)
- ::CloseHandle(::GetStdHandle(STD_INPUT_HANDLE));
-#endif
-
- m_request_cv.notify_one();
- m_reader_thread.join();
- }
- }
-
- private:
- bool start_read()
- {
- std::unique_lock lock(m_request_mutex);
- if (!m_run.load(std::memory_order_relaxed) || m_has_read_request)
- return false;
-
- m_has_read_request = true;
- m_request_cv.notify_one();
- return true;
- }
-
- bool wait_read()
- {
- std::unique_lock lock(m_request_mutex);
- while (m_run.load(std::memory_order_relaxed) && !m_has_read_request)
- {
- m_request_cv.wait(lock);
- }
-
- if (m_has_read_request)
- {
- m_has_read_request = false;
- return true;
- }
-
- return false;
- }
-
- bool wait_stdin_data()
- {
-#if !defined(WIN32)
- int stdin_fileno = ::fileno(stdin);
-
- while (m_run.load(std::memory_order_relaxed))
- {
- fd_set read_set;
- FD_ZERO(&read_set);
- FD_SET(stdin_fileno, &read_set);
-
- struct timeval tv;
- tv.tv_sec = 0;
- tv.tv_usec = 100 * 1000;
-
- int retval = ::select(stdin_fileno + 1, &read_set, NULL, NULL, &tv);
- if (retval < 0)
- return false;
- else if (0 < retval)
- return true;
- }
-#endif
-
- return true;
- }
-
- void reader_thread_func()
- {
- while (true)
- {
- if (!wait_read())
- break;
-
- std::string line;
- bool read_ok = true;
- if (wait_stdin_data())
- {
- if (m_run.load(std::memory_order_relaxed))
- {
- std::getline(std::cin, line);
- read_ok = !std::cin.eof() && !std::cin.fail();
- }
- }
- else
- {
- read_ok = false;
- }
-
- {
- std::unique_lock lock(m_response_mutex);
- if (m_run.load(std::memory_order_relaxed))
- {
- m_line = std::move(line);
- m_read_status = read_ok ? state_success : state_error;
- }
- else
- {
- m_read_status = state_cancelled;
- }
- m_response_cv.notify_one();
- }
- }
- }
-
- enum t_state
- {
- state_init,
- state_success,
- state_error,
- state_cancelled
- };
-
- private:
- std::thread m_reader_thread;
- std::atomic m_run;
-
- std::string m_line;
- bool m_has_read_request;
- t_state m_read_status;
-
- std::mutex m_request_mutex;
- std::mutex m_response_mutex;
- std::condition_variable m_request_cv;
- std::condition_variable m_response_cv;
- };
-
-
- template
- bool empty_commands_handler(t_server* psrv, const std::string& command)
- {
- return true;
- }
-
-
- class async_console_handler
- {
- public:
- async_console_handler()
- {
- }
-
- template
- bool run(t_server* psrv, chain_handler ch_handler, const std::string& prompt = "#", const std::string& usage = "")
- {
- return run(prompt, usage, [&](const std::string& cmd) { return ch_handler(psrv, cmd); }, [&] { psrv->send_stop_signal(); });
- }
-
- template
- bool run(chain_handler ch_handler, const std::string& prompt = "#", const std::string& usage = "")
- {
- return run(prompt, usage, [&](const std::string& cmd) { return ch_handler(cmd); }, [] { });
- }
-
- void stop()
- {
- m_stdin_reader.stop();
- }
-
- private:
- template
- bool run(const std::string& prompt, const std::string& usage, const t_cmd_handler& cmd_handler, const t_exit_handler& exit_handler)
- {
- TRY_ENTRY();
- bool continue_handle = true;
- while(continue_handle)
- {
- if (!prompt.empty())
- {
- epee::log_space::set_console_color(epee::log_space::console_color_yellow, true);
- std::cout << prompt;
- if (' ' != prompt.back())
- std::cout << ' ';
- epee::log_space::reset_console_color();
- std::cout.flush();
- }
-
- std::string command;
- if(!m_stdin_reader.get_line(command))
- {
- LOG_PRINT("Failed to read line. Stopping...", LOG_LEVEL_0);
- continue_handle = false;
- break;
- }
- string_tools::trim(command);
-
- LOG_PRINT_L2("Read command: " << command);
- if(0 == command.compare("exit") || 0 == command.compare("q"))
- {
- continue_handle = false;
- }else if (command.empty())
- {
- continue;
- }
- else if(cmd_handler(command))
- {
- continue;
- } else
- {
- std::cout << "unknown command: " << command << std::endl;
- std::cout << usage;
- }
- }
- exit_handler();
- return true;
- CATCH_ENTRY_L0("console_handler", false);
- }
-
- private:
- async_stdin_reader m_stdin_reader;
- };
-
-
- template
- bool start_default_console(t_server* ptsrv, t_handler handlr, const std::string& prompt, const std::string& usage = "")
- {
- std::shared_ptr console_handler = std::make_shared();
- std::thread([=](){console_handler->run(ptsrv, handlr, prompt, usage);}).detach();
- return true;
- }
-
- template
- bool start_default_console(t_server* ptsrv, const std::string& prompt, const std::string& usage = "")
- {
- return start_default_console(ptsrv, empty_commands_handler, prompt, usage);
- }
-
- template
- bool no_srv_param_adapter(t_server* ptsrv, const std::string& cmd, t_handler handlr)
- {
- return handlr(cmd);
- }
-
- template
- bool run_default_console_handler_no_srv_param(t_server* ptsrv, t_handler handlr, const std::string& prompt, const std::string& usage = "")
- {
- async_console_handler console_handler;
- return console_handler.run(ptsrv, std::bind(no_srv_param_adapter, std::placeholders::_1, std::placeholders::_2, handlr), prompt, usage);
- }
-
- template
- bool start_default_console_handler_no_srv_param(t_server* ptsrv, t_handler handlr, const std::string& prompt, const std::string& usage = "")
- {
- std::thread( std::bind(run_default_console_handler_no_srv_param, ptsrv, handlr, prompt, usage) );
- return true;
- }
-
- /************************************************************************/
- /* */
- /************************************************************************/
- class console_handlers_binder
- {
- typedef std::function &)> console_command_handler;
- typedef std::map > command_handlers_map;
- std::unique_ptr m_console_thread;
- command_handlers_map m_command_handlers;
- async_console_handler m_console_handler;
- public:
- std::string get_usage()
- {
- std::stringstream ss;
- size_t max_command_len = 0;
- for(auto& x:m_command_handlers)
- if(x.first.size() > max_command_len)
- max_command_len = x.first.size();
-
- for(auto& x:m_command_handlers)
- {
- ss.width(max_command_len + 3);
- ss << std::left << x.first << x.second.second << ENDL;
- }
- return ss.str();
- }
- void set_handler(const std::string& cmd, const console_command_handler& hndlr, const std::string& usage = "")
- {
- command_handlers_map::mapped_type & vt = m_command_handlers[cmd];
- vt.first = hndlr;
- vt.second = usage;
- }
- bool process_command_vec(const std::vector& cmd)
- {
- if(!cmd.size())
- return false;
- auto it = m_command_handlers.find(cmd.front());
- if(it == m_command_handlers.end())
- return false;
- std::vector cmd_local(cmd.begin()+1, cmd.end());
- return it->second.first(cmd_local);
- }
-
- bool process_command_str(const std::string& cmd)
- {
- std::vector cmd_v;
- boost::split(cmd_v,cmd,boost::is_any_of(" "), boost::token_compress_on);
- return process_command_vec(cmd_v);
- }
-
- bool start_handling(const std::string& prompt, const std::string& usage_string = "")
- {
- m_console_thread.reset(new std::thread(std::bind(&console_handlers_binder::run_handling, this, prompt, usage_string)));
- m_console_thread->detach();
- return true;
- }
-
- void stop_handling()
- {
- m_console_handler.stop();
- }
-
- bool run_handling(const std::string& prompt, const std::string& usage_string)
- {
- return m_console_handler.run(std::bind(&console_handlers_binder::process_command_str, this, std::placeholders::_1), prompt, usage_string);
- }
- };
-
- /* work around because of broken boost bind */
- template
- class srv_console_handlers_binder: public console_handlers_binder
- {
- bool process_command_str(t_server* /*psrv*/, const std::string& cmd)
- {
- return console_handlers_binder::process_command_str(cmd);
- }
- public:
- bool start_handling(t_server* psrv, const std::string& prompt, const std::string& usage_string = "")
- {
- std::thread(std::bind(&srv_console_handlers_binder::run_handling, this, psrv, prompt, usage_string)).detach();
- return true;
- }
-
- bool run_handling(t_server* psrv, const std::string& prompt, const std::string& usage_string)
- {
- return m_console_handler.run(psrv, std::bind(&srv_console_handlers_binder::process_command_str, this,
- std::placeholders::_1, std::placeholders::_2), prompt, usage_string);
- }
-
- void stop_handling()
- {
- m_console_handler.stop();
- }
-
- private:
- async_console_handler m_console_handler;
- };
-}
diff --git a/contrib/epee/include/copyable_atomic.h b/contrib/epee/include/copyable_atomic.h
deleted file mode 100644
index 6b5691ab11..0000000000
--- a/contrib/epee/include/copyable_atomic.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
-// 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 Andrey N. Sabelnikov 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 THE COPYRIGHT OWNER 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.
-//
-
-#pragma once
-
-#include
-
-namespace epee
-{
- class copyable_atomic: public std::atomic
- {
- public:
- copyable_atomic()
- {};
- copyable_atomic(const copyable_atomic& a):std::atomic(a.load())
- {}
- copyable_atomic& operator= (const copyable_atomic& a)
- {
- store(a.load());
- return *this;
- }
- uint32_t operator++()
- {
- return std::atomic::operator++();
- }
- uint32_t operator++(int fake)
- {
- return std::atomic::operator++(fake);
- }
- };
-}
\ No newline at end of file
diff --git a/contrib/epee/include/file_io_utils.h b/contrib/epee/include/file_io_utils.h
deleted file mode 100644
index 01d70db3ef..0000000000
--- a/contrib/epee/include/file_io_utils.h
+++ /dev/null
@@ -1,452 +0,0 @@
-// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
-// 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 Andrey N. Sabelnikov 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 THE COPYRIGHT OWNER 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 _FILE_IO_UTILS_H_
-#define _FILE_IO_UTILS_H_
-
-#include
-#include
-#include
-
-
-#ifndef MAKE64
- #define MAKE64(low,high) ((__int64)(((DWORD)(low)) | ((__int64)((DWORD)(high))) << 32))
-#endif
-
-#ifdef WINDOWS_PLATFORM
-#include
-#include
-#include
-#include
-
-#endif
-
-
-
-namespace epee
-{
-namespace file_io_utils
-{
-#ifdef WINDOWS_PLATFORM
-
- inline
- std::string get_temp_file_name_a()
- {
- std::string str_result;
- char sz_temp[MAX_PATH*2] = {0};
- if(!::GetTempPathA( sizeof( sz_temp ), sz_temp ))
- return str_result;
-
- char sz_temp_file[MAX_PATH*2] = {0};
- if(!::GetTempFileNameA( sz_temp, "mail", 0, sz_temp_file))
- return str_result;
- sz_temp_file[sizeof(sz_temp_file)-1] = 0; //be happy!
- str_result = sz_temp_file;
- return str_result;
- }
-
-
-#ifdef BOOST_LEXICAL_CAST_INCLUDED
- inline
- bool get_not_used_filename(const std::string& folder, std::string& result_name)
- {
- DWORD folder_attr = ::GetFileAttributesA(folder.c_str());
- if(folder_attr == INVALID_FILE_ATTRIBUTES)
- return false;
- if(!(folder_attr&FILE_ATTRIBUTE_DIRECTORY))
- return false;
-
-
- std::string base_name = folder + "\\tmp";
- std::string tmp_name;
- bool name_found = false;
- int current_index = 0;
- tmp_name = base_name + boost::lexical_cast(current_index) + ".tmp";
- while(!name_found)
- {
- if(INVALID_FILE_ATTRIBUTES == ::GetFileAttributesA(tmp_name.c_str()))
- name_found = true;
- else
- {
- current_index++;
- tmp_name = base_name + boost::lexical_cast(current_index) + ".tmp";
- }
- }
- result_name = tmp_name;
- return true;
- }
-#endif
-
- inline
- std::string get_temp_folder_a()
- {
- std::string str_result;
- char sz_temp[MAX_PATH*2] = {0};
- if(!::GetTempPathA( sizeof( sz_temp ), sz_temp ))
- return str_result;
- sz_temp[(sizeof(sz_temp)/sizeof(sz_temp[0])) -1] = 0;
- str_result = sz_temp;
- return str_result;
- }
-
- std::string convert_from_device_path_to_standart(const std::string& path)
- {
-
-
- STRSAFE_LPSTR pszFilename = (STRSAFE_LPSTR)path.c_str();
-
- // Translate path with device name to drive letters.
- char szTemp[4000] = {0};
-
- if (::GetLogicalDriveStringsA(sizeof(szTemp)-1, szTemp))
- {
- char szName[MAX_PATH];
- char szDrive[3] = " :";
- BOOL bFound = FALSE;
- char* p = szTemp;
-
- do
- {
- // Copy the drive letter to the template string
- *szDrive = *p;
-
- // Look up each device name
- if (::QueryDosDeviceA(szDrive, szName, sizeof(szName)))
- {
- UINT uNameLen = strlen(szName);
-
- if (uNameLen < MAX_PATH)
- {
- bFound = _mbsnbicmp((const unsigned char*)pszFilename, (const unsigned char*)szName,
- uNameLen) == 0;
-
- if (bFound)
- {
- // Reconstruct pszFilename using szTempFile
- // Replace device path with DOS path
- char szTempFile[MAX_PATH] = {0};
- StringCchPrintfA(szTempFile,
- MAX_PATH,
- "%s%s",
- szDrive,
- pszFilename+uNameLen);
- return szTempFile;
- //::StringCchCopyNA(pszFilename, MAX_PATH+1, szTempFile, strlen(szTempFile));
- }
- }
- }
-
- // Go to the next NULL character.
- while (*p++);
- } while (!bFound && *p); // end of string
- }
-
- return "";
- }
-
- inline
- std::string get_process_path_by_pid(DWORD pid)
- {
- std::string res;
-
- HANDLE hprocess = 0;
- if( hprocess = ::OpenProcess( PROCESS_QUERY_INFORMATION|PROCESS_VM_READ, FALSE, pid) )
- {
- char buff[MAX_PATH]= {0};
- if(!::GetModuleFileNameExA( hprocess, 0, buff, MAX_PATH - 1 ))
- res = "Unknown_b";
- else
- {
- buff[MAX_PATH - 1]=0; //be happy!
- res = buff;
- std::string::size_type a = res.rfind( '\\' );
- if ( a != std::string::npos )
- res.erase( 0, a+1);
-
- }
- ::CloseHandle( hprocess );
- }else
- res = "Unknown_a";
-
- return res;
- }
-
-
-
-
-
- inline
- std::wstring get_temp_file_name_w()
- {
- std::wstring str_result;
- wchar_t sz_temp[MAX_PATH*2] = {0};
- if(!::GetTempPathW( sizeof(sz_temp)/sizeof(sz_temp[0]), sz_temp ))
- return str_result;
-
- wchar_t sz_temp_file[MAX_PATH+1] = {0};
- if(!::GetTempFileNameW( sz_temp, L"mail", 0, sz_temp_file))
- return str_result;
-
- sz_temp_file[(sizeof(sz_temp_file)/sizeof(sz_temp_file[0]))-1] = 0; //be happy!
- str_result = sz_temp_file;
- return str_result;
- }
-#endif
- inline
- bool is_file_exist(const std::string& path)
- {
- boost::filesystem::path p(path);
- return boost::filesystem::exists(p);
- }
-
- /*
- inline
- bool save_string_to_handle(HANDLE hfile, const std::string& str)
- {
-
-
-
- if( INVALID_HANDLE_VALUE != hfile )
- {
- DWORD dw;
- if( !::WriteFile( hfile, str.data(), (DWORD) str.size(), &dw, NULL) )
- {
- int err_code = GetLastError();
- //LOG_PRINT("Failed to write to file handle: " << hfile<< " Last error code:" << err_code << " : " << log_space::get_win32_err_descr(err_code), LOG_LEVEL_2);
- return false;
- }
- ::CloseHandle(hfile);
- return true;
- }else
- {
- //LOG_WIN32_ERROR(::GetLastError());
- return false;
- }
-
- return false;
- }*/
-
-
-
- inline
- bool save_string_to_file(const std::string& path_to_file, const std::string& str)
- {
-
- try
- {
- std::ofstream fstream;
- fstream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
- fstream.open(path_to_file, std::ios_base::binary | std::ios_base::out | std::ios_base::trunc);
- fstream << str;
- fstream.close();
- return true;
- }
-
- catch(...)
- {
- return false;
- }
- }
-
- /*
- inline
- bool load_form_handle(HANDLE hfile, std::string& str)
- {
- if( INVALID_HANDLE_VALUE != hfile )
- {
- bool res = true;
- DWORD dw = 0;
- DWORD fsize = ::GetFileSize(hfile, &dw);
- if(fsize > 300000000)
- {
- ::CloseHandle(hfile);
- return false;
- }
- if(fsize)
- {
- str.resize(fsize);
- if(!::ReadFile( hfile, (LPVOID)str.data(), (DWORD)str.size(), &dw, NULL))
- res = false;
- }
- ::CloseHandle(hfile);
- return res;
- }
- return false;
- }
- */
- inline
- bool get_file_time(const std::string& path_to_file, time_t& ft)
- {
- boost::system::error_code ec;
- ft = boost::filesystem::last_write_time(boost::filesystem::path(path_to_file), ec);
- if(!ec)
- return true;
- else
- return false;
- }
-
- inline
- bool set_file_time(const std::string& path_to_file, const time_t& ft)
- {
- boost::system::error_code ec;
- boost::filesystem::last_write_time(boost::filesystem::path(path_to_file), ft, ec);
- if(!ec)
- return true;
- else
- return false;
- }
-
-
- inline
- bool load_file_to_string(const std::string& path_to_file, std::string& target_str)
- {
- try
- {
- std::ifstream fstream;
- fstream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
- fstream.open(path_to_file, std::ios_base::binary | std::ios_base::in | std::ios::ate);
-
- std::ifstream::pos_type file_size = fstream.tellg();
-
- if(file_size > 1000000000)
- return false;//don't go crazy
- size_t file_size_t = static_cast(file_size);
-
- target_str.resize(file_size_t);
-
- fstream.seekg (0, std::ios::beg);
- fstream.read((char*)target_str.data(), target_str.size());
- fstream.close();
- return true;
- }
-
- catch(...)
- {
- return false;
- }
- }
-
- inline
- bool append_string_to_file(const std::string& path_to_file, const std::string& str)
- {
- try
- {
- std::ofstream fstream;
- fstream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
- fstream.open(path_to_file.c_str(), std::ios_base::binary | std::ios_base::out | std::ios_base::app);
- fstream << str;
- fstream.close();
- return true;
- }
-
- catch(...)
- {
- return false;
- }
- }
-
- /*
- bool remove_dir_and_subirs(const char* path_to_dir);
-
- inline
- bool clean_dir(const char* path_to_dir)
- {
- if(!path_to_dir)
- return false;
-
- std::string folder = path_to_dir;
- WIN32_FIND_DATAA find_data = {0};
- HANDLE hfind = ::FindFirstFileA((folder + "\\*.*").c_str(), &find_data);
- if(INVALID_HANDLE_VALUE == hfind)
- return false;
- do{
- if(!strcmp("..", find_data.cFileName) || (!strcmp(".", find_data.cFileName)))
- continue;
-
- if(find_data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
- {
- if(!remove_dir_and_subirs((folder + "\\" + find_data.cFileName).c_str()))
- return false;
- }else
- {
- if(!::DeleteFileA((folder + "\\" + find_data.cFileName).c_str()))
- return false;
- }
-
-
- }while(::FindNextFileA(hfind, &find_data));
- ::FindClose(hfind);
-
- return true;
- }
- */
-#ifdef WINDOWS_PLATFORM
- inline bool get_folder_content(const std::string& path, std::list& target_list)
- {
- WIN32_FIND_DATAA find_data = {0};
- HANDLE hfind = ::FindFirstFileA((path + "\\*.*").c_str(), &find_data);
- if(INVALID_HANDLE_VALUE == hfind)
- return false;
- do{
- if(!strcmp("..", find_data.cFileName) || (!strcmp(".", find_data.cFileName)))
- continue;
-
- target_list.push_back(find_data);
-
- }while(::FindNextFileA(hfind, &find_data));
- ::FindClose(hfind);
-
- return true;
- }
-#endif
- inline bool get_folder_content(const std::string& path, std::list& target_list, bool only_files = false)
- {
- try
- {
-
- boost::filesystem::directory_iterator end_itr; // default construction yields past-the-end
- for ( boost::filesystem::directory_iterator itr( path ); itr != end_itr; ++itr )
- {
- if ( only_files && boost::filesystem::is_directory(itr->status()) )
- {
- continue;
- }
- target_list.push_back(itr->path().filename().string());
- }
-
- }
-
- catch(...)
- {
- return false;
- }
- return true;
- }
-}
-}
-
-#endif //_FILE_IO_UTILS_H_
diff --git a/contrib/epee/include/global_stream_operators.h b/contrib/epee/include/global_stream_operators.h
deleted file mode 100644
index 6fbdbc2edb..0000000000
--- a/contrib/epee/include/global_stream_operators.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
-// 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 Andrey N. Sabelnikov 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 THE COPYRIGHT OWNER 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.
-//
-
-
-#pragma once
-
-std::stringstream& operator<<(std::stringstream& out, const std::wstring& ws)
-{
- std::string as = string_encoding::convert_to_ansii(ws);
- out << as;
- return out;
-}
diff --git a/contrib/epee/include/gzip_encoding.h b/contrib/epee/include/gzip_encoding.h
deleted file mode 100644
index 2be51e77d6..0000000000
--- a/contrib/epee/include/gzip_encoding.h
+++ /dev/null
@@ -1,227 +0,0 @@
-// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
-// 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 Andrey N. Sabelnikov 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 THE COPYRIGHT OWNER 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 _GZIP_ENCODING_H_
-#define _GZIP_ENCODING_H_
-#include "net/http_client_base.h"
-#include "zlib/zlib.h"
-//#include "http.h"
-
-
-namespace epee
-{
-namespace net_utils
-{
-
-
-
- class content_encoding_gzip: public i_sub_handler
- {
- public:
- /*! \brief
- * Function content_encoding_gzip : Constructor
- *
- */
- inline
- content_encoding_gzip(i_target_handler* powner_filter, bool is_deflate_mode = false):m_powner_filter(powner_filter),
- m_is_stream_ended(false),
- m_is_deflate_mode(is_deflate_mode),
- m_is_first_update_in(true)
- {
- memset(&m_zstream_in, 0, sizeof(m_zstream_in));
- memset(&m_zstream_out, 0, sizeof(m_zstream_out));
- int ret = 0;
- if(is_deflate_mode)
- {
- ret = inflateInit(&m_zstream_in);
- ret = deflateInit(&m_zstream_out, Z_DEFAULT_COMPRESSION);
- }else
- {
- ret = inflateInit2(&m_zstream_in, 0x1F);
- ret = deflateInit2(&m_zstream_out, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 0x1F, 8, Z_DEFAULT_STRATEGY);
- }
- }
- /*! \brief
- * Function content_encoding_gzip : Destructor
- *
- */
- inline
- ~content_encoding_gzip()
- {
- inflateEnd(& m_zstream_in );
- deflateEnd(& m_zstream_out );
- }
- /*! \brief
- * Function update_in : Entry point for income data
- *
- */
- inline
- virtual bool update_in( std::string& piece_of_transfer)
- {
-
- bool is_first_time_here = m_is_first_update_in;
- m_is_first_update_in = false;
-
- if(m_pre_decode.size())
- m_pre_decode += piece_of_transfer;
- else
- m_pre_decode.swap(piece_of_transfer);
- piece_of_transfer.clear();
-
- std::string decode_summary_buff;
-
- size_t ungzip_size = m_pre_decode.size() * 0x30;
- std::string current_decode_buff(ungzip_size, 'X');
-
- //Here the cycle is introduced where we unpack the buffer, the cycle is required
- //because of the case where if after unpacking the data will exceed the awaited size, we will not halt with error
- bool continue_unpacking = true;
- bool first_step = true;
- while(m_pre_decode.size() && continue_unpacking)
- {
-
- //fill buffers
- m_zstream_in.next_in = (Bytef*)m_pre_decode.data();
- m_zstream_in.avail_in = (uInt)m_pre_decode.size();
- m_zstream_in.next_out = (Bytef*)current_decode_buff.data();
- m_zstream_in.avail_out = (uInt)ungzip_size;
-
- int flag = Z_SYNC_FLUSH;
- int ret = inflate(&m_zstream_in, flag);
- CHECK_AND_ASSERT_MES(ret>=0 || m_zstream_in.avail_out ||m_is_deflate_mode, false, "content_encoding_gzip::update_in() Failed to inflate. err = " << ret);
-
- if(Z_STREAM_END == ret)
- m_is_stream_ended = true;
- else if(Z_DATA_ERROR == ret && is_first_time_here && m_is_deflate_mode&& first_step)
- {
- // some servers (notably Apache with mod_deflate) don't generate zlib headers
- // insert a dummy header and try again
- static char dummy_head[2] =
- {
- 0x8 + 0x7 * 0x10,
- (((0x8 + 0x7 * 0x10) * 0x100 + 30) / 31 * 31) & 0xFF,
- };
- inflateReset(&m_zstream_in);
- m_zstream_in.next_in = (Bytef*) dummy_head;
- m_zstream_in.avail_in = sizeof(dummy_head);
-
- ret = inflate(&m_zstream_in, Z_NO_FLUSH);
- if (ret != Z_OK)
- {
- LOCAL_ASSERT(0);
- m_pre_decode.swap(piece_of_transfer);
- return false;
- }
- m_zstream_in.next_in = (Bytef*)m_pre_decode.data();
- m_zstream_in.avail_in = (uInt)m_pre_decode.size();
-
- ret = inflate(&m_zstream_in, Z_NO_FLUSH);
- if (ret != Z_OK)
- {
- LOCAL_ASSERT(0);
- m_pre_decode.swap(piece_of_transfer);
- return false;
- }
- }
-
-
- //leave only unpacked part in the output buffer to start with it the next time
- m_pre_decode.erase(0, m_pre_decode.size()-m_zstream_in.avail_in);
- //if decoder gave nothing to return, then everything is ahead, now simply break
- if(ungzip_size == m_zstream_in.avail_out)
- break;
-
- //decode_buff currently stores data parts that were unpacked, fix this size
- current_decode_buff.resize(ungzip_size - m_zstream_in.avail_out);
- if(decode_summary_buff.size())
- decode_summary_buff += current_decode_buff;
- else
- current_decode_buff.swap(decode_summary_buff);
-
- current_decode_buff.resize(ungzip_size);
- first_step = false;
- }
-
- //Process these data if required
- bool res = true;
-
- res = m_powner_filter->handle_target_data(decode_summary_buff);
-
- return true;
-
- }
- /*! \brief
- * Function stop : Entry point for stop signal and flushing cached data buffer.
- *
- */
- inline
- virtual void stop(std::string& OUT collect_remains)
- {
- }
- protected:
- private:
- /*! \brief
- * Pointer to parent HTTP-parser
- */
- i_target_handler* m_powner_filter;
- /*! \brief
- * ZLIB object for income stream
- */
- z_stream m_zstream_in;
- /*! \brief
- * ZLIB object for outcome stream
- */
- z_stream m_zstream_out;
- /*! \brief
- * Data that could not be unpacked immediately, left to wait for the next packet of data
- */
- std::string m_pre_decode;
- /*! \brief
- * The data are accumulated for a package in the buffer to send the web client
- */
- std::string m_pre_encode;
- /*! \brief
- * Signals that stream looks like ended
- */
- bool m_is_stream_ended;
- /*! \brief
- * If this flag is set, income data is in HTTP-deflate mode
- */
- bool m_is_deflate_mode;
- /*! \brief
- * Marks that it is a first data packet
- */
- bool m_is_first_update_in;
- };
-}
-}
-
-
-
-#endif //_GZIP_ENCODING_H_
diff --git a/contrib/epee/include/hmac-md5.h b/contrib/epee/include/hmac-md5.h
deleted file mode 100644
index 2a4e0d401a..0000000000
--- a/contrib/epee/include/hmac-md5.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * libEtPan! -- a mail stuff library
- *
- * Copyright (C) 2001, 2005 - DINH Viet Hoa
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the libEtPan! 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 AUTHORS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* hmac-md5.h -- HMAC_MD5 functions
- */
-
-/*
- * $Id: hmac-md5.h,v 1.1.1.1 2005/03/18 20:17:28 zautrix Exp $
- */
-
-#ifndef HMAC_MD5_H
-#define HMAC_MD5_H 1
-
-namespace md5
-{
-
-
-
-#define HMAC_MD5_SIZE 16
-
- /* intermediate MD5 context */
- typedef struct HMAC_MD5_CTX_s {
- MD5_CTX ictx, octx;
- } HMAC_MD5_CTX;
-
- /* intermediate HMAC state
- * values stored in network byte order (Big Endian)
- */
- typedef struct HMAC_MD5_STATE_s {
- UINT4 istate[4];
- UINT4 ostate[4];
- } HMAC_MD5_STATE;
-
- /* One step hmac computation
- *
- * digest may be same as text or key
- */
- void hmac_md5(const unsigned char *text, int text_len,
- const unsigned char *key, int key_len,
- unsigned char digest[HMAC_MD5_SIZE]);
-
- /* create context from key
- */
- void hmac_md5_init(HMAC_MD5_CTX *hmac,
- const unsigned char *key, int key_len);
-
- /* precalculate intermediate state from key
- */
- void hmac_md5_precalc(HMAC_MD5_STATE *hmac,
- const unsigned char *key, int key_len);
-
- /* initialize context from intermediate state
- */
- void hmac_md5_import(HMAC_MD5_CTX *hmac, HMAC_MD5_STATE *state);
-
-#define hmac_md5_update(hmac, text, text_len) MD5Update(&(hmac)->ictx, (text), (text_len))
-
- /* finish hmac from intermediate result. Intermediate result is zeroed.
- */
- void hmac_md5_final(unsigned char digest[HMAC_MD5_SIZE],
- HMAC_MD5_CTX *hmac);
-
-}
-
-#endif /* HMAC_MD5_H */
diff --git a/contrib/epee/include/include_base_utils.h b/contrib/epee/include/include_base_utils.h
deleted file mode 100644
index 8412a0083c..0000000000
--- a/contrib/epee/include/include_base_utils.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
-// 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 Andrey N. Sabelnikov 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 THE COPYRIGHT OWNER 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.
-//
-
-#pragma once
-
-#define BOOST_FILESYSTEM_VERSION 3
-#define ENABLE_RELEASE_LOGGING
-
-#include "misc_log_ex.h"
-
-
diff --git a/contrib/epee/include/math_helper.h b/contrib/epee/include/math_helper.h
deleted file mode 100644
index 11faa9762f..0000000000
--- a/contrib/epee/include/math_helper.h
+++ /dev/null
@@ -1,273 +0,0 @@
-// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
-// 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 Andrey N. Sabelnikov 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 THE COPYRIGHT OWNER 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.
-//
-
-
-
-
-#pragma once
-
-
-#include
-#include
-#include
-#include
-#include
-
-#include "misc_os_dependent.h"
-#include "pragma_comp_defs.h"
-
-namespace epee
-{
-namespace math_helper
-{
-
- template
- class average
- {
- public:
-
- average()
- {
- m_base = default_base;
- m_last_avg_val = 0;
- }
-
- bool set_base()
- {
- CRITICAL_REGION_LOCAL(m_lock);
-
- m_base = default_base;
- if(m_list.size() > m_base)
- m_list.resize(m_base);
-
- return true;
- }
-
- typedef val value_type;
-
- void push(const value_type& vl)
- {
- CRITICAL_REGION_LOCAL(m_lock);
-
-//#ifndef DEBUG_STUB
- m_list.push_back(vl);
- if(m_list.size() > m_base )
- m_list.pop_front();
-//#endif
- }
-
- double update(const value_type& vl)
- {
- CRITICAL_REGION_LOCAL(m_lock);
-//#ifndef DEBUG_STUB
- push(vl);
-//#endif
-
- return get_avg();
- }
-
- double get_avg()
- {
- CRITICAL_REGION_LOCAL(m_lock);
-
- value_type vl = std::accumulate(m_list.begin(), m_list.end(), value_type(0));
- if(m_list.size())
- return m_last_avg_val = (double)(vl/m_list.size());
-
- return m_last_avg_val = (double)vl;
- }
-
- value_type get_last_val()
- {
- CRITICAL_REGION_LOCAL(m_lock);
- if(m_list.size())
- return m_list.back();
-
- return 0;
- }
-
- private:
- unsigned int m_base;
- double m_last_avg_val;
- std::list m_list;
- critical_section m_lock;
- };
-
-
-#ifdef WINDOWS_PLATFORM
-
- /************************************************************************/
- /* */
- /************************************************************************/
- class timing_guard_base
- {
- public:
- virtual ~timing_guard_base(){};
- };
-
- template
- class timing_guard: public timing_guard_base
- {
- public:
- timing_guard(T& avrg):m_avrg(avrg)
- {
- m_start_ticks = ::GetTickCount();
- }
-
- ~timing_guard()
- {
- m_avrg.push(::GetTickCount()-m_start_ticks);
- }
-
- private:
- T& m_avrg;
- DWORD m_start_ticks;
- };
-
- template
- timing_guard_base* create_timing_guard(t_timing& timing){return new timing_guard(timing);}
-
-#define BEGIN_TIMING_ZONE(timing_var) { boost::shared_ptr local_timing_guard_ptr(math_helper::create_timing_guard(timing_var));
-#define END_TIMING_ZONE() }
-#endif
-
-//#ifdef WINDOWS_PLATFORM_EX
- template
- class speed
- {
- public:
-
- speed()
- {
- m_time_window = default_time_window;
- m_last_speed_value = 0;
- }
- bool chick()
- {
-#ifndef DEBUG_STUB
- uint64_t ticks = misc_utils::get_tick_count();
- CRITICAL_REGION_BEGIN(m_lock);
- m_chicks.push_back(ticks);
- CRITICAL_REGION_END();
- //flush(ticks);
-#endif
- return true;
- }
-
- bool chick(size_t count)
- {
- for(size_t s = 0; s != count; s++)
- chick();
-
- return true;
- }
-
-
- size_t get_speed()
- {
- flush(misc_utils::get_tick_count());
- return m_last_speed_value = m_chicks.size();
- }
- private:
-
- bool flush(uint64_t ticks)
- {
- CRITICAL_REGION_BEGIN(m_lock);
- std::list::iterator it = m_chicks.begin();
- while(it != m_chicks.end())
- {
- if(*it + m_time_window < ticks)
- m_chicks.erase(it++);
- else
- break;
- }
- CRITICAL_REGION_END();
- return true;
- }
-
- std::list m_chicks;
- uint64_t m_time_window;
- size_t m_last_speed_value;
- critical_section m_lock;
- };
-//#endif
-
- template
- void randomize_list(tlist& t_list)
- {
- for(typename tlist::iterator it = t_list.begin();it!=t_list.end();it++)
- {
- size_t offset = rand()%t_list.size();
- typename tlist::iterator it_2 = t_list.begin();
- for(size_t local_offset = 0;local_offset!=offset;local_offset++)
- it_2++;
- if(it_2 == it)
- continue;
- std::swap(*it_2, *it);
- }
-
- }
-PRAGMA_WARNING_PUSH
-PRAGMA_GCC("GCC diagnostic ignored \"-Wstrict-aliasing\"")
- inline
- uint64_t generated_random_uint64()
- {
- boost::uuids::uuid id___ = boost::uuids::random_generator()();
- return *reinterpret_cast(&id___.data[0]); //(*reinterpret_cast(&id___.data[0]) ^ *reinterpret_cast(&id___.data[8]));
- }
-PRAGMA_WARNING_POP
- template
- class once_a_time_seconds
- {
- public:
- once_a_time_seconds():m_interval(default_interval)
- {
- m_last_worked_time = 0;
- if(!start_immediate)
- time(&m_last_worked_time);
- }
-
- template
- bool do_call(functor_t functr)
- {
- time_t current_time = 0;
- time(¤t_time);
-
- if(current_time - m_last_worked_time > m_interval)
- {
- bool res = functr();
- time(&m_last_worked_time);
- return res;
- }
- return true;
- }
-
- private:
- time_t m_last_worked_time;
- time_t m_interval;
- };
-}
-}
\ No newline at end of file
diff --git a/contrib/epee/include/md5_l.h b/contrib/epee/include/md5_l.h
deleted file mode 100644
index fe4c67db62..0000000000
--- a/contrib/epee/include/md5_l.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * libEtPan! -- a mail stuff library
- *
- * Copyright (C) 2001, 2005 - DINH Viet Hoa
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the libEtPan! 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 AUTHORS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * $Id: md5.h,v 1.1.1.1 2005/03/18 20:17:27 zautrix Exp $
- */
-
-/* MD5.H - header file for MD5C.C
- */
-
-/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
-rights reserved.
-
-License to copy and use this software is granted provided that it
-is identified as the "RSA Data Security, Inc. MD5 Message-Digest
-Algorithm" in all material mentioning or referencing this software
-or this function.
-
-License is also granted to make and use derivative works provided
-that such works are identified as "derived from the RSA Data
-Security, Inc. MD5 Message-Digest Algorithm" in all material
-mentioning or referencing the derived work.
-
-RSA Data Security, Inc. makes no representations concerning either
-the merchantability of this software or the suitability of this
-software for any particular purpose. It is provided "as is"
-without express or implied warranty of any kind.
-These notices must be retained in any copies of any part of this
-documentation and/or software.
- */
-#ifndef MD5_H
-#define MD5_H
-
-
-#include "md5global.h"
-
-namespace md5
-{
- /* MD5 context. */
- typedef struct {
- UINT4 state[4]; /* state (ABCD) */
- UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
- unsigned char buffer[64]; /* input buffer */
- } MD5_CTX;
-
- static void MD5Init(MD5_CTX * context);
- static void MD5Update( MD5_CTX *context, const unsigned char *input, unsigned int inputLen );
- static void MD5Final ( unsigned char digest[16], MD5_CTX *context );
- static void hmac_md5(const unsigned char* text, int text_len, const unsigned char* key, int key_len, unsigned char *digest);
-
-
- inline bool md5( unsigned char *input, int ilen, unsigned char output[16] )
- {
- MD5_CTX ctx;
-
- MD5Init( &ctx );
- MD5Update( &ctx, input, ilen );
- MD5Final( output, &ctx);
-
- memset( &ctx, 0, sizeof( MD5_CTX) );
- return true;
- }
-
-
-}
-
-#include "md5_l.inl"
-
-#endif
diff --git a/contrib/epee/include/md5_l.inl b/contrib/epee/include/md5_l.inl
deleted file mode 100644
index c3da1a3b07..0000000000
--- a/contrib/epee/include/md5_l.inl
+++ /dev/null
@@ -1,563 +0,0 @@
-/*
-* libEtPan! -- a mail stuff library
-*
-* Copyright (C) 2001, 2005 - DINH Viet Hoa
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-* 1. Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* 3. Neither the name of the libEtPan! 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 AUTHORS AND CONTRIBUTORS ``AS IS'' AND
-* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-* SUCH DAMAGE.
-*/
-
-/*
-* $Id: md5.c,v 1.1.1.1 2005/03/18 20:17:27 zautrix Exp $
-*/
-
-/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
-*/
-
-/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
-rights reserved.
-
-License to copy and use this software is granted provided that it
-is identified as the "RSA Data Security, Inc. MD5 Message-Digest
-Algorithm" in all material mentioning or referencing this software
-or this function.
-
-License is also granted to make and use derivative works provided
-that such works are identified as "derived from the RSA Data
-Security, Inc. MD5 Message-Digest Algorithm" in all material
-mentioning or referencing the derived work.
-
-RSA Data Security, Inc. makes no representations concerning either
-the merchantability of this software or the suitability of this
-software for any particular purpose. It is provided "as is"
-without express or implied warranty of any kind.
-
-These notices must be retained in any copies of any part of this
-documentation and/or software.
-*/
-
-/* do i need all of this just for htonl()? damn. */
-//#include
-//#include
-//#include
-//#include
-
-
-
-#include "md5global.h"
-#include "md5_l.h"
-#include "hmac-md5.h"
-
-namespace md5
-{
- /* Constants for MD5Transform routine.
- */
-
-#define S11 7
-#define S12 12
-#define S13 17
-#define S14 22
-#define S21 5
-#define S22 9
-#define S23 14
-#define S24 20
-#define S31 4
-#define S32 11
-#define S33 16
-#define S34 23
-#define S41 6
-#define S42 10
-#define S43 15
-#define S44 21
-
- /*
- static void MD5Transform PROTO_LIST ((UINT4 [4], unsigned char [64]));
- static void Encode PROTO_LIST
- ((unsigned char *, UINT4 *, unsigned int));
- static void Decode PROTO_LIST
- ((UINT4 *, unsigned char *, unsigned int));
- static void MD5_memcpy PROTO_LIST ((POINTER, POINTER, unsigned int));
- static void MD5_memset PROTO_LIST ((POINTER, int, unsigned int));
- */
-
- static void MD5_memcpy (POINTER output, POINTER input, unsigned int len)
- {
- unsigned int i;
-
- for (i = 0; i < len; i++)
- output[i] = input[i];
- }
-
- /* Note: Replace "for loop" with standard memset if possible.
- */
-
- static void MD5_memset (POINTER output, int value, unsigned int len)
- {
- unsigned int i;
-
- for (i = 0; i < len; i++)
- ((char *)output)[i] = (char)value;
- }
-
- static void MD5Transform (UINT4 state[4], unsigned char block[64]);
-
- static unsigned char* PADDING()
- {
- static unsigned char local_PADDING[64] = {
- 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
-
- return local_PADDING;
-
- }
-
-
-
- /* F, G, H and I are basic MD5 functions.
-
- */
-#ifdef I
- /* This might be defined via NANA */
-#undef I
-#endif
-
-#define MD5_M_F(x, y, z) (((x) & (y)) | ((~x) & (z)))
-#define MD5_M_G(x, y, z) (((x) & (z)) | ((y) & (~z)))
-#define MD5_M_H(x, y, z) ((x) ^ (y) ^ (z))
-#define MD5_M_I(x, y, z) ((y) ^ ((x) | (~z)))
-
- /* ROTATE_LEFT rotates x left n bits.
-
- */
-
-#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
-
- /* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
- Rotation is separate from addition to prevent recomputation.
- */
-
-#define FF(a, b, c, d, x, s, ac) { (a) += MD5_M_F ((b), (c), (d)) + (x) + (UINT4)(ac); (a) = ROTATE_LEFT ((a), (s)); (a) += (b); }
-#define GG(a, b, c, d, x, s, ac) { (a) += MD5_M_G ((b), (c), (d)) + (x) + (UINT4)(ac); (a) = ROTATE_LEFT ((a), (s)); (a) += (b); }
-#define HH(a, b, c, d, x, s, ac) { (a) += MD5_M_H ((b), (c), (d)) + (x) + (UINT4)(ac); (a) = ROTATE_LEFT ((a), (s)); (a) += (b); }
-#define II(a, b, c, d, x, s, ac) { (a) += MD5_M_I ((b), (c), (d)) + (x) + (UINT4)(ac); (a) = ROTATE_LEFT ((a), (s)); (a) += (b); }
-
- /* MD5 initialization. Begins an MD5 operation, writing a new context.
- */
-
- static void MD5Init(MD5_CTX * context)
- {
- context->count[0] = context->count[1] = 0;
-
- /* Load magic initialization constants.
-
- */
- context->state[0] = 0x67452301;
- context->state[1] = 0xefcdab89;
- context->state[2] = 0x98badcfe;
- context->state[3] = 0x10325476;
- }
-
- /* MD5 block update operation. Continues an MD5 message-digest
- operation, processing another message block, and updating the context.
- */
-
- static void MD5Update( MD5_CTX *context, const unsigned char *input, unsigned int inputLen )
- {
- unsigned int i, index, partLen;
-
- /* Compute number of bytes mod 64 */
- index = (unsigned int)((context->count[0] >> 3) & 0x3F);
-
- /* Update number of bits */
- if ((context->count[0] += ((UINT4)inputLen << 3))
- < ((UINT4)inputLen << 3))
- context->count[1]++;
- context->count[1] += ((UINT4)inputLen >> 29);
-
- partLen = 64 - index;
-
- /* Transform as many times as possible.
-
- */
- if (inputLen >= partLen)
- {
- MD5_memcpy( (POINTER)&context->buffer[index], (POINTER)input, partLen );
- MD5Transform( context->state, context->buffer );
-
- for (i = partLen; i + 63 < inputLen; i += 64)
- MD5Transform (context->state, (unsigned char*)&input[i]);
-
- index = 0;
- }
- else
- i = 0;
-
- /* Buffer remaining input */
- MD5_memcpy( (POINTER)&context->buffer[index], (POINTER)&input[i], inputLen-i );
-
- }
-
- /* Encodes input (UINT4) into output (unsigned char). Assumes len is
- a multiple of 4.
-
- */
-
- static void Encode (unsigned char *output, UINT4 *input, unsigned int len)
- {
- unsigned int i, j;
-
- for (i = 0, j = 0; j < len; i++, j += 4) {
- output[j] = (unsigned char)(input[i] & 0xff);
- output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
- output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
- output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
- }
- }
-
- /* Decodes input (unsigned char) into output (UINT4). Assumes len is
- a multiple of 4.
-
- */
-
- static void Decode (UINT4 *output, unsigned char *input, unsigned int len)
- {
- unsigned int i, j;
-
- for (i = 0, j = 0; j < len; i++, j += 4)
- output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | (((UINT4)input[j+2]) << 16)
- | (((UINT4)input[j+3]) << 24);
- }
-
- /* MD5 finalization. Ends an MD5 message-digest operation, writing the
- the message digest and zeroizing the context.
-
- */
-
- static void MD5Final ( unsigned char digest[16], MD5_CTX *context )
- {
- unsigned char bits[8];
- unsigned int index, padLen;
-
- /* Save number of bits */
- Encode (bits, context->count, 8);
-
- /* Pad out to 56 mod 64.
-
- */
- index = (unsigned int)((context->count[0] >> 3) & 0x3f);
- padLen = (index < 56) ? (56 - index) : (120 - index);
- MD5Update (context, PADDING(), padLen);
-
- /* Append length (before padding) */
- MD5Update (context, bits, 8);
-
- /* Store state in digest */
- Encode (digest, context->state, 16);
-
- /* Zeroize sensitive information.
-
- */
- MD5_memset ((POINTER)context, 0, sizeof (*context));
- }
-
- /* MD5 basic transformation. Transforms state based on block.
-
- */
-
- static void MD5Transform (UINT4 state[4], unsigned char block[64])
- {
- UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
-
- Decode (x, block, 64);
-
- /* Round 1 */
- FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
- FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
- FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
- FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
- FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
- FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
- FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
- FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
- FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
- FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
- FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
- FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
- FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
- FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
- FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
- FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
-
- /* Round 2 */
- GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
- GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
- GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
- GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
- GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
- GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
- GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
- GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
- GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
- GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
- GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
- GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
- GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
- GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
- GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
- GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
-
- /* Round 3 */
- HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
- HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
- HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
- HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
- HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
- HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
- HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
- HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
- HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
- HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
- HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
- HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
- HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
- HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
- HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
- HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
-
- /* Round 4 */
- II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
- II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
- II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
- II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
- II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
- II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
- II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
- II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
- II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
- II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
- II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
- II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
- II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
- II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
- II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
- II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
-
- state[0] += a;
- state[1] += b;
- state[2] += c;
- state[3] += d;
-
- /* Zeroize sensitive information.
- */
- MD5_memset ((POINTER)x, 0, sizeof (x));
- }
-
- /* Note: Replace "for loop" with standard memcpy if possible.
-
- */
- inline
- void hmac_md5_init(HMAC_MD5_CTX *hmac,
- const unsigned char *key,
- int key_len)
- {
- unsigned char k_ipad[65]; /* inner padding -
- * key XORd with ipad
- */
- unsigned char k_opad[65]; /* outer padding -
- * key XORd with opad
- */
- unsigned char tk[16];
- int i;
- /* if key is longer than 64 bytes reset it to key=MD5(key) */
- if (key_len > 64) {
-
- MD5_CTX tctx;
-
- MD5Init(&tctx);
- MD5Update(&tctx, key, key_len);
- MD5Final(tk, &tctx);
-
- key = tk;
- key_len = 16;
- }
-
- /*
- * the HMAC_MD5 transform looks like:
- *
- * MD5(K XOR opad, MD5(K XOR ipad, text))
- *
- * where K is an n byte key
- * ipad is the byte 0x36 repeated 64 times
- * opad is the byte 0x5c repeated 64 times
- * and text is the data being protected
- */
-
- /* start out by storing key in pads */
- MD5_memset(k_ipad, '\0', sizeof k_ipad);
- MD5_memset(k_opad, '\0', sizeof k_opad);
- MD5_memcpy( k_ipad, (POINTER)key, key_len);
- MD5_memcpy( k_opad, (POINTER)key, key_len);
-
- /* XOR key with ipad and opad values */
- for (i=0; i<64; i++) {
- k_ipad[i] ^= 0x36;
- k_opad[i] ^= 0x5c;
- }
-
- MD5Init(&hmac->ictx); /* init inner context */
- MD5Update(&hmac->ictx, k_ipad, 64); /* apply inner pad */
-
- MD5Init(&hmac->octx); /* init outer context */
- MD5Update(&hmac->octx, k_opad, 64); /* apply outer pad */
-
- /* scrub the pads and key context (if used) */
- MD5_memset( (POINTER)&k_ipad, 0, sizeof(k_ipad));
- MD5_memset( (POINTER)&k_opad, 0, sizeof(k_opad));
- MD5_memset( (POINTER)&tk, 0, sizeof(tk));
-
- /* and we're done. */
- }
-
- /* The precalc and import routines here rely on the fact that we pad
- * the key out to 64 bytes and use that to initialize the md5
- * contexts, and that updating an md5 context with 64 bytes of data
- * leaves nothing left over; all of the interesting state is contained
- * in the state field, and none of it is left over in the count and
- * buffer fields. So all we have to do is save the state field; we
- * can zero the others when we reload it. Which is why the decision
- * was made to pad the key out to 64 bytes in the first place. */
- inline
- void hmac_md5_precalc(HMAC_MD5_STATE *state,
- const unsigned char *key,
- int key_len)
- {
- HMAC_MD5_CTX hmac;
- unsigned lupe;
-
- hmac_md5_init(&hmac, key, key_len);
- for (lupe = 0; lupe < 4; lupe++) {
- state->istate[lupe] = htonl(hmac.ictx.state[lupe]);
- state->ostate[lupe] = htonl(hmac.octx.state[lupe]);
- }
- MD5_memset( (POINTER)&hmac, 0, sizeof(hmac));
- }
-
-
- inline
- void hmac_md5_import(HMAC_MD5_CTX *hmac,
- HMAC_MD5_STATE *state)
- {
- unsigned lupe;
- MD5_memset( (POINTER)hmac, 0, sizeof(HMAC_MD5_CTX));
- for (lupe = 0; lupe < 4; lupe++) {
- hmac->ictx.state[lupe] = ntohl(state->istate[lupe]);
- hmac->octx.state[lupe] = ntohl(state->ostate[lupe]);
- }
- /* Init the counts to account for our having applied
- * 64 bytes of key; this works out to 0x200 (64 << 3; see
- * MD5Update above...) */
- hmac->ictx.count[0] = hmac->octx.count[0] = 0x200;
- }
-
- inline
- void hmac_md5_final(unsigned char digest[HMAC_MD5_SIZE],
- HMAC_MD5_CTX *hmac)
- {
- MD5Final(digest, &hmac->ictx); /* Finalize inner md5 */
- MD5Update(&hmac->octx, digest, 16); /* Update outer ctx */
- MD5Final(digest, &hmac->octx); /* Finalize outer md5 */
- }
-
-
- void hmac_md5(const unsigned char* text, int text_len, const unsigned char* key, int key_len, unsigned char *digest)
- {
- MD5_CTX context;
-
- unsigned char k_ipad[65]; /* inner padding -
- * key XORd with ipad
- */
- unsigned char k_opad[65]; /* outer padding -
- * key XORd with opad
- */
- unsigned char tk[16];
- int i;
- /* if key is longer than 64 bytes reset it to key=MD5(key) */
- if (key_len > 64) {
-
- MD5_CTX tctx;
-
- MD5Init(&tctx);
- MD5Update(&tctx, key, key_len);
- MD5Final(tk, &tctx);
-
- key = tk;
- key_len = 16;
- }
-
- /*
- * the HMAC_MD5 transform looks like:
- *
- * MD5(K XOR opad, MD5(K XOR ipad, text))
- *
- * where K is an n byte key
- * ipad is the byte 0x36 repeated 64 times
- * opad is the byte 0x5c repeated 64 times
- * and text is the data being protected
- */
-
- /* start out by storing key in pads */
- MD5_memset(k_ipad, '\0', sizeof k_ipad);
- MD5_memset(k_opad, '\0', sizeof k_opad);
- MD5_memcpy( k_ipad, (POINTER)key, key_len);
- MD5_memcpy( k_opad, (POINTER)key, key_len);
-
- /* XOR key with ipad and opad values */
- for (i=0; i<64; i++) {
- k_ipad[i] ^= 0x36;
- k_opad[i] ^= 0x5c;
- }
- /*
- * perform inner MD5
- */
-
- MD5Init(&context); /* init context for 1st
- * pass */
- MD5Update(&context, k_ipad, 64); /* start with inner pad */
- MD5Update(&context, text, text_len); /* then text of datagram */
- MD5Final(digest, &context); /* finish up 1st pass */
-
- /*
- * perform outer MD5
- */
- MD5Init(&context); /* init context for 2nd
- * pass */
- MD5Update(&context, k_opad, 64); /* start with outer pad */
- MD5Update(&context, digest, 16); /* then results of 1st
- * hash */
- MD5Final(digest, &context); /* finish up 2nd pass */
-
- }
-}
\ No newline at end of file
diff --git a/contrib/epee/include/md5global.h b/contrib/epee/include/md5global.h
deleted file mode 100644
index afc2290193..0000000000
--- a/contrib/epee/include/md5global.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * libEtPan! -- a mail stuff library
- *
- * Copyright (C) 2001, 2005 - DINH Viet Hoa
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the libEtPan! 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 AUTHORS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * $Id: md5global.h,v 1.1.1.1 2005/03/18 20:17:28 zautrix Exp $
- */
-
-/* GLOBAL.H - RSAREF types and constants
- */
-
-#ifndef MD5GLOBAL_H
-#define MD5GLOBAL_H
-
-namespace md5
-{
-
-
- /* PROTOTYPES should be set to one if and only if the compiler supports
- function argument prototyping.
- The following makes PROTOTYPES default to 0 if it has not already
- been defined with C compiler flags.
- */
-#ifndef PROTOTYPES
-#define PROTOTYPES 0
-#endif
-
- /* POINTER defines a generic pointer type */
- typedef unsigned char *POINTER;
-
- /* UINT2 defines a two byte word */
- typedef unsigned short int UINT2;
-
- /* UINT4 defines a four byte word */
- //typedef unsigned long int UINT4;
- typedef unsigned int UINT4;
-
- /* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
- If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
- returns an empty list.
- */
-#if PROTOTYPES
-#define PROTO_LIST(list) list
-#else
-#define PROTO_LIST(list) ()
-#endif
-
-}
-
-#endif
diff --git a/contrib/epee/include/misc_language.h b/contrib/epee/include/misc_language.h
deleted file mode 100644
index d5157365c8..0000000000
--- a/contrib/epee/include/misc_language.h
+++ /dev/null
@@ -1,162 +0,0 @@
-// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
-// 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 Andrey N. Sabelnikov 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 THE COPYRIGHT OWNER 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.
-//
-
-
-
-#pragma once
-
-#include
-#include
-#include
-namespace epee
-{
-#define STD_TRY_BEGIN() try {
-
-#define STD_TRY_CATCH(where_, ret_val) \
- } \
- catch (const std::exception &e) \
- { \
- LOG_ERROR("EXCEPTION: " << where_ << ", mes: "<< e.what()); \
- return ret_val; \
- } \
- catch (...) \
- { \
- LOG_ERROR("EXCEPTION: " << where_ ); \
- return ret_val; \
- }
-
-
-
-#define AUTO_VAL_INIT(v) boost::value_initialized()
-
-namespace misc_utils
-{
- template
- t_type get_max_t_val(t_type t)
- {
- return (std::numeric_limits::max)();
- }
-
-
- template
- t_iterator move_it_forward(t_iterator it, size_t count)
- {
- while(count--)
- it++;
- return it;
- }
-
- template
- t_iterator move_it_backward(t_iterator it, size_t count)
- {
- while(count--)
- it--;
- return it;
- }
-
-
- // TEMPLATE STRUCT less
- template
- struct less_as_pod
- : public std::binary_function<_Ty, _Ty, bool>
- { // functor for operator<
- bool operator()(const _Ty& _Left, const _Ty& _Right) const
- { // apply operator< to operands
- return memcmp(&_Left, &_Right, sizeof(_Left)) < 0;
- }
- };
-
- template
- bool is_less_as_pod(const _Ty& _Left, const _Ty& _Right)
- { // apply operator< to operands
- return memcmp(&_Left, &_Right, sizeof(_Left)) < 0;
- }
-
-
- inline
- bool sleep_no_w(long ms )
- {
- boost::this_thread::sleep(
- boost::get_system_time() +
- boost::posix_time::milliseconds( std::max(ms,0) ) );
-
- return true;
- }
-
- template
- type_vec_type median(std::vector &v)
- {
- if(v.empty())
- return boost::value_initialized();
- if(v.size() == 1)
- return v[0];
-
- size_t n = (v.size()) / 2;
- std::sort(v.begin(), v.end());
- //nth_element(v.begin(), v.begin()+n-1, v.end());
- if(v.size()%2)
- {//1, 3, 5...
- return v[n];
- }else
- {//2, 4, 6...
- return (v[n-1] + v[n])/2;
- }
-
- }
-
- /************************************************************************/
- /* */
- /************************************************************************/
-
- struct call_befor_die_base
- {
- virtual ~call_befor_die_base(){}
- };
-
- typedef boost::shared_ptr auto_scope_leave_caller;
-
-
- template
- struct call_befor_die: public call_befor_die_base
- {
- t_scope_leave_handler m_func;
- call_befor_die(t_scope_leave_handler f):m_func(f)
- {}
- ~call_befor_die()
- {
- m_func();
- }
- };
-
- template
- auto_scope_leave_caller create_scope_leave_handler(t_scope_leave_handler f)
- {
- auto_scope_leave_caller slc(new call_befor_die(f));
- return slc;
- }
-
-}
-}
diff --git a/contrib/epee/include/misc_log_ex.cpp b/contrib/epee/include/misc_log_ex.cpp
deleted file mode 100644
index 0c0b441b4f..0000000000
--- a/contrib/epee/include/misc_log_ex.cpp
+++ /dev/null
@@ -1,1029 +0,0 @@
-// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
-// 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 Andrey N. Sabelnikov 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 THE COPYRIGHT OWNER BE LIABLE FOR ANY
-// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-
-#include "misc_log_ex.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include