Skip to content

Commit

Permalink
Merge all changes from branch "router".
Browse files Browse the repository at this point in the history
  • Loading branch information
silvioprog committed Oct 1, 2018
1 parent ae3bc6f commit 2ffa404
Show file tree
Hide file tree
Showing 53 changed files with 3,200 additions and 118 deletions.
2 changes: 1 addition & 1 deletion ABIComplianceChecker.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
**Configure the build:**

```bash
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=ON -DSG_HTTPS_SUPPORT=ON -DSG_ABI_COMPLIANCE_CHECKER=ON -DSG_OLD_LIB_DIR=$HOME/libsagui-1.0.0 -DSG_OLD_LIB_VERSION=1.0.0 ..
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=ON -DSG_HTTPS_SUPPORT=ON -DSG_ABI_COMPLIANCE_CHECKER=ON -DSG_OLD_LIB_DIR=/home/USER/libsagui-1.0.0 -DSG_OLD_LIB_VERSION=1.0.0 ..
make abi_compliance_checker
```

Expand Down
20 changes: 20 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@ and was successfully tested in:
* GCC on Raspbian - version 6.3.0 [`i686` / `arm-linux-gnueabihf`]
* CLang on Raspbian - version 3.8.1 [`i686` / `armv6--linux-gnueabihf`]

# Build options

There are a few options of the Sagui building, they are:

```bash
-DSG_ABI_COMPLIANCE_CHECKER=<ON|OFF>
-DSG_BUILD_HTML=<ON|OFF>
-DSG_BUILD_PDF=<ON|OFF>
-DSG_PICKY_COMPILER=<ON|OFF>
-DPCRE2_JIT_SUPPORT=<ON|OFF>
-DSG_PVS_STUDIO=<ON|OFF>
-DSG_BUILD_EXAMPLES=<ON|OFF>
-DSG_BUILD_<EXAMPLE>_EXAMPLE=<ON|OFF>
-DSG_BUILD_<TEST>_TESTING=<ON|OFF>
-DSG_HTTPS_SUPPORT=<ON|OFF>
-DSG_PATH_ROUTING=<ON|OFF>
```

and many specific variables, like `SG_BUILD_HTML`, `SG_BUILD_PDF`, `SG_LIBSAGUI_RC`, `PCRE2_INCLUDE_DIR`, `PCRE2_JIT_SUPPORT` and so on. Please take a look at the `/cmake` directory for more information.

# Build types

One build type can be specified though the variable `CMAKE_BUILD_TYPE=<Release|Debug>`. A minimal command to prepare the release type is:
Expand Down
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ endif ()
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

option(SG_HTTPS_SUPPORT "Enable HTTPS support" OFF)
option(SG_PATH_ROUTING "Enable path routing" ON)

include(GNUInstallDirs)
include(ExternalProject)
Expand All @@ -83,6 +84,13 @@ if (SG_HTTPS_SUPPORT)
endif ()
endif ()
include(SgMHD)
if (SG_PATH_ROUTING)
include(SgPCRE2)
add_definitions(-DSG_PATH_ROUTING=1)
endif ()
if (WIN32 AND BUILD_SHARED_LIBS)
include(SgRC)
endif ()
include(SgPC)
include(SgUninstall)

Expand All @@ -104,6 +112,9 @@ endif ()

include_directories(${SG_INCLUDE_DIR})
include_directories(${MHD_INCLUDE_DIR})
if (SG_PATH_ROUTING)
include_directories(${PCRE2_INCLUDE_DIR})
endif ()

add_subdirectory(src)
add_subdirectory(examples)
Expand Down
24 changes: 2 additions & 22 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
2018-09-18 silvioprog <[email protected]>

Bump v1.1.0

Upgrade document "ABIComplianceChecker.md".

Fix #2 issued as "The authentication process doesn't allow to send a response when it is cancelled".

Handle errors using fixed buffer size.

2018-09-17 silvioprog <[email protected]>

Implements the response cleaning feature: sg_httpres_clear().

2018-08-31 silvioprog <[email protected]>

Adds steps to build for Raspbian.

2018-08-29 silvioprog <[email protected]>

Bump v1.0.3

Uses better parameter names in the sg_strerror() function.

Update the SECURITY document.
Expand Down Expand Up @@ -112,15 +92,15 @@

Fix docs output.

2018-08-10 Silvio Clecio <[email protected]>
2018-08-10 silvioprog <[email protected]>

Set theme jekyll-theme-midnight

2018-08-10 silvioprog <[email protected]>

Update issues template

2018-08-10 Silvio Clecio <[email protected]>
2018-08-10 silvioprog <[email protected]>

Update issue templates

Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Sagui is an ideal C library to develop cross-platform HTTP servers. Its core has
* Event-driven - _single-thread + main loop + select_
* Threaded - _one thread per request_
* Thread pool - _thread pool + select_
* High-performance path routing that supports:
* Regular expressions using [PCRE2](https://www.pcre.org/current/doc/html/pcre2pattern.html) [syntax](https://www.pcre.org/current/doc/html/pcre2syntax.html)
* Just-in-time optimization ([JIT](https://www.pcre.org/current/doc/html/pcre2jit.html))
* Binary search in path entry-points
* HTTPS support using [GnuTLS](https://www.gnutls.org)
* Basic authentication
* Upload/download streaming by:
Expand Down Expand Up @@ -40,6 +44,12 @@ The documentation has been written in [Doxygen](https://www.stack.nl/~dimitri/do

Check the [BUILD.md](https://github.com/risoflora/libsagui/blob/master/BUILD.md) for instructions to build the library, examples, tests and documentation, then, follow the steps in [INSTALL.md](https://github.com/risoflora/libsagui/blob/master/INSTALL.md) to install the library from sources on your system.

# Compatibility

A typical upgrade of the Sagui library does not break the ABI at all. Take a look at the [API/ABI compatibility report](https://abi-laboratory.pro/?view=timeline&l=libsagui) to compare most recent library versions.

See also [Checking backward API/ABI compatibility of Sagui library versions](https://github.com/risoflora/libsagui/blob/master/ABIComplianceChecker.md).

# Contributing

Sagui is totally open source and would not be possible without our [contributors](https://github.com/risoflora/libsagui/blob/master/THANKS). If you want to submit contributions, please fork the project on GitHub and send a pull request. You retain the copyright on your contributions. If you have questions, open a new issue at the [issues page](https://github.com/risoflora/libsagui/issues). For donations to support this project, please click the botton below.
Expand Down
3 changes: 3 additions & 0 deletions cmake/SgDoxygen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ if (SG_BUILD_HTML)
if (SG_HTTPS_SUPPORT AND GNUTLS_FOUND)
set(SG_HTTPS_SUPPORT_DOC "SG_HTTPS_SUPPORT")
endif ()
if (SG_PATH_ROUTING)
set(SG_PATH_ROUTING_DOC "SG_PATH_ROUTING")
endif ()
configure_file(${DOXYGEN_INPUT_FILE} ${DOXYGEN_OUTPUT_FILE} @ONLY)
message(STATUS "Generating Doxygen file - done")
add_custom_target(doc ALL
Expand Down
114 changes: 114 additions & 0 deletions cmake/SgPCRE2.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#.rst:
# SgPCRE2
# -------
#
# Build PCRE2.
#
# Build PCRE2 from Cordel building.
#
# ::
#
# PCRE2_INCLUDE_DIR - Directory of includes.
# PCRE2_ARCHIVE_LIB - AR archive library.
# PCRE2_JIT_SUPPORT - Enable/disable JIT support.
#

# _
# ___ __ _ __ _ _ _(_)
# / __|/ _` |/ _` | | | | |
# \__ \ (_| | (_| | |_| | |
# |___/\__,_|\__, |\__,_|_|
# |___/
#
# –– an ideal C library to develop cross-platform HTTP servers.
#
# Copyright (c) 2016-2018 Silvio Clecio <[email protected]>
#
# This file is part of Sagui library.
#
# Sagui library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Sagui library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Sagui library. If not, see <http:https://www.gnu.org/licenses/>.
#

if (__SG_PCRE2_INCLUDED)
return()
endif ()
set(__SG_PCRE2_INCLUDED ON)

option(PCRE2_JIT_SUPPORT "Enable JIT support" ON)

set(PCRE2_NAME "pcre2")
set(PCRE2_VER "10.31")
set(PCRE2_FULL_NAME "${PCRE2_NAME}-${PCRE2_VER}")
set(PCRE2_URL "https://ftp.pcre.org/pub/pcre/${PCRE2_FULL_NAME}.tar.gz")
set(PCRE2_URL_MIRROR "ftp:https://ftp.csx.cam.ac.uk/pub/software/programming/pcre/${PCRE2_FULL_NAME}.tar.gz")
set(PCRE2_SHA256 "e11ebd99dd23a7bccc9127d95d9978101b5f3cf0a6e7d25a1b1ca165a97166c4")
if (CMAKE_C_COMPILER)
set(PCRE2_OPTIONS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER})
endif ()
if (CMAKE_RC_COMPILER)
set(PCRE2_OPTIONS ${PCRE2_OPTIONS} -DCMAKE_RC_COMPILER=${CMAKE_RC_COMPILER})
endif ()
if (CMAKE_SYSTEM_NAME)
set(PCRE2_OPTIONS ${PCRE2_OPTIONS} -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME})
endif ()
if (UNIX)
set(PCRE2_OPTIONS ${PCRE2_OPTIONS} -DCMAKE_POSITION_INDEPENDENT_CODE=ON)
endif ()
if (ANDROID)
set(PCRE2_OPTIONS ${PCRE2_OPTIONS}
-DCMAKE_ANDROID_ARM_MODE=${CMAKE_ANDROID_ARM_MODE}
-DCMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION}
-DCMAKE_ANDROID_ARCH_ABI=${CMAKE_ANDROID_ARCH_ABI}
-DCMAKE_ANDROID_STANDALONE_TOOLCHAIN=${CMAKE_ANDROID_STANDALONE_TOOLCHAIN})
endif ()
set(PCRE2_OPTIONS ${PCRE2_OPTIONS}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/${PCRE2_FULL_NAME}
-DPCRE2_BUILD_PCRE2GREP=OFF
-DPCRE2_BUILD_TESTS=OFF
-DPCRE2_SUPPORT_JIT=ON
-DPCRE2_SUPPORT_PCRE2GREP_JIT=OFF
-DPCRE2_SUPPORT_PCRE2GREP_CALLOUT=OFF
-DPCRE2_SUPPORT_UNICODE=OFF
-DPCRE2_SUPPORT_VALGRIND=OFF
-DPCRE2_SUPPORT_LIBBZ2=OFF
-DPCRE2_SUPPORT_LIBZ=OFF
-DPCRE2_SUPPORT_LIBEDIT=OFF
-DPCRE2_SUPPORT_LIBREADLINE=OFF)

ExternalProject_Add(${PCRE2_FULL_NAME}
URL ${PCRE2_URL} ${PCRE2_URL_MIRROR}
URL_HASH SHA256=${PCRE2_SHA256}
TIMEOUT 15
DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/lib
PREFIX ${CMAKE_BINARY_DIR}/${PCRE2_FULL_NAME}
SOURCE_DIR ${CMAKE_SOURCE_DIR}/lib/${PCRE2_FULL_NAME}
CMAKE_ARGS ${PCRE2_OPTIONS}
LOG_DOWNLOAD ON
LOG_CONFIGURE ON
LOG_BUILD ON
LOG_INSTALL ON)

ExternalProject_Get_Property(${PCRE2_FULL_NAME} INSTALL_DIR)
set(PCRE2_INCLUDE_DIR ${INSTALL_DIR}/include)
if (WIN32 AND (CMAKE_BUILD_TYPE MATCHES "[Dd]ebug|DEBUG"))
set(PCRE2_SUFFIX "d")
endif ()
set(PCRE2_ARCHIVE_LIB ${INSTALL_DIR}/lib/lib${PCRE2_NAME}-8${PCRE2_SUFFIX}.a)
add_definitions(-DPCRE2_STATIC=1)
add_definitions(-DPCRE2_CODE_UNIT_WIDTH=8)
if (PCRE2_JIT_SUPPORT)
add_definitions(-DPCRE2_JIT_SUPPORT=1)
endif ()
unset(INSTALL_DIR)
77 changes: 77 additions & 0 deletions cmake/SgRC.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#.rst:
# SgRC
# ----
#
# RC file generation.
#
# Generates the RC file.
#
# ::
#
# SG_LIBSAGUI_RC - RC file path.

# _
# ___ __ _ __ _ _ _(_)
# / __|/ _` |/ _` | | | | |
# \__ \ (_| | (_| | |_| | |
# |___/\__,_|\__, |\__,_|_|
# |___/
#
# –– an ideal C library to develop cross-platform HTTP servers.
#
# Copyright (c) 2016-2018 Silvio Clecio <[email protected]>
#
# This file is part of Sagui library.
#
# Sagui library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Sagui library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Sagui library. If not, see <http:https://www.gnu.org/licenses/>.
#

if (__SG_RC_INCLUDED)
return()
endif ()
set(__SG_RC_INCLUDED ON)

set(SG_LIBSAGUI_RC ${CMAKE_BINARY_DIR}/libsagui.rc)

if (${CMAKE_BUILD_TYPE} MATCHES "[Dd]ebug|DEBUG")
set(FILEFLAGS VS_FF_DEBUG)
else ()
set(FILEFLAGS 0)
endif ()

set(RC_FILE_DESC "Sagui library for")
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(RC_FILE_DESC "${RC_FILE_DESC} Win64")
else ()
set(RC_FILE_DESC "${RC_FILE_DESC} Win32")
endif ()

unset(RC_FILE_DESC_MODS)
if (SG_HTTPS_SUPPORT)
list(APPEND RC_FILE_DESC_MODS "TLS")
endif ()
if (SG_PATH_ROUTING)
list(APPEND RC_FILE_DESC_MODS "PCRE2")
endif ()
if (RC_FILE_DESC_MODS)
string(REPLACE ";" "," RC_FILE_DESC_MODS "${RC_FILE_DESC_MODS}")
set(RC_FILE_DESC "${RC_FILE_DESC} (${RC_FILE_DESC_MODS})")
endif ()

configure_file(${CMAKE_MODULE_PATH}/libsagui.rc.cmake.in
${CMAKE_BINARY_DIR}/libsagui.rc @ONLY)

unset(FILEFLAGS)
unset(RC_FILE_DESC)
unset(RC_FILE_DESC_MODS)
9 changes: 9 additions & 0 deletions cmake/SgSummary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ else ()
set(_https_support "No")
endif ()

if (SG_PATH_ROUTING)
set(_routing "Yes")
else ()
set(_routing "No")
endif ()

if (SG_BUILD_EXAMPLES)
set(_build_examples "Yes")
if (SG_EXAMPLES)
Expand Down Expand Up @@ -169,6 +175,8 @@ endif ()
# Machine: ${CMAKE_C_MACHINE}
# CFLAGS: ${_cflags}
# Build: ${_build_type}-${_build_arch} (${_lib_type})
# HTTPS: ${_https_support}
# Routing: ${_routing}
# Examples: ${_build_examples}
# Docs:
# HTML: ${_build_html}
Expand All @@ -190,6 +198,7 @@ Sagui library ${VERSION} - building summary:
CFLAGS: ${_cflags}
Build: ${_build_type}-${_build_arch} (${_lib_type})
HTTPS: ${_https_support}
Routing: ${_routing}
Examples: ${_build_examples}
Docs:
HTML: ${_build_html}
Expand Down
Loading

0 comments on commit 2ffa404

Please sign in to comment.