mirror of
https://github.com/tsl0922/ttyd.git
synced 2025-12-23 20:24:20 +01:00
src: seprate includes from server.h
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#include <string.h>
|
||||
#include <libwebsockets.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
@@ -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 "utils.h"
|
||||
|
||||
int
|
||||
send_initial_message(struct lws *wsi) {
|
||||
|
||||
21
src/server.c
21
src/server.c
@@ -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 "utils.h"
|
||||
|
||||
#ifndef TTYD_VERSION
|
||||
#define TTYD_VERSION "unknown"
|
||||
#endif
|
||||
|
||||
volatile bool force_exit = false;
|
||||
struct lws_context *context;
|
||||
|
||||
48
src/server.h
48
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 <stdio.h>
|
||||
#include <stdlib.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/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
|
||||
#define INPUT '0'
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
Reference in New Issue
Block a user