Skip to content

Commit

Permalink
src: seprate includes from server.h
Browse files Browse the repository at this point in the history
  • Loading branch information
tsl0922 committed Aug 18, 2018
1 parent dc5f358 commit be91d56
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 51 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -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")
Expand Down
5 changes: 4 additions & 1 deletion src/http.c
@@ -1,3 +1,6 @@
#include <string.h>
#include <libwebsockets.h>

#include "server.h"
#include "html.h"

Expand Down Expand Up @@ -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;
}
Expand Down
26 changes: 26 additions & 0 deletions src/protocol.c
@@ -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) {
Expand Down
21 changes: 21 additions & 0 deletions 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;
Expand Down
48 changes: 0 additions & 48 deletions 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'
Expand Down
2 changes: 0 additions & 2 deletions src/utils.c
@@ -1,5 +1,3 @@
#define _GNU_SOURCE

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
Expand Down

0 comments on commit be91d56

Please sign in to comment.