This repository was archived by the owner on Sep 14, 2023. It is now read-only.
forked from Gregwar/mongoose-cpp
-
Notifications
You must be signed in to change notification settings - Fork 1
Massive cleanup #4
Open
saidinesh5
wants to merge
5
commits into
master
Choose a base branch
from
multithreaded-server
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
570a143
Massive cleanup
saidinesh5 91b3e15
Move all weak_ptr -> const shared_ptr&
saidinesh5 a1d9149
Made AbstractRequestPreprocessor into AbstractRequestCoprocessor
saidinesh5 ac555a8
Request::isValid is not an std::atomic_bool
saidinesh5 e90ac6c
configure cmake to use c++11
saidinesh5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,37 @@ | ||
| build | ||
| # Prerequisites | ||
| *.d | ||
|
|
||
| # Compiled Object files | ||
| *.slo | ||
| *.lo | ||
| *.o | ||
| *.obj | ||
|
|
||
| # Precompiled Headers | ||
| *.gch | ||
| *.pch | ||
|
|
||
| # Compiled Dynamic libraries | ||
| *.so | ||
| *.dylib | ||
| *.dll | ||
|
|
||
| # Fortran module files | ||
| *.mod | ||
| *.smod | ||
|
|
||
| # Compiled Static libraries | ||
| *.lai | ||
| *.la | ||
| *.a | ||
| *.lib | ||
|
|
||
| # Executables | ||
| *.exe | ||
| *.out | ||
| *.app | ||
|
|
||
|
|
||
| build/* | ||
| *.user | ||
| *.autosave |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [submodule "mongoose"] | ||
| path = vendor/mongoose | ||
| url = https://github.com/saidinesh5/mongoose/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,156 +1,104 @@ | ||
| cmake_minimum_required (VERSION 2.6) | ||
| project (mongoose) | ||
| find_package (Threads) | ||
|
|
||
| option (MAIN | ||
| "Compile the main" OFF) | ||
|
|
||
| option (EXAMPLES | ||
| "Compile examples" OFF) | ||
|
|
||
| option (WEBSOCKET | ||
| "Enables websocket" OFF) | ||
|
|
||
| option (CPP_BINDING | ||
| "Enables C++ binding" ON) | ||
|
|
||
| option (HAS_JSONCPP | ||
| "Enables JsonCpp" OFF) | ||
| option (MAIN "Compile the main" OFF) | ||
| option (EXAMPLES "Compile examples" ON) | ||
| option (HAS_JSON11 "Enables support for Json11 (https://github.com/dropbox/json11)" OFF) | ||
| option (ENABLE_REGEX_URL "Enable url regex matching dispatcher" OFF) | ||
|
|
||
| option (ENABLE_STATS | ||
| "Enable server statistics" ON) | ||
| set (JSON11_DIR "${PROJECT_SOURCE_DIR}/../json11" CACHE STRING "Json11 (https://github.com/dropbox/json11) directory") | ||
|
|
||
| option (ENABLE_REGEX_URL | ||
| "Enable url regex matching dispatcher" OFF) | ||
|
|
||
| set (JSONCPP_DIR "${PROJECT_SOURCE_DIR}/../jsoncpp" | ||
| CACHE STRING "Json C++ directory") | ||
|
|
||
| set (SOURCES | ||
| mongoose.c | ||
| ) | ||
|
|
||
| set (MONGOOSE_CPP "${PROJECT_SOURCE_DIR}/mongoose") | ||
| if (CMAKE_VERSION VERSION_LESS "3.1") | ||
| if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||
| set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") | ||
| endif () | ||
| else () | ||
| set (CMAKE_CXX_STANDARD 11) | ||
| endif () | ||
|
|
||
| include_directories ("${PROJECT_SOURCE_DIR}") | ||
|
|
||
| if (ENABLE_STATS) | ||
| add_definitions("-DENABLE_STATS") | ||
| endif (ENABLE_STATS) | ||
| set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules") | ||
| include(GetVersionFromGitTag) | ||
|
|
||
| if (ENABLE_REGEX_URL) | ||
| add_definitions("-DENABLE_REGEX_URL") | ||
| SET (CMAKE_CXX_FLAGS "-std=c++11") | ||
| endif (ENABLE_REGEX_URL) | ||
|
|
||
| if (CPP_BINDING) | ||
| set (SOURCES | ||
| ${SOURCES} | ||
| ${MONGOOSE_CPP}/Utils.cpp | ||
| ${MONGOOSE_CPP}/Controller.cpp | ||
| ${MONGOOSE_CPP}/Mutex.cpp | ||
| ${MONGOOSE_CPP}/Request.cpp | ||
| ${MONGOOSE_CPP}/Response.cpp | ||
| ${MONGOOSE_CPP}/Server.cpp | ||
| ${MONGOOSE_CPP}/Session.cpp | ||
| ${MONGOOSE_CPP}/Sessions.cpp | ||
| ${MONGOOSE_CPP}/StreamResponse.cpp | ||
| ${MONGOOSE_CPP}/UploadFile.cpp | ||
| ${MONGOOSE_CPP}/WebController.cpp | ||
| ) | ||
|
|
||
| if (HAS_JSONCPP) | ||
| set (SOURCES | ||
| ${SOURCES} | ||
| ${MONGOOSE_CPP}/JsonResponse.cpp | ||
| ${MONGOOSE_CPP}/JsonController.cpp | ||
| ) | ||
|
|
||
| include_directories ("${JSONCPP_DIR}/include/") | ||
| endif (HAS_JSONCPP) | ||
|
|
||
| if (WEBSOCKET) | ||
| set (SOURCES | ||
| ${SOURCES} | ||
| ${MONGOOSE_CPP}/WebSocket.cpp | ||
| ${MONGOOSE_CPP}/WebSockets.cpp | ||
| ) | ||
| endif (WEBSOCKET) | ||
|
|
||
| include_directories ("${MONGOOSE_CPP}") | ||
| endif (CPP_BINDING) | ||
|
|
||
| if (NOT WEBSOCKET) | ||
| add_definitions("-DNO_WEBSOCKET") | ||
| endif (NOT WEBSOCKET) | ||
|
|
||
| # Adding dl | ||
| if (NOT WIN32) | ||
| set (EXTRA_LIBS ${EXTRA_LIBS} dl) | ||
| endif (NOT WIN32) | ||
| include_directories(${CMAKE_BINARY_DIR}) | ||
| include_directories ("${PROJECT_SOURCE_DIR}/lib") | ||
| include_directories ("vendor/mongoose") | ||
| include_directories ("vendor/libyuarel") | ||
| add_definitions("-DMG_ENABLE_CALLBACK_USERDATA") | ||
| add_definitions("-DMG_ENABLE_HTTP_STREAMING_MULTIPART") | ||
| add_definitions("-DMG_ENABLE_THREADSAFE_MBUF") | ||
| add_definitions("-DMG_ENABLE_HTTP_WEBSOCKET=0") | ||
|
|
||
| find_package (Threads) | ||
|
|
||
| set(HEADERS | ||
| lib/Utils.h | ||
| lib/Controller.h | ||
| lib/Request.h | ||
| lib/AbstractRequestCoprocessor.h | ||
| lib/Response.h | ||
| lib/Server.h | ||
| lib/Session.h | ||
| lib/Sessions.h | ||
| ) | ||
|
|
||
| set(SOURCES | ||
| lib/Utils.cpp | ||
| lib/Controller.cpp | ||
| lib/Request.cpp | ||
| lib/Response.cpp | ||
| lib/Server.cpp | ||
| lib/Session.cpp | ||
| lib/Sessions.cpp | ||
| vendor/mongoose/mongoose.c | ||
| vendor/libyuarel/yuarel.c | ||
| ) | ||
|
|
||
| # Adding sockets for Win32 | ||
| if (WIN32) | ||
| set (EXTRA_LIBS ${EXTRA_LIBS} ws2_32) | ||
| else(WIN32) | ||
| set (EXTRA_LIBS ${EXTRA_LIBS} dl) | ||
| endif (WIN32) | ||
|
|
||
| # Compiling library | ||
| add_library (mongoose ${SOURCES}) | ||
| target_link_libraries (mongoose ${EXTRA_LIBS} ${CMAKE_THREAD_LIBS_INIT}) | ||
|
|
||
| if (HAS_JSONCPP) | ||
| target_link_libraries (mongoose json) | ||
| endif (HAS_JSONCPP) | ||
|
|
||
| if (EXAMPLES OR MAIN) | ||
| if (HAS_JSONCPP) | ||
| add_subdirectory("${JSONCPP_DIR}" jsoncpp) | ||
| endif (HAS_JSONCPP) | ||
| endif () | ||
| if (HAS_JSON11) | ||
| add_definitions("-DHAS_JSON11") | ||
| include_directories ("${JSON11_DIR}/include/") | ||
| link_directories("${JSON11_DIR}/lib/") | ||
| target_link_libraries (mongoose json11) | ||
| endif (HAS_JSON11) | ||
|
|
||
| # Compiling executable | ||
| if (MAIN) | ||
| add_executable (main main.c) | ||
| target_link_libraries (main mongoose) | ||
| endif (MAIN) | ||
|
|
||
| # Compiling tests | ||
| if (EXAMPLES) | ||
| add_executable (post examples/post.c) | ||
| target_link_libraries (post mongoose) | ||
|
|
||
| if (NOT WIN32) | ||
| add_executable (hello examples/hello.c) | ||
| target_link_libraries (hello mongoose) | ||
| endif (NOT WIN32) | ||
|
|
||
| if (CPP_BINDING) | ||
| add_executable (helloworld examples/helloworld.cpp) | ||
| add_executable (basic_auth examples/basic_auth.cpp) | ||
| target_link_libraries (helloworld mongoose) | ||
| target_link_libraries (basic_auth mongoose) | ||
|
|
||
| add_executable (cpp examples/main.cpp) | ||
| target_link_libraries (cpp mongoose) | ||
|
|
||
| if (HAS_JSONCPP) | ||
| add_executable (json_api examples/json.cpp) | ||
| target_link_libraries (json_api mongoose) | ||
| endif (HAS_JSONCPP) | ||
|
|
||
| if (WEBSOCKET) | ||
| add_executable (cpp_websocket examples/websocket.cpp) | ||
| target_link_libraries (cpp_websocket mongoose) | ||
| endif (WEBSOCKET) | ||
| endif (CPP_BINDING) | ||
| add_executable (basic_auth examples/basic_auth.cpp) | ||
| target_link_libraries (basic_auth mongoose) | ||
|
|
||
| add_executable (examples examples/examples.cpp) | ||
| target_link_libraries (examples mongoose) | ||
| if (HAS_JSON11) | ||
| target_link_libraries (examples json11) | ||
| endif (HAS_JSON11) | ||
| endif (EXAMPLES) | ||
|
|
||
| # install | ||
| set (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The directory the headers are installed in") | ||
| configure_file(MongooseConfig.cmake.in MongooseConfig.cmake @ONLY) | ||
| set (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/mongoose-cpp/" CACHE PATH "The directory the headers are installed in") | ||
| set (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/" CACHE PATH "The directory the library is installed in") | ||
|
|
||
| install (FILES mongoose.h DESTINATION "${INCLUDE_INSTALL_DIR}") | ||
| install (DIRECTORY mongoose DESTINATION "${INCLUDE_INSTALL_DIR}" PATTERN "*.cpp" EXCLUDE) | ||
| install (FILES ${HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}") | ||
| install (TARGETS mongoose DESTINATION lib EXPORT mongoose-targets) | ||
| install (EXPORT mongoose-targets DESTINATION "lib/cmake/mongoose" FILE MongooseTargets.cmake) | ||
|
|
||
| configure_file(MongooseConfig.cmake.in MongooseConfig.cmake @ONLY) | ||
| configure_file("version.h.in" "version.h" @ONLY) | ||
|
|
||
| install (FILES ${CMAKE_CURRENT_BINARY_DIR}/MongooseConfig.cmake DESTINATION "lib/cmake/mongoose") | ||
| install (FILES ${CMAKE_CURRENT_BINARY_DIR}/version.h DESTINATION "${INCLUDE_INSTALL_DIR}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,24 @@ | ||
| The MIT License | ||
|
|
||
| Copyright (c) 2007-2019 Dinesh Manajipet <dinesh.manajipet@proemion.com> | ||
| Copyright (c) 2004-2013 Sergey Lyubka <valenok@gmail.com> | ||
| Copyright (c) 2013 Cesanta Software Limited | ||
| All rights reserved | ||
|
|
||
| This code is dual-licensed: you can redistribute it and/or modify | ||
| it under the terms of the GNU General Public License version 2 as | ||
| published by the Free Software Foundation. For the terms of this | ||
| license, see http://www.gnu.org/licenses. | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in | ||
| all copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| THE SOFTWARE. | ||
|
|
||
| You are free to use this code under the terms of the GNU General | ||
| Public License, but WITHOUT ANY WARRANTY; without even the implied | ||
| warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| See the GNU General Public License for more details. | ||
|
|
||
| Alternatively, you can license this code under a commercial | ||
| license, as set out in http://cesanta.com/products.html. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Has been the license changed even on the upstream mongoose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh there are 2 licenses. One is the license of upstream mongoose C library - which is GPL something and commercial something.
Then there is the license of the mongoose-cpp fork we started off with. That was a "fork" of mongoose C library - but the license is MIT. With this pull request - the upstream mongoose is just a git submodule inside vendor/ , and we rewrote so much of the mongoose-cpp library - thought to update the license.