diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e00482f..50e2f6b1 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 d569ce97..522ecf03 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 19746536..21074d53 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 a16bab0d..b8d0a3be 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 e1c64696..5e61d2a2 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 ac16bd15..c4330ef9 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,5 +1,3 @@ -#define _GNU_SOURCE - #include #include #include