From: Shuanglei Tao Date: Sat, 18 Aug 2018 01:39:34 +0000 (+0800) Subject: src: seprate includes from server.h X-Git-Url: http://git.prime8.dev/?a=commitdiff_plain;h=be91d56904b29f3b7b26248b3bd9c0b6db6b03cf;p=ttyd.git src: seprate includes from server.h --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e00482..50e2f6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_policy(SET CMP0048 NEW) project(ttyd VERSION "1.4.0") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE") if(CMAKE_VERSION VERSION_LESS "3.1") if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") diff --git a/src/http.c b/src/http.c index d569ce9..522ecf0 100644 --- a/src/http.c +++ b/src/http.c @@ -1,3 +1,6 @@ +#include +#include + #include "server.h" #include "html.h" @@ -98,7 +101,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user, voi goto try_to_reuse; } - if (strncmp((const char *) in, "/", 1)) { + if (strncmp((const char *) in, "/", 1) != 0) { lws_return_http_status(wsi, HTTP_STATUS_NOT_FOUND, NULL); goto try_to_reuse; } diff --git a/src/protocol.c b/src/protocol.c index 1974653..21074d5 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -1,4 +1,30 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(__OpenBSD__) || defined(__APPLE__) +#include +#elif defined(__FreeBSD__) +#include +#else +#include +#endif + +#include +#include + #include "server.h" +#include "utils.h" int send_initial_message(struct lws *wsi) { diff --git a/src/server.c b/src/server.c index a16bab0..b8d0a3b 100644 --- a/src/server.c +++ b/src/server.c @@ -1,4 +1,25 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_LWS_CONFIG_H +#include "lws_config.h" +#endif +#include +#include + #include "server.h" +#include "utils.h" + +#ifndef TTYD_VERSION +#define TTYD_VERSION "unknown" +#endif volatile bool force_exit = false; struct lws_context *context; diff --git a/src/server.h b/src/server.h index e1c6469..5e61d2a 100644 --- a/src/server.h +++ b/src/server.h @@ -1,54 +1,6 @@ -#ifdef HAVE_LWS_CONFIG_H -#include "lws_config.h" -#endif - -#ifndef TTYD_VERSION -#define TTYD_VERSION "unknown" -#endif - -#define _GNU_SOURCE - -#include -#include #include -#include -#include -#include -#include -#include -#include -#include #include #include -#include -#include -#include -#include -#include - -#ifdef __OpenBSD__ -#define STAILQ_HEAD SIMPLEQ_HEAD -#define STAILQ_ENTRY SIMPLEQ_ENTRY -#define STAILQ_INIT SIMPLEQ_INIT -#define STAILQ_INSERT_TAIL SIMPLEQ_INSERT_TAIL -#define STAILQ_EMPTY SIMPLEQ_EMPTY -#define STAILQ_FIRST SIMPLEQ_FIRST -#define STAILQ_REMOVE_HEAD SIMPLEQ_REMOVE_HEAD -#define STAILQ_FOREACH SIMPLEQ_FOREACH -#endif - -#if defined(__OpenBSD__) || defined(__APPLE__) -#include -#elif defined(__FreeBSD__) -#include -#else -#include -#endif - -#include -#include - -#include "utils.h" // client message #define INPUT '0' diff --git a/src/utils.c b/src/utils.c index ac16bd1..c4330ef 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,5 +1,3 @@ -#define _GNU_SOURCE - #include #include #include