AUTH_OK, AUTH_FAIL, AUTH_ERROR
};
-char * html_cache = NULL;
-size_t html_cache_len = 0;
+static char * html_cache = NULL;
+static size_t html_cache_len = 0;
-int
+static int
check_auth(struct lws *wsi, struct pss_http *pss) {
if (server->credential == NULL)
return AUTH_OK;
return AUTH_FAIL;
}
-bool accept_gzip(struct lws *wsi) {
+static bool
+accept_gzip(struct lws *wsi) {
int hdr_length = lws_hdr_total_length(wsi, WSI_TOKEN_HTTP_ACCEPT_ENCODING);
char buf[hdr_length + 1];
int len = lws_hdr_copy(wsi, buf, sizeof(buf), WSI_TOKEN_HTTP_ACCEPT_ENCODING);
return len > 0 && strstr(buf, "gzip") != NULL;
}
-bool
+static bool
uncompress_html(char **output, size_t *output_len) {
if (html_cache == NULL || html_cache_len == 0) {
z_stream stream;
return true;
}
-void
+static void
pss_buffer_free(struct pss_http *pss) {
if (pss->buffer != (char *) index_html && pss->buffer != html_cache)
free(pss->buffer);
}
-void
+static void
access_log(struct lws *wsi, const char *path) {
char rip[50];
#include "utils.h"
// initial message list
-char initial_cmds[] = {
+static char initial_cmds[] = {
SET_WINDOW_TITLE,
SET_PREFERENCES
};
-int
+static int
send_initial_message(struct lws *wsi, int index) {
unsigned char message[LWS_PRE + 1 + 4096];
unsigned char *p = &message[LWS_PRE];
return lws_write(wsi, p, (size_t) n, LWS_WRITE_BINARY);
}
-bool
+static bool
parse_window_size(struct pss_tty *pss, int *cols, int *rows) {
char json[pss->len];
strncpy(json, pss->buffer + 1, pss->len - 1);
return true;
}
-bool
+static bool
check_host_origin(struct lws *wsi) {
int origin_length = lws_hdr_total_length(wsi, WSI_TOKEN_ORIGIN);
char buf[origin_length + 1];
return len > 0 && strcasecmp(buf, host_buf) == 0;
}
-void
+static void
pty_proc_free(struct pty_proc *proc) {
uv_read_stop((uv_stream_t *) &proc->pipe);
uv_close((uv_handle_t*) &proc->pipe, NULL);
free(proc);
}
-void
+static void
alloc_cb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) {
buf->base = xmalloc(suggested_size);
buf->len = suggested_size;
}
-void
+static void
read_cb(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) {
struct pss_tty *pss = (struct pss_tty *) stream->data;
struct pty_proc *proc = pss->proc;
lws_callback_on_writable(pss->wsi);
}
-void
+static void
child_cb(uv_signal_t *handle, int signum) {
pid_t pid;
int stat;
}
}
-int
+static int
spawn_process(struct pss_tty *pss) {
struct pty_proc *proc = pss->proc;
// append url args to arguments
return 0;
}
-void
+static void
kill_process(struct pty_proc *proc) {
if (proc->pid <= 0) return;
}
}
-void
+static void
write_cb(uv_write_t* req, int status) {
if (status != 0)
lwsl_warn("uv_write callback returned status: %d\n", status);
};
static const char *opt_string = "p:i:c:u:g:s:I:b:6aSC:K:A:Rt:T:Om:oBd:vh";
-void print_help() {
+static void
+print_help() {
fprintf(stderr, "ttyd is a tool for sharing terminal over the web\n\n"
"USAGE:\n"
" ttyd [options] <command> [<arguments...>]\n\n"
);
}
-struct server *
+static struct server *
server_new(int argc, char **argv, int start) {
struct server *ts;
size_t cmd_len = 0;
return ts;
}
-void
+static void
server_free(struct server *ts) {
if (ts == NULL)
return;
free(ts);
}
-void
+static void
signal_cb(uv_signal_t *watcher, int signum) {
char sig_name[20];
#endif
}
-int
+static int
calc_command_start(int argc, char **argv) {
// make a copy of argc and argv
int argc_copy = argc;