Renamed project: libuhttp -> libuhttpd
Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
This commit is contained in:
1 parent
01503b3128
commit
62a3a563f1
24 files changed
+153
-153
No files matched your search
+51
-51
@@ -1,7 +1,7 @@
|
||||
# The version number.
|
||||
set(UHTTP_VERSION_MAJOR 0)
|
||||
set(UHTTP_VERSION_MINOR 3)
|
||||
set(UHTTP_VERSION_PATCH 0)
|
||||
set(UHTTPD_VERSION_MAJOR 0)
|
||||
set(UHTTPD_VERSION_MINOR 3)
|
||||
set(UHTTPD_VERSION_PATCH 0)
|
||||
|
||||
# Check the third party Libraries
|
||||
find_package(Libev REQUIRED)
|
||||
@@ -11,60 +11,60 @@ find_package(Lua)
|
||||
|
||||
include_directories(${LIBEV_INCLUDE_DIR} ${LUA_INCLUDE_DIR})
|
||||
set(EXTRA_LIBS ${LIBEV_LIBRARIES} ${LUA_LIBRARIES})
|
||||
set(SOURCE_FILES uhttp.c log.c buf.c ssl.c parser.c template.c)
|
||||
set(SOURCE_FILES uhttpd.c log.c buf.c ssl.c parser.c template.c)
|
||||
|
||||
set(UHTTP_DEBUG_CONFIG 0)
|
||||
option(UHTTP_DEBUG "Turn on debug" OFF)
|
||||
if(UHTTP_DEBUG)
|
||||
set(UHTTP_DEBUG_CONFIG 1)
|
||||
set(UHTTPD_DEBUG_CONFIG 0)
|
||||
option(UHTTPD_DEBUG "Turn on debug" OFF)
|
||||
if(UHTTPD_DEBUG)
|
||||
set(UHTTPD_DEBUG_CONFIG 1)
|
||||
endif()
|
||||
|
||||
option(UHTTP_DISABLE_SSL "Disable ssl support" OFF)
|
||||
option(UHTTP_USE_OPENSSL "Explicit use OpenSSL as SSL backend" OFF)
|
||||
option(UHTTP_USE_CYASSL "Explicit use CyaSSL as SSL backend" OFF)
|
||||
option(UHTTPD_DISABLE_SSL "Disable ssl support" OFF)
|
||||
option(UHTTPD_USE_OPENSSL "Explicit use OpenSSL as SSL backend" OFF)
|
||||
option(UHTTPD_USE_CYASSL "Explicit use CyaSSL as SSL backend" OFF)
|
||||
|
||||
set(UHTTP_SSL_ENABLED OFF)
|
||||
set(UHTTP_SSL_ENABLED_CONFIG 0)
|
||||
set(UHTTP_USE_OPENSSL_CONFIG 0)
|
||||
set(UHTTP_USE_CYASSL_CONFIG 0)
|
||||
set(UHTTPD_SSL_ENABLED OFF)
|
||||
set(UHTTPD_SSL_ENABLED_CONFIG 0)
|
||||
set(UHTTPD_USE_OPENSSL_CONFIG 0)
|
||||
set(UHTTPD_USE_CYASSL_CONFIG 0)
|
||||
|
||||
if(NOT UHTTP_DISABLE_SSL)
|
||||
if(UHTTP_USE_OPENSSL)
|
||||
if(NOT UHTTPD_DISABLE_SSL)
|
||||
if(UHTTPD_USE_OPENSSL)
|
||||
if(NOT OPENSSL_FOUND)
|
||||
message(FATAL_ERROR "Could NOT find OpenSSL")
|
||||
endif()
|
||||
|
||||
set(UHTTP_SSL_ENABLED ON)
|
||||
set(UHTTP_SSL_ENABLED_CONFIG 1)
|
||||
set(UHTTP_USE_OPENSSL_CONFIG 1)
|
||||
set(UHTTPD_SSL_ENABLED ON)
|
||||
set(UHTTPD_SSL_ENABLED_CONFIG 1)
|
||||
set(UHTTPD_USE_OPENSSL_CONFIG 1)
|
||||
|
||||
list(APPEND EXTRA_LIBS ${OPENSSL_LIBRARIES})
|
||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
||||
elseif(UHTTP_USE_CYASSL)
|
||||
elseif(UHTTPD_USE_CYASSL)
|
||||
if (NOT CYASSL_FOUND)
|
||||
message(FATAL_ERROR "Could NOT find CyaSSL")
|
||||
endif()
|
||||
|
||||
set(UHTTP_SSL_ENABLED ON)
|
||||
set(UHTTP_SSL_ENABLED_CONFIG 1)
|
||||
set(UHTTP_USE_CYASSL_CONFIG 1)
|
||||
set(UHTTPD_SSL_ENABLED ON)
|
||||
set(UHTTPD_SSL_ENABLED_CONFIG 1)
|
||||
set(UHTTPD_USE_CYASSL_CONFIG 1)
|
||||
|
||||
list(APPEND EXTRA_LIBS ${CYASSL_LIBRARIES})
|
||||
include_directories(${CYASSL_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
if(NOT UHTTP_SSL_ENABLED)
|
||||
if(NOT UHTTPD_SSL_ENABLED)
|
||||
if(OPENSSL_FOUND)
|
||||
set(UHTTP_SSL_ENABLED ON)
|
||||
set(UHTTP_SSL_ENABLED_CONFIG 1)
|
||||
set(UHTTP_USE_OPENSSL_CONFIG 1)
|
||||
set(UHTTPD_SSL_ENABLED ON)
|
||||
set(UHTTPD_SSL_ENABLED_CONFIG 1)
|
||||
set(UHTTPD_USE_OPENSSL_CONFIG 1)
|
||||
|
||||
list(APPEND EXTRA_LIBS ${OPENSSL_LIBRARIES})
|
||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
||||
elseif(CYASSL_FOUND)
|
||||
set(UHTTP_SSL_ENABLED ON)
|
||||
set(UHTTP_SSL_ENABLED_CONFIG 1)
|
||||
set(UHTTP_USE_CYASSL_CONFIG 1)
|
||||
set(UHTTPD_SSL_ENABLED ON)
|
||||
set(UHTTPD_SSL_ENABLED_CONFIG 1)
|
||||
set(UHTTPD_USE_CYASSL_CONFIG 1)
|
||||
|
||||
list(APPEND EXTRA_LIBS ${CYASSL_LIBRARIES})
|
||||
include_directories(${CYASSL_INCLUDE_DIR})
|
||||
@@ -72,45 +72,45 @@ if(NOT UHTTP_DISABLE_SSL)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_library(uhttp SHARED ${SOURCE_FILES})
|
||||
set_target_properties(uhttp PROPERTIES VERSION ${UHTTP_VERSION_MAJOR}.${UHTTP_VERSION_MINOR}.${UHTTP_VERSION_PATCH})
|
||||
target_link_libraries(uhttp ${EXTRA_LIBS})
|
||||
add_library(uhttpd SHARED ${SOURCE_FILES})
|
||||
set_target_properties(uhttpd PROPERTIES VERSION ${UHTTPD_VERSION_MAJOR}.${UHTTPD_VERSION_MINOR}.${UHTTPD_VERSION_PATCH})
|
||||
target_link_libraries(uhttpd ${EXTRA_LIBS})
|
||||
|
||||
# configure a header file to pass some of the CMake settings to the source code
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/uhttp/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/uhttp/config.h)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/uhttpd/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/uhttpd/config.h)
|
||||
|
||||
install(
|
||||
FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/uhttp/config.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/uhttp/uhttp.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/uhttp/log.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/uhttp/buf.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/uhttp/str.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/uhttp/parser.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/uhttpd/config.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/uhttpd/uhttpd.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/uhttpd/log.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/uhttpd/buf.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/uhttpd/str.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/uhttpd/parser.h
|
||||
DESTINATION
|
||||
include/uhttp
|
||||
include/uhttpd
|
||||
)
|
||||
|
||||
install(
|
||||
FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/uhttp.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/uhttpd.h
|
||||
DESTINATION
|
||||
include
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS uhttp LIBRARY
|
||||
TARGETS uhttpd LIBRARY
|
||||
DESTINATION lib
|
||||
)
|
||||
|
||||
message("")
|
||||
message(STATUS "UHTTP_VERSION: ${UHTTP_VERSION_MAJOR}.${UHTTP_VERSION_MINOR}.${UHTTP_VERSION_PATCH}")
|
||||
if(UHTTP_USE_OPENSSL_CONFIG)
|
||||
message(STATUS "UHTTP_SSL_ENABLED: OpenSSL")
|
||||
elseif(UHTTP_USE_CYASSL_CONFIG)
|
||||
message(STATUS "UHTTP_SSL_ENABLED: CyaSSL")
|
||||
message(STATUS "UHTTPD_VERSION: ${UHTTPD_VERSION_MAJOR}.${UHTTPD_VERSION_MINOR}.${UHTTPD_VERSION_PATCH}")
|
||||
if(UHTTPD_USE_OPENSSL_CONFIG)
|
||||
message(STATUS "UHTTPD_SSL_ENABLED: OpenSSL")
|
||||
elseif(UHTTPD_USE_CYASSL_CONFIG)
|
||||
message(STATUS "UHTTPD_SSL_ENABLED: CyaSSL")
|
||||
else()
|
||||
message(STATUS "UHTTP_SSL_ENABLED: None")
|
||||
message(STATUS "UHTTPD_SSL_ENABLED: None")
|
||||
endif()
|
||||
message(STATUS "DEBUG: ${UHTTP_DEBUG}")
|
||||
message(STATUS "DEBUG: ${UHTTPD_DEBUG}")
|
||||
message("")
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "uhttp/buf.h"
|
||||
#include "uhttp/log.h"
|
||||
#include "uhttpd/buf.h"
|
||||
#include "uhttpd/log.h"
|
||||
|
||||
int uh_buf_init(struct uh_buf *buf, size_t initial_size)
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <lua.h>
|
||||
|
||||
#include "list.h"
|
||||
#include "uhttp/uhttp.h"
|
||||
#include "uhttpd/uhttpd.h"
|
||||
|
||||
#define UH_BUFFER_SIZE 2048
|
||||
#define UH_CONNECTION_TIMEOUT 30
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#ifndef _UHTTP_CONFIG_H
|
||||
#define _UHTTP_CONFIG_H
|
||||
|
||||
#define UHTTP_VERSION_MAJOR @UHTTP_VERSION_MAJOR@
|
||||
#define UHTTP_VERSION_MINOR @UHTTP_VERSION_MINOR@
|
||||
#define UHTTP_VERSION_PATCH @UHTTP_VERSION_PATCH@
|
||||
#define UHTTP_VERSION_STRING "@UHTTP_VERSION_MAJOR@.@UHTTP_VERSION_MINOR@.@UHTTP_VERSION_PATCH@"
|
||||
|
||||
#define UHTTP_DEBUG @UHTTP_DEBUG_CONFIG@
|
||||
|
||||
#define UHTTP_SSL_ENABLED @UHTTP_SSL_ENABLED_CONFIG@
|
||||
#define UHTTP_USE_OPENSSL @UHTTP_USE_OPENSSL_CONFIG@
|
||||
#define UHTTP_USE_CYASSL @UHTTP_USE_CYASSL_CONFIG@
|
||||
|
||||
#endif
|
||||
@@ -15,9 +15,9 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _UHTTP_H
|
||||
#define _UHTTP_H
|
||||
#ifndef _UHTTPD_H
|
||||
#define _UHTTPD_H
|
||||
|
||||
#include "uhttp/uhttp.h"
|
||||
#include "uhttpd/uhttpd.h"
|
||||
|
||||
#endif
|
||||
@@ -15,8 +15,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _UHTTP_BUF_H
|
||||
#define _UHTTP_BUF_H
|
||||
#ifndef _UHTTPD_BUF_H
|
||||
#define _UHTTPD_BUF_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#ifndef _UHTTPD_CONFIG_H
|
||||
#define _UHTTPD_CONFIG_H
|
||||
|
||||
#define UHTTPD_VERSION_MAJOR @UHTTPD_VERSION_MAJOR@
|
||||
#define UHTTPD_VERSION_MINOR @UHTTPD_VERSION_MINOR@
|
||||
#define UHTTPD_VERSION_PATCH @UHTTPD_VERSION_PATCH@
|
||||
#define UHTTPD_VERSION_STRING "@UHTTPD_VERSION_MAJOR@.@UHTTPD_VERSION_MINOR@.@UHTTPD_VERSION_PATCH@"
|
||||
|
||||
#define UHTTPD_DEBUG @UHTTPD_DEBUG_CONFIG@
|
||||
|
||||
#define UHTTPD_SSL_ENABLED @UHTTPD_SSL_ENABLED_CONFIG@
|
||||
#define UHTTPD_USE_OPENSSL @UHTTPD_USE_OPENSSL_CONFIG@
|
||||
#define UHTTPD_USE_CYASSL @UHTTPD_USE_CYASSL_CONFIG@
|
||||
|
||||
#endif
|
||||
@@ -15,15 +15,15 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _UHTTP_LOG_H
|
||||
#define _UHTTP_LOG_H
|
||||
#ifndef _UHTTPD_LOG_H
|
||||
#define _UHTTPD_LOG_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
#include <syslog.h>
|
||||
#include "uhttp/config.h"
|
||||
#include "uhttpd/config.h"
|
||||
|
||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
*/
|
||||
#define uh_log(priority, format...) __uh_log(__FILENAME__, __LINE__, priority, format)
|
||||
|
||||
#if (UHTTP_DEBUG)
|
||||
#if (UHTTPD_DEBUG)
|
||||
#define uh_log_debug(format...) uh_log(LOG_DEBUG, format)
|
||||
#else
|
||||
#define uh_log_debug(format...)
|
||||
@@ -18,8 +18,8 @@
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
#ifndef _UHTTP_PARSER_H
|
||||
#define _UHTTP_PARSER_H
|
||||
#ifndef _UHTTPD_PARSER_H
|
||||
#define _UHTTPD_PARSER_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -15,8 +15,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _UHTTP_SSL_H
|
||||
#define _UHTTP_SSL_H
|
||||
#ifndef _UHTTPD_SSL_H
|
||||
#define _UHTTPD_SSL_H
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _UHTTP_STR_H
|
||||
#define _UHTTP_STR_H
|
||||
#ifndef _UHTTPD_STR_H
|
||||
#define _UHTTPD_STR_H
|
||||
|
||||
struct uh_str {
|
||||
const char *at;
|
||||
@@ -15,17 +15,17 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _UHTTP_UHTTP_H
|
||||
#define _UHTTP_UHTTP_H
|
||||
#ifndef _UHTTPD_UHTTP_H
|
||||
#define _UHTTPD_UHTTP_H
|
||||
|
||||
#include <ev.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "uhttp/config.h"
|
||||
#include "uhttp/log.h"
|
||||
#include "uhttp/buf.h"
|
||||
#include "uhttp/str.h"
|
||||
#include "uhttp/parser.h"
|
||||
#include "uhttpd/config.h"
|
||||
#include "uhttpd/log.h"
|
||||
#include "uhttpd/buf.h"
|
||||
#include "uhttpd/str.h"
|
||||
#include "uhttpd/parser.h"
|
||||
|
||||
struct uh_server;
|
||||
struct uh_connection;
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "uhttp/log.h"
|
||||
#include "uhttpd/log.h"
|
||||
|
||||
void __uh_log(const char *filename, int line, int priority, const char *format, ...)
|
||||
{
|
||||
@@ -35,7 +35,7 @@ void __uh_log(const char *filename, int line, int priority, const char *format,
|
||||
|
||||
syslog(priority, "%s", buf);
|
||||
|
||||
#if (UHTTP_DEBUG)
|
||||
#if (UHTTPD_DEBUG)
|
||||
fprintf(stderr, "%s\n", buf);
|
||||
#else
|
||||
if (priority == LOG_ERR)
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "uhttp/ssl.h"
|
||||
#include "uhttpd/ssl.h"
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "internal.h"
|
||||
#include "uhttp/uhttp.h"
|
||||
#include "uhttpd/uhttpd.h"
|
||||
|
||||
/* code types */
|
||||
#define T_TYPE_INIT 0
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "internal.h"
|
||||
#include "uhttp/uhttp.h"
|
||||
#include "uhttp/ssl.h"
|
||||
#include "uhttpd/uhttpd.h"
|
||||
#include "uhttpd/ssl.h"
|
||||
|
||||
const char *uh_version()
|
||||
{
|
||||
return UHTTP_VERSION_STRING;
|
||||
return UHTTPD_VERSION_STRING;
|
||||
}
|
||||
|
||||
static const char *http_status_str(enum http_status s)
|
||||
@@ -223,7 +223,7 @@ static void connection_read_cb(struct ev_loop *loop, ev_io *w, int revents)
|
||||
char *base;
|
||||
int len, parsered;
|
||||
|
||||
#if (UHTTP_SSL_ENABLED)
|
||||
#if (UHTTPD_SSL_ENABLED)
|
||||
if (con->flags & UH_CON_SSL_HANDSHAKE_DONE)
|
||||
goto handshake_done;
|
||||
|
||||
@@ -467,7 +467,7 @@ static void send_status_line(struct uh_connection *con, int code)
|
||||
{
|
||||
const char *reason = http_status_str(code);
|
||||
uh_printf(con, "HTTP/1.1 %d %s\r\nServer: Libuhttp %s\r\n",
|
||||
code, reason, UHTTP_VERSION_STRING);
|
||||
code, reason, UHTTPD_VERSION_STRING);
|
||||
}
|
||||
|
||||
void uh_send_head(struct uh_connection *con, int status, int length, const char *extra_headers)
|
||||
Reference in new issue
Block a user