Optimize directory organization structure
Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>main
parent
9cc3836868
commit
32f478f370
|
@ -8,7 +8,10 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/")
|
|||
|
||||
add_definitions(-O -Wall -Werror --std=gnu99 -D_GNU_SOURCE)
|
||||
|
||||
include_directories(${CMAKE_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/src)
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/include
|
||||
${CMAKE_CURRENT_BINARY_DIR}/src/include
|
||||
)
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(example)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <ev.h>
|
||||
#include <stdio.h>
|
||||
#include "uhttp.h"
|
||||
#include <uhttp.h>
|
||||
|
||||
static void signal_cb(struct ev_loop *loop, ev_signal *w, int revents)
|
||||
{
|
||||
|
@ -17,15 +17,17 @@ void route_test(struct uh_connection *con)
|
|||
struct uh_value *header_ua = uh_get_header(con, "User-Agent");
|
||||
char unescaped_name[128];
|
||||
|
||||
uh_unescape(name.at, name.len, unescaped_name, sizeof(unescaped_name));
|
||||
|
||||
uh_send_head(con, UH_STATUS_OK, -1, NULL);
|
||||
uh_printf_chunk(con, "<h1>Hello World</h1>");
|
||||
uh_printf_chunk(con, "<h1>Libuhttp v%s</h1>", uh_version());
|
||||
uh_printf_chunk(con, "<h1>Url: %.*s</h1>", (int)url->len, url->at);
|
||||
uh_printf_chunk(con, "<h1>Path: %.*s</h1>", (int)path->len, path->at);
|
||||
uh_printf_chunk(con, "<h1>Name: %.*s</h1>", (int)name.len, name.at);
|
||||
uh_printf_chunk(con, "<h1>Unescaped Name: %s</h1>", unescaped_name);
|
||||
|
||||
if (name.at) {
|
||||
uh_unescape(name.at, name.len, unescaped_name, sizeof(unescaped_name));
|
||||
uh_printf_chunk(con, "<h1>Unescaped Name: %s</h1>", unescaped_name);
|
||||
}
|
||||
|
||||
if (header_host)
|
||||
uh_printf_chunk(con, "<h1>Host: %.*s</h1>", (int)header_host->len, header_host->at);
|
||||
|
|
|
@ -3,16 +3,14 @@ set(UHTTP_VERSION_MAJOR 0)
|
|||
set(UHTTP_VERSION_MINOR 1)
|
||||
set(UHTTP_VERSION_PATCH 0)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# Check the third party Libraries
|
||||
find_package(Libev REQUIRED)
|
||||
find_package(OpenSSL)
|
||||
find_package(CyaSSL)
|
||||
|
||||
include_directories(${LIBEV_INCLUDE_DIRS} ${HTTPPARSER_INCLUDE_DIRS})
|
||||
set(EXTRA_LIBS ${LIBEV_LIBRARIES} ${HTTPPARSER_LIBRARIES})
|
||||
set(SOURCE_FILES uhttp.c uhttp_log.c uhttp_buf.c uhttp_ssl.c http_parser.c)
|
||||
include_directories(${LIBEV_INCLUDE_DIRS})
|
||||
set(EXTRA_LIBS ${LIBEV_LIBRARIES})
|
||||
set(SOURCE_FILES uhttp.c log.c buf.c ssl.c http_parser.c)
|
||||
|
||||
set(UHTTP_DEBUG_CONFIG 0)
|
||||
option(UHTTP_DEBUG "Turn on debug" OFF)
|
||||
|
@ -78,11 +76,24 @@ set_target_properties(uhttp PROPERTIES VERSION ${UHTTP_VERSION_MAJOR}.${UHTTP_VE
|
|||
target_link_libraries(uhttp ${EXTRA_LIBS})
|
||||
|
||||
# configure a header file to pass some of the CMake settings to the source code
|
||||
configure_file(uhttp_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/uhttp_config.h)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/uhttp/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/uhttp/config.h)
|
||||
|
||||
install(
|
||||
FILES uhttp.h ${CMAKE_CURRENT_BINARY_DIR}/uhttp_config.h uhttp_log.h uhttp_buf.h
|
||||
DESTINATION include/uhttp
|
||||
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/http_parser.h
|
||||
DESTINATION
|
||||
include/uhttp
|
||||
)
|
||||
|
||||
install(
|
||||
FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/uhttp.h
|
||||
DESTINATION
|
||||
include
|
||||
)
|
||||
|
||||
install(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "uhttp_buf.h"
|
||||
#include "uhttp_log.h"
|
||||
#include "uhttp/buf.h"
|
||||
#include "uhttp/log.h"
|
||||
|
||||
int uh_buf_init(struct uh_buf *buf, size_t initial_size)
|
||||
{
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef _UHTTP_INTERNAL_H
|
||||
#define _UHTTP_INTERNAL_H
|
||||
|
||||
#include "http_parser.h"
|
||||
#include "uhttp/http_parser.h"
|
||||
#include "list.h"
|
||||
#include "uhttp.h"
|
||||
#include "uhttp/uhttp.h"
|
||||
|
||||
#define UH_BUFFER_SIZE 2048
|
||||
#define UH_CONNECTION_TIMEOUT 30
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef _UHTTP_BASE_H
|
||||
#define _UHTTP_BASE_H
|
||||
|
||||
#include "uhttp/uhttp.h"
|
||||
|
||||
#endif
|
|
@ -6,7 +6,7 @@
|
|||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
#include <syslog.h>
|
||||
#include "uhttp_config.h"
|
||||
#include "uhttp/config.h"
|
||||
|
||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef _UHTTP_SSL_H
|
||||
#define _UHTTP_SSL_H
|
||||
|
||||
#include "uhttp_internal.h"
|
||||
#include "internal.h"
|
||||
|
||||
#if (UHTTP_USE_OPENSSL)
|
||||
#include <openssl/ssl.h>
|
|
@ -2,9 +2,9 @@
|
|||
#define _UHTTP_H
|
||||
|
||||
#include <ev.h>
|
||||
#include "uhttp_config.h"
|
||||
#include "uhttp_log.h"
|
||||
#include "uhttp_buf.h"
|
||||
#include "uhttp/config.h"
|
||||
#include "uhttp/log.h"
|
||||
#include "uhttp/buf.h"
|
||||
|
||||
/* HTTP Status Codes */
|
||||
#define UH_STATUS_MAP(XX) \
|
|
@ -1,4 +1,4 @@
|
|||
#include "uhttp_log.h"
|
||||
#include "uhttp/log.h"
|
||||
|
||||
void __uh_log(const char *filename, int line, int priority, const char *format, ...)
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
#include "uhttp_ssl.h"
|
||||
#include "uhttp/ssl.h"
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
|
|
@ -5,9 +5,9 @@
|
|||
#include <assert.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "uhttp.h"
|
||||
#include "uhttp_internal.h"
|
||||
#include "uhttp_ssl.h"
|
||||
#include "uhttp/uhttp.h"
|
||||
#include "internal.h"
|
||||
#include "uhttp/ssl.h"
|
||||
|
||||
const char *uh_version()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue