src: seprate includes from server.h

This commit is contained in:
Shuanglei Tao
2018-08-18 09:39:34 +08:00
parent dc5f35896d
commit be91d56904
6 changed files with 52 additions and 51 deletions

View File

@@ -3,6 +3,7 @@ cmake_policy(SET CMP0048 NEW)
project(ttyd VERSION "1.4.0") 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_VERSION VERSION_LESS "3.1")
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")

View File

@@ -1,3 +1,6 @@
#include <string.h>
#include <libwebsockets.h>
#include "server.h" #include "server.h"
#include "html.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; 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); lws_return_http_status(wsi, HTTP_STATUS_NOT_FOUND, NULL);
goto try_to_reuse; goto try_to_reuse;
} }

View File

@@ -1,4 +1,30 @@
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/queue.h>
#include <sys/select.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <pthread.h>
#if defined(__OpenBSD__) || defined(__APPLE__)
#include <util.h>
#elif defined(__FreeBSD__)
#include <libutil.h>
#else
#include <pty.h>
#endif
#include <libwebsockets.h>
#include <json.h>
#include "server.h" #include "server.h"
#include "utils.h"
int int
send_initial_message(struct lws *wsi) { send_initial_message(struct lws *wsi) {

View File

@@ -1,4 +1,25 @@
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <getopt.h>
#include <pthread.h>
#include <signal.h>
#include <sys/stat.h>
#ifdef HAVE_LWS_CONFIG_H
#include "lws_config.h"
#endif
#include <libwebsockets.h>
#include <json.h>
#include "server.h" #include "server.h"
#include "utils.h"
#ifndef TTYD_VERSION
#define TTYD_VERSION "unknown"
#endif
volatile bool force_exit = false; volatile bool force_exit = false;
struct lws_context *context; struct lws_context *context;

View File

@@ -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 <stdio.h>
#include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#include <signal.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <getopt.h>
#include <pthread.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/queue.h> #include <sys/queue.h>
#include <sys/stat.h>
#include <sys/select.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <assert.h>
#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 <util.h>
#elif defined(__FreeBSD__)
#include <libutil.h>
#else
#include <pty.h>
#endif
#include <libwebsockets.h>
#include <json.h>
#include "utils.h"
// client message // client message
#define INPUT '0' #define INPUT '0'

View File

@@ -1,5 +1,3 @@
#define _GNU_SOURCE
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>